@zauru-sdk/components 1.0.12 → 1.0.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/CHANGELOG.md +16 -0
- package/dist/Alerts/index.d.ts +0 -1
- package/dist/Alerts/index.js +0 -1
- package/dist/Chat/ChatLayout.d.ts +2 -2
- package/dist/Chat/ChatLayout.js +4 -3
- package/dist/Chat/ChatMessageHistory.js +1 -1
- package/dist/ConnectionState/ConnectionState.d.ts +2 -0
- package/dist/ConnectionState/ConnectionState.js +22 -0
- package/dist/ConnectionState/index.d.ts +1 -0
- package/dist/ConnectionState/index.js +1 -0
- package/dist/DynamicTable/BasicPrintDynamicTable.d.ts +10 -0
- package/dist/DynamicTable/BasicPrintDynamicTable.js +27 -0
- package/dist/DynamicTable/DynamicPrintTable.d.ts +23 -0
- package/dist/DynamicTable/DynamicPrintTable.js +132 -0
- package/dist/DynamicTable/GenericDynamicTable.d.ts +21 -0
- package/dist/DynamicTable/GenericDynamicTable.js +195 -0
- package/dist/DynamicTable/index.d.ts +24 -0
- package/dist/DynamicTable/index.js +193 -0
- package/dist/Footer/Footer.js +2 -2
- package/dist/Form/Checkbox/index.d.ts +17 -0
- package/dist/Form/Checkbox/index.js +34 -0
- package/dist/Form/Checklist/index.d.ts +14 -0
- package/dist/Form/Checklist/index.js +10 -0
- package/dist/Form/DatePicker/index.d.ts +18 -0
- package/dist/Form/DatePicker/index.js +31 -0
- package/dist/Form/DynamicBaculoForm/index.d.ts +18 -0
- package/dist/Form/DynamicBaculoForm/index.js +138 -0
- package/dist/Form/FieldContainer/DoubleFieldContainer.d.ts +8 -0
- package/dist/Form/FieldContainer/DoubleFieldContainer.js +14 -0
- package/dist/Form/FieldContainer/QuadrupleFieldContainer.d.ts +7 -0
- package/dist/Form/FieldContainer/QuadrupleFieldContainer.js +14 -0
- package/dist/Form/FieldContainer/TripleFieldContainer.d.ts +7 -0
- package/dist/Form/FieldContainer/TripleFieldContainer.js +14 -0
- package/dist/Form/FieldContainer/index.d.ts +3 -0
- package/dist/Form/FieldContainer/index.js +3 -0
- package/dist/Form/FileUpload/index.d.ts +21 -0
- package/dist/Form/FileUpload/index.js +54 -0
- package/dist/Form/FormButtons/index.d.ts +16 -0
- package/dist/Form/FormButtons/index.js +5 -0
- package/dist/Form/FormLayout/index.d.ts +11 -0
- package/dist/Form/FormLayout/index.js +7 -0
- package/dist/Form/SelectField/index.d.ts +27 -0
- package/dist/Form/SelectField/index.js +74 -0
- package/dist/Form/TextArea/index.d.ts +23 -0
- package/dist/Form/TextArea/index.js +36 -0
- package/dist/Form/TextField/index.d.ts +25 -0
- package/dist/Form/TextField/index.js +70 -0
- package/dist/Form/TimePicker/index.d.ts +16 -0
- package/dist/Form/TimePicker/index.js +31 -0
- package/dist/Form/YesNo/index.d.ts +12 -0
- package/dist/Form/YesNo/index.js +19 -0
- package/dist/Form/index.d.ts +13 -0
- package/dist/Form/index.js +13 -0
- package/dist/NavBar/NavBar.js +2 -2
- package/dist/Table/ZauruTable.js +1 -1
- package/dist/Zendesk/Chat.d.ts +2 -2
- package/dist/Zendesk/Chat.js +2 -1
- package/dist/Zendesk/zendesk.config.d.ts +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -2
- package/package.json +9 -8
- package/src/Alerts/index.ts +0 -1
- package/src/Chat/ChatLayout.tsx +133 -0
- package/src/Chat/ChatMessageHistory.tsx +142 -0
- package/src/Chat/index.ts +2 -0
- package/src/ConnectionState/ConnectionState.tsx +29 -0
- package/src/ConnectionState/index.tsx +1 -0
- package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -0
- package/src/DynamicTable/DynamicPrintTable.tsx +290 -0
- package/src/DynamicTable/GenericDynamicTable.tsx +455 -0
- package/src/DynamicTable/index.tsx +407 -0
- package/src/Footer/Footer.tsx +3 -3
- package/src/Form/Checkbox/index.tsx +96 -0
- package/src/Form/Checklist/index.tsx +35 -0
- package/src/Form/DatePicker/index.tsx +132 -0
- package/src/Form/DynamicBaculoForm/index.tsx +359 -0
- package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -0
- package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -0
- package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -0
- package/src/Form/FieldContainer/index.ts +3 -0
- package/src/Form/FileUpload/index.tsx +184 -0
- package/src/Form/FormButtons/index.tsx +78 -0
- package/src/Form/FormLayout/index.tsx +37 -0
- package/src/Form/SelectField/index.tsx +237 -0
- package/src/Form/TextArea/index.tsx +125 -0
- package/src/Form/TextField/index.tsx +194 -0
- package/src/Form/TimePicker/index.tsx +127 -0
- package/src/Form/YesNo/index.tsx +79 -0
- package/src/Form/index.ts +13 -0
- package/src/NavBar/NavBar.tsx +2 -2
- package/src/Table/ZauruTable.tsx +1 -1
- package/src/Zendesk/Chat.tsx +85 -0
- package/src/Zendesk/index.ts +2 -0
- package/src/Zendesk/zendesk.config.ts +40 -0
- package/src/index.ts +4 -2
- package/dist/Alerts/Alert.d.ts +0 -9
- package/dist/Alerts/Alert.js +0 -97
- package/dist/Icons/Icons.d.ts +0 -47
- package/dist/Icons/Icons.js +0 -110
- package/dist/Icons/StylesConstants.d.ts +0 -26
- package/dist/Icons/StylesConstants.js +0 -34
- package/src/Alerts/Alert.tsx +0 -149
- package/src/Icons/Icons.tsx +0 -782
- package/src/Icons/StylesConstants.tsx +0 -66
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ClockIconSVG, CloseSvgIcon, IdeaIconSVG } from "@zauru-sdk/icons";
|
|
2
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
|
+
import React, { useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
id?: string;
|
|
7
|
+
name: string;
|
|
8
|
+
formName?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
helpText?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
tabIndex?: number;
|
|
15
|
+
error?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
20
|
+
const {
|
|
21
|
+
id,
|
|
22
|
+
name,
|
|
23
|
+
title,
|
|
24
|
+
defaultValue = "",
|
|
25
|
+
hint,
|
|
26
|
+
helpText,
|
|
27
|
+
onChange,
|
|
28
|
+
tabIndex,
|
|
29
|
+
error,
|
|
30
|
+
disabled = false,
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const [value, setValue] = useState<string>(defaultValue);
|
|
34
|
+
const [showTooltip, setShowTooltip] = useState<boolean>(false);
|
|
35
|
+
|
|
36
|
+
const color = error ? "red" : "gray";
|
|
37
|
+
|
|
38
|
+
const isReadOnly = disabled;
|
|
39
|
+
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
40
|
+
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-500`;
|
|
41
|
+
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setValue(defaultValue);
|
|
45
|
+
}, [defaultValue]);
|
|
46
|
+
|
|
47
|
+
const clearValue = () => {
|
|
48
|
+
setValue("");
|
|
49
|
+
onChange && onChange("");
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{title && (
|
|
55
|
+
<label
|
|
56
|
+
htmlFor={error ? `${name}-error` : `${name}-success`}
|
|
57
|
+
className={`block text-sm font-medium ${textColor}`}
|
|
58
|
+
>
|
|
59
|
+
{title}
|
|
60
|
+
</label>
|
|
61
|
+
)}
|
|
62
|
+
<div className="flex relative items-center">
|
|
63
|
+
<div className="absolute left-0 flex items-center pl-3 pointer-events-none">
|
|
64
|
+
<ClockIconSVG />
|
|
65
|
+
</div>
|
|
66
|
+
<input
|
|
67
|
+
id={id}
|
|
68
|
+
name={name}
|
|
69
|
+
tabIndex={tabIndex}
|
|
70
|
+
type="time"
|
|
71
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
72
|
+
setValue(e.target.value);
|
|
73
|
+
onChange && onChange(e.target.value);
|
|
74
|
+
}}
|
|
75
|
+
value={value}
|
|
76
|
+
pattern="\d{2}:\d{2}"
|
|
77
|
+
className={`${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`}
|
|
78
|
+
/>
|
|
79
|
+
{value && (
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
onClick={clearValue}
|
|
83
|
+
className="absolute right-0 mr-10"
|
|
84
|
+
>
|
|
85
|
+
<CloseSvgIcon />
|
|
86
|
+
</button>
|
|
87
|
+
)}
|
|
88
|
+
{helpText && (
|
|
89
|
+
<div className="flex items-center relative ml-3">
|
|
90
|
+
<div
|
|
91
|
+
className="relative cursor-pointer"
|
|
92
|
+
onMouseEnter={() => setShowTooltip(true)}
|
|
93
|
+
onMouseLeave={() => setShowTooltip(false)}
|
|
94
|
+
>
|
|
95
|
+
<IdeaIconSVG />
|
|
96
|
+
{showTooltip && (
|
|
97
|
+
<div className="absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black">
|
|
98
|
+
{helpText}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
{error && (
|
|
106
|
+
<p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
|
|
107
|
+
<span className="font-medium">Oops!</span> {error}
|
|
108
|
+
</p>
|
|
109
|
+
)}
|
|
110
|
+
{!error && hint && (
|
|
111
|
+
<p
|
|
112
|
+
className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
|
|
113
|
+
>
|
|
114
|
+
{hint}
|
|
115
|
+
</p>
|
|
116
|
+
)}
|
|
117
|
+
</>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const FormTimePicker = (props: Props) => {
|
|
122
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
123
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
124
|
+
props = { ...props, error };
|
|
125
|
+
|
|
126
|
+
return <FormTimePickerWithoutValidation {...props} />;
|
|
127
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
id?: string;
|
|
6
|
+
name: string;
|
|
7
|
+
formName?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
defaultValue?: boolean;
|
|
10
|
+
helpText?: string;
|
|
11
|
+
onChange?: (value: boolean) => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const YesNo = (props: Props) => {
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
name,
|
|
19
|
+
title,
|
|
20
|
+
defaultValue = false,
|
|
21
|
+
helpText,
|
|
22
|
+
onChange,
|
|
23
|
+
disabled,
|
|
24
|
+
} = props;
|
|
25
|
+
|
|
26
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
27
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
28
|
+
|
|
29
|
+
const [value, setValue] = useState(defaultValue);
|
|
30
|
+
|
|
31
|
+
const color = error ? "red" : "gray";
|
|
32
|
+
|
|
33
|
+
const handleOnChange = () => {
|
|
34
|
+
if (disabled) return; // No hacer nada si está deshabilitado
|
|
35
|
+
const newValue = !value;
|
|
36
|
+
setValue(newValue);
|
|
37
|
+
onChange && onChange(newValue);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<label
|
|
43
|
+
className={`relative inline-flex items-center cursor-pointer ${
|
|
44
|
+
disabled ? "opacity-50" : ""
|
|
45
|
+
}`}
|
|
46
|
+
>
|
|
47
|
+
<input
|
|
48
|
+
type="checkbox"
|
|
49
|
+
id={id ?? name}
|
|
50
|
+
name={name}
|
|
51
|
+
checked={value}
|
|
52
|
+
value={value.toString()}
|
|
53
|
+
className="sr-only peer"
|
|
54
|
+
onChange={handleOnChange}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
/>
|
|
57
|
+
{value.toString() === "false" && (
|
|
58
|
+
<input type="hidden" name={name} value="false" />
|
|
59
|
+
)}
|
|
60
|
+
<div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
|
61
|
+
<span className="ml-3 text-sm font-medium text-gray-900">{title}</span>
|
|
62
|
+
</label>
|
|
63
|
+
{error && (
|
|
64
|
+
<p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
|
|
65
|
+
<span className="font-medium">Oops!</span> {error}
|
|
66
|
+
</p>
|
|
67
|
+
)}
|
|
68
|
+
{!error && helpText && (
|
|
69
|
+
<p
|
|
70
|
+
className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
|
|
71
|
+
>
|
|
72
|
+
{helpText}
|
|
73
|
+
</p>
|
|
74
|
+
)}
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default YesNo;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./Checkbox";
|
|
2
|
+
export * from "./Checklist";
|
|
3
|
+
export * from "./DatePicker";
|
|
4
|
+
export * from "./DynamicBaculoForm";
|
|
5
|
+
export * from "./FieldContainer";
|
|
6
|
+
export * from "./FileUpload";
|
|
7
|
+
export * from "./FormButtons";
|
|
8
|
+
export * from "./FormLayout";
|
|
9
|
+
export * from "./SelectField";
|
|
10
|
+
export * from "./TextArea";
|
|
11
|
+
export * from "./TextField";
|
|
12
|
+
export * from "./TimePicker";
|
|
13
|
+
export * from "./YesNo";
|
package/src/NavBar/NavBar.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
LogoutDropDownSvgIcon,
|
|
5
5
|
MenuAlt4Svg,
|
|
6
6
|
OpcionButtonSvgIcon,
|
|
7
|
-
} from "
|
|
7
|
+
} from "@zauru-sdk/icons";
|
|
8
8
|
import { COLORS } from "./NavBar.utils";
|
|
9
9
|
import type {
|
|
10
10
|
ColorInterface,
|
|
@@ -202,7 +202,7 @@ export const NavBar = ({
|
|
|
202
202
|
type="button"
|
|
203
203
|
onClick={() => setNavBarOpen(!NavBarOpen)}
|
|
204
204
|
>
|
|
205
|
-
<MenuAlt4Svg
|
|
205
|
+
<MenuAlt4Svg open={NavBarOpen} />
|
|
206
206
|
</button>
|
|
207
207
|
</div>
|
|
208
208
|
{/* Menú para dispositivos móviles */}
|
package/src/Table/ZauruTable.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
TableStyles,
|
|
7
7
|
} from "react-data-table-component";
|
|
8
8
|
import DataTable, { createTheme } from "react-data-table-component";
|
|
9
|
-
import { SearchSVG } from "
|
|
9
|
+
import { SearchSVG } from "@zauru-sdk/icons";
|
|
10
10
|
import { ExpandableRowsComponent } from "react-data-table-component/dist/DataTable/types";
|
|
11
11
|
|
|
12
12
|
const customStyles: TableStyles = {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
const canUseDOM = (): boolean => {
|
|
4
|
+
if (
|
|
5
|
+
typeof window === "undefined" ||
|
|
6
|
+
!window.document ||
|
|
7
|
+
!window.document.createElement
|
|
8
|
+
) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const logoutFromZendesk = () => {
|
|
15
|
+
if (canUseDOM() && (window as any).zE) {
|
|
16
|
+
(window as any).zE("messenger", "logoutUser");
|
|
17
|
+
} else {
|
|
18
|
+
console.warn("Zendesk is not initialized yet");
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const ZendeskAPI = (...args: any[]) => {
|
|
23
|
+
if (canUseDOM() && (window as any).zE) {
|
|
24
|
+
(window as any).zE.apply(null, args);
|
|
25
|
+
} else {
|
|
26
|
+
console.warn("Zendesk is not initialized yet");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
interface ZendeskProps {
|
|
31
|
+
defer?: boolean;
|
|
32
|
+
onLoaded?: () => void;
|
|
33
|
+
token: string;
|
|
34
|
+
configuration: {
|
|
35
|
+
zendeskChatKey: string;
|
|
36
|
+
};
|
|
37
|
+
[key: string]: any; // Para propiedades adicionales que se pasen y se asignen a window.zESettings
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Zendesk: React.FC<ZendeskProps> = (props: ZendeskProps) => {
|
|
41
|
+
const { defer, configuration, token, ...other } = props;
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const insertScript = () => {
|
|
45
|
+
const zendeskScript = document.createElement("script");
|
|
46
|
+
if (defer) {
|
|
47
|
+
zendeskScript.defer = true;
|
|
48
|
+
} else {
|
|
49
|
+
zendeskScript.async = true;
|
|
50
|
+
}
|
|
51
|
+
zendeskScript.id = "ze-snippet";
|
|
52
|
+
zendeskScript.src = `https://static.zdassets.com/ekr/snippet.js?key=${configuration.zendeskChatKey}`;
|
|
53
|
+
zendeskScript.addEventListener("load", () => {
|
|
54
|
+
if (props.onLoaded) {
|
|
55
|
+
props.onLoaded();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
(window as any).zE("messenger", "loginUser", function (callback: any) {
|
|
59
|
+
callback(token);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
document.body.appendChild(zendeskScript);
|
|
63
|
+
|
|
64
|
+
return zendeskScript; // Devolvemos la referencia del script
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
let script: HTMLScriptElement | undefined; // Guardamos la referencia del script aquí
|
|
68
|
+
|
|
69
|
+
if (canUseDOM() && !(window as any).zE) {
|
|
70
|
+
script = insertScript();
|
|
71
|
+
(window as any).zESettings = other;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return () => {
|
|
75
|
+
if (script) {
|
|
76
|
+
// Si el script existe, lo eliminamos del DOM
|
|
77
|
+
script.remove();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [props, defer, other, configuration, token]);
|
|
81
|
+
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default Zendesk;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import jwt from "jsonwebtoken";
|
|
2
|
+
|
|
3
|
+
export function zendeskJwt(
|
|
4
|
+
current_user: {
|
|
5
|
+
selected_entity_id: number;
|
|
6
|
+
id: number;
|
|
7
|
+
email: string;
|
|
8
|
+
name: string;
|
|
9
|
+
},
|
|
10
|
+
configuration: {
|
|
11
|
+
zendeskJWTSecret: string;
|
|
12
|
+
zendeskJWTKey: string;
|
|
13
|
+
}
|
|
14
|
+
) {
|
|
15
|
+
// get the INFO
|
|
16
|
+
const jwtSecret = configuration.zendeskJWTSecret;
|
|
17
|
+
const jwtKey = configuration.zendeskJWTKey;
|
|
18
|
+
const expiresIn = Math.floor(Date.now() / 1000) + 60 * 60 * 24; // Expires in 1 day
|
|
19
|
+
|
|
20
|
+
// create the payload
|
|
21
|
+
const payload = {
|
|
22
|
+
external_id:
|
|
23
|
+
"z" +
|
|
24
|
+
current_user.selected_entity_id.toString() +
|
|
25
|
+
"-" +
|
|
26
|
+
current_user.id.toString(),
|
|
27
|
+
email: current_user.email,
|
|
28
|
+
name: current_user.name,
|
|
29
|
+
organization_id: current_user.selected_entity_id.toString(),
|
|
30
|
+
scope: "user",
|
|
31
|
+
exp: expiresIn,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const jwtHeader: jwt.JwtHeader = { kid: jwtKey, typ: "JWT", alg: "HS256" };
|
|
35
|
+
|
|
36
|
+
return jwt.sign(payload, jwtSecret, {
|
|
37
|
+
algorithm: "HS256",
|
|
38
|
+
header: jwtHeader,
|
|
39
|
+
});
|
|
40
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,11 @@ export * from "./Alerts";
|
|
|
2
2
|
export * from "./BlockUI";
|
|
3
3
|
export * from "./Buttons";
|
|
4
4
|
export * from "./Card";
|
|
5
|
-
|
|
5
|
+
export * from "./ConnectionState";
|
|
6
|
+
export * from "./Chat";
|
|
6
7
|
export * from "./Containers";
|
|
7
8
|
export * from "./Footer";
|
|
9
|
+
export * from "./Form";
|
|
8
10
|
export * from "./Labels";
|
|
9
11
|
export * from "./Layouts";
|
|
10
12
|
export * from "./LineSeparator";
|
|
@@ -18,4 +20,4 @@ export * from "./Titles";
|
|
|
18
20
|
export * from "./Tooltip";
|
|
19
21
|
export * from "./WithTooltip";
|
|
20
22
|
export * from "./Wizards";
|
|
21
|
-
|
|
23
|
+
export * from "./Zendesk";
|
package/dist/Alerts/Alert.d.ts
DELETED
package/dist/Alerts/Alert.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef, useEffect } from "react";
|
|
3
|
-
import { createRoot } from "react-dom/client";
|
|
4
|
-
import { ExitSvg } from "../Icons/Icons";
|
|
5
|
-
import { AnimatePresence, motion } from "framer-motion";
|
|
6
|
-
const Alert = ({ type, title, description, onClose }) => {
|
|
7
|
-
const [, setLifetime] = useState(4000);
|
|
8
|
-
const [progress, setProgress] = useState(0);
|
|
9
|
-
const intervalRef = useRef(null);
|
|
10
|
-
const getColor = () => {
|
|
11
|
-
switch (type) {
|
|
12
|
-
case "success":
|
|
13
|
-
return "bg-green-100 text-green-800";
|
|
14
|
-
case "error":
|
|
15
|
-
return "bg-red-100 text-red-800";
|
|
16
|
-
case "info":
|
|
17
|
-
return "bg-blue-100 text-blue-800";
|
|
18
|
-
case "warning":
|
|
19
|
-
return "bg-yellow-100 text-yellow-800";
|
|
20
|
-
default:
|
|
21
|
-
return "bg-gray-100 text-gray-800";
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
const startTimer = () => {
|
|
26
|
-
intervalRef.current = setInterval(() => {
|
|
27
|
-
setLifetime((lifetime) => {
|
|
28
|
-
if (lifetime <= 0) {
|
|
29
|
-
onClose && onClose();
|
|
30
|
-
clearInterval(intervalRef.current);
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
setProgress((4000 - lifetime) / 4000);
|
|
35
|
-
return lifetime - 50;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}, 50);
|
|
39
|
-
};
|
|
40
|
-
const pauseTimer = () => {
|
|
41
|
-
clearInterval(intervalRef.current);
|
|
42
|
-
};
|
|
43
|
-
startTimer();
|
|
44
|
-
return () => {
|
|
45
|
-
pauseTimer();
|
|
46
|
-
};
|
|
47
|
-
}, [onClose]);
|
|
48
|
-
return (_jsxs(motion.div, { initial: { y: -50, opacity: 0 }, animate: { y: 0, opacity: 1 }, exit: { y: -50, opacity: 0 }, className: `fixed top-0 right-0 w-80 mt-10 mr-10 rounded-md shadow-lg ${getColor()} p-4 transition-transform duration-300`, style: {
|
|
49
|
-
zIndex: 1000,
|
|
50
|
-
transform: `translateY(calc(var(--alert-offset, 0)))`,
|
|
51
|
-
}, onMouseEnter: () => clearInterval(intervalRef.current), onMouseLeave: () => {
|
|
52
|
-
intervalRef.current = setInterval(() => {
|
|
53
|
-
setLifetime((lifetime) => {
|
|
54
|
-
if (lifetime <= 0) {
|
|
55
|
-
onClose && onClose();
|
|
56
|
-
clearInterval(intervalRef.current);
|
|
57
|
-
return 0;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
setProgress((4000 - lifetime) / 4000);
|
|
61
|
-
return lifetime - 50;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}, 50);
|
|
65
|
-
}, children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h3", { className: "font-semibold", children: title }), _jsx("button", { className: "text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 transition duration-150 ease-in-out", onClick: () => {
|
|
66
|
-
setLifetime(0);
|
|
67
|
-
onClose && onClose();
|
|
68
|
-
}, children: _jsx(ExitSvg, {}) })] }), _jsx("div", { className: "mt-2", children: _jsx("p", { className: "text-sm overflow-wrap break-words", children: description }) }), _jsx("div", { className: "relative h-1 mt-4 bg-gray-200 rounded", children: _jsx("div", { className: `absolute left-0 top-0 h-full ${getColor()} rounded`, style: { width: `${progress * 100}%` } }) })] }));
|
|
69
|
-
};
|
|
70
|
-
let activeAlerts = [];
|
|
71
|
-
export const showAlert = (alertProps) => {
|
|
72
|
-
if (typeof document === "undefined") {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const container = document.createElement("div");
|
|
76
|
-
document.body.appendChild(container);
|
|
77
|
-
const onClose = () => {
|
|
78
|
-
root.unmount();
|
|
79
|
-
container.remove();
|
|
80
|
-
activeAlerts = activeAlerts.filter((alert) => alert !== container);
|
|
81
|
-
updateAlertOffsets();
|
|
82
|
-
};
|
|
83
|
-
const asyncOnClose = () => {
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
onClose();
|
|
86
|
-
}, 0);
|
|
87
|
-
};
|
|
88
|
-
activeAlerts.push(container);
|
|
89
|
-
updateAlertOffsets();
|
|
90
|
-
const root = createRoot(container);
|
|
91
|
-
root.render(_jsx(AnimatePresence, { children: _jsx(Alert, { ...alertProps, onClose: asyncOnClose }) }));
|
|
92
|
-
};
|
|
93
|
-
const updateAlertOffsets = () => {
|
|
94
|
-
activeAlerts.forEach((alertContainer, index) => {
|
|
95
|
-
alertContainer.style.setProperty("--alert-offset", `${index * 100}px`);
|
|
96
|
-
});
|
|
97
|
-
};
|
package/dist/Icons/Icons.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { NavBarStateProps } from "../NavBar/NavBar.types";
|
|
2
|
-
export declare const applicationDropDownIconColor = "text-slate-500";
|
|
3
|
-
export declare const MenuAlt4Svg: (props: NavBarStateProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare const ExitSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
export declare const EyeSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export declare const PencilSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export declare const TrashSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare const PdfDownloadSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare const SearchSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export declare const PlusSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare const SpinnerSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare const PlusSvgIcon: () => void;
|
|
13
|
-
export declare const WhitePencilSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const ButtonTrashSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const PrinterButtonIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare const CloseSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export declare const ChangeSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare const ReturnButtonSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export declare const SpreadsheetSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export declare const ArrowToRigth: () => import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
export declare const DropDownArrowSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export declare const OpcionButtonSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export declare const NewButtonSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
export declare const ReportButtonIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export declare const NewNavbarButtonIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
export declare const UserDropdownIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export declare const ReportDropDownIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export declare const ChangeDropDownSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
export declare const LogoutDropDownSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export declare const NewDropdownSvgIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
31
|
-
export declare const BigChecklistIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
export declare const LoadingBarSpinnerSvg: () => import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare const IdeaIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
export declare const CalendarIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
35
|
-
export declare const ClockIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
36
|
-
export declare const FinishLabRemisionSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
export declare const SendMessageIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
export declare const CheckIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
39
|
-
export declare const PrintIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
40
|
-
export declare const DownloadIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
41
|
-
export declare const LoadingIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
42
|
-
export declare const AttachmentIconSVG: () => import("react/jsx-runtime").JSX.Element;
|
|
43
|
-
export declare const CustomIconFromImage: ({ imageName, height, width, }: {
|
|
44
|
-
imageName: string;
|
|
45
|
-
width?: number | undefined;
|
|
46
|
-
height?: number | undefined;
|
|
47
|
-
}) => import("react/jsx-runtime").JSX.Element;
|