framepexls-ui-lib 0.3.1 → 0.3.2
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/AvatarGroup.js +1 -1
- package/dist/AvatarGroup.mjs +1 -1
- package/dist/Badge.js +12 -12
- package/dist/Badge.mjs +12 -12
- package/dist/BadgeCluster.js +1 -1
- package/dist/BadgeCluster.mjs +1 -1
- package/dist/Button.js +1 -1
- package/dist/Button.mjs +1 -1
- package/dist/Card.js +1 -1
- package/dist/Card.mjs +1 -1
- package/dist/ChartCard.js +1 -1
- package/dist/ChartCard.mjs +1 -1
- package/dist/Checkbox.d.mts +1 -1
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.js +1 -1
- package/dist/Checkbox.mjs +1 -1
- package/dist/CheckboxPillsGroup.js +3 -3
- package/dist/CheckboxPillsGroup.mjs +3 -3
- package/dist/ComboSelect.js +2 -2
- package/dist/ComboSelect.mjs +2 -2
- package/dist/DateTimeField.js +1 -1
- package/dist/DateTimeField.mjs +1 -1
- package/dist/EmptyState.js +1 -1
- package/dist/EmptyState.mjs +1 -1
- package/dist/FiltersMultiSelect.js +3 -3
- package/dist/FiltersMultiSelect.mjs +3 -3
- package/dist/Input.js +4 -4
- package/dist/Input.mjs +4 -4
- package/dist/KpiCard.js +1 -1
- package/dist/KpiCard.mjs +1 -1
- package/dist/MediaCard.js +1 -1
- package/dist/MediaCard.mjs +1 -1
- package/dist/MediaSelector.js +235 -135
- package/dist/MediaSelector.mjs +235 -135
- package/dist/MediaTile.d.mts +18 -0
- package/dist/MediaTile.d.ts +18 -0
- package/dist/MediaTile.js +146 -0
- package/dist/MediaTile.mjs +116 -0
- package/dist/MultiComboSelect.js +2 -2
- package/dist/MultiComboSelect.mjs +2 -2
- package/dist/Pagination.js +8 -6
- package/dist/Pagination.mjs +8 -6
- package/dist/Sidebar.js +9 -9
- package/dist/Sidebar.mjs +9 -9
- package/dist/Skeleton.d.mts +34 -0
- package/dist/Skeleton.d.ts +34 -0
- package/dist/Skeleton.js +92 -0
- package/dist/Skeleton.mjs +64 -0
- package/dist/StatCard.js +1 -1
- package/dist/StatCard.mjs +1 -1
- package/dist/Steps.js +2 -2
- package/dist/Steps.mjs +2 -2
- package/dist/Table.js +5 -5
- package/dist/Table.mjs +5 -5
- package/dist/Textarea.js +1 -1
- package/dist/Textarea.mjs +1 -1
- package/dist/TimePanel.js +4 -4
- package/dist/TimePanel.mjs +4 -4
- package/dist/TimePopover.js +2 -2
- package/dist/TimePopover.mjs +2 -2
- package/dist/TimeRangeField.js +1 -1
- package/dist/TimeRangeField.mjs +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/Tooltip.mjs +1 -1
- package/dist/UploadCard.js +7 -7
- package/dist/UploadCard.mjs +7 -7
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.mjs +68 -64
- package/dist/theme/ThemeToggle.js +2 -1
- package/dist/theme/ThemeToggle.mjs +2 -1
- package/package.json +1 -1
package/dist/MediaSelector.js
CHANGED
|
@@ -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] =
|
|
55
|
-
const [uploading, setUploading] =
|
|
56
|
-
const [progress, setProgress] =
|
|
57
|
-
const inputRef =
|
|
58
|
-
const [linkValue, setLinkValue] =
|
|
59
|
-
const [linkLoading, setLinkLoading] =
|
|
60
|
-
const [linkError, setLinkError] =
|
|
61
|
-
|
|
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
|
-
|
|
64
|
+
import_react.default.useEffect(() => {
|
|
65
65
|
if (autoOpen) setOpenPicker(true);
|
|
66
66
|
}, [autoOpen]);
|
|
67
|
-
|
|
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
|
|
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
|
|
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)(
|
|
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-
|
|
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)(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
128
|
+
import_ChartCard.default,
|
|
152
129
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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.
|
|
213
|
-
|
|
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
|
-
)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
}
|