framepexls-ui-lib 0.3.1 → 0.3.3

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 (71) hide show
  1. package/dist/AvatarGroup.js +1 -1
  2. package/dist/AvatarGroup.mjs +1 -1
  3. package/dist/Badge.js +12 -12
  4. package/dist/Badge.mjs +12 -12
  5. package/dist/BadgeCluster.js +1 -1
  6. package/dist/BadgeCluster.mjs +1 -1
  7. package/dist/Button.js +1 -1
  8. package/dist/Button.mjs +1 -1
  9. package/dist/Card.js +1 -1
  10. package/dist/Card.mjs +1 -1
  11. package/dist/ChartCard.js +1 -1
  12. package/dist/ChartCard.mjs +1 -1
  13. package/dist/Checkbox.js +1 -1
  14. package/dist/Checkbox.mjs +1 -1
  15. package/dist/CheckboxPillsGroup.js +3 -3
  16. package/dist/CheckboxPillsGroup.mjs +3 -3
  17. package/dist/ComboSelect.js +2 -2
  18. package/dist/ComboSelect.mjs +2 -2
  19. package/dist/DateTimeField.js +7 -4
  20. package/dist/DateTimeField.mjs +7 -4
  21. package/dist/EmptyState.js +1 -1
  22. package/dist/EmptyState.mjs +1 -1
  23. package/dist/FiltersMultiSelect.js +3 -3
  24. package/dist/FiltersMultiSelect.mjs +3 -3
  25. package/dist/Input.js +4 -4
  26. package/dist/Input.mjs +4 -4
  27. package/dist/KpiCard.js +1 -1
  28. package/dist/KpiCard.mjs +1 -1
  29. package/dist/MediaCard.js +1 -1
  30. package/dist/MediaCard.mjs +1 -1
  31. package/dist/MediaSelector.js +235 -135
  32. package/dist/MediaSelector.mjs +235 -135
  33. package/dist/MediaTile.d.mts +18 -0
  34. package/dist/MediaTile.d.ts +18 -0
  35. package/dist/MediaTile.js +146 -0
  36. package/dist/MediaTile.mjs +116 -0
  37. package/dist/MultiComboSelect.js +2 -2
  38. package/dist/MultiComboSelect.mjs +2 -2
  39. package/dist/Pagination.js +8 -6
  40. package/dist/Pagination.mjs +8 -6
  41. package/dist/Sidebar.js +9 -9
  42. package/dist/Sidebar.mjs +9 -9
  43. package/dist/Skeleton.d.mts +34 -0
  44. package/dist/Skeleton.d.ts +34 -0
  45. package/dist/Skeleton.js +92 -0
  46. package/dist/Skeleton.mjs +64 -0
  47. package/dist/StatCard.js +1 -1
  48. package/dist/StatCard.mjs +1 -1
  49. package/dist/Steps.js +2 -2
  50. package/dist/Steps.mjs +2 -2
  51. package/dist/Table.js +5 -5
  52. package/dist/Table.mjs +5 -5
  53. package/dist/Textarea.js +1 -1
  54. package/dist/Textarea.mjs +1 -1
  55. package/dist/TimePanel.js +4 -4
  56. package/dist/TimePanel.mjs +4 -4
  57. package/dist/TimePopover.js +2 -2
  58. package/dist/TimePopover.mjs +2 -2
  59. package/dist/TimeRangeField.js +7 -4
  60. package/dist/TimeRangeField.mjs +7 -4
  61. package/dist/Tooltip.js +1 -1
  62. package/dist/Tooltip.mjs +1 -1
  63. package/dist/UploadCard.js +7 -7
  64. package/dist/UploadCard.mjs +7 -7
  65. package/dist/index.d.mts +2 -0
  66. package/dist/index.d.ts +2 -0
  67. package/dist/index.js +6 -0
  68. package/dist/index.mjs +68 -64
  69. package/dist/theme/ThemeToggle.js +2 -1
  70. package/dist/theme/ThemeToggle.mjs +2 -1
  71. package/package.json +1 -1
@@ -33,7 +33,7 @@ __export(MediaSelector_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(MediaSelector_exports);
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_react = require("react");
36
+ var import_react = __toESM(require("react"));
37
37
  var import_ChartCard = __toESM(require("./ChartCard"));
38
38
  var import_Button = __toESM(require("./Button"));
39
39
  var import_Input = __toESM(require("./Input"));
@@ -51,24 +51,24 @@ function MediaSelector({
51
51
  onClose
52
52
  }) {
53
53
  const { obtenerMedios, items, page, lastPage, setPage, subirMedio } = medios;
54
- const [openPicker, setOpenPicker] = (0, import_react.useState)(false);
55
- const [uploading, setUploading] = (0, import_react.useState)(false);
56
- const [progress, setProgress] = (0, import_react.useState)(0);
57
- const inputRef = (0, import_react.useRef)(null);
58
- const [linkValue, setLinkValue] = (0, import_react.useState)(value != null ? value : "");
59
- const [linkLoading, setLinkLoading] = (0, import_react.useState)(false);
60
- const [linkError, setLinkError] = (0, import_react.useState)(null);
61
- (0, import_react.useEffect)(() => {
54
+ const [openPicker, setOpenPicker] = import_react.default.useState(false);
55
+ const [uploading, setUploading] = import_react.default.useState(false);
56
+ const [progress, setProgress] = import_react.default.useState(0);
57
+ const inputRef = import_react.default.useRef(null);
58
+ const [linkValue, setLinkValue] = import_react.default.useState(value != null ? value : "");
59
+ const [linkLoading, setLinkLoading] = import_react.default.useState(false);
60
+ const [linkError, setLinkError] = import_react.default.useState(null);
61
+ import_react.default.useEffect(() => {
62
62
  if (openPicker) obtenerMedios({ page: page || 1 });
63
63
  }, [openPicker, page, obtenerMedios]);
64
- (0, import_react.useEffect)(() => {
64
+ import_react.default.useEffect(() => {
65
65
  if (autoOpen) setOpenPicker(true);
66
66
  }, [autoOpen]);
67
- (0, import_react.useEffect)(() => {
67
+ import_react.default.useEffect(() => {
68
68
  if (openPicker) setLinkValue(value != null ? value : "");
69
69
  }, [openPicker, value]);
70
70
  const onFiles = async (files) => {
71
- var _a, _b, _c, _d;
71
+ var _a, _b;
72
72
  if (!(files == null ? void 0 : files.length)) return;
73
73
  const file = files[0];
74
74
  setUploading(true);
@@ -76,7 +76,8 @@ function MediaSelector({
76
76
  const res = await subirMedio(file, { onProgress: (p) => setProgress(p.porcentaje) });
77
77
  setUploading(false);
78
78
  if (res.ok) {
79
- const url = (_d = (_c = (_a = res.data) == null ? void 0 : _a.url) != null ? _c : (_b = res.data) == null ? void 0 : _b.url) != null ? _d : null;
79
+ const anyData = (_a = res.data) != null ? _a : res;
80
+ const url = (_b = anyData == null ? void 0 : anyData.url) != null ? _b : null;
80
81
  onChange(url, res.data);
81
82
  }
82
83
  };
@@ -87,140 +88,239 @@ function MediaSelector({
87
88
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
88
89
  !dialogOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
89
90
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
90
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Input.default, { value: value != null ? value : "", onChange: (e) => onChange(e.target.value || null), placeholder: "URL de imagen", clearable: true, onClear: () => onChange(null) }),
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ import_Input.default,
93
+ {
94
+ value: value != null ? value : "",
95
+ onChange: (e) => onChange(e.target.value || null),
96
+ placeholder: "URL de imagen",
97
+ clearable: true,
98
+ onClear: () => onChange(null)
99
+ }
100
+ ),
91
101
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { variant: "secondary", onClick: () => setOpenPicker(true), children: "Elegir" })
92
102
  ] }),
93
- value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "overflow-hidden rounded-2xl border border-slate-200 bg-white/60 p-2 dark:border-white/10 dark:bg-white/5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "aspect-video w-full overflow-hidden rounded-xl bg-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: value, alt: "preview", className: "h-full w-full object-cover" }) }) })
103
+ value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "overflow-hidden rounded-2xl border border-slate-200 bg-white/60 p-2 dark:border-white/10 dark:bg-[var(--fx-surface)]", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "aspect-video w-full overflow-hidden rounded-xl bg-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: value, alt: "preview", className: "h-full w-full object-cover" }) }) })
94
104
  ] }),
95
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Dialog.default, { open: openPicker, onClose: () => {
96
- setOpenPicker(false);
97
- onClose == null ? void 0 : onClose();
98
- }, size: "full", children: [
99
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Header, { title: "Biblioteca de medios", description: "Selecciona una imagen o sube una nueva", onClose: () => {
100
- setOpenPicker(false);
101
- onClose == null ? void 0 : onClose();
102
- } }),
103
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
104
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChartCard.default, { className: "lg:col-span-1", title: "Subir imagen", subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Arrastra una imagen o selecci\xF3nala" }), right: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
105
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Input.default, { unstyled: true, ref: inputRef, type: "file", accept, className: "hidden", onChange: (e) => onFiles(e.target.files) }),
106
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { onClick: () => {
107
- var _a;
108
- return (_a = inputRef.current) == null ? void 0 : _a.click();
109
- }, disabled: uploading, children: "Seleccionar" })
110
- ] }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
111
- "div",
112
- {
113
- onDragOver: (e) => {
114
- e.preventDefault();
115
- e.dataTransfer.dropEffect = "copy";
116
- },
117
- onDrop: handleDrop,
118
- onClick: () => {
119
- var _a;
120
- return (_a = inputRef.current) == null ? void 0 : _a.click();
121
- },
122
- className: "flex cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl border border-dashed border-slate-300 bg-gradient-to-b from-white/90 to-white/60 p-8 text-center transition hover:border-slate-400 hover:bg-white/80 dark:border-white/10 dark:from-white/10 dark:to-white/5",
123
- children: [
124
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", className: "h-8 w-8 text-slate-400", fill: "none", stroke: "currentColor", strokeWidth: "1.6", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 16V4M7 9l5-5 5 5M20 16v3a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3" }) }),
125
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-medium", children: "Soltar imagen aqu\xED" }),
126
- uploading && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-3 w-full", children: [
127
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-1 text-xs text-slate-500", children: [
128
- progress,
129
- "%"
130
- ] }),
131
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-2 overflow-hidden rounded-full bg-slate-100 dark:bg-white/10", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.motion.div, { className: "h-full w-full origin-left bg-gradient-to-r from-emerald-500/70 to-emerald-500/20 will-change-transform", initial: { scaleX: 0 }, animate: { scaleX: progress / 100 }, transition: import_animations.springSm }) })
132
- ] })
133
- ]
134
- }
135
- ) }),
136
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ChartCard.default, { className: "lg:col-span-1", title: "Desde enlace", subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Pega una URL http(s) v\xE1lida" }), compact: true, children: [
137
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
138
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
139
- import_Input.default,
140
- {
141
- type: "url",
142
- placeholder: "https://\u2026",
143
- value: linkValue,
144
- onChange: (e) => {
145
- setLinkValue(e.target.value);
146
- setLinkError(null);
147
- }
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
106
+ import_Dialog.default,
107
+ {
108
+ open: openPicker,
109
+ onClose: () => {
110
+ setOpenPicker(false);
111
+ onClose == null ? void 0 : onClose();
112
+ },
113
+ size: "full",
114
+ children: [
115
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
+ import_Dialog.default.Header,
117
+ {
118
+ title: "Biblioteca de medios",
119
+ description: "Selecciona una imagen o sube una nueva",
120
+ onClose: () => {
121
+ setOpenPicker(false);
122
+ onClose == null ? void 0 : onClose();
148
123
  }
149
- ),
124
+ }
125
+ ),
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
150
127
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
- import_Button.default,
128
+ import_ChartCard.default,
152
129
  {
153
- onClick: async () => {
154
- var _a, _b, _c, _d;
155
- if (!linkValue) return;
156
- setLinkError(null);
157
- const isHttp = /^https?:\/\//i.test(linkValue);
158
- if (!isHttp) {
159
- setLinkError("Ingresa un enlace v\xE1lido (http/https)");
160
- return;
161
- }
162
- const importer = (_a = medios.importFromUrl) != null ? _a : medios.importarMedioDesdeUrl;
163
- if (importer) {
164
- setLinkLoading(true);
165
- const res = await importer(linkValue);
166
- setLinkLoading(false);
167
- if (res && res.ok) {
168
- const d = (_b = res.data) != null ? _b : res;
169
- onChange((_c = d == null ? void 0 : d.url) != null ? _c : null, d != null ? d : null);
170
- setOpenPicker(false);
171
- onClose == null ? void 0 : onClose();
172
- } else {
173
- setLinkError(String((_d = res == null ? void 0 : res.error) != null ? _d : "No se pudo importar el enlace"));
130
+ className: "lg:col-span-1",
131
+ title: "Subir imagen",
132
+ subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Arrastra una imagen o selecci\xF3nala" }),
133
+ right: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
134
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
+ import_Input.default,
136
+ {
137
+ unstyled: true,
138
+ ref: inputRef,
139
+ type: "file",
140
+ accept,
141
+ className: "hidden",
142
+ onChange: (e) => onFiles(e.target.files)
174
143
  }
175
- } else {
176
- onChange(linkValue || null, null);
177
- setOpenPicker(false);
178
- onClose == null ? void 0 : onClose();
144
+ ),
145
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { onClick: () => {
146
+ var _a;
147
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
148
+ }, disabled: uploading, children: "Seleccionar" })
149
+ ] }),
150
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
151
+ "div",
152
+ {
153
+ onDragOver: (e) => {
154
+ e.preventDefault();
155
+ e.dataTransfer.dropEffect = "copy";
156
+ },
157
+ onDrop: handleDrop,
158
+ onClick: () => {
159
+ var _a;
160
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
161
+ },
162
+ className: "flex cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl border border-dashed border-slate-300 bg-gradient-to-b from-white/90 to-white/60 p-8 text-center transition hover:border-slate-400 hover:bg-white/80 dark:border-white/10 dark:from-white/10 dark:to-white/5",
163
+ children: [
164
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
165
+ "svg",
166
+ {
167
+ viewBox: "0 0 24 24",
168
+ className: "h-8 w-8 text-slate-400",
169
+ fill: "none",
170
+ stroke: "currentColor",
171
+ strokeWidth: "1.6",
172
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 16V4M7 9l5-5 5 5M20 16v3a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3" })
173
+ }
174
+ ),
175
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-medium", children: "Arrastra y suelta archivos aqu\xED o haz clic" }),
176
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-xs text-slate-500", children: "Formatos: JPG, PNG, WEBP, GIF" }),
177
+ uploading && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-3 w-full rounded-xl border border-slate-200 p-2 text-left text-sm dark:border-white/10", children: [
178
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between text-xs", children: [
179
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Subiendo\u2026" }),
180
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
181
+ progress,
182
+ "%"
183
+ ] })
184
+ ] }),
185
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-2 overflow-hidden rounded-full bg-slate-100 dark:bg-white/10", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
186
+ import_framer_motion.motion.div,
187
+ {
188
+ className: "h-full w-full origin-left bg-gradient-to-r from-emerald-500/70 to-emerald-500/20 will-change-transform",
189
+ initial: { scaleX: 0 },
190
+ animate: { scaleX: progress / 100 },
191
+ transition: import_animations.springSm
192
+ }
193
+ ) })
194
+ ] })
195
+ ]
179
196
  }
180
- },
181
- disabled: !linkValue || linkLoading,
182
- children: linkLoading ? "Importando\u2026" : "Usar"
197
+ )
183
198
  }
184
- )
185
- ] }),
186
- linkError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-2 rounded-xl border border-rose-300/70 bg-rose-50 px-3 py-2 text-rose-900 text-xs", children: linkError })
187
- ] }),
188
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "lg:col-span-2 space-y-3", children: [
189
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
190
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "text-sm text-slate-500 dark:text-slate-400", children: [
191
- "P\xE1gina ",
192
- page,
193
- " de ",
194
- Math.max(1, lastPage)
195
- ] }),
196
- lastPage > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Pagination.default, { page, totalPages: lastPage, onPageChange: setPage })
197
- ] }),
198
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { initial: false, children: items.map((m) => {
199
- var _a;
200
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.motion.div, { layout: true, initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: 8 }, transition: import_animations.springSm, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
201
- import_Button.default,
199
+ ),
200
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
201
+ import_ChartCard.default,
202
202
  {
203
- unstyled: true,
204
- className: "group overflow-hidden rounded-2xl border border-slate-200 bg-white/70 p-1 text-left transition hover:shadow-md focus:outline-none focus:ring-2 focus:ring-slate-300 dark:border-white/10 dark:bg-white/5",
205
- onClick: () => {
206
- var _a2;
207
- onChange((_a2 = m.url) != null ? _a2 : null, m);
208
- setOpenPicker(false);
209
- onClose == null ? void 0 : onClose();
210
- },
203
+ className: "lg:col-span-1",
204
+ title: "Desde enlace",
205
+ subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Pega una URL http(s) v\xE1lida" }),
206
+ compact: true,
211
207
  children: [
212
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "aspect-square w-full overflow-hidden rounded-xl bg-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: (_a = m.url) != null ? _a : "", alt: m.nombre, className: "h-full w-full object-cover transition group-hover:scale-105" }) }),
213
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "truncate p-1 text-xs", children: m.nombre })
208
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
209
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
+ import_Input.default,
211
+ {
212
+ type: "url",
213
+ placeholder: "https://\u2026",
214
+ value: linkValue,
215
+ onChange: (e) => {
216
+ setLinkValue(e.target.value);
217
+ setLinkError(null);
218
+ }
219
+ }
220
+ ),
221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
+ import_Button.default,
223
+ {
224
+ onClick: async () => {
225
+ var _a, _b, _c, _d;
226
+ if (!linkValue) return;
227
+ setLinkError(null);
228
+ const isHttp = /^https?:\/\//i.test(linkValue);
229
+ if (!isHttp) {
230
+ setLinkError("Ingresa un enlace v\xE1lido (http/https)");
231
+ return;
232
+ }
233
+ const importer = (_a = medios.importFromUrl) != null ? _a : medios.importarMedioDesdeUrl;
234
+ if (importer) {
235
+ setLinkLoading(true);
236
+ const res = await importer(linkValue);
237
+ setLinkLoading(false);
238
+ if (res && res.ok) {
239
+ const d = (_b = res.data) != null ? _b : res;
240
+ onChange((_c = d == null ? void 0 : d.url) != null ? _c : null, d != null ? d : null);
241
+ setOpenPicker(false);
242
+ onClose == null ? void 0 : onClose();
243
+ } else {
244
+ setLinkError(String((_d = res == null ? void 0 : res.error) != null ? _d : "No se pudo importar el enlace"));
245
+ }
246
+ } else {
247
+ onChange(linkValue || null, null);
248
+ setOpenPicker(false);
249
+ onClose == null ? void 0 : onClose();
250
+ }
251
+ },
252
+ disabled: !linkValue || linkLoading,
253
+ children: linkLoading ? "Importando\u2026" : "Usar"
254
+ }
255
+ )
256
+ ] }),
257
+ linkError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-2 rounded-xl border border-rose-300/70 bg-rose-50 px-3 py-2 text-rose-900 text-xs", children: linkError })
214
258
  ]
215
259
  }
216
- ) }, m.id);
217
- }) }) })
218
- ] })
219
- ] }) }),
220
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Footer, { align: "end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { variant: "secondary", onClick: () => {
221
- setOpenPicker(false);
222
- onClose == null ? void 0 : onClose();
223
- }, children: "Cerrar" }) })
224
- ] })
260
+ ),
261
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "lg:col-span-2 space-y-3", children: [
262
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
263
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "text-sm text-slate-500 dark:text-slate-400", children: [
264
+ "P\xE1gina ",
265
+ page,
266
+ " de ",
267
+ Math.max(1, lastPage)
268
+ ] }),
269
+ lastPage > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Pagination.default, { page, totalPages: lastPage, onPageChange: setPage })
270
+ ] }),
271
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { initial: false, children: items.map((m) => {
272
+ var _a;
273
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
274
+ import_framer_motion.motion.div,
275
+ {
276
+ layout: true,
277
+ initial: { opacity: 0, y: 8 },
278
+ animate: { opacity: 1, y: 0 },
279
+ exit: { opacity: 0, y: 8 },
280
+ transition: import_animations.springSm,
281
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
282
+ import_Button.default,
283
+ {
284
+ unstyled: true,
285
+ className: "group overflow-hidden rounded-2xl border border-slate-200 bg-white/70 p-1 text-left transition hover:shadow-md focus:outline-none focus:ring-2 focus:ring-slate-300 dark:border-white/10 dark:bg-[var(--fx-surface)]",
286
+ onClick: () => {
287
+ var _a2;
288
+ onChange((_a2 = m.url) != null ? _a2 : null, m);
289
+ setOpenPicker(false);
290
+ onClose == null ? void 0 : onClose();
291
+ },
292
+ children: [
293
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "aspect-square w-full overflow-hidden rounded-xl bg-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
294
+ "img",
295
+ {
296
+ src: (_a = m.url) != null ? _a : "",
297
+ alt: m.nombre,
298
+ className: "h-full w-full object-cover transition group-hover:scale-105"
299
+ }
300
+ ) }),
301
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "truncate p-1 text-xs", children: m.nombre })
302
+ ]
303
+ }
304
+ )
305
+ },
306
+ String(m.id)
307
+ );
308
+ }) }) })
309
+ ] })
310
+ ] }) }),
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Footer, { align: "end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
312
+ import_Button.default,
313
+ {
314
+ variant: "secondary",
315
+ onClick: () => {
316
+ setOpenPicker(false);
317
+ onClose == null ? void 0 : onClose();
318
+ },
319
+ children: "Cerrar"
320
+ }
321
+ ) })
322
+ ]
323
+ }
324
+ )
225
325
  ] });
226
326
  }