@dmsi/wedgekit-react 0.0.476 → 0.0.477
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/{chunk-HSJ34DOK.js → chunk-WIDUWFLX.js} +748 -34
- package/dist/components/CalendarRange.cjs +452 -152
- package/dist/components/CalendarRange.js +1 -2
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +916 -151
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +1 -1
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +926 -161
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +1 -1
- package/dist/components/DataGrid/PinnedColumns.cjs +941 -176
- package/dist/components/DataGrid/PinnedColumns.js +1 -1
- package/dist/components/DataGrid/TableBody/LoadingCell.cjs +917 -152
- package/dist/components/DataGrid/TableBody/LoadingCell.js +1 -1
- package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +923 -158
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +1 -1
- package/dist/components/DataGrid/TableBody/index.cjs +938 -173
- package/dist/components/DataGrid/TableBody/index.js +1 -1
- package/dist/components/DataGrid/index.cjs +1027 -262
- package/dist/components/DataGrid/index.js +1 -1
- package/dist/components/DataGrid/utils.cjs +917 -152
- package/dist/components/DataGrid/utils.js +1 -1
- package/dist/components/DateInput.js +7 -254
- package/dist/components/DateRangeInput.cjs +406 -176
- package/dist/components/DateRangeInput.js +1 -2
- package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +923 -158
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +1 -1
- package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +921 -156
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +1 -1
- package/dist/components/MobileDataGrid/index.cjs +971 -206
- package/dist/components/MobileDataGrid/index.js +1 -1
- package/dist/components/index.cjs +1145 -378
- package/dist/components/index.js +3 -1
- package/package.json +1 -1
- package/src/components/index.ts +1 -0
- package/dist/chunk-X35NLL3N.js +0 -493
package/dist/components/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataGrid,
|
|
3
|
+
DateInput,
|
|
3
4
|
MobileDataGrid
|
|
4
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-WIDUWFLX.js";
|
|
5
6
|
import "../chunk-M7INAUAJ.js";
|
|
6
7
|
import "../chunk-4Q7T4GJ2.js";
|
|
7
8
|
import "../chunk-3DEYCNUE.js";
|
|
@@ -125,6 +126,7 @@ export {
|
|
|
125
126
|
DataCellHeader,
|
|
126
127
|
DataGrid,
|
|
127
128
|
DataGridCell,
|
|
129
|
+
DateInput,
|
|
128
130
|
DragAlongCell,
|
|
129
131
|
DraggableCellHeader,
|
|
130
132
|
EmptyCartIcon,
|
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { MenuOption } from "./MenuOption";
|
|
|
18
18
|
export { Search } from "./Search";
|
|
19
19
|
export { Tooltip } from "./Tooltip";
|
|
20
20
|
export { Input } from "./Input";
|
|
21
|
+
export { DateInput } from "./DateInput";
|
|
21
22
|
export { Accordion } from "./Accordion";
|
|
22
23
|
export { Card } from "./Card";
|
|
23
24
|
export { MobileDataGrid } from "./MobileDataGrid";
|
package/dist/chunk-X35NLL3N.js
DELETED
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Menu
|
|
3
|
-
} from "./chunk-TCMOGTPB.js";
|
|
4
|
-
import {
|
|
5
|
-
MenuOption
|
|
6
|
-
} from "./chunk-IPAKWF2V.js";
|
|
7
|
-
import {
|
|
8
|
-
Icon
|
|
9
|
-
} from "./chunk-NKUETCDA.js";
|
|
10
|
-
import {
|
|
11
|
-
componentPadding,
|
|
12
|
-
layoutGap,
|
|
13
|
-
layoutPaddding,
|
|
14
|
-
typography
|
|
15
|
-
} from "./chunk-IXR65MOU.js";
|
|
16
|
-
import {
|
|
17
|
-
__objRest,
|
|
18
|
-
__spreadProps,
|
|
19
|
-
__spreadValues
|
|
20
|
-
} from "./chunk-ORMEWXMH.js";
|
|
21
|
-
|
|
22
|
-
// src/components/CalendarRange.tsx
|
|
23
|
-
import clsx from "clsx";
|
|
24
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
25
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
26
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
-
function isWeekend(date) {
|
|
28
|
-
return date.dayOfWeek === 6 || date.dayOfWeek === 7;
|
|
29
|
-
}
|
|
30
|
-
function DateCell(_a) {
|
|
31
|
-
var _b = _a, {
|
|
32
|
-
date,
|
|
33
|
-
isInMonth,
|
|
34
|
-
isToday,
|
|
35
|
-
isSelected,
|
|
36
|
-
inRange,
|
|
37
|
-
isDisabled,
|
|
38
|
-
isRangeStart,
|
|
39
|
-
isRangeEnd,
|
|
40
|
-
onClick,
|
|
41
|
-
onMouseEnter,
|
|
42
|
-
onMouseLeave,
|
|
43
|
-
cellPadding = "",
|
|
44
|
-
isRangeDisabled = false,
|
|
45
|
-
id,
|
|
46
|
-
testid
|
|
47
|
-
} = _b, props = __objRest(_b, [
|
|
48
|
-
"date",
|
|
49
|
-
"isInMonth",
|
|
50
|
-
"isToday",
|
|
51
|
-
"isSelected",
|
|
52
|
-
"inRange",
|
|
53
|
-
"isDisabled",
|
|
54
|
-
"isRangeStart",
|
|
55
|
-
"isRangeEnd",
|
|
56
|
-
"onClick",
|
|
57
|
-
"onMouseEnter",
|
|
58
|
-
"onMouseLeave",
|
|
59
|
-
"cellPadding",
|
|
60
|
-
"isRangeDisabled",
|
|
61
|
-
"id",
|
|
62
|
-
"testid"
|
|
63
|
-
]);
|
|
64
|
-
return /* @__PURE__ */ jsx(
|
|
65
|
-
"span",
|
|
66
|
-
__spreadProps(__spreadValues({}, props), {
|
|
67
|
-
id,
|
|
68
|
-
"data-testid": testid,
|
|
69
|
-
className: clsx(
|
|
70
|
-
"flex items-center justify-center aspect-square select-none transition-colors border duration-100 font-medium",
|
|
71
|
-
typography.caption,
|
|
72
|
-
cellPadding,
|
|
73
|
-
!isToday && !isSelected && !inRange && !isDisabled && !isRangeStart && !isRangeEnd && "border-transparent",
|
|
74
|
-
!isInMonth && "border-transparent",
|
|
75
|
-
// Today: subtle border ring
|
|
76
|
-
isToday && !isSelected && !inRange && "rounded-full border-border-primary-normal ",
|
|
77
|
-
// Selected: Figma blue, white text, strong shadow
|
|
78
|
-
isSelected && "bg-action-400 text-white border-action-400 z-10",
|
|
79
|
-
!isSelected && !inRange && "rounded-base",
|
|
80
|
-
// When range is disabled OR when only 'from' is selected (no range yet), apply rounded corners
|
|
81
|
-
(isRangeDisabled || !inRange && isSelected) && "rounded-base",
|
|
82
|
-
inRange && isSelected && "hover:border-action-500",
|
|
83
|
-
// In range: Figma light blue background
|
|
84
|
-
inRange && !isSelected && "bg-action-100 text-text-primary-normal border-y-action-400 border-x-0 ",
|
|
85
|
-
// Disabled: Figma gray, no pointer, no hover
|
|
86
|
-
isDisabled && !inRange ? "text-text-primary-disabled bg-transparent pointer-events-none opacity-40 border-transparent" : [
|
|
87
|
-
"text-text-primary-normal cursor-pointer",
|
|
88
|
-
// Figma hover: blue bg, blue text (or red text if selected)
|
|
89
|
-
isSelected ? "hover:bg-background-action-primary-hover hover:text-white" : "hover:bg-action-100 hover:text-text-action-primary-hover",
|
|
90
|
-
// Figma active: darker blue bg, white text
|
|
91
|
-
"active:bg-action-300 active:text-white",
|
|
92
|
-
// Figma focus: ring
|
|
93
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action-400"
|
|
94
|
-
],
|
|
95
|
-
isRangeStart && "rounded-l",
|
|
96
|
-
isRangeEnd && "rounded-r"
|
|
97
|
-
),
|
|
98
|
-
tabIndex: isDisabled ? -1 : 0,
|
|
99
|
-
"aria-disabled": isDisabled,
|
|
100
|
-
onClick: () => !isDisabled && isInMonth && onClick(),
|
|
101
|
-
onMouseEnter: () => isInMonth && onMouseEnter(),
|
|
102
|
-
onMouseLeave: () => isInMonth && onMouseLeave(),
|
|
103
|
-
children: isInMonth ? date.day : ""
|
|
104
|
-
})
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
function CalendarRange({
|
|
108
|
-
from,
|
|
109
|
-
to,
|
|
110
|
-
onChange,
|
|
111
|
-
isDateAvailable,
|
|
112
|
-
mode = "double",
|
|
113
|
-
cardStyle = false,
|
|
114
|
-
disableRange = false,
|
|
115
|
-
id,
|
|
116
|
-
testid
|
|
117
|
-
}) {
|
|
118
|
-
const weekDays = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
119
|
-
const parseDate = (d) => {
|
|
120
|
-
if (!d) {
|
|
121
|
-
return void 0;
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
if (typeof d === "number") {
|
|
125
|
-
return Temporal.PlainDate.from(new Date(d).toISOString().slice(0, 10));
|
|
126
|
-
}
|
|
127
|
-
if (typeof d === "string") {
|
|
128
|
-
return Temporal.PlainDate.from(d);
|
|
129
|
-
}
|
|
130
|
-
return void 0;
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error("Invalid date format:", d, error);
|
|
133
|
-
return Temporal.Now.plainDateISO();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const fromDate = parseDate(from);
|
|
137
|
-
const toDate = parseDate(to);
|
|
138
|
-
const today = Temporal.Now.plainDateISO();
|
|
139
|
-
const [baseMonth, setBaseMonth] = useState(
|
|
140
|
-
fromDate != null ? fromDate : today.with({ day: 1 })
|
|
141
|
-
);
|
|
142
|
-
const [selecting, setSelecting] = useState("from");
|
|
143
|
-
const [pendingFrom, setPendingFrom] = useState(void 0);
|
|
144
|
-
const [hoveredDate, setHoveredDate] = useState(void 0);
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
if (fromDate) {
|
|
147
|
-
setBaseMonth(fromDate.with({ day: 1 }));
|
|
148
|
-
} else if (toDate) {
|
|
149
|
-
setBaseMonth(toDate.with({ day: 1 }));
|
|
150
|
-
}
|
|
151
|
-
}, [from, to]);
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (fromDate && toDate) {
|
|
154
|
-
setSelecting("from");
|
|
155
|
-
setPendingFrom(void 0);
|
|
156
|
-
setHoveredDate(void 0);
|
|
157
|
-
}
|
|
158
|
-
}, [from, to]);
|
|
159
|
-
function getMonthData(monthOffset) {
|
|
160
|
-
const monthDate = baseMonth.add({ months: monthOffset }).with({ day: 1 });
|
|
161
|
-
const days = monthDate.daysInMonth;
|
|
162
|
-
const firstDayOffset = monthDate.dayOfWeek % 7;
|
|
163
|
-
return {
|
|
164
|
-
name: monthDate.toLocaleString("en-US", { month: "long" }),
|
|
165
|
-
year: monthDate.year,
|
|
166
|
-
days,
|
|
167
|
-
firstDayOffset,
|
|
168
|
-
date: monthDate
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function getMonthDataWith(monthOffset) {
|
|
172
|
-
const monthDate = baseMonth.with({ month: monthOffset }).with({ day: 1 });
|
|
173
|
-
const days = monthDate.daysInMonth;
|
|
174
|
-
const firstDayOffset = monthDate.dayOfWeek % 7;
|
|
175
|
-
return {
|
|
176
|
-
name: monthDate.toLocaleString("en-US", { month: "long" }),
|
|
177
|
-
year: monthDate.year,
|
|
178
|
-
days,
|
|
179
|
-
firstDayOffset,
|
|
180
|
-
date: monthDate
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function handleDayClick(date) {
|
|
184
|
-
if (isDateAvailable && !isDateAvailable(date)) return;
|
|
185
|
-
if (mode === "single" && disableRange) {
|
|
186
|
-
if (onChange) {
|
|
187
|
-
onChange(date.toString(), date.toString());
|
|
188
|
-
}
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
if (selecting === "from") {
|
|
192
|
-
setPendingFrom(date);
|
|
193
|
-
setSelecting("to");
|
|
194
|
-
setHoveredDate(void 0);
|
|
195
|
-
} else if (pendingFrom) {
|
|
196
|
-
if (onChange) {
|
|
197
|
-
const [start, end] = Temporal.PlainDate.compare(date, pendingFrom) < 0 ? [date, pendingFrom] : [pendingFrom, date];
|
|
198
|
-
onChange(start.toString(), end.toString());
|
|
199
|
-
}
|
|
200
|
-
setPendingFrom(void 0);
|
|
201
|
-
setSelecting("from");
|
|
202
|
-
setHoveredDate(void 0);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function isInRange(date) {
|
|
206
|
-
if (mode === "single" && disableRange) {
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
if (pendingFrom && selecting === "to" && hoveredDate) {
|
|
210
|
-
const [start, end] = Temporal.PlainDate.compare(hoveredDate, pendingFrom) < 0 ? [hoveredDate, pendingFrom] : [pendingFrom, hoveredDate];
|
|
211
|
-
return Temporal.PlainDate.compare(date, start) >= 0 && Temporal.PlainDate.compare(date, end) <= 0;
|
|
212
|
-
}
|
|
213
|
-
if (!pendingFrom && fromDate && toDate) {
|
|
214
|
-
return Temporal.PlainDate.compare(date, fromDate) >= 0 && Temporal.PlainDate.compare(date, toDate) <= 0;
|
|
215
|
-
}
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
return /* @__PURE__ */ jsx(
|
|
219
|
-
"div",
|
|
220
|
-
{
|
|
221
|
-
id,
|
|
222
|
-
"data-testid": testid,
|
|
223
|
-
className: clsx(
|
|
224
|
-
"relative bg-background-grouped-primary-normal rounded-base w-fit",
|
|
225
|
-
layoutPaddding,
|
|
226
|
-
layoutGap,
|
|
227
|
-
cardStyle && "shadow-4",
|
|
228
|
-
// baseTransition,
|
|
229
|
-
"overflow-hidden"
|
|
230
|
-
),
|
|
231
|
-
children: /* @__PURE__ */ jsx(
|
|
232
|
-
"div",
|
|
233
|
-
{
|
|
234
|
-
className: clsx(
|
|
235
|
-
"flex flex-row items-start justify-start bg-background-primary-normal overflow-clip",
|
|
236
|
-
layoutGap
|
|
237
|
-
),
|
|
238
|
-
children: (mode === "double" ? [0, 1] : [0]).map((offset, idx) => {
|
|
239
|
-
return /* @__PURE__ */ jsx(
|
|
240
|
-
CalendarPane,
|
|
241
|
-
{
|
|
242
|
-
getMonthData,
|
|
243
|
-
getMonthDataWith,
|
|
244
|
-
offset,
|
|
245
|
-
idx,
|
|
246
|
-
id,
|
|
247
|
-
testid,
|
|
248
|
-
baseMonth,
|
|
249
|
-
setBaseMonth,
|
|
250
|
-
mode,
|
|
251
|
-
pendingFrom,
|
|
252
|
-
weekDays,
|
|
253
|
-
fromDate,
|
|
254
|
-
toDate,
|
|
255
|
-
isDateAvailable,
|
|
256
|
-
disableRange,
|
|
257
|
-
hoveredDate,
|
|
258
|
-
isInRange,
|
|
259
|
-
today,
|
|
260
|
-
setHoveredDate,
|
|
261
|
-
handleDayClick
|
|
262
|
-
},
|
|
263
|
-
idx
|
|
264
|
-
);
|
|
265
|
-
})
|
|
266
|
-
}
|
|
267
|
-
)
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
function CalendarPane({
|
|
272
|
-
getMonthData,
|
|
273
|
-
getMonthDataWith,
|
|
274
|
-
offset,
|
|
275
|
-
idx,
|
|
276
|
-
id,
|
|
277
|
-
testid,
|
|
278
|
-
baseMonth,
|
|
279
|
-
setBaseMonth,
|
|
280
|
-
mode,
|
|
281
|
-
pendingFrom,
|
|
282
|
-
weekDays,
|
|
283
|
-
fromDate,
|
|
284
|
-
toDate,
|
|
285
|
-
isDateAvailable,
|
|
286
|
-
disableRange,
|
|
287
|
-
hoveredDate,
|
|
288
|
-
isInRange,
|
|
289
|
-
today,
|
|
290
|
-
setHoveredDate,
|
|
291
|
-
handleDayClick
|
|
292
|
-
}) {
|
|
293
|
-
const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
294
|
-
const years = Array.from({ length: 100 }).map(
|
|
295
|
-
(_, i) => baseMonth.year - 50 + i
|
|
296
|
-
);
|
|
297
|
-
const [monthMenuOpen, setMonthMenuOpen] = useState(false);
|
|
298
|
-
const [yearMenuOpen, setYearMenuOpen] = useState(false);
|
|
299
|
-
const monthMenuRef = useRef(null);
|
|
300
|
-
const yearMenuRef = useRef(null);
|
|
301
|
-
const month = getMonthData(offset);
|
|
302
|
-
const totalCells = 42;
|
|
303
|
-
const emptyCells = month.firstDayOffset;
|
|
304
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
305
|
-
/* @__PURE__ */ jsxs(
|
|
306
|
-
"div",
|
|
307
|
-
{
|
|
308
|
-
className: clsx("flex flex-col"),
|
|
309
|
-
children: [
|
|
310
|
-
/* @__PURE__ */ jsxs(
|
|
311
|
-
"div",
|
|
312
|
-
{
|
|
313
|
-
className: clsx(
|
|
314
|
-
"flex flex-row items-center justify-between",
|
|
315
|
-
typography.label,
|
|
316
|
-
"text-text-action-primary-normal"
|
|
317
|
-
),
|
|
318
|
-
children: [
|
|
319
|
-
idx === 0 ? /* @__PURE__ */ jsx(
|
|
320
|
-
"button",
|
|
321
|
-
{
|
|
322
|
-
id: id ? `${id}-prev-month-button` : void 0,
|
|
323
|
-
"data-testid": testid ? `${testid}-prev-month-button` : void 0,
|
|
324
|
-
type: "button",
|
|
325
|
-
className: clsx(
|
|
326
|
-
"flex items-center justify-center rounded-base hover:bg-action-100 active:bg-action-300 text-icon-action-primary-normal",
|
|
327
|
-
componentPadding
|
|
328
|
-
),
|
|
329
|
-
"aria-label": "Previous month",
|
|
330
|
-
onClick: () => setBaseMonth(baseMonth.subtract({ months: 1 })),
|
|
331
|
-
children: /* @__PURE__ */ jsx(Icon, { name: "chevron_left", size: 24 })
|
|
332
|
-
}
|
|
333
|
-
) : /* @__PURE__ */ jsx("span", { className: clsx(componentPadding, "mr-1") }),
|
|
334
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-desktop-compact-component-padding", children: [
|
|
335
|
-
/* @__PURE__ */ jsx(
|
|
336
|
-
"button",
|
|
337
|
-
{
|
|
338
|
-
ref: (el) => {
|
|
339
|
-
monthMenuRef.current = el;
|
|
340
|
-
},
|
|
341
|
-
type: "button",
|
|
342
|
-
onClick: () => {
|
|
343
|
-
setMonthMenuOpen(true);
|
|
344
|
-
setYearMenuOpen(false);
|
|
345
|
-
},
|
|
346
|
-
className: "font-semibold text-text-action-primary-normal text-[14px] py-[2px] truncate",
|
|
347
|
-
children: month.name
|
|
348
|
-
}
|
|
349
|
-
),
|
|
350
|
-
/* @__PURE__ */ jsx(
|
|
351
|
-
Menu,
|
|
352
|
-
{
|
|
353
|
-
show: monthMenuOpen,
|
|
354
|
-
positionTo: monthMenuRef,
|
|
355
|
-
setShow: () => setMonthMenuOpen(false),
|
|
356
|
-
children: months.map((x) => [x, getMonthDataWith(x + 1)]).map(([x, m]) => /* @__PURE__ */ jsx(
|
|
357
|
-
MenuOption,
|
|
358
|
-
{
|
|
359
|
-
selected: baseMonth.month === x + 1,
|
|
360
|
-
onClick: () => {
|
|
361
|
-
setBaseMonth(baseMonth.with({ month: x + 1 }));
|
|
362
|
-
setMonthMenuOpen(false);
|
|
363
|
-
},
|
|
364
|
-
children: m.name
|
|
365
|
-
},
|
|
366
|
-
m.name
|
|
367
|
-
))
|
|
368
|
-
}
|
|
369
|
-
),
|
|
370
|
-
/* @__PURE__ */ jsx(
|
|
371
|
-
"button",
|
|
372
|
-
{
|
|
373
|
-
ref: (el) => {
|
|
374
|
-
yearMenuRef.current = el;
|
|
375
|
-
},
|
|
376
|
-
type: "button",
|
|
377
|
-
onClick: () => {
|
|
378
|
-
setYearMenuOpen(true);
|
|
379
|
-
setMonthMenuOpen(false);
|
|
380
|
-
},
|
|
381
|
-
className: "font-semibold text-text-action-primary-normal text-[14px] py-[2px] truncate",
|
|
382
|
-
children: month.year
|
|
383
|
-
}
|
|
384
|
-
),
|
|
385
|
-
/* @__PURE__ */ jsx(
|
|
386
|
-
Menu,
|
|
387
|
-
{
|
|
388
|
-
show: yearMenuOpen,
|
|
389
|
-
positionTo: yearMenuRef,
|
|
390
|
-
setShow: () => setYearMenuOpen(false),
|
|
391
|
-
children: years.map((y) => /* @__PURE__ */ jsx(
|
|
392
|
-
MenuOption,
|
|
393
|
-
{
|
|
394
|
-
selected: baseMonth.year === y,
|
|
395
|
-
onClick: () => {
|
|
396
|
-
setBaseMonth(baseMonth.with({ year: y }));
|
|
397
|
-
setYearMenuOpen(false);
|
|
398
|
-
},
|
|
399
|
-
children: y
|
|
400
|
-
},
|
|
401
|
-
y
|
|
402
|
-
))
|
|
403
|
-
}
|
|
404
|
-
)
|
|
405
|
-
] }),
|
|
406
|
-
(mode === "double" ? idx === 1 : true) ? /* @__PURE__ */ jsx(
|
|
407
|
-
"button",
|
|
408
|
-
{
|
|
409
|
-
id: id ? `${id}-next-month-button` : void 0,
|
|
410
|
-
"data-testid": testid ? `${testid}-next-month-button` : void 0,
|
|
411
|
-
type: "button",
|
|
412
|
-
className: clsx(
|
|
413
|
-
"flex items-center justify-center rounded-base hover:bg-action-100 active:bg-action-300 text-icon-action-primary-normal",
|
|
414
|
-
componentPadding
|
|
415
|
-
),
|
|
416
|
-
"aria-label": "Next month",
|
|
417
|
-
onClick: () => setBaseMonth(baseMonth.add({ months: 1 })),
|
|
418
|
-
children: /* @__PURE__ */ jsx(Icon, { name: "chevron_right", size: 24 })
|
|
419
|
-
}
|
|
420
|
-
) : /* @__PURE__ */ jsx("span", { className: clsx(componentPadding, "ml-1") })
|
|
421
|
-
]
|
|
422
|
-
}
|
|
423
|
-
),
|
|
424
|
-
/* @__PURE__ */ jsx("div", { className: clsx("grid grid-cols-7"), children: weekDays.map((d) => /* @__PURE__ */ jsx(
|
|
425
|
-
"span",
|
|
426
|
-
{
|
|
427
|
-
className: clsx(
|
|
428
|
-
typography.caption,
|
|
429
|
-
"text-text-secondary-normal text-center",
|
|
430
|
-
"w-10"
|
|
431
|
-
),
|
|
432
|
-
children: d
|
|
433
|
-
},
|
|
434
|
-
d
|
|
435
|
-
)) }),
|
|
436
|
-
/* @__PURE__ */ jsx("div", { className: clsx("grid grid-cols-7"), children: Array.from({ length: totalCells }).map((_, i) => {
|
|
437
|
-
const day = i - emptyCells + 1;
|
|
438
|
-
const date = month.date.with({ day: 1 }).add({
|
|
439
|
-
days: i - emptyCells
|
|
440
|
-
});
|
|
441
|
-
const isInMonth = day > 0 && day <= month.days;
|
|
442
|
-
const isToday = isInMonth && date.equals(today);
|
|
443
|
-
const isSelected = isInMonth && (!pendingFrom && fromDate && date.equals(fromDate) || !pendingFrom && toDate && date.equals(toDate) || pendingFrom && date.equals(pendingFrom));
|
|
444
|
-
const inRange = isInMonth && isInRange(date);
|
|
445
|
-
const isDisabled = !isInMonth || (isDateAvailable ? !isDateAvailable(date) : false);
|
|
446
|
-
const hoverDateIsBeforePendingFrom = hoveredDate && pendingFrom && Temporal.PlainDate.compare(hoveredDate, pendingFrom) < 0;
|
|
447
|
-
const hoverDateIsAfterPendingFrom = hoveredDate && pendingFrom && Temporal.PlainDate.compare(hoveredDate, pendingFrom) >= 0;
|
|
448
|
-
const isRangeStart = mode === "single" && disableRange ? false : !pendingFrom && isInMonth && fromDate && date.equals(fromDate) || hoverDateIsAfterPendingFrom && date.equals(pendingFrom);
|
|
449
|
-
const isRangeEnd = mode === "single" && disableRange ? false : !pendingFrom && isInMonth && toDate && date.equals(toDate) || hoverDateIsBeforePendingFrom && date.equals(pendingFrom);
|
|
450
|
-
return /* @__PURE__ */ jsx(
|
|
451
|
-
DateCell,
|
|
452
|
-
{
|
|
453
|
-
id: id ? `${id}-date-${date.toString()}` : void 0,
|
|
454
|
-
testid: testid ? `${testid}-date-${date.toString()}` : void 0,
|
|
455
|
-
date,
|
|
456
|
-
isInMonth: !!isInMonth,
|
|
457
|
-
isToday: !!isToday,
|
|
458
|
-
isSelected: !!isSelected,
|
|
459
|
-
inRange: !!inRange,
|
|
460
|
-
isDisabled: !!isDisabled,
|
|
461
|
-
onClick: () => handleDayClick(date),
|
|
462
|
-
onMouseEnter: () => setHoveredDate(date),
|
|
463
|
-
onMouseLeave: () => setHoveredDate(void 0),
|
|
464
|
-
isRangeStart: !!isRangeStart,
|
|
465
|
-
isRangeEnd: !!isRangeEnd,
|
|
466
|
-
isRangeDisabled: mode === "single" && disableRange,
|
|
467
|
-
cellPadding: componentPadding
|
|
468
|
-
},
|
|
469
|
-
i
|
|
470
|
-
);
|
|
471
|
-
}) })
|
|
472
|
-
]
|
|
473
|
-
}
|
|
474
|
-
),
|
|
475
|
-
mode === "double" && idx === 0 && /* @__PURE__ */ jsx(
|
|
476
|
-
"div",
|
|
477
|
-
{
|
|
478
|
-
className: clsx(
|
|
479
|
-
"self-stretch bg-border-primary-normal rounded-base",
|
|
480
|
-
// 1px width, full height, matches Figma divider
|
|
481
|
-
"w-px"
|
|
482
|
-
)
|
|
483
|
-
}
|
|
484
|
-
)
|
|
485
|
-
] }, month.name + month.year);
|
|
486
|
-
}
|
|
487
|
-
var CalendarRange_default = CalendarRange;
|
|
488
|
-
|
|
489
|
-
export {
|
|
490
|
-
isWeekend,
|
|
491
|
-
CalendarRange,
|
|
492
|
-
CalendarRange_default
|
|
493
|
-
};
|