kahuna-base-react-components 1.2.5 → 1.2.7

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/types.d.ts CHANGED
@@ -160,6 +160,7 @@ interface KDropdownProps {
160
160
  label?: string;
161
161
  textColor?: string;
162
162
  shadowDisabled?: boolean;
163
+ closeMenuOnSelect?: boolean;
163
164
  menuBackground?: string;
164
165
  padding?: string;
165
166
  gap?: string;
@@ -209,6 +210,7 @@ interface KSelectDateProps {
209
210
  anchorToButton?: boolean;
210
211
  position?: "top" | "bottom" | "left" | "right";
211
212
  align?: "top" | "bottom" | "left" | "right" | "center";
213
+ hideBackdrop?: boolean;
212
214
  }
213
215
  declare const KSelectDate: React.FC<KSelectDateProps>;
214
216
 
@@ -298,6 +300,7 @@ interface KSelectRangeProps {
298
300
  minimumDate?: Date;
299
301
  maximumDate?: Date;
300
302
  popupCalendarBackground?: string;
303
+ hideBackdrop?: boolean;
301
304
  }
302
305
  type DateRangeType = Date | null | [Date | null, Date | null];
303
306
  declare const KSelectRange: React.FC<KSelectRangeProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kahuna-base-react-components",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Kahuna Base React Components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -36,6 +36,7 @@ export interface KDropdownProps {
36
36
  label?: string
37
37
  textColor?: string
38
38
  shadowDisabled?: boolean
39
+ closeMenuOnSelect?: boolean
39
40
  menuBackground?: string
40
41
  padding?: string
41
42
  gap?: string
@@ -93,6 +94,10 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
93
94
  const placeholderColor = props.placeholderColor || "#848484"
94
95
  const enableIndicator = props.enableIndicator || false
95
96
  const allowContainerShrink = props.allowContainerShrink || false
97
+ let closeMenuOnSelect = true
98
+ if (props.closeMenuOnSelect === false) {
99
+ closeMenuOnSelect = false
100
+ }
96
101
 
97
102
  let defaultValue = props.defaultValue
98
103
  if (!defaultValue && props.defaultValuePrimitive) {
@@ -225,6 +230,7 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
225
230
  defaultValue={defaultValue}
226
231
  isMulti={isMulti}
227
232
  name={props.label || ""}
233
+ closeMenuOnSelect={closeMenuOnSelect}
228
234
  placeholder={props.placeholder || ""}
229
235
  options={props.options}
230
236
  className={"k-dropdown"}
@@ -3,6 +3,7 @@ import KSelectDate, { KSelectDateProps } from "./KSelectDate"
3
3
  import { useEffect, useState } from "react"
4
4
  //@ts-ignore
5
5
  import CalendarNewIcon from "../../assets/calendar-new.svg"
6
+ import KSpan from "../KSpan"
6
7
 
7
8
  export default {
8
9
  title: "ReactComponentLibrary/KSelectDate",
@@ -13,28 +14,52 @@ export default {
13
14
  } as Meta<typeof KSelectDate>
14
15
 
15
16
  const KSelectDateWrapper: React.FC<KSelectDateProps> = (args) => {
16
-
17
17
  const [selectedDate, setSelectedDate] = useState<Date | undefined>(undefined)
18
18
  useEffect(() => {
19
19
  // console.log("selectedDate: ", selectedDate)
20
20
  }, [selectedDate])
21
21
 
22
22
  return (
23
- <KSelectDate
24
- {...args}
25
- value={selectedDate}
26
- onChange={(date) => {
27
- // console.log("date: ", date)
28
- if (date) {
29
- setSelectedDate(date)
30
- console.log("updating is completed: ", date)
31
- // console.log("updating is completed date.toISOString(): ", date?.toISOString())
32
- } else {
33
- setSelectedDate(undefined)
34
- // console.log("Deleting is completed")
35
- }
36
- }}
37
- />
23
+ <div className=" flex flex-row gap-4 items-center">
24
+ <div className="flex flex-row items-center justify-center w-auto h-40 z-10">
25
+ <KSpan text="Lorem Ipsum is simply dummy text of the printing and typesetting industry." />
26
+ </div>
27
+ <div className="flex flex-col relative">
28
+ <KSelectDate
29
+ {...args}
30
+ value={selectedDate}
31
+ onChange={(date) => {
32
+ // console.log("date: ", date)
33
+ if (date) {
34
+ setSelectedDate(date)
35
+ console.log("updating is completed: ", date)
36
+ // console.log("updating is completed date.toISOString(): ", date?.toISOString())
37
+ } else {
38
+ setSelectedDate(undefined)
39
+ // console.log("Deleting is completed")
40
+ }
41
+ }}
42
+ anchorToButton
43
+ />
44
+ <KSelectDate
45
+ {...args}
46
+ value={selectedDate}
47
+ onChange={(date) => {
48
+ // console.log("date: ", date)
49
+ if (date) {
50
+ setSelectedDate(date)
51
+ console.log("updating is completed: ", date)
52
+ // console.log("updating is completed date.toISOString(): ", date?.toISOString())
53
+ } else {
54
+ setSelectedDate(undefined)
55
+ // console.log("Deleting is completed")
56
+ }
57
+ }}
58
+ anchorToButton
59
+ />
60
+ </div>
61
+ <div></div>
62
+ </div>
38
63
  )
39
64
  }
40
65
 
@@ -34,11 +34,12 @@ export interface KSelectDateProps {
34
34
  anchorToButton?: boolean // opens the calendar relative to the button's position, does not have any effect if body is not hidden.
35
35
  position?: "top" | "bottom" | "left" | "right" // position of the calendar relative to the button's position, has effect as long as anchorButton is true
36
36
  align?: "top" | "bottom" | "left" | "right" | "center" // lets to align the calendar, has effect as long as anchorButton is true
37
+ hideBackdrop?: boolean
37
38
  }
38
39
  interface MonthSelectorType {
39
40
  monthName: string
40
41
  year: string
41
- date: Date,
42
+ date: Date
42
43
  monthIndex: string | number
43
44
  }
44
45
  interface DaySelectorType {
@@ -75,6 +76,8 @@ const KSelectDate: React.FC<KSelectDateProps> = (props) => {
75
76
  const position = props.position || "bottom"
76
77
  const align = props.align || "center"
77
78
 
79
+ const hideBackdrop = props.hideBackdrop || false
80
+
78
81
  const formatShortWeekday = (locale: string | undefined, date: Date): string => {
79
82
  return date.toLocaleDateString(locale, { weekday: "short" }).charAt(0) // Return only the first letter of the weekday
80
83
  }
@@ -182,7 +185,7 @@ const KSelectDate: React.FC<KSelectDateProps> = (props) => {
182
185
  )
183
186
  }
184
187
 
185
- const monthSelector = (month: string, year: string, date: Date, monthIndex:string | number) => {
188
+ const monthSelector = (month: string, year: string, date: Date, monthIndex: string | number) => {
186
189
  const monthText: MonthTextType = lang.common.months_short
187
190
 
188
191
  const text = `${monthText[monthIndex]}, ${year}`
@@ -309,6 +312,9 @@ const KSelectDate: React.FC<KSelectDateProps> = (props) => {
309
312
 
310
313
  return (
311
314
  <React.Fragment>
315
+ {openCalendar && !hideBackdrop && (
316
+ <div className="w-[100vw] h-[100vh] fixed left-0 top-0 z-[49] bg-[#0000004d]"/>
317
+ )}
312
318
  {openCalendar && (!hideBody || !anchorToButton) && (
313
319
  <div className="w-[100vw] h-[100vh] fixed left-0 top-0 flex items-center justify-center z-50">
314
320
  <div>{renderPopUpCalendar()}</div>
@@ -373,7 +379,7 @@ const KSelectDate: React.FC<KSelectDateProps> = (props) => {
373
379
  ) : (
374
380
  <div className="flex relative">
375
381
  {openCalendar && anchorToButton && (
376
- <div className={`absolute ${absolutePositionClassName(position, align)}`}>
382
+ <div className={`absolute ${absolutePositionClassName(position, align)} z-[51]`}>
377
383
  <div>{renderPopUpCalendar()}</div>
378
384
  </div>
379
385
  )}
@@ -50,7 +50,25 @@ const KSelectRangeWrapper: React.FC<KSelectRangeProps> = (args) => {
50
50
  // console.log("Deleting is completed")
51
51
  }
52
52
  }}
53
- /></div>
53
+ />
54
+ <div className="relative z-10">
55
+ <KSelectRange
56
+ {...args}
57
+ value={selectedDate}
58
+ onChange={(date: DateRangeType) => {
59
+ // console.log("date: ", date)
60
+ if (date) {
61
+ setSelectedDate(date)
62
+ console.log("updating is completed: ", date)
63
+ // console.log("updating is completed date.toISOString(): ", date?.toISOString())
64
+ } else {
65
+ setSelectedDate(null)
66
+ // console.log("Deleting is completed")
67
+ }
68
+ }}
69
+ />
70
+ </div>
71
+ </div>
54
72
  )
55
73
  }
56
74
 
@@ -63,10 +81,10 @@ KSelectRangePrimary.args = {
63
81
  backgroundColor: "#F7F7F7",
64
82
  hoverBackgroundColor: "#F3F3F3",
65
83
  borderRadius: 24,
66
- anchorToButton:true,
67
84
  position: "top",
68
85
  align: "center",
69
-
86
+ hideBackdrop: true,
87
+ anchorToButton: true,
70
88
  onChange: (value) => {
71
89
  if (value) {
72
90
  console.log("value is updated using this value:", value)
@@ -30,6 +30,7 @@ export interface KSelectRangeProps {
30
30
  minimumDate?: Date
31
31
  maximumDate?: Date
32
32
  popupCalendarBackground?: string
33
+ hideBackdrop?: boolean
33
34
  }
34
35
 
35
36
  export type DateRangeType = Date | null | [Date | null, Date | null]
@@ -47,6 +48,7 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
47
48
  const anchorToButton = props.anchorToButton || false
48
49
  const position = props.position || "bottom"
49
50
  const align = props.align || "center"
51
+ const hideBackdrop = props.hideBackdrop || false
50
52
 
51
53
  const [value, setValue] = useState<DateRangeType>(props.value)
52
54
  const [range, setRange] = useState<DateRangeType>(props.value)
@@ -59,6 +61,8 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
59
61
  approved: -1
60
62
  })
61
63
 
64
+ const [openBackdrop, setOpenBackdrop] = useState<boolean>(false)
65
+
62
66
  const convertToMonthYear = (date: Date | null): string => {
63
67
  if (!date) return "?"
64
68
 
@@ -351,6 +355,7 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
351
355
  onClick={() => {
352
356
  setRange(value)
353
357
  setOpenCalendar(false)
358
+ setOpenBackdrop(false)
354
359
  const approvedIndex = shorthandIndex.approved
355
360
  setShorthandIndex({ ...shorthandIndex, current: approvedIndex })
356
361
  if (Array.isArray(value) && value[0] !== null) {
@@ -368,6 +373,7 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
368
373
  onClick={() => {
369
374
  setValue(range)
370
375
  setOpenCalendar(false)
376
+ setOpenBackdrop(false)
371
377
  const currentIndex = shorthandIndex.current
372
378
  setShorthandIndex({ ...shorthandIndex, approved: currentIndex })
373
379
  if (Array.isArray(range) && range[0] !== null) {
@@ -395,6 +401,9 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
395
401
 
396
402
  return (
397
403
  <React.Fragment>
404
+ {openBackdrop && !hideBackdrop && (
405
+ <div className="w-[100vw] h-[100vh] fixed left-0 top-0 z-[49] bg-[#0000004d]"/>
406
+ )}
398
407
  {openCalendar && !anchorToButton && (
399
408
  <div
400
409
  className="w-[100vw] h-[100vh] fixed left-0 top-0 flex items-center justify-center z-50"
@@ -405,7 +414,7 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
405
414
  )}
406
415
  <div className="flex relative">
407
416
  {openCalendar && anchorToButton && (
408
- <div className={`absolute ${absolutePositionClassName(position, align)}`}>
417
+ <div className={`absolute ${absolutePositionClassName(position, align)} z-[51]`}>
409
418
  <div>{renderPopUpCalendar()}</div>
410
419
  </div>
411
420
  )}
@@ -422,9 +431,11 @@ const KSelectRange: React.FC<KSelectRangeProps> = (props) => {
422
431
  onClick={() => {
423
432
  if (!openCalendar) {
424
433
  setOpenCalendar(true)
434
+ setOpenBackdrop(true)
425
435
  } else {
426
436
  setRange(value)
427
437
  setOpenCalendar(false)
438
+ setOpenBackdrop(false)
428
439
  const approvedIndex = shorthandIndex.approved
429
440
  setShorthandIndex({ ...shorthandIndex, current: approvedIndex })
430
441
  if (Array.isArray(value) && value[0] !== null) {