siam-ui-utils 2.2.19 → 2.2.20

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/index.d.ts CHANGED
@@ -88,4 +88,7 @@ declare module 'siam-ui-utils' {
88
88
 
89
89
  //VIEW LAYOUT
90
90
  export function ViewLayout(props);
91
+
92
+ //TIMER
93
+ export function Timer(props);
91
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siam-ui-utils",
3
- "version": "2.2.19",
3
+ "version": "2.2.20",
4
4
  "keywords": [
5
5
  "ampf-react",
6
6
  "ampf-utils",
package/src/App.jsx CHANGED
@@ -13,6 +13,7 @@ import './assets/css/vendor/bootstrap.min.css';
13
13
  import { WhereByRoom } from './where-by-room';
14
14
  import { ViewLayout } from './view-layout';
15
15
  import { CopyLink } from './copy-link';
16
+ import { Timer } from './timer';
16
17
 
17
18
  const slots = [
18
19
  {
@@ -141,6 +142,16 @@ const App = () => {
141
142
  <ViewLayout slots={slots} />
142
143
  </AccordionBody>
143
144
  </AccordionItem>
145
+ <AccordionItem>
146
+ <AccordionHeader targetId="8">Timer</AccordionHeader>
147
+ <AccordionBody accordionId="8">
148
+ <Timer
149
+ initialMinutes={2}
150
+ active={true}
151
+ style={{ color: 'green' }}
152
+ />
153
+ </AccordionBody>
154
+ </AccordionItem>
144
155
  </Accordion>
145
156
  </div>
146
157
  );
@@ -1,6 +1,5 @@
1
1
  import { getDroppedOrSelectedFiles } from 'html5-file-selector';
2
2
  import { useEffect, useState } from 'react';
3
- import '../dropzone/styles.css';
4
3
  import Dropzone from '../dropzone/Dropzone';
5
4
  import '../dropzone/styles.css';
6
5
  import { IconButtonSvg, pdfImage } from '../iconos';
@@ -88,7 +87,7 @@ export const DropzoneUploader = ({
88
87
  <p>{(meta.size / 1024).toFixed(2)} .Kb</p>
89
88
  <button
90
89
  onClick={remove}
91
- className="dropzone-upload-delete-btn simple-icon-trash"
90
+ className="dropzone-upload-delete-btn icon-trash"
92
91
  ></button>
93
92
  </div>
94
93
  );
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './archivos-adjuntos';
2
- export * from './archivos-adjuntos/dropzone-uploader-dni-digital';
1
+ export * from './dropzone-uploader';
2
+ export * from './dropzone-uploader/dropzone-uploader-dni-digital';
3
3
  export * from './bridges';
4
4
  export * from './CustomBootstrap';
5
5
  export * from './custom-input';
@@ -9,3 +9,4 @@ export * as IntlMessages from './IntlMessages';
9
9
  export * from './where-by-room';
10
10
  export * from './copy-link';
11
11
  export * from './view-layout';
12
+ export * from './timer';
@@ -0,0 +1,62 @@
1
+ import { useEffect, useState, useRef } from 'react';
2
+ import './styles.scss';
3
+
4
+ export const formatTiempo = (ms) => {
5
+ if (ms == null) return '--:--';
6
+ const absMs = Math.abs(ms);
7
+ const totalSec = Math.floor(absMs / 1000);
8
+ const min = Math.floor(totalSec / 60);
9
+ const sec = totalSec % 60;
10
+ const formatted = `${min.toString().padStart(2, '0')}:${sec
11
+ .toString()
12
+ .padStart(2, '0')}`;
13
+ return ms < 0 ? `-${formatted}` : formatted;
14
+ };
15
+
16
+ const getTimerColorClass = (ms, maxTime) => {
17
+ if (!maxTime) return '';
18
+ const percent = ms / maxTime;
19
+ if (percent > 0.33) return 'timer-green';
20
+ if (percent > 0.15) return 'timer-yellow';
21
+ if (percent > 0) return 'timer-red';
22
+ if (ms === 0) return 'timer-out';
23
+ if (ms < 0) return 'timer-over';
24
+ return '';
25
+ };
26
+
27
+ const Timer = ({
28
+ initialMinutes = 0,
29
+ icon = true,
30
+ className = '',
31
+ active = true,
32
+ style = {},
33
+ }) => {
34
+ const initialMs = initialMinutes * 60 * 1000;
35
+ const [ms, setMs] = useState(initialMs);
36
+ const intervalRef = useRef();
37
+
38
+ useEffect(() => {
39
+ if (!active) return;
40
+ intervalRef.current = setInterval(() => {
41
+ setMs((prev) => prev - 1000);
42
+ }, 1000);
43
+ return () => clearInterval(intervalRef.current);
44
+ }, [active]);
45
+
46
+ useEffect(() => {
47
+ setMs(initialMs);
48
+ }, [initialMs]);
49
+
50
+ const timerColorClass = getTimerColorClass(ms, initialMs);
51
+
52
+ return (
53
+ <span
54
+ className={`av-video-timer timer ${timerColorClass} ${className}`}
55
+ style={style}
56
+ >
57
+ {icon && <i className="icon-clock timer" />}
58
+ {formatTiempo(ms)}
59
+ </span>
60
+ );
61
+ };
62
+ export { Timer };
@@ -0,0 +1,54 @@
1
+ .av-video-timer {
2
+ color: inherit;
3
+ margin: 0 12px;
4
+ flex: 1;
5
+ text-align: center;
6
+ display: flex;
7
+ justify-content: center;
8
+ font-weight: bold;
9
+ align-items: center;
10
+ font-size: 1.3em;
11
+ width: 100%;
12
+ margin: 8px 0;
13
+ }
14
+ .timer {
15
+ font-size: clamp(5px, 2vw, 20px);
16
+ margin-right: 4px;
17
+ }
18
+ .timer-green {
19
+ color: #28a745;
20
+ }
21
+ .timer-yellow {
22
+ color: #ffc107;
23
+ }
24
+ .timer-red {
25
+ color: #bd0300;
26
+ }
27
+
28
+ @keyframes vibrate {
29
+ 0% {
30
+ transform: translateX(0);
31
+ }
32
+ 20% {
33
+ transform: translateX(-3px);
34
+ }
35
+ 40% {
36
+ transform: translateX(3px);
37
+ }
38
+ 60% {
39
+ transform: translateX(-3px);
40
+ }
41
+ 80% {
42
+ transform: translateX(3px);
43
+ }
44
+ 100% {
45
+ transform: translateX(0);
46
+ }
47
+ }
48
+ .timer-out {
49
+ color: #000000;
50
+ animation: vibrate 0.3s linear infinite;
51
+ }
52
+ .timer-over {
53
+ color: #c00805;
54
+ }