@xsolla/xui-date-picker 0.117.0 → 0.118.0
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/README.md +28 -115
- package/native/index.d.mts +3 -70
- package/native/index.d.ts +3 -70
- package/native/index.js +41 -478
- package/native/index.js.flow +17 -97
- package/native/index.js.map +1 -1
- package/native/index.mjs +42 -495
- package/native/index.mjs.map +1 -1
- package/package.json +5 -6
- package/web/index.d.mts +3 -70
- package/web/index.d.ts +3 -70
- package/web/index.js +41 -448
- package/web/index.js.flow +17 -97
- package/web/index.js.map +1 -1
- package/web/index.mjs +42 -462
- package/web/index.mjs.map +1 -1
package/native/index.js
CHANGED
|
@@ -30,15 +30,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.tsx
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
Calendar: () => Calendar,
|
|
33
|
+
Calendar: () => import_xui_calendar2.Calendar,
|
|
34
|
+
CalendarChips: () => import_xui_calendar2.CalendarChips,
|
|
35
|
+
CalendarGrid: () => import_xui_calendar2.CalendarGrid,
|
|
36
|
+
CalendarHeader: () => import_xui_calendar2.CalendarHeader,
|
|
34
37
|
DatePicker: () => DatePicker,
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
DualCalendar: () => import_xui_calendar2.DualCalendar,
|
|
39
|
+
formatDate: () => formatDate
|
|
37
40
|
});
|
|
38
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
var import_xui_calendar2 = require("@xsolla/xui-calendar");
|
|
39
43
|
|
|
40
44
|
// src/DatePicker.tsx
|
|
41
|
-
var
|
|
45
|
+
var import_react = require("react");
|
|
42
46
|
|
|
43
47
|
// ../primitives-native/src/Box.tsx
|
|
44
48
|
var import_react_native = require("react-native");
|
|
@@ -206,468 +210,13 @@ var Box = ({
|
|
|
206
210
|
);
|
|
207
211
|
};
|
|
208
212
|
|
|
209
|
-
// ../primitives-native/src/Text.tsx
|
|
210
|
-
var import_react_native2 = require("react-native");
|
|
211
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
212
|
-
var roleMap = {
|
|
213
|
-
alert: "alert",
|
|
214
|
-
heading: "header",
|
|
215
|
-
button: "button",
|
|
216
|
-
link: "link",
|
|
217
|
-
text: "text"
|
|
218
|
-
};
|
|
219
|
-
var parseNumericValue = (value) => {
|
|
220
|
-
if (value === void 0) return void 0;
|
|
221
|
-
if (typeof value === "number") return value;
|
|
222
|
-
const parsed = parseFloat(value);
|
|
223
|
-
return isNaN(parsed) ? void 0 : parsed;
|
|
224
|
-
};
|
|
225
|
-
var Text = ({
|
|
226
|
-
children,
|
|
227
|
-
color,
|
|
228
|
-
fontSize,
|
|
229
|
-
fontWeight,
|
|
230
|
-
fontFamily,
|
|
231
|
-
textAlign,
|
|
232
|
-
lineHeight,
|
|
233
|
-
numberOfLines,
|
|
234
|
-
id,
|
|
235
|
-
role,
|
|
236
|
-
style: styleProp,
|
|
237
|
-
...props
|
|
238
|
-
}) => {
|
|
239
|
-
let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
|
|
240
|
-
if (resolvedFontFamily === "Pilat Wide" || resolvedFontFamily === "Pilat Wide Bold" || resolvedFontFamily === "Aktiv Grotesk") {
|
|
241
|
-
resolvedFontFamily = void 0;
|
|
242
|
-
}
|
|
243
|
-
const incomingStyle = import_react_native2.StyleSheet.flatten(styleProp);
|
|
244
|
-
const baseStyle = {
|
|
245
|
-
color,
|
|
246
|
-
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
247
|
-
fontWeight,
|
|
248
|
-
fontFamily: resolvedFontFamily,
|
|
249
|
-
textDecorationLine: props.textDecoration,
|
|
250
|
-
textAlign: textAlign ?? incomingStyle?.textAlign,
|
|
251
|
-
lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),
|
|
252
|
-
marginTop: parseNumericValue(
|
|
253
|
-
incomingStyle?.marginTop
|
|
254
|
-
),
|
|
255
|
-
marginBottom: parseNumericValue(
|
|
256
|
-
incomingStyle?.marginBottom
|
|
257
|
-
)
|
|
258
|
-
};
|
|
259
|
-
const accessibilityRole = role ? roleMap[role] : void 0;
|
|
260
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
261
|
-
import_react_native2.Text,
|
|
262
|
-
{
|
|
263
|
-
style: baseStyle,
|
|
264
|
-
numberOfLines,
|
|
265
|
-
testID: id,
|
|
266
|
-
accessibilityRole,
|
|
267
|
-
children
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
213
|
// src/DatePicker.tsx
|
|
273
214
|
var import_xui_input = require("@xsolla/xui-input");
|
|
274
|
-
var import_xui_core2 = require("@xsolla/xui-core");
|
|
275
|
-
var import_date_fns3 = require("date-fns");
|
|
276
|
-
|
|
277
|
-
// src/Calendar.tsx
|
|
278
|
-
var import_react2 = require("react");
|
|
279
215
|
var import_xui_core = require("@xsolla/xui-core");
|
|
280
|
-
var import_date_fns2 = require("date-fns");
|
|
281
|
-
var locales2 = __toESM(require("date-fns/locale"));
|
|
282
|
-
|
|
283
|
-
// src/CalendarHeader.tsx
|
|
284
|
-
var import_react = require("react");
|
|
285
|
-
var import_xui_button = require("@xsolla/xui-button");
|
|
286
|
-
var import_xui_select = require("@xsolla/xui-select");
|
|
287
|
-
|
|
288
|
-
// src/utils.ts
|
|
289
216
|
var import_date_fns = require("date-fns");
|
|
290
|
-
var
|
|
291
|
-
var
|
|
292
|
-
|
|
293
|
-
const localeObj = locales[locale] || locales[defaultLocale];
|
|
294
|
-
return (0, import_date_fns.format)(date, formatStr, {
|
|
295
|
-
locale: localeObj
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
function getMonthInLocale(month, locale = defaultLocale) {
|
|
299
|
-
return formatDate((0, import_date_fns.setMonth)(/* @__PURE__ */ new Date(), month), "LLLL", locale);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// src/CalendarHeader.tsx
|
|
303
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
304
|
-
var ArrowLeft = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
305
|
-
"svg",
|
|
306
|
-
{
|
|
307
|
-
viewBox: "0 0 24 24",
|
|
308
|
-
width: 16,
|
|
309
|
-
height: 16,
|
|
310
|
-
fill: "none",
|
|
311
|
-
stroke: "currentColor",
|
|
312
|
-
strokeWidth: "2",
|
|
313
|
-
strokeLinecap: "round",
|
|
314
|
-
strokeLinejoin: "round",
|
|
315
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "15 18 9 12 15 6" })
|
|
316
|
-
}
|
|
317
|
-
);
|
|
318
|
-
var ArrowRight = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
319
|
-
"svg",
|
|
320
|
-
{
|
|
321
|
-
viewBox: "0 0 24 24",
|
|
322
|
-
width: 16,
|
|
323
|
-
height: 16,
|
|
324
|
-
fill: "none",
|
|
325
|
-
stroke: "currentColor",
|
|
326
|
-
strokeWidth: "2",
|
|
327
|
-
strokeLinecap: "round",
|
|
328
|
-
strokeLinejoin: "round",
|
|
329
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "9 18 15 12 9 6" })
|
|
330
|
-
}
|
|
331
|
-
);
|
|
332
|
-
var months = [
|
|
333
|
-
"january",
|
|
334
|
-
"february",
|
|
335
|
-
"march",
|
|
336
|
-
"april",
|
|
337
|
-
"may",
|
|
338
|
-
"june",
|
|
339
|
-
"july",
|
|
340
|
-
"august",
|
|
341
|
-
"september",
|
|
342
|
-
"october",
|
|
343
|
-
"november",
|
|
344
|
-
"december"
|
|
345
|
-
];
|
|
346
|
-
var CalendarHeader = ({
|
|
347
|
-
monthDate,
|
|
348
|
-
decreaseMonth,
|
|
349
|
-
increaseMonth,
|
|
350
|
-
changeYear,
|
|
351
|
-
changeMonth,
|
|
352
|
-
prevMonthButtonDisabled,
|
|
353
|
-
nextMonthButtonDisabled,
|
|
354
|
-
locale,
|
|
355
|
-
minDate,
|
|
356
|
-
maxDate
|
|
357
|
-
}) => {
|
|
358
|
-
const handleChangeMonth = (0, import_react.useCallback)(
|
|
359
|
-
(value) => {
|
|
360
|
-
changeMonth(months.indexOf(value));
|
|
361
|
-
},
|
|
362
|
-
[changeMonth]
|
|
363
|
-
);
|
|
364
|
-
const handleChangeYear = (0, import_react.useCallback)(
|
|
365
|
-
(value) => {
|
|
366
|
-
changeYear(parseInt(value, 10));
|
|
367
|
-
},
|
|
368
|
-
[changeYear]
|
|
369
|
-
);
|
|
370
|
-
const monthOptions = (0, import_react.useMemo)(() => {
|
|
371
|
-
return months.map((month, index) => ({
|
|
372
|
-
label: getMonthInLocale(index, locale),
|
|
373
|
-
value: month
|
|
374
|
-
}));
|
|
375
|
-
}, [locale]);
|
|
376
|
-
const yearOptions = (0, import_react.useMemo)(() => {
|
|
377
|
-
const options = [];
|
|
378
|
-
const yearStart = minDate ? minDate.getFullYear() : 1900;
|
|
379
|
-
const yearEnd = maxDate ? maxDate.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear() + 100;
|
|
380
|
-
for (let i = yearEnd; i >= yearStart; i--) {
|
|
381
|
-
options.push({ value: i.toString(), label: i.toString() });
|
|
382
|
-
}
|
|
383
|
-
return options;
|
|
384
|
-
}, [minDate, maxDate]);
|
|
385
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
386
|
-
Box,
|
|
387
|
-
{
|
|
388
|
-
width: "100%",
|
|
389
|
-
flexDirection: "row",
|
|
390
|
-
justifyContent: "space-between",
|
|
391
|
-
alignItems: "center",
|
|
392
|
-
marginBottom: 16,
|
|
393
|
-
gap: 8,
|
|
394
|
-
children: [
|
|
395
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
396
|
-
import_xui_button.IconButton,
|
|
397
|
-
{
|
|
398
|
-
size: "xs",
|
|
399
|
-
tone: "mono",
|
|
400
|
-
variant: "secondary",
|
|
401
|
-
onPress: decreaseMonth,
|
|
402
|
-
disabled: prevMonthButtonDisabled,
|
|
403
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ArrowLeft, {}),
|
|
404
|
-
"aria-label": "Previous month"
|
|
405
|
-
}
|
|
406
|
-
),
|
|
407
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box, { flexDirection: "row", flex: 1, gap: 4, children: [
|
|
408
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { flex: 1.5, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
409
|
-
import_xui_select.Select,
|
|
410
|
-
{
|
|
411
|
-
value: months[monthDate.getMonth()],
|
|
412
|
-
onValueChange: handleChangeMonth,
|
|
413
|
-
options: monthOptions,
|
|
414
|
-
size: "sm"
|
|
415
|
-
}
|
|
416
|
-
) }),
|
|
417
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
418
|
-
import_xui_select.Select,
|
|
419
|
-
{
|
|
420
|
-
value: monthDate.getFullYear().toString(),
|
|
421
|
-
onValueChange: handleChangeYear,
|
|
422
|
-
options: yearOptions,
|
|
423
|
-
size: "sm"
|
|
424
|
-
}
|
|
425
|
-
) })
|
|
426
|
-
] }),
|
|
427
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
428
|
-
import_xui_button.IconButton,
|
|
429
|
-
{
|
|
430
|
-
size: "xs",
|
|
431
|
-
tone: "mono",
|
|
432
|
-
variant: "secondary",
|
|
433
|
-
onPress: increaseMonth,
|
|
434
|
-
disabled: nextMonthButtonDisabled,
|
|
435
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ArrowRight, {}),
|
|
436
|
-
"aria-label": "Next month"
|
|
437
|
-
}
|
|
438
|
-
)
|
|
439
|
-
]
|
|
440
|
-
}
|
|
441
|
-
);
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
// src/Calendar.tsx
|
|
445
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
446
|
-
var Calendar = (0, import_react2.forwardRef)(
|
|
447
|
-
({
|
|
448
|
-
locale = "enUS",
|
|
449
|
-
onChange,
|
|
450
|
-
startDate,
|
|
451
|
-
endDate,
|
|
452
|
-
selectedDate,
|
|
453
|
-
selectsRange = false,
|
|
454
|
-
contextMenuMaxHeight,
|
|
455
|
-
topContent,
|
|
456
|
-
bottomContent,
|
|
457
|
-
testID,
|
|
458
|
-
minDate,
|
|
459
|
-
maxDate,
|
|
460
|
-
firstDayOfWeek = 0,
|
|
461
|
-
month,
|
|
462
|
-
initialMonth
|
|
463
|
-
}, ref) => {
|
|
464
|
-
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
465
|
-
const localeObj = locales2[locale] || locales2.enUS;
|
|
466
|
-
const [currentMonth, setCurrentMonth] = (0, import_react2.useState)(
|
|
467
|
-
month || initialMonth || selectedDate || startDate || /* @__PURE__ */ new Date()
|
|
468
|
-
);
|
|
469
|
-
const [selectedStartDate, setSelectedStartDate] = (0, import_react2.useState)(startDate);
|
|
470
|
-
const [selectedEndDate, setSelectedEndDate] = (0, import_react2.useState)(endDate);
|
|
471
|
-
const [locSelectedDate, setLocSelectedDate] = (0, import_react2.useState)(selectedDate);
|
|
472
|
-
const [selectingRange, setSelectingRange] = (0, import_react2.useState)(null);
|
|
473
|
-
(0, import_react2.useEffect)(() => {
|
|
474
|
-
setSelectedStartDate(startDate);
|
|
475
|
-
setSelectedEndDate(endDate);
|
|
476
|
-
setLocSelectedDate(selectedDate);
|
|
477
|
-
if (month !== void 0) {
|
|
478
|
-
setCurrentMonth(month);
|
|
479
|
-
}
|
|
480
|
-
}, [startDate, endDate, selectedDate, month]);
|
|
481
|
-
const handleChange = (0, import_react2.useCallback)(
|
|
482
|
-
(date) => {
|
|
483
|
-
const newDate = new Date(
|
|
484
|
-
currentMonth.getFullYear(),
|
|
485
|
-
currentMonth.getMonth(),
|
|
486
|
-
date.getDate()
|
|
487
|
-
);
|
|
488
|
-
if (!selectsRange) {
|
|
489
|
-
setLocSelectedDate(newDate);
|
|
490
|
-
onChange?.(newDate);
|
|
491
|
-
} else {
|
|
492
|
-
if (!selectedStartDate || selectedStartDate && selectedEndDate) {
|
|
493
|
-
setSelectedStartDate(newDate);
|
|
494
|
-
setSelectedEndDate(null);
|
|
495
|
-
setSelectingRange(newDate);
|
|
496
|
-
onChange?.([newDate, null]);
|
|
497
|
-
} else {
|
|
498
|
-
const start = selectedStartDate < newDate ? selectedStartDate : newDate;
|
|
499
|
-
const end = selectedStartDate < newDate ? newDate : selectedStartDate;
|
|
500
|
-
setSelectedStartDate(start);
|
|
501
|
-
setSelectedEndDate(end);
|
|
502
|
-
setSelectingRange(null);
|
|
503
|
-
onChange?.([start, end]);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
[onChange, selectsRange, selectedStartDate, selectedEndDate, currentMonth]
|
|
508
|
-
);
|
|
509
|
-
const decreaseMonth = (0, import_react2.useCallback)(
|
|
510
|
-
() => setCurrentMonth((prev) => (0, import_date_fns2.subMonths)(prev, 1)),
|
|
511
|
-
[]
|
|
512
|
-
);
|
|
513
|
-
const increaseMonth = (0, import_react2.useCallback)(
|
|
514
|
-
() => setCurrentMonth((prev) => (0, import_date_fns2.addMonths)(prev, 1)),
|
|
515
|
-
[]
|
|
516
|
-
);
|
|
517
|
-
const changeMonth = (0, import_react2.useCallback)(
|
|
518
|
-
(m) => setCurrentMonth((prev) => new Date(prev.getFullYear(), m, 1)),
|
|
519
|
-
[]
|
|
520
|
-
);
|
|
521
|
-
const changeYear = (0, import_react2.useCallback)(
|
|
522
|
-
(y) => setCurrentMonth((prev) => new Date(y, prev.getMonth(), 1)),
|
|
523
|
-
[]
|
|
524
|
-
);
|
|
525
|
-
const monthStart = (0, import_date_fns2.startOfMonth)(currentMonth);
|
|
526
|
-
const monthEnd = (0, import_date_fns2.endOfMonth)(currentMonth);
|
|
527
|
-
const weekStartsOn = firstDayOfWeek ?? 0;
|
|
528
|
-
const calendarStart = (0, import_date_fns2.startOfWeek)(monthStart, { weekStartsOn });
|
|
529
|
-
const calendarEnd = (0, import_date_fns2.endOfWeek)(monthEnd, { weekStartsOn });
|
|
530
|
-
const days = (0, import_date_fns2.eachDayOfInterval)({ start: calendarStart, end: calendarEnd });
|
|
531
|
-
const weekDays = (0, import_react2.useMemo)(() => {
|
|
532
|
-
return Array.from({ length: 7 }, (_, i) => {
|
|
533
|
-
const day = (0, import_date_fns2.addDays)(calendarStart, i);
|
|
534
|
-
return (0, import_date_fns2.format)(day, "EEEEEE", { locale: localeObj });
|
|
535
|
-
});
|
|
536
|
-
}, [calendarStart, localeObj]);
|
|
537
|
-
const weeks = (0, import_react2.useMemo)(() => {
|
|
538
|
-
const weekArray = [];
|
|
539
|
-
for (let i = 0; i < days.length; i += 7) {
|
|
540
|
-
weekArray.push(days.slice(i, i + 7));
|
|
541
|
-
}
|
|
542
|
-
return weekArray;
|
|
543
|
-
}, [days]);
|
|
544
|
-
const isDateDisabled = (0, import_react2.useCallback)(
|
|
545
|
-
(date) => {
|
|
546
|
-
if (minDate && (0, import_date_fns2.isBefore)(date, (0, import_date_fns2.startOfDay)(minDate))) return true;
|
|
547
|
-
if (maxDate && (0, import_date_fns2.isAfter)(date, (0, import_date_fns2.endOfDay)(maxDate))) return true;
|
|
548
|
-
return false;
|
|
549
|
-
},
|
|
550
|
-
[minDate, maxDate]
|
|
551
|
-
);
|
|
552
|
-
const isDateInRange = (0, import_react2.useCallback)(
|
|
553
|
-
(date) => {
|
|
554
|
-
if (!selectsRange || !selectedStartDate) return false;
|
|
555
|
-
const rangeEnd = selectedEndDate || selectingRange;
|
|
556
|
-
if (!rangeEnd) return false;
|
|
557
|
-
const start = selectedStartDate < rangeEnd ? selectedStartDate : rangeEnd;
|
|
558
|
-
const end = selectedStartDate < rangeEnd ? rangeEnd : selectedStartDate;
|
|
559
|
-
return (0, import_date_fns2.isWithinInterval)(date, {
|
|
560
|
-
start: (0, import_date_fns2.startOfDay)(start),
|
|
561
|
-
end: (0, import_date_fns2.endOfDay)(end)
|
|
562
|
-
});
|
|
563
|
-
},
|
|
564
|
-
[selectsRange, selectedStartDate, selectedEndDate, selectingRange]
|
|
565
|
-
);
|
|
566
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
567
|
-
Box,
|
|
568
|
-
{
|
|
569
|
-
ref,
|
|
570
|
-
testID,
|
|
571
|
-
backgroundColor: theme.colors.background.secondary,
|
|
572
|
-
borderRadius: 8,
|
|
573
|
-
padding: 16,
|
|
574
|
-
overflow: "hidden",
|
|
575
|
-
style: {
|
|
576
|
-
boxShadow: "0px 4px 16px 0px rgba(7, 7, 8, 0.1)",
|
|
577
|
-
width: 312
|
|
578
|
-
},
|
|
579
|
-
children: [
|
|
580
|
-
topContent?.({ close: () => {
|
|
581
|
-
} }),
|
|
582
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
583
|
-
CalendarHeader,
|
|
584
|
-
{
|
|
585
|
-
monthDate: currentMonth,
|
|
586
|
-
decreaseMonth,
|
|
587
|
-
increaseMonth,
|
|
588
|
-
changeYear,
|
|
589
|
-
changeMonth,
|
|
590
|
-
locale,
|
|
591
|
-
minDate,
|
|
592
|
-
maxDate,
|
|
593
|
-
contextMenuMaxHeight
|
|
594
|
-
}
|
|
595
|
-
),
|
|
596
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
597
|
-
Box,
|
|
598
|
-
{
|
|
599
|
-
flexDirection: "row",
|
|
600
|
-
justifyContent: "space-between",
|
|
601
|
-
marginBottom: 8,
|
|
602
|
-
children: weekDays.map((day, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { width: 40, alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
603
|
-
Text,
|
|
604
|
-
{
|
|
605
|
-
fontSize: 12,
|
|
606
|
-
fontWeight: "600",
|
|
607
|
-
color: theme.colors.content.tertiary,
|
|
608
|
-
children: day.toUpperCase()
|
|
609
|
-
}
|
|
610
|
-
) }, i))
|
|
611
|
-
}
|
|
612
|
-
),
|
|
613
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { gap: 2, children: weeks.map((week, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { flexDirection: "row", justifyContent: "space-between", children: week.map((day, j) => {
|
|
614
|
-
const isOutsideMonth = !(0, import_date_fns2.isSameMonth)(day, currentMonth);
|
|
615
|
-
const isSelected = !selectsRange && locSelectedDate && (0, import_date_fns2.isSameDay)(day, locSelectedDate) || selectsRange && selectedStartDate && selectedEndDate && (0, import_date_fns2.isSameDay)(day, selectedStartDate) && (0, import_date_fns2.isSameDay)(day, selectedEndDate);
|
|
616
|
-
const isRangeStart = selectsRange && selectedStartDate && (0, import_date_fns2.isSameDay)(day, selectedStartDate);
|
|
617
|
-
const isRangeEnd = selectsRange && selectedEndDate && (0, import_date_fns2.isSameDay)(day, selectedEndDate);
|
|
618
|
-
const inRange = isDateInRange(day);
|
|
619
|
-
const today = (0, import_date_fns2.isToday)(day);
|
|
620
|
-
const disabled = isDateDisabled(day);
|
|
621
|
-
let bgColor = "transparent";
|
|
622
|
-
let textColor = theme.colors.content.primary;
|
|
623
|
-
if (isSelected || isRangeStart || isRangeEnd) {
|
|
624
|
-
bgColor = theme.colors.background.brand.primary;
|
|
625
|
-
textColor = theme.colors.content.on.brand;
|
|
626
|
-
} else if (inRange) {
|
|
627
|
-
bgColor = theme.colors.overlay.brand;
|
|
628
|
-
} else if (today) {
|
|
629
|
-
bgColor = theme.colors.overlay.mono;
|
|
630
|
-
}
|
|
631
|
-
if (isOutsideMonth || disabled) {
|
|
632
|
-
textColor = theme.colors.content.tertiary;
|
|
633
|
-
}
|
|
634
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
635
|
-
Box,
|
|
636
|
-
{
|
|
637
|
-
width: 40,
|
|
638
|
-
height: 32,
|
|
639
|
-
alignItems: "center",
|
|
640
|
-
justifyContent: "center",
|
|
641
|
-
borderRadius: isSelected || isRangeStart || isRangeEnd ? 4 : 0,
|
|
642
|
-
backgroundColor: bgColor,
|
|
643
|
-
cursor: disabled || isOutsideMonth ? "default" : "pointer",
|
|
644
|
-
onPress: () => !disabled && !isOutsideMonth && handleChange(day),
|
|
645
|
-
hoverStyle: !disabled && !isOutsideMonth && !isSelected ? { backgroundColor: theme.colors.overlay.mono } : void 0,
|
|
646
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
647
|
-
Text,
|
|
648
|
-
{
|
|
649
|
-
color: textColor,
|
|
650
|
-
fontSize: 14,
|
|
651
|
-
fontWeight: isSelected || isRangeStart || isRangeEnd ? "600" : "400",
|
|
652
|
-
children: (0, import_date_fns2.format)(day, "d")
|
|
653
|
-
}
|
|
654
|
-
)
|
|
655
|
-
},
|
|
656
|
-
j
|
|
657
|
-
);
|
|
658
|
-
}) }, i)) }),
|
|
659
|
-
bottomContent?.({ close: () => {
|
|
660
|
-
} })
|
|
661
|
-
]
|
|
662
|
-
}
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
);
|
|
666
|
-
Calendar.displayName = "Calendar";
|
|
667
|
-
|
|
668
|
-
// src/DatePicker.tsx
|
|
669
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
670
|
-
var DatePicker = (0, import_react3.forwardRef)(
|
|
217
|
+
var import_xui_calendar = require("@xsolla/xui-calendar");
|
|
218
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
219
|
+
var DatePicker = (0, import_react.forwardRef)(
|
|
671
220
|
({
|
|
672
221
|
onChange,
|
|
673
222
|
size = "md",
|
|
@@ -681,18 +230,18 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
681
230
|
testID,
|
|
682
231
|
...rest
|
|
683
232
|
}) => {
|
|
684
|
-
const [open, setOpen] = (0,
|
|
685
|
-
const [inputValue, setInputValue] = (0,
|
|
686
|
-
const containerRef = (0,
|
|
233
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
234
|
+
const [inputValue, setInputValue] = (0, import_react.useState)("");
|
|
235
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
687
236
|
const formatDateForDisplay = (date) => {
|
|
688
237
|
if (!date) return "";
|
|
689
238
|
try {
|
|
690
|
-
return (0,
|
|
239
|
+
return (0, import_date_fns.format)(date, "MM/dd/yyyy");
|
|
691
240
|
} catch {
|
|
692
241
|
return "";
|
|
693
242
|
}
|
|
694
243
|
};
|
|
695
|
-
const getDisplayValue = (0,
|
|
244
|
+
const getDisplayValue = (0, import_react.useCallback)(() => {
|
|
696
245
|
if (selectsRange) {
|
|
697
246
|
if (startDate && endDate) {
|
|
698
247
|
return `${formatDateForDisplay(startDate)} - ${formatDateForDisplay(endDate)}`;
|
|
@@ -704,7 +253,7 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
704
253
|
return formatDateForDisplay(selectedDate);
|
|
705
254
|
}
|
|
706
255
|
}, [selectsRange, startDate, endDate, selectedDate]);
|
|
707
|
-
(0,
|
|
256
|
+
(0, import_react.useEffect)(() => {
|
|
708
257
|
setInputValue(getDisplayValue());
|
|
709
258
|
}, [getDisplayValue]);
|
|
710
259
|
const handleInputChange = (text) => {
|
|
@@ -722,8 +271,8 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
722
271
|
}
|
|
723
272
|
}
|
|
724
273
|
};
|
|
725
|
-
(0,
|
|
726
|
-
if (
|
|
274
|
+
(0, import_react.useEffect)(() => {
|
|
275
|
+
if (import_xui_core.isNative) return;
|
|
727
276
|
const handleClickOutside = (event) => {
|
|
728
277
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
729
278
|
setOpen(false);
|
|
@@ -732,8 +281,8 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
732
281
|
document.addEventListener("mousedown", handleClickOutside);
|
|
733
282
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
734
283
|
}, []);
|
|
735
|
-
const renderCalendar = () => /* @__PURE__ */ (0,
|
|
736
|
-
Calendar,
|
|
284
|
+
const renderCalendar = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
285
|
+
import_xui_calendar.Calendar,
|
|
737
286
|
{
|
|
738
287
|
locale,
|
|
739
288
|
startDate,
|
|
@@ -744,8 +293,8 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
744
293
|
...rest
|
|
745
294
|
}
|
|
746
295
|
);
|
|
747
|
-
return /* @__PURE__ */ (0,
|
|
748
|
-
/* @__PURE__ */ (0,
|
|
296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box, { ref: containerRef, position: "relative", width: "100%", children: [
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
749
298
|
import_xui_input.Input,
|
|
750
299
|
{
|
|
751
300
|
...rest,
|
|
@@ -758,7 +307,7 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
758
307
|
testID
|
|
759
308
|
}
|
|
760
309
|
),
|
|
761
|
-
open && (
|
|
310
|
+
open && (import_xui_core.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
762
311
|
Box,
|
|
763
312
|
{
|
|
764
313
|
position: "absolute",
|
|
@@ -772,17 +321,31 @@ var DatePicker = (0, import_react3.forwardRef)(
|
|
|
772
321
|
// Native implementation could use a Modal here
|
|
773
322
|
// For now, we just show it below the input if needed,
|
|
774
323
|
// but usually a bottom sheet or centered modal is better.
|
|
775
|
-
/* @__PURE__ */ (0,
|
|
324
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box, { marginTop: 4, children: renderCalendar() })
|
|
776
325
|
))
|
|
777
326
|
] });
|
|
778
327
|
}
|
|
779
328
|
);
|
|
780
329
|
DatePicker.displayName = "DatePicker";
|
|
330
|
+
|
|
331
|
+
// src/utils.ts
|
|
332
|
+
var import_date_fns2 = require("date-fns");
|
|
333
|
+
var locales = __toESM(require("date-fns/locale"));
|
|
334
|
+
var defaultLocale = "enUS";
|
|
335
|
+
function formatDate(date, formatStr, locale = defaultLocale) {
|
|
336
|
+
const localeObj = locales[locale] || locales[defaultLocale];
|
|
337
|
+
return (0, import_date_fns2.format)(date, formatStr, {
|
|
338
|
+
locale: localeObj
|
|
339
|
+
});
|
|
340
|
+
}
|
|
781
341
|
// Annotate the CommonJS export names for ESM import in node:
|
|
782
342
|
0 && (module.exports = {
|
|
783
343
|
Calendar,
|
|
344
|
+
CalendarChips,
|
|
345
|
+
CalendarGrid,
|
|
346
|
+
CalendarHeader,
|
|
784
347
|
DatePicker,
|
|
785
|
-
|
|
786
|
-
|
|
348
|
+
DualCalendar,
|
|
349
|
+
formatDate
|
|
787
350
|
});
|
|
788
351
|
//# sourceMappingURL=index.js.map
|