gbs-add-block 0.0.73 → 0.0.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "description": "React Component Library",
5
5
  "type": "module",
6
6
  "files": [
@@ -11,7 +11,7 @@
11
11
  "node": ">=17"
12
12
  },
13
13
  "bin": {
14
- "gbs-add-block": "./index.cjs"
14
+ "gbs-add-block": "index.cjs"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -15,7 +15,7 @@ import {
15
15
  applyScrollbarStyles,
16
16
  } from "@grampro/headless-helpers";
17
17
  import Icon from "../icon/Icon";
18
- import { calender, down, leftArrows, rightArrows } from "../icon/iconPaths";
18
+ import { calender, down, leftArrows, rightArrows, x } from "../icon/iconPaths";
19
19
  import type { DatePickerProps } from "./types";
20
20
  import { iconClass, popUp, primary } from "../globalStyle";
21
21
 
@@ -52,6 +52,7 @@ export const DatePicker = ({
52
52
  tempSelectedDate,
53
53
  setTempSelectedDate,
54
54
  hasMounted,
55
+ clearSelected,
55
56
  } = useDatePickerState(selectedDateValue || null);
56
57
 
57
58
  const { prevMonth, nextMonth } = useYearMonthNavigation(
@@ -119,29 +120,45 @@ export const DatePicker = ({
119
120
  return null;
120
121
  }
121
122
 
123
+ const clearSelectedHandler = () => {
124
+ clearSelected();
125
+ if( onDateChange) onDateChange(null);
126
+ };
127
+
122
128
  return (
123
129
  <div className="relative inline-block w-full" ref={dateRef}>
124
- <button
125
- type="button"
126
- onClick={toggleDatepicker}
130
+ <div
127
131
  className={`${
128
- error ? primary["error-border"] : "border"
129
- } p-2 rounded-lg w-full flex items-center gap-2 dark:text-white dark:bg-black ${
132
+ error ? primary["error-border"] : "border border-gray-300"
133
+ } p-2 rounded-lg w-full flex items-center justify-between gap-2 ${
130
134
  disabled ? "opacity-50 cursor-not-allowed" : ""
131
135
  }`}
132
- disabled={disabled}
133
136
  >
134
- <Icon
135
- dimensions={{ width: "20", height: "20" }}
136
- elements={calender}
137
- svgClass={iconClass["grey-common"]}
138
- />
139
- <span className={!selectedDate ? "text-gray-400" : ""}>
140
- {selectedDate
141
- ? selectedDate.toLocaleDateString("en-GB")
142
- : placeholder}
143
- </span>
144
- </button>
137
+ <button
138
+ type="button"
139
+ onClick={toggleDatepicker}
140
+ disabled={disabled}
141
+ className="flex items-center gap-2 w-full"
142
+ >
143
+ <Icon
144
+ dimensions={{ width: "20", height: "20" }}
145
+ elements={calender}
146
+ svgClass={iconClass["grey-common"]}
147
+ />
148
+ <span className={!selectedDate ? "text-gray-400 text-sm" : ""}>
149
+ {selectedDate
150
+ ? selectedDate.toLocaleDateString("en-GB")
151
+ : placeholder}
152
+ </span>
153
+ </button>
154
+
155
+ {selectedDate && !disabled && (
156
+ <button onClick={clearSelectedHandler} type="button">
157
+ <Icon elements={x} svgClass={iconClass["grey-common"]} />
158
+ </button>
159
+ )}
160
+ </div>
161
+
145
162
  {error && <p className={primary["error-primary"]}>{error}</p>}
146
163
 
147
164
  <input
@@ -5,7 +5,7 @@ export type DatePickerProps = {
5
5
  maxDate?: Date | null;
6
6
  yearLimitStart?: number;
7
7
  yearLimitEnd?: number;
8
- onDateChange?: (date: Date) => void;
8
+ onDateChange?: (date: Date | null) => void;
9
9
  name?: string;
10
10
  error?: string;
11
11
  disabled?: boolean;