framepexls-ui-lib 0.1.4

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.
Files changed (125) hide show
  1. package/dist/ActionIconButton.d.mts +11 -0
  2. package/dist/ActionIconButton.d.ts +11 -0
  3. package/dist/ActionIconButton.js +71 -0
  4. package/dist/ActionIconButton.mjs +41 -0
  5. package/dist/AppTopbar.d.mts +17 -0
  6. package/dist/AppTopbar.d.ts +17 -0
  7. package/dist/AppTopbar.js +51 -0
  8. package/dist/AppTopbar.mjs +31 -0
  9. package/dist/AvatarSquare.d.mts +16 -0
  10. package/dist/AvatarSquare.d.ts +16 -0
  11. package/dist/AvatarSquare.js +82 -0
  12. package/dist/AvatarSquare.mjs +52 -0
  13. package/dist/Badge.d.mts +13 -0
  14. package/dist/Badge.d.ts +13 -0
  15. package/dist/Badge.js +65 -0
  16. package/dist/Badge.mjs +45 -0
  17. package/dist/BadgeCluster.d.mts +17 -0
  18. package/dist/BadgeCluster.d.ts +17 -0
  19. package/dist/BadgeCluster.js +125 -0
  20. package/dist/BadgeCluster.mjs +95 -0
  21. package/dist/Breadcrumb.d.mts +11 -0
  22. package/dist/Breadcrumb.d.ts +11 -0
  23. package/dist/Breadcrumb.js +42 -0
  24. package/dist/Breadcrumb.mjs +12 -0
  25. package/dist/Button.d.mts +15 -0
  26. package/dist/Button.d.ts +15 -0
  27. package/dist/Button.js +72 -0
  28. package/dist/Button.mjs +52 -0
  29. package/dist/CalendarPanel.d.mts +13 -0
  30. package/dist/CalendarPanel.d.ts +13 -0
  31. package/dist/CalendarPanel.js +110 -0
  32. package/dist/CalendarPanel.mjs +90 -0
  33. package/dist/ChartCard.d.mts +15 -0
  34. package/dist/ChartCard.d.ts +15 -0
  35. package/dist/ChartCard.js +44 -0
  36. package/dist/ChartCard.mjs +24 -0
  37. package/dist/CheckboxPillsGroup.d.mts +28 -0
  38. package/dist/CheckboxPillsGroup.d.ts +28 -0
  39. package/dist/CheckboxPillsGroup.js +186 -0
  40. package/dist/CheckboxPillsGroup.mjs +156 -0
  41. package/dist/ColumnSelector.d.mts +17 -0
  42. package/dist/ColumnSelector.d.ts +17 -0
  43. package/dist/ColumnSelector.js +74 -0
  44. package/dist/ColumnSelector.mjs +54 -0
  45. package/dist/ComboSelect.d.mts +46 -0
  46. package/dist/ComboSelect.d.ts +46 -0
  47. package/dist/ComboSelect.js +442 -0
  48. package/dist/ComboSelect.mjs +412 -0
  49. package/dist/DateTimeField.d.mts +22 -0
  50. package/dist/DateTimeField.d.ts +22 -0
  51. package/dist/DateTimeField.js +409 -0
  52. package/dist/DateTimeField.mjs +379 -0
  53. package/dist/Dialog.d.mts +82 -0
  54. package/dist/Dialog.d.ts +82 -0
  55. package/dist/Dialog.js +408 -0
  56. package/dist/Dialog.mjs +368 -0
  57. package/dist/Dropdown.d.mts +52 -0
  58. package/dist/Dropdown.d.ts +52 -0
  59. package/dist/Dropdown.js +333 -0
  60. package/dist/Dropdown.mjs +313 -0
  61. package/dist/EmptyState.d.mts +8 -0
  62. package/dist/EmptyState.d.ts +8 -0
  63. package/dist/EmptyState.js +35 -0
  64. package/dist/EmptyState.mjs +15 -0
  65. package/dist/InfoGrid.d.mts +20 -0
  66. package/dist/InfoGrid.d.ts +20 -0
  67. package/dist/InfoGrid.js +67 -0
  68. package/dist/InfoGrid.mjs +47 -0
  69. package/dist/Input.d.mts +20 -0
  70. package/dist/Input.d.ts +20 -0
  71. package/dist/Input.js +85 -0
  72. package/dist/Input.mjs +55 -0
  73. package/dist/Money.d.mts +8 -0
  74. package/dist/Money.d.ts +8 -0
  75. package/dist/Money.js +30 -0
  76. package/dist/Money.mjs +10 -0
  77. package/dist/OrderButton.d.mts +11 -0
  78. package/dist/OrderButton.d.ts +11 -0
  79. package/dist/OrderButton.js +39 -0
  80. package/dist/OrderButton.mjs +19 -0
  81. package/dist/Pagination.d.mts +12 -0
  82. package/dist/Pagination.d.ts +12 -0
  83. package/dist/Pagination.js +71 -0
  84. package/dist/Pagination.mjs +51 -0
  85. package/dist/SearchInput.d.mts +17 -0
  86. package/dist/SearchInput.d.ts +17 -0
  87. package/dist/SearchInput.js +116 -0
  88. package/dist/SearchInput.mjs +86 -0
  89. package/dist/Select.d.mts +31 -0
  90. package/dist/Select.d.ts +31 -0
  91. package/dist/Select.js +293 -0
  92. package/dist/Select.mjs +263 -0
  93. package/dist/StatCard.d.mts +15 -0
  94. package/dist/StatCard.d.ts +15 -0
  95. package/dist/StatCard.js +47 -0
  96. package/dist/StatCard.mjs +27 -0
  97. package/dist/Steps.d.mts +31 -0
  98. package/dist/Steps.d.ts +31 -0
  99. package/dist/Steps.js +123 -0
  100. package/dist/Steps.mjs +99 -0
  101. package/dist/Table.d.mts +31 -0
  102. package/dist/Table.d.ts +31 -0
  103. package/dist/Table.js +153 -0
  104. package/dist/Table.mjs +117 -0
  105. package/dist/TimeAgo.d.mts +12 -0
  106. package/dist/TimeAgo.d.ts +12 -0
  107. package/dist/TimeAgo.js +104 -0
  108. package/dist/TimeAgo.mjs +74 -0
  109. package/dist/TimePanel.d.mts +14 -0
  110. package/dist/TimePanel.d.ts +14 -0
  111. package/dist/TimePanel.js +145 -0
  112. package/dist/TimePanel.mjs +125 -0
  113. package/dist/TimePopover.d.mts +33 -0
  114. package/dist/TimePopover.d.ts +33 -0
  115. package/dist/TimePopover.js +441 -0
  116. package/dist/TimePopover.mjs +406 -0
  117. package/dist/iconos/index.d.mts +60 -0
  118. package/dist/iconos/index.d.ts +60 -0
  119. package/dist/iconos/index.js +621 -0
  120. package/dist/iconos/index.mjs +548 -0
  121. package/dist/index.d.mts +32 -0
  122. package/dist/index.d.ts +32 -0
  123. package/dist/index.js +141 -0
  124. package/dist/index.mjs +70 -0
  125. package/package.json +178 -0
@@ -0,0 +1,17 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type Props = {
4
+ value: string;
5
+ onChange: (v: string) => void;
6
+ placeholder?: string;
7
+ className?: string;
8
+ minWidthClasses?: string;
9
+ fit?: boolean;
10
+ clearable?: boolean;
11
+ disabled?: boolean;
12
+ id?: string;
13
+ label?: string;
14
+ };
15
+ declare function SearchInput({ value, onChange, placeholder, className, minWidthClasses, fit, clearable, disabled, id, label, }: Props): react_jsx_runtime.JSX.Element;
16
+
17
+ export { SearchInput as default };
@@ -0,0 +1,17 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type Props = {
4
+ value: string;
5
+ onChange: (v: string) => void;
6
+ placeholder?: string;
7
+ className?: string;
8
+ minWidthClasses?: string;
9
+ fit?: boolean;
10
+ clearable?: boolean;
11
+ disabled?: boolean;
12
+ id?: string;
13
+ label?: string;
14
+ };
15
+ declare function SearchInput({ value, onChange, placeholder, className, minWidthClasses, fit, clearable, disabled, id, label, }: Props): react_jsx_runtime.JSX.Element;
16
+
17
+ export { SearchInput as default };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var SearchInput_exports = {};
31
+ __export(SearchInput_exports, {
32
+ default: () => SearchInput
33
+ });
34
+ module.exports = __toCommonJS(SearchInput_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_react = __toESM(require("react"));
37
+ function SearchInput({
38
+ value,
39
+ onChange,
40
+ placeholder,
41
+ className,
42
+ minWidthClasses = "min-w-[12rem] sm:min-w-[16rem] md:min-w-[20rem]",
43
+ fit = false,
44
+ clearable = true,
45
+ disabled = false,
46
+ id,
47
+ label
48
+ }) {
49
+ const autoId = import_react.default.useId();
50
+ const inputId = id != null ? id : autoId;
51
+ const widthClasses = fit ? "w-auto min-w-0 max-w-full" : `w-full ${minWidthClasses}`;
52
+ const clear = () => onChange("");
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { htmlFor: inputId, className: `relative ${widthClasses} ${className != null ? className : ""}`, children: [
54
+ label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: label }),
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ "input",
57
+ {
58
+ id: inputId,
59
+ type: "search",
60
+ role: "searchbox",
61
+ value,
62
+ disabled,
63
+ onChange: (e) => onChange(e.target.value),
64
+ placeholder: placeholder != null ? placeholder : "Buscar...",
65
+ className: [
66
+ "w-full rounded-2xl border bg-white px-4 py-2.5 text-sm outline-none ring-0",
67
+ "pr-10",
68
+ // espacio para el icono
69
+ "placeholder:text-slate-400",
70
+ "border-slate-200 focus:border-blue-300 focus:ring-2 focus:ring-blue-200",
71
+ "dark:border-white/10 dark:bg-[#0e0d0e] dark:focus:border-blue-500 dark:focus:ring-blue-900/40",
72
+ disabled ? "opacity-60 cursor-not-allowed" : ""
73
+ ].join(" "),
74
+ onKeyDown: (e) => {
75
+ if (clearable && !disabled && value && e.key === "Escape") {
76
+ e.preventDefault();
77
+ clear();
78
+ }
79
+ }
80
+ }
81
+ ),
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
83
+ "svg",
84
+ {
85
+ viewBox: "0 0 24 24",
86
+ className: "pointer-events-none absolute right-3 top-1/2 h-5 w-5 -translate-y-1/2 opacity-50",
87
+ fill: "none",
88
+ stroke: "currentColor",
89
+ strokeWidth: "2",
90
+ "aria-hidden": "true",
91
+ children: [
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m21 21-4.3-4.3" }),
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "11", cy: "11", r: "7" })
94
+ ]
95
+ }
96
+ ),
97
+ clearable && !disabled && value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
+ "button",
99
+ {
100
+ type: "button",
101
+ onClick: clear,
102
+ className: "absolute right-9 top-1/2 -translate-y-1/2 grid h-6 w-6 place-items-center rounded-md text-slate-400 hover:text-slate-700 hover:bg-slate-100 dark:hover:bg-white/10",
103
+ "aria-label": "Limpiar b\xFAsqueda",
104
+ title: "Limpiar",
105
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
106
+ "path",
107
+ {
108
+ fillRule: "evenodd",
109
+ d: "M10 8.586l3.536-3.536a1 1 0 111.414 1.414L11.414 10l3.536 3.536a1 1 0 01-1.414 1.414L10 11.414l-3.536 3.536a1 1 0 01-1.414-1.414L8.586 10 5.05 6.464A1 1 0 116.464 5.05L10 8.586z",
110
+ clipRule: "evenodd"
111
+ }
112
+ ) })
113
+ }
114
+ )
115
+ ] });
116
+ }
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import React from "react";
4
+ function SearchInput({
5
+ value,
6
+ onChange,
7
+ placeholder,
8
+ className,
9
+ minWidthClasses = "min-w-[12rem] sm:min-w-[16rem] md:min-w-[20rem]",
10
+ fit = false,
11
+ clearable = true,
12
+ disabled = false,
13
+ id,
14
+ label
15
+ }) {
16
+ const autoId = React.useId();
17
+ const inputId = id != null ? id : autoId;
18
+ const widthClasses = fit ? "w-auto min-w-0 max-w-full" : `w-full ${minWidthClasses}`;
19
+ const clear = () => onChange("");
20
+ return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: `relative ${widthClasses} ${className != null ? className : ""}`, children: [
21
+ label && /* @__PURE__ */ jsx("span", { className: "sr-only", children: label }),
22
+ /* @__PURE__ */ jsx(
23
+ "input",
24
+ {
25
+ id: inputId,
26
+ type: "search",
27
+ role: "searchbox",
28
+ value,
29
+ disabled,
30
+ onChange: (e) => onChange(e.target.value),
31
+ placeholder: placeholder != null ? placeholder : "Buscar...",
32
+ className: [
33
+ "w-full rounded-2xl border bg-white px-4 py-2.5 text-sm outline-none ring-0",
34
+ "pr-10",
35
+ // espacio para el icono
36
+ "placeholder:text-slate-400",
37
+ "border-slate-200 focus:border-blue-300 focus:ring-2 focus:ring-blue-200",
38
+ "dark:border-white/10 dark:bg-[#0e0d0e] dark:focus:border-blue-500 dark:focus:ring-blue-900/40",
39
+ disabled ? "opacity-60 cursor-not-allowed" : ""
40
+ ].join(" "),
41
+ onKeyDown: (e) => {
42
+ if (clearable && !disabled && value && e.key === "Escape") {
43
+ e.preventDefault();
44
+ clear();
45
+ }
46
+ }
47
+ }
48
+ ),
49
+ /* @__PURE__ */ jsxs(
50
+ "svg",
51
+ {
52
+ viewBox: "0 0 24 24",
53
+ className: "pointer-events-none absolute right-3 top-1/2 h-5 w-5 -translate-y-1/2 opacity-50",
54
+ fill: "none",
55
+ stroke: "currentColor",
56
+ strokeWidth: "2",
57
+ "aria-hidden": "true",
58
+ children: [
59
+ /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" }),
60
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "7" })
61
+ ]
62
+ }
63
+ ),
64
+ clearable && !disabled && value && /* @__PURE__ */ jsx(
65
+ "button",
66
+ {
67
+ type: "button",
68
+ onClick: clear,
69
+ className: "absolute right-9 top-1/2 -translate-y-1/2 grid h-6 w-6 place-items-center rounded-md text-slate-400 hover:text-slate-700 hover:bg-slate-100 dark:hover:bg-white/10",
70
+ "aria-label": "Limpiar b\xFAsqueda",
71
+ title: "Limpiar",
72
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
73
+ "path",
74
+ {
75
+ fillRule: "evenodd",
76
+ d: "M10 8.586l3.536-3.536a1 1 0 111.414 1.414L11.414 10l3.536 3.536a1 1 0 01-1.414 1.414L10 11.414l-3.536 3.536a1 1 0 01-1.414-1.414L8.586 10 5.05 6.464A1 1 0 116.464 5.05L10 8.586z",
77
+ clipRule: "evenodd"
78
+ }
79
+ ) })
80
+ }
81
+ )
82
+ ] });
83
+ }
84
+ export {
85
+ SearchInput as default
86
+ };
@@ -0,0 +1,31 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type BaseValue = string | number;
4
+ type Option<T extends BaseValue> = {
5
+ label: string;
6
+ value: T;
7
+ disabled?: boolean;
8
+ };
9
+ type Size = "sm" | "md" | "lg";
10
+ type Props<T extends BaseValue> = {
11
+ value: T | "";
12
+ onChange: (v: T | "") => void;
13
+ options: Option<T>[];
14
+ id?: string;
15
+ label?: string;
16
+ hint?: string;
17
+ placeholder?: string;
18
+ title?: string;
19
+ className?: string;
20
+ fullWidth?: boolean;
21
+ disabled?: boolean;
22
+ error?: string | boolean;
23
+ size?: Size;
24
+ clearable?: boolean;
25
+ closeOnSelect?: boolean;
26
+ minWidthClasses?: string;
27
+ fit?: boolean;
28
+ };
29
+ declare function ModernSelect<T extends BaseValue>({ value, onChange, options, id, label, hint, placeholder, title, className, fullWidth, disabled, error, size, clearable, closeOnSelect, minWidthClasses, fit, }: Props<T>): react_jsx_runtime.JSX.Element;
30
+
31
+ export { type Option, ModernSelect as default };
@@ -0,0 +1,31 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type BaseValue = string | number;
4
+ type Option<T extends BaseValue> = {
5
+ label: string;
6
+ value: T;
7
+ disabled?: boolean;
8
+ };
9
+ type Size = "sm" | "md" | "lg";
10
+ type Props<T extends BaseValue> = {
11
+ value: T | "";
12
+ onChange: (v: T | "") => void;
13
+ options: Option<T>[];
14
+ id?: string;
15
+ label?: string;
16
+ hint?: string;
17
+ placeholder?: string;
18
+ title?: string;
19
+ className?: string;
20
+ fullWidth?: boolean;
21
+ disabled?: boolean;
22
+ error?: string | boolean;
23
+ size?: Size;
24
+ clearable?: boolean;
25
+ closeOnSelect?: boolean;
26
+ minWidthClasses?: string;
27
+ fit?: boolean;
28
+ };
29
+ declare function ModernSelect<T extends BaseValue>({ value, onChange, options, id, label, hint, placeholder, title, className, fullWidth, disabled, error, size, clearable, closeOnSelect, minWidthClasses, fit, }: Props<T>): react_jsx_runtime.JSX.Element;
30
+
31
+ export { type Option, ModernSelect as default };
package/dist/Select.js ADDED
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var Select_exports = {};
31
+ __export(Select_exports, {
32
+ default: () => ModernSelect
33
+ });
34
+ module.exports = __toCommonJS(Select_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_react = __toESM(require("react"));
37
+ const S = {
38
+ sm: { h: "h-8", text: "text-[13px]", radius: "rounded-xl", padX: "px-3", itemPad: "px-3 py-1.5" },
39
+ md: { h: "h-10", text: "text-sm", radius: "rounded-2xl", padX: "px-3.5", itemPad: "px-3.5 py-2" },
40
+ lg: { h: "h-11", text: "text-base", radius: "rounded-2xl", padX: "px-4", itemPad: "px-4 py-2.5" }
41
+ };
42
+ function ModernSelect({
43
+ value,
44
+ onChange,
45
+ options,
46
+ id,
47
+ label,
48
+ hint,
49
+ placeholder = "Selecciona una opci\xF3n\u2026",
50
+ title,
51
+ className,
52
+ fullWidth = true,
53
+ disabled = false,
54
+ error = false,
55
+ size = "md",
56
+ clearable = false,
57
+ closeOnSelect = false,
58
+ minWidthClasses,
59
+ fit = true
60
+ }) {
61
+ var _a, _b;
62
+ const s = S[size];
63
+ const hasError = Boolean(error);
64
+ const autoId = import_react.default.useId();
65
+ const selectId = id != null ? id : autoId;
66
+ const hintId = hint ? `${selectId}-hint` : void 0;
67
+ const errorId = hasError ? `${selectId}-err` : void 0;
68
+ const [open, setOpen] = import_react.default.useState(false);
69
+ const [active, setActive] = import_react.default.useState(() => {
70
+ const idx = options.findIndex((o) => String(o.value) === String(value));
71
+ return Math.max(0, idx);
72
+ });
73
+ const btnRef = import_react.default.useRef(null);
74
+ const listRef = import_react.default.useRef(null);
75
+ const rootRef = import_react.default.useRef(null);
76
+ const [menuPos, setMenuPos] = import_react.default.useState({ top: 0, left: 0, width: 0 });
77
+ const updateMenuPosition = import_react.default.useCallback(() => {
78
+ const el = btnRef.current;
79
+ if (!el) return;
80
+ const r = el.getBoundingClientRect();
81
+ setMenuPos({
82
+ top: Math.round(r.bottom + window.scrollY + 6),
83
+ left: Math.round(r.left + window.scrollX),
84
+ width: Math.round(r.width)
85
+ });
86
+ }, []);
87
+ import_react.default.useEffect(() => {
88
+ const onDoc = (e) => {
89
+ if (!rootRef.current) return;
90
+ if (!rootRef.current.contains(e.target)) setOpen(false);
91
+ };
92
+ document.addEventListener("mousedown", onDoc);
93
+ return () => document.removeEventListener("mousedown", onDoc);
94
+ }, []);
95
+ import_react.default.useEffect(() => {
96
+ if (!open) return;
97
+ updateMenuPosition();
98
+ const onScroll = () => updateMenuPosition();
99
+ const onResize = () => updateMenuPosition();
100
+ window.addEventListener("scroll", onScroll, { passive: true });
101
+ window.addEventListener("resize", onResize);
102
+ return () => {
103
+ window.removeEventListener("scroll", onScroll);
104
+ window.removeEventListener("resize", onResize);
105
+ };
106
+ }, [open, updateMenuPosition]);
107
+ import_react.default.useEffect(() => {
108
+ var _a2;
109
+ if (!open) return;
110
+ const el = (_a2 = listRef.current) == null ? void 0 : _a2.querySelector(`[data-idx="${active}"]`);
111
+ el == null ? void 0 : el.focus();
112
+ }, [open, active]);
113
+ const selected = (_a = options.find((o) => String(o.value) === String(value))) != null ? _a : null;
114
+ const setSelected = (o) => {
115
+ if (o.disabled) return;
116
+ onChange(o.value);
117
+ setActive(options.findIndex((x) => String(x.value) === String(o.value)));
118
+ if (closeOnSelect) setOpen(false);
119
+ };
120
+ const clear = () => {
121
+ var _a2;
122
+ onChange("");
123
+ setActive(0);
124
+ (_a2 = btnRef.current) == null ? void 0 : _a2.focus();
125
+ };
126
+ const onKeyBtn = (e) => {
127
+ if (disabled) return;
128
+ if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
129
+ e.preventDefault();
130
+ setOpen(true);
131
+ }
132
+ };
133
+ const onKeyList = (e) => {
134
+ var _a2;
135
+ if (!open) return;
136
+ if (e.key === "Escape") {
137
+ e.preventDefault();
138
+ setOpen(false);
139
+ (_a2 = btnRef.current) == null ? void 0 : _a2.focus();
140
+ return;
141
+ }
142
+ if (e.key === "ArrowDown") {
143
+ e.preventDefault();
144
+ setActive((i) => Math.min(i + 1, options.length - 1));
145
+ } else if (e.key === "ArrowUp") {
146
+ e.preventDefault();
147
+ setActive((i) => Math.max(i - 1, 0));
148
+ } else if (e.key === "Home") {
149
+ e.preventDefault();
150
+ setActive(0);
151
+ } else if (e.key === "End") {
152
+ e.preventDefault();
153
+ setActive(options.length - 1);
154
+ } else if (e.key === "Enter") {
155
+ e.preventDefault();
156
+ const o = options[active];
157
+ if (o) setSelected(o);
158
+ }
159
+ };
160
+ const widthBtn = fit ? "w-full min-w-[12rem] md:min-w-[16rem]" : `w-full ${minWidthClasses != null ? minWidthClasses : "min-w-full sm:min-w-[12rem] lg:min-w-[16rem]"}`;
161
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: fullWidth ? "block w-full" : "inline-block", ref: rootRef, children: [
162
+ label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-1.5 text-[13px] font-semibold", children: label }),
163
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
164
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
165
+ "button",
166
+ {
167
+ ref: btnRef,
168
+ id: selectId,
169
+ type: "button",
170
+ title: (_b = selected == null ? void 0 : selected.label) != null ? _b : title,
171
+ disabled,
172
+ "aria-haspopup": "listbox",
173
+ "aria-expanded": open,
174
+ "aria-controls": `${selectId}-listbox`,
175
+ "aria-describedby": hintId != null ? hintId : hasError ? errorId : void 0,
176
+ onClick: () => !disabled && setOpen((o) => !o),
177
+ onKeyDown: onKeyBtn,
178
+ className: [
179
+ "text-left bg-white dark:bg-[#0e0d0e] border transition shadow-sm",
180
+ s.radius,
181
+ s.h,
182
+ s.text,
183
+ s.padX,
184
+ "pr-12",
185
+ widthBtn,
186
+ hasError ? "border-blue-500 focus:ring-2 ring-blue-300" : "border-slate-200 dark:border-white/10 focus:ring-2 ring-blue-300",
187
+ disabled ? "opacity-60 cursor-not-allowed" : "cursor-pointer",
188
+ "whitespace-nowrap overflow-hidden text-ellipsis",
189
+ className != null ? className : ""
190
+ ].join(" "),
191
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: selected ? "text-slate-900 dark:text-slate-100" : "text-slate-400", children: selected ? selected.label : placeholder })
192
+ }
193
+ ),
194
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
195
+ "svg",
196
+ {
197
+ className: `pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 h-5 w-5 transition ${open ? "rotate-180 opacity-70" : "opacity-70"}`,
198
+ viewBox: "0 0 20 20",
199
+ fill: "currentColor",
200
+ "aria-hidden": "true",
201
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5.23 7.21a.75.75 0 011.06.02L10 10.2l3.71-2.97a.75.75 0 111.04 1.08l-4.24 3.4a.75.75 0 01-.94 0L5.21 8.31a.75.75 0 01.02-1.1z" })
202
+ }
203
+ ),
204
+ clearable && value !== "" && !disabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
+ "button",
206
+ {
207
+ type: "button",
208
+ onClick: clear,
209
+ className: "absolute right-9 top-1/2 -translate-y-1/2 grid h-6 w-6 place-items-center rounded-md text-slate-400 hover:text-slate-700 hover:bg-slate-100 dark:hover:bg-white/10",
210
+ "aria-label": "Limpiar selecci\xF3n",
211
+ title: "Limpiar",
212
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
+ "path",
214
+ {
215
+ fillRule: "evenodd",
216
+ d: "M10 8.586l3.536-3.536a1 1 0 111.414 1.414L11.414 10l3.536 3.536a1 1 0 01-1.414 1.414L10 11.414l-3.536 3.536a1 1 0 01-1.414-1.414L8.586 10 5.05 6.464A1 1 0 116.464 5.05L10 8.586z",
217
+ clipRule: "evenodd"
218
+ }
219
+ ) })
220
+ }
221
+ )
222
+ ] }),
223
+ open && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
224
+ "ul",
225
+ {
226
+ id: `${selectId}-listbox`,
227
+ role: "listbox",
228
+ ref: listRef,
229
+ tabIndex: -1,
230
+ onKeyDown: onKeyList,
231
+ "aria-labelledby": selectId,
232
+ className: [
233
+ "fixed z-[1000] max-h-72 overflow-auto",
234
+ "rounded-2xl border border-slate-200/80 bg-white/90 backdrop-blur-md shadow-2xl ring-1 ring-black/5",
235
+ "dark:border-white/10 dark:bg-[#0f0d0e]/90 dark:ring-white/10"
236
+ ].join(" "),
237
+ style: {
238
+ top: menuPos.top,
239
+ left: menuPos.left,
240
+ width: menuPos.width,
241
+ maxWidth: "calc(100vw - 24px)"
242
+ },
243
+ children: [
244
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
245
+ "li",
246
+ {
247
+ role: "presentation",
248
+ className: `${S[size].itemPad} sticky top-0 bg-white/90 dark:bg-[#0f0d0e]/90 backdrop-blur-md text-slate-400 select-none`,
249
+ children: placeholder
250
+ }
251
+ ),
252
+ options.map((o, idx) => {
253
+ const isSelected = String(value) === String(o.value);
254
+ const isDisabled = Boolean(o.disabled);
255
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
256
+ "li",
257
+ {
258
+ role: "option",
259
+ "aria-selected": isSelected,
260
+ "aria-disabled": isDisabled,
261
+ tabIndex: -1,
262
+ "data-idx": idx,
263
+ onMouseDown: (e) => e.preventDefault(),
264
+ onClick: () => !isDisabled && setSelected(o),
265
+ className: [
266
+ S[size].itemPad,
267
+ "flex items-start justify-between gap-3",
268
+ "cursor-pointer focus:outline-none",
269
+ "hover:bg-slate-50 dark:hover:bg-white/5",
270
+ isSelected ? "bg-slate-50/70 dark:bg-white/10" : "",
271
+ isDisabled ? "opacity-50 cursor-not-allowed" : ""
272
+ ].join(" "),
273
+ children: [
274
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "min-w-0 flex-1 leading-snug whitespace-normal break-words line-clamp-2", children: o.label }),
275
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "ml-3 h-4 w-4 shrink-0 opacity-80", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
+ "path",
277
+ {
278
+ fillRule: "evenodd",
279
+ d: "M16.707 5.293a1 1 0 010 1.414l-7.25 7.25a1 1 0 01-1.414 0l-3.25-3.25a1 1 0 111.414-1.414l2.543 2.543 6.543-6.543a1 1 0 011.414 0z",
280
+ clipRule: "evenodd"
281
+ }
282
+ ) })
283
+ ]
284
+ },
285
+ String(o.value)
286
+ );
287
+ })
288
+ ]
289
+ }
290
+ ),
291
+ hasError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: errorId, className: "mt-1 text-[12px] text-blue-600", children: typeof error === "string" ? error : "Corrige este campo" }) : hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: hintId, className: "mt-1 text-[12px] text-slate-500", children: hint }) : null
292
+ ] });
293
+ }