anteriority-ui 1.0.0
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/.github/workflows/ci.yml +31 -0
- package/.github/workflows/publish.yml +45 -0
- package/.npmrc.bak +1 -0
- package/.storybook/main.js +15 -0
- package/.storybook/preview.jsx +26 -0
- package/AnteriorityUI.md +2400 -0
- package/CLAUDE.md +91 -0
- package/README.md +182 -0
- package/assets/anteriorityUI/AnteriorityUI.logo.jpeg +0 -0
- package/assets/favicon/anteriorityUI.ico +0 -0
- package/common/api/client.js +43 -0
- package/common/storage/LocalStorage.js +13 -0
- package/common/styles/typography.css +5 -0
- package/common/styles/variables.css +192 -0
- package/common/theme/muiTheme.js +9 -0
- package/features/password-reset/api.js +39 -0
- package/features/user-profile/api.js +5 -0
- package/hooks/useAdminPasswordReset.js +133 -0
- package/index.js +57 -0
- package/package.json +57 -0
- package/pnpm-workspace.yaml +3 -0
- package/screens/components/AlertModal/AlertModal.jsx +259 -0
- package/screens/components/AlertModal/AlertModal.module.css +185 -0
- package/screens/components/AlertModal/AlertModal.stories.jsx +87 -0
- package/screens/components/Avatar/index.jsx +0 -0
- package/screens/components/Avatar/index.module.css +0 -0
- package/screens/components/Avatar/utils.js +0 -0
- package/screens/components/Badge/index.jsx +33 -0
- package/screens/components/Badge/index.module.css +18 -0
- package/screens/components/Badge/index.stories.jsx +40 -0
- package/screens/components/Barnner/index.jsx +21 -0
- package/screens/components/Barnner/index.module.css +33 -0
- package/screens/components/Barnner/index.stories.jsx +39 -0
- package/screens/components/Barnner/utils.js +0 -0
- package/screens/components/BlueLink/index.jsx +27 -0
- package/screens/components/BlueLink/index.module.css +11 -0
- package/screens/components/BlueLink/index.stories.jsx +29 -0
- package/screens/components/Breadcrumbs/index.jsx +62 -0
- package/screens/components/Breadcrumbs/index.module.css +158 -0
- package/screens/components/Breadcrumbs/index.stories.jsx +37 -0
- package/screens/components/Button/index.jsx +169 -0
- package/screens/components/Button/index.module.css +168 -0
- package/screens/components/Button/index.stories.jsx +71 -0
- package/screens/components/Button/utils.js +28 -0
- package/screens/components/CalendarComponent/CustomDatePicker.jsx +248 -0
- package/screens/components/CalendarComponent/CustomDatePicker.module.css +323 -0
- package/screens/components/CalendarComponent/CustomDatePicker.stories.jsx +45 -0
- package/screens/components/CalendarPicker/Constants.js +12 -0
- package/screens/components/CalendarPicker/index.jsx +263 -0
- package/screens/components/CalendarPicker/index.module.css +147 -0
- package/screens/components/CalendarPicker/index.stories.jsx +45 -0
- package/screens/components/CalendarPicker/utils.js +42 -0
- package/screens/components/CardV1/index.jsx +165 -0
- package/screens/components/CardV1/index.module.css +232 -0
- package/screens/components/CardV1/index.stories.jsx +62 -0
- package/screens/components/CardV1/utils.js +49 -0
- package/screens/components/ChatWindow/index.jsx +251 -0
- package/screens/components/ChatWindow/index.module.css +311 -0
- package/screens/components/ChatWindow/index.stories.jsx +62 -0
- package/screens/components/Checks/index.jsx +31 -0
- package/screens/components/Checks/index.module.css +32 -0
- package/screens/components/Checks/index.stories.jsx +32 -0
- package/screens/components/Container/index.jsx +36 -0
- package/screens/components/Container/index.module.css +24 -0
- package/screens/components/Container/index.stories.jsx +32 -0
- package/screens/components/CopyText/index.jsx +42 -0
- package/screens/components/CopyText/index.module.css +52 -0
- package/screens/components/CopyText/index.stories.jsx +24 -0
- package/screens/components/CountdownBar/constants.js +3 -0
- package/screens/components/CountdownBar/index.jsx +81 -0
- package/screens/components/CountdownBar/index.module.css +45 -0
- package/screens/components/CountdownBar/index.stories.jsx +43 -0
- package/screens/components/CountdownBar/utils.js +119 -0
- package/screens/components/DateTag/index.jsx +33 -0
- package/screens/components/DateTag/index.module.css +12 -0
- package/screens/components/DateTag/index.stories.jsx +29 -0
- package/screens/components/DesplegablePanel/constants.js +0 -0
- package/screens/components/DesplegablePanel/index.jsx +61 -0
- package/screens/components/DesplegablePanel/index.module.css +120 -0
- package/screens/components/DesplegablePanel/index.stories.jsx +44 -0
- package/screens/components/DesplegablePanel/utils.js +0 -0
- package/screens/components/DrawPanel/index.jsx +217 -0
- package/screens/components/DrawPanel/index.module.css +252 -0
- package/screens/components/DrawPanel/index.stories.jsx +66 -0
- package/screens/components/DrawPanel/utils.js +0 -0
- package/screens/components/Filter/index.jsx +105 -0
- package/screens/components/Filter/index.module.css +91 -0
- package/screens/components/Filter/index.stories.jsx +46 -0
- package/screens/components/Filter/utils.js +0 -0
- package/screens/components/FormControls/FormControls.module.css +86 -0
- package/screens/components/FormControls/index.jsx +51 -0
- package/screens/components/FormControls/index.stories.jsx +36 -0
- package/screens/components/Frame/index.jsx +54 -0
- package/screens/components/Frame/index.module.css +102 -0
- package/screens/components/Frame/index.stories.jsx +37 -0
- package/screens/components/Frame/utils.js +0 -0
- package/screens/components/GreenHighlight/index.jsx +11 -0
- package/screens/components/GreenHighlight/index.module.css +7 -0
- package/screens/components/GreenHighlight/index.stories.jsx +26 -0
- package/screens/components/GreenHighlight/utils.jsx +45 -0
- package/screens/components/HoursPicker/Constants.js +26 -0
- package/screens/components/HoursPicker/index.jsx +350 -0
- package/screens/components/HoursPicker/index.module.css +99 -0
- package/screens/components/HoursPicker/index.stories.jsx +44 -0
- package/screens/components/HoursPicker/utils.js +48 -0
- package/screens/components/InfoTooltip/index.jsx +59 -0
- package/screens/components/InfoTooltip/index.module.css +98 -0
- package/screens/components/InfoTooltip/index.stories.jsx +35 -0
- package/screens/components/Input/index.jsx +36 -0
- package/screens/components/Input/index.module.css +49 -0
- package/screens/components/Input/index.stories.jsx +37 -0
- package/screens/components/Input/utils.js +0 -0
- package/screens/components/Loading/index.jsx +76 -0
- package/screens/components/Loading/index.module.css +193 -0
- package/screens/components/Loading/index.stories.jsx +38 -0
- package/screens/components/Loading/utils.js +0 -0
- package/screens/components/MarkdownContent/index.jsx +16 -0
- package/screens/components/MarkdownContent/index.module.css +149 -0
- package/screens/components/MarkdownContent/index.stories.jsx +30 -0
- package/screens/components/MarkdownEditor/index.jsx +430 -0
- package/screens/components/MarkdownEditor/index.module.css +192 -0
- package/screens/components/MarkdownEditor/index.stories.jsx +50 -0
- package/screens/components/Material-UI/Components/InputWithIcon/index.jsx +87 -0
- package/screens/components/Material-UI/Components/InputWithIcon/index.stories.jsx +49 -0
- package/screens/components/Material-UI/Components/MenuPopover/index.jsx +117 -0
- package/screens/components/Material-UI/Components/MenuPopover/index.stories.jsx +36 -0
- package/screens/components/Material-UI/Components/MultilinePlaceholder/index.jsx +44 -0
- package/screens/components/Material-UI/Components/MultilinePlaceholder/index.stories.jsx +45 -0
- package/screens/components/Material-UI/Components/Paginador/index.jsx +79 -0
- package/screens/components/Material-UI/Components/Paginador/index.stories.jsx +49 -0
- package/screens/components/Material-UI/Components/Search/index.jsx +81 -0
- package/screens/components/Material-UI/Components/Search/index.stories.jsx +68 -0
- package/screens/components/Material-UI/Components/Selector/index.jsx +100 -0
- package/screens/components/Material-UI/Components/Selector/index.module.css +0 -0
- package/screens/components/Material-UI/Components/Selector/index.stories.jsx +52 -0
- package/screens/components/Material-UI/Components/Selector/utils.js +0 -0
- package/screens/components/Material-UI/Components/TextField/index.jsx +61 -0
- package/screens/components/Material-UI/Components/TextField/index.stories.jsx +53 -0
- package/screens/components/ModalTooltip/ModalTooltip.jsx +122 -0
- package/screens/components/ModalTooltip/ModalTooltip.module.css +65 -0
- package/screens/components/ModalTooltip/ModalTooltip.stories.jsx +39 -0
- package/screens/components/Notification/Error/ErrorMessage.jsx +30 -0
- package/screens/components/Notification/Error/ErrorMessage.module.css +57 -0
- package/screens/components/Notification/Error/ErrorMessage.stories.jsx +37 -0
- package/screens/components/PasswordResetPanel/index.jsx +325 -0
- package/screens/components/PasswordResetPanel/index.stories.jsx +26 -0
- package/screens/components/PlaceholderButton/index.jsx +169 -0
- package/screens/components/PlaceholderButton/index.module.css +162 -0
- package/screens/components/PlaceholderButton/index.stories.jsx +69 -0
- package/screens/components/PlaceholderButton/utils.js +42 -0
- package/screens/components/Profile/Avatar/index.jsx +125 -0
- package/screens/components/Profile/Avatar/index.module.css +86 -0
- package/screens/components/Profile/Avatar/index.stories.jsx +48 -0
- package/screens/components/Profile/Avatar/utils.js +18 -0
- package/screens/components/Profile/index.jsx +58 -0
- package/screens/components/Profile/index.module.css +0 -0
- package/screens/components/Profile/index.stories.jsx +38 -0
- package/screens/components/Profile/utils.js +0 -0
- package/screens/components/ScrollBar/index.jsx +62 -0
- package/screens/components/ScrollBar/index.module.css +78 -0
- package/screens/components/ScrollBar/index.stories.jsx +64 -0
- package/screens/components/ScrollBar/utils.js +127 -0
- package/screens/components/Sidebar/constants.js +16 -0
- package/screens/components/Sidebar/index.jsx +399 -0
- package/screens/components/Sidebar/index.module.css +405 -0
- package/screens/components/Sidebar/index.stories.jsx +86 -0
- package/screens/components/Sidebar/utils.js +75 -0
- package/screens/components/Skeleton/index.jsx +11 -0
- package/screens/components/Skeleton/index.module.css +26 -0
- package/screens/components/Skeleton/index.stories.jsx +42 -0
- package/screens/components/SubSidebarLayout/index.jsx +44 -0
- package/screens/components/SubSidebarLayout/index.module.css +80 -0
- package/screens/components/SubSidebarLayout/index.stories.jsx +51 -0
- package/screens/components/SummaryCard/index.jsx +50 -0
- package/screens/components/SummaryCard/index.module.css +30 -0
- package/screens/components/SummaryCard/index.stories.jsx +29 -0
- package/screens/components/Swich/constants.js +4 -0
- package/screens/components/Swich/index.jsx +85 -0
- package/screens/components/Swich/index.module.css +68 -0
- package/screens/components/Swich/index.stories.jsx +44 -0
- package/screens/components/Swich/utils.js +0 -0
- package/screens/components/TableA/index.jsx +156 -0
- package/screens/components/TableA/index.module.css +105 -0
- package/screens/components/TableA/index.stories.jsx +116 -0
- package/screens/components/TableA/utils.js +11 -0
- package/screens/components/TableB/index.jsx +222 -0
- package/screens/components/TableB/index.module.css +295 -0
- package/screens/components/TableB/index.stories.jsx +110 -0
- package/screens/components/TableB/utils.js +11 -0
- package/screens/components/ToggleCard/index.jsx +64 -0
- package/screens/components/ToggleCard/index.module.css +111 -0
- package/screens/components/ToggleCard/index.stories.jsx +49 -0
- package/screens/components/UserEditPopover/index.jsx +102 -0
- package/screens/components/UserEditPopover/index.module.css +97 -0
- package/screens/components/UserEditPopover/index.stories.jsx +49 -0
- package/scripts/build.mjs +129 -0
- package/scripts/check-case.mjs +127 -0
- package/scripts/verify-dist.mjs +45 -0
- package/vitest.config.js +36 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import GreenHighlight from './index.jsx';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/GreenHighlight',
|
|
5
|
+
component: GreenHighlight,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const Default = {
|
|
9
|
+
args: {
|
|
10
|
+
children: 'texto destacado',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const InSentence = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<p>
|
|
17
|
+
El pedido fue <GreenHighlight>aprobado exitosamente</GreenHighlight> y está listo para su envío.
|
|
18
|
+
</p>
|
|
19
|
+
),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Number = {
|
|
23
|
+
args: {
|
|
24
|
+
children: '$1,250.00',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import GreenHighlight from './index';
|
|
3
|
+
import BlueLink from '../BlueLink/index';
|
|
4
|
+
import CopyableText from '../CopyText/index';
|
|
5
|
+
|
|
6
|
+
export const formatHighlightedText = (content, GreenHighlightComponent = GreenHighlight, textColor, bgColor) => {
|
|
7
|
+
if (typeof content !== 'string') return content;
|
|
8
|
+
const parts = content.split(/(\*\*[^*]+\*\*)/g);
|
|
9
|
+
|
|
10
|
+
return parts.map((part, index) => {
|
|
11
|
+
if (part.startsWith('**') && part.endsWith('**')) {
|
|
12
|
+
return (
|
|
13
|
+
<GreenHighlightComponent key={index} textColor={textColor} bgColor={bgColor}>
|
|
14
|
+
{part.slice(2, -2)}
|
|
15
|
+
</GreenHighlightComponent>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return part;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const renderFormattedText = (content, navigate) => {
|
|
23
|
+
if (typeof content !== 'string') return content;
|
|
24
|
+
const parts = content.split(/(\*\*[^*]+\*\*|\$[^\$]+\$|\([^)]+\))/g);
|
|
25
|
+
|
|
26
|
+
return parts.map((part, index) => {
|
|
27
|
+
if (part.startsWith('**') && part.endsWith('**')) {
|
|
28
|
+
return <GreenHighlight key={index}>{part.slice(2, -2)}</GreenHighlight>;
|
|
29
|
+
}
|
|
30
|
+
if (part.startsWith('$') && part.endsWith('$')) {
|
|
31
|
+
const rawContent = part.slice(1, -1).trim();
|
|
32
|
+
let label = rawContent, url = rawContent;
|
|
33
|
+
if (rawContent.includes('|')) {
|
|
34
|
+
const segments = rawContent.split('|');
|
|
35
|
+
label = segments[0].trim();
|
|
36
|
+
url = segments[1].trim();
|
|
37
|
+
}
|
|
38
|
+
return <BlueLink key={index} label={label} url={url} navigate={navigate} />;
|
|
39
|
+
}
|
|
40
|
+
if (part.startsWith('(') && part.endsWith(')')) {
|
|
41
|
+
return <CopyableText key={index} text={part.slice(1, -1)} />;
|
|
42
|
+
}
|
|
43
|
+
return part;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const TEXT_HOURS_PICKER = {
|
|
2
|
+
TITLE: 'Seleccionar Hora',
|
|
3
|
+
PLACEHOLDER: '00:00 AM',
|
|
4
|
+
LABEL_HOUR: 'Hora',
|
|
5
|
+
LABEL_MINUTE: 'Minuto',
|
|
6
|
+
LABEL_PERIOD: 'Período',
|
|
7
|
+
QUICK_PRESETS_TITLE: 'Horarios Frecuentes',
|
|
8
|
+
BUTTON_CLEAR: 'Borrar',
|
|
9
|
+
BUTTON_CONFIRM: 'Confirmar',
|
|
10
|
+
BUTTON_NOW: 'Hora Actual',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const HOURS_LIST = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
14
|
+
|
|
15
|
+
export const MINUTES_LIST = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55];
|
|
16
|
+
|
|
17
|
+
export const QUICK_TIMES = [
|
|
18
|
+
{ label: '08:00 AM', h24: 8, m: 0 },
|
|
19
|
+
{ label: '09:00 AM', h24: 9, m: 0 },
|
|
20
|
+
{ label: '10:00 AM', h24: 10, m: 0 },
|
|
21
|
+
{ label: '11:00 AM', h24: 11, m: 0 },
|
|
22
|
+
{ label: '02:00 PM', h24: 14, m: 0 },
|
|
23
|
+
{ label: '03:00 PM', h24: 15, m: 0 },
|
|
24
|
+
{ label: '04:00 PM', h24: 16, m: 0 },
|
|
25
|
+
{ label: '05:00 PM', h24: 17, m: 0 },
|
|
26
|
+
];
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Clock, X, ChevronUp, ChevronDown } from 'lucide-react';
|
|
3
|
+
import styles from './index.module.css';
|
|
4
|
+
import TextField from '../Material-UI/Components/TextField/index';
|
|
5
|
+
import Frame from '../Frame/index';
|
|
6
|
+
import Button from '../Button/index';
|
|
7
|
+
import {
|
|
8
|
+
TEXT_HOURS_PICKER,
|
|
9
|
+
HOURS_LIST,
|
|
10
|
+
MINUTES_LIST,
|
|
11
|
+
QUICK_TIMES
|
|
12
|
+
} from './Constants';
|
|
13
|
+
import {
|
|
14
|
+
parseTimeTo12h,
|
|
15
|
+
format12hTo24h,
|
|
16
|
+
getDisplayTimeText,
|
|
17
|
+
getCurrentTime12h
|
|
18
|
+
} from './utils';
|
|
19
|
+
|
|
20
|
+
const HoursPicker = ({
|
|
21
|
+
label,
|
|
22
|
+
name,
|
|
23
|
+
value,
|
|
24
|
+
onChange,
|
|
25
|
+
required = false,
|
|
26
|
+
disabled = false,
|
|
27
|
+
selectedColor = '#10b981',
|
|
28
|
+
accentColor = '#0f172a'
|
|
29
|
+
}) => {
|
|
30
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
31
|
+
const [hours, setHours] = useState(12);
|
|
32
|
+
const [minutes, setMinutes] = useState(0);
|
|
33
|
+
const [period, setPeriod] = useState('AM');
|
|
34
|
+
const [activeTab, setActiveTab] = useState(null); // null, 'hours', 'minutes'
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const parsed = parseTimeTo12h(value);
|
|
38
|
+
setHours(parsed.hours);
|
|
39
|
+
setMinutes(parsed.minutes);
|
|
40
|
+
setPeriod(parsed.period);
|
|
41
|
+
}, [value, isOpen]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const handleKeyDown = (e) => {
|
|
45
|
+
if (e.key === 'Escape') {
|
|
46
|
+
setIsOpen(false);
|
|
47
|
+
setActiveTab(null);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
if (isOpen) {
|
|
51
|
+
document.body.style.overflow = 'hidden';
|
|
52
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
53
|
+
}
|
|
54
|
+
return () => {
|
|
55
|
+
document.body.style.overflow = '';
|
|
56
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
57
|
+
};
|
|
58
|
+
}, [isOpen]);
|
|
59
|
+
|
|
60
|
+
const incrementHours = () => setHours(prev => (prev === 12 ? 1 : prev + 1));
|
|
61
|
+
const decrementHours = () => setHours(prev => (prev === 1 ? 12 : prev - 1));
|
|
62
|
+
const incrementMinutes = () => setMinutes(prev => (prev + 5 >= 60 ? 0 : Math.floor(prev / 5) * 5 + 5));
|
|
63
|
+
const decrementMinutes = () => setMinutes(prev => (prev - 5 < 0 ? 55 : Math.floor(prev / 5) * 5 - 5));
|
|
64
|
+
|
|
65
|
+
const handleConfirm = () => {
|
|
66
|
+
const formatted = format12hTo24h(hours, minutes, period);
|
|
67
|
+
if (typeof onChange === 'function') {
|
|
68
|
+
onChange({
|
|
69
|
+
target: {
|
|
70
|
+
name,
|
|
71
|
+
value: formatted,
|
|
72
|
+
type: 'time'
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
setIsOpen(false);
|
|
77
|
+
setActiveTab(null);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const handleClear = () => {
|
|
81
|
+
if (typeof onChange === 'function') {
|
|
82
|
+
onChange({
|
|
83
|
+
target: {
|
|
84
|
+
name,
|
|
85
|
+
value: '',
|
|
86
|
+
type: 'time'
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
setIsOpen(false);
|
|
91
|
+
setActiveTab(null);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const handleSetNow = () => {
|
|
95
|
+
const now = getCurrentTime12h();
|
|
96
|
+
setHours(now.hours);
|
|
97
|
+
setMinutes(now.minutes);
|
|
98
|
+
setPeriod(now.period);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleQuickPreset = (preset) => {
|
|
102
|
+
let h12 = preset.h24 % 12;
|
|
103
|
+
if (h12 === 0) h12 = 12;
|
|
104
|
+
const p = preset.h24 >= 12 ? 'PM' : 'AM';
|
|
105
|
+
setHours(h12);
|
|
106
|
+
setMinutes(preset.m);
|
|
107
|
+
setPeriod(p);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const headerContent = (
|
|
111
|
+
<div className={styles.header}>
|
|
112
|
+
<span className={styles.modalTitle}>{TEXT_HOURS_PICKER.TITLE}</span>
|
|
113
|
+
<Button
|
|
114
|
+
variant="ghost"
|
|
115
|
+
size="small"
|
|
116
|
+
circle
|
|
117
|
+
onClick={() => { setIsOpen(false); setActiveTab(null); }}
|
|
118
|
+
icon={X}
|
|
119
|
+
color="var(--cancel-button)"
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className={styles.inputGroup} onClick={(e) => e.stopPropagation()}>
|
|
126
|
+
<TextField
|
|
127
|
+
label={label}
|
|
128
|
+
value={getDisplayTimeText(value, hours, minutes, period)}
|
|
129
|
+
readOnly
|
|
130
|
+
placeholder={TEXT_HOURS_PICKER.PLACEHOLDER}
|
|
131
|
+
onClick={() => !disabled && setIsOpen(true)}
|
|
132
|
+
disabled={disabled}
|
|
133
|
+
required={required}
|
|
134
|
+
slotProps={{
|
|
135
|
+
input: {
|
|
136
|
+
endAdornment: (
|
|
137
|
+
<Clock
|
|
138
|
+
size={16}
|
|
139
|
+
style={{ cursor: 'pointer', color: '#64748b' }}
|
|
140
|
+
onClick={() => !disabled && setIsOpen(true)}
|
|
141
|
+
/>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
{isOpen && (
|
|
148
|
+
<Frame
|
|
149
|
+
isModal={true}
|
|
150
|
+
onClose={() => { setIsOpen(false); setActiveTab(null); }}
|
|
151
|
+
className={styles.hoursFrame}
|
|
152
|
+
>
|
|
153
|
+
{headerContent}
|
|
154
|
+
|
|
155
|
+
{/* MAIN TIME SELECTOR DISPLAY */}
|
|
156
|
+
<div className={styles.timeDisplaySection}>
|
|
157
|
+
{/* Hours Column */}
|
|
158
|
+
<div className={styles.timeColumn}>
|
|
159
|
+
<Button
|
|
160
|
+
variant="ghost"
|
|
161
|
+
size="small"
|
|
162
|
+
circle
|
|
163
|
+
icon={ChevronUp}
|
|
164
|
+
onClick={incrementHours}
|
|
165
|
+
color="inherit"
|
|
166
|
+
title="Incrementar hora"
|
|
167
|
+
/>
|
|
168
|
+
<Button
|
|
169
|
+
variant={activeTab === 'hours' ? 'primary' : 'outline'}
|
|
170
|
+
size="large"
|
|
171
|
+
onClick={() => setActiveTab(activeTab === 'hours' ? null : 'hours')}
|
|
172
|
+
color={activeTab === 'hours' ? selectedColor : accentColor}
|
|
173
|
+
style={{
|
|
174
|
+
minWidth: '58px',
|
|
175
|
+
height: '54px',
|
|
176
|
+
fontSize: '1.5rem',
|
|
177
|
+
fontWeight: 800
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
{String(hours).padStart(2, '0')}
|
|
181
|
+
</Button>
|
|
182
|
+
<Button
|
|
183
|
+
variant="ghost"
|
|
184
|
+
size="small"
|
|
185
|
+
circle
|
|
186
|
+
icon={ChevronDown}
|
|
187
|
+
onClick={decrementHours}
|
|
188
|
+
color="inherit"
|
|
189
|
+
title="Decrementar hora"
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<span className={styles.timeSeparator}>:</span>
|
|
194
|
+
|
|
195
|
+
{/* Minutes Column */}
|
|
196
|
+
<div className={styles.timeColumn}>
|
|
197
|
+
<Button
|
|
198
|
+
variant="ghost"
|
|
199
|
+
size="small"
|
|
200
|
+
circle
|
|
201
|
+
icon={ChevronUp}
|
|
202
|
+
onClick={incrementMinutes}
|
|
203
|
+
color="inherit"
|
|
204
|
+
title="Incrementar minutos"
|
|
205
|
+
/>
|
|
206
|
+
<Button
|
|
207
|
+
variant={activeTab === 'minutes' ? 'primary' : 'outline'}
|
|
208
|
+
size="large"
|
|
209
|
+
onClick={() => setActiveTab(activeTab === 'minutes' ? null : 'minutes')}
|
|
210
|
+
color={activeTab === 'minutes' ? selectedColor : accentColor}
|
|
211
|
+
style={{
|
|
212
|
+
minWidth: '58px',
|
|
213
|
+
height: '54px',
|
|
214
|
+
fontSize: '1.5rem',
|
|
215
|
+
fontWeight: 800
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
{String(minutes).padStart(2, '0')}
|
|
219
|
+
</Button>
|
|
220
|
+
<Button
|
|
221
|
+
variant="ghost"
|
|
222
|
+
size="small"
|
|
223
|
+
circle
|
|
224
|
+
icon={ChevronDown}
|
|
225
|
+
onClick={decrementMinutes}
|
|
226
|
+
color="inherit"
|
|
227
|
+
title="Decrementar minutos"
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
{/* Period Column (AM / PM) */}
|
|
232
|
+
<div className={styles.periodColumn}>
|
|
233
|
+
<Button
|
|
234
|
+
variant={period === 'AM' ? 'primary' : 'ghost'}
|
|
235
|
+
size="small"
|
|
236
|
+
onClick={() => setPeriod('AM')}
|
|
237
|
+
color={period === 'AM' ? accentColor : 'inherit'}
|
|
238
|
+
style={{ minWidth: '48px' }}
|
|
239
|
+
>
|
|
240
|
+
AM
|
|
241
|
+
</Button>
|
|
242
|
+
<Button
|
|
243
|
+
variant={period === 'PM' ? 'primary' : 'ghost'}
|
|
244
|
+
size="small"
|
|
245
|
+
onClick={() => setPeriod('PM')}
|
|
246
|
+
color={period === 'PM' ? accentColor : 'inherit'}
|
|
247
|
+
style={{ minWidth: '48px' }}
|
|
248
|
+
>
|
|
249
|
+
PM
|
|
250
|
+
</Button>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
{/* EXPANDABLE DIRECT NUMBER SELECTION */}
|
|
255
|
+
{activeTab === 'hours' && (
|
|
256
|
+
<div className={styles.quickSelectGrid}>
|
|
257
|
+
{HOURS_LIST.map(h => (
|
|
258
|
+
<Button
|
|
259
|
+
key={h}
|
|
260
|
+
variant={hours === h ? 'primary' : 'outline'}
|
|
261
|
+
size="small"
|
|
262
|
+
onClick={() => { setHours(h); setActiveTab(null); }}
|
|
263
|
+
color={hours === h ? accentColor : 'inherit'}
|
|
264
|
+
style={{ minWidth: 'auto', padding: '4px 0' }}
|
|
265
|
+
>
|
|
266
|
+
{String(h).padStart(2, '0')}
|
|
267
|
+
</Button>
|
|
268
|
+
))}
|
|
269
|
+
</div>
|
|
270
|
+
)}
|
|
271
|
+
|
|
272
|
+
{activeTab === 'minutes' && (
|
|
273
|
+
<div className={styles.quickSelectGrid}>
|
|
274
|
+
{MINUTES_LIST.map(m => (
|
|
275
|
+
<Button
|
|
276
|
+
key={m}
|
|
277
|
+
variant={minutes === m ? 'primary' : 'outline'}
|
|
278
|
+
size="small"
|
|
279
|
+
onClick={() => { setMinutes(m); setActiveTab(null); }}
|
|
280
|
+
color={minutes === m ? accentColor : 'inherit'}
|
|
281
|
+
style={{ minWidth: 'auto', padding: '4px 0' }}
|
|
282
|
+
>
|
|
283
|
+
{String(m).padStart(2, '0')}
|
|
284
|
+
</Button>
|
|
285
|
+
))}
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
|
|
289
|
+
{/* QUICK PRESETS */}
|
|
290
|
+
{!activeTab && (
|
|
291
|
+
<div className={styles.presetsSection}>
|
|
292
|
+
<div className={styles.presetsTitle}>{TEXT_HOURS_PICKER.QUICK_PRESETS_TITLE}</div>
|
|
293
|
+
<div className={styles.presetsGrid}>
|
|
294
|
+
{QUICK_TIMES.map((qt, idx) => {
|
|
295
|
+
let h12 = qt.h24 % 12 || 12;
|
|
296
|
+
let p = qt.h24 >= 12 ? 'PM' : 'AM';
|
|
297
|
+
const isActive = hours === h12 && minutes === qt.m && period === p;
|
|
298
|
+
return (
|
|
299
|
+
<Button
|
|
300
|
+
key={idx}
|
|
301
|
+
variant={isActive ? 'primary' : 'outline'}
|
|
302
|
+
size="small"
|
|
303
|
+
onClick={() => handleQuickPreset(qt)}
|
|
304
|
+
color={isActive ? selectedColor : 'inherit'}
|
|
305
|
+
style={{ fontSize: '0.72rem', padding: '4px 2px', minWidth: 'auto' }}
|
|
306
|
+
>
|
|
307
|
+
{qt.label}
|
|
308
|
+
</Button>
|
|
309
|
+
);
|
|
310
|
+
})}
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
)}
|
|
314
|
+
|
|
315
|
+
{/* FOOTER ACTIONS */}
|
|
316
|
+
<div className={styles.footer}>
|
|
317
|
+
<Button
|
|
318
|
+
variant="ghost"
|
|
319
|
+
size="small"
|
|
320
|
+
onClick={handleClear}
|
|
321
|
+
color="inherit"
|
|
322
|
+
>
|
|
323
|
+
{TEXT_HOURS_PICKER.BUTTON_CLEAR}
|
|
324
|
+
</Button>
|
|
325
|
+
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
|
326
|
+
<Button
|
|
327
|
+
variant="ghost"
|
|
328
|
+
size="small"
|
|
329
|
+
onClick={handleSetNow}
|
|
330
|
+
color="green"
|
|
331
|
+
>
|
|
332
|
+
{TEXT_HOURS_PICKER.BUTTON_NOW}
|
|
333
|
+
</Button>
|
|
334
|
+
<Button
|
|
335
|
+
variant="primary"
|
|
336
|
+
size="small"
|
|
337
|
+
onClick={handleConfirm}
|
|
338
|
+
color={accentColor}
|
|
339
|
+
>
|
|
340
|
+
{TEXT_HOURS_PICKER.BUTTON_CONFIRM}
|
|
341
|
+
</Button>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
</Frame>
|
|
345
|
+
)}
|
|
346
|
+
</div>
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
export default HoursPicker;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
.inputGroup {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 0.25rem;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.hoursFrame {
|
|
9
|
+
width: 340px !important;
|
|
10
|
+
padding: 1.25rem !important;
|
|
11
|
+
border-radius: 16px !important;
|
|
12
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.header {
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
align-items: center;
|
|
19
|
+
width: 100%;
|
|
20
|
+
border-bottom: 1px solid #f1f5f9;
|
|
21
|
+
padding-bottom: 0.75rem;
|
|
22
|
+
margin-bottom: 1rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.modalTitle {
|
|
26
|
+
font-size: 1rem;
|
|
27
|
+
font-weight: 700;
|
|
28
|
+
color: #0f172a;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.timeDisplaySection {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
gap: 0.75rem;
|
|
36
|
+
padding: 0.75rem;
|
|
37
|
+
background-color: #f8fafc;
|
|
38
|
+
border-radius: 12px;
|
|
39
|
+
border: 1px solid #e2e8f0;
|
|
40
|
+
margin-bottom: 1rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.timeColumn {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 0.25rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.timeSeparator {
|
|
51
|
+
font-size: 1.75rem;
|
|
52
|
+
font-weight: 800;
|
|
53
|
+
color: #94a3b8;
|
|
54
|
+
margin-top: -4px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.periodColumn {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: 0.35rem;
|
|
61
|
+
margin-left: 0.25rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.presetsSection {
|
|
65
|
+
margin-bottom: 1rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.presetsTitle {
|
|
69
|
+
font-size: 0.75rem;
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
color: #64748b;
|
|
72
|
+
margin-bottom: 0.5rem;
|
|
73
|
+
text-transform: uppercase;
|
|
74
|
+
letter-spacing: 0.05em;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.presetsGrid {
|
|
78
|
+
display: grid;
|
|
79
|
+
grid-template-columns: repeat(4, 1fr);
|
|
80
|
+
gap: 0.4rem;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.quickSelectGrid {
|
|
84
|
+
display: grid;
|
|
85
|
+
grid-template-columns: repeat(4, 1fr);
|
|
86
|
+
gap: 0.4rem;
|
|
87
|
+
margin-bottom: 1rem;
|
|
88
|
+
max-height: 140px;
|
|
89
|
+
overflow-y: auto;
|
|
90
|
+
padding-right: 0.2rem;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.footer {
|
|
94
|
+
display: flex;
|
|
95
|
+
justify-content: space-between;
|
|
96
|
+
align-items: center;
|
|
97
|
+
padding-top: 0.75rem;
|
|
98
|
+
border-top: 1px solid #f1f5f9;
|
|
99
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import HoursPicker from './index.jsx';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/HoursPicker',
|
|
5
|
+
component: HoursPicker,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const Default = {
|
|
9
|
+
args: {
|
|
10
|
+
label: 'Hora de inicio',
|
|
11
|
+
name: 'startTime',
|
|
12
|
+
value: '',
|
|
13
|
+
onChange: (e) => console.log('changed', e.target.value),
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const WithPreselectedValue = {
|
|
18
|
+
args: {
|
|
19
|
+
label: 'Hora de la cita',
|
|
20
|
+
name: 'appointmentTime',
|
|
21
|
+
value: '14:30',
|
|
22
|
+
onChange: (e) => console.log('changed', e.target.value),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Required = {
|
|
27
|
+
args: {
|
|
28
|
+
label: 'Hora límite',
|
|
29
|
+
name: 'deadlineTime',
|
|
30
|
+
value: '09:00',
|
|
31
|
+
required: true,
|
|
32
|
+
onChange: (e) => console.log('changed', e.target.value),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Disabled = {
|
|
37
|
+
args: {
|
|
38
|
+
label: 'Hora de cierre',
|
|
39
|
+
name: 'closeTime',
|
|
40
|
+
value: '18:00',
|
|
41
|
+
disabled: true,
|
|
42
|
+
onChange: (e) => console.log('changed', e.target.value),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const parseTimeTo12h = (value) => {
|
|
2
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
3
|
+
const h24 = value.getHours();
|
|
4
|
+
const m = value.getMinutes();
|
|
5
|
+
const period = h24 >= 12 ? 'PM' : 'AM';
|
|
6
|
+
let h12 = h24 % 12;
|
|
7
|
+
if (h12 === 0) h12 = 12;
|
|
8
|
+
return { hours: h12, minutes: m, period };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
12
|
+
const match = value.match(/^(\d{1,2}):(\d{2})/);
|
|
13
|
+
if (match) {
|
|
14
|
+
const h24 = Number(match[1]);
|
|
15
|
+
const m = Number(match[2]);
|
|
16
|
+
if (!Number.isNaN(h24) && !Number.isNaN(m) && h24 >= 0 && h24 <= 23 && m >= 0 && m <= 59) {
|
|
17
|
+
const period = h24 >= 12 ? 'PM' : 'AM';
|
|
18
|
+
let h12 = h24 % 12;
|
|
19
|
+
if (h12 === 0) h12 = 12;
|
|
20
|
+
return { hours: h12, minutes: m, period };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { hours: 12, minutes: 0, period: 'AM' };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const format12hTo24h = (hours, minutes, period) => {
|
|
29
|
+
let h24 = Number(hours);
|
|
30
|
+
if (period === 'PM' && h24 !== 12) h24 += 12;
|
|
31
|
+
if (period === 'AM' && h24 === 12) h24 = 0;
|
|
32
|
+
|
|
33
|
+
const formattedHours = String(h24).padStart(2, '0');
|
|
34
|
+
const formattedMinutes = String(minutes).padStart(2, '0');
|
|
35
|
+
return `${formattedHours}:${formattedMinutes}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getDisplayTimeText = (value, hours, minutes, period) => {
|
|
39
|
+
if (!value) return '';
|
|
40
|
+
const displayHours = String(hours).padStart(2, '0');
|
|
41
|
+
const displayMinutes = String(minutes).padStart(2, '0');
|
|
42
|
+
return `${displayHours}:${displayMinutes} ${period}`;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const getCurrentTime12h = () => {
|
|
46
|
+
const now = new Date();
|
|
47
|
+
return parseTimeTo12h(now);
|
|
48
|
+
};
|