@neko-os/ui 0.5.0 → 0.5.2
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/NekoUI.js +4 -1
- package/dist/abstractions/index.js +1 -0
- package/dist/components/actions/Dropdown.js +5 -3
- package/dist/components/calendar/PeriodNavBar.js +176 -0
- package/dist/components/calendar/WeekDaysBar.js +8 -4
- package/dist/components/calendar/_helpers/calendarDays.js +5 -1
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/carousel/CarouselSlider.native.js +12 -1
- package/dist/components/filter/DateFilter.js +1 -1
- package/dist/components/inputs/Select.js +56 -52
- package/dist/components/inputs/datePicker/DayPicker.js +15 -9
- package/dist/components/inputs/datePicker/MonthPicker.js +15 -10
- package/dist/components/inputs/datePicker/QuarterPicker.js +15 -10
- package/dist/components/inputs/datePicker/WeekPicker.js +15 -9
- package/dist/components/inputs/datePicker/YearPicker.js +15 -10
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/weekStart.js +25 -0
- package/dist/helpers/weekStartSetup.js +11 -0
- package/dist/helpers/weekStartSetup.native.js +11 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/src/NekoUI.js +3 -0
- package/src/abstractions/index.js +1 -0
- package/src/components/actions/Dropdown.js +2 -0
- package/src/components/calendar/PeriodNavBar.js +176 -0
- package/src/components/calendar/WeekDaysBar.js +6 -2
- package/src/components/calendar/_helpers/calendarDays.js +5 -1
- package/src/components/calendar/index.js +1 -1
- package/src/components/carousel/CarouselSlider.native.js +12 -1
- package/src/components/filter/DateFilter.js +1 -1
- package/src/components/inputs/Select.js +19 -15
- package/src/components/inputs/datePicker/DayPicker.js +14 -8
- package/src/components/inputs/datePicker/MonthPicker.js +14 -9
- package/src/components/inputs/datePicker/QuarterPicker.js +14 -9
- package/src/components/inputs/datePicker/WeekPicker.js +14 -8
- package/src/components/inputs/datePicker/YearPicker.js +14 -9
- package/src/helpers/index.js +2 -0
- package/src/helpers/weekStart.js +25 -0
- package/src/helpers/weekStartSetup.js +11 -0
- package/src/helpers/weekStartSetup.native.js +11 -0
- package/src/index.js +1 -0
package/dist/NekoUI.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/NekoUI.js";var _excluded = ["children", "i18n"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import {
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/NekoUI.js";var _excluded = ["children", "i18n"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import { initFirstDayOfWeek } from "./helpers/weekStartSetup";
|
|
2
|
+
import { DynamicStyleTag } from "./DynamicStyleTag";
|
|
2
3
|
import { I18nProvider } from "./i18n";
|
|
3
4
|
import { ModalsHandler } from "./components/modals/modal/handler/ModalsHandler";
|
|
4
5
|
import { NotificationsHandler } from "./components/feedback/notifications/NotificationsHandler";
|
|
@@ -9,6 +10,8 @@ import { ThemeHandler } from "./theme/ThemeHandler";
|
|
|
9
10
|
import { ThemePickerDrawer } from "./components/theme";
|
|
10
11
|
import { useThemeHandler } from "./theme";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
|
|
13
|
+
initFirstDayOfWeek();
|
|
14
|
+
|
|
12
15
|
export function NekoUI(_ref) {var children = _ref.children,i18n = _ref.i18n,props = _objectWithoutProperties(_ref, _excluded);
|
|
13
16
|
return (
|
|
14
17
|
_jsxs(ThemeHandler, Object.assign({}, props, { children: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Platform";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/actions/Dropdown.js";var _excluded = ["items"],_excluded2 = ["onChange", "label", "trigger", "icon", "strong", "color", "popoverProps", "iconLabelProps", "children", "placement", "gap", "useBottomDrawer"];function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import { pipe } from 'ramda';
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/actions/Dropdown.js";var _excluded = ["items"],_excluded2 = ["onChange", "label", "trigger", "icon", "strong", "color", "popoverProps", "iconLabelProps", "children", "placement", "gap", "useBottomDrawer", "snapPoints"];function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import { pipe } from 'ramda';
|
|
2
2
|
|
|
3
3
|
import { DrawerScrollView } from "../modals";
|
|
4
4
|
import { IconLabel } from "../presentation/IconLabel";
|
|
@@ -38,7 +38,8 @@ export function Dropdown(_ref) {var _this = this;var items = _ref.items,rootProp
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
formattedProps.onChange,label = formattedProps.label,_formattedProps$trigg = formattedProps.trigger,trigger = _formattedProps$trigg === void 0 ? 'click' : _formattedProps$trigg,icon = formattedProps.icon,strong = formattedProps.strong,color = formattedProps.color,popoverProps = formattedProps.popoverProps,iconLabelProps = formattedProps.iconLabelProps,children = formattedProps.children,placement = formattedProps.placement,gap = formattedProps.gap,useBottomDrawer = formattedProps.useBottomDrawer,snapPoints = formattedProps.snapPoints,props = _objectWithoutProperties(formattedProps, _excluded2);
|
|
42
43
|
|
|
43
44
|
useBottomDrawer = useResponsiveValue(useBottomDrawer || { native: true, sm: true, md: true });
|
|
44
45
|
|
|
@@ -51,7 +52,8 @@ export function Dropdown(_ref) {var _this = this;var items = _ref.items,rootProp
|
|
|
51
52
|
padding: 0,
|
|
52
53
|
|
|
53
54
|
contentProps: { padding: 0 },
|
|
54
|
-
useBottomDrawer: useBottomDrawer
|
|
55
|
+
useBottomDrawer: useBottomDrawer,
|
|
56
|
+
snapPoints: snapPoints },
|
|
55
57
|
popoverProps, {
|
|
56
58
|
renderContent: function renderContent(_ref2) {var onClose = _ref2.onClose;
|
|
57
59
|
var handleChange = function handleChange() {
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
var _excluded = ["type", "value", "onChange", "min", "max", "onCheckDisabled"];var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/calendar/PeriodNavBar.js";function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React from 'react';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import quarterOfYear from 'dayjs/esm/plugin/quarterOfYear';
|
|
4
|
+
|
|
5
|
+
import { InfiniteCarousel } from "../carousel/InfiniteCarousel";
|
|
6
|
+
import { Link } from "../actions/Link";
|
|
7
|
+
import { Text } from "../text/Text";
|
|
8
|
+
import { View } from "../structure/View";
|
|
9
|
+
import { isDateDisabled } from "./_helpers/dateDisabled";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
dayjs.extend(quarterOfYear);
|
|
12
|
+
|
|
13
|
+
function getWeekEpoch() {
|
|
14
|
+
return dayjs('2000-01-01').startOf('week');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var TYPES = {
|
|
18
|
+
day: {
|
|
19
|
+
count: 7,
|
|
20
|
+
unit: 'day',
|
|
21
|
+
toPageValue: function toPageValue(date) {
|
|
22
|
+
return date.startOf('week').diff(getWeekEpoch(), 'week');
|
|
23
|
+
},
|
|
24
|
+
getItems: function getItems(pageValue) {
|
|
25
|
+
var weekStart = getWeekEpoch().add(pageValue, 'week');
|
|
26
|
+
return Array.from({ length: 7 }, function (_, i) {
|
|
27
|
+
var d = weekStart.add(i, 'day');
|
|
28
|
+
return { key: d.valueOf(), date: d, label: d.format('ddd'), sublabel: String(d.date()) };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
week: {
|
|
33
|
+
count: 7,
|
|
34
|
+
unit: 'week',
|
|
35
|
+
toPageValue: function toPageValue(date) {
|
|
36
|
+
var weekIndex = date.startOf('week').diff(getWeekEpoch(), 'week');
|
|
37
|
+
return Math.floor(weekIndex / 7);
|
|
38
|
+
},
|
|
39
|
+
getItems: function getItems(pageValue) {
|
|
40
|
+
return Array.from({ length: 7 }, function (_, i) {
|
|
41
|
+
var weekIndex = pageValue * 7 + i;
|
|
42
|
+
var d = getWeekEpoch().add(weekIndex, 'week');
|
|
43
|
+
var end = d.add(6, 'day');
|
|
44
|
+
return { key: d.valueOf(), date: d, label: `${d.date()}-${end.date()}`, sublabel: d.format('MMM') };
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
month: {
|
|
49
|
+
count: 7,
|
|
50
|
+
unit: 'month',
|
|
51
|
+
toPageValue: function toPageValue(date) {
|
|
52
|
+
var absMonth = date.year() * 12 + date.month();
|
|
53
|
+
return Math.floor(absMonth / 7);
|
|
54
|
+
},
|
|
55
|
+
getItems: function getItems(pageValue) {
|
|
56
|
+
return Array.from({ length: 7 }, function (_, i) {
|
|
57
|
+
var absMonth = pageValue * 7 + i;
|
|
58
|
+
var year = Math.floor(absMonth / 12);
|
|
59
|
+
var month = absMonth % 12;
|
|
60
|
+
var d = dayjs().year(year).month(month).startOf('month');
|
|
61
|
+
return { key: d.valueOf(), date: d, label: d.format('MMM'), sublabel: d.format("'YY") };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
quarter: {
|
|
66
|
+
count: 4,
|
|
67
|
+
unit: 'quarter',
|
|
68
|
+
toPageValue: function toPageValue(date) {
|
|
69
|
+
return date.year();
|
|
70
|
+
},
|
|
71
|
+
getItems: function getItems(pageValue) {
|
|
72
|
+
return Array.from({ length: 4 }, function (_, i) {
|
|
73
|
+
var d = dayjs().year(pageValue).month(i * 3).startOf('month');
|
|
74
|
+
return { key: d.valueOf(), date: d, label: `Q${i + 1}`, sublabel: String(pageValue) };
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
year: {
|
|
79
|
+
count: 7,
|
|
80
|
+
unit: 'year',
|
|
81
|
+
toPageValue: function toPageValue(date) {
|
|
82
|
+
return Math.floor(date.year() / 7);
|
|
83
|
+
},
|
|
84
|
+
getItems: function getItems(pageValue) {
|
|
85
|
+
return Array.from({ length: 7 }, function (_, i) {
|
|
86
|
+
var year = pageValue * 7 + i;
|
|
87
|
+
var d = dayjs().year(year).startOf('year');
|
|
88
|
+
return { key: d.valueOf(), date: d, label: String(year), sublabel: null };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
var PeriodSlide = React.memo(function PeriodSlide(_ref) {var _this = this;var items = _ref.items,value = _ref.value,unit = _ref.unit,onChange = _ref.onChange,min = _ref.min,max = _ref.max,onCheckDisabled = _ref.onCheckDisabled;
|
|
95
|
+
return (
|
|
96
|
+
_jsx(View, { row: true, center: true, gap: "xs", children:
|
|
97
|
+
items.map(function (item) {
|
|
98
|
+
var isActive = !!value && dayjs(value).isSame(item.date, unit);
|
|
99
|
+
var disabled = isDateDisabled(item.date, { min: min, max: max, onCheckDisabled: onCheckDisabled });
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
_jsxs(Link, {
|
|
103
|
+
|
|
104
|
+
flex: true,
|
|
105
|
+
center: true,
|
|
106
|
+
br: "md",
|
|
107
|
+
paddingV: "xs",
|
|
108
|
+
onPress: function onPress() {return onChange(item.date);},
|
|
109
|
+
bg: isActive && 'primary',
|
|
110
|
+
disabled: disabled, children: [
|
|
111
|
+
|
|
112
|
+
_jsx(Text, { sm: true, center: true, strong: isActive, text2: !isActive, children:
|
|
113
|
+
item.label }
|
|
114
|
+
),
|
|
115
|
+
item.sublabel &&
|
|
116
|
+
_jsx(Text, { xxs: true, center: true, text4: !isActive, strong: isActive, children:
|
|
117
|
+
item.sublabel }
|
|
118
|
+
)] }, item.key
|
|
119
|
+
|
|
120
|
+
));
|
|
121
|
+
|
|
122
|
+
}) }
|
|
123
|
+
));
|
|
124
|
+
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export function PeriodNavBar(_ref2) {var _this2 = this;var _ref2$type = _ref2.type,type = _ref2$type === void 0 ? 'day' : _ref2$type,value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,props = _objectWithoutProperties(_ref2, _excluded);
|
|
128
|
+
var config = TYPES[type];
|
|
129
|
+
var _React$useState = React.useState(value),_React$useState2 = _slicedToArray(_React$useState, 2),localValue = _React$useState2[0],setLocalValue = _React$useState2[1];
|
|
130
|
+
var resolvedValue = value === undefined ? localValue : value;
|
|
131
|
+
|
|
132
|
+
var _React$useState3 = React.useState(function () {
|
|
133
|
+
var date = resolvedValue ? dayjs(resolvedValue) : dayjs();
|
|
134
|
+
return config.toPageValue(date);
|
|
135
|
+
}),_React$useState4 = _slicedToArray(_React$useState3, 2),currentPage = _React$useState4[0],setCurrentPage = _React$useState4[1];
|
|
136
|
+
|
|
137
|
+
React.useEffect(function () {
|
|
138
|
+
var date = resolvedValue ? dayjs(resolvedValue) : dayjs();
|
|
139
|
+
setCurrentPage(TYPES[type].toPageValue(date));
|
|
140
|
+
}, [resolvedValue, type]);
|
|
141
|
+
|
|
142
|
+
var handleSelect = React.useCallback(
|
|
143
|
+
function (date) {
|
|
144
|
+
setLocalValue(date);
|
|
145
|
+
onChange == null ? void 0 : onChange(date);
|
|
146
|
+
},
|
|
147
|
+
[onChange]
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
var minPage = min ? config.toPageValue(dayjs(min)) : undefined;
|
|
151
|
+
var maxPage = max ? config.toPageValue(dayjs(max)) : undefined;
|
|
152
|
+
|
|
153
|
+
var renderSlide = function renderSlide(pageValue) {return (
|
|
154
|
+
_jsx(PeriodSlide, {
|
|
155
|
+
items: config.getItems(pageValue),
|
|
156
|
+
value: resolvedValue,
|
|
157
|
+
unit: config.unit,
|
|
158
|
+
onChange: handleSelect,
|
|
159
|
+
min: min,
|
|
160
|
+
max: max,
|
|
161
|
+
onCheckDisabled: onCheckDisabled }
|
|
162
|
+
));};
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
_jsx(View, Object.assign({ className: "neko-period-nav-bar" }, props, { children:
|
|
167
|
+
_jsx(InfiniteCarousel, {
|
|
168
|
+
value: currentPage,
|
|
169
|
+
onChange: setCurrentPage,
|
|
170
|
+
renderSlide: renderSlide,
|
|
171
|
+
min: minPage,
|
|
172
|
+
max: maxPage }
|
|
173
|
+
) })
|
|
174
|
+
));
|
|
175
|
+
|
|
176
|
+
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/calendar/WeekDaysBar.js";import { Text } from "../text/Text";
|
|
2
|
-
import { View } from "../structure/View";
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/calendar/WeekDaysBar.js";function _toConsumableArray(r) {return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();}function _nonIterableSpread() {throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _iterableToArray(r) {if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);}function _arrayWithoutHoles(r) {if (Array.isArray(r)) return _arrayLikeToArray(r);}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}import { Text } from "../text/Text";
|
|
2
|
+
import { View } from "../structure/View";
|
|
3
|
+
import { getFirstDayOfWeek } from "../../helpers/weekStart";import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
4
|
|
|
4
|
-
var
|
|
5
|
+
var ALL_DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
5
6
|
|
|
6
7
|
export function WeekDaysBar() {var _this = this;
|
|
8
|
+
var firstDay = getFirstDayOfWeek();
|
|
9
|
+
var labels = [].concat(_toConsumableArray(ALL_DAYS.slice(firstDay)), _toConsumableArray(ALL_DAYS.slice(0, firstDay)));
|
|
10
|
+
|
|
7
11
|
return (
|
|
8
12
|
_jsx(View, { className: "neko-week-days-bar", row: true, center: true, gap: "sm", children:
|
|
9
|
-
|
|
13
|
+
labels.map(function (w) {return (
|
|
10
14
|
_jsx(View, { flex: true, height: 30, center: true, children:
|
|
11
15
|
_jsx(Text, { center: true, sm: true, text4: true, children:
|
|
12
16
|
w }
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
+
import { getFirstDayOfWeek } from "../../../helpers/weekStart";
|
|
5
|
+
|
|
4
6
|
export function useCalendarDays(currentMonth) {
|
|
5
7
|
return React.useMemo(function () {var _currentMonth;
|
|
6
8
|
if (!((_currentMonth = currentMonth) != null && _currentMonth.isValid != null && _currentMonth.isValid())) currentMonth = dayjs();
|
|
7
9
|
var startWeekday = currentMonth.startOf('month').day();
|
|
10
|
+
var firstDay = getFirstDayOfWeek();
|
|
11
|
+
var offset = (startWeekday - firstDay + 7) % 7;
|
|
8
12
|
var daysInMonth = currentMonth.daysInMonth();
|
|
9
13
|
|
|
10
|
-
var blanks = Array.from({ length:
|
|
14
|
+
var blanks = Array.from({ length: offset }, function () {return null;});
|
|
11
15
|
var days = Array.from({ length: daysInMonth }, function (_, i) {return i + 1;});
|
|
12
16
|
var cells = [].concat(blanks, days);
|
|
13
17
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PeriodNavBar";
|
|
@@ -27,12 +27,20 @@ export function CarouselSlider() {var _this = this;
|
|
|
27
27
|
var translateX = useSharedValue(0);
|
|
28
28
|
var gestureStartX = useSharedValue(0);
|
|
29
29
|
var prevItemsRef = React.useRef(items);
|
|
30
|
+
var gestureAnimatingRef = React.useRef(false);
|
|
31
|
+
|
|
32
|
+
var setGestureAnimating = React.useCallback(function (v) {
|
|
33
|
+
gestureAnimatingRef.current = v;
|
|
34
|
+
}, []);
|
|
30
35
|
|
|
31
36
|
React.useEffect(function () {
|
|
32
37
|
if (slideWidth > 0) {
|
|
33
38
|
if (prevItemsRef.current !== items) {
|
|
34
39
|
prevItemsRef.current = items;
|
|
35
40
|
translateX.value = -activeIndex * slideWidth;
|
|
41
|
+
} else if (gestureAnimatingRef.current) {
|
|
42
|
+
|
|
43
|
+
gestureAnimatingRef.current = false;
|
|
36
44
|
} else {
|
|
37
45
|
translateX.value = withTiming(-activeIndex * slideWidth, { duration: 300 }, function (finished) {var _items$activeIndex;
|
|
38
46
|
if (finished && afterChange) runOnJS(afterChange)(items == null ? void 0 : (_items$activeIndex = items[activeIndex]) == null ? void 0 : _items$activeIndex.key, activeIndex);
|
|
@@ -87,7 +95,10 @@ export function CarouselSlider() {var _this = this;
|
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
var clamped = clampIndex(targetIndex, itemsCount, loop);
|
|
90
|
-
translateX.value = withTiming(-clamped * slideWidth, { duration: 300 });
|
|
98
|
+
translateX.value = withTiming(-clamped * slideWidth, { duration: 300 }, function (finished) {var _items$clamped;
|
|
99
|
+
if (finished && afterChange) runOnJS(afterChange)(items == null ? void 0 : (_items$clamped = items[clamped]) == null ? void 0 : _items$clamped.key, clamped);
|
|
100
|
+
});
|
|
101
|
+
runOnJS(setGestureAnimating)(true);
|
|
91
102
|
runOnJS(goTo)(targetIndex);
|
|
92
103
|
runOnJS(resumeAutoplay)();
|
|
93
104
|
});
|
|
@@ -33,7 +33,7 @@ function formatValue(value, type) {
|
|
|
33
33
|
case 'month':
|
|
34
34
|
return [date.startOf('month'), date.endOf('month')];
|
|
35
35
|
case 'week':
|
|
36
|
-
return [date.startOf('
|
|
36
|
+
return [date.startOf('week'), date.endOf('week')];
|
|
37
37
|
default:
|
|
38
38
|
return [date.startOf('day'), date.endOf('day')];
|
|
39
39
|
}
|
|
@@ -2,6 +2,7 @@ var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/compon
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { Icon, IconLabel } from "../presentation";
|
|
5
|
+
import { KeyboardDismissButton } from "../keyboard";
|
|
5
6
|
import { Link } from "../actions";
|
|
6
7
|
import { LinkInput } from "./LinkInput";
|
|
7
8
|
import { Picker, getOptionLabel, searchOptions } from "./Picker";
|
|
@@ -134,58 +135,61 @@ export function Select(_ref2)
|
|
|
134
135
|
maxHeight: popoverMaxHeight },
|
|
135
136
|
popoverProps, {
|
|
136
137
|
renderContent: function renderContent(_ref3) {var onClose = _ref3.onClose;return (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
138
|
+
_jsxs(_Fragment, { children: [
|
|
139
|
+
useBottomDrawer && useSearch && _jsx(KeyboardDismissButton, {}),
|
|
140
|
+
_jsx(Picker, Object.assign({
|
|
141
|
+
row: false,
|
|
142
|
+
options: searchOptions(options, search, { labelKey: labelKey }),
|
|
143
|
+
value: value,
|
|
144
|
+
gap: 0,
|
|
145
|
+
maxHeight: !useBottomDrawer && popoverMaxHeight,
|
|
146
|
+
useFlatList: true,
|
|
147
|
+
onlyOnScreen: true,
|
|
148
|
+
itemMinHeight: 30,
|
|
149
|
+
onChange: function onChange(v, option) {
|
|
150
|
+
handleChange(v, option);
|
|
151
|
+
if (!multiple) {
|
|
152
|
+
setFocus(false);
|
|
153
|
+
onClose();
|
|
154
|
+
}
|
|
155
|
+
} },
|
|
156
|
+
pickerProps, {
|
|
157
|
+
renderHeader:
|
|
158
|
+
useBottomDrawer && useSearch ?
|
|
159
|
+
_jsxs(_Fragment, { children: [
|
|
160
|
+
_jsx(View, { padding: "md", paddingB: "xs", children:
|
|
161
|
+
_jsx(TextInput, {
|
|
162
|
+
prefixIcon: "search-line",
|
|
163
|
+
prefixIconColor: "text4",
|
|
164
|
+
value: search,
|
|
165
|
+
onChange: handleChangeSearch }
|
|
166
|
+
) }
|
|
167
|
+
),
|
|
168
|
+
renderHeader == null ? void 0 : renderHeader()] }
|
|
169
|
+
) :
|
|
170
|
+
|
|
171
|
+
renderHeader,
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
renderOption: function renderOption(_ref4) {var option = _ref4.option,selected = _ref4.selected,onChange = _ref4.onChange;return (
|
|
175
|
+
_jsxs(Link, {
|
|
176
|
+
row: true,
|
|
177
|
+
paddingH: useBottomDrawer ? 'md' : 'sm',
|
|
178
|
+
paddingV: "xs",
|
|
179
|
+
minHeight: useBottomDrawer ? 'xl' : 'md',
|
|
180
|
+
gap: "sm",
|
|
181
|
+
onMouseDown: function onMouseDown(e) {return !!multiple && e.preventDefault();},
|
|
182
|
+
onPress: onChange,
|
|
183
|
+
centerV: true,
|
|
184
|
+
bg: selected && 'primary_op10', children: [
|
|
185
|
+
|
|
186
|
+
_jsx(View, { flex: true, row: true, children:
|
|
187
|
+
finalRenderOption({ option: option, labelKey: labelKey, selected: selected }) }
|
|
188
|
+
),
|
|
189
|
+
selected && _jsx(Icon, { name: "checkbox-circle-fill", primary: true })] }
|
|
190
|
+
));} })
|
|
191
|
+
|
|
192
|
+
)] }
|
|
189
193
|
));}, children:
|
|
190
194
|
|
|
191
195
|
|
|
@@ -24,7 +24,9 @@ function fromMonthValue(v) {
|
|
|
24
24
|
startOf('month');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function MonthDays(_ref) {var _this = this;var
|
|
27
|
+
var MonthDays = React.memo(function MonthDays(_ref) {var _this = this;var monthValue = _ref.monthValue,selectedKey = _ref.selectedKey,onSelect = _ref.onSelect,min = _ref.min,max = _ref.max,onCheckDisabled = _ref.onCheckDisabled;
|
|
28
|
+
var month = fromMonthValue(monthValue);
|
|
29
|
+
var selectedValue = selectedKey ? dayjs(selectedKey) : null;
|
|
28
30
|
var _useCalendarDays = useCalendarDays(month),cells = _useCalendarDays.cells;
|
|
29
31
|
|
|
30
32
|
return (
|
|
@@ -57,9 +59,9 @@ function MonthDays(_ref) {var _this = this;var month = _ref.month,selectedValue
|
|
|
57
59
|
)] }
|
|
58
60
|
));
|
|
59
61
|
|
|
60
|
-
}
|
|
62
|
+
});
|
|
61
63
|
|
|
62
|
-
export function DayPicker(_ref2) {var _value2,_value3,_value4,_this2 = this;var value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,allowClear = _ref2.allowClear,props = _objectWithoutProperties(_ref2, _excluded);
|
|
64
|
+
export function DayPicker(_ref2) {var _value2,_value3,_value4,_value5,_this2 = this;var value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,allowClear = _ref2.allowClear,props = _objectWithoutProperties(_ref2, _excluded);
|
|
63
65
|
if (!!value) value = dayjs(value);
|
|
64
66
|
var _React$useState = React.useState(value),_React$useState2 = _slicedToArray(_React$useState, 2),localValue = _React$useState2[0],setLocalValue = _React$useState2[1];
|
|
65
67
|
var _React$useState3 = React.useState(function () {return dayjs(value || undefined).startOf('month');}),_React$useState4 = _slicedToArray(_React$useState3, 2),currentMonth = _React$useState4[0],setCurrentMonth = _React$useState4[1];
|
|
@@ -70,19 +72,23 @@ export function DayPicker(_ref2) {var _value2,_value3,_value4,_this2 = this;var
|
|
|
70
72
|
if ((_value = value) != null && _value.isValid != null && _value.isValid()) setCurrentMonth(value.startOf('month'));
|
|
71
73
|
}, [(_value2 = value) == null ? void 0 : _value2.day == null ? void 0 : _value2.day(), (_value3 = value) == null ? void 0 : _value3.month == null ? void 0 : _value3.month(), (_value4 = value) == null ? void 0 : _value4.year == null ? void 0 : _value4.year()]);
|
|
72
74
|
|
|
73
|
-
var handleChange =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
var handleChange = React.useCallback(
|
|
76
|
+
function (v) {
|
|
77
|
+
setLocalValue(v);
|
|
78
|
+
onChange == null ? void 0 : onChange(v);
|
|
79
|
+
},
|
|
80
|
+
[onChange]
|
|
81
|
+
);
|
|
77
82
|
|
|
78
83
|
var monthValue = toMonthValue(currentMonth);
|
|
79
84
|
var minMonth = min ? toMonthValue(dayjs(min).startOf('month')) : undefined;
|
|
80
85
|
var maxMonth = max ? toMonthValue(dayjs(max).startOf('month')) : undefined;
|
|
86
|
+
var selectedKey = (_value5 = value) == null ? void 0 : _value5.valueOf == null ? void 0 : _value5.valueOf();
|
|
81
87
|
|
|
82
88
|
var renderSlide = function renderSlide(v) {return (
|
|
83
89
|
_jsx(MonthDays, {
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
monthValue: v,
|
|
91
|
+
selectedKey: selectedKey,
|
|
86
92
|
onSelect: handleChange,
|
|
87
93
|
min: min,
|
|
88
94
|
max: max,
|
|
@@ -14,14 +14,15 @@ import { isDateDisabled } from "../../calendar/_helpers/dateDisabled";import { j
|
|
|
14
14
|
|
|
15
15
|
var months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
16
16
|
|
|
17
|
-
function MonthGrid(_ref) {var _this = this;var year = _ref.year,
|
|
17
|
+
var MonthGrid = React.memo(function MonthGrid(_ref) {var _this = this;var year = _ref.year,selectedKey = _ref.selectedKey,onSelect = _ref.onSelect,min = _ref.min,max = _ref.max,onCheckDisabled = _ref.onCheckDisabled;
|
|
18
18
|
var yearDate = dayjs().year(year).startOf('year');
|
|
19
|
+
var selectedValue = selectedKey ? dayjs(selectedKey) : null;
|
|
19
20
|
|
|
20
21
|
return (
|
|
21
22
|
_jsx(Grid, { colSpan: 8, gap: "xs", children:
|
|
22
23
|
months.map(function (month) {
|
|
23
24
|
var dateVal = yearDate.month(month);
|
|
24
|
-
var isActive = !!selectedValue && dateVal.isSame(selectedValue, '
|
|
25
|
+
var isActive = !!selectedValue && dateVal.isSame(selectedValue, 'month');
|
|
25
26
|
var disabled = isDateDisabled(dateVal, { min: min, max: max, onCheckDisabled: onCheckDisabled });
|
|
26
27
|
|
|
27
28
|
return (
|
|
@@ -43,9 +44,9 @@ function MonthGrid(_ref) {var _this = this;var year = _ref.year,selectedValue =
|
|
|
43
44
|
}) }
|
|
44
45
|
));
|
|
45
46
|
|
|
46
|
-
}
|
|
47
|
+
});
|
|
47
48
|
|
|
48
|
-
export function MonthPicker(_ref2) {var _value2,_value3,_this2 = this;var value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,allowClear = _ref2.allowClear,props = _objectWithoutProperties(_ref2, _excluded);
|
|
49
|
+
export function MonthPicker(_ref2) {var _value2,_value3,_value4,_this2 = this;var value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,allowClear = _ref2.allowClear,props = _objectWithoutProperties(_ref2, _excluded);
|
|
49
50
|
var _React$useState = React.useState(value),_React$useState2 = _slicedToArray(_React$useState, 2),localValue = _React$useState2[0],setLocalValue = _React$useState2[1];
|
|
50
51
|
var _React$useState3 = React.useState(function () {return dayjs(value || undefined).startOf('year');}),_React$useState4 = _slicedToArray(_React$useState3, 2),currentYear = _React$useState4[0],setCurrentYear = _React$useState4[1];
|
|
51
52
|
value = value === undefined ? localValue : value;
|
|
@@ -55,18 +56,22 @@ export function MonthPicker(_ref2) {var _value2,_value3,_this2 = this;var value
|
|
|
55
56
|
if ((_value = value) != null && _value.isValid != null && _value.isValid()) setCurrentYear(value.startOf('year'));
|
|
56
57
|
}, [(_value2 = value) == null ? void 0 : _value2.month == null ? void 0 : _value2.month(), (_value3 = value) == null ? void 0 : _value3.year == null ? void 0 : _value3.year()]);
|
|
57
58
|
|
|
58
|
-
var handleChange =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
var handleChange = React.useCallback(
|
|
60
|
+
function (v) {
|
|
61
|
+
var newValue = v.startOf('month');
|
|
62
|
+
setLocalValue(newValue);
|
|
63
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
64
|
+
},
|
|
65
|
+
[onChange]
|
|
66
|
+
);
|
|
63
67
|
|
|
64
68
|
var yearValue = currentYear.year();
|
|
65
69
|
var minYear = min ? dayjs(min).year() : undefined;
|
|
66
70
|
var maxYear = max ? dayjs(max).year() : undefined;
|
|
71
|
+
var selectedKey = (_value4 = value) == null ? void 0 : _value4.valueOf == null ? void 0 : _value4.valueOf();
|
|
67
72
|
|
|
68
73
|
var renderSlide = function renderSlide(v) {return (
|
|
69
|
-
_jsx(MonthGrid, { year: v,
|
|
74
|
+
_jsx(MonthGrid, { year: v, selectedKey: selectedKey, onSelect: handleChange, min: min, max: max, onCheckDisabled: onCheckDisabled }));};
|
|
70
75
|
|
|
71
76
|
|
|
72
77
|
return (
|
|
@@ -17,14 +17,15 @@ dayjs.extend(quarterOfYear);
|
|
|
17
17
|
|
|
18
18
|
var quarters = [1, 2, 3, 4];
|
|
19
19
|
|
|
20
|
-
function QuarterGrid(_ref) {var _this = this;var year = _ref.year,
|
|
20
|
+
var QuarterGrid = React.memo(function QuarterGrid(_ref) {var _this = this;var year = _ref.year,selectedKey = _ref.selectedKey,onSelect = _ref.onSelect,min = _ref.min,max = _ref.max,onCheckDisabled = _ref.onCheckDisabled;
|
|
21
21
|
var yearDate = dayjs().year(year).startOf('year');
|
|
22
|
+
var selectedValue = selectedKey ? dayjs(selectedKey) : null;
|
|
22
23
|
|
|
23
24
|
return (
|
|
24
25
|
_jsx(Grid, { colSpan: 6, gap: "xs", children:
|
|
25
26
|
quarters.map(function (quarter) {
|
|
26
27
|
var dateVal = yearDate.quarter(quarter);
|
|
27
|
-
var isActive = !!selectedValue && dateVal.isSame(selectedValue, '
|
|
28
|
+
var isActive = !!selectedValue && dateVal.isSame(selectedValue, 'quarter');
|
|
28
29
|
var disabled = isDateDisabled(dateVal, { min: min, max: max, onCheckDisabled: onCheckDisabled });
|
|
29
30
|
|
|
30
31
|
return (
|
|
@@ -46,9 +47,9 @@ function QuarterGrid(_ref) {var _this = this;var year = _ref.year,selectedValue
|
|
|
46
47
|
}) }
|
|
47
48
|
));
|
|
48
49
|
|
|
49
|
-
}
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
export function QuarterPicker(_ref2) {var _value2,_value3,_this2 = this;var value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,allowClear = _ref2.allowClear,props = _objectWithoutProperties(_ref2, _excluded);
|
|
52
|
+
export function QuarterPicker(_ref2) {var _value2,_value3,_value4,_this2 = this;var value = _ref2.value,onChange = _ref2.onChange,min = _ref2.min,max = _ref2.max,onCheckDisabled = _ref2.onCheckDisabled,allowClear = _ref2.allowClear,props = _objectWithoutProperties(_ref2, _excluded);
|
|
52
53
|
var _React$useState = React.useState(value),_React$useState2 = _slicedToArray(_React$useState, 2),localValue = _React$useState2[0],setLocalValue = _React$useState2[1];
|
|
53
54
|
var _React$useState3 = React.useState(function () {return dayjs(value || undefined).startOf('year');}),_React$useState4 = _slicedToArray(_React$useState3, 2),currentYear = _React$useState4[0],setCurrentYear = _React$useState4[1];
|
|
54
55
|
value = value === undefined ? localValue : value;
|
|
@@ -58,18 +59,22 @@ export function QuarterPicker(_ref2) {var _value2,_value3,_this2 = this;var valu
|
|
|
58
59
|
if ((_value = value) != null && _value.isValid != null && _value.isValid()) setCurrentYear(value.startOf('year'));
|
|
59
60
|
}, [(_value2 = value) == null ? void 0 : _value2.quarter == null ? void 0 : _value2.quarter(), (_value3 = value) == null ? void 0 : _value3.year == null ? void 0 : _value3.year()]);
|
|
60
61
|
|
|
61
|
-
var handleChange =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
var handleChange = React.useCallback(
|
|
63
|
+
function (v) {
|
|
64
|
+
var newValue = v.startOf('quarter');
|
|
65
|
+
setLocalValue(newValue);
|
|
66
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
67
|
+
},
|
|
68
|
+
[onChange]
|
|
69
|
+
);
|
|
66
70
|
|
|
67
71
|
var yearValue = currentYear.year();
|
|
68
72
|
var minYear = min ? dayjs(min).year() : undefined;
|
|
69
73
|
var maxYear = max ? dayjs(max).year() : undefined;
|
|
74
|
+
var selectedKey = (_value4 = value) == null ? void 0 : _value4.valueOf == null ? void 0 : _value4.valueOf();
|
|
70
75
|
|
|
71
76
|
var renderSlide = function renderSlide(v) {return (
|
|
72
|
-
_jsx(QuarterGrid, { year: v,
|
|
77
|
+
_jsx(QuarterGrid, { year: v, selectedKey: selectedKey, onSelect: handleChange, min: min, max: max, onCheckDisabled: onCheckDisabled }));};
|
|
73
78
|
|
|
74
79
|
|
|
75
80
|
return (
|