@neoptocom/neopto-ui 1.6.0 → 1.6.3
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/index.cjs +31 -41
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +31 -41
- package/package.json +1 -1
- package/src/components/Autocomplete.tsx +1 -1
- package/src/components/Calendar.tsx +33 -38
- package/src/components/DateInput.tsx +8 -1
- package/src/stories/DateInput.stories.tsx +9 -9
package/dist/index.cjs
CHANGED
|
@@ -897,7 +897,7 @@ function Autocomplete({
|
|
|
897
897
|
onClick: selectedOption && !open ? handleClear : () => setOpen((s) => !s),
|
|
898
898
|
disabled,
|
|
899
899
|
"aria-label": selectedOption && !open ? "Clear" : open ? "Collapse" : "Expand",
|
|
900
|
-
className: "absolute right-
|
|
900
|
+
className: "absolute right-1 top-[-20%]",
|
|
901
901
|
iconClassName: [
|
|
902
902
|
"transition-transform duration-300 text-[var(--muted-fg)]",
|
|
903
903
|
open ? "rotate-180 text-[var(--color-brand)]" : ""
|
|
@@ -1549,21 +1549,8 @@ var Breadcrumb = ({
|
|
|
1549
1549
|
] }, index);
|
|
1550
1550
|
}) }) });
|
|
1551
1551
|
};
|
|
1552
|
-
var DAYS_OF_WEEK = ["
|
|
1553
|
-
var MONTHS = [
|
|
1554
|
-
"January",
|
|
1555
|
-
"February",
|
|
1556
|
-
"March",
|
|
1557
|
-
"April",
|
|
1558
|
-
"May",
|
|
1559
|
-
"June",
|
|
1560
|
-
"July",
|
|
1561
|
-
"August",
|
|
1562
|
-
"September",
|
|
1563
|
-
"October",
|
|
1564
|
-
"November",
|
|
1565
|
-
"December"
|
|
1566
|
-
];
|
|
1552
|
+
var DAYS_OF_WEEK = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "S\xE1b"];
|
|
1553
|
+
var MONTHS = ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"];
|
|
1567
1554
|
function isSameDay(date1, date2) {
|
|
1568
1555
|
return date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
|
|
1569
1556
|
}
|
|
@@ -1640,31 +1627,32 @@ function Calendar({
|
|
|
1640
1627
|
}
|
|
1641
1628
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
1642
1629
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-4", children: [
|
|
1643
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1644
|
-
"
|
|
1645
|
-
{
|
|
1646
|
-
type: "button",
|
|
1647
|
-
onClick: prevMonth,
|
|
1648
|
-
className: "p-2 rounded-full hover:bg-[var(--muted)] transition-colors",
|
|
1649
|
-
"aria-label": "Previous month",
|
|
1650
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "material-symbols-rounded text-[var(--fg)]", children: "chevron_left" })
|
|
1651
|
-
}
|
|
1652
|
-
),
|
|
1653
|
-
/* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-sm font-medium text-[var(--fg)]", children: [
|
|
1654
|
-
MONTHS[currentMonth.getMonth()],
|
|
1655
|
-
" ",
|
|
1656
|
-
currentMonth.getFullYear()
|
|
1630
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1631
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typo, { variant: "title-md", bold: "medium", className: "text-[var(--fg)]", children: MONTHS[currentMonth.getMonth()] }),
|
|
1632
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typo, { variant: "title-md", bold: "medium", className: "text-cyan-500", children: currentMonth.getFullYear() })
|
|
1657
1633
|
] }),
|
|
1658
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1634
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1635
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1636
|
+
"button",
|
|
1637
|
+
{
|
|
1638
|
+
type: "button",
|
|
1639
|
+
onClick: prevMonth,
|
|
1640
|
+
className: "p-2 rounded-full hover:bg-[var(--muted)] transition-colors",
|
|
1641
|
+
"aria-label": "Previous month",
|
|
1642
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "material-symbols-rounded text-[var(--fg)]", children: "chevron_left" })
|
|
1643
|
+
}
|
|
1644
|
+
),
|
|
1645
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1646
|
+
"button",
|
|
1647
|
+
{
|
|
1648
|
+
type: "button",
|
|
1649
|
+
onClick: nextMonth,
|
|
1650
|
+
className: "p-2 rounded-full hover:bg-[var(--muted)] transition-colors",
|
|
1651
|
+
"aria-label": "Next month",
|
|
1652
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "material-symbols-rounded text-[var(--fg)]", children: "chevron_right" })
|
|
1653
|
+
}
|
|
1654
|
+
)
|
|
1655
|
+
] })
|
|
1668
1656
|
] }),
|
|
1669
1657
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 gap-1 mb-2", children: DAYS_OF_WEEK.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1670
1658
|
"div",
|
|
@@ -1745,6 +1733,8 @@ var DateInput = React11__namespace.forwardRef(
|
|
|
1745
1733
|
maxDate,
|
|
1746
1734
|
placeholder = "00/00/0000",
|
|
1747
1735
|
className = "",
|
|
1736
|
+
lightBackgroundImage,
|
|
1737
|
+
darkBackgroundImage,
|
|
1748
1738
|
...props
|
|
1749
1739
|
}, ref) => {
|
|
1750
1740
|
const [inputValue, setInputValue] = React11__namespace.useState(
|
|
@@ -1834,7 +1824,7 @@ var DateInput = React11__namespace.forwardRef(
|
|
|
1834
1824
|
...props
|
|
1835
1825
|
}
|
|
1836
1826
|
),
|
|
1837
|
-
showCalendar && !disabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute z-20 mt-2 w-full max-w-sm", children: /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "p-4", showDecorations: false, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1827
|
+
showCalendar && !disabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute z-20 mt-2 w-full max-w-sm", children: /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "p-4", showDecorations: false, lightImage: lightBackgroundImage, darkImage: darkBackgroundImage, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1838
1828
|
Calendar,
|
|
1839
1829
|
{
|
|
1840
1830
|
selectedDate: inputValue !== placeholder && parseDate(inputValue) && isValidDate(parseDate(inputValue)) ? parseDate(inputValue) : /* @__PURE__ */ new Date(),
|
package/dist/index.d.cts
CHANGED
|
@@ -407,6 +407,10 @@ type DateInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value"
|
|
|
407
407
|
maxDate?: Date;
|
|
408
408
|
/** Placeholder text (default: "00/00/0000") */
|
|
409
409
|
placeholder?: string;
|
|
410
|
+
/** Background image URL for light mode */
|
|
411
|
+
lightBackgroundImage?: string;
|
|
412
|
+
/** Background image URL for dark mode */
|
|
413
|
+
darkBackgroundImage?: string;
|
|
410
414
|
};
|
|
411
415
|
declare const DateInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "type" | "value"> & {
|
|
412
416
|
/** Label text displayed above the input */
|
|
@@ -423,6 +427,10 @@ declare const DateInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAtt
|
|
|
423
427
|
maxDate?: Date;
|
|
424
428
|
/** Placeholder text (default: "00/00/0000") */
|
|
425
429
|
placeholder?: string;
|
|
430
|
+
/** Background image URL for light mode */
|
|
431
|
+
lightBackgroundImage?: string;
|
|
432
|
+
/** Background image URL for dark mode */
|
|
433
|
+
darkBackgroundImage?: string;
|
|
426
434
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
427
435
|
|
|
428
436
|
type CalendarProps = {
|
package/dist/index.d.ts
CHANGED
|
@@ -407,6 +407,10 @@ type DateInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value"
|
|
|
407
407
|
maxDate?: Date;
|
|
408
408
|
/** Placeholder text (default: "00/00/0000") */
|
|
409
409
|
placeholder?: string;
|
|
410
|
+
/** Background image URL for light mode */
|
|
411
|
+
lightBackgroundImage?: string;
|
|
412
|
+
/** Background image URL for dark mode */
|
|
413
|
+
darkBackgroundImage?: string;
|
|
410
414
|
};
|
|
411
415
|
declare const DateInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "type" | "value"> & {
|
|
412
416
|
/** Label text displayed above the input */
|
|
@@ -423,6 +427,10 @@ declare const DateInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAtt
|
|
|
423
427
|
maxDate?: Date;
|
|
424
428
|
/** Placeholder text (default: "00/00/0000") */
|
|
425
429
|
placeholder?: string;
|
|
430
|
+
/** Background image URL for light mode */
|
|
431
|
+
lightBackgroundImage?: string;
|
|
432
|
+
/** Background image URL for dark mode */
|
|
433
|
+
darkBackgroundImage?: string;
|
|
426
434
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
427
435
|
|
|
428
436
|
type CalendarProps = {
|
package/dist/index.js
CHANGED
|
@@ -876,7 +876,7 @@ function Autocomplete({
|
|
|
876
876
|
onClick: selectedOption && !open ? handleClear : () => setOpen((s) => !s),
|
|
877
877
|
disabled,
|
|
878
878
|
"aria-label": selectedOption && !open ? "Clear" : open ? "Collapse" : "Expand",
|
|
879
|
-
className: "absolute right-
|
|
879
|
+
className: "absolute right-1 top-[-20%]",
|
|
880
880
|
iconClassName: [
|
|
881
881
|
"transition-transform duration-300 text-[var(--muted-fg)]",
|
|
882
882
|
open ? "rotate-180 text-[var(--color-brand)]" : ""
|
|
@@ -1528,21 +1528,8 @@ var Breadcrumb = ({
|
|
|
1528
1528
|
] }, index);
|
|
1529
1529
|
}) }) });
|
|
1530
1530
|
};
|
|
1531
|
-
var DAYS_OF_WEEK = ["
|
|
1532
|
-
var MONTHS = [
|
|
1533
|
-
"January",
|
|
1534
|
-
"February",
|
|
1535
|
-
"March",
|
|
1536
|
-
"April",
|
|
1537
|
-
"May",
|
|
1538
|
-
"June",
|
|
1539
|
-
"July",
|
|
1540
|
-
"August",
|
|
1541
|
-
"September",
|
|
1542
|
-
"October",
|
|
1543
|
-
"November",
|
|
1544
|
-
"December"
|
|
1545
|
-
];
|
|
1531
|
+
var DAYS_OF_WEEK = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "S\xE1b"];
|
|
1532
|
+
var MONTHS = ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"];
|
|
1546
1533
|
function isSameDay(date1, date2) {
|
|
1547
1534
|
return date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
|
|
1548
1535
|
}
|
|
@@ -1619,31 +1606,32 @@ function Calendar({
|
|
|
1619
1606
|
}
|
|
1620
1607
|
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
1621
1608
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4", children: [
|
|
1622
|
-
/* @__PURE__ */
|
|
1623
|
-
"
|
|
1624
|
-
{
|
|
1625
|
-
type: "button",
|
|
1626
|
-
onClick: prevMonth,
|
|
1627
|
-
className: "p-2 rounded-full hover:bg-[var(--muted)] transition-colors",
|
|
1628
|
-
"aria-label": "Previous month",
|
|
1629
|
-
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded text-[var(--fg)]", children: "chevron_left" })
|
|
1630
|
-
}
|
|
1631
|
-
),
|
|
1632
|
-
/* @__PURE__ */ jsxs("h3", { className: "text-sm font-medium text-[var(--fg)]", children: [
|
|
1633
|
-
MONTHS[currentMonth.getMonth()],
|
|
1634
|
-
" ",
|
|
1635
|
-
currentMonth.getFullYear()
|
|
1609
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1610
|
+
/* @__PURE__ */ jsx(Typo, { variant: "title-md", bold: "medium", className: "text-[var(--fg)]", children: MONTHS[currentMonth.getMonth()] }),
|
|
1611
|
+
/* @__PURE__ */ jsx(Typo, { variant: "title-md", bold: "medium", className: "text-cyan-500", children: currentMonth.getFullYear() })
|
|
1636
1612
|
] }),
|
|
1637
|
-
/* @__PURE__ */
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1613
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1614
|
+
/* @__PURE__ */ jsx(
|
|
1615
|
+
"button",
|
|
1616
|
+
{
|
|
1617
|
+
type: "button",
|
|
1618
|
+
onClick: prevMonth,
|
|
1619
|
+
className: "p-2 rounded-full hover:bg-[var(--muted)] transition-colors",
|
|
1620
|
+
"aria-label": "Previous month",
|
|
1621
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded text-[var(--fg)]", children: "chevron_left" })
|
|
1622
|
+
}
|
|
1623
|
+
),
|
|
1624
|
+
/* @__PURE__ */ jsx(
|
|
1625
|
+
"button",
|
|
1626
|
+
{
|
|
1627
|
+
type: "button",
|
|
1628
|
+
onClick: nextMonth,
|
|
1629
|
+
className: "p-2 rounded-full hover:bg-[var(--muted)] transition-colors",
|
|
1630
|
+
"aria-label": "Next month",
|
|
1631
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded text-[var(--fg)]", children: "chevron_right" })
|
|
1632
|
+
}
|
|
1633
|
+
)
|
|
1634
|
+
] })
|
|
1647
1635
|
] }),
|
|
1648
1636
|
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-1 mb-2", children: DAYS_OF_WEEK.map((day) => /* @__PURE__ */ jsx(
|
|
1649
1637
|
"div",
|
|
@@ -1724,6 +1712,8 @@ var DateInput = React11.forwardRef(
|
|
|
1724
1712
|
maxDate,
|
|
1725
1713
|
placeholder = "00/00/0000",
|
|
1726
1714
|
className = "",
|
|
1715
|
+
lightBackgroundImage,
|
|
1716
|
+
darkBackgroundImage,
|
|
1727
1717
|
...props
|
|
1728
1718
|
}, ref) => {
|
|
1729
1719
|
const [inputValue, setInputValue] = React11.useState(
|
|
@@ -1813,7 +1803,7 @@ var DateInput = React11.forwardRef(
|
|
|
1813
1803
|
...props
|
|
1814
1804
|
}
|
|
1815
1805
|
),
|
|
1816
|
-
showCalendar && !disabled && /* @__PURE__ */ jsx("div", { className: "absolute z-20 mt-2 w-full max-w-sm", children: /* @__PURE__ */ jsx(Card, { className: "p-4", showDecorations: false, children: /* @__PURE__ */ jsx(
|
|
1806
|
+
showCalendar && !disabled && /* @__PURE__ */ jsx("div", { className: "absolute z-20 mt-2 w-full max-w-sm", children: /* @__PURE__ */ jsx(Card, { className: "p-4", showDecorations: false, lightImage: lightBackgroundImage, darkImage: darkBackgroundImage, children: /* @__PURE__ */ jsx(
|
|
1817
1807
|
Calendar,
|
|
1818
1808
|
{
|
|
1819
1809
|
selectedDate: inputValue !== placeholder && parseDate(inputValue) && isValidDate(parseDate(inputValue)) ? parseDate(inputValue) : /* @__PURE__ */ new Date(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neoptocom/neopto-ui",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A modern React component library built with Tailwind CSS v4 and TypeScript. Features dark mode, design tokens, and comprehensive Storybook documentation. Requires Tailwind v4+.",
|
|
6
6
|
"keywords": [
|
|
@@ -222,7 +222,7 @@ export default function Autocomplete({
|
|
|
222
222
|
}
|
|
223
223
|
disabled={disabled}
|
|
224
224
|
aria-label={selectedOption && !open ? "Clear" : open ? "Collapse" : "Expand"}
|
|
225
|
-
className="absolute right-
|
|
225
|
+
className="absolute right-1 top-[-20%]"
|
|
226
226
|
iconClassName={[
|
|
227
227
|
"transition-transform duration-300 text-[var(--muted-fg)]",
|
|
228
228
|
open ? "rotate-180 text-[var(--color-brand)]" : ""
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import Typo from "./Typo";
|
|
2
3
|
|
|
3
4
|
export type CalendarProps = {
|
|
4
5
|
/** Currently selected date */
|
|
@@ -13,21 +14,8 @@ export type CalendarProps = {
|
|
|
13
14
|
maxDate?: Date;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const DAYS_OF_WEEK = ["
|
|
17
|
-
const MONTHS = [
|
|
18
|
-
"January",
|
|
19
|
-
"February",
|
|
20
|
-
"March",
|
|
21
|
-
"April",
|
|
22
|
-
"May",
|
|
23
|
-
"June",
|
|
24
|
-
"July",
|
|
25
|
-
"August",
|
|
26
|
-
"September",
|
|
27
|
-
"October",
|
|
28
|
-
"November",
|
|
29
|
-
"December",
|
|
30
|
-
];
|
|
17
|
+
const DAYS_OF_WEEK = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"];
|
|
18
|
+
const MONTHS = ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"];
|
|
31
19
|
|
|
32
20
|
function isSameDay(date1: Date, date2: Date): boolean {
|
|
33
21
|
return (
|
|
@@ -130,29 +118,36 @@ export default function Calendar({
|
|
|
130
118
|
<div className="w-full">
|
|
131
119
|
{/* Header */}
|
|
132
120
|
<div className="flex items-center justify-between mb-4">
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
121
|
+
<div className="flex items-center gap-2">
|
|
122
|
+
<Typo variant="title-md" bold="medium" className="text-[var(--fg)]">
|
|
123
|
+
{MONTHS[currentMonth.getMonth()]}
|
|
124
|
+
</Typo>
|
|
125
|
+
<Typo variant="title-md" bold="medium" className="text-cyan-500">
|
|
126
|
+
{currentMonth.getFullYear()}
|
|
127
|
+
</Typo>
|
|
128
|
+
</div>
|
|
129
|
+
<div>
|
|
130
|
+
<button
|
|
131
|
+
type="button"
|
|
132
|
+
onClick={prevMonth}
|
|
133
|
+
className="p-2 rounded-full hover:bg-[var(--muted)] transition-colors"
|
|
134
|
+
aria-label="Previous month"
|
|
135
|
+
>
|
|
136
|
+
<span className="material-symbols-rounded text-[var(--fg)]">
|
|
137
|
+
chevron_left
|
|
138
|
+
</span>
|
|
139
|
+
</button>
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
142
|
+
onClick={nextMonth}
|
|
143
|
+
className="p-2 rounded-full hover:bg-[var(--muted)] transition-colors"
|
|
144
|
+
aria-label="Next month"
|
|
145
|
+
>
|
|
146
|
+
<span className="material-symbols-rounded text-[var(--fg)]">
|
|
147
|
+
chevron_right
|
|
148
|
+
</span>
|
|
149
|
+
</button>
|
|
150
|
+
</div>
|
|
156
151
|
</div>
|
|
157
152
|
|
|
158
153
|
{/* Days of week header */}
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { Input } from "./Input";
|
|
3
3
|
import Calendar from "./Calendar";
|
|
4
4
|
import { Card } from "./Card";
|
|
5
|
+
import { assets } from "..";
|
|
5
6
|
|
|
6
7
|
export type DateInputProps = Omit<
|
|
7
8
|
React.InputHTMLAttributes<HTMLInputElement>,
|
|
@@ -21,6 +22,10 @@ export type DateInputProps = Omit<
|
|
|
21
22
|
maxDate?: Date;
|
|
22
23
|
/** Placeholder text (default: "00/00/0000") */
|
|
23
24
|
placeholder?: string;
|
|
25
|
+
/** Background image URL for light mode */
|
|
26
|
+
lightBackgroundImage?: string;
|
|
27
|
+
/** Background image URL for dark mode */
|
|
28
|
+
darkBackgroundImage?: string;
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
function formatDate(date: Date): string {
|
|
@@ -75,6 +80,8 @@ export const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
|
|
|
75
80
|
maxDate,
|
|
76
81
|
placeholder = "00/00/0000",
|
|
77
82
|
className = "",
|
|
83
|
+
lightBackgroundImage,
|
|
84
|
+
darkBackgroundImage,
|
|
78
85
|
...props
|
|
79
86
|
},
|
|
80
87
|
ref
|
|
@@ -199,7 +206,7 @@ export const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
|
|
|
199
206
|
|
|
200
207
|
{showCalendar && !disabled && (
|
|
201
208
|
<div className="absolute z-20 mt-2 w-full max-w-sm">
|
|
202
|
-
<Card className="p-4" showDecorations={false}>
|
|
209
|
+
<Card className="p-4" showDecorations={false} lightImage={lightBackgroundImage} darkImage={darkBackgroundImage}>
|
|
203
210
|
<Calendar
|
|
204
211
|
selectedDate={
|
|
205
212
|
inputValue !== placeholder &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
3
|
import { DateInput } from "../components/DateInput";
|
|
3
|
-
import { useState } from "react";
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof DateInput> = {
|
|
6
6
|
title: "Components/DateInput",
|
|
@@ -11,7 +11,7 @@ type Story = StoryObj<typeof DateInput>;
|
|
|
11
11
|
|
|
12
12
|
export const Default: Story = {
|
|
13
13
|
render: () => {
|
|
14
|
-
const [date, setDate] = useState<Date | null>(null);
|
|
14
|
+
const [date, setDate] = React.useState<Date | null>(null);
|
|
15
15
|
return (
|
|
16
16
|
<div className="flex flex-col gap-4 w-96">
|
|
17
17
|
<DateInput
|
|
@@ -26,7 +26,7 @@ export const Default: Story = {
|
|
|
26
26
|
|
|
27
27
|
export const WithInitialValue: Story = {
|
|
28
28
|
render: () => {
|
|
29
|
-
const [date, setDate] = useState<Date | null>(new Date());
|
|
29
|
+
const [date, setDate] = React.useState<Date | null>(new Date());
|
|
30
30
|
return (
|
|
31
31
|
<div className="flex flex-col gap-4 w-96">
|
|
32
32
|
<DateInput
|
|
@@ -41,7 +41,7 @@ export const WithInitialValue: Story = {
|
|
|
41
41
|
|
|
42
42
|
export const WithoutLabel: Story = {
|
|
43
43
|
render: () => {
|
|
44
|
-
const [date, setDate] = useState<Date | null>(null);
|
|
44
|
+
const [date, setDate] = React.useState<Date | null>(null);
|
|
45
45
|
return (
|
|
46
46
|
<div className="flex flex-col gap-4 w-96">
|
|
47
47
|
<DateInput
|
|
@@ -55,7 +55,7 @@ export const WithoutLabel: Story = {
|
|
|
55
55
|
|
|
56
56
|
export const Disabled: Story = {
|
|
57
57
|
render: () => {
|
|
58
|
-
const [date, setDate] = useState<Date | null>(new Date());
|
|
58
|
+
const [date, setDate] = React.useState<Date | null>(new Date());
|
|
59
59
|
return (
|
|
60
60
|
<div className="flex flex-col gap-4 w-96">
|
|
61
61
|
<DateInput
|
|
@@ -71,7 +71,7 @@ export const Disabled: Story = {
|
|
|
71
71
|
|
|
72
72
|
export const WithError: Story = {
|
|
73
73
|
render: () => {
|
|
74
|
-
const [date, setDate] = useState<Date | null>(null);
|
|
74
|
+
const [date, setDate] = React.useState<Date | null>(null);
|
|
75
75
|
return (
|
|
76
76
|
<div className="flex flex-col gap-4 w-96">
|
|
77
77
|
<DateInput
|
|
@@ -87,7 +87,7 @@ export const WithError: Story = {
|
|
|
87
87
|
|
|
88
88
|
export const WithMinMax: Story = {
|
|
89
89
|
render: () => {
|
|
90
|
-
const [date, setDate] = useState<Date | null>(null);
|
|
90
|
+
const [date, setDate] = React.useState<Date | null>(null);
|
|
91
91
|
const today = new Date();
|
|
92
92
|
const minDate = new Date(today);
|
|
93
93
|
minDate.setDate(today.getDate() - 7); // 7 days ago
|
|
@@ -113,8 +113,8 @@ export const WithMinMax: Story = {
|
|
|
113
113
|
|
|
114
114
|
export const Multiple: Story = {
|
|
115
115
|
render: () => {
|
|
116
|
-
const [startDate, setStartDate] = useState<Date | null>(null);
|
|
117
|
-
const [endDate, setEndDate] = useState<Date | null>(null);
|
|
116
|
+
const [startDate, setStartDate] = React.useState<Date | null>(null);
|
|
117
|
+
const [endDate, setEndDate] = React.useState<Date | null>(null);
|
|
118
118
|
|
|
119
119
|
return (
|
|
120
120
|
<div className="flex flex-col gap-4 w-96">
|