gbs-add-block 0.0.74 → 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
|
@@ -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
|
-
<
|
|
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
|
|
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
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|