willba-component-library 0.2.28 → 0.2.30
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/lib/assets/SpinnerSvg.d.ts +5 -0
- package/lib/core/components/calendar/CalendarTypes.d.ts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.esm.js +27 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +27 -18
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +27 -18
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/SpinnerSvg.tsx +40 -0
- package/src/components/FilterCalendar/FilterCalendar.tsx +1 -0
- package/src/core/components/calendar/Calendar.tsx +20 -15
- package/src/core/components/calendar/CalendarTypes.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const SpinnerSVG = ({
|
|
4
|
+
fill,
|
|
5
|
+
size,
|
|
6
|
+
}: {
|
|
7
|
+
fill?: string
|
|
8
|
+
size?: number
|
|
9
|
+
}) => (
|
|
10
|
+
<svg
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
width={`${size || 25}`}
|
|
13
|
+
height={`${size || 25}`}
|
|
14
|
+
viewBox="0 0 24 24"
|
|
15
|
+
>
|
|
16
|
+
<style>
|
|
17
|
+
{`
|
|
18
|
+
.spinner_z9k8 {
|
|
19
|
+
transform-origin: center;
|
|
20
|
+
animation: spinner_StKS .75s infinite linear;
|
|
21
|
+
}
|
|
22
|
+
@keyframes spinner_StKS {
|
|
23
|
+
100% {
|
|
24
|
+
transform: rotate(360deg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`}
|
|
28
|
+
</style>
|
|
29
|
+
<path
|
|
30
|
+
d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
|
|
31
|
+
opacity=".25"
|
|
32
|
+
fill={fill}
|
|
33
|
+
/>
|
|
34
|
+
<path
|
|
35
|
+
d="M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"
|
|
36
|
+
className="spinner_z9k8"
|
|
37
|
+
fill={fill}
|
|
38
|
+
/>
|
|
39
|
+
</svg>
|
|
40
|
+
)
|
|
@@ -6,6 +6,7 @@ import { DateRange, DayPicker, Matcher } from 'react-day-picker'
|
|
|
6
6
|
import { useMediaQuery } from 'react-responsive'
|
|
7
7
|
|
|
8
8
|
import { CalendarTypes, DisableCalendarDates } from './CalendarTypes'
|
|
9
|
+
import { SpinnerSVG } from '../../../assets/SpinnerSvg'
|
|
9
10
|
|
|
10
11
|
import 'react-day-picker/dist/style.css'
|
|
11
12
|
import './Calendar.css'
|
|
@@ -26,6 +27,7 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
26
27
|
loadingData,
|
|
27
28
|
initialCalendarRange,
|
|
28
29
|
showFeedback,
|
|
30
|
+
palette,
|
|
29
31
|
}: CalendarTypes,
|
|
30
32
|
ref
|
|
31
33
|
) => {
|
|
@@ -96,6 +98,7 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
96
98
|
useEffect(() => {
|
|
97
99
|
if (typeof document === 'undefined' || !showFeedback) return
|
|
98
100
|
|
|
101
|
+
// Children
|
|
99
102
|
const calendarTooltip = document.querySelector('.will-calendar-tooltip')
|
|
100
103
|
const calendarTooltipCheckOut = document.querySelector(
|
|
101
104
|
'.will-calendar-tooltip-check-out'
|
|
@@ -108,6 +111,8 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
108
111
|
const loadingSpinner = document.querySelector(
|
|
109
112
|
'.will-filter-bar-calendar .will-calendar-spinner'
|
|
110
113
|
)
|
|
114
|
+
|
|
115
|
+
// Parents
|
|
111
116
|
const calendarButtons = document.querySelectorAll(
|
|
112
117
|
'.will-filter-bar-calendar .rdp-cell:has(.booked):not(:has(.disabled-after-check-in))'
|
|
113
118
|
)
|
|
@@ -117,16 +122,13 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
117
122
|
const calendarMonthContainer = document.querySelector(
|
|
118
123
|
'.will-filter-bar-calendar .rdp-months'
|
|
119
124
|
)
|
|
120
|
-
const calendarOverlappingDate = document.
|
|
125
|
+
const calendarOverlappingDate = document.querySelectorAll(
|
|
121
126
|
'.will-filter-bar-calendar .rdp-cell:has(.overlapping-date)'
|
|
122
127
|
)
|
|
123
|
-
const appendedOverlappingDateTooltip: HTMLElement | null =
|
|
124
|
-
document.querySelector(
|
|
125
|
-
'.will-filter-bar-calendar .rdp-cell .will-calendar-tooltip-overlapping-date'
|
|
126
|
-
)
|
|
127
128
|
|
|
128
129
|
const tooltipClones: Element[] = []
|
|
129
130
|
const tooltipClonesCheckOut: Element[] = []
|
|
131
|
+
const tooltipClonesOverlappingDates: Element[] = []
|
|
130
132
|
|
|
131
133
|
if (calendarTooltip && calendarButtons.length > 0) {
|
|
132
134
|
calendarButtons.forEach((element) => {
|
|
@@ -153,23 +155,23 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
if (
|
|
156
|
-
calendarOverlappingDate &&
|
|
157
158
|
calendarTooltipOverlappingDate &&
|
|
158
|
-
|
|
159
|
-
!calendarRange
|
|
159
|
+
calendarOverlappingDate.length > 0
|
|
160
160
|
) {
|
|
161
|
-
calendarOverlappingDate.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
calendarOverlappingDate.forEach((element) => {
|
|
162
|
+
const tooltipClone: Element =
|
|
163
|
+
calendarTooltipOverlappingDate.cloneNode(true) as Element
|
|
164
|
+
element.appendChild(tooltipClone)
|
|
165
|
+
tooltipClonesOverlappingDates.push(tooltipClone)
|
|
166
|
+
})
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
return () => {
|
|
169
170
|
tooltipClones.forEach((clone) => clone.remove())
|
|
170
171
|
tooltipClonesCheckOut.forEach((clone) => clone.remove())
|
|
172
|
+
tooltipClonesOverlappingDates.forEach((clone) => clone.remove())
|
|
171
173
|
}
|
|
172
|
-
}, [calendarRange, overlappingDate])
|
|
174
|
+
}, [calendarRange, updateCalendar, overlappingDate])
|
|
173
175
|
|
|
174
176
|
return (
|
|
175
177
|
<div className="will-filter-bar-calendar" ref={ref}>
|
|
@@ -193,6 +195,7 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
193
195
|
}
|
|
194
196
|
captionLayout="dropdown-buttons"
|
|
195
197
|
defaultMonth={
|
|
198
|
+
initialCalendarRange?.from ||
|
|
196
199
|
selectedStartDate ||
|
|
197
200
|
(disableCalendarDates?.disabledDates?.length
|
|
198
201
|
? disableCalendarDates.disabledDates[0].from
|
|
@@ -267,7 +270,9 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarTypes>(
|
|
|
267
270
|
<div className={'will-calendar-tooltip-overlapping-date'}>
|
|
268
271
|
<div>{t('checkOutOnly')}</div>
|
|
269
272
|
</div>
|
|
270
|
-
<div className={'will-calendar-spinner'}>
|
|
273
|
+
<div className={'will-calendar-spinner'}>
|
|
274
|
+
<SpinnerSVG fill={palette?.primary || 'inherit'} size={50} />
|
|
275
|
+
</div>
|
|
271
276
|
</div>
|
|
272
277
|
</div>
|
|
273
278
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateRange, Matcher } from 'react-day-picker'
|
|
2
|
+
import { Palette } from 'src/themes/useTheme'
|
|
2
3
|
|
|
3
4
|
export type CalendarOffset = {
|
|
4
5
|
[key: string]: number
|
|
@@ -33,4 +34,5 @@ export type CalendarTypes = {
|
|
|
33
34
|
initialCalendarRange?: DateRange | undefined
|
|
34
35
|
showFeedback?: boolean
|
|
35
36
|
noActiveSelection?: boolean
|
|
37
|
+
palette?: Palette
|
|
36
38
|
}
|