framepexls-ui-lib 0.1.12 → 0.1.14
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/ActionIconButton.d.mts +1 -0
- package/dist/ActionIconButton.d.ts +1 -0
- package/dist/ActionIconButton.js +12 -9
- package/dist/ActionIconButton.mjs +13 -10
- package/dist/AppTopbar.d.mts +8 -9
- package/dist/AppTopbar.d.ts +8 -9
- package/dist/AppTopbar.js +31 -5
- package/dist/AppTopbar.mjs +21 -5
- package/dist/AvatarGroup.d.mts +14 -0
- package/dist/AvatarGroup.d.ts +14 -0
- package/dist/AvatarGroup.js +77 -0
- package/dist/AvatarGroup.mjs +47 -0
- package/dist/AvatarSquare.d.mts +2 -5
- package/dist/AvatarSquare.d.ts +2 -5
- package/dist/AvatarSquare.js +52 -3
- package/dist/AvatarSquare.mjs +52 -3
- package/dist/Badge.d.mts +2 -1
- package/dist/Badge.d.ts +2 -1
- package/dist/Badge.js +3 -1
- package/dist/Badge.mjs +3 -1
- package/dist/BadgeCluster.js +3 -3
- package/dist/BadgeCluster.mjs +3 -3
- package/dist/Button.d.mts +3 -4
- package/dist/Button.d.ts +3 -4
- package/dist/Button.js +97 -9
- package/dist/Button.mjs +87 -9
- package/dist/CalendarPanel.js +20 -3
- package/dist/CalendarPanel.mjs +10 -3
- package/dist/Card.d.mts +6 -0
- package/dist/Card.d.ts +6 -0
- package/dist/Card.js +52 -0
- package/dist/Card.mjs +22 -0
- package/dist/CheckboxPillsGroup.d.mts +2 -1
- package/dist/CheckboxPillsGroup.d.ts +2 -1
- package/dist/CheckboxPillsGroup.js +8 -4
- package/dist/CheckboxPillsGroup.mjs +8 -4
- package/dist/ColumnSelector.js +16 -2
- package/dist/ColumnSelector.mjs +6 -2
- package/dist/ComboSelect.d.mts +0 -2
- package/dist/ComboSelect.d.ts +0 -2
- package/dist/ComboSelect.js +8 -4
- package/dist/ComboSelect.mjs +8 -4
- package/dist/DateTimeField.d.mts +0 -5
- package/dist/DateTimeField.d.ts +0 -5
- package/dist/DateTimeField.js +17 -8
- package/dist/DateTimeField.mjs +17 -8
- package/dist/Dialog.d.mts +2 -5
- package/dist/Dialog.d.ts +2 -5
- package/dist/Dialog.js +21 -22
- package/dist/Dialog.mjs +21 -22
- package/dist/Drawer.d.mts +38 -0
- package/dist/Drawer.d.ts +38 -0
- package/dist/Drawer.js +139 -0
- package/dist/Drawer.mjs +102 -0
- package/dist/Dropdown.d.mts +0 -3
- package/dist/Dropdown.d.ts +0 -3
- package/dist/Dropdown.js +61 -42
- package/dist/Dropdown.mjs +51 -42
- package/dist/Input.d.mts +2 -0
- package/dist/Input.d.ts +2 -0
- package/dist/Input.js +20 -5
- package/dist/Input.mjs +20 -5
- package/dist/Link.d.mts +15 -0
- package/dist/Link.d.ts +15 -0
- package/dist/Link.js +93 -0
- package/dist/Link.mjs +63 -0
- package/dist/MediaCard.d.mts +15 -0
- package/dist/MediaCard.d.ts +15 -0
- package/dist/MediaCard.js +153 -0
- package/dist/MediaCard.mjs +123 -0
- package/dist/MediaSelector.d.mts +48 -0
- package/dist/MediaSelector.d.ts +48 -0
- package/dist/MediaSelector.js +225 -0
- package/dist/MediaSelector.mjs +195 -0
- package/dist/Money.d.mts +2 -1
- package/dist/Money.d.ts +2 -1
- package/dist/Money.js +26 -2
- package/dist/Money.mjs +26 -2
- package/dist/MultiComboSelect.js +6 -11
- package/dist/MultiComboSelect.mjs +6 -11
- package/dist/OrderButton.js +13 -1
- package/dist/OrderButton.mjs +3 -1
- package/dist/Pagination.d.mts +2 -1
- package/dist/Pagination.d.ts +2 -1
- package/dist/Pagination.js +40 -3
- package/dist/Pagination.mjs +30 -3
- package/dist/ReviewHistory.js +3 -9
- package/dist/ReviewHistory.mjs +3 -9
- package/dist/SearchInput.js +17 -42
- package/dist/SearchInput.mjs +17 -42
- package/dist/Select.js +5 -2
- package/dist/Select.mjs +5 -2
- package/dist/Sidebar.d.mts +2 -3
- package/dist/Sidebar.d.ts +2 -3
- package/dist/Sidebar.js +132 -24
- package/dist/Sidebar.mjs +132 -24
- package/dist/Steps.d.mts +0 -2
- package/dist/Steps.d.ts +0 -2
- package/dist/Steps.js +19 -6
- package/dist/Steps.mjs +9 -6
- package/dist/Table.js +3 -1
- package/dist/Table.mjs +3 -1
- package/dist/TimePanel.js +21 -7
- package/dist/TimePanel.mjs +11 -7
- package/dist/TimePopover.js +32 -15
- package/dist/TimePopover.mjs +32 -15
- package/dist/TimeRangeField.js +13 -6
- package/dist/TimeRangeField.mjs +13 -6
- package/dist/Toast.d.mts +53 -0
- package/dist/Toast.d.ts +53 -0
- package/dist/Toast.js +273 -0
- package/dist/Toast.mjs +238 -0
- package/dist/Tooltip.d.mts +15 -0
- package/dist/Tooltip.d.ts +15 -0
- package/dist/Tooltip.js +135 -0
- package/dist/Tooltip.mjs +105 -0
- package/dist/UploadCard.d.mts +27 -0
- package/dist/UploadCard.d.ts +27 -0
- package/dist/UploadCard.js +143 -0
- package/dist/UploadCard.mjs +113 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +30 -1
- package/dist/index.mjs +58 -39
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
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 MediaCard_exports = {};
|
|
31
|
+
__export(MediaCard_exports, {
|
|
32
|
+
default: () => MediaCard
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(MediaCard_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_image = __toESM(require("next/image"));
|
|
38
|
+
var import_ActionIconButton = __toESM(require("./ActionIconButton"));
|
|
39
|
+
function MediaCard({
|
|
40
|
+
imageUrl,
|
|
41
|
+
title,
|
|
42
|
+
subtitle,
|
|
43
|
+
copyUrl,
|
|
44
|
+
onRename,
|
|
45
|
+
onReplace,
|
|
46
|
+
onDelete,
|
|
47
|
+
className
|
|
48
|
+
}) {
|
|
49
|
+
const [copied, setCopied] = (0, import_react.useState)(false);
|
|
50
|
+
const copy = async () => {
|
|
51
|
+
if (!copyUrl) return;
|
|
52
|
+
try {
|
|
53
|
+
await navigator.clipboard.writeText(copyUrl);
|
|
54
|
+
setCopied(true);
|
|
55
|
+
setTimeout(() => setCopied(false), 1200);
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: [
|
|
63
|
+
"group relative overflow-hidden rounded-2xl border border-slate-200 bg-white/80 shadow-sm ring-1 ring-black/5 backdrop-blur dark:border-white/10 dark:bg-white/5",
|
|
64
|
+
className != null ? className : ""
|
|
65
|
+
].join(" "),
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "aspect-square w-full bg-slate-100 relative", children: imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
import_image.default,
|
|
69
|
+
{
|
|
70
|
+
src: imageUrl,
|
|
71
|
+
alt: title,
|
|
72
|
+
fill: true,
|
|
73
|
+
sizes: "(min-width:1024px) 20vw, (min-width:768px) 25vw, (min-width:640px) 33vw, 50vw",
|
|
74
|
+
className: "object-cover"
|
|
75
|
+
}
|
|
76
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full w-full" }) }),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-2 p-2", children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0", children: [
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "truncate text-sm font-medium", children: title }),
|
|
80
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-xs text-slate-500", children: subtitle })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
83
|
+
copyUrl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ActionIconButton.default, { title: copied ? "Copiado" : "Copiar URL", onClick: copy, children: copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
|
+
"svg",
|
|
85
|
+
{
|
|
86
|
+
viewBox: "0 0 24 24",
|
|
87
|
+
className: "h-4.5 w-4.5 text-emerald-600",
|
|
88
|
+
fill: "none",
|
|
89
|
+
stroke: "currentColor",
|
|
90
|
+
strokeWidth: "2",
|
|
91
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 13l4 4L19 7" })
|
|
92
|
+
}
|
|
93
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
94
|
+
"svg",
|
|
95
|
+
{
|
|
96
|
+
viewBox: "0 0 24 24",
|
|
97
|
+
className: "h-4.5 w-4.5",
|
|
98
|
+
fill: "none",
|
|
99
|
+
stroke: "currentColor",
|
|
100
|
+
strokeWidth: "2",
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
) }),
|
|
107
|
+
onRename && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ActionIconButton.default, { title: "Renombrar", onClick: onRename, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
108
|
+
"svg",
|
|
109
|
+
{
|
|
110
|
+
viewBox: "0 0 24 24",
|
|
111
|
+
className: "h-4.5 w-4.5",
|
|
112
|
+
fill: "none",
|
|
113
|
+
stroke: "currentColor",
|
|
114
|
+
strokeWidth: "2",
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 21v-4l12-12 4 4-12 12z" }),
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 7l4 4" })
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
) }),
|
|
121
|
+
onReplace && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ActionIconButton.default, { title: "Reemplazar", onClick: onReplace, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
+
"svg",
|
|
123
|
+
{
|
|
124
|
+
viewBox: "0 0 24 24",
|
|
125
|
+
className: "h-4.5 w-4.5",
|
|
126
|
+
fill: "none",
|
|
127
|
+
stroke: "currentColor",
|
|
128
|
+
strokeWidth: "2",
|
|
129
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 5v14M5 12h14" })
|
|
130
|
+
}
|
|
131
|
+
) }),
|
|
132
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ActionIconButton.default, { title: "Eliminar", danger: true, onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
133
|
+
"svg",
|
|
134
|
+
{
|
|
135
|
+
viewBox: "0 0 24 24",
|
|
136
|
+
className: "h-4.5 w-4.5",
|
|
137
|
+
fill: "none",
|
|
138
|
+
stroke: "currentColor",
|
|
139
|
+
strokeWidth: "2",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 6h18" }),
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 6v14a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V6" }),
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 11v6M14 11v6" }),
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2" })
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
) })
|
|
148
|
+
] })
|
|
149
|
+
] })
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Image from "next/image";
|
|
5
|
+
import ActionIconButton from "./ActionIconButton";
|
|
6
|
+
function MediaCard({
|
|
7
|
+
imageUrl,
|
|
8
|
+
title,
|
|
9
|
+
subtitle,
|
|
10
|
+
copyUrl,
|
|
11
|
+
onRename,
|
|
12
|
+
onReplace,
|
|
13
|
+
onDelete,
|
|
14
|
+
className
|
|
15
|
+
}) {
|
|
16
|
+
const [copied, setCopied] = useState(false);
|
|
17
|
+
const copy = async () => {
|
|
18
|
+
if (!copyUrl) return;
|
|
19
|
+
try {
|
|
20
|
+
await navigator.clipboard.writeText(copyUrl);
|
|
21
|
+
setCopied(true);
|
|
22
|
+
setTimeout(() => setCopied(false), 1200);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
className: [
|
|
30
|
+
"group relative overflow-hidden rounded-2xl border border-slate-200 bg-white/80 shadow-sm ring-1 ring-black/5 backdrop-blur dark:border-white/10 dark:bg-white/5",
|
|
31
|
+
className != null ? className : ""
|
|
32
|
+
].join(" "),
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx("div", { className: "aspect-square w-full bg-slate-100 relative", children: imageUrl ? /* @__PURE__ */ jsx(
|
|
35
|
+
Image,
|
|
36
|
+
{
|
|
37
|
+
src: imageUrl,
|
|
38
|
+
alt: title,
|
|
39
|
+
fill: true,
|
|
40
|
+
sizes: "(min-width:1024px) 20vw, (min-width:768px) 25vw, (min-width:640px) 33vw, 50vw",
|
|
41
|
+
className: "object-cover"
|
|
42
|
+
}
|
|
43
|
+
) : /* @__PURE__ */ jsx("div", { className: "h-full w-full" }) }),
|
|
44
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 p-2", children: [
|
|
45
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
46
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-sm font-medium", children: title }),
|
|
47
|
+
subtitle && /* @__PURE__ */ jsx("div", { className: "text-xs text-slate-500", children: subtitle })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
50
|
+
copyUrl && /* @__PURE__ */ jsx(ActionIconButton, { title: copied ? "Copiado" : "Copiar URL", onClick: copy, children: copied ? /* @__PURE__ */ jsx(
|
|
51
|
+
"svg",
|
|
52
|
+
{
|
|
53
|
+
viewBox: "0 0 24 24",
|
|
54
|
+
className: "h-4.5 w-4.5 text-emerald-600",
|
|
55
|
+
fill: "none",
|
|
56
|
+
stroke: "currentColor",
|
|
57
|
+
strokeWidth: "2",
|
|
58
|
+
children: /* @__PURE__ */ jsx("path", { d: "M5 13l4 4L19 7" })
|
|
59
|
+
}
|
|
60
|
+
) : /* @__PURE__ */ jsxs(
|
|
61
|
+
"svg",
|
|
62
|
+
{
|
|
63
|
+
viewBox: "0 0 24 24",
|
|
64
|
+
className: "h-4.5 w-4.5",
|
|
65
|
+
fill: "none",
|
|
66
|
+
stroke: "currentColor",
|
|
67
|
+
strokeWidth: "2",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
|
|
70
|
+
/* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
) }),
|
|
74
|
+
onRename && /* @__PURE__ */ jsx(ActionIconButton, { title: "Renombrar", onClick: onRename, children: /* @__PURE__ */ jsxs(
|
|
75
|
+
"svg",
|
|
76
|
+
{
|
|
77
|
+
viewBox: "0 0 24 24",
|
|
78
|
+
className: "h-4.5 w-4.5",
|
|
79
|
+
fill: "none",
|
|
80
|
+
stroke: "currentColor",
|
|
81
|
+
strokeWidth: "2",
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsx("path", { d: "M3 21v-4l12-12 4 4-12 12z" }),
|
|
84
|
+
/* @__PURE__ */ jsx("path", { d: "M14 7l4 4" })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
) }),
|
|
88
|
+
onReplace && /* @__PURE__ */ jsx(ActionIconButton, { title: "Reemplazar", onClick: onReplace, children: /* @__PURE__ */ jsx(
|
|
89
|
+
"svg",
|
|
90
|
+
{
|
|
91
|
+
viewBox: "0 0 24 24",
|
|
92
|
+
className: "h-4.5 w-4.5",
|
|
93
|
+
fill: "none",
|
|
94
|
+
stroke: "currentColor",
|
|
95
|
+
strokeWidth: "2",
|
|
96
|
+
children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M5 12h14" })
|
|
97
|
+
}
|
|
98
|
+
) }),
|
|
99
|
+
onDelete && /* @__PURE__ */ jsx(ActionIconButton, { title: "Eliminar", danger: true, onClick: onDelete, children: /* @__PURE__ */ jsxs(
|
|
100
|
+
"svg",
|
|
101
|
+
{
|
|
102
|
+
viewBox: "0 0 24 24",
|
|
103
|
+
className: "h-4.5 w-4.5",
|
|
104
|
+
fill: "none",
|
|
105
|
+
stroke: "currentColor",
|
|
106
|
+
strokeWidth: "2",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx("path", { d: "M3 6h18" }),
|
|
109
|
+
/* @__PURE__ */ jsx("path", { d: "M8 6v14a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V6" }),
|
|
110
|
+
/* @__PURE__ */ jsx("path", { d: "M10 11v6M14 11v6" }),
|
|
111
|
+
/* @__PURE__ */ jsx("path", { d: "M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2" })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
) })
|
|
115
|
+
] })
|
|
116
|
+
] })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
MediaCard as default
|
|
123
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type MediaSelectorItem = {
|
|
4
|
+
id: number | string;
|
|
5
|
+
nombre: string;
|
|
6
|
+
url?: string | null;
|
|
7
|
+
};
|
|
8
|
+
type MediosAdapter = {
|
|
9
|
+
items: MediaSelectorItem[];
|
|
10
|
+
page: number;
|
|
11
|
+
lastPage: number;
|
|
12
|
+
setPage: (p: number) => void;
|
|
13
|
+
obtenerMedios: (opts?: {
|
|
14
|
+
page?: number;
|
|
15
|
+
per_page?: number;
|
|
16
|
+
}) => Promise<any>;
|
|
17
|
+
subirMedio: (file: File, opts?: {
|
|
18
|
+
onProgress?: (p: {
|
|
19
|
+
porcentaje: number;
|
|
20
|
+
}) => void;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
ok: boolean;
|
|
23
|
+
data?: any;
|
|
24
|
+
error?: any;
|
|
25
|
+
}>;
|
|
26
|
+
importFromUrl?: (url: string) => Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
data?: any;
|
|
29
|
+
error?: any;
|
|
30
|
+
}>;
|
|
31
|
+
importarMedioDesdeUrl?: (url: string) => Promise<{
|
|
32
|
+
ok: boolean;
|
|
33
|
+
data?: any;
|
|
34
|
+
error?: any;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
declare function MediaSelector({ value, onChange, medios, accept, autoOpen, dialogOnly, onClose, }: {
|
|
38
|
+
value?: string | null;
|
|
39
|
+
onChange: (url: string | null, picked?: MediaSelectorItem | null) => void;
|
|
40
|
+
medios: MediosAdapter;
|
|
41
|
+
label?: string;
|
|
42
|
+
accept?: string;
|
|
43
|
+
autoOpen?: boolean;
|
|
44
|
+
dialogOnly?: boolean;
|
|
45
|
+
onClose?: () => void;
|
|
46
|
+
}): react_jsx_runtime.JSX.Element;
|
|
47
|
+
|
|
48
|
+
export { type MediaSelectorItem, type MediosAdapter, MediaSelector as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type MediaSelectorItem = {
|
|
4
|
+
id: number | string;
|
|
5
|
+
nombre: string;
|
|
6
|
+
url?: string | null;
|
|
7
|
+
};
|
|
8
|
+
type MediosAdapter = {
|
|
9
|
+
items: MediaSelectorItem[];
|
|
10
|
+
page: number;
|
|
11
|
+
lastPage: number;
|
|
12
|
+
setPage: (p: number) => void;
|
|
13
|
+
obtenerMedios: (opts?: {
|
|
14
|
+
page?: number;
|
|
15
|
+
per_page?: number;
|
|
16
|
+
}) => Promise<any>;
|
|
17
|
+
subirMedio: (file: File, opts?: {
|
|
18
|
+
onProgress?: (p: {
|
|
19
|
+
porcentaje: number;
|
|
20
|
+
}) => void;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
ok: boolean;
|
|
23
|
+
data?: any;
|
|
24
|
+
error?: any;
|
|
25
|
+
}>;
|
|
26
|
+
importFromUrl?: (url: string) => Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
data?: any;
|
|
29
|
+
error?: any;
|
|
30
|
+
}>;
|
|
31
|
+
importarMedioDesdeUrl?: (url: string) => Promise<{
|
|
32
|
+
ok: boolean;
|
|
33
|
+
data?: any;
|
|
34
|
+
error?: any;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
declare function MediaSelector({ value, onChange, medios, accept, autoOpen, dialogOnly, onClose, }: {
|
|
38
|
+
value?: string | null;
|
|
39
|
+
onChange: (url: string | null, picked?: MediaSelectorItem | null) => void;
|
|
40
|
+
medios: MediosAdapter;
|
|
41
|
+
label?: string;
|
|
42
|
+
accept?: string;
|
|
43
|
+
autoOpen?: boolean;
|
|
44
|
+
dialogOnly?: boolean;
|
|
45
|
+
onClose?: () => void;
|
|
46
|
+
}): react_jsx_runtime.JSX.Element;
|
|
47
|
+
|
|
48
|
+
export { type MediaSelectorItem, type MediosAdapter, MediaSelector as default };
|
|
@@ -0,0 +1,225 @@
|
|
|
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 MediaSelector_exports = {};
|
|
31
|
+
__export(MediaSelector_exports, {
|
|
32
|
+
default: () => MediaSelector
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(MediaSelector_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_ChartCard = __toESM(require("./ChartCard"));
|
|
38
|
+
var import_Button = __toESM(require("./Button"));
|
|
39
|
+
var import_Input = __toESM(require("./Input"));
|
|
40
|
+
var import_Dialog = __toESM(require("./Dialog"));
|
|
41
|
+
var import_Pagination = __toESM(require("./Pagination"));
|
|
42
|
+
function MediaSelector({
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
medios,
|
|
46
|
+
accept = "image/png,image/jpeg,image/jpg,image/webp,image/gif",
|
|
47
|
+
autoOpen,
|
|
48
|
+
dialogOnly,
|
|
49
|
+
onClose
|
|
50
|
+
}) {
|
|
51
|
+
const { obtenerMedios, items, page, lastPage, setPage, subirMedio } = medios;
|
|
52
|
+
const [openPicker, setOpenPicker] = (0, import_react.useState)(false);
|
|
53
|
+
const [uploading, setUploading] = (0, import_react.useState)(false);
|
|
54
|
+
const [progress, setProgress] = (0, import_react.useState)(0);
|
|
55
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
56
|
+
const [linkValue, setLinkValue] = (0, import_react.useState)(value != null ? value : "");
|
|
57
|
+
const [linkLoading, setLinkLoading] = (0, import_react.useState)(false);
|
|
58
|
+
const [linkError, setLinkError] = (0, import_react.useState)(null);
|
|
59
|
+
(0, import_react.useEffect)(() => {
|
|
60
|
+
if (openPicker) obtenerMedios({ page: page || 1 });
|
|
61
|
+
}, [openPicker, page, obtenerMedios]);
|
|
62
|
+
(0, import_react.useEffect)(() => {
|
|
63
|
+
if (autoOpen) setOpenPicker(true);
|
|
64
|
+
}, [autoOpen]);
|
|
65
|
+
(0, import_react.useEffect)(() => {
|
|
66
|
+
if (openPicker) setLinkValue(value != null ? value : "");
|
|
67
|
+
}, [openPicker, value]);
|
|
68
|
+
const onFiles = async (files) => {
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
if (!(files == null ? void 0 : files.length)) return;
|
|
71
|
+
const file = files[0];
|
|
72
|
+
setUploading(true);
|
|
73
|
+
setProgress(0);
|
|
74
|
+
const res = await subirMedio(file, { onProgress: (p) => setProgress(p.porcentaje) });
|
|
75
|
+
setUploading(false);
|
|
76
|
+
if (res.ok) {
|
|
77
|
+
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;
|
|
78
|
+
onChange(url, res.data);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const handleDrop = (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
onFiles(e.dataTransfer.files);
|
|
84
|
+
};
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
86
|
+
!dialogOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
88
|
+
/* @__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) }),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { variant: "secondary", onClick: () => setOpenPicker(true), children: "Elegir" })
|
|
90
|
+
] }),
|
|
91
|
+
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" }) }) })
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Dialog.default, { open: openPicker, onClose: () => {
|
|
94
|
+
setOpenPicker(false);
|
|
95
|
+
onClose == null ? void 0 : onClose();
|
|
96
|
+
}, size: "full", children: [
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Header, { title: "Biblioteca de medios", description: "Selecciona una imagen o sube una nueva", onClose: () => {
|
|
98
|
+
setOpenPicker(false);
|
|
99
|
+
onClose == null ? void 0 : onClose();
|
|
100
|
+
} }),
|
|
101
|
+
/* @__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-3", children: [
|
|
102
|
+
/* @__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: [
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Input.default, { unstyled: true, ref: inputRef, type: "file", accept, className: "hidden", onChange: (e) => onFiles(e.target.files) }),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { onClick: () => {
|
|
105
|
+
var _a;
|
|
106
|
+
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
107
|
+
}, disabled: uploading, children: "Seleccionar" })
|
|
108
|
+
] }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
onDragOver: (e) => {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
e.dataTransfer.dropEffect = "copy";
|
|
114
|
+
},
|
|
115
|
+
onDrop: handleDrop,
|
|
116
|
+
onClick: () => {
|
|
117
|
+
var _a;
|
|
118
|
+
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
119
|
+
},
|
|
120
|
+
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",
|
|
121
|
+
children: [
|
|
122
|
+
/* @__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" }) }),
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-medium", children: "Soltar imagen aqu\xED" }),
|
|
124
|
+
uploading && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-3 w-full", children: [
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-1 text-xs text-slate-500", children: [
|
|
126
|
+
progress,
|
|
127
|
+
"%"
|
|
128
|
+
] }),
|
|
129
|
+
/* @__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)("div", { className: "h-full bg-gradient-to-r from-emerald-500/70 to-emerald-500/20", style: { width: `${progress}%` } }) })
|
|
130
|
+
] })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
) }),
|
|
134
|
+
/* @__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: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
137
|
+
import_Input.default,
|
|
138
|
+
{
|
|
139
|
+
type: "url",
|
|
140
|
+
placeholder: "https://\u2026",
|
|
141
|
+
value: linkValue,
|
|
142
|
+
onChange: (e) => {
|
|
143
|
+
setLinkValue(e.target.value);
|
|
144
|
+
setLinkError(null);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
149
|
+
import_Button.default,
|
|
150
|
+
{
|
|
151
|
+
onClick: async () => {
|
|
152
|
+
var _a, _b, _c, _d;
|
|
153
|
+
if (!linkValue) return;
|
|
154
|
+
setLinkError(null);
|
|
155
|
+
const isHttp = /^https?:\/\//i.test(linkValue);
|
|
156
|
+
if (!isHttp) {
|
|
157
|
+
setLinkError("Ingresa un enlace v\xE1lido (http/https)");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const importer = (_a = medios.importFromUrl) != null ? _a : medios.importarMedioDesdeUrl;
|
|
161
|
+
if (importer) {
|
|
162
|
+
setLinkLoading(true);
|
|
163
|
+
const res = await importer(linkValue);
|
|
164
|
+
setLinkLoading(false);
|
|
165
|
+
if (res && res.ok) {
|
|
166
|
+
const d = (_b = res.data) != null ? _b : res;
|
|
167
|
+
onChange((_c = d == null ? void 0 : d.url) != null ? _c : null, d != null ? d : null);
|
|
168
|
+
setOpenPicker(false);
|
|
169
|
+
onClose == null ? void 0 : onClose();
|
|
170
|
+
} else {
|
|
171
|
+
setLinkError(String((_d = res == null ? void 0 : res.error) != null ? _d : "No se pudo importar el enlace"));
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
onChange(linkValue || null, null);
|
|
175
|
+
setOpenPicker(false);
|
|
176
|
+
onClose == null ? void 0 : onClose();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
disabled: !linkValue || linkLoading,
|
|
180
|
+
children: linkLoading ? "Importando\u2026" : "Usar"
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
] }),
|
|
184
|
+
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 })
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "lg:col-span-2 space-y-3", children: [
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "text-sm text-slate-500", children: [
|
|
189
|
+
"P\xE1gina ",
|
|
190
|
+
page,
|
|
191
|
+
" de ",
|
|
192
|
+
Math.max(1, lastPage)
|
|
193
|
+
] }),
|
|
194
|
+
lastPage > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Pagination.default, { page, totalPages: lastPage, onPageChange: setPage })
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4", children: items.map((m) => {
|
|
197
|
+
var _a;
|
|
198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
199
|
+
import_Button.default,
|
|
200
|
+
{
|
|
201
|
+
unstyled: true,
|
|
202
|
+
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",
|
|
203
|
+
onClick: () => {
|
|
204
|
+
var _a2;
|
|
205
|
+
onChange((_a2 = m.url) != null ? _a2 : null, m);
|
|
206
|
+
setOpenPicker(false);
|
|
207
|
+
onClose == null ? void 0 : onClose();
|
|
208
|
+
},
|
|
209
|
+
children: [
|
|
210
|
+
/* @__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-[1.01]" }) }),
|
|
211
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "truncate p-1 text-xs", children: m.nombre })
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
m.id
|
|
215
|
+
);
|
|
216
|
+
}) })
|
|
217
|
+
] })
|
|
218
|
+
] }) }),
|
|
219
|
+
/* @__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: () => {
|
|
220
|
+
setOpenPicker(false);
|
|
221
|
+
onClose == null ? void 0 : onClose();
|
|
222
|
+
}, children: "Cerrar" }) })
|
|
223
|
+
] })
|
|
224
|
+
] });
|
|
225
|
+
}
|