linkedunion-design-kit 1.10.1 → 1.10.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/build/types/app/layout.d.ts +12 -0
- package/dist/build/types/app/layout.js +22 -0
- package/dist/build/types/app/page.d.ts +12 -0
- package/dist/build/types/app/page.js +22 -0
- package/dist/build/types/validator.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/src/components/Button/Button/Button.module.css +1 -1
- package/dist/src/components/ColorPicker/ColorPicker.stories.js +1 -1
- package/dist/src/components/ColorPicker/index.d.ts +1 -1
- package/dist/src/components/Input/DatePicker.d.ts +3 -0
- package/dist/src/components/Input/DatePicker.js +255 -0
- package/dist/src/components/Input/DatePicker.stories.d.ts +15 -0
- package/dist/src/components/Input/DatePicker.stories.js +253 -0
- package/dist/src/components/Input/Input.stories.d.ts +2 -1
- package/dist/src/components/Input/Input.stories.js +7 -2
- package/dist/src/components/Input/index.d.ts +90 -17
- package/dist/src/components/Input/index.js +83 -8
- package/dist/src/components/Input/input.d.ts +8 -27
- package/dist/src/components/Input/input.js +7 -29
- package/dist/src/components/Input/type.d.ts +18 -10
- package/dist/src/components/Label/Label.d.ts +1 -1
- package/dist/src/components/Pagination/pagination.js +2 -2
- package/dist/src/components/Title/Title.module.css +1 -1
- package/dist/src/components/Typography/Heading/Heading.stories.d.ts +24 -0
- package/dist/src/components/Typography/Heading/Heading.stories.js +20 -2
- package/dist/src/components/Typography/Heading/heading.module.css +121 -25
- package/dist/styles/global.css +54 -3
- package/package.json +1 -1
- package/dist/src/components/Avatar/Avatar/Avatar1.stories.d.ts +0 -17
- package/dist/src/components/Avatar/Avatar/Avatar1.stories.js +0 -68
- package/dist/src/components/Avatar/Avatar/type.d.ts +0 -12
- package/dist/src/components/ui/avatar.d.ts +0 -13
- package/dist/src/components/ui/avatar.js +0 -53
- /package/dist/{src/components/Avatar/Avatar/type.js → build/types/validator.d.ts} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type SegmentParams<T extends Object = any> = T extends Record<string, any> ? {
|
|
2
|
+
[K in keyof T]: T[K] extends string ? string | string[] | undefined : never;
|
|
3
|
+
} : T;
|
|
4
|
+
export interface PageProps {
|
|
5
|
+
params?: Promise<SegmentParams>;
|
|
6
|
+
searchParams?: Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
export interface LayoutProps {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
params?: Promise<SegmentParams>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// File: /Users/sameersultan/Desktop/linkedunion-design-kit/app/layout.tsx
|
|
2
|
+
import * as entry from '../../../app/layout.js';
|
|
3
|
+
// Check that the entry is a valid entry
|
|
4
|
+
checkFields();
|
|
5
|
+
// Check the prop type of the entry function
|
|
6
|
+
checkFields();
|
|
7
|
+
// Check the arguments and return type of the generateMetadata function
|
|
8
|
+
if ('generateMetadata' in entry) {
|
|
9
|
+
checkFields();
|
|
10
|
+
checkFields();
|
|
11
|
+
}
|
|
12
|
+
// Check the arguments and return type of the generateViewport function
|
|
13
|
+
if ('generateViewport' in entry) {
|
|
14
|
+
checkFields();
|
|
15
|
+
checkFields();
|
|
16
|
+
}
|
|
17
|
+
// Check the arguments and return type of the generateStaticParams function
|
|
18
|
+
if ('generateStaticParams' in entry) {
|
|
19
|
+
checkFields();
|
|
20
|
+
checkFields();
|
|
21
|
+
}
|
|
22
|
+
function checkFields() { }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type SegmentParams<T extends Object = any> = T extends Record<string, any> ? {
|
|
2
|
+
[K in keyof T]: T[K] extends string ? string | string[] | undefined : never;
|
|
3
|
+
} : T;
|
|
4
|
+
export interface PageProps {
|
|
5
|
+
params?: Promise<SegmentParams>;
|
|
6
|
+
searchParams?: Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
export interface LayoutProps {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
params?: Promise<SegmentParams>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// File: /Users/sameersultan/Desktop/linkedunion-design-kit/app/page.tsx
|
|
2
|
+
import * as entry from '../../../app/page.js';
|
|
3
|
+
// Check that the entry is a valid entry
|
|
4
|
+
checkFields();
|
|
5
|
+
// Check the prop type of the entry function
|
|
6
|
+
checkFields();
|
|
7
|
+
// Check the arguments and return type of the generateMetadata function
|
|
8
|
+
if ('generateMetadata' in entry) {
|
|
9
|
+
checkFields();
|
|
10
|
+
checkFields();
|
|
11
|
+
}
|
|
12
|
+
// Check the arguments and return type of the generateViewport function
|
|
13
|
+
if ('generateViewport' in entry) {
|
|
14
|
+
checkFields();
|
|
15
|
+
checkFields();
|
|
16
|
+
}
|
|
17
|
+
// Check the arguments and return type of the generateStaticParams function
|
|
18
|
+
if ('generateStaticParams' in entry) {
|
|
19
|
+
checkFields();
|
|
20
|
+
checkFields();
|
|
21
|
+
}
|
|
22
|
+
function checkFields() { }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file is generated automatically by Next.js
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
// This file validates that all pages and layouts export the correct types
|
|
4
|
+
// Validate ../../app/page.tsx
|
|
5
|
+
{
|
|
6
|
+
var handler = {};
|
|
7
|
+
}
|
|
8
|
+
// Validate ../../app/layout.tsx
|
|
9
|
+
{
|
|
10
|
+
var handler = {};
|
|
11
|
+
}
|
|
12
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -31,3 +31,4 @@ export { default as Combobox } from "./src/components/Dropdown/Combobox/Combobox
|
|
|
31
31
|
export { Pagination, PaginationContent, PaginationLink, PaginationItem, PaginationPrevious, PaginationNext, PaginationEllipsis, } from "./src/components/Pagination/pagination";
|
|
32
32
|
export { Skeleton } from "./src/components/Skeleton/skeleton";
|
|
33
33
|
export { Tabs as VerticalTabs, TabsContent as VerticalTabsContent, TabsList as VerticalTabsList, tabSizes as verticalTabsSize, TabsTrigger as VerticalTabsTrigger, TabsHeading as VerticalTabsHeading, } from "./src/components/VerticalTabs/VerticalTabs";
|
|
34
|
+
export { DatePicker } from "./src/components/Input/DatePicker";
|
package/dist/index.js
CHANGED
|
@@ -31,3 +31,4 @@ export { default as Combobox } from "./src/components/Dropdown/Combobox/Combobox
|
|
|
31
31
|
export { Pagination, PaginationContent, PaginationLink, PaginationItem, PaginationPrevious, PaginationNext, PaginationEllipsis, } from "./src/components/Pagination/pagination";
|
|
32
32
|
export { Skeleton } from "./src/components/Skeleton/skeleton";
|
|
33
33
|
export { Tabs as VerticalTabs, TabsContent as VerticalTabsContent, TabsList as VerticalTabsList, tabSizes as verticalTabsSize, TabsTrigger as VerticalTabsTrigger, TabsHeading as VerticalTabsHeading, } from "./src/components/VerticalTabs/VerticalTabs";
|
|
34
|
+
export { DatePicker } from "./src/components/Input/DatePicker";
|
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import ColorPicker from "./ColorPicker";
|
|
14
14
|
import { Label } from "../Label/Label";
|
|
15
|
-
import { inputVariantConfig } from "../Input
|
|
15
|
+
import { inputVariantConfig } from "../Input";
|
|
16
16
|
export default {
|
|
17
17
|
title: "Components/ColorPicker",
|
|
18
18
|
component: ColorPicker,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DatePickerProps } from "./";
|
|
2
|
+
declare function DatePicker({ className, variant, size, startIcon, endIcon, shape, color, value, onChange, minDate, maxDate, disabled, placeholder, ...props }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export { DatePicker };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import { createPortal } from "react-dom";
|
|
26
|
+
import { isSameDay as dateFnsIsSameDay, isToday as dateFnsIsToday, startOfDay, isBefore, isAfter, } from "date-fns";
|
|
27
|
+
import { cn } from "../../lib/utils";
|
|
28
|
+
import LUIcon from "../Icons/LUIcon";
|
|
29
|
+
import { Button } from "../Button/Button/Button";
|
|
30
|
+
import { Input } from "./input";
|
|
31
|
+
import { getIconSize, MONTHS, DAYS, datePickerStyles, DEFAULT_INPUT_VARIANT, DEFAULT_INPUT_SIZE, DEFAULT_INPUT_COLOR, DEFAULT_INPUT_SHAPE, } from "./";
|
|
32
|
+
function DatePicker(_a) {
|
|
33
|
+
var className = _a.className, _b = _a.variant, variant = _b === void 0 ? DEFAULT_INPUT_VARIANT : _b, _c = _a.size, size = _c === void 0 ? DEFAULT_INPUT_SIZE : _c, startIcon = _a.startIcon, endIcon = _a.endIcon, _d = _a.shape, shape = _d === void 0 ? DEFAULT_INPUT_SHAPE : _d, _e = _a.color, color = _e === void 0 ? DEFAULT_INPUT_COLOR : _e, value = _a.value, onChange = _a.onChange, minDate = _a.minDate, maxDate = _a.maxDate, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.placeholder, placeholder = _g === void 0 ? "MM/DD/YYYY" : _g, props = __rest(_a, ["className", "variant", "size", "startIcon", "endIcon", "shape", "color", "value", "onChange", "minDate", "maxDate", "disabled", "placeholder"]);
|
|
34
|
+
var _h = React.useState(false), isOpen = _h[0], setIsOpen = _h[1];
|
|
35
|
+
var _j = React.useState(value || null), selectedDate = _j[0], setSelectedDate = _j[1];
|
|
36
|
+
var _k = React.useState(value || new Date()), viewDate = _k[0], setViewDate = _k[1];
|
|
37
|
+
var _l = React.useState("days"), viewMode = _l[0], setViewMode = _l[1];
|
|
38
|
+
var _m = React.useState({ top: 0, left: 0, width: 0 }), dropdownPosition = _m[0], setDropdownPosition = _m[1];
|
|
39
|
+
var containerRef = React.useRef(null);
|
|
40
|
+
var inputRef = React.useRef(null);
|
|
41
|
+
var dropdownRef = React.useRef(null);
|
|
42
|
+
var iconSizeClass = getIconSize(size);
|
|
43
|
+
React.useEffect(function () {
|
|
44
|
+
setSelectedDate(value || null);
|
|
45
|
+
if (value) {
|
|
46
|
+
setViewDate(value);
|
|
47
|
+
}
|
|
48
|
+
}, [value]);
|
|
49
|
+
React.useEffect(function () {
|
|
50
|
+
var handleClickOutside = function (event) {
|
|
51
|
+
if (containerRef.current &&
|
|
52
|
+
!containerRef.current.contains(event.target) &&
|
|
53
|
+
dropdownRef.current &&
|
|
54
|
+
!dropdownRef.current.contains(event.target)) {
|
|
55
|
+
setIsOpen(false);
|
|
56
|
+
setViewMode("days");
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (isOpen) {
|
|
60
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
61
|
+
}
|
|
62
|
+
return function () {
|
|
63
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
64
|
+
};
|
|
65
|
+
}, [isOpen]);
|
|
66
|
+
React.useEffect(function () {
|
|
67
|
+
var updatePosition = function () {
|
|
68
|
+
var _a;
|
|
69
|
+
if (isOpen && containerRef.current) {
|
|
70
|
+
var rect = containerRef.current.getBoundingClientRect();
|
|
71
|
+
var dropdownHeight = ((_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 400;
|
|
72
|
+
var spaceBelow = window.innerHeight - rect.bottom;
|
|
73
|
+
var spaceAbove = rect.top;
|
|
74
|
+
var top_1 = rect.bottom + 8;
|
|
75
|
+
if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
|
|
76
|
+
top_1 = rect.top - dropdownHeight - 8;
|
|
77
|
+
}
|
|
78
|
+
setDropdownPosition({
|
|
79
|
+
top: top_1,
|
|
80
|
+
left: rect.left,
|
|
81
|
+
width: rect.width,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
if (isOpen) {
|
|
86
|
+
updatePosition();
|
|
87
|
+
window.addEventListener("resize", updatePosition);
|
|
88
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
89
|
+
return function () {
|
|
90
|
+
window.removeEventListener("resize", updatePosition);
|
|
91
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}, [isOpen]);
|
|
95
|
+
var handleDateSelect = function (date) {
|
|
96
|
+
if (isDateDisabled(date))
|
|
97
|
+
return;
|
|
98
|
+
// If clicking on already selected date, clear it
|
|
99
|
+
if (selectedDate && dateFnsIsSameDay(selectedDate, date)) {
|
|
100
|
+
setSelectedDate(null);
|
|
101
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
102
|
+
setIsOpen(false);
|
|
103
|
+
setViewMode("days");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setSelectedDate(date);
|
|
107
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(date);
|
|
108
|
+
setIsOpen(false);
|
|
109
|
+
setViewMode("days");
|
|
110
|
+
};
|
|
111
|
+
var handleMonthSelect = function (monthIndex) {
|
|
112
|
+
var newDate = new Date(viewDate.getFullYear(), monthIndex, 1);
|
|
113
|
+
setViewDate(newDate);
|
|
114
|
+
setViewMode("days");
|
|
115
|
+
};
|
|
116
|
+
var handleYearSelect = function (year) {
|
|
117
|
+
var newDate = new Date(year, viewDate.getMonth(), 1);
|
|
118
|
+
setViewDate(newDate);
|
|
119
|
+
setViewMode("months");
|
|
120
|
+
};
|
|
121
|
+
var isDateDisabled = function (date) {
|
|
122
|
+
if (minDate && isBefore(startOfDay(date), startOfDay(minDate)))
|
|
123
|
+
return true;
|
|
124
|
+
if (maxDate && isAfter(startOfDay(date), startOfDay(maxDate)))
|
|
125
|
+
return true;
|
|
126
|
+
return false;
|
|
127
|
+
};
|
|
128
|
+
var getDaysInMonth = function (year, month) {
|
|
129
|
+
var firstDay = new Date(year, month, 1);
|
|
130
|
+
var lastDay = new Date(year, month + 1, 0);
|
|
131
|
+
var daysInMonth = lastDay.getDate();
|
|
132
|
+
var startingDayOfWeek = firstDay.getDay();
|
|
133
|
+
var days = [];
|
|
134
|
+
for (var i = 0; i < startingDayOfWeek; i++) {
|
|
135
|
+
var prevMonthDay = new Date(year, month, -startingDayOfWeek + i + 1);
|
|
136
|
+
days.push(prevMonthDay);
|
|
137
|
+
}
|
|
138
|
+
for (var day = 1; day <= daysInMonth; day++) {
|
|
139
|
+
days.push(new Date(year, month, day));
|
|
140
|
+
}
|
|
141
|
+
var remainingDays = 42 - days.length;
|
|
142
|
+
for (var i = 1; i <= remainingDays; i++) {
|
|
143
|
+
days.push(new Date(year, month + 1, i));
|
|
144
|
+
}
|
|
145
|
+
return days;
|
|
146
|
+
};
|
|
147
|
+
var getYearRange = function () {
|
|
148
|
+
var currentYear = viewDate.getFullYear();
|
|
149
|
+
var startYear = Math.floor(currentYear / 12) * 12;
|
|
150
|
+
return Array.from({ length: 12 }, function (_, i) { return startYear + i; });
|
|
151
|
+
};
|
|
152
|
+
var navigateMonth = function (direction) {
|
|
153
|
+
var newDate = new Date(viewDate);
|
|
154
|
+
newDate.setMonth(viewDate.getMonth() + (direction === "prev" ? -1 : 1));
|
|
155
|
+
setViewDate(newDate);
|
|
156
|
+
};
|
|
157
|
+
var navigateYear = function (direction) {
|
|
158
|
+
var newDate = new Date(viewDate);
|
|
159
|
+
newDate.setFullYear(viewDate.getFullYear() + (direction === "prev" ? -1 : 1));
|
|
160
|
+
setViewDate(newDate);
|
|
161
|
+
};
|
|
162
|
+
var navigateYearRange = function (direction) {
|
|
163
|
+
var newDate = new Date(viewDate);
|
|
164
|
+
newDate.setFullYear(viewDate.getFullYear() + (direction === "prev" ? -12 : 12));
|
|
165
|
+
setViewDate(newDate);
|
|
166
|
+
};
|
|
167
|
+
var toggleCalendar = function () {
|
|
168
|
+
if (disabled)
|
|
169
|
+
return;
|
|
170
|
+
setIsOpen(function (prev) { return !prev; });
|
|
171
|
+
if (!isOpen) {
|
|
172
|
+
setViewMode("days");
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var renderDaysView = function () {
|
|
176
|
+
var days = getDaysInMonth(viewDate.getFullYear(), viewDate.getMonth());
|
|
177
|
+
var currentMonth = viewDate.getMonth();
|
|
178
|
+
var config = datePickerStyles.dayConfig[size];
|
|
179
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "bg-gray-100 rounded-md mb-2", children: _jsx("div", { className: "grid grid-cols-7 gap-1 px-1", children: DAYS.map(function (day) { return (_jsx("div", { className: cn("text-center font-medium text-gray-900 py-2", config.fontSize), children: day }, day)); }) }) }), _jsx("div", { className: "grid grid-cols-7 gap-1", children: days.map(function (day, index) {
|
|
180
|
+
var isCurrentMonth = day.getMonth() === currentMonth;
|
|
181
|
+
var isSelected = selectedDate
|
|
182
|
+
? dateFnsIsSameDay(selectedDate, day)
|
|
183
|
+
: false;
|
|
184
|
+
var isTodayDate = dateFnsIsToday(day);
|
|
185
|
+
var isDisabled = isDateDisabled(day);
|
|
186
|
+
return (_jsx(Button, { onClick: function () { return handleDateSelect(day); }, disabled: isDisabled, variant: "ghost", size: size, className: cn(config.buttonSize, "rounded-md transition-colors", "hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-600", isSelected
|
|
187
|
+
? "!bg-blue-600 text-white hover:bg-blue-700"
|
|
188
|
+
: isCurrentMonth
|
|
189
|
+
? "text-gray-900"
|
|
190
|
+
: "text-gray-400", isTodayDate && !isSelected && "border border-blue-600", isDisabled &&
|
|
191
|
+
"opacity-40 cursor-not-allowed hover:bg-transparent"), children: day.getDate() }, index));
|
|
192
|
+
}) })] }));
|
|
193
|
+
};
|
|
194
|
+
var renderMonthsView = function () {
|
|
195
|
+
var config = datePickerStyles.monthConfig[size];
|
|
196
|
+
return (_jsx("div", { className: "grid grid-cols-3 gap-2", children: MONTHS.map(function (month, index) {
|
|
197
|
+
var isSelected = (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getMonth()) === index &&
|
|
198
|
+
(selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getFullYear()) === viewDate.getFullYear();
|
|
199
|
+
var isCurrent = new Date().getMonth() === index &&
|
|
200
|
+
new Date().getFullYear() === viewDate.getFullYear();
|
|
201
|
+
return (_jsx(Button, { onClick: function () { return handleMonthSelect(index); }, variant: "ghost", size: size, className: cn(config.buttonSize, "rounded-md transition-colors", "hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-600", isSelected && "bg-blue-600 text-white hover:bg-blue-700", isCurrent && !isSelected && "border border-blue-600"), children: month.slice(0, 3) }, month));
|
|
202
|
+
}) }));
|
|
203
|
+
};
|
|
204
|
+
var renderYearsView = function () {
|
|
205
|
+
var years = getYearRange();
|
|
206
|
+
var config = datePickerStyles.yearConfig[size];
|
|
207
|
+
return (_jsx("div", { className: "grid grid-cols-3 gap-2", children: years.map(function (year) {
|
|
208
|
+
var isSelected = (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getFullYear()) === year;
|
|
209
|
+
var isCurrent = new Date().getFullYear() === year;
|
|
210
|
+
return (_jsx(Button, { onClick: function () { return handleYearSelect(year); }, variant: "ghost", size: size, className: cn(config.buttonSize, "rounded-md transition-colors", "hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-600", isSelected && "bg-blue-600 text-white hover:bg-blue-700", isCurrent && !isSelected && "border border-blue-600"), children: year }, year));
|
|
211
|
+
}) }));
|
|
212
|
+
};
|
|
213
|
+
var getHeaderTitle = function () {
|
|
214
|
+
switch (viewMode) {
|
|
215
|
+
case "days":
|
|
216
|
+
return "".concat(MONTHS[viewDate.getMonth()], " ").concat(viewDate.getFullYear());
|
|
217
|
+
case "months":
|
|
218
|
+
return viewDate.getFullYear().toString();
|
|
219
|
+
case "years": {
|
|
220
|
+
var years = getYearRange();
|
|
221
|
+
return "".concat(years[0], " - ").concat(years[years.length - 1]);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
var handleHeaderClick = function () {
|
|
226
|
+
if (viewMode === "days") {
|
|
227
|
+
setViewMode("months");
|
|
228
|
+
}
|
|
229
|
+
else if (viewMode === "months") {
|
|
230
|
+
setViewMode("years");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var handleNavigation = function (direction) {
|
|
234
|
+
switch (viewMode) {
|
|
235
|
+
case "days":
|
|
236
|
+
navigateMonth(direction);
|
|
237
|
+
break;
|
|
238
|
+
case "months":
|
|
239
|
+
navigateYear(direction);
|
|
240
|
+
break;
|
|
241
|
+
case "years":
|
|
242
|
+
navigateYearRange(direction);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
return (_jsxs("div", { className: "relative", ref: containerRef, children: [_jsx(Input, __assign({ ref: inputRef, type: "text", readOnly: true, variant: variant, size: size, startIcon: startIcon, endIcon: endIcon, shape: shape, color: color, className: cn("cursor-pointer", className), value: selectedDate
|
|
247
|
+
? "".concat(String(selectedDate.getMonth() + 1).padStart(2, "0"), "/").concat(String(selectedDate.getDate()).padStart(2, "0"), "/").concat(selectedDate.getFullYear())
|
|
248
|
+
: "", placeholder: placeholder, onClick: toggleCalendar, disabled: disabled }, props)), isOpen &&
|
|
249
|
+
!disabled &&
|
|
250
|
+
createPortal(_jsxs("div", { ref: dropdownRef, className: "fixed bg-white border border-gray-200 rounded-sm shadow-xl z-[9999] max-h-[400px] overflow-y-auto p-2", style: {
|
|
251
|
+
top: "".concat(dropdownPosition.top, "px"),
|
|
252
|
+
left: "".concat(dropdownPosition.left, "px"),
|
|
253
|
+
}, children: [_jsxs("div", { className: cn("flex items-center justify-between", "mb-2"), children: [_jsx(Button, { onClick: function () { return handleNavigation("prev"); }, variant: "ghost", size: size, className: "p-2 hover:bg-gray-100 rounded-md h-auto w-auto min-w-0 text-gray-900", children: _jsx(LUIcon, { icon: "arrow-left", size: iconSizeClass }) }), _jsx(Button, { onClick: handleHeaderClick, variant: "ghost", size: size, className: cn("font-semibold hover:bg-gray-100 px-3 py-2 rounded-md h-auto text-gray-900", datePickerStyles.headerText[size]), children: getHeaderTitle() }), _jsx(Button, { onClick: function () { return handleNavigation("next"); }, variant: "ghost", size: size, className: "p-2 hover:bg-gray-100 rounded-md h-auto w-auto min-w-0 text-gray-900", children: _jsx(LUIcon, { icon: "arrow-right", size: iconSizeClass }) })] }), viewMode === "days" && renderDaysView(), viewMode === "months" && renderMonthsView(), viewMode === "years" && renderYearsView()] }), document.body)] }));
|
|
254
|
+
}
|
|
255
|
+
export { DatePicker };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta } from "@storybook/react";
|
|
2
|
+
import type { DatePickerProps } from "./type";
|
|
3
|
+
declare const _default: Meta<DatePickerProps>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, DatePickerProps>;
|
|
6
|
+
export declare const Sizes: () => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const Shapes: () => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const WithCustomIcons: () => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const WithDateRestrictions: () => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const ErrorValidation: () => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const SuccessValidation: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const WarningValidation: () => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const AllSizesAndShapes: () => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const DisabledState: () => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const AllVariantsAllColors: () => import("react/jsx-runtime").JSX.Element;
|