@scripso-homepad/ui 0.4.31 → 0.4.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +101 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +101 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Calendar.tsx +2 -5
- package/src/components/DatePicker.tsx +55 -11
- package/src/theme/calendar.ts +9 -1
package/dist/index.cjs
CHANGED
|
@@ -2420,7 +2420,7 @@ var calendarDropdownMetrics = reactNative.StyleSheet.create({
|
|
|
2420
2420
|
boxSizing: "border-box"
|
|
2421
2421
|
} : null
|
|
2422
2422
|
},
|
|
2423
|
-
|
|
2423
|
+
dayCellDisabled: {
|
|
2424
2424
|
backgroundColor: colors.stormGray50
|
|
2425
2425
|
},
|
|
2426
2426
|
dayCellSelected: {
|
|
@@ -2543,6 +2543,10 @@ function resolveCalendarDropdownLeft(anchor, panelWidth = CALENDAR_PANEL_WIDTH)
|
|
|
2543
2543
|
const maxLeft = Math.max(0, windowWidth - panelWidth);
|
|
2544
2544
|
return Math.max(0, Math.min(anchor.x, maxLeft));
|
|
2545
2545
|
}
|
|
2546
|
+
function resolveCalendarDropdownLeftCentered(panelWidth = CALENDAR_PANEL_WIDTH) {
|
|
2547
|
+
const windowWidth = reactNative.Dimensions.get("window").width;
|
|
2548
|
+
return Math.max(0, (windowWidth - panelWidth) / 2);
|
|
2549
|
+
}
|
|
2546
2550
|
var calendarFieldMetrics = reactNative.StyleSheet.create({
|
|
2547
2551
|
container: {
|
|
2548
2552
|
flexDirection: "row",
|
|
@@ -2959,10 +2963,9 @@ function resolveDayCellStyle(day) {
|
|
|
2959
2963
|
if (day.isSelected) {
|
|
2960
2964
|
return [calendarDropdownMetrics.dayCell, calendarDropdownMetrics.dayCellSelected];
|
|
2961
2965
|
}
|
|
2962
|
-
const useMutedBackground = day.inCurrentMonth && !day.isToday && (day.isPast || day.isDisabled);
|
|
2963
2966
|
return [
|
|
2964
2967
|
calendarDropdownMetrics.dayCell,
|
|
2965
|
-
|
|
2968
|
+
day.isDisabled ? calendarDropdownMetrics.dayCellDisabled : null
|
|
2966
2969
|
];
|
|
2967
2970
|
}
|
|
2968
2971
|
function resolveDayLabelStyle(day) {
|
|
@@ -2975,7 +2978,7 @@ function resolveDayLabelStyle(day) {
|
|
|
2975
2978
|
if (day.isToday) {
|
|
2976
2979
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelToday];
|
|
2977
2980
|
}
|
|
2978
|
-
if (day.
|
|
2981
|
+
if (day.isDisabled) {
|
|
2979
2982
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelMuted];
|
|
2980
2983
|
}
|
|
2981
2984
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelFuture];
|
|
@@ -3253,6 +3256,7 @@ function CalendarIcon({
|
|
|
3253
3256
|
}
|
|
3254
3257
|
) });
|
|
3255
3258
|
}
|
|
3259
|
+
var isDesktopCalendar = reactNative.Platform.OS === "web";
|
|
3256
3260
|
function DatePicker(props) {
|
|
3257
3261
|
const {
|
|
3258
3262
|
label,
|
|
@@ -3278,7 +3282,9 @@ function DatePicker(props) {
|
|
|
3278
3282
|
labelClassName,
|
|
3279
3283
|
errorClassName,
|
|
3280
3284
|
hintClassName,
|
|
3281
|
-
defaultOpen = false
|
|
3285
|
+
defaultOpen = false,
|
|
3286
|
+
open: controlledOpen,
|
|
3287
|
+
onOpenChange
|
|
3282
3288
|
} = props;
|
|
3283
3289
|
const mode = props.mode ?? "single";
|
|
3284
3290
|
const closeOnRangeComplete = props.mode === "range" ? props.closeOnRangeComplete ?? true : false;
|
|
@@ -3288,11 +3294,18 @@ function DatePicker(props) {
|
|
|
3288
3294
|
const wrapperRef = react.useRef(null);
|
|
3289
3295
|
const triggerRef = react.useRef(null);
|
|
3290
3296
|
const helperRef = react.useRef(null);
|
|
3291
|
-
const
|
|
3297
|
+
const isControlled = controlledOpen !== void 0;
|
|
3298
|
+
const [uncontrolledOpen, setUncontrolledOpen] = react.useState(defaultOpen);
|
|
3299
|
+
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
3292
3300
|
const [anchor, setAnchor] = react.useState(null);
|
|
3293
3301
|
useApplyWebClassName(wrapperRef, className);
|
|
3294
3302
|
useApplyWebClassName(triggerRef, fieldClassName);
|
|
3295
3303
|
useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
|
|
3304
|
+
react.useEffect(() => {
|
|
3305
|
+
if (!open) {
|
|
3306
|
+
setAnchor(null);
|
|
3307
|
+
}
|
|
3308
|
+
}, [open]);
|
|
3296
3309
|
react.useEffect(() => {
|
|
3297
3310
|
if (!defaultOpen || disabled) {
|
|
3298
3311
|
return;
|
|
@@ -3300,7 +3313,7 @@ function DatePicker(props) {
|
|
|
3300
3313
|
const frame = requestAnimationFrame(() => {
|
|
3301
3314
|
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
3302
3315
|
setAnchor({ x, y, width, height });
|
|
3303
|
-
|
|
3316
|
+
setOpenState(true);
|
|
3304
3317
|
});
|
|
3305
3318
|
});
|
|
3306
3319
|
return () => cancelAnimationFrame(frame);
|
|
@@ -3335,11 +3348,16 @@ function DatePicker(props) {
|
|
|
3335
3348
|
};
|
|
3336
3349
|
const helperMessage = error ?? hint;
|
|
3337
3350
|
const panelWidth = CALENDAR_PANEL_WIDTH;
|
|
3338
|
-
const panelLeft = anchor ? resolveCalendarDropdownLeft(anchor, panelWidth) : 0;
|
|
3351
|
+
const panelLeft = anchor ? isDesktopCalendar ? resolveCalendarDropdownLeft(anchor, panelWidth) : resolveCalendarDropdownLeftCentered(panelWidth) : 0;
|
|
3339
3352
|
const dropdownTop = anchor ? resolveCalendarDropdownTop(anchor) : 0;
|
|
3340
|
-
|
|
3353
|
+
function setOpenState(next) {
|
|
3354
|
+
if (!isControlled) {
|
|
3355
|
+
setUncontrolledOpen(next);
|
|
3356
|
+
}
|
|
3357
|
+
onOpenChange?.(next);
|
|
3358
|
+
}
|
|
3341
3359
|
function closePicker() {
|
|
3342
|
-
|
|
3360
|
+
setOpenState(false);
|
|
3343
3361
|
setAnchor(null);
|
|
3344
3362
|
}
|
|
3345
3363
|
function openPicker() {
|
|
@@ -3348,9 +3366,10 @@ function DatePicker(props) {
|
|
|
3348
3366
|
}
|
|
3349
3367
|
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
3350
3368
|
setAnchor({ x, y, width, height });
|
|
3351
|
-
|
|
3369
|
+
setOpenState(true);
|
|
3352
3370
|
});
|
|
3353
3371
|
}
|
|
3372
|
+
const resolvedDefaultViewDate = defaultViewDate ?? (props.mode === "range" ? props.value?.start : props.value) ?? today;
|
|
3354
3373
|
function handleSingleSelect(date) {
|
|
3355
3374
|
if (props.mode === "range") {
|
|
3356
3375
|
return;
|
|
@@ -3420,64 +3439,76 @@ function DatePicker(props) {
|
|
|
3420
3439
|
}
|
|
3421
3440
|
),
|
|
3422
3441
|
helperMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ref: helperRef, style: error ? styles8.error : styles8.hint, children: helperMessage }) : null,
|
|
3423
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
}
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
{
|
|
3436
|
-
style: [
|
|
3437
|
-
styles8.panelPosition,
|
|
3438
|
-
{
|
|
3439
|
-
top: dropdownTop,
|
|
3440
|
-
left: panelLeft,
|
|
3441
|
-
width: panelWidth,
|
|
3442
|
-
height: CALENDAR_PANEL_HEIGHT
|
|
3443
|
-
}
|
|
3444
|
-
],
|
|
3445
|
-
children: props.mode === "range" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3446
|
-
Calendar,
|
|
3442
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3443
|
+
reactNative.Modal,
|
|
3444
|
+
{
|
|
3445
|
+
visible: open,
|
|
3446
|
+
transparent: true,
|
|
3447
|
+
animationType: "fade",
|
|
3448
|
+
onRequestClose: closePicker,
|
|
3449
|
+
statusBarTranslucent: true,
|
|
3450
|
+
...reactNative.Platform.OS === "ios" ? { presentationStyle: "overFullScreen" } : null,
|
|
3451
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles8.modalRoot, children: [
|
|
3452
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3453
|
+
reactNative.Pressable,
|
|
3447
3454
|
{
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
defaultViewDate: resolvedDefaultViewDate,
|
|
3453
|
-
onViewDateChange,
|
|
3454
|
-
locale: resolvedLocale,
|
|
3455
|
-
labels,
|
|
3456
|
-
minDate,
|
|
3457
|
-
maxDate,
|
|
3458
|
-
today,
|
|
3459
|
-
className: panelClassName
|
|
3455
|
+
style: styles8.backdrop,
|
|
3456
|
+
onPress: closePicker,
|
|
3457
|
+
accessibilityRole: "button",
|
|
3458
|
+
accessibilityLabel: labels?.closeCalendar ?? translations.closeCalendar
|
|
3460
3459
|
}
|
|
3461
|
-
)
|
|
3462
|
-
|
|
3460
|
+
),
|
|
3461
|
+
anchor ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3462
|
+
reactNative.View,
|
|
3463
3463
|
{
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3464
|
+
pointerEvents: "box-none",
|
|
3465
|
+
style: [
|
|
3466
|
+
styles8.panelPosition,
|
|
3467
|
+
{
|
|
3468
|
+
top: dropdownTop,
|
|
3469
|
+
left: panelLeft,
|
|
3470
|
+
width: panelWidth,
|
|
3471
|
+
height: CALENDAR_PANEL_HEIGHT
|
|
3472
|
+
}
|
|
3473
|
+
],
|
|
3474
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "auto", children: props.mode === "range" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3475
|
+
Calendar,
|
|
3476
|
+
{
|
|
3477
|
+
mode: "range",
|
|
3478
|
+
value: props.value,
|
|
3479
|
+
onChange: handleRangeSelect,
|
|
3480
|
+
viewDate,
|
|
3481
|
+
defaultViewDate: resolvedDefaultViewDate,
|
|
3482
|
+
onViewDateChange,
|
|
3483
|
+
locale: resolvedLocale,
|
|
3484
|
+
labels,
|
|
3485
|
+
minDate,
|
|
3486
|
+
maxDate,
|
|
3487
|
+
today,
|
|
3488
|
+
className: panelClassName
|
|
3489
|
+
}
|
|
3490
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3491
|
+
Calendar,
|
|
3492
|
+
{
|
|
3493
|
+
mode: "single",
|
|
3494
|
+
value: props.value,
|
|
3495
|
+
onChange: handleSingleSelect,
|
|
3496
|
+
viewDate,
|
|
3497
|
+
defaultViewDate: resolvedDefaultViewDate,
|
|
3498
|
+
onViewDateChange,
|
|
3499
|
+
locale: resolvedLocale,
|
|
3500
|
+
labels,
|
|
3501
|
+
minDate,
|
|
3502
|
+
maxDate,
|
|
3503
|
+
today,
|
|
3504
|
+
className: panelClassName
|
|
3505
|
+
}
|
|
3506
|
+
) })
|
|
3476
3507
|
}
|
|
3477
|
-
)
|
|
3478
|
-
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3508
|
+
) : null
|
|
3509
|
+
] })
|
|
3510
|
+
}
|
|
3511
|
+
)
|
|
3481
3512
|
]
|
|
3482
3513
|
}
|
|
3483
3514
|
);
|
|
@@ -3517,11 +3548,14 @@ var styles8 = reactNative.StyleSheet.create({
|
|
|
3517
3548
|
flexShrink: 0
|
|
3518
3549
|
},
|
|
3519
3550
|
modalRoot: {
|
|
3520
|
-
flex: 1
|
|
3551
|
+
flex: 1,
|
|
3552
|
+
width: "100%",
|
|
3553
|
+
height: "100%"
|
|
3521
3554
|
},
|
|
3522
3555
|
backdrop: {
|
|
3523
3556
|
...reactNative.StyleSheet.absoluteFillObject,
|
|
3524
|
-
backgroundColor:
|
|
3557
|
+
backgroundColor: "rgba(0, 0, 0, 0.35)",
|
|
3558
|
+
zIndex: 0
|
|
3525
3559
|
},
|
|
3526
3560
|
panelPosition: {
|
|
3527
3561
|
position: "absolute",
|