kahuna-base-react-components 1.4.3 → 1.4.4
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/dist/components/KButton/KButton.stories.d.ts +10 -0
- package/dist/components/KCodeInput/KCodeInput.stories.d.ts +7 -0
- package/dist/components/KDropdown/KDropdown.stories.d.ts +9 -0
- package/dist/components/KInput/KInput.stories.d.ts +10 -0
- package/dist/components/KLogo/KLogo.stories.d.ts +6 -0
- package/dist/components/KSelectDate/KSelectDate.stories.d.ts +6 -0
- package/dist/components/KSelectRange/KSelectRange.stories.d.ts +7 -0
- package/dist/components/KSelectRangeDate/KSelectRangeDate.d.ts +1 -0
- package/dist/components/KSelectRangeDate/KSelectRangeDate.stories.d.ts +8 -0
- package/dist/components/KSlider/KSlider.stories.d.ts +5 -0
- package/dist/components/KSliderLabel/KSliderLabel.stories.d.ts +6 -0
- package/dist/components/KSpan/KSpan.stories.d.ts +5 -0
- package/dist/components/KTextArea/KTextArea.stories.d.ts +8 -0
- package/dist/components/KTitleSpan/KTitleSpan.stories.d.ts +6 -0
- package/dist/components/KTooltip/KTooltip.stories.d.ts +6 -0
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/KSelectRangeDate/KSelectRangeDate.stories.tsx +1 -0
- package/src/components/KSelectRangeDate/KSelectRangeDate.tsx +43 -5
package/dist/types.d.ts
CHANGED
|
@@ -348,6 +348,7 @@ interface KSelectRangeDateProps {
|
|
|
348
348
|
hideBackdrop?: boolean;
|
|
349
349
|
weeklyMode?: boolean;
|
|
350
350
|
shorthandEndDateOffsetDays?: number;
|
|
351
|
+
weeklyModeStartDay?: number;
|
|
351
352
|
}
|
|
352
353
|
type DateRangeType = Date | null | [Date | null, Date | null];
|
|
353
354
|
declare const KSelectRangeDate: React.FC<KSelectRangeDateProps>;
|
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ export interface KSelectRangeDateProps {
|
|
|
33
33
|
hideBackdrop?: boolean
|
|
34
34
|
weeklyMode?: boolean
|
|
35
35
|
shorthandEndDateOffsetDays?: number
|
|
36
|
+
weeklyModeStartDay?: number // Day the weekly range should start from (0=Sun...6=Sat); defaults to a rolling 7-day range if unset.
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export type DateRangeType = Date | null | [Date | null, Date | null]
|
|
@@ -125,9 +126,25 @@ const KSelectRangeDate: React.FC<KSelectRangeDateProps> = (props) => {
|
|
|
125
126
|
|
|
126
127
|
if (props.weeklyMode) {
|
|
127
128
|
const DAY = 24 * 60 * 60 * 1000
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
let startDate: Date
|
|
130
|
+
let endDate: Date
|
|
131
|
+
|
|
132
|
+
if (props.weeklyModeStartDay !== undefined) {
|
|
133
|
+
const startDay = props.weeklyModeStartDay
|
|
134
|
+
const dayOfWeek = clickedDate.getDay()
|
|
135
|
+
const daysSinceStart = (dayOfWeek - startDay + 7) % 7
|
|
136
|
+
|
|
137
|
+
startDate = new Date(clickedDate)
|
|
138
|
+
startDate.setDate(clickedDate.getDate() - daysSinceStart)
|
|
139
|
+
startDate.setHours(0, 0, 0, 0)
|
|
140
|
+
|
|
141
|
+
endDate = new Date(startDate)
|
|
142
|
+
endDate.setDate(startDate.getDate() + 6)
|
|
143
|
+
endDate.setHours(0, 0, 0, 0)
|
|
144
|
+
} else {
|
|
145
|
+
endDate = clickedDate
|
|
146
|
+
startDate = new Date(clickedDate.getTime() - 6 * DAY)
|
|
147
|
+
}
|
|
131
148
|
|
|
132
149
|
setRange([startDate, endDate])
|
|
133
150
|
skipNextOpenRef.current = true
|
|
@@ -214,8 +231,29 @@ const KSelectRangeDate: React.FC<KSelectRangeDateProps> = (props) => {
|
|
|
214
231
|
|
|
215
232
|
if (hoveredDate && props.weeklyMode) {
|
|
216
233
|
const DAY = 24 * 60 * 60 * 1000
|
|
217
|
-
|
|
218
|
-
|
|
234
|
+
let start: number
|
|
235
|
+
let end: number
|
|
236
|
+
|
|
237
|
+
if (props.weeklyModeStartDay !== undefined) {
|
|
238
|
+
const startDay = props.weeklyModeStartDay
|
|
239
|
+
const dayOfWeek = hoveredDate.getDay()
|
|
240
|
+
const daysSinceStart = (dayOfWeek - startDay + 7) % 7
|
|
241
|
+
|
|
242
|
+
const startDate = new Date(hoveredDate)
|
|
243
|
+
startDate.setDate(hoveredDate.getDate() - daysSinceStart)
|
|
244
|
+
startDate.setHours(0, 0, 0, 0)
|
|
245
|
+
|
|
246
|
+
const endDate = new Date(startDate)
|
|
247
|
+
endDate.setDate(startDate.getDate() + 6)
|
|
248
|
+
endDate.setHours(0, 0, 0, 0)
|
|
249
|
+
|
|
250
|
+
start = startDate.getTime()
|
|
251
|
+
end = endDate.getTime()
|
|
252
|
+
} else {
|
|
253
|
+
end = hoveredDate.getTime()
|
|
254
|
+
start = end - 6 * DAY
|
|
255
|
+
}
|
|
256
|
+
|
|
219
257
|
const t = date.getTime()
|
|
220
258
|
if (t >= start && t <= end) {
|
|
221
259
|
return "hovered-range-day"
|