@scripso-homepad/ui 0.4.33 → 0.4.35
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 +91 -61
- 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 +91 -61
- package/dist/index.js.map +1 -1
- package/dist/web/index.cjs +15 -4
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +3 -1
- package/dist/web/index.d.ts +3 -1
- package/dist/web/index.js +15 -4
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DatePicker.tsx +41 -6
- package/src/web/components/TableActionsMenu.tsx +20 -3
package/dist/index.d.cts
CHANGED
|
@@ -231,6 +231,10 @@ type DatePickerFieldProps = {
|
|
|
231
231
|
hintClassName?: string;
|
|
232
232
|
/** Opens the calendar popup on mount (useful for Storybook previews). */
|
|
233
233
|
defaultOpen?: boolean;
|
|
234
|
+
/** Controlled open state for the calendar popup. */
|
|
235
|
+
open?: boolean;
|
|
236
|
+
/** Called when the calendar popup opens or closes. */
|
|
237
|
+
onOpenChange?: (open: boolean) => void;
|
|
234
238
|
/** Closes the popup after a complete range is selected. Defaults to true in range mode. */
|
|
235
239
|
closeOnRangeComplete?: boolean;
|
|
236
240
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -231,6 +231,10 @@ type DatePickerFieldProps = {
|
|
|
231
231
|
hintClassName?: string;
|
|
232
232
|
/** Opens the calendar popup on mount (useful for Storybook previews). */
|
|
233
233
|
defaultOpen?: boolean;
|
|
234
|
+
/** Controlled open state for the calendar popup. */
|
|
235
|
+
open?: boolean;
|
|
236
|
+
/** Called when the calendar popup opens or closes. */
|
|
237
|
+
onOpenChange?: (open: boolean) => void;
|
|
234
238
|
/** Closes the popup after a complete range is selected. Defaults to true in range mode. */
|
|
235
239
|
closeOnRangeComplete?: boolean;
|
|
236
240
|
};
|
package/dist/index.js
CHANGED
|
@@ -2338,7 +2338,9 @@ function DatePicker(props) {
|
|
|
2338
2338
|
labelClassName,
|
|
2339
2339
|
errorClassName,
|
|
2340
2340
|
hintClassName,
|
|
2341
|
-
defaultOpen = false
|
|
2341
|
+
defaultOpen = false,
|
|
2342
|
+
open: controlledOpen,
|
|
2343
|
+
onOpenChange
|
|
2342
2344
|
} = props;
|
|
2343
2345
|
const mode = props.mode ?? "single";
|
|
2344
2346
|
const closeOnRangeComplete = props.mode === "range" ? props.closeOnRangeComplete ?? true : false;
|
|
@@ -2348,11 +2350,18 @@ function DatePicker(props) {
|
|
|
2348
2350
|
const wrapperRef = useRef(null);
|
|
2349
2351
|
const triggerRef = useRef(null);
|
|
2350
2352
|
const helperRef = useRef(null);
|
|
2351
|
-
const
|
|
2353
|
+
const isControlled = controlledOpen !== void 0;
|
|
2354
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
2355
|
+
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
2352
2356
|
const [anchor, setAnchor] = useState(null);
|
|
2353
2357
|
useApplyWebClassName(wrapperRef, className);
|
|
2354
2358
|
useApplyWebClassName(triggerRef, fieldClassName);
|
|
2355
2359
|
useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
|
|
2360
|
+
useEffect(() => {
|
|
2361
|
+
if (!open) {
|
|
2362
|
+
setAnchor(null);
|
|
2363
|
+
}
|
|
2364
|
+
}, [open]);
|
|
2356
2365
|
useEffect(() => {
|
|
2357
2366
|
if (!defaultOpen || disabled) {
|
|
2358
2367
|
return;
|
|
@@ -2360,7 +2369,7 @@ function DatePicker(props) {
|
|
|
2360
2369
|
const frame = requestAnimationFrame(() => {
|
|
2361
2370
|
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
2362
2371
|
setAnchor({ x, y, width, height });
|
|
2363
|
-
|
|
2372
|
+
setOpenState(true);
|
|
2364
2373
|
});
|
|
2365
2374
|
});
|
|
2366
2375
|
return () => cancelAnimationFrame(frame);
|
|
@@ -2397,8 +2406,14 @@ function DatePicker(props) {
|
|
|
2397
2406
|
const panelWidth = CALENDAR_PANEL_WIDTH;
|
|
2398
2407
|
const panelLeft = anchor ? isDesktopCalendar ? resolveCalendarDropdownLeft(anchor, panelWidth) : resolveCalendarDropdownLeftCentered(panelWidth) : 0;
|
|
2399
2408
|
const dropdownTop = anchor ? resolveCalendarDropdownTop(anchor) : 0;
|
|
2409
|
+
function setOpenState(next) {
|
|
2410
|
+
if (!isControlled) {
|
|
2411
|
+
setUncontrolledOpen(next);
|
|
2412
|
+
}
|
|
2413
|
+
onOpenChange?.(next);
|
|
2414
|
+
}
|
|
2400
2415
|
function closePicker() {
|
|
2401
|
-
|
|
2416
|
+
setOpenState(false);
|
|
2402
2417
|
setAnchor(null);
|
|
2403
2418
|
}
|
|
2404
2419
|
function openPicker() {
|
|
@@ -2407,7 +2422,7 @@ function DatePicker(props) {
|
|
|
2407
2422
|
}
|
|
2408
2423
|
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
2409
2424
|
setAnchor({ x, y, width, height });
|
|
2410
|
-
|
|
2425
|
+
setOpenState(true);
|
|
2411
2426
|
});
|
|
2412
2427
|
}
|
|
2413
2428
|
const resolvedDefaultViewDate = defaultViewDate ?? (props.mode === "range" ? props.value?.start : props.value) ?? today;
|
|
@@ -2480,64 +2495,76 @@ function DatePicker(props) {
|
|
|
2480
2495
|
}
|
|
2481
2496
|
),
|
|
2482
2497
|
helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles5.error : styles5.hint, children: helperMessage }) : null,
|
|
2483
|
-
/* @__PURE__ */ jsx(
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
}
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
{
|
|
2496
|
-
style: [
|
|
2497
|
-
styles5.panelPosition,
|
|
2498
|
-
{
|
|
2499
|
-
top: dropdownTop,
|
|
2500
|
-
left: panelLeft,
|
|
2501
|
-
width: panelWidth,
|
|
2502
|
-
height: CALENDAR_PANEL_HEIGHT
|
|
2503
|
-
}
|
|
2504
|
-
],
|
|
2505
|
-
children: props.mode === "range" ? /* @__PURE__ */ jsx(
|
|
2506
|
-
Calendar,
|
|
2498
|
+
/* @__PURE__ */ jsx(
|
|
2499
|
+
Modal,
|
|
2500
|
+
{
|
|
2501
|
+
visible: open,
|
|
2502
|
+
transparent: true,
|
|
2503
|
+
animationType: "fade",
|
|
2504
|
+
onRequestClose: closePicker,
|
|
2505
|
+
statusBarTranslucent: true,
|
|
2506
|
+
...Platform.OS === "ios" ? { presentationStyle: "overFullScreen" } : null,
|
|
2507
|
+
children: /* @__PURE__ */ jsxs(View, { style: styles5.modalRoot, children: [
|
|
2508
|
+
/* @__PURE__ */ jsx(
|
|
2509
|
+
Pressable,
|
|
2507
2510
|
{
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
defaultViewDate: resolvedDefaultViewDate,
|
|
2513
|
-
onViewDateChange,
|
|
2514
|
-
locale: resolvedLocale,
|
|
2515
|
-
labels,
|
|
2516
|
-
minDate,
|
|
2517
|
-
maxDate,
|
|
2518
|
-
today,
|
|
2519
|
-
className: panelClassName
|
|
2511
|
+
style: styles5.backdrop,
|
|
2512
|
+
onPress: closePicker,
|
|
2513
|
+
accessibilityRole: "button",
|
|
2514
|
+
accessibilityLabel: labels?.closeCalendar ?? translations.closeCalendar
|
|
2520
2515
|
}
|
|
2521
|
-
)
|
|
2522
|
-
|
|
2516
|
+
),
|
|
2517
|
+
anchor ? /* @__PURE__ */ jsx(
|
|
2518
|
+
View,
|
|
2523
2519
|
{
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2520
|
+
pointerEvents: "box-none",
|
|
2521
|
+
style: [
|
|
2522
|
+
styles5.panelPosition,
|
|
2523
|
+
{
|
|
2524
|
+
top: dropdownTop,
|
|
2525
|
+
left: panelLeft,
|
|
2526
|
+
width: panelWidth,
|
|
2527
|
+
height: CALENDAR_PANEL_HEIGHT
|
|
2528
|
+
}
|
|
2529
|
+
],
|
|
2530
|
+
children: /* @__PURE__ */ jsx(View, { pointerEvents: "auto", children: props.mode === "range" ? /* @__PURE__ */ jsx(
|
|
2531
|
+
Calendar,
|
|
2532
|
+
{
|
|
2533
|
+
mode: "range",
|
|
2534
|
+
value: props.value,
|
|
2535
|
+
onChange: handleRangeSelect,
|
|
2536
|
+
viewDate,
|
|
2537
|
+
defaultViewDate: resolvedDefaultViewDate,
|
|
2538
|
+
onViewDateChange,
|
|
2539
|
+
locale: resolvedLocale,
|
|
2540
|
+
labels,
|
|
2541
|
+
minDate,
|
|
2542
|
+
maxDate,
|
|
2543
|
+
today,
|
|
2544
|
+
className: panelClassName
|
|
2545
|
+
}
|
|
2546
|
+
) : /* @__PURE__ */ jsx(
|
|
2547
|
+
Calendar,
|
|
2548
|
+
{
|
|
2549
|
+
mode: "single",
|
|
2550
|
+
value: props.value,
|
|
2551
|
+
onChange: handleSingleSelect,
|
|
2552
|
+
viewDate,
|
|
2553
|
+
defaultViewDate: resolvedDefaultViewDate,
|
|
2554
|
+
onViewDateChange,
|
|
2555
|
+
locale: resolvedLocale,
|
|
2556
|
+
labels,
|
|
2557
|
+
minDate,
|
|
2558
|
+
maxDate,
|
|
2559
|
+
today,
|
|
2560
|
+
className: panelClassName
|
|
2561
|
+
}
|
|
2562
|
+
) })
|
|
2536
2563
|
}
|
|
2537
|
-
)
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
|
|
2564
|
+
) : null
|
|
2565
|
+
] })
|
|
2566
|
+
}
|
|
2567
|
+
)
|
|
2541
2568
|
]
|
|
2542
2569
|
}
|
|
2543
2570
|
);
|
|
@@ -2577,11 +2604,14 @@ var styles5 = StyleSheet.create({
|
|
|
2577
2604
|
flexShrink: 0
|
|
2578
2605
|
},
|
|
2579
2606
|
modalRoot: {
|
|
2580
|
-
flex: 1
|
|
2607
|
+
flex: 1,
|
|
2608
|
+
width: "100%",
|
|
2609
|
+
height: "100%"
|
|
2581
2610
|
},
|
|
2582
2611
|
backdrop: {
|
|
2583
2612
|
...StyleSheet.absoluteFillObject,
|
|
2584
|
-
backgroundColor:
|
|
2613
|
+
backgroundColor: "rgba(0, 0, 0, 0.35)",
|
|
2614
|
+
zIndex: 0
|
|
2585
2615
|
},
|
|
2586
2616
|
panelPosition: {
|
|
2587
2617
|
position: "absolute",
|