@xsolla/xui-date-picker 0.87.0 → 0.89.0-pr137.1770210437
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/native/index.js +57 -310
- package/native/index.js.map +1 -1
- package/native/index.mjs +27 -280
- package/native/index.mjs.map +1 -1
- package/package.json +7 -6
- package/web/index.js +57 -304
- package/web/index.js.map +1 -1
- package/web/index.mjs +27 -274
- package/web/index.mjs.map +1 -1
package/native/index.js
CHANGED
|
@@ -38,7 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
39
|
|
|
40
40
|
// src/DatePicker.tsx
|
|
41
|
-
var
|
|
41
|
+
var import_react3 = require("react");
|
|
42
42
|
|
|
43
43
|
// ../primitives-native/src/Box.tsx
|
|
44
44
|
var import_react_native = require("react-native");
|
|
@@ -241,272 +241,19 @@ var Text = ({
|
|
|
241
241
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
|
|
242
242
|
};
|
|
243
243
|
|
|
244
|
-
// ../primitives-native/src/Spinner.tsx
|
|
245
|
-
var import_react_native3 = require("react-native");
|
|
246
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
247
|
-
var Spinner = ({
|
|
248
|
-
color,
|
|
249
|
-
size,
|
|
250
|
-
role,
|
|
251
|
-
"aria-label": ariaLabel,
|
|
252
|
-
"aria-live": ariaLive,
|
|
253
|
-
testID
|
|
254
|
-
}) => {
|
|
255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
256
|
-
import_react_native3.View,
|
|
257
|
-
{
|
|
258
|
-
accessible: true,
|
|
259
|
-
accessibilityRole: role === "status" ? "none" : void 0,
|
|
260
|
-
accessibilityLabel: ariaLabel,
|
|
261
|
-
accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
|
|
262
|
-
testID,
|
|
263
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
264
|
-
import_react_native3.ActivityIndicator,
|
|
265
|
-
{
|
|
266
|
-
color,
|
|
267
|
-
size: typeof size === "number" ? size : "small"
|
|
268
|
-
}
|
|
269
|
-
)
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
};
|
|
273
|
-
Spinner.displayName = "Spinner";
|
|
274
|
-
|
|
275
|
-
// ../primitives-native/src/Icon.tsx
|
|
276
|
-
var import_react = __toESM(require("react"));
|
|
277
|
-
var import_react_native4 = require("react-native");
|
|
278
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
279
|
-
|
|
280
|
-
// ../primitives-native/src/Divider.tsx
|
|
281
|
-
var import_react_native5 = require("react-native");
|
|
282
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
283
|
-
|
|
284
|
-
// ../primitives-native/src/Input.tsx
|
|
285
|
-
var import_react2 = require("react");
|
|
286
|
-
var import_react_native6 = require("react-native");
|
|
287
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
288
|
-
var keyboardTypeMap = {
|
|
289
|
-
text: "default",
|
|
290
|
-
number: "numeric",
|
|
291
|
-
email: "email-address",
|
|
292
|
-
tel: "phone-pad",
|
|
293
|
-
url: "url",
|
|
294
|
-
decimal: "decimal-pad"
|
|
295
|
-
};
|
|
296
|
-
var inputModeToKeyboardType = {
|
|
297
|
-
none: "default",
|
|
298
|
-
text: "default",
|
|
299
|
-
decimal: "decimal-pad",
|
|
300
|
-
numeric: "number-pad",
|
|
301
|
-
tel: "phone-pad",
|
|
302
|
-
search: "default",
|
|
303
|
-
email: "email-address",
|
|
304
|
-
url: "url"
|
|
305
|
-
};
|
|
306
|
-
var autoCompleteToTextContentType = {
|
|
307
|
-
"one-time-code": "oneTimeCode",
|
|
308
|
-
email: "emailAddress",
|
|
309
|
-
username: "username",
|
|
310
|
-
password: "password",
|
|
311
|
-
"new-password": "newPassword",
|
|
312
|
-
tel: "telephoneNumber",
|
|
313
|
-
"postal-code": "postalCode",
|
|
314
|
-
name: "name"
|
|
315
|
-
};
|
|
316
|
-
var InputPrimitive = (0, import_react2.forwardRef)(
|
|
317
|
-
({
|
|
318
|
-
value,
|
|
319
|
-
placeholder,
|
|
320
|
-
onChange,
|
|
321
|
-
onChangeText,
|
|
322
|
-
onFocus,
|
|
323
|
-
onBlur,
|
|
324
|
-
onKeyDown,
|
|
325
|
-
disabled,
|
|
326
|
-
secureTextEntry,
|
|
327
|
-
style,
|
|
328
|
-
color,
|
|
329
|
-
fontSize,
|
|
330
|
-
placeholderTextColor,
|
|
331
|
-
maxLength,
|
|
332
|
-
type,
|
|
333
|
-
inputMode,
|
|
334
|
-
autoComplete,
|
|
335
|
-
id,
|
|
336
|
-
"aria-describedby": ariaDescribedBy,
|
|
337
|
-
"aria-label": ariaLabel,
|
|
338
|
-
"aria-disabled": ariaDisabled,
|
|
339
|
-
"data-testid": dataTestId
|
|
340
|
-
}, ref) => {
|
|
341
|
-
const handleChangeText = (text) => {
|
|
342
|
-
onChangeText?.(text);
|
|
343
|
-
if (onChange) {
|
|
344
|
-
const syntheticEvent = {
|
|
345
|
-
target: { value: text },
|
|
346
|
-
currentTarget: { value: text },
|
|
347
|
-
type: "change",
|
|
348
|
-
nativeEvent: { text },
|
|
349
|
-
preventDefault: () => {
|
|
350
|
-
},
|
|
351
|
-
stopPropagation: () => {
|
|
352
|
-
},
|
|
353
|
-
isTrusted: false
|
|
354
|
-
};
|
|
355
|
-
onChange(syntheticEvent);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
|
|
359
|
-
const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
|
|
360
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
361
|
-
import_react_native6.TextInput,
|
|
362
|
-
{
|
|
363
|
-
ref,
|
|
364
|
-
value,
|
|
365
|
-
placeholder,
|
|
366
|
-
onChangeText: handleChangeText,
|
|
367
|
-
onFocus,
|
|
368
|
-
onBlur,
|
|
369
|
-
onKeyPress: (e) => {
|
|
370
|
-
if (onKeyDown) {
|
|
371
|
-
onKeyDown({
|
|
372
|
-
key: e.nativeEvent.key,
|
|
373
|
-
preventDefault: () => {
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
editable: !disabled,
|
|
379
|
-
secureTextEntry: secureTextEntry || type === "password",
|
|
380
|
-
keyboardType,
|
|
381
|
-
textContentType,
|
|
382
|
-
style: [
|
|
383
|
-
{
|
|
384
|
-
color,
|
|
385
|
-
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
386
|
-
flex: 1,
|
|
387
|
-
padding: 0,
|
|
388
|
-
textAlign: style?.textAlign || "left"
|
|
389
|
-
},
|
|
390
|
-
style
|
|
391
|
-
],
|
|
392
|
-
placeholderTextColor,
|
|
393
|
-
maxLength,
|
|
394
|
-
testID: dataTestId || id,
|
|
395
|
-
accessibilityLabel: ariaLabel,
|
|
396
|
-
accessibilityHint: ariaDescribedBy,
|
|
397
|
-
accessibilityState: {
|
|
398
|
-
disabled: disabled || ariaDisabled
|
|
399
|
-
},
|
|
400
|
-
accessible: true
|
|
401
|
-
}
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
);
|
|
405
|
-
InputPrimitive.displayName = "InputPrimitive";
|
|
406
|
-
|
|
407
|
-
// ../primitives-native/src/TextArea.tsx
|
|
408
|
-
var import_react3 = require("react");
|
|
409
|
-
var import_react_native7 = require("react-native");
|
|
410
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
411
|
-
var TextAreaPrimitive = (0, import_react3.forwardRef)(
|
|
412
|
-
({
|
|
413
|
-
value,
|
|
414
|
-
placeholder,
|
|
415
|
-
onChange,
|
|
416
|
-
onChangeText,
|
|
417
|
-
onFocus,
|
|
418
|
-
onBlur,
|
|
419
|
-
onKeyDown,
|
|
420
|
-
disabled,
|
|
421
|
-
style,
|
|
422
|
-
color,
|
|
423
|
-
fontSize,
|
|
424
|
-
placeholderTextColor,
|
|
425
|
-
maxLength,
|
|
426
|
-
rows,
|
|
427
|
-
id,
|
|
428
|
-
"aria-describedby": ariaDescribedBy,
|
|
429
|
-
"aria-label": ariaLabel,
|
|
430
|
-
"aria-disabled": ariaDisabled,
|
|
431
|
-
"data-testid": dataTestId
|
|
432
|
-
}, ref) => {
|
|
433
|
-
const handleChangeText = (text) => {
|
|
434
|
-
onChangeText?.(text);
|
|
435
|
-
if (onChange) {
|
|
436
|
-
const syntheticEvent = {
|
|
437
|
-
target: { value: text },
|
|
438
|
-
currentTarget: { value: text },
|
|
439
|
-
type: "change",
|
|
440
|
-
nativeEvent: { text },
|
|
441
|
-
preventDefault: () => {
|
|
442
|
-
},
|
|
443
|
-
stopPropagation: () => {
|
|
444
|
-
},
|
|
445
|
-
isTrusted: false
|
|
446
|
-
};
|
|
447
|
-
onChange(syntheticEvent);
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
451
|
-
import_react_native7.TextInput,
|
|
452
|
-
{
|
|
453
|
-
ref,
|
|
454
|
-
value,
|
|
455
|
-
placeholder,
|
|
456
|
-
onChangeText: handleChangeText,
|
|
457
|
-
onFocus,
|
|
458
|
-
onBlur,
|
|
459
|
-
onKeyPress: (e) => {
|
|
460
|
-
if (onKeyDown) {
|
|
461
|
-
onKeyDown({
|
|
462
|
-
key: e.nativeEvent.key,
|
|
463
|
-
preventDefault: () => {
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
},
|
|
468
|
-
editable: !disabled,
|
|
469
|
-
multiline: true,
|
|
470
|
-
numberOfLines: rows || 4,
|
|
471
|
-
style: [
|
|
472
|
-
{
|
|
473
|
-
color,
|
|
474
|
-
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
475
|
-
flex: 1,
|
|
476
|
-
padding: 0,
|
|
477
|
-
textAlignVertical: "top",
|
|
478
|
-
textAlign: style?.textAlign || "left"
|
|
479
|
-
},
|
|
480
|
-
style
|
|
481
|
-
],
|
|
482
|
-
placeholderTextColor,
|
|
483
|
-
maxLength,
|
|
484
|
-
testID: dataTestId || id,
|
|
485
|
-
accessibilityLabel: ariaLabel,
|
|
486
|
-
accessibilityHint: ariaDescribedBy,
|
|
487
|
-
accessibilityState: {
|
|
488
|
-
disabled: disabled || ariaDisabled
|
|
489
|
-
},
|
|
490
|
-
accessible: true
|
|
491
|
-
}
|
|
492
|
-
);
|
|
493
|
-
}
|
|
494
|
-
);
|
|
495
|
-
TextAreaPrimitive.displayName = "TextAreaPrimitive";
|
|
496
|
-
|
|
497
244
|
// src/DatePicker.tsx
|
|
498
245
|
var import_xui_input = require("@xsolla/xui-input");
|
|
499
246
|
var import_xui_core2 = require("@xsolla/xui-core");
|
|
500
247
|
var import_date_fns3 = require("date-fns");
|
|
501
248
|
|
|
502
249
|
// src/Calendar.tsx
|
|
503
|
-
var
|
|
250
|
+
var import_react2 = require("react");
|
|
504
251
|
var import_xui_core = require("@xsolla/xui-core");
|
|
505
252
|
var import_date_fns2 = require("date-fns");
|
|
506
253
|
var locales2 = __toESM(require("date-fns/locale"));
|
|
507
254
|
|
|
508
255
|
// src/CalendarHeader.tsx
|
|
509
|
-
var
|
|
256
|
+
var import_react = require("react");
|
|
510
257
|
var import_xui_button = require("@xsolla/xui-button");
|
|
511
258
|
var import_xui_select = require("@xsolla/xui-select");
|
|
512
259
|
|
|
@@ -525,8 +272,8 @@ function getMonthInLocale(month, locale = defaultLocale) {
|
|
|
525
272
|
}
|
|
526
273
|
|
|
527
274
|
// src/CalendarHeader.tsx
|
|
528
|
-
var
|
|
529
|
-
var ArrowLeft = () => /* @__PURE__ */ (0,
|
|
275
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
276
|
+
var ArrowLeft = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
530
277
|
"svg",
|
|
531
278
|
{
|
|
532
279
|
viewBox: "0 0 24 24",
|
|
@@ -537,10 +284,10 @@ var ArrowLeft = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
|
537
284
|
strokeWidth: "2",
|
|
538
285
|
strokeLinecap: "round",
|
|
539
286
|
strokeLinejoin: "round",
|
|
540
|
-
children: /* @__PURE__ */ (0,
|
|
287
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "15 18 9 12 15 6" })
|
|
541
288
|
}
|
|
542
289
|
);
|
|
543
|
-
var ArrowRight = () => /* @__PURE__ */ (0,
|
|
290
|
+
var ArrowRight = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
544
291
|
"svg",
|
|
545
292
|
{
|
|
546
293
|
viewBox: "0 0 24 24",
|
|
@@ -551,7 +298,7 @@ var ArrowRight = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
|
551
298
|
strokeWidth: "2",
|
|
552
299
|
strokeLinecap: "round",
|
|
553
300
|
strokeLinejoin: "round",
|
|
554
|
-
children: /* @__PURE__ */ (0,
|
|
301
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "9 18 15 12 9 6" })
|
|
555
302
|
}
|
|
556
303
|
);
|
|
557
304
|
var months = [
|
|
@@ -580,25 +327,25 @@ var CalendarHeader = ({
|
|
|
580
327
|
minDate,
|
|
581
328
|
maxDate
|
|
582
329
|
}) => {
|
|
583
|
-
const handleChangeMonth = (0,
|
|
330
|
+
const handleChangeMonth = (0, import_react.useCallback)(
|
|
584
331
|
(value) => {
|
|
585
332
|
changeMonth(months.indexOf(value));
|
|
586
333
|
},
|
|
587
334
|
[changeMonth]
|
|
588
335
|
);
|
|
589
|
-
const handleChangeYear = (0,
|
|
336
|
+
const handleChangeYear = (0, import_react.useCallback)(
|
|
590
337
|
(value) => {
|
|
591
338
|
changeYear(parseInt(value, 10));
|
|
592
339
|
},
|
|
593
340
|
[changeYear]
|
|
594
341
|
);
|
|
595
|
-
const monthOptions = (0,
|
|
342
|
+
const monthOptions = (0, import_react.useMemo)(() => {
|
|
596
343
|
return months.map((month, index) => ({
|
|
597
344
|
label: getMonthInLocale(index, locale),
|
|
598
345
|
value: month
|
|
599
346
|
}));
|
|
600
347
|
}, [locale]);
|
|
601
|
-
const yearOptions = (0,
|
|
348
|
+
const yearOptions = (0, import_react.useMemo)(() => {
|
|
602
349
|
const options = [];
|
|
603
350
|
const yearStart = minDate ? minDate.getFullYear() : 1900;
|
|
604
351
|
const yearEnd = maxDate ? maxDate.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear() + 100;
|
|
@@ -607,7 +354,7 @@ var CalendarHeader = ({
|
|
|
607
354
|
}
|
|
608
355
|
return options;
|
|
609
356
|
}, [minDate, maxDate]);
|
|
610
|
-
return /* @__PURE__ */ (0,
|
|
357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
611
358
|
Box,
|
|
612
359
|
{
|
|
613
360
|
width: "100%",
|
|
@@ -617,7 +364,7 @@ var CalendarHeader = ({
|
|
|
617
364
|
marginBottom: 16,
|
|
618
365
|
gap: 8,
|
|
619
366
|
children: [
|
|
620
|
-
/* @__PURE__ */ (0,
|
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
621
368
|
import_xui_button.IconButton,
|
|
622
369
|
{
|
|
623
370
|
size: "xs",
|
|
@@ -625,12 +372,12 @@ var CalendarHeader = ({
|
|
|
625
372
|
variant: "secondary",
|
|
626
373
|
onPress: decreaseMonth,
|
|
627
374
|
disabled: prevMonthButtonDisabled,
|
|
628
|
-
icon: /* @__PURE__ */ (0,
|
|
375
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ArrowLeft, {}),
|
|
629
376
|
"aria-label": "Previous month"
|
|
630
377
|
}
|
|
631
378
|
),
|
|
632
|
-
/* @__PURE__ */ (0,
|
|
633
|
-
/* @__PURE__ */ (0,
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box, { flexDirection: "row", flex: 1, gap: 4, children: [
|
|
380
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { flex: 1.5, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
634
381
|
import_xui_select.Select,
|
|
635
382
|
{
|
|
636
383
|
value: months[monthDate.getMonth()],
|
|
@@ -639,7 +386,7 @@ var CalendarHeader = ({
|
|
|
639
386
|
size: "sm"
|
|
640
387
|
}
|
|
641
388
|
) }),
|
|
642
|
-
/* @__PURE__ */ (0,
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
643
390
|
import_xui_select.Select,
|
|
644
391
|
{
|
|
645
392
|
value: monthDate.getFullYear().toString(),
|
|
@@ -649,7 +396,7 @@ var CalendarHeader = ({
|
|
|
649
396
|
}
|
|
650
397
|
) })
|
|
651
398
|
] }),
|
|
652
|
-
/* @__PURE__ */ (0,
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
653
400
|
import_xui_button.IconButton,
|
|
654
401
|
{
|
|
655
402
|
size: "xs",
|
|
@@ -657,7 +404,7 @@ var CalendarHeader = ({
|
|
|
657
404
|
variant: "secondary",
|
|
658
405
|
onPress: increaseMonth,
|
|
659
406
|
disabled: nextMonthButtonDisabled,
|
|
660
|
-
icon: /* @__PURE__ */ (0,
|
|
407
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ArrowRight, {}),
|
|
661
408
|
"aria-label": "Next month"
|
|
662
409
|
}
|
|
663
410
|
)
|
|
@@ -667,8 +414,8 @@ var CalendarHeader = ({
|
|
|
667
414
|
};
|
|
668
415
|
|
|
669
416
|
// src/Calendar.tsx
|
|
670
|
-
var
|
|
671
|
-
var Calendar = (0,
|
|
417
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
418
|
+
var Calendar = (0, import_react2.forwardRef)(
|
|
672
419
|
({
|
|
673
420
|
locale = "enUS",
|
|
674
421
|
onChange,
|
|
@@ -688,14 +435,14 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
688
435
|
}, ref) => {
|
|
689
436
|
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
690
437
|
const localeObj = locales2[locale] || locales2.enUS;
|
|
691
|
-
const [currentMonth, setCurrentMonth] = (0,
|
|
438
|
+
const [currentMonth, setCurrentMonth] = (0, import_react2.useState)(
|
|
692
439
|
month || initialMonth || selectedDate || startDate || /* @__PURE__ */ new Date()
|
|
693
440
|
);
|
|
694
|
-
const [selectedStartDate, setSelectedStartDate] = (0,
|
|
695
|
-
const [selectedEndDate, setSelectedEndDate] = (0,
|
|
696
|
-
const [locSelectedDate, setLocSelectedDate] = (0,
|
|
697
|
-
const [selectingRange, setSelectingRange] = (0,
|
|
698
|
-
(0,
|
|
441
|
+
const [selectedStartDate, setSelectedStartDate] = (0, import_react2.useState)(startDate);
|
|
442
|
+
const [selectedEndDate, setSelectedEndDate] = (0, import_react2.useState)(endDate);
|
|
443
|
+
const [locSelectedDate, setLocSelectedDate] = (0, import_react2.useState)(selectedDate);
|
|
444
|
+
const [selectingRange, setSelectingRange] = (0, import_react2.useState)(null);
|
|
445
|
+
(0, import_react2.useEffect)(() => {
|
|
699
446
|
setSelectedStartDate(startDate);
|
|
700
447
|
setSelectedEndDate(endDate);
|
|
701
448
|
setLocSelectedDate(selectedDate);
|
|
@@ -703,7 +450,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
703
450
|
setCurrentMonth(month);
|
|
704
451
|
}
|
|
705
452
|
}, [startDate, endDate, selectedDate, month]);
|
|
706
|
-
const handleChange = (0,
|
|
453
|
+
const handleChange = (0, import_react2.useCallback)(
|
|
707
454
|
(date) => {
|
|
708
455
|
const newDate = new Date(
|
|
709
456
|
currentMonth.getFullYear(),
|
|
@@ -731,19 +478,19 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
731
478
|
},
|
|
732
479
|
[onChange, selectsRange, selectedStartDate, selectedEndDate, currentMonth]
|
|
733
480
|
);
|
|
734
|
-
const decreaseMonth = (0,
|
|
481
|
+
const decreaseMonth = (0, import_react2.useCallback)(
|
|
735
482
|
() => setCurrentMonth((prev) => (0, import_date_fns2.subMonths)(prev, 1)),
|
|
736
483
|
[]
|
|
737
484
|
);
|
|
738
|
-
const increaseMonth = (0,
|
|
485
|
+
const increaseMonth = (0, import_react2.useCallback)(
|
|
739
486
|
() => setCurrentMonth((prev) => (0, import_date_fns2.addMonths)(prev, 1)),
|
|
740
487
|
[]
|
|
741
488
|
);
|
|
742
|
-
const changeMonth = (0,
|
|
489
|
+
const changeMonth = (0, import_react2.useCallback)(
|
|
743
490
|
(m) => setCurrentMonth((prev) => new Date(prev.getFullYear(), m, 1)),
|
|
744
491
|
[]
|
|
745
492
|
);
|
|
746
|
-
const changeYear = (0,
|
|
493
|
+
const changeYear = (0, import_react2.useCallback)(
|
|
747
494
|
(y) => setCurrentMonth((prev) => new Date(y, prev.getMonth(), 1)),
|
|
748
495
|
[]
|
|
749
496
|
);
|
|
@@ -753,20 +500,20 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
753
500
|
const calendarStart = (0, import_date_fns2.startOfWeek)(monthStart, { weekStartsOn });
|
|
754
501
|
const calendarEnd = (0, import_date_fns2.endOfWeek)(monthEnd, { weekStartsOn });
|
|
755
502
|
const days = (0, import_date_fns2.eachDayOfInterval)({ start: calendarStart, end: calendarEnd });
|
|
756
|
-
const weekDays = (0,
|
|
503
|
+
const weekDays = (0, import_react2.useMemo)(() => {
|
|
757
504
|
return Array.from({ length: 7 }, (_, i) => {
|
|
758
505
|
const day = (0, import_date_fns2.addDays)(calendarStart, i);
|
|
759
506
|
return (0, import_date_fns2.format)(day, "EEEEEE", { locale: localeObj });
|
|
760
507
|
});
|
|
761
508
|
}, [calendarStart, localeObj]);
|
|
762
|
-
const weeks = (0,
|
|
509
|
+
const weeks = (0, import_react2.useMemo)(() => {
|
|
763
510
|
const weekArray = [];
|
|
764
511
|
for (let i = 0; i < days.length; i += 7) {
|
|
765
512
|
weekArray.push(days.slice(i, i + 7));
|
|
766
513
|
}
|
|
767
514
|
return weekArray;
|
|
768
515
|
}, [days]);
|
|
769
|
-
const isDateDisabled = (0,
|
|
516
|
+
const isDateDisabled = (0, import_react2.useCallback)(
|
|
770
517
|
(date) => {
|
|
771
518
|
if (minDate && (0, import_date_fns2.isBefore)(date, (0, import_date_fns2.startOfDay)(minDate))) return true;
|
|
772
519
|
if (maxDate && (0, import_date_fns2.isAfter)(date, (0, import_date_fns2.endOfDay)(maxDate))) return true;
|
|
@@ -774,7 +521,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
774
521
|
},
|
|
775
522
|
[minDate, maxDate]
|
|
776
523
|
);
|
|
777
|
-
const isDateInRange = (0,
|
|
524
|
+
const isDateInRange = (0, import_react2.useCallback)(
|
|
778
525
|
(date) => {
|
|
779
526
|
if (!selectsRange || !selectedStartDate) return false;
|
|
780
527
|
const rangeEnd = selectedEndDate || selectingRange;
|
|
@@ -788,7 +535,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
788
535
|
},
|
|
789
536
|
[selectsRange, selectedStartDate, selectedEndDate, selectingRange]
|
|
790
537
|
);
|
|
791
|
-
return /* @__PURE__ */ (0,
|
|
538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
792
539
|
Box,
|
|
793
540
|
{
|
|
794
541
|
ref,
|
|
@@ -804,7 +551,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
804
551
|
children: [
|
|
805
552
|
topContent?.({ close: () => {
|
|
806
553
|
} }),
|
|
807
|
-
/* @__PURE__ */ (0,
|
|
554
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
808
555
|
CalendarHeader,
|
|
809
556
|
{
|
|
810
557
|
monthDate: currentMonth,
|
|
@@ -818,13 +565,13 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
818
565
|
contextMenuMaxHeight
|
|
819
566
|
}
|
|
820
567
|
),
|
|
821
|
-
/* @__PURE__ */ (0,
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
822
569
|
Box,
|
|
823
570
|
{
|
|
824
571
|
flexDirection: "row",
|
|
825
572
|
justifyContent: "space-between",
|
|
826
573
|
marginBottom: 8,
|
|
827
|
-
children: weekDays.map((day, i) => /* @__PURE__ */ (0,
|
|
574
|
+
children: weekDays.map((day, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { width: 40, alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
828
575
|
Text,
|
|
829
576
|
{
|
|
830
577
|
fontSize: 12,
|
|
@@ -835,7 +582,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
835
582
|
) }, i))
|
|
836
583
|
}
|
|
837
584
|
),
|
|
838
|
-
/* @__PURE__ */ (0,
|
|
585
|
+
/* @__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) => {
|
|
839
586
|
const isOutsideMonth = !(0, import_date_fns2.isSameMonth)(day, currentMonth);
|
|
840
587
|
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);
|
|
841
588
|
const isRangeStart = selectsRange && selectedStartDate && (0, import_date_fns2.isSameDay)(day, selectedStartDate);
|
|
@@ -856,7 +603,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
856
603
|
if (isOutsideMonth || disabled) {
|
|
857
604
|
textColor = theme.colors.content.tertiary;
|
|
858
605
|
}
|
|
859
|
-
return /* @__PURE__ */ (0,
|
|
606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
860
607
|
Box,
|
|
861
608
|
{
|
|
862
609
|
width: 40,
|
|
@@ -868,7 +615,7 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
868
615
|
cursor: disabled || isOutsideMonth ? "default" : "pointer",
|
|
869
616
|
onPress: () => !disabled && !isOutsideMonth && handleChange(day),
|
|
870
617
|
hoverStyle: !disabled && !isOutsideMonth && !isSelected ? { backgroundColor: theme.colors.overlay.mono } : void 0,
|
|
871
|
-
children: /* @__PURE__ */ (0,
|
|
618
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
872
619
|
Text,
|
|
873
620
|
{
|
|
874
621
|
color: textColor,
|
|
@@ -891,8 +638,8 @@ var Calendar = (0, import_react5.forwardRef)(
|
|
|
891
638
|
Calendar.displayName = "Calendar";
|
|
892
639
|
|
|
893
640
|
// src/DatePicker.tsx
|
|
894
|
-
var
|
|
895
|
-
var DatePicker = (0,
|
|
641
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
642
|
+
var DatePicker = (0, import_react3.forwardRef)(
|
|
896
643
|
({
|
|
897
644
|
onChange,
|
|
898
645
|
size = "md",
|
|
@@ -906,9 +653,9 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
906
653
|
testID,
|
|
907
654
|
...rest
|
|
908
655
|
}) => {
|
|
909
|
-
const [open, setOpen] = (0,
|
|
910
|
-
const [inputValue, setInputValue] = (0,
|
|
911
|
-
const containerRef = (0,
|
|
656
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
657
|
+
const [inputValue, setInputValue] = (0, import_react3.useState)("");
|
|
658
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
912
659
|
const formatDateForDisplay = (date) => {
|
|
913
660
|
if (!date) return "";
|
|
914
661
|
try {
|
|
@@ -917,7 +664,7 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
917
664
|
return "";
|
|
918
665
|
}
|
|
919
666
|
};
|
|
920
|
-
const getDisplayValue = (0,
|
|
667
|
+
const getDisplayValue = (0, import_react3.useCallback)(() => {
|
|
921
668
|
if (selectsRange) {
|
|
922
669
|
if (startDate && endDate) {
|
|
923
670
|
return `${formatDateForDisplay(startDate)} - ${formatDateForDisplay(endDate)}`;
|
|
@@ -929,7 +676,7 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
929
676
|
return formatDateForDisplay(selectedDate);
|
|
930
677
|
}
|
|
931
678
|
}, [selectsRange, startDate, endDate, selectedDate]);
|
|
932
|
-
(0,
|
|
679
|
+
(0, import_react3.useEffect)(() => {
|
|
933
680
|
setInputValue(getDisplayValue());
|
|
934
681
|
}, [getDisplayValue]);
|
|
935
682
|
const handleInputChange = (text) => {
|
|
@@ -947,7 +694,7 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
947
694
|
}
|
|
948
695
|
}
|
|
949
696
|
};
|
|
950
|
-
(0,
|
|
697
|
+
(0, import_react3.useEffect)(() => {
|
|
951
698
|
if (import_xui_core2.isNative) return;
|
|
952
699
|
const handleClickOutside = (event) => {
|
|
953
700
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
@@ -957,7 +704,7 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
957
704
|
document.addEventListener("mousedown", handleClickOutside);
|
|
958
705
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
959
706
|
}, []);
|
|
960
|
-
const renderCalendar = () => /* @__PURE__ */ (0,
|
|
707
|
+
const renderCalendar = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
961
708
|
Calendar,
|
|
962
709
|
{
|
|
963
710
|
locale,
|
|
@@ -969,8 +716,8 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
969
716
|
...rest
|
|
970
717
|
}
|
|
971
718
|
);
|
|
972
|
-
return /* @__PURE__ */ (0,
|
|
973
|
-
/* @__PURE__ */ (0,
|
|
719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box, { ref: containerRef, position: "relative", width: "100%", children: [
|
|
720
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
974
721
|
import_xui_input.Input,
|
|
975
722
|
{
|
|
976
723
|
...rest,
|
|
@@ -983,7 +730,7 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
983
730
|
testID
|
|
984
731
|
}
|
|
985
732
|
),
|
|
986
|
-
open && (import_xui_core2.isWeb ? /* @__PURE__ */ (0,
|
|
733
|
+
open && (import_xui_core2.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
987
734
|
Box,
|
|
988
735
|
{
|
|
989
736
|
position: "absolute",
|
|
@@ -997,7 +744,7 @@ var DatePicker = (0, import_react6.forwardRef)(
|
|
|
997
744
|
// Native implementation could use a Modal here
|
|
998
745
|
// For now, we just show it below the input if needed,
|
|
999
746
|
// but usually a bottom sheet or centered modal is better.
|
|
1000
|
-
/* @__PURE__ */ (0,
|
|
747
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { marginTop: 4, children: renderCalendar() })
|
|
1001
748
|
))
|
|
1002
749
|
] });
|
|
1003
750
|
}
|