@popsure/dirty-swan 0.63.1 → 0.64.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.
Files changed (33) hide show
  1. package/dist/cjs/index.js +7762 -1991
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/dateSelector/components/Calendar.d.ts +0 -1
  4. package/dist/esm/Calendar-C7I0F5Gv.js +8032 -0
  5. package/dist/esm/Calendar-C7I0F5Gv.js.map +1 -0
  6. package/dist/esm/components/dateSelector/components/Calendar.js +2 -3
  7. package/dist/esm/components/dateSelector/components/Calendar.js.map +1 -1
  8. package/dist/esm/components/dateSelector/index.js +1 -2
  9. package/dist/esm/components/dateSelector/index.js.map +1 -1
  10. package/dist/esm/components/dateSelector/index.stories.js +1 -2
  11. package/dist/esm/components/dateSelector/index.stories.js.map +1 -1
  12. package/dist/esm/components/dateSelector/index.test.js +4 -5
  13. package/dist/esm/components/dateSelector/index.test.js.map +1 -1
  14. package/dist/esm/index.js +2 -3
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/lib/components/dateSelector/components/Calendar.d.ts +0 -1
  17. package/dist/esm/util/images/index.stories.js +1 -2
  18. package/dist/esm/util/images/index.stories.js.map +1 -1
  19. package/package.json +2 -3
  20. package/src/lib/components/dateSelector/components/Calendar.tsx +22 -39
  21. package/src/lib/components/dateSelector/components/datepicker.module.scss +199 -0
  22. package/src/lib/components/dateSelector/index.test.tsx +2 -2
  23. package/dist/cjs/lib/components/dateSelector/components/CalendarCaption.d.ts +0 -13
  24. package/dist/esm/Calendar-OjEwgyw8.js +0 -2191
  25. package/dist/esm/Calendar-OjEwgyw8.js.map +0 -1
  26. package/dist/esm/CalendarCaption-Bs7RbqJC.js +0 -77
  27. package/dist/esm/CalendarCaption-Bs7RbqJC.js.map +0 -1
  28. package/dist/esm/components/dateSelector/components/CalendarCaption.js +0 -7
  29. package/dist/esm/components/dateSelector/components/CalendarCaption.js.map +0 -1
  30. package/dist/esm/lib/components/dateSelector/components/CalendarCaption.d.ts +0 -13
  31. package/src/lib/components/dateSelector/components/CalendarCaption.tsx +0 -175
  32. package/src/lib/components/dateSelector/components/calendarCaption.module.scss +0 -168
  33. package/src/lib/components/dateSelector/components/datepicker.scss +0 -356
@@ -1,13 +1,13 @@
1
1
  import { useRef, useState } from 'react';
2
2
  import dayjs from 'dayjs';
3
- import DayPicker from 'react-day-picker';
3
+ import { DayPicker } from 'react-day-picker';
4
+ import rdpStyles from 'react-day-picker/style.module.css';
4
5
 
5
6
  import { useOnClickOutside } from '../../../hooks/useOnClickOutside';
6
7
  import { CalendarIcon } from '../../icon/icons';
7
- import { CalendarCaption } from './CalendarCaption';
8
8
 
9
9
  import styles from './style.module.scss';
10
- import './datepicker.scss';
10
+ import datepickerStyles from './datepicker.module.scss';
11
11
  import { Button } from '../../button';
12
12
 
13
13
  export interface CalendarProps {
@@ -39,9 +39,8 @@ export const Calendar = ({
39
39
  ? dayjs().locale(dayjsLocale).localeData()
40
40
  : dayjs().locale('en').localeData();
41
41
 
42
- const localizedWeekdays = localeDate.weekdays();
43
- const localizedWeekdaysShort = localeDate.weekdaysMin();
44
42
  const localizedMonths = localeDate.months();
43
+ const localizedWeekdaysShort = localeDate.weekdaysMin();
45
44
 
46
45
  const calendarContainerRef = useRef<HTMLDivElement | null>(null);
47
46
  const [displayedMonth, setDisplayedMonth] = useState<Date | undefined>(undefined);
@@ -62,20 +61,6 @@ export const Calendar = ({
62
61
  .endOf('year')
63
62
  .toDate();
64
63
 
65
- const currentMonth = displayedMonth ?? selectedDateInDateType ?? calendarDefaultDate;
66
-
67
- const handlePrevMonth = () => {
68
- const prev = new Date(currentMonth);
69
- prev.setMonth(prev.getMonth() - 1);
70
- setDisplayedMonth(prev);
71
- };
72
-
73
- const handleNextMonth = () => {
74
- const next = new Date(currentMonth);
75
- next.setMonth(next.getMonth() + 1);
76
- setDisplayedMonth(next);
77
- };
78
-
79
64
  useOnClickOutside(calendarContainerRef, () => setCalendarOpen(false));
80
65
 
81
66
  if (!displayCalendar) {
@@ -100,10 +85,13 @@ export const Calendar = ({
100
85
  {isOpen && (
101
86
  <DayPicker
102
87
  month={displayedMonth ?? selectedDateInDateType ?? calendarDefaultDate}
88
+ mode="single"
103
89
  showOutsideDays={true}
104
- fromMonth={dateCalendarFromMonth}
105
- toMonth={dateCalendarToMonth}
106
- selectedDays={selectedDateInDateType}
90
+ captionLayout="dropdown"
91
+ navLayout="around"
92
+ startMonth={dateCalendarFromMonth}
93
+ endMonth={dateCalendarToMonth}
94
+ selected={selectedDateInDateType}
107
95
  onDayClick={(date: Date) => {
108
96
  if (!dayjs(date).isValid()) {
109
97
  return;
@@ -118,28 +106,23 @@ export const Calendar = ({
118
106
  setCalendarOpen(false);
119
107
  }
120
108
  }}
121
- navbarElement={() => null}
122
109
  onMonthChange={(month: Date) => setDisplayedMonth(month)}
123
- captionElement={({ date }: { date: Date }) => (
124
- <CalendarCaption
125
- date={date}
126
- months={localizedMonths}
127
- yearBoundaries={yearBoundaries}
128
- onMonthChange={(newDate) => setDisplayedMonth(newDate)}
129
- onPrevClick={handlePrevMonth}
130
- onNextClick={handleNextMonth}
131
- />
132
- )}
133
110
  pagedNavigation={true}
134
- disabledDays={{
111
+ disabled={{
135
112
  before: dateCalendarFromMonth,
136
113
  after: dateCalendarToMonth,
137
114
  }}
138
- firstDayOfWeek={firstDayOfWeek}
139
- locale={dayjsLocale?.name || 'en'}
140
- months={localizedMonths}
141
- weekdaysLong={localizedWeekdays}
142
- weekdaysShort={localizedWeekdaysShort}
115
+ weekStartsOn={firstDayOfWeek as 0 | 1 | 2 | 3 | 4 | 5 | 6}
116
+ formatters={{
117
+ formatWeekdayName: (_date) => {
118
+ const dayIndex = _date.getDay();
119
+ return localizedWeekdaysShort[dayIndex]?.charAt(0) ?? '';
120
+ },
121
+ formatMonthDropdown: (date) => {
122
+ return localizedMonths[date.getMonth()];
123
+ },
124
+ }}
125
+ classNames={{ ...rdpStyles, ...datepickerStyles }}
143
126
  />
144
127
  )}
145
128
  </div>
@@ -0,0 +1,199 @@
1
+ @use '../../../scss/public/grid' as *;
2
+ @use '../../../scss/public/colors' as *;
3
+ @use '../../../scss/public/font-weight' as *;
4
+ @use '../../../scss/public/shadows' as *;
5
+
6
+ .root {
7
+ --rdp-accent-color: #{$ds-neutral-600};
8
+ --rdp-accent-background-color: #{$ds-orange-500};
9
+ --rdp-day-height: 44px;
10
+ --rdp-day-width: 44px;
11
+ --rdp-day_button-height: 42px;
12
+ --rdp-day_button-width: 42px;
13
+ --rdp-day_button-border-radius: 50%;
14
+ --rdp-day_button-border: 2px solid transparent;
15
+ --rdp-selected-border: 2px solid #{$ds-orange-500};
16
+ --rdp-selected-background: #{$ds-orange-500};
17
+ --rdp-outside-opacity: 1;
18
+ --rdp-today-color: #{$ds-neutral-900};
19
+ --rdp-dropdown-gap: 8px;
20
+ --rdp-nav_button-disabled-opacity: 0.5;
21
+ --rdp-nav_button-height: 2.75rem;
22
+ --rdp-nav_button-width: 2.75rem;
23
+
24
+ position: absolute;
25
+ left: 40px;
26
+ top: -112px;
27
+ z-index: 100;
28
+ background-color: $ds-white;
29
+ box-shadow: $bs-md;
30
+ border-radius: 16px;
31
+ color: $ds-neutral-900;
32
+ font-size: 16px;
33
+ padding: 16px 24px 24px 24px;
34
+
35
+ @include p-size-mobile {
36
+ position: fixed;
37
+ top: 50%;
38
+ left: 50%;
39
+ transform: translate(-50%, -50%);
40
+ }
41
+ }
42
+
43
+ .month {
44
+ position: relative;
45
+ }
46
+
47
+ .month_caption {
48
+ display: flex;
49
+ align-content: center;
50
+ justify-content: center;
51
+ height: var(--rdp-nav-height);
52
+ margin-top: 6px;
53
+ margin-bottom: 24px;
54
+ margin-inline-start: var(--rdp-nav_button-width);
55
+ margin-inline-end: var(--rdp-nav_button-width);
56
+ position: relative;
57
+ }
58
+
59
+ .weekday {
60
+ padding: 8px 0;
61
+ font-weight: $p-font-weight-normal;
62
+ text-align: center;
63
+ color: $ds-neutral-600;
64
+ font-size: 16px;
65
+ }
66
+
67
+ .dropdowns {
68
+ position: relative;
69
+ display: inline-flex;
70
+ align-items: center;
71
+ gap: var(--rdp-dropdown-gap);
72
+ }
73
+
74
+ .day_button {
75
+ background: none;
76
+ padding: 0;
77
+ margin: 0;
78
+ cursor: pointer;
79
+ font-weight: $p-font-weight-normal;
80
+ font-size: 16px;
81
+ color: inherit;
82
+ display: flex;
83
+ justify-content: center;
84
+ align-items: center;
85
+ width: var(--rdp-day_button-width);
86
+ height: var(--rdp-day_button-height);
87
+ border: var(--rdp-day_button-border);
88
+ border-radius: var(--rdp-day_button-border-radius);
89
+
90
+ &:hover {
91
+ background-color: $ds-transparent;
92
+ border-color: $ds-orange-600;
93
+ }
94
+ }
95
+
96
+ .outside {
97
+ color: $ds-neutral-400;
98
+ }
99
+
100
+ .disabled {
101
+ color: $ds-neutral-400;
102
+ pointer-events: none;
103
+ }
104
+
105
+ .selected {
106
+ font-size: unset;
107
+ font-weight: unset;
108
+
109
+ .day_button {
110
+ border: var(--rdp-selected-border);
111
+ background-color: $ds-orange-500;
112
+ color: $ds-neutral-900;
113
+ }
114
+ }
115
+
116
+ .button_previous,
117
+ .button_next {
118
+ position: absolute;
119
+ top: 4px;
120
+ }
121
+
122
+ .button_previous {
123
+ inset-inline-start: 0;
124
+ }
125
+
126
+ .button_next {
127
+ inset-inline-end: 0;
128
+ }
129
+
130
+ .button_previous,
131
+ .button_next {
132
+ border: none;
133
+ background: none;
134
+ padding: 0;
135
+ margin: 0;
136
+ cursor: pointer;
137
+ display: inline-flex;
138
+ justify-content: center;
139
+ align-items: center;
140
+ width: 40px;
141
+ height: 40px;
142
+ border-radius: 50%;
143
+
144
+ &:hover {
145
+ background-color: $ds-neutral-100;
146
+ }
147
+
148
+ &:disabled,
149
+ &[aria-disabled='true'] {
150
+ cursor: revert;
151
+ opacity: var(--rdp-nav_button-disabled-opacity);
152
+ }
153
+
154
+ svg {
155
+ width: 20px;
156
+ height: 20px;
157
+ fill: $ds-neutral-800;
158
+ }
159
+ }
160
+
161
+ .chevron {
162
+ display: inline-block;
163
+ fill: $ds-neutral-500;
164
+ }
165
+
166
+ .dropdown_root {
167
+ position: relative;
168
+ display: inline-flex;
169
+ align-items: center;
170
+ border: 1px solid $ds-neutral-300;
171
+ border-radius: 8px;
172
+ padding: 8px 12px;
173
+ }
174
+
175
+ .dropdown {
176
+ z-index: 2;
177
+ opacity: 0;
178
+ appearance: none;
179
+ position: absolute;
180
+ inset-inline-start: 0;
181
+ inset-block-start: 0;
182
+ width: 100%;
183
+ height: 100%;
184
+ cursor: pointer;
185
+ line-height: inherit;
186
+ font-weight: 500;
187
+ font-size: inherit;
188
+ color: $ds-neutral-900;
189
+ }
190
+
191
+ .caption_label {
192
+ z-index: 1;
193
+ position: relative;
194
+ display: inline-flex;
195
+ align-items: center;
196
+ white-space: nowrap;
197
+ border: 0;
198
+ font-weight: $p-font-weight-bold;
199
+ }
@@ -150,7 +150,7 @@ describe('DateSelector component', () => {
150
150
 
151
151
  await user.click(button);
152
152
 
153
- const calendarCell = getByLabelText(/17 2024/);
153
+ const calendarCell = getByLabelText(/January 17/);
154
154
 
155
155
  await user.click(calendarCell);
156
156
 
@@ -167,7 +167,7 @@ describe('DateSelector component', () => {
167
167
 
168
168
  await user.click(button);
169
169
 
170
- const calendarCell = getByLabelText(/17 2024/);
170
+ const calendarCell = getByLabelText(/January 17/);
171
171
  expect(calendarCell).toBeVisible();
172
172
 
173
173
  // click outside the calendar
@@ -1,13 +0,0 @@
1
- interface CalendarCaptionProps {
2
- date: Date;
3
- months: string[];
4
- yearBoundaries: {
5
- min: number;
6
- max: number;
7
- };
8
- onMonthChange: (date: Date) => void;
9
- onPrevClick: () => void;
10
- onNextClick: () => void;
11
- }
12
- export declare const CalendarCaption: ({ date, months, yearBoundaries, onMonthChange, onPrevClick, onNextClick, }: CalendarCaptionProps) => JSX.Element;
13
- export {};