diff --git a/pages/index.js b/pages/index.js
index 5ce6034e..d889dda7 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -31,6 +31,7 @@ export default function Playground() {
const [newDisabledDates, setNewDisabledDates] = useState({ startDate: "", endDate: "" });
const [startFrom, setStartFrom] = useState("2023-03-01");
const [startWeekOn, setStartWeekOn] = useState("");
+ const [inline, setInline] = useState(false);
const handleChange = (value, e) => {
setValue(value);
@@ -113,6 +114,7 @@ export default function Playground() {
return isEmpty ? "Select Date" : "Clear";
}}
popoverDirection={"down"}
+ inline={inline}
// classNames={{
// input: ({ disabled, readOnly, className }) => {
// if (disabled) {
@@ -215,6 +217,20 @@ export default function Playground() {
+
+
+ setInline(e.target.checked)}
+ />
+
+
+
diff --git a/src/components/Calendar/Week.tsx b/src/components/Calendar/Week.tsx
index 45e957c2..12f4de38 100644
--- a/src/components/Calendar/Week.tsx
+++ b/src/components/Calendar/Week.tsx
@@ -33,7 +33,7 @@ const Week: React.FC = () => {
}, [startWeekOn]);
return (
-
+
{DAYS.map(item => (
{ucFirst(
diff --git a/src/components/Calendar/index.tsx b/src/components/Calendar/index.tsx
index 4a374375..7e26e2ef 100644
--- a/src/components/Calendar/index.tsx
+++ b/src/components/Calendar/index.tsx
@@ -243,7 +243,7 @@ const Calendar: React.FC
= ({
return (
-
+
{!showMonths && !showYears && (
diff --git a/src/components/Datepicker.tsx b/src/components/Datepicker.tsx
index 54e90b78..553e8149 100644
--- a/src/components/Datepicker.tsx
+++ b/src/components/Datepicker.tsx
@@ -7,13 +7,13 @@ import Input from "../components/Input";
import Shortcuts from "../components/Shortcuts";
import { COLORS, DATE_FORMAT, DEFAULT_COLOR, LANGUAGE } from "../constants";
import DatepickerContext from "../contexts/DatepickerContext";
-import { formatDate, nextMonth, previousMonth } from "../helpers";
+import { formatDate, nextMonth, previousMonth, classNames as classNamesUtil } from "../helpers";
import useOnClickOutside from "../hooks";
import { Period, DatepickerType, ColorKeys } from "../types";
import { Arrow, VerticalDash } from "./utils";
-const Datepicker: React.FC = ({
+const Datepicker = ({
primaryColor = "blue",
value = null,
onChange,
@@ -22,13 +22,14 @@ const Datepicker: React.FC = ({
showShortcuts = false,
configs = undefined,
asSingle = false,
- placeholder = null,
+ placeholder = undefined,
separator = "~",
startFrom = null,
i18n = LANGUAGE,
disabled = false,
inputClassName = null,
containerClassName = null,
+ pickerClassName = null,
toggleClassName = null,
toggleIcon = undefined,
displayFormat = DATE_FORMAT,
@@ -41,8 +42,9 @@ const Datepicker: React.FC = ({
inputName,
startWeekOn = "sun",
classNames = undefined,
- popoverDirection = undefined
-}) => {
+ popoverDirection = undefined,
+ inline = false
+}: DatepickerType) => {
// Ref
const containerRef = useRef(null);
const calendarContainerRef = useRef(null);
@@ -64,7 +66,7 @@ const Datepicker: React.FC = ({
// Custom Hooks use
useOnClickOutside(containerRef, () => {
const container = containerRef.current;
- if (container) {
+ if (container && !inline) {
hideDatepicker();
}
});
@@ -327,18 +329,33 @@ const Datepicker: React.FC = ({
: defaultContainerClassName;
}, [containerClassName]);
+ const pickerClassNameOverload = useMemo(() => {
+ const defaultPickerClassName = classNamesUtil(
+ "shadow-sm border border-zinc-300 px-1 py-0.5 bg-white dark:bg-slate-800 dark:text-white dark:border-slate-600 rounded-lg w-fit",
+ !inline && "mt-2.5"
+ );
+ return typeof pickerClassName === "function"
+ ? pickerClassName(defaultPickerClassName)
+ : typeof pickerClassName === "string" && pickerClassName !== ""
+ ? pickerClassName
+ : defaultPickerClassName;
+ }, [pickerClassName, inline]);
+
return (
-
+ {!inline &&
}
-
+ {!inline &&
}
-
+
{showShortcuts &&
}
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index 40f8fd2b..34125443 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -17,7 +17,7 @@ const Footer: React.FC = () => {
return classNames.footer();
}
- return "flex items-center justify-end pb-2.5 pt-3 border-t border-gray-300 dark:border-gray-700";
+ return "flex items-center justify-end pb-2.5 pt-3 border-t border-zinc-300 dark:border-zinc-700";
}, [classNames]);
return (
diff --git a/src/components/Input.tsx b/src/components/Input.tsx
index 38fc856e..7f469481 100644
--- a/src/components/Input.tsx
+++ b/src/components/Input.tsx
@@ -55,7 +55,7 @@ const Input: React.FC
= (e: Props) => {
const ring =
RING_COLOR["second-focus"][primaryColor as keyof (typeof RING_COLOR)["second-focus"]];
- const defaultInputClassName = `relative transition-all duration-300 py-2.5 pl-4 pr-14 w-full border-gray-300 dark:bg-slate-800 dark:text-white/80 dark:border-slate-600 rounded-lg tracking-wide font-light text-sm placeholder-gray-400 bg-white focus:ring disabled:opacity-40 disabled:cursor-not-allowed ${border} ${ring}`;
+ const defaultInputClassName = `relative transition-all duration-300 py-2.5 pl-4 pr-14 w-full border-zinc-300 dark:bg-slate-800 dark:text-white/80 dark:border-slate-600 rounded-lg tracking-wide font-light text-sm placeholder-gray-400 bg-white focus:ring disabled:opacity-40 disabled:cursor-not-allowed ${border} ${ring}`;
return typeof inputClassName === "function"
? inputClassName(defaultInputClassName)
diff --git a/src/components/Shortcuts.tsx b/src/components/Shortcuts.tsx
index ae54b21c..8f18c2bf 100644
--- a/src/components/Shortcuts.tsx
+++ b/src/components/Shortcuts.tsx
@@ -132,7 +132,7 @@ const Shortcuts: React.FC = () => {
}, []);
return shortcutOptions?.length ? (
-
+
{shortcutOptions.map(([key, item], index: number) =>
Array.isArray(item) ? (
diff --git a/src/components/utils.tsx b/src/components/utils.tsx
index 6bdb31a7..4b87f2bb 100644
--- a/src/components/utils.tsx
+++ b/src/components/utils.tsx
@@ -123,7 +123,7 @@ export const Arrow = React.forwardRef((props, ref) => {
return (
);
});
@@ -135,7 +135,7 @@ export const SecondaryButton: React.FC