@zauru-sdk/components 1.0.12 → 1.0.13

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.
@@ -1,34 +0,0 @@
1
- // ============================| Background colors |============================
2
- export const styleGreenBackground = "bg-green-600";
3
- export const styleActiveGreenBackground = "active:bg-green-800";
4
- export const styleRedBackground = "bg-red-600";
5
- export const styleActiveRedBackground = "active:bg-red-800";
6
- export const styleInactiveButtonBackground = "bg-zinc-300";
7
- export const styleActiveInactiveButtonBackground = "active:bg-zinc-200";
8
- export const styleStandardBackgroundColor = "bg-slate-900";
9
- export const styleStandardActiveBackgroundColor = "active:bg-slate-800";
10
- // ==============================| Icons Colors |=================================
11
- export const buttonIconTableColor = "text-slate-700";
12
- export const greenColorIcon = "text-emerald-600";
13
- export const redColorIcon = "text-red-600";
14
- export const applicationDropDownIconColor = "text-slate-900";
15
- export const inputIconColor = "text-zinc-400";
16
- // ==============================| Table Utils Colors |============================
17
- // CSS Color Nams, RGB, Hexadecimal
18
- export const lastRowSelectedBackground = "lightgreen";
19
- // ==============================| Dropdown Hover |=================================
20
- export const greenDropdownHover = "hover:bg-red-100";
21
- export const redDropdownHover = "hover:bg-green-100";
22
- export const standardDropdownHover = "hover:bg-gray-100";
23
- // ===============================| Border Colors | =================================
24
- export const standarBorderColor = "border-slate-500";
25
- export const alertBorderColor = "border-red-500";
26
- // ===============================| Section Background Color | =================================
27
- export const sectionNormalBackgroundColor = "bg-neutral-100";
28
- export const inProgressProcessAlertBackgroundColor = "bg-yellow-900";
29
- // ===============================| Progress Bar Styles | =================================
30
- export const progressBarLightBackground = "bg-slate-200";
31
- export const progressBarBackground = "bg-slate-600";
32
- export const progressBarTextColor = "text-slate-800";
33
- export const progressBarLightTextColor = "text-slate-300";
34
- export const progressBarSpinnerFillColor = "fill-slate-800";
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const logoutFromZendesk: () => void;
3
- export declare const ZendeskAPI: (...args: any[]) => void;
4
- interface ZendeskProps {
5
- defer?: boolean;
6
- onLoaded?: () => void;
7
- token: string;
8
- configuration: {
9
- zendeskChatKey: string;
10
- };
11
- [key: string]: any;
12
- }
13
- export declare const Zendesk: React.FC<ZendeskProps>;
14
- export {};
@@ -1,63 +0,0 @@
1
- import { useEffect } from "react";
2
- const canUseDOM = () => {
3
- if (typeof window === "undefined" ||
4
- !window.document ||
5
- !window.document.createElement) {
6
- return false;
7
- }
8
- return true;
9
- };
10
- export const logoutFromZendesk = () => {
11
- if (canUseDOM() && window.zE) {
12
- window.zE("messenger", "logoutUser");
13
- }
14
- else {
15
- console.warn("Zendesk is not initialized yet");
16
- }
17
- };
18
- export const ZendeskAPI = (...args) => {
19
- if (canUseDOM() && window.zE) {
20
- window.zE.apply(null, args);
21
- }
22
- else {
23
- console.warn("Zendesk is not initialized yet");
24
- }
25
- };
26
- export const Zendesk = (props) => {
27
- const { defer, configuration, token, ...other } = props;
28
- useEffect(() => {
29
- const insertScript = () => {
30
- const zendeskScript = document.createElement("script");
31
- if (defer) {
32
- zendeskScript.defer = true;
33
- }
34
- else {
35
- zendeskScript.async = true;
36
- }
37
- zendeskScript.id = "ze-snippet";
38
- zendeskScript.src = `https://static.zdassets.com/ekr/snippet.js?key=${configuration.zendeskChatKey}`;
39
- zendeskScript.addEventListener("load", () => {
40
- if (props.onLoaded) {
41
- props.onLoaded();
42
- }
43
- window.zE("messenger", "loginUser", function (callback) {
44
- callback(token);
45
- });
46
- });
47
- document.body.appendChild(zendeskScript);
48
- return zendeskScript; // Devolvemos la referencia del script
49
- };
50
- let script; // Guardamos la referencia del script aquí
51
- if (canUseDOM() && !window.zE) {
52
- script = insertScript();
53
- window.zESettings = other;
54
- }
55
- return () => {
56
- if (script) {
57
- // Si el script existe, lo eliminamos del DOM
58
- script.remove();
59
- }
60
- };
61
- }, [props, defer, other, configuration, token]);
62
- return null;
63
- };
@@ -1,2 +0,0 @@
1
- export * from "./Chat";
2
- export * from "./zendesk.config";
@@ -1,2 +0,0 @@
1
- export * from "./Chat";
2
- export * from "./zendesk.config";
@@ -1,9 +0,0 @@
1
- export declare function zendeskJwt(current_user: {
2
- selected_entity_id: number;
3
- id: number;
4
- email: string;
5
- name: string;
6
- }, configuration: {
7
- zendeskJWTSecret: string;
8
- zendeskJWTKey: string;
9
- }): any;
@@ -1,24 +0,0 @@
1
- import jwt from "jsonwebtoken";
2
- export function zendeskJwt(current_user, configuration) {
3
- // get the INFO
4
- const jwtSecret = configuration.zendeskJWTSecret;
5
- const jwtKey = configuration.zendeskJWTKey;
6
- const expiresIn = Math.floor(Date.now() / 1000) + 60 * 60 * 24; // Expires in 1 day
7
- // create the payload
8
- const payload = {
9
- external_id: "z" +
10
- current_user.selected_entity_id.toString() +
11
- "-" +
12
- current_user.id.toString(),
13
- email: current_user.email,
14
- name: current_user.name,
15
- organization_id: current_user.selected_entity_id.toString(),
16
- scope: "user",
17
- exp: expiresIn,
18
- };
19
- const jwtHeader = { kid: jwtKey, typ: "JWT", alg: "HS256" };
20
- return jwt.sign(payload, jwtSecret, {
21
- algorithm: "HS256",
22
- header: jwtHeader,
23
- });
24
- }
@@ -1,149 +0,0 @@
1
- import React, { useState, useRef, useEffect } from "react";
2
- import { createRoot } from "react-dom/client";
3
- import { ExitSvg } from "../Icons/Icons";
4
- import { AnimatePresence, motion } from "framer-motion";
5
-
6
- type AlertType = "success" | "error" | "info" | "warning";
7
-
8
- export type AlertProps = {
9
- type: AlertType;
10
- title: string;
11
- description: string;
12
- onClose?: () => void;
13
- };
14
-
15
- const Alert: React.FC<AlertProps> = ({ type, title, description, onClose }) => {
16
- const [, setLifetime] = useState(4000);
17
- const [progress, setProgress] = useState(0);
18
- const intervalRef = useRef<any>(null);
19
-
20
- const getColor = () => {
21
- switch (type) {
22
- case "success":
23
- return "bg-green-100 text-green-800";
24
- case "error":
25
- return "bg-red-100 text-red-800";
26
- case "info":
27
- return "bg-blue-100 text-blue-800";
28
- case "warning":
29
- return "bg-yellow-100 text-yellow-800";
30
- default:
31
- return "bg-gray-100 text-gray-800";
32
- }
33
- };
34
-
35
- useEffect(() => {
36
- const startTimer = () => {
37
- intervalRef.current = setInterval(() => {
38
- setLifetime((lifetime) => {
39
- if (lifetime <= 0) {
40
- onClose && onClose();
41
- clearInterval(intervalRef.current);
42
- return 0;
43
- } else {
44
- setProgress((4000 - lifetime) / 4000);
45
- return lifetime - 50;
46
- }
47
- });
48
- }, 50);
49
- };
50
-
51
- const pauseTimer = () => {
52
- clearInterval(intervalRef.current);
53
- };
54
-
55
- startTimer();
56
- return () => {
57
- pauseTimer();
58
- };
59
- }, [onClose]);
60
-
61
- return (
62
- <motion.div
63
- initial={{ y: -50, opacity: 0 }}
64
- animate={{ y: 0, opacity: 1 }}
65
- exit={{ y: -50, opacity: 0 }}
66
- className={`fixed top-0 right-0 w-80 mt-10 mr-10 rounded-md shadow-lg ${getColor()} p-4 transition-transform duration-300`}
67
- style={{
68
- zIndex: 1000,
69
- transform: `translateY(calc(var(--alert-offset, 0)))`,
70
- }}
71
- onMouseEnter={() => clearInterval(intervalRef.current)}
72
- onMouseLeave={() => {
73
- intervalRef.current = setInterval(() => {
74
- setLifetime((lifetime) => {
75
- if (lifetime <= 0) {
76
- onClose && onClose();
77
- clearInterval(intervalRef.current);
78
- return 0;
79
- } else {
80
- setProgress((4000 - lifetime) / 4000);
81
- return lifetime - 50;
82
- }
83
- });
84
- }, 50);
85
- }}
86
- >
87
- <div className="flex items-center justify-between">
88
- <h3 className="font-semibold">{title}</h3>
89
- <button
90
- className="text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 transition duration-150 ease-in-out"
91
- onClick={() => {
92
- setLifetime(0);
93
- onClose && onClose();
94
- }}
95
- >
96
- <ExitSvg />
97
- </button>
98
- </div>
99
- <div className="mt-2">
100
- <p className="text-sm overflow-wrap break-words">{description}</p>
101
- </div>
102
- <div className="relative h-1 mt-4 bg-gray-200 rounded">
103
- <div
104
- className={`absolute left-0 top-0 h-full ${getColor()} rounded`}
105
- style={{ width: `${progress * 100}%` }}
106
- ></div>
107
- </div>
108
- </motion.div>
109
- );
110
- };
111
-
112
- let activeAlerts: HTMLElement[] = [];
113
-
114
- export const showAlert = (alertProps: AlertProps) => {
115
- if (typeof document === "undefined") {
116
- return;
117
- }
118
- const container = document.createElement("div");
119
- document.body.appendChild(container);
120
-
121
- const onClose = () => {
122
- root.unmount();
123
- container.remove();
124
- activeAlerts = activeAlerts.filter((alert) => alert !== container);
125
- updateAlertOffsets();
126
- };
127
-
128
- const asyncOnClose = () => {
129
- setTimeout(() => {
130
- onClose();
131
- }, 0);
132
- };
133
-
134
- activeAlerts.push(container);
135
- updateAlertOffsets();
136
-
137
- const root = createRoot(container);
138
- root.render(
139
- <AnimatePresence>
140
- <Alert {...alertProps} onClose={asyncOnClose} />
141
- </AnimatePresence>
142
- );
143
- };
144
-
145
- const updateAlertOffsets = () => {
146
- activeAlerts.forEach((alertContainer, index) => {
147
- alertContainer.style.setProperty("--alert-offset", `${index * 100}px`);
148
- });
149
- };