react-native-resource-calendar 1.1.4 → 1.1.6
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.js +32 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1034,13 +1034,12 @@ var EventBlock = React19__namespace.default.memo(({
|
|
|
1034
1034
|
onPress,
|
|
1035
1035
|
disabled,
|
|
1036
1036
|
selected,
|
|
1037
|
+
anyEventSelected,
|
|
1037
1038
|
hourHeight,
|
|
1038
1039
|
slots,
|
|
1039
1040
|
frame,
|
|
1040
1041
|
styleOverrides
|
|
1041
1042
|
}) => {
|
|
1042
|
-
const { useGetSelectedEvent: useGetSelectedEvent2 } = useCalendarBinding();
|
|
1043
|
-
const selectedAppointment = useGetSelectedEvent2();
|
|
1044
1043
|
const eventTop = scalePosition(event.from, hourHeight);
|
|
1045
1044
|
const eventHeight = scalePosition(event.to - event.from, hourHeight);
|
|
1046
1045
|
const start = minutesToTime(event.from);
|
|
@@ -1051,11 +1050,13 @@ var EventBlock = React19__namespace.default.memo(({
|
|
|
1051
1050
|
left: frame.leftPx + 1,
|
|
1052
1051
|
width: frame.widthPx - 3,
|
|
1053
1052
|
zIndex: frame.zIndex,
|
|
1054
|
-
opacity:
|
|
1053
|
+
opacity: anyEventSelected || disabled ? 0.5 : 1,
|
|
1055
1054
|
borderWidth: selected ? 2 : 1,
|
|
1056
1055
|
borderColor: selected ? "#4d959c" : "rgba(0,0,0,0.12)"
|
|
1057
1056
|
};
|
|
1058
1057
|
const resolved = typeof styleOverrides === "function" ? styleOverrides(event) ?? {} : styleOverrides ?? {};
|
|
1058
|
+
const handlePress = React19.useCallback(() => onPress?.(event), [onPress, event]);
|
|
1059
|
+
const handleLongPress = React19.useCallback(() => onLongPress?.(event), [onLongPress, event]);
|
|
1059
1060
|
if (eventHeight == 0)
|
|
1060
1061
|
return null;
|
|
1061
1062
|
const TopRight = slots?.TopRight;
|
|
@@ -1067,12 +1068,8 @@ var EventBlock = React19__namespace.default.memo(({
|
|
|
1067
1068
|
{
|
|
1068
1069
|
style: [styles5.event, resolved?.container, dynamicStyle],
|
|
1069
1070
|
disabled,
|
|
1070
|
-
onPress:
|
|
1071
|
-
|
|
1072
|
-
},
|
|
1073
|
-
onLongPress: () => {
|
|
1074
|
-
onLongPress && onLongPress(event);
|
|
1075
|
-
}
|
|
1071
|
+
onPress: handlePress,
|
|
1072
|
+
onLongPress: handleLongPress
|
|
1076
1073
|
},
|
|
1077
1074
|
/* @__PURE__ */ React19__namespace.default.createElement(Col_default, { style: [{ position: "relative" }, resolved?.content] }, /* @__PURE__ */ React19__namespace.default.createElement(
|
|
1078
1075
|
reactNative.TextInput,
|
|
@@ -1266,9 +1263,11 @@ var EventBlocks = React19__namespace.default.memo(({
|
|
|
1266
1263
|
mode,
|
|
1267
1264
|
date: dateProp
|
|
1268
1265
|
}) => {
|
|
1269
|
-
const { useEventsFor: useEventsFor2, useGetDate: useGetDate2 } = useCalendarBinding();
|
|
1266
|
+
const { useEventsFor: useEventsFor2, useGetDate: useGetDate2, useGetSelectedEvent: useGetSelectedEvent2 } = useCalendarBinding();
|
|
1270
1267
|
const date = useGetDate2();
|
|
1268
|
+
const selectedEvent = useGetSelectedEvent2();
|
|
1271
1269
|
const events = useEventsFor2(id, dateProp ?? date);
|
|
1270
|
+
const anyEventSelected = !!selectedEvent;
|
|
1272
1271
|
const frameMap = React19.useMemo(
|
|
1273
1272
|
() => computeEventFrames(events, EVENT_BLOCK_WIDTH, mode),
|
|
1274
1273
|
[events, mode, EVENT_BLOCK_WIDTH]
|
|
@@ -1283,12 +1282,13 @@ var EventBlocks = React19__namespace.default.memo(({
|
|
|
1283
1282
|
{
|
|
1284
1283
|
key: `${evt.from}-${evt.to}-${index}`,
|
|
1285
1284
|
event: evt,
|
|
1286
|
-
onLongPress
|
|
1287
|
-
onPress
|
|
1285
|
+
onLongPress,
|
|
1286
|
+
onPress,
|
|
1288
1287
|
hourHeight,
|
|
1289
1288
|
frame: frameMap.get(evt.id),
|
|
1290
1289
|
selected,
|
|
1291
|
-
disabled
|
|
1290
|
+
disabled,
|
|
1291
|
+
anyEventSelected
|
|
1292
1292
|
}
|
|
1293
1293
|
);
|
|
1294
1294
|
}
|
|
@@ -1367,6 +1367,7 @@ var DaysComponent = ({ onResourcePress, activeResourceId, mode, date, APPOINTMEN
|
|
|
1367
1367
|
})));
|
|
1368
1368
|
};
|
|
1369
1369
|
var AnimatedFlashList = Animated2__default.default.createAnimatedComponent(flashList.FlashList);
|
|
1370
|
+
var DEFAULT_TIMEZONE = Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone;
|
|
1370
1371
|
var CalendarInner = (props) => {
|
|
1371
1372
|
const { width } = reactNative.useWindowDimensions();
|
|
1372
1373
|
const isIOS = reactNative.Platform.OS === "ios";
|
|
@@ -1377,7 +1378,7 @@ var CalendarInner = (props) => {
|
|
|
1377
1378
|
startMinutes,
|
|
1378
1379
|
hourHeight = 120,
|
|
1379
1380
|
snapIntervalInMinutes = 5,
|
|
1380
|
-
timezone =
|
|
1381
|
+
timezone = DEFAULT_TIMEZONE,
|
|
1381
1382
|
resources,
|
|
1382
1383
|
onResourcePress,
|
|
1383
1384
|
onBlockLongPress,
|
|
@@ -1401,11 +1402,16 @@ var CalendarInner = (props) => {
|
|
|
1401
1402
|
);
|
|
1402
1403
|
const snapInterval = hourHeight / 60 * snapIntervalInMinutes;
|
|
1403
1404
|
const onPressRef = React19__namespace.default.useRef(onEventPress);
|
|
1405
|
+
onPressRef.current = onEventPress;
|
|
1404
1406
|
const onLongPressRef = React19__namespace.default.useRef(onEventLongPress);
|
|
1407
|
+
onLongPressRef.current = onEventLongPress;
|
|
1405
1408
|
const internalOnLongPress = React19.useRef(null);
|
|
1406
1409
|
const onDisabledBlockPressRef = React19__namespace.default.useRef(onDisabledBlockPress);
|
|
1410
|
+
onDisabledBlockPressRef.current = onDisabledBlockPress;
|
|
1407
1411
|
const selectedRef = React19.useRef(props.isEventSelected);
|
|
1412
|
+
selectedRef.current = props.isEventSelected;
|
|
1408
1413
|
const disabledRef = React19.useRef(props.isEventDisabled);
|
|
1414
|
+
disabledRef.current = props.isEventDisabled;
|
|
1409
1415
|
const effectiveRenderer = React19.useMemo(() => {
|
|
1410
1416
|
return (p) => /* @__PURE__ */ React19__namespace.default.createElement(
|
|
1411
1417
|
EventBlock_default,
|
|
@@ -1424,25 +1430,8 @@ var CalendarInner = (props) => {
|
|
|
1424
1430
|
(ev) => disabledRef.current ? disabledRef.current(ev) : false,
|
|
1425
1431
|
[]
|
|
1426
1432
|
);
|
|
1427
|
-
React19.useEffect(() => {
|
|
1428
|
-
onPressRef.current = onEventPress;
|
|
1429
|
-
}, [onEventPress]);
|
|
1430
|
-
React19.useEffect(() => {
|
|
1431
|
-
onLongPressRef.current = onEventLongPress;
|
|
1432
|
-
}, [onEventLongPress]);
|
|
1433
|
-
React19.useEffect(() => {
|
|
1434
|
-
onDisabledBlockPressRef.current = onDisabledBlockPress;
|
|
1435
|
-
}, [onDisabledBlockPress]);
|
|
1436
|
-
React19.useEffect(() => {
|
|
1437
|
-
rendererRef.current = effectiveRenderer;
|
|
1438
|
-
}, [effectiveRenderer]);
|
|
1439
|
-
React19.useEffect(() => {
|
|
1440
|
-
selectedRef.current = props.isEventSelected;
|
|
1441
|
-
}, [props.isEventSelected]);
|
|
1442
|
-
React19.useEffect(() => {
|
|
1443
|
-
disabledRef.current = props.isEventDisabled;
|
|
1444
|
-
}, [props.isEventDisabled]);
|
|
1445
1433
|
const rendererRef = React19.useRef(effectiveRenderer);
|
|
1434
|
+
rendererRef.current = effectiveRenderer;
|
|
1446
1435
|
const stableRenderer = React19.useCallback((p) => rendererRef.current(p), []);
|
|
1447
1436
|
const stableOnPress = React19__namespace.default.useCallback((e) => onPressRef.current?.(e), []);
|
|
1448
1437
|
const stableOnDisabledBlockPress = React19__namespace.default.useCallback((b) => onDisabledBlockPressRef.current?.(b), []);
|
|
@@ -1450,27 +1439,20 @@ var CalendarInner = (props) => {
|
|
|
1450
1439
|
const selectedEvent = useGetSelectedEvent2();
|
|
1451
1440
|
const setSelectedEvent = useSetSelectedEvent2();
|
|
1452
1441
|
const setDraggedEventDraft = useSetDraggedEventDraft2();
|
|
1453
|
-
const APPOINTMENT_BLOCK_WIDTH = (
|
|
1442
|
+
const APPOINTMENT_BLOCK_WIDTH = React19.useMemo(
|
|
1443
|
+
() => (width - TIME_LABEL_WIDTH) / numberOfColumns,
|
|
1444
|
+
[width, numberOfColumns]
|
|
1445
|
+
);
|
|
1454
1446
|
const hourHeightRef = React19.useRef(hourHeight);
|
|
1447
|
+
hourHeightRef.current = hourHeight;
|
|
1455
1448
|
const resourcesRef = React19.useRef(resources);
|
|
1449
|
+
resourcesRef.current = resources;
|
|
1456
1450
|
const apptWidthRef = React19.useRef(APPOINTMENT_BLOCK_WIDTH);
|
|
1451
|
+
apptWidthRef.current = APPOINTMENT_BLOCK_WIDTH;
|
|
1457
1452
|
const isMultiDayRef = React19.useRef(isMultiDay);
|
|
1453
|
+
isMultiDayRef.current = isMultiDay;
|
|
1458
1454
|
const daysRef = React19.useRef(days);
|
|
1459
|
-
|
|
1460
|
-
hourHeightRef.current = hourHeight;
|
|
1461
|
-
}, [hourHeight]);
|
|
1462
|
-
React19.useEffect(() => {
|
|
1463
|
-
resourcesRef.current = resources;
|
|
1464
|
-
}, [resources]);
|
|
1465
|
-
React19.useEffect(() => {
|
|
1466
|
-
apptWidthRef.current = APPOINTMENT_BLOCK_WIDTH;
|
|
1467
|
-
}, [APPOINTMENT_BLOCK_WIDTH]);
|
|
1468
|
-
React19.useEffect(() => {
|
|
1469
|
-
isMultiDayRef.current = isMultiDay;
|
|
1470
|
-
}, [isMultiDay]);
|
|
1471
|
-
React19.useEffect(() => {
|
|
1472
|
-
daysRef.current = days;
|
|
1473
|
-
}, [days]);
|
|
1455
|
+
daysRef.current = days;
|
|
1474
1456
|
React19.useEffect(() => {
|
|
1475
1457
|
if (!selectedEvent) {
|
|
1476
1458
|
setDraggedEventDraft(null);
|
|
@@ -1487,6 +1469,7 @@ var CalendarInner = (props) => {
|
|
|
1487
1469
|
const [layout, setLayout] = React19.useState(null);
|
|
1488
1470
|
const [dragReady, setDragReady] = React19.useState(false);
|
|
1489
1471
|
const dateRef = React19.useRef(date);
|
|
1472
|
+
dateRef.current = date;
|
|
1490
1473
|
const eventStartedTop = Animated2.useSharedValue(0);
|
|
1491
1474
|
const eventHeight = Animated2.useSharedValue(0);
|
|
1492
1475
|
const panXAbs = Animated2.useSharedValue(0);
|
|
@@ -1790,9 +1773,6 @@ var CalendarInner = (props) => {
|
|
|
1790
1773
|
subscription.remove();
|
|
1791
1774
|
};
|
|
1792
1775
|
}, [setSelectedEvent, selectedEvent, setDragReady]);
|
|
1793
|
-
React19.useEffect(() => {
|
|
1794
|
-
dateRef.current = date;
|
|
1795
|
-
}, [date]);
|
|
1796
1776
|
const renderItem = React19.useCallback(({ item, index }) => {
|
|
1797
1777
|
const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
|
|
1798
1778
|
const dayDate = !isMultiDay ? void 0 : item.dayDate;
|
|
@@ -1848,8 +1828,7 @@ var CalendarInner = (props) => {
|
|
|
1848
1828
|
overLappingLayoutMode,
|
|
1849
1829
|
stableOnPress,
|
|
1850
1830
|
internalStableOnLongPress,
|
|
1851
|
-
stableOnDisabledBlockPress
|
|
1852
|
-
dateRef
|
|
1831
|
+
stableOnDisabledBlockPress
|
|
1853
1832
|
]);
|
|
1854
1833
|
return /* @__PURE__ */ React19__namespace.default.createElement(React19__namespace.default.Fragment, null, /* @__PURE__ */ React19__namespace.default.createElement(StoreFeeder, { resources, store: binding, baseDate: date }), /* @__PURE__ */ React19__namespace.default.createElement(reactNative.View, { style: { flex: 1 } }, !isMultiDay ? /* @__PURE__ */ React19__namespace.default.createElement(reactNative.View, { key: `header-${numberOfColumns}-${width}` }, /* @__PURE__ */ React19__namespace.default.createElement(
|
|
1855
1834
|
Animated2__default.default.ScrollView,
|