next-recomponents 1.7.15 → 1.7.16
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/index.d.mts +27 -15
- package/dist/index.d.ts +27 -15
- package/dist/index.js +52 -0
- package/dist/index.mjs +51 -0
- package/package.json +1 -1
- package/src/doc-viewer/index.tsx +69 -0
- package/src/index.tsx +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { DetailedHTMLProps, ButtonHTMLAttributes, Dispatch, SetStateAction, InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
|
-
interface Props$
|
|
4
|
+
interface Props$6 {
|
|
5
5
|
color?: "white" | "primary" | "secondary" | "info" | "danger" | "warning" | "success";
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
}
|
|
8
|
-
declare function Alert({ color, children, ...props }: Props$
|
|
8
|
+
declare function Alert({ color, children, ...props }: Props$6): react_jsx_runtime.JSX.Element;
|
|
9
9
|
|
|
10
|
-
interface Props$
|
|
10
|
+
interface Props$5 extends DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
11
11
|
icon?: React.ReactNode;
|
|
12
12
|
size?: "full" | "small";
|
|
13
13
|
color?: "white" | "primary" | "secondary" | "info" | "danger" | "warning" | "success";
|
|
14
14
|
}
|
|
15
|
-
declare function Button({ className, size, color, children, icon, disabled, ...props }: Props$
|
|
15
|
+
declare function Button({ className, size, color, children, icon, disabled, ...props }: Props$5): react_jsx_runtime.JSX.Element;
|
|
16
16
|
|
|
17
17
|
type LocationItem = {
|
|
18
18
|
location: string;
|
|
@@ -33,7 +33,7 @@ declare function Container({ children, appName, menuList, navItems, leftPanel, f
|
|
|
33
33
|
interface OnSubmitProps extends React$1.FormEvent<HTMLFormElement> {
|
|
34
34
|
values: Record<string, any>;
|
|
35
35
|
}
|
|
36
|
-
interface Props$
|
|
36
|
+
interface Props$4 extends React$1.DetailedHTMLProps<React$1.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement> {
|
|
37
37
|
onSubmit: (e: OnSubmitProps) => void | Promise<void>;
|
|
38
38
|
children: React$1.ReactNode;
|
|
39
39
|
state?: [any, Dispatch<SetStateAction<any>>];
|
|
@@ -41,7 +41,7 @@ interface Props$3 extends React$1.DetailedHTMLProps<React$1.FormHTMLAttributes<H
|
|
|
41
41
|
loader?: React$1.ReactNode;
|
|
42
42
|
}
|
|
43
43
|
declare function useFormValues<T>(initial: Partial<T>): [Partial<T>, React$1.Dispatch<Partial<T>>];
|
|
44
|
-
declare function Form({ onSubmit, state, invalidMessage, children, loader, ...otherProps }: Props$
|
|
44
|
+
declare function Form({ onSubmit, state, invalidMessage, children, loader, ...otherProps }: Props$4): react_jsx_runtime.JSX.Element;
|
|
45
45
|
|
|
46
46
|
interface InputProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
|
47
47
|
label: React.ReactNode;
|
|
@@ -57,11 +57,11 @@ declare const regularExpresions: {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
type DataType = string | number | Date | object | undefined | null;
|
|
60
|
-
type Item = {
|
|
60
|
+
type Item$1 = {
|
|
61
61
|
content: DataType;
|
|
62
62
|
handler: ReactNode;
|
|
63
63
|
};
|
|
64
|
-
type DataTypeOrItem = DataType | Item;
|
|
64
|
+
type DataTypeOrItem = DataType | Item$1;
|
|
65
65
|
type TableEventPropsItem = {
|
|
66
66
|
index: number;
|
|
67
67
|
originalData: number;
|
|
@@ -91,18 +91,18 @@ interface TableProps extends React.DetailedHTMLProps<React.TableHTMLAttributes<H
|
|
|
91
91
|
}
|
|
92
92
|
declare function Table({ ...props }: TableProps): react_jsx_runtime.JSX.Element;
|
|
93
93
|
|
|
94
|
-
interface Props$
|
|
94
|
+
interface Props$3 extends DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {
|
|
95
95
|
label?: React$1.ReactNode;
|
|
96
96
|
maxLength?: number;
|
|
97
97
|
}
|
|
98
|
-
declare function TextArea({ label, className, maxLength, onChange, children, ...props }: Props$
|
|
98
|
+
declare function TextArea({ label, className, maxLength, onChange, children, ...props }: Props$3): react_jsx_runtime.JSX.Element;
|
|
99
99
|
|
|
100
100
|
interface ItemsRecord<T = any> {
|
|
101
101
|
typeof: T;
|
|
102
102
|
id?: number | string | string[] | undefined;
|
|
103
103
|
defaultParams?: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
interface Props$
|
|
105
|
+
interface Props$2<T extends Record<string, ItemsRecord>> {
|
|
106
106
|
baseURI: string;
|
|
107
107
|
endpoints: T;
|
|
108
108
|
onError?: (error: any) => void;
|
|
@@ -138,7 +138,7 @@ type EnhancedEndpoints<T extends Record<string, ItemsRecord>> = {
|
|
|
138
138
|
};
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
declare function useResources<T extends Record<string, ItemsRecord>>({ baseURI, endpoints, onError, }: Props$
|
|
141
|
+
declare function useResources<T extends Record<string, ItemsRecord>>({ baseURI, endpoints, onError, }: Props$2<T>): EnhancedEndpoints<T>;
|
|
142
142
|
|
|
143
143
|
interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
|
144
144
|
label?: string;
|
|
@@ -152,7 +152,7 @@ interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLA
|
|
|
152
152
|
}
|
|
153
153
|
declare function Select({ label, placeholder, children, strictMode, ...props }: CustomSelectProps): react_jsx_runtime.JSX.Element;
|
|
154
154
|
|
|
155
|
-
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
155
|
+
interface Props$1 extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
156
156
|
button: React$1.ReactElement<{
|
|
157
157
|
onClick: (e: React$1.MouseEvent) => void;
|
|
158
158
|
}>;
|
|
@@ -160,7 +160,7 @@ interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<H
|
|
|
160
160
|
hide: () => void;
|
|
161
161
|
}>;
|
|
162
162
|
}
|
|
163
|
-
declare function Modal({ button, children, ref, title }: Props): react_jsx_runtime.JSX.Element;
|
|
163
|
+
declare function Modal({ button, children, ref, title }: Props$1): react_jsx_runtime.JSX.Element;
|
|
164
164
|
|
|
165
165
|
type PreProps = {
|
|
166
166
|
data: string;
|
|
@@ -190,4 +190,16 @@ interface CalendarProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputE
|
|
|
190
190
|
}
|
|
191
191
|
declare function MyCalendar({ enabledDates, onChange, defaultValue, className, label, value, ...otherProps }: CalendarProps): react_jsx_runtime.JSX.Element | null;
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
type Item = {
|
|
194
|
+
url: string;
|
|
195
|
+
name: string;
|
|
196
|
+
contentType: string;
|
|
197
|
+
width?: string;
|
|
198
|
+
height?: string;
|
|
199
|
+
};
|
|
200
|
+
type Props = {
|
|
201
|
+
item: Item;
|
|
202
|
+
};
|
|
203
|
+
declare function DocumentViewer({ item }: Props): react_jsx_runtime.JSX.Element;
|
|
204
|
+
|
|
205
|
+
export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, type TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, useResources };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { DetailedHTMLProps, ButtonHTMLAttributes, Dispatch, SetStateAction, InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
|
-
interface Props$
|
|
4
|
+
interface Props$6 {
|
|
5
5
|
color?: "white" | "primary" | "secondary" | "info" | "danger" | "warning" | "success";
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
}
|
|
8
|
-
declare function Alert({ color, children, ...props }: Props$
|
|
8
|
+
declare function Alert({ color, children, ...props }: Props$6): react_jsx_runtime.JSX.Element;
|
|
9
9
|
|
|
10
|
-
interface Props$
|
|
10
|
+
interface Props$5 extends DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
11
11
|
icon?: React.ReactNode;
|
|
12
12
|
size?: "full" | "small";
|
|
13
13
|
color?: "white" | "primary" | "secondary" | "info" | "danger" | "warning" | "success";
|
|
14
14
|
}
|
|
15
|
-
declare function Button({ className, size, color, children, icon, disabled, ...props }: Props$
|
|
15
|
+
declare function Button({ className, size, color, children, icon, disabled, ...props }: Props$5): react_jsx_runtime.JSX.Element;
|
|
16
16
|
|
|
17
17
|
type LocationItem = {
|
|
18
18
|
location: string;
|
|
@@ -33,7 +33,7 @@ declare function Container({ children, appName, menuList, navItems, leftPanel, f
|
|
|
33
33
|
interface OnSubmitProps extends React$1.FormEvent<HTMLFormElement> {
|
|
34
34
|
values: Record<string, any>;
|
|
35
35
|
}
|
|
36
|
-
interface Props$
|
|
36
|
+
interface Props$4 extends React$1.DetailedHTMLProps<React$1.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement> {
|
|
37
37
|
onSubmit: (e: OnSubmitProps) => void | Promise<void>;
|
|
38
38
|
children: React$1.ReactNode;
|
|
39
39
|
state?: [any, Dispatch<SetStateAction<any>>];
|
|
@@ -41,7 +41,7 @@ interface Props$3 extends React$1.DetailedHTMLProps<React$1.FormHTMLAttributes<H
|
|
|
41
41
|
loader?: React$1.ReactNode;
|
|
42
42
|
}
|
|
43
43
|
declare function useFormValues<T>(initial: Partial<T>): [Partial<T>, React$1.Dispatch<Partial<T>>];
|
|
44
|
-
declare function Form({ onSubmit, state, invalidMessage, children, loader, ...otherProps }: Props$
|
|
44
|
+
declare function Form({ onSubmit, state, invalidMessage, children, loader, ...otherProps }: Props$4): react_jsx_runtime.JSX.Element;
|
|
45
45
|
|
|
46
46
|
interface InputProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
|
47
47
|
label: React.ReactNode;
|
|
@@ -57,11 +57,11 @@ declare const regularExpresions: {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
type DataType = string | number | Date | object | undefined | null;
|
|
60
|
-
type Item = {
|
|
60
|
+
type Item$1 = {
|
|
61
61
|
content: DataType;
|
|
62
62
|
handler: ReactNode;
|
|
63
63
|
};
|
|
64
|
-
type DataTypeOrItem = DataType | Item;
|
|
64
|
+
type DataTypeOrItem = DataType | Item$1;
|
|
65
65
|
type TableEventPropsItem = {
|
|
66
66
|
index: number;
|
|
67
67
|
originalData: number;
|
|
@@ -91,18 +91,18 @@ interface TableProps extends React.DetailedHTMLProps<React.TableHTMLAttributes<H
|
|
|
91
91
|
}
|
|
92
92
|
declare function Table({ ...props }: TableProps): react_jsx_runtime.JSX.Element;
|
|
93
93
|
|
|
94
|
-
interface Props$
|
|
94
|
+
interface Props$3 extends DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {
|
|
95
95
|
label?: React$1.ReactNode;
|
|
96
96
|
maxLength?: number;
|
|
97
97
|
}
|
|
98
|
-
declare function TextArea({ label, className, maxLength, onChange, children, ...props }: Props$
|
|
98
|
+
declare function TextArea({ label, className, maxLength, onChange, children, ...props }: Props$3): react_jsx_runtime.JSX.Element;
|
|
99
99
|
|
|
100
100
|
interface ItemsRecord<T = any> {
|
|
101
101
|
typeof: T;
|
|
102
102
|
id?: number | string | string[] | undefined;
|
|
103
103
|
defaultParams?: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
interface Props$
|
|
105
|
+
interface Props$2<T extends Record<string, ItemsRecord>> {
|
|
106
106
|
baseURI: string;
|
|
107
107
|
endpoints: T;
|
|
108
108
|
onError?: (error: any) => void;
|
|
@@ -138,7 +138,7 @@ type EnhancedEndpoints<T extends Record<string, ItemsRecord>> = {
|
|
|
138
138
|
};
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
declare function useResources<T extends Record<string, ItemsRecord>>({ baseURI, endpoints, onError, }: Props$
|
|
141
|
+
declare function useResources<T extends Record<string, ItemsRecord>>({ baseURI, endpoints, onError, }: Props$2<T>): EnhancedEndpoints<T>;
|
|
142
142
|
|
|
143
143
|
interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
|
144
144
|
label?: string;
|
|
@@ -152,7 +152,7 @@ interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLA
|
|
|
152
152
|
}
|
|
153
153
|
declare function Select({ label, placeholder, children, strictMode, ...props }: CustomSelectProps): react_jsx_runtime.JSX.Element;
|
|
154
154
|
|
|
155
|
-
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
155
|
+
interface Props$1 extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
156
156
|
button: React$1.ReactElement<{
|
|
157
157
|
onClick: (e: React$1.MouseEvent) => void;
|
|
158
158
|
}>;
|
|
@@ -160,7 +160,7 @@ interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<H
|
|
|
160
160
|
hide: () => void;
|
|
161
161
|
}>;
|
|
162
162
|
}
|
|
163
|
-
declare function Modal({ button, children, ref, title }: Props): react_jsx_runtime.JSX.Element;
|
|
163
|
+
declare function Modal({ button, children, ref, title }: Props$1): react_jsx_runtime.JSX.Element;
|
|
164
164
|
|
|
165
165
|
type PreProps = {
|
|
166
166
|
data: string;
|
|
@@ -190,4 +190,16 @@ interface CalendarProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputE
|
|
|
190
190
|
}
|
|
191
191
|
declare function MyCalendar({ enabledDates, onChange, defaultValue, className, label, value, ...otherProps }: CalendarProps): react_jsx_runtime.JSX.Element | null;
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
type Item = {
|
|
194
|
+
url: string;
|
|
195
|
+
name: string;
|
|
196
|
+
contentType: string;
|
|
197
|
+
width?: string;
|
|
198
|
+
height?: string;
|
|
199
|
+
};
|
|
200
|
+
type Props = {
|
|
201
|
+
item: Item;
|
|
202
|
+
};
|
|
203
|
+
declare function DocumentViewer({ item }: Props): react_jsx_runtime.JSX.Element;
|
|
204
|
+
|
|
205
|
+
export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, type TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, useResources };
|
package/dist/index.js
CHANGED
|
@@ -2971,6 +2971,7 @@ __export(index_exports, {
|
|
|
2971
2971
|
Alert: () => Alert,
|
|
2972
2972
|
Button: () => Button,
|
|
2973
2973
|
Container: () => Container,
|
|
2974
|
+
DocumentViewer: () => DocumentViewer,
|
|
2974
2975
|
Form: () => Form,
|
|
2975
2976
|
Input: () => Input,
|
|
2976
2977
|
Modal: () => Modal,
|
|
@@ -44673,11 +44674,62 @@ function MyCalendar(_a) {
|
|
|
44673
44674
|
)
|
|
44674
44675
|
] });
|
|
44675
44676
|
}
|
|
44677
|
+
|
|
44678
|
+
// src/doc-viewer/index.tsx
|
|
44679
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
44680
|
+
function DocumentViewer({ item }) {
|
|
44681
|
+
const { url, name, contentType, width = "100%", height = "100%" } = item;
|
|
44682
|
+
const isImage = contentType.startsWith("image/");
|
|
44683
|
+
const isPdf = contentType === "application/pdf";
|
|
44684
|
+
const isGoogleDocCompatible = isPdf || contentType.includes("msword") || contentType.includes("officedocument") || contentType.includes("presentation");
|
|
44685
|
+
const viewerUrl = isGoogleDocCompatible ? `https://docs.google.com/gview?url=${encodeURIComponent(
|
|
44686
|
+
url
|
|
44687
|
+
)}&embedded=true` : url;
|
|
44688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "border shadow rounded p-2 h-[100%]", children: [
|
|
44689
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "mb-1 flex justify-between ", children: [
|
|
44690
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { className: "font-bold", children: name }),
|
|
44691
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
44692
|
+
"a",
|
|
44693
|
+
{
|
|
44694
|
+
href: url,
|
|
44695
|
+
download: name,
|
|
44696
|
+
target: "_blank",
|
|
44697
|
+
rel: "noopener noreferrer",
|
|
44698
|
+
className: "border shadow rounded bg-blue-400 text-white p-2",
|
|
44699
|
+
children: "Descargar"
|
|
44700
|
+
}
|
|
44701
|
+
)
|
|
44702
|
+
] }),
|
|
44703
|
+
isImage ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
44704
|
+
"img",
|
|
44705
|
+
{
|
|
44706
|
+
src: url,
|
|
44707
|
+
alt: name,
|
|
44708
|
+
style: {
|
|
44709
|
+
width,
|
|
44710
|
+
height,
|
|
44711
|
+
maxWidth: "100%",
|
|
44712
|
+
objectFit: "cover",
|
|
44713
|
+
display: "block"
|
|
44714
|
+
}
|
|
44715
|
+
}
|
|
44716
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
44717
|
+
"iframe",
|
|
44718
|
+
{
|
|
44719
|
+
title: name,
|
|
44720
|
+
src: viewerUrl,
|
|
44721
|
+
style: { width, height, border: "none" },
|
|
44722
|
+
allowFullScreen: true
|
|
44723
|
+
}
|
|
44724
|
+
)
|
|
44725
|
+
] });
|
|
44726
|
+
}
|
|
44676
44727
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44677
44728
|
0 && (module.exports = {
|
|
44678
44729
|
Alert,
|
|
44679
44730
|
Button,
|
|
44680
44731
|
Container,
|
|
44732
|
+
DocumentViewer,
|
|
44681
44733
|
Form,
|
|
44682
44734
|
Input,
|
|
44683
44735
|
Modal,
|
package/dist/index.mjs
CHANGED
|
@@ -44666,10 +44666,61 @@ function MyCalendar(_a) {
|
|
|
44666
44666
|
)
|
|
44667
44667
|
] });
|
|
44668
44668
|
}
|
|
44669
|
+
|
|
44670
|
+
// src/doc-viewer/index.tsx
|
|
44671
|
+
import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
44672
|
+
function DocumentViewer({ item }) {
|
|
44673
|
+
const { url, name, contentType, width = "100%", height = "100%" } = item;
|
|
44674
|
+
const isImage = contentType.startsWith("image/");
|
|
44675
|
+
const isPdf = contentType === "application/pdf";
|
|
44676
|
+
const isGoogleDocCompatible = isPdf || contentType.includes("msword") || contentType.includes("officedocument") || contentType.includes("presentation");
|
|
44677
|
+
const viewerUrl = isGoogleDocCompatible ? `https://docs.google.com/gview?url=${encodeURIComponent(
|
|
44678
|
+
url
|
|
44679
|
+
)}&embedded=true` : url;
|
|
44680
|
+
return /* @__PURE__ */ jsxs15("div", { className: "border shadow rounded p-2 h-[100%]", children: [
|
|
44681
|
+
/* @__PURE__ */ jsxs15("div", { className: "mb-1 flex justify-between ", children: [
|
|
44682
|
+
/* @__PURE__ */ jsx23("h3", { className: "font-bold", children: name }),
|
|
44683
|
+
/* @__PURE__ */ jsx23(
|
|
44684
|
+
"a",
|
|
44685
|
+
{
|
|
44686
|
+
href: url,
|
|
44687
|
+
download: name,
|
|
44688
|
+
target: "_blank",
|
|
44689
|
+
rel: "noopener noreferrer",
|
|
44690
|
+
className: "border shadow rounded bg-blue-400 text-white p-2",
|
|
44691
|
+
children: "Descargar"
|
|
44692
|
+
}
|
|
44693
|
+
)
|
|
44694
|
+
] }),
|
|
44695
|
+
isImage ? /* @__PURE__ */ jsx23(
|
|
44696
|
+
"img",
|
|
44697
|
+
{
|
|
44698
|
+
src: url,
|
|
44699
|
+
alt: name,
|
|
44700
|
+
style: {
|
|
44701
|
+
width,
|
|
44702
|
+
height,
|
|
44703
|
+
maxWidth: "100%",
|
|
44704
|
+
objectFit: "cover",
|
|
44705
|
+
display: "block"
|
|
44706
|
+
}
|
|
44707
|
+
}
|
|
44708
|
+
) : /* @__PURE__ */ jsx23(
|
|
44709
|
+
"iframe",
|
|
44710
|
+
{
|
|
44711
|
+
title: name,
|
|
44712
|
+
src: viewerUrl,
|
|
44713
|
+
style: { width, height, border: "none" },
|
|
44714
|
+
allowFullScreen: true
|
|
44715
|
+
}
|
|
44716
|
+
)
|
|
44717
|
+
] });
|
|
44718
|
+
}
|
|
44669
44719
|
export {
|
|
44670
44720
|
Alert,
|
|
44671
44721
|
Button,
|
|
44672
44722
|
Container,
|
|
44723
|
+
DocumentViewer,
|
|
44673
44724
|
Form,
|
|
44674
44725
|
Input,
|
|
44675
44726
|
Modal,
|
package/package.json
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
type Item = {
|
|
4
|
+
url: string;
|
|
5
|
+
name: string;
|
|
6
|
+
contentType: string;
|
|
7
|
+
width?: string;
|
|
8
|
+
height?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
item: Item;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default function DocumentViewer({ item }: Props) {
|
|
16
|
+
const { url, name, contentType, width = "100%", height = "100%" } = item;
|
|
17
|
+
|
|
18
|
+
const isImage = contentType.startsWith("image/");
|
|
19
|
+
const isPdf = contentType === "application/pdf";
|
|
20
|
+
const isGoogleDocCompatible =
|
|
21
|
+
isPdf ||
|
|
22
|
+
contentType.includes("msword") ||
|
|
23
|
+
contentType.includes("officedocument") ||
|
|
24
|
+
contentType.includes("presentation");
|
|
25
|
+
|
|
26
|
+
const viewerUrl = isGoogleDocCompatible
|
|
27
|
+
? `https://docs.google.com/gview?url=${encodeURIComponent(
|
|
28
|
+
url
|
|
29
|
+
)}&embedded=true`
|
|
30
|
+
: url;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="border shadow rounded p-2 h-[100%]">
|
|
34
|
+
<div className="mb-1 flex justify-between ">
|
|
35
|
+
<h3 className="font-bold">{name}</h3>
|
|
36
|
+
<a
|
|
37
|
+
href={url}
|
|
38
|
+
download={name}
|
|
39
|
+
target="_blank"
|
|
40
|
+
rel="noopener noreferrer"
|
|
41
|
+
className="border shadow rounded bg-blue-400 text-white p-2"
|
|
42
|
+
>
|
|
43
|
+
Descargar
|
|
44
|
+
</a>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
{isImage ? (
|
|
48
|
+
<img
|
|
49
|
+
src={url}
|
|
50
|
+
alt={name}
|
|
51
|
+
style={{
|
|
52
|
+
width: width,
|
|
53
|
+
height: height,
|
|
54
|
+
maxWidth: "100%",
|
|
55
|
+
objectFit: "cover",
|
|
56
|
+
display: "block",
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
) : (
|
|
60
|
+
<iframe
|
|
61
|
+
title={name}
|
|
62
|
+
src={viewerUrl}
|
|
63
|
+
style={{ width, height, border: "none" }}
|
|
64
|
+
allowFullScreen
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
package/src/index.tsx
CHANGED