kahuna-base-react-components 1.4.2 → 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 +2 -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 +2 -0
- package/package.json +1 -1
- package/src/components/KSelectRangeDate/KSelectRangeDate.stories.tsx +4 -1
- package/src/components/KSelectRangeDate/KSelectRangeDate.tsx +49 -7
package/dist/types.d.ts
CHANGED
|
@@ -347,6 +347,8 @@ interface KSelectRangeDateProps {
|
|
|
347
347
|
popupCalendarBackground?: string;
|
|
348
348
|
hideBackdrop?: boolean;
|
|
349
349
|
weeklyMode?: boolean;
|
|
350
|
+
shorthandEndDateOffsetDays?: number;
|
|
351
|
+
weeklyModeStartDay?: number;
|
|
350
352
|
}
|
|
351
353
|
type DateRangeType = Date | null | [Date | null, Date | null];
|
|
352
354
|
declare const KSelectRangeDate: React.FC<KSelectRangeDateProps>;
|
package/package.json
CHANGED
|
@@ -71,6 +71,7 @@ KSelectRangePrimary.args = {
|
|
|
71
71
|
align: "center",
|
|
72
72
|
hideBackdrop: true,
|
|
73
73
|
anchorToButton: true,
|
|
74
|
+
shorthandEndDateOffsetDays: 5,
|
|
74
75
|
|
|
75
76
|
onChange: (value) => {
|
|
76
77
|
if (value) {
|
|
@@ -93,6 +94,7 @@ KSelectRangeWeekly.args = {
|
|
|
93
94
|
hideBackdrop: true,
|
|
94
95
|
anchorToButton: true,
|
|
95
96
|
weeklyMode: true,
|
|
97
|
+
weeklyModeStartDay: 5,
|
|
96
98
|
|
|
97
99
|
onChange: (value) => {
|
|
98
100
|
if (value) {
|
|
@@ -113,7 +115,8 @@ KSelectRangeDateMinimumDate.args = {
|
|
|
113
115
|
anchorToButton: true,
|
|
114
116
|
position: "top",
|
|
115
117
|
align: "center",
|
|
116
|
-
minimumDate: new Date(new Date().getTime()
|
|
118
|
+
minimumDate: new Date(new Date().getTime() - 2 * 24 * 60 * 60 * 1000),
|
|
119
|
+
maximumDate: new Date(new Date().getTime() - 2 * 24 * 60 * 60 * 1000),
|
|
117
120
|
|
|
118
121
|
onChange: (value) => {
|
|
119
122
|
if (value) {
|
|
@@ -32,6 +32,8 @@ export interface KSelectRangeDateProps {
|
|
|
32
32
|
popupCalendarBackground?: string
|
|
33
33
|
hideBackdrop?: boolean
|
|
34
34
|
weeklyMode?: boolean
|
|
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.
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export type DateRangeType = Date | null | [Date | null, Date | null]
|
|
@@ -111,8 +113,11 @@ const KSelectRangeDate: React.FC<KSelectRangeDateProps> = (props) => {
|
|
|
111
113
|
const month = theDate.getMonth()
|
|
112
114
|
const day = theDate.getDate()
|
|
113
115
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
+
const delta = props.shorthandEndDateOffsetDays ?? 0
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const endDate = new Date(year, month, day - delta)
|
|
120
|
+
const startDate = new Date(year, month, day - delta - (range - 1))
|
|
116
121
|
setRange([startDate, endDate])
|
|
117
122
|
}
|
|
118
123
|
|
|
@@ -121,9 +126,25 @@ const KSelectRangeDate: React.FC<KSelectRangeDateProps> = (props) => {
|
|
|
121
126
|
|
|
122
127
|
if (props.weeklyMode) {
|
|
123
128
|
const DAY = 24 * 60 * 60 * 1000
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
}
|
|
127
148
|
|
|
128
149
|
setRange([startDate, endDate])
|
|
129
150
|
skipNextOpenRef.current = true
|
|
@@ -210,8 +231,29 @@ const KSelectRangeDate: React.FC<KSelectRangeDateProps> = (props) => {
|
|
|
210
231
|
|
|
211
232
|
if (hoveredDate && props.weeklyMode) {
|
|
212
233
|
const DAY = 24 * 60 * 60 * 1000
|
|
213
|
-
|
|
214
|
-
|
|
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
|
+
|
|
215
257
|
const t = date.getTime()
|
|
216
258
|
if (t >= start && t <= end) {
|
|
217
259
|
return "hovered-range-day"
|