@shohojdhara/atomix 0.2.4 → 0.2.6
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/README.md +19 -0
- package/dist/atomix.css +1300 -1418
- package/dist/atomix.min.css +3 -3
- package/dist/index.d.ts +1259 -874
- package/dist/index.esm.js +16256 -26366
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15691 -22295
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/applemix.css +15036 -0
- package/dist/themes/applemix.min.css +72 -0
- package/dist/themes/boomdevs.css +1300 -1419
- package/dist/themes/boomdevs.min.css +3 -3
- package/dist/themes/esrar.css +1301 -1419
- package/dist/themes/esrar.min.css +3 -3
- package/dist/themes/flashtrade.css +15187 -0
- package/dist/themes/flashtrade.min.css +86 -0
- package/dist/themes/mashroom.css +1299 -1417
- package/dist/themes/mashroom.min.css +5 -5
- package/dist/themes/shaj-default.css +1300 -1418
- package/dist/themes/shaj-default.min.css +3 -3
- package/package.json +6 -17
- package/src/components/Accordion/Accordion.stories.tsx +4 -26
- package/src/components/Accordion/Accordion.tsx +21 -12
- package/src/components/AtomixGlass/AtomixGlass.test.tsx +106 -72
- package/src/components/AtomixGlass/AtomixGlass.tsx +485 -1215
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +399 -0
- package/src/components/AtomixGlass/GlassFilter.tsx +156 -0
- package/src/components/AtomixGlass/README.md +124 -2
- package/src/components/AtomixGlass/atomixGLass.old.tsx +1266 -0
- package/src/components/AtomixGlass/glass-utils.ts +263 -0
- package/src/components/AtomixGlass/shader-utils.ts +404 -236
- package/src/components/AtomixGlass/{AtomixGlass.stories.tsx → stories/AtomixGlass.stories.tsx} +55 -35
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +57 -89
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +149 -149
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +95 -32
- package/src/components/AtomixGlass/stories/ShaderVariants.stories.tsx +0 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +9 -18
- package/src/components/AtomixGlass/utils.ts +3 -3
- package/src/components/Avatar/Avatar.tsx +3 -0
- package/src/components/Avatar/AvatarGroup.tsx +2 -1
- package/src/components/Badge/Badge.stories.tsx +74 -54
- package/src/components/Badge/Badge.tsx +8 -12
- package/src/components/Breadcrumb/Breadcrumb.tsx +23 -4
- package/src/components/Button/Button.tsx +3 -5
- package/src/components/Callout/Callout.stories.tsx +86 -35
- package/src/components/Callout/Callout.tsx +4 -0
- package/src/components/Card/Card.stories.tsx +89 -85
- package/src/components/Card/Card.tsx +15 -4
- package/src/components/Card/ElevationCard.tsx +2 -0
- package/src/components/Chart/AnimatedChart.tsx +179 -156
- package/src/components/Chart/AreaChart.tsx +123 -12
- package/src/components/Chart/BarChart.tsx +91 -100
- package/src/components/Chart/BaseChart.tsx +80 -0
- package/src/components/Chart/BubbleChart.tsx +114 -290
- package/src/components/Chart/CandlestickChart.tsx +282 -622
- package/src/components/Chart/Chart.stories.tsx +576 -179
- package/src/components/Chart/Chart.tsx +374 -75
- package/src/components/Chart/ChartRenderer.tsx +371 -220
- package/src/components/Chart/ChartToolbar.tsx +372 -61
- package/src/components/Chart/ChartTooltip.tsx +33 -18
- package/src/components/Chart/DonutChart.tsx +172 -254
- package/src/components/Chart/FunnelChart.tsx +169 -240
- package/src/components/Chart/GaugeChart.tsx +224 -392
- package/src/components/Chart/HeatmapChart.tsx +302 -440
- package/src/components/Chart/LineChart.tsx +148 -103
- package/src/components/Chart/MultiAxisChart.tsx +267 -395
- package/src/components/Chart/PieChart.tsx +114 -64
- package/src/components/Chart/RadarChart.tsx +202 -218
- package/src/components/Chart/ScatterChart.tsx +111 -97
- package/src/components/Chart/TreemapChart.tsx +147 -222
- package/src/components/Chart/WaterfallChart.tsx +253 -291
- package/src/components/Chart/index.ts +11 -9
- package/src/components/Chart/types.ts +85 -9
- package/src/components/Chart/utils.ts +66 -0
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +121 -11
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +149 -45
- package/src/components/ColorModeToggle/index.ts +1 -1
- package/src/components/Countdown/Countdown.tsx +4 -0
- package/src/components/DataTable/DataTable.tsx +2 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -11
- package/src/components/DatePicker/DatePicker.tsx +3 -9
- package/src/components/DatePicker/types.ts +5 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +32 -25
- package/src/components/Dropdown/Dropdown.tsx +26 -28
- package/src/components/EdgePanel/EdgePanel.stories.tsx +13 -15
- package/src/components/EdgePanel/EdgePanel.tsx +20 -5
- package/src/components/Footer/Footer.stories.tsx +187 -60
- package/src/components/Footer/Footer.test.tsx +134 -0
- package/src/components/Footer/Footer.tsx +133 -34
- package/src/components/Footer/FooterLink.tsx +1 -1
- package/src/components/Footer/FooterSection.tsx +53 -36
- package/src/components/Footer/FooterSocialLink.tsx +32 -29
- package/src/components/Footer/README.md +82 -3
- package/src/components/Footer/index.ts +1 -1
- package/src/components/Form/Checkbox.stories.tsx +13 -5
- package/src/components/Form/Checkbox.tsx +3 -6
- package/src/components/Form/Form.stories.tsx +10 -3
- package/src/components/Form/Form.tsx +2 -0
- package/src/components/Form/FormGroup.tsx +2 -1
- package/src/components/Form/Input.stories.tsx +12 -11
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +22 -7
- package/src/components/Form/Radio.tsx +3 -6
- package/src/components/Form/Select.stories.tsx +21 -6
- package/src/components/Form/Select.tsx +3 -5
- package/src/components/Form/Textarea.stories.tsx +13 -11
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/Hero/Hero.stories.tsx +2 -3
- package/src/components/Hero/Hero.tsx +5 -6
- package/src/components/Icon/Icon.tsx +12 -1
- package/src/components/List/List.tsx +2 -1
- package/src/components/List/ListGroup.tsx +2 -1
- package/src/components/Messages/Messages.tsx +3 -2
- package/src/components/Modal/Modal.stories.tsx +48 -34
- package/src/components/Modal/Modal.tsx +19 -23
- package/src/components/Navigation/Menu/MegaMenu.tsx +2 -2
- package/src/components/Navigation/Menu/Menu.tsx +2 -2
- package/src/components/Navigation/Nav/Nav.tsx +6 -1
- package/src/components/Navigation/Nav/NavDropdown.tsx +10 -1
- package/src/components/Navigation/Navbar/Navbar.tsx +4 -1
- package/src/components/Navigation/SideMenu/SideMenu.tsx +3 -2
- package/src/components/Pagination/Pagination.stories.tsx +13 -6
- package/src/components/Pagination/Pagination.tsx +7 -6
- package/src/components/PhotoViewer/PhotoViewer.tsx +2 -1
- package/src/components/Popover/Popover.stories.tsx +32 -24
- package/src/components/Popover/Popover.tsx +4 -1
- package/src/components/ProductReview/ProductReview.tsx +8 -2
- package/src/components/Progress/Progress.tsx +2 -1
- package/src/components/Rating/Rating.stories.tsx +11 -6
- package/src/components/Rating/Rating.tsx +3 -5
- package/src/components/River/River.tsx +5 -5
- package/src/components/SectionIntro/SectionIntro.tsx +8 -2
- package/src/components/Slider/Slider.stories.tsx +4 -4
- package/src/components/Slider/Slider.tsx +4 -3
- package/src/components/Spinner/Spinner.tsx +2 -1
- package/src/components/Steps/Steps.stories.tsx +5 -4
- package/src/components/Steps/Steps.tsx +8 -5
- package/src/components/Tab/Tab.stories.tsx +4 -3
- package/src/components/Tab/Tab.tsx +8 -6
- package/src/components/Testimonial/Testimonial.tsx +8 -2
- package/src/components/Todo/Todo.tsx +2 -1
- package/src/components/Toggle/Toggle.stories.tsx +5 -4
- package/src/components/Toggle/Toggle.tsx +8 -5
- package/src/components/Tooltip/Tooltip.stories.tsx +40 -30
- package/src/components/Tooltip/Tooltip.tsx +9 -2
- package/src/components/Upload/Upload.stories.tsx +252 -0
- package/src/components/Upload/Upload.tsx +92 -53
- package/src/components/VideoPlayer/VideoPlayer.tsx +3 -1
- package/src/components/index.ts +0 -4
- package/src/layouts/Grid/Grid.stories.tsx +10 -23
- package/src/layouts/Grid/Grid.tsx +20 -1
- package/src/layouts/Grid/GridCol.tsx +76 -48
- package/src/lib/composables/useAtomixGlass.ts +861 -44
- package/src/lib/composables/useBarChart.ts +13 -6
- package/src/lib/composables/useChart.ts +17 -13
- package/src/lib/composables/useChartExport.ts +19 -78
- package/src/lib/composables/useChartToolbar.ts +0 -1
- package/src/lib/composables/useEdgePanel.ts +111 -103
- package/src/lib/composables/useFooter.ts +3 -3
- package/src/lib/composables/useGlassContainer.ts +16 -7
- package/src/lib/composables/useLineChart.ts +8 -1
- package/src/lib/composables/useRiver.ts +5 -0
- package/src/lib/composables/useSlider.ts +62 -24
- package/src/lib/composables/useVideoPlayer.ts +60 -63
- package/src/lib/constants/components.ts +146 -32
- package/src/lib/types/components.ts +258 -10
- package/src/lib/utils/displacement-generator.ts +55 -49
- package/src/lib/utils/icons.ts +1 -1
- package/src/lib/utils/index.ts +16 -10
- package/src/styles/01-settings/_settings.accordion.scss +19 -19
- package/src/styles/01-settings/_settings.animations.scss +5 -5
- package/src/styles/01-settings/_settings.avatar-group.scss +1 -1
- package/src/styles/01-settings/_settings.avatar.scss +17 -17
- package/src/styles/01-settings/_settings.background.scss +1 -4
- package/src/styles/01-settings/_settings.badge.scss +1 -1
- package/src/styles/01-settings/_settings.breadcrumb.scss +1 -1
- package/src/styles/01-settings/_settings.card.scss +1 -1
- package/src/styles/01-settings/_settings.chart.scss +65 -2
- package/src/styles/01-settings/_settings.dropdown.scss +1 -1
- package/src/styles/01-settings/_settings.footer.scss +35 -42
- package/src/styles/01-settings/_settings.input.scss +1 -1
- package/src/styles/01-settings/_settings.list.scss +1 -1
- package/src/styles/01-settings/_settings.rating.scss +1 -1
- package/src/styles/01-settings/_settings.tabs.scss +1 -1
- package/src/styles/01-settings/_settings.upload.scss +6 -5
- package/src/styles/02-tools/_tools.animations.scss +4 -5
- package/src/styles/02-tools/_tools.background.scss +1 -13
- package/src/styles/02-tools/_tools.glass.scss +0 -1
- package/src/styles/02-tools/_tools.utility-api.scss +42 -34
- package/src/styles/03-generic/_generic.root.scss +1 -4
- package/src/styles/04-elements/_elements.body.scss +0 -1
- package/src/styles/06-components/_components.atomix-glass.scss +217 -39
- package/src/styles/06-components/_components.badge.scss +6 -8
- package/src/styles/06-components/_components.button.scss +8 -3
- package/src/styles/06-components/_components.card.scss +2 -14
- package/src/styles/06-components/_components.chart.scss +969 -1449
- package/src/styles/06-components/_components.color-mode-toggle.scss +43 -6
- package/src/styles/06-components/_components.dropdown.scss +19 -7
- package/src/styles/06-components/_components.edge-panel.scss +4 -2
- package/src/styles/06-components/_components.footer.scss +166 -85
- package/src/styles/06-components/_components.input.scss +8 -9
- package/src/styles/06-components/_components.list.scss +1 -0
- package/src/styles/06-components/_components.modal.scss +5 -3
- package/src/styles/06-components/_components.skeleton.scss +8 -6
- package/src/styles/06-components/_components.upload.scss +219 -4
- package/src/styles/06-components/old.chart.styles.scss +1 -30
- package/src/styles/99-utilities/_utilities.opacity.scss +1 -1
- package/src/styles/99-utilities/_utilities.scss +1 -1
- package/src/components/Chart/AdvancedChart.tsx +0 -624
- package/src/components/Chart/LineChartNew.tsx +0 -167
- package/src/components/Chart/RealTimeChart.tsx +0 -436
- package/src/components/DatePicker/DatePicker copy.tsx +0 -551
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useImperativeHandle } from 'react';
|
|
2
|
-
import { DatePickerProps, DatePickerRef } from './types';
|
|
3
|
-
import { useDatePicker } from '../../lib/composables/useDatePicker';
|
|
4
|
-
import { formatDate } from './utils';
|
|
5
|
-
import { Icon } from '../Icon/Icon';
|
|
6
|
-
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* DatePicker component for selecting dates from a calendar interface.
|
|
10
|
-
* Supports various display modes, date ranges, and customization options.
|
|
11
|
-
*/
|
|
12
|
-
export const DatePicker = forwardRef<DatePickerRef, DatePickerProps>(
|
|
13
|
-
(
|
|
14
|
-
{
|
|
15
|
-
value,
|
|
16
|
-
onChange,
|
|
17
|
-
selectionMode = 'single',
|
|
18
|
-
startDate,
|
|
19
|
-
endDate,
|
|
20
|
-
onRangeChange,
|
|
21
|
-
format = 'MM/dd/yyyy',
|
|
22
|
-
minDate,
|
|
23
|
-
maxDate,
|
|
24
|
-
placeholder = 'Select date...',
|
|
25
|
-
disabled = false,
|
|
26
|
-
readOnly = false,
|
|
27
|
-
clearable = true,
|
|
28
|
-
showTodayButton = true,
|
|
29
|
-
showWeekNumbers = false,
|
|
30
|
-
inline = false,
|
|
31
|
-
id,
|
|
32
|
-
name,
|
|
33
|
-
className = '',
|
|
34
|
-
placement = 'bottom-start',
|
|
35
|
-
inputClassName = '',
|
|
36
|
-
size = 'md',
|
|
37
|
-
glass,
|
|
38
|
-
...props
|
|
39
|
-
},
|
|
40
|
-
ref
|
|
41
|
-
) => {
|
|
42
|
-
const {
|
|
43
|
-
// State
|
|
44
|
-
isOpen,
|
|
45
|
-
inputValue,
|
|
46
|
-
rangeInputValue,
|
|
47
|
-
viewMode,
|
|
48
|
-
currentMonth,
|
|
49
|
-
currentYear,
|
|
50
|
-
selectionMode: activeSelectionMode,
|
|
51
|
-
rangeSelectionState,
|
|
52
|
-
|
|
53
|
-
// Refs
|
|
54
|
-
datePickerRef,
|
|
55
|
-
inputRef,
|
|
56
|
-
|
|
57
|
-
// Range state
|
|
58
|
-
startDate: rangeStartDate,
|
|
59
|
-
endDate: rangeEndDate,
|
|
60
|
-
|
|
61
|
-
// Methods
|
|
62
|
-
setIsOpen,
|
|
63
|
-
handleInputChange,
|
|
64
|
-
handleInputFocus,
|
|
65
|
-
handleClear,
|
|
66
|
-
handleDateSelect,
|
|
67
|
-
handleTodayClick,
|
|
68
|
-
handlePrevMonth,
|
|
69
|
-
handleNextMonth,
|
|
70
|
-
handlePrevYear,
|
|
71
|
-
handleNextYear,
|
|
72
|
-
// View mode handlers
|
|
73
|
-
switchToMonthView,
|
|
74
|
-
switchToYearView,
|
|
75
|
-
selectMonth,
|
|
76
|
-
selectYear,
|
|
77
|
-
|
|
78
|
-
// Utility methods
|
|
79
|
-
generateDays,
|
|
80
|
-
generateMonths,
|
|
81
|
-
generateYears,
|
|
82
|
-
isDateSelectable,
|
|
83
|
-
isDateSelected,
|
|
84
|
-
isDateInSelectedRange,
|
|
85
|
-
isToday,
|
|
86
|
-
getWeekNumber,
|
|
87
|
-
} = useDatePicker({
|
|
88
|
-
value,
|
|
89
|
-
onChange,
|
|
90
|
-
selectionMode,
|
|
91
|
-
startDate,
|
|
92
|
-
endDate,
|
|
93
|
-
onRangeChange,
|
|
94
|
-
minDate,
|
|
95
|
-
maxDate,
|
|
96
|
-
format,
|
|
97
|
-
inline,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Expose the ref API
|
|
101
|
-
useImperativeHandle(ref, () => ({
|
|
102
|
-
open: () => setIsOpen(true),
|
|
103
|
-
close: () => setIsOpen(false),
|
|
104
|
-
clear: handleClear,
|
|
105
|
-
focus: () => inputRef.current?.focus(),
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
// Prepare class names
|
|
109
|
-
const datepickerClassName =
|
|
110
|
-
`c-datepicker ${className} ${inline ? 'c-datepicker--inline' : ''}`.trim();
|
|
111
|
-
const inputClasses = `c-datepicker__input c-input c-input--${size} ${inputClassName}`.trim();
|
|
112
|
-
|
|
113
|
-
// Create unique ID for accessibility
|
|
114
|
-
const datepickerId = id || `datepicker-${Math.random().toString(36).substring(2, 9)}`;
|
|
115
|
-
const calendarId = `${datepickerId}-calendar`;
|
|
116
|
-
|
|
117
|
-
// Get the appropriate input value based on selection mode
|
|
118
|
-
const displayValue = selectionMode === 'single' ? inputValue : rangeInputValue;
|
|
119
|
-
|
|
120
|
-
// Helper function to get placeholder based on selection mode
|
|
121
|
-
const getPlaceholder = () => {
|
|
122
|
-
if (selectionMode === 'single') {
|
|
123
|
-
return placeholder;
|
|
124
|
-
} else {
|
|
125
|
-
return rangeSelectionState === 'start'
|
|
126
|
-
? 'Select start date...'
|
|
127
|
-
: rangeStartDate
|
|
128
|
-
? `${formatDate(rangeStartDate, format)} - Select end date...`
|
|
129
|
-
: 'Select date range...';
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// Utility functions
|
|
134
|
-
const getMonthName = (monthIndex: number): string => {
|
|
135
|
-
const months = [
|
|
136
|
-
'January',
|
|
137
|
-
'February',
|
|
138
|
-
'March',
|
|
139
|
-
'April',
|
|
140
|
-
'May',
|
|
141
|
-
'June',
|
|
142
|
-
'July',
|
|
143
|
-
'August',
|
|
144
|
-
'September',
|
|
145
|
-
'October',
|
|
146
|
-
'November',
|
|
147
|
-
'December',
|
|
148
|
-
];
|
|
149
|
-
return months[monthIndex] || '';
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const getDaysOfWeek = (): string[] => {
|
|
153
|
-
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const isDateDisabled = (date: Date): boolean => {
|
|
157
|
-
if (minDate && date < minDate) return true;
|
|
158
|
-
if (maxDate && date > maxDate) return true;
|
|
159
|
-
return false;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const isDateToday = (date: Date): boolean => {
|
|
163
|
-
const today = new Date();
|
|
164
|
-
return (
|
|
165
|
-
date.getDate() === today.getDate() &&
|
|
166
|
-
date.getMonth() === today.getMonth() &&
|
|
167
|
-
date.getFullYear() === today.getFullYear()
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const isSameDate = (date1: Date, date2: Date): boolean => {
|
|
172
|
-
return (
|
|
173
|
-
date1.getDate() === date2.getDate() &&
|
|
174
|
-
date1.getMonth() === date2.getMonth() &&
|
|
175
|
-
date1.getFullYear() === date2.getFullYear()
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const generateCalendar = () => {
|
|
180
|
-
const days = generateDays();
|
|
181
|
-
const weeks = [];
|
|
182
|
-
for (let i = 0; i < days.length; i += 7) {
|
|
183
|
-
weeks.push(days.slice(i, i + 7));
|
|
184
|
-
}
|
|
185
|
-
return weeks;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const handlePrevDecade = () => {
|
|
189
|
-
// This would need to be implemented in the hook or handled differently
|
|
190
|
-
// For now, we'll work with what we have
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const handleNextDecade = () => {
|
|
194
|
-
// This would need to be implemented in the hook or handled differently
|
|
195
|
-
// For now, we'll work with what we have
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const switchToDayView = () => {
|
|
199
|
-
// This would need to be implemented in the hook or handled differently
|
|
200
|
-
// For now, we'll work with what we have
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// Helper function to render calendar content
|
|
204
|
-
const renderCalendarContent = () => (
|
|
205
|
-
<>
|
|
206
|
-
<div className="c-datepicker__header">
|
|
207
|
-
{viewMode === 'days' && (
|
|
208
|
-
<>
|
|
209
|
-
<button
|
|
210
|
-
type="button"
|
|
211
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--prev-year"
|
|
212
|
-
onClick={handlePrevYear}
|
|
213
|
-
aria-label="Previous year"
|
|
214
|
-
>
|
|
215
|
-
<Icon name="CaretDoubleLeft" size="sm" />
|
|
216
|
-
</button>
|
|
217
|
-
<button
|
|
218
|
-
type="button"
|
|
219
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--prev-month"
|
|
220
|
-
onClick={handlePrevMonth}
|
|
221
|
-
aria-label="Previous month"
|
|
222
|
-
>
|
|
223
|
-
<Icon name="CaretLeft" size="sm" />
|
|
224
|
-
</button>
|
|
225
|
-
<button
|
|
226
|
-
type="button"
|
|
227
|
-
className="c-datepicker__view-switch"
|
|
228
|
-
onClick={switchToMonthView}
|
|
229
|
-
aria-label={`${getMonthName(currentMonth)} ${currentYear}`}
|
|
230
|
-
>
|
|
231
|
-
{getMonthName(currentMonth)} {currentYear}
|
|
232
|
-
</button>
|
|
233
|
-
<button
|
|
234
|
-
type="button"
|
|
235
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--next-month"
|
|
236
|
-
onClick={handleNextMonth}
|
|
237
|
-
aria-label="Next month"
|
|
238
|
-
>
|
|
239
|
-
<Icon name="CaretRight" size="sm" />
|
|
240
|
-
</button>
|
|
241
|
-
<button
|
|
242
|
-
type="button"
|
|
243
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--next-year"
|
|
244
|
-
onClick={handleNextYear}
|
|
245
|
-
aria-label="Next year"
|
|
246
|
-
>
|
|
247
|
-
<Icon name="CaretDoubleRight" size="sm" />
|
|
248
|
-
</button>
|
|
249
|
-
</>
|
|
250
|
-
)}
|
|
251
|
-
|
|
252
|
-
{viewMode === 'months' && (
|
|
253
|
-
<>
|
|
254
|
-
<button
|
|
255
|
-
type="button"
|
|
256
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--prev-year"
|
|
257
|
-
onClick={handlePrevYear}
|
|
258
|
-
aria-label="Previous year"
|
|
259
|
-
>
|
|
260
|
-
<Icon name="CaretDoubleLeft" size="sm" />
|
|
261
|
-
</button>
|
|
262
|
-
<button
|
|
263
|
-
type="button"
|
|
264
|
-
className="c-datepicker__view-switch"
|
|
265
|
-
onClick={switchToYearView}
|
|
266
|
-
aria-label={`Year ${currentYear}`}
|
|
267
|
-
>
|
|
268
|
-
{currentYear}
|
|
269
|
-
</button>
|
|
270
|
-
<button
|
|
271
|
-
type="button"
|
|
272
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--next-year"
|
|
273
|
-
onClick={handleNextYear}
|
|
274
|
-
aria-label="Next year"
|
|
275
|
-
>
|
|
276
|
-
<Icon name="CaretDoubleRight" size="sm" />
|
|
277
|
-
</button>
|
|
278
|
-
</>
|
|
279
|
-
)}
|
|
280
|
-
|
|
281
|
-
{viewMode === 'years' && (
|
|
282
|
-
<>
|
|
283
|
-
<button
|
|
284
|
-
type="button"
|
|
285
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--prev-decade"
|
|
286
|
-
onClick={handlePrevDecade}
|
|
287
|
-
aria-label="Previous decade"
|
|
288
|
-
>
|
|
289
|
-
<Icon name="CaretDoubleLeft" size="sm" />
|
|
290
|
-
</button>
|
|
291
|
-
<button type="button" className="c-datepicker__view-switch" onClick={switchToDayView}>
|
|
292
|
-
{generateYears()[0]} - {generateYears()[generateYears().length - 1]}
|
|
293
|
-
</button>
|
|
294
|
-
<button
|
|
295
|
-
type="button"
|
|
296
|
-
className="c-datepicker__nav-button c-datepicker__nav-button--next-decade"
|
|
297
|
-
onClick={handleNextDecade}
|
|
298
|
-
aria-label="Next decade"
|
|
299
|
-
>
|
|
300
|
-
<Icon name="CaretDoubleRight" size="sm" />
|
|
301
|
-
</button>
|
|
302
|
-
</>
|
|
303
|
-
)}
|
|
304
|
-
</div>
|
|
305
|
-
|
|
306
|
-
<div className="c-datepicker__body">
|
|
307
|
-
{viewMode === 'days' && (
|
|
308
|
-
<>
|
|
309
|
-
<div
|
|
310
|
-
className={`c-datepicker__weekdays${showWeekNumbers ? ' c-datepicker__weekdays--has-weeknumber' : ''}`}
|
|
311
|
-
role="row"
|
|
312
|
-
>
|
|
313
|
-
{showWeekNumbers && <div className="c-datepicker__weekday">Wk</div>}
|
|
314
|
-
{getDaysOfWeek().map(day => (
|
|
315
|
-
<div key={day} className="c-datepicker__weekday" role="columnheader">
|
|
316
|
-
{day}
|
|
317
|
-
</div>
|
|
318
|
-
))}
|
|
319
|
-
</div>
|
|
320
|
-
|
|
321
|
-
<div
|
|
322
|
-
className={`c-datepicker__days${showWeekNumbers ? ' c-datepicker__days--has-weeknumber' : ''}`}
|
|
323
|
-
role="grid"
|
|
324
|
-
>
|
|
325
|
-
{(() => {
|
|
326
|
-
const allElements = [];
|
|
327
|
-
const days = generateDays();
|
|
328
|
-
|
|
329
|
-
for (let i = 0; i < days.length; i++) {
|
|
330
|
-
const dateObj = days[i];
|
|
331
|
-
if (!dateObj) continue;
|
|
332
|
-
|
|
333
|
-
const dateValue = new Date(dateObj.year, dateObj.month, dateObj.day);
|
|
334
|
-
const isSelectable = isDateSelectable(dateObj.year, dateObj.month, dateObj.day);
|
|
335
|
-
const isSelected = isDateSelected(dateObj.year, dateObj.month, dateObj.day);
|
|
336
|
-
const isTodayDate = isToday(dateObj.year, dateObj.month, dateObj.day);
|
|
337
|
-
const isInRange = isDateInSelectedRange(
|
|
338
|
-
dateObj.year,
|
|
339
|
-
dateObj.month,
|
|
340
|
-
dateObj.day
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
// Add week number at the start of each week
|
|
344
|
-
if (showWeekNumbers && i % 7 === 0) {
|
|
345
|
-
const weekNum = getWeekNumber(dateValue);
|
|
346
|
-
allElements.push(
|
|
347
|
-
<div
|
|
348
|
-
key={`weeknumber-${Math.floor(i / 7)}`}
|
|
349
|
-
className="c-datepicker__weeknumber"
|
|
350
|
-
role="rowheader"
|
|
351
|
-
>
|
|
352
|
-
{weekNum}
|
|
353
|
-
</div>
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// Add the day button
|
|
358
|
-
allElements.push(
|
|
359
|
-
<button
|
|
360
|
-
key={`day-${i}`}
|
|
361
|
-
type="button"
|
|
362
|
-
className={`c-datepicker__day
|
|
363
|
-
${!dateObj.isCurrentMonth ? 'c-datepicker__day--outside' : ''}
|
|
364
|
-
${isSelected ? 'c-datepicker__day--selected' : ''}
|
|
365
|
-
${isInRange ? 'c-datepicker__day--in-range' : ''}
|
|
366
|
-
${isTodayDate ? 'c-datepicker__day--today' : ''}
|
|
367
|
-
${!isSelectable ? 'c-datepicker__day--disabled' : ''}`}
|
|
368
|
-
onClick={() => isSelectable && handleDateSelect(dateObj.day)}
|
|
369
|
-
disabled={!isSelectable}
|
|
370
|
-
tabIndex={dateObj.isCurrentMonth ? 0 : -1}
|
|
371
|
-
aria-label={dateValue.toLocaleDateString()}
|
|
372
|
-
aria-selected={isSelected ? 'true' : 'false'}
|
|
373
|
-
role="gridcell"
|
|
374
|
-
>
|
|
375
|
-
{dateObj.day}
|
|
376
|
-
</button>
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
return allElements;
|
|
381
|
-
})()}
|
|
382
|
-
</div>
|
|
383
|
-
</>
|
|
384
|
-
)}
|
|
385
|
-
|
|
386
|
-
{viewMode === 'months' && (
|
|
387
|
-
<div className="c-datepicker__months" role="grid">
|
|
388
|
-
{generateMonths().map((monthObj, index) => {
|
|
389
|
-
const isSelected =
|
|
390
|
-
value &&
|
|
391
|
-
value.getMonth() === monthObj.month &&
|
|
392
|
-
value.getFullYear() === currentYear;
|
|
393
|
-
|
|
394
|
-
return (
|
|
395
|
-
<button
|
|
396
|
-
key={`month-${index}`}
|
|
397
|
-
type="button"
|
|
398
|
-
className={`c-datepicker__month ${isSelected ? 'c-datepicker__month--selected' : ''}`}
|
|
399
|
-
onClick={() => selectMonth(monthObj.month)}
|
|
400
|
-
aria-selected={isSelected ? 'true' : 'false'}
|
|
401
|
-
role="gridcell"
|
|
402
|
-
>
|
|
403
|
-
{monthObj.name.substring(0, 3)}
|
|
404
|
-
</button>
|
|
405
|
-
);
|
|
406
|
-
})}
|
|
407
|
-
</div>
|
|
408
|
-
)}
|
|
409
|
-
|
|
410
|
-
{viewMode === 'years' && (
|
|
411
|
-
<div className="c-datepicker__years" role="grid">
|
|
412
|
-
{generateYears().map((year, index) => {
|
|
413
|
-
const isSelected = value && value.getFullYear() === year;
|
|
414
|
-
|
|
415
|
-
return (
|
|
416
|
-
<button
|
|
417
|
-
key={`year-${index}`}
|
|
418
|
-
type="button"
|
|
419
|
-
className={`c-datepicker__year ${isSelected ? 'c-datepicker__year--selected' : ''}`}
|
|
420
|
-
onClick={() => selectYear(year)}
|
|
421
|
-
aria-selected={isSelected ? 'true' : 'false'}
|
|
422
|
-
role="gridcell"
|
|
423
|
-
>
|
|
424
|
-
{year}
|
|
425
|
-
</button>
|
|
426
|
-
);
|
|
427
|
-
})}
|
|
428
|
-
</div>
|
|
429
|
-
)}
|
|
430
|
-
</div>
|
|
431
|
-
|
|
432
|
-
{viewMode === 'days' && (
|
|
433
|
-
<div className="c-datepicker__footer">
|
|
434
|
-
{selectionMode === 'range' && (
|
|
435
|
-
<div className="c-datepicker__range-status c-badge c-badge--sm c-badge--info u-w-100">
|
|
436
|
-
Selecting {rangeSelectionState === 'start' ? 'start' : 'end'} date
|
|
437
|
-
</div>
|
|
438
|
-
)}
|
|
439
|
-
|
|
440
|
-
{showTodayButton && (
|
|
441
|
-
<button
|
|
442
|
-
type="button"
|
|
443
|
-
className="c-datepicker__today-button c-btn c-btn--sm c-btn--outline-primary"
|
|
444
|
-
onClick={handleTodayClick}
|
|
445
|
-
aria-label="Go to today"
|
|
446
|
-
>
|
|
447
|
-
Today
|
|
448
|
-
</button>
|
|
449
|
-
)}
|
|
450
|
-
|
|
451
|
-
{!inline && (
|
|
452
|
-
<button
|
|
453
|
-
type="button"
|
|
454
|
-
className="c-datepicker__close-button c-btn c-btn--sm c-btn--outline-error"
|
|
455
|
-
onClick={() => setIsOpen(false)}
|
|
456
|
-
aria-label="Close calendar"
|
|
457
|
-
>
|
|
458
|
-
Close
|
|
459
|
-
</button>
|
|
460
|
-
)}
|
|
461
|
-
</div>
|
|
462
|
-
)}
|
|
463
|
-
</>
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
return (
|
|
467
|
-
<div className={datepickerClassName} ref={datePickerRef} {...props}>
|
|
468
|
-
{!inline && (
|
|
469
|
-
<div className="c-datepicker__input-wrapper">
|
|
470
|
-
<input
|
|
471
|
-
id={datepickerId}
|
|
472
|
-
name={name}
|
|
473
|
-
ref={inputRef}
|
|
474
|
-
type="text"
|
|
475
|
-
className={inputClasses}
|
|
476
|
-
placeholder={getPlaceholder()}
|
|
477
|
-
value={displayValue}
|
|
478
|
-
onChange={handleInputChange}
|
|
479
|
-
onFocus={handleInputFocus}
|
|
480
|
-
disabled={disabled}
|
|
481
|
-
readOnly={readOnly}
|
|
482
|
-
aria-haspopup="dialog"
|
|
483
|
-
aria-expanded={isOpen}
|
|
484
|
-
aria-controls={calendarId}
|
|
485
|
-
/>
|
|
486
|
-
{clearable && displayValue && (
|
|
487
|
-
<button
|
|
488
|
-
type="button"
|
|
489
|
-
className="c-datepicker__clear-button"
|
|
490
|
-
onClick={handleClear}
|
|
491
|
-
aria-label="Clear date"
|
|
492
|
-
>
|
|
493
|
-
<Icon name="X" size="sm" />
|
|
494
|
-
</button>
|
|
495
|
-
)}
|
|
496
|
-
<span className="c-datepicker__calendar-icon" aria-hidden="true">
|
|
497
|
-
<Icon name="Calendar" size="sm" color="var(--atomix-secondary-text-emphasis)" />
|
|
498
|
-
</span>
|
|
499
|
-
</div>
|
|
500
|
-
)}
|
|
501
|
-
|
|
502
|
-
{(isOpen || inline) && (
|
|
503
|
-
<>
|
|
504
|
-
{glass ? (
|
|
505
|
-
<div
|
|
506
|
-
id={calendarId}
|
|
507
|
-
className={`c-datepicker__calendar c-datepicker__calendar--${placement} c-datepicker__calendar--glass`}
|
|
508
|
-
role="dialog"
|
|
509
|
-
aria-modal={!inline ? 'true' : undefined}
|
|
510
|
-
aria-label="Date picker"
|
|
511
|
-
>
|
|
512
|
-
<AtomixGlass
|
|
513
|
-
{...(glass === true
|
|
514
|
-
? {
|
|
515
|
-
displacementScale: 50,
|
|
516
|
-
blurAmount: 3,
|
|
517
|
-
saturation: 160,
|
|
518
|
-
aberrationIntensity: 0,
|
|
519
|
-
cornerRadius: 12,
|
|
520
|
-
overLight: false,
|
|
521
|
-
elasticity: 0,
|
|
522
|
-
mode: 'standard' as const,
|
|
523
|
-
}
|
|
524
|
-
: glass)}
|
|
525
|
-
>
|
|
526
|
-
<div className="c-datepicker__glass-content">{renderCalendarContent()}</div>
|
|
527
|
-
</AtomixGlass>
|
|
528
|
-
</div>
|
|
529
|
-
) : (
|
|
530
|
-
<div
|
|
531
|
-
id={calendarId}
|
|
532
|
-
className={`c-datepicker__calendar c-datepicker__calendar--${placement}`}
|
|
533
|
-
role="dialog"
|
|
534
|
-
aria-modal={!inline ? 'true' : undefined}
|
|
535
|
-
aria-label="Date picker"
|
|
536
|
-
>
|
|
537
|
-
{renderCalendarContent()}
|
|
538
|
-
</div>
|
|
539
|
-
)}
|
|
540
|
-
</>
|
|
541
|
-
)}
|
|
542
|
-
</div>
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
);
|
|
546
|
-
|
|
547
|
-
export type { DatePickerProps };
|
|
548
|
-
|
|
549
|
-
DatePicker.displayName = 'DatePicker';
|
|
550
|
-
|
|
551
|
-
export default DatePicker;
|