@scripso-homepad/ui 0.4.30 → 0.4.33
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 +24 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Calendar.tsx +5 -13
- package/src/components/DatePicker.tsx +14 -5
- package/src/theme/calendar.ts +20 -10
package/dist/index.js
CHANGED
|
@@ -1348,7 +1348,7 @@ var CALENDAR_NAV_ICON_COLOR = colors.stormGray850;
|
|
|
1348
1348
|
var CALENDAR_FIELD_ICON_SIZE = 20;
|
|
1349
1349
|
var CALENDAR_FIELD_WIDTH = CALENDAR_PANEL_WIDTH;
|
|
1350
1350
|
var CALENDAR_FIELD_HEIGHT = 52;
|
|
1351
|
-
var CALENDAR_FIELD_PADDING =
|
|
1351
|
+
var CALENDAR_FIELD_PADDING = 14;
|
|
1352
1352
|
var CALENDAR_FIELD_GAP = spacing.sm;
|
|
1353
1353
|
var CALENDAR_FIELD_PLACEHOLDER_COLOR = colors.stormGray200;
|
|
1354
1354
|
var CALENDAR_PANEL_TOTAL_HEIGHT = CALENDAR_PANEL_PADDING * 2 + CALENDAR_HEADER_HEIGHT + CALENDAR_PANEL_GAP * 2 + CALENDAR_WEEKDAY_CELL_SIZE + CALENDAR_DAY_GRID_HEIGHT;
|
|
@@ -1476,7 +1476,7 @@ var calendarDropdownMetrics = StyleSheet.create({
|
|
|
1476
1476
|
boxSizing: "border-box"
|
|
1477
1477
|
} : null
|
|
1478
1478
|
},
|
|
1479
|
-
|
|
1479
|
+
dayCellDisabled: {
|
|
1480
1480
|
backgroundColor: colors.stormGray50
|
|
1481
1481
|
},
|
|
1482
1482
|
dayCellSelected: {
|
|
@@ -1510,19 +1510,20 @@ var calendarDropdownMetrics = StyleSheet.create({
|
|
|
1510
1510
|
color: colors.stormGray300
|
|
1511
1511
|
},
|
|
1512
1512
|
dayLabelDisabled: {
|
|
1513
|
-
color: colors.stormGray300
|
|
1514
|
-
opacity: 0.5
|
|
1513
|
+
color: colors.stormGray300
|
|
1515
1514
|
},
|
|
1516
|
-
|
|
1515
|
+
todayDotWrap: {
|
|
1517
1516
|
position: "absolute",
|
|
1518
|
-
bottom:
|
|
1519
|
-
left:
|
|
1517
|
+
bottom: 4,
|
|
1518
|
+
left: 0,
|
|
1519
|
+
right: 0,
|
|
1520
|
+
alignItems: "center"
|
|
1521
|
+
},
|
|
1522
|
+
todayDot: {
|
|
1520
1523
|
width: CALENDAR_DAY_DOT_SIZE,
|
|
1521
1524
|
height: CALENDAR_DAY_DOT_SIZE,
|
|
1522
|
-
borderRadius:
|
|
1523
|
-
backgroundColor: CALENDAR_TODAY_DOT_COLOR
|
|
1524
|
-
marginLeft: -1.5,
|
|
1525
|
-
zIndex: 1
|
|
1525
|
+
borderRadius: CALENDAR_DAY_DOT_SIZE / 2,
|
|
1526
|
+
backgroundColor: CALENDAR_TODAY_DOT_COLOR
|
|
1526
1527
|
},
|
|
1527
1528
|
pickerBody: {
|
|
1528
1529
|
width: CALENDAR_DAY_GRID_WIDTH,
|
|
@@ -1598,6 +1599,10 @@ function resolveCalendarDropdownLeft(anchor, panelWidth = CALENDAR_PANEL_WIDTH)
|
|
|
1598
1599
|
const maxLeft = Math.max(0, windowWidth - panelWidth);
|
|
1599
1600
|
return Math.max(0, Math.min(anchor.x, maxLeft));
|
|
1600
1601
|
}
|
|
1602
|
+
function resolveCalendarDropdownLeftCentered(panelWidth = CALENDAR_PANEL_WIDTH) {
|
|
1603
|
+
const windowWidth = Dimensions.get("window").width;
|
|
1604
|
+
return Math.max(0, (windowWidth - panelWidth) / 2);
|
|
1605
|
+
}
|
|
1601
1606
|
var calendarFieldMetrics = StyleSheet.create({
|
|
1602
1607
|
container: {
|
|
1603
1608
|
flexDirection: "row",
|
|
@@ -1623,7 +1628,8 @@ var calendarFieldMetrics = StyleSheet.create({
|
|
|
1623
1628
|
paddingVertical: 0,
|
|
1624
1629
|
paddingHorizontal: 0,
|
|
1625
1630
|
margin: 0,
|
|
1626
|
-
|
|
1631
|
+
includeFontPadding: false,
|
|
1632
|
+
...Platform.OS === "android" ? { textAlignVertical: "center" } : null,
|
|
1627
1633
|
...Platform.OS === "web" ? {
|
|
1628
1634
|
outlineStyle: "none"
|
|
1629
1635
|
} : null
|
|
@@ -2010,21 +2016,15 @@ function useCalendarLocale(locale) {
|
|
|
2010
2016
|
);
|
|
2011
2017
|
}
|
|
2012
2018
|
function resolveDayCellStyle(day) {
|
|
2013
|
-
if (day.isDisabled) {
|
|
2014
|
-
return [calendarDropdownMetrics.dayCell];
|
|
2015
|
-
}
|
|
2016
2019
|
if (day.isSelected) {
|
|
2017
2020
|
return [calendarDropdownMetrics.dayCell, calendarDropdownMetrics.dayCellSelected];
|
|
2018
2021
|
}
|
|
2019
2022
|
return [
|
|
2020
2023
|
calendarDropdownMetrics.dayCell,
|
|
2021
|
-
day.
|
|
2024
|
+
day.isDisabled ? calendarDropdownMetrics.dayCellDisabled : null
|
|
2022
2025
|
];
|
|
2023
2026
|
}
|
|
2024
2027
|
function resolveDayLabelStyle(day) {
|
|
2025
|
-
if (day.isDisabled) {
|
|
2026
|
-
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelDisabled];
|
|
2027
|
-
}
|
|
2028
2028
|
if (day.isSelected) {
|
|
2029
2029
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelSelected];
|
|
2030
2030
|
}
|
|
@@ -2034,7 +2034,7 @@ function resolveDayLabelStyle(day) {
|
|
|
2034
2034
|
if (day.isToday) {
|
|
2035
2035
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelToday];
|
|
2036
2036
|
}
|
|
2037
|
-
if (day.
|
|
2037
|
+
if (day.isDisabled) {
|
|
2038
2038
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelMuted];
|
|
2039
2039
|
}
|
|
2040
2040
|
return [calendarDropdownMetrics.dayLabel, calendarDropdownMetrics.dayLabelFuture];
|
|
@@ -2225,7 +2225,7 @@ function Calendar(props) {
|
|
|
2225
2225
|
style: resolveDayCellStyle(day),
|
|
2226
2226
|
children: [
|
|
2227
2227
|
/* @__PURE__ */ jsx(Text, { style: resolveDayLabelStyle(day), children: day.date.getDate() }),
|
|
2228
|
-
day.isToday && day.inCurrentMonth && !day.isSelected ? /* @__PURE__ */ jsx(View, { style: calendarDropdownMetrics.todayDot }) : null
|
|
2228
|
+
day.isToday && day.inCurrentMonth && !day.isSelected ? /* @__PURE__ */ jsx(View, { style: calendarDropdownMetrics.todayDotWrap, children: /* @__PURE__ */ jsx(View, { style: calendarDropdownMetrics.todayDot }) }) : null
|
|
2229
2229
|
]
|
|
2230
2230
|
},
|
|
2231
2231
|
day.date.toISOString()
|
|
@@ -2312,6 +2312,7 @@ function CalendarIcon({
|
|
|
2312
2312
|
}
|
|
2313
2313
|
) });
|
|
2314
2314
|
}
|
|
2315
|
+
var isDesktopCalendar = Platform.OS === "web";
|
|
2315
2316
|
function DatePicker(props) {
|
|
2316
2317
|
const {
|
|
2317
2318
|
label,
|
|
@@ -2394,9 +2395,8 @@ function DatePicker(props) {
|
|
|
2394
2395
|
};
|
|
2395
2396
|
const helperMessage = error ?? hint;
|
|
2396
2397
|
const panelWidth = CALENDAR_PANEL_WIDTH;
|
|
2397
|
-
const panelLeft = anchor ? resolveCalendarDropdownLeft(anchor, panelWidth) : 0;
|
|
2398
|
+
const panelLeft = anchor ? isDesktopCalendar ? resolveCalendarDropdownLeft(anchor, panelWidth) : resolveCalendarDropdownLeftCentered(panelWidth) : 0;
|
|
2398
2399
|
const dropdownTop = anchor ? resolveCalendarDropdownTop(anchor) : 0;
|
|
2399
|
-
const resolvedDefaultViewDate = defaultViewDate ?? (props.mode === "range" ? props.value?.start : props.value) ?? today;
|
|
2400
2400
|
function closePicker() {
|
|
2401
2401
|
setOpen(false);
|
|
2402
2402
|
setAnchor(null);
|
|
@@ -2410,6 +2410,7 @@ function DatePicker(props) {
|
|
|
2410
2410
|
setOpen(true);
|
|
2411
2411
|
});
|
|
2412
2412
|
}
|
|
2413
|
+
const resolvedDefaultViewDate = defaultViewDate ?? (props.mode === "range" ? props.value?.start : props.value) ?? today;
|
|
2413
2414
|
function handleSingleSelect(date) {
|
|
2414
2415
|
if (props.mode === "range") {
|
|
2415
2416
|
return;
|