@cashub/ui 0.21.0 → 0.21.1
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/Tab/Tab.js +9 -13
- package/Tab/TabList.js +14 -32
- package/Tab/TabPanel.js +21 -58
- package/Tab/TabTab.js +20 -40
- package/Tab/index.js +2 -10
- package/Tab/subComponent/TabContext.js +2 -5
- package/animate/Collapse.js +26 -53
- package/animate/Loader.js +21 -26
- package/animate/NumberCounter.js +22 -44
- package/animate/PulseRing.js +9 -21
- package/animate/Spinner.js +2 -10
- package/animate/index.js +5 -11
- package/backdrop/BaseBackdrop.js +2 -9
- package/backdrop/LoadingBackdrop.js +2 -9
- package/backdrop/ModalBackdrop.js +2 -9
- package/backdrop/index.js +3 -7
- package/badge/Badge.js +2 -11
- package/badge/BadgeDot.js +2 -10
- package/badge/BadgeFill.js +15 -20
- package/badge/BadgeWithText.js +6 -13
- package/badge/index.js +4 -9
- package/billing/BarChart.js +10 -17
- package/billing/Grid.js +11 -15
- package/billing/Header2.js +6 -9
- package/billing/Header3.js +9 -16
- package/billing/Paragraph.js +8 -14
- package/billing/ParagraphGroup.js +6 -9
- package/billing/ParagraphText.js +7 -12
- package/billing/Section.js +13 -23
- package/billing/SectionBody.js +5 -8
- package/billing/SectionHeader.js +7 -12
- package/breadcrumb/Breadcrumb.js +11 -21
- package/breadcrumb/index.js +1 -3
- package/button/Button.js +41 -38
- package/button/ButtonGroup.js +21 -18
- package/button/IconButton.js +29 -29
- package/button/ScrollToTopButton.js +12 -39
- package/button/index.js +4 -9
- package/callout/Callout.js +13 -26
- package/callout/index.js +1 -3
- package/chart/BarChart.js +28 -53
- package/chart/DoughnutChart.js +23 -62
- package/chart/LineChart.js +33 -55
- package/chart/SingleBarChart.js +11 -17
- package/chart/index.js +5 -12
- package/chart/utils/customTooltip.js +26 -43
- package/chart/utils/htmlLegendPlugin.js +24 -30
- package/chart/utils/index.js +3 -7
- package/chart/utils/padEmptyChartBar.js +24 -22
- package/container/FlexContainer.js +9 -12
- package/container/index.js +1 -3
- package/cropper/Cropper.js +21 -34
- package/cropper/CropperModalHandler.js +15 -21
- package/cropper/index.js +2 -5
- package/cropper/subComponent/CropImageModal.js +23 -58
- package/datetimePicker/DatePicker.js +103 -217
- package/datetimePicker/DatePickerV2.js +116 -221
- package/datetimePicker/DatetimePicker.js +27 -48
- package/datetimePicker/DatetimePickerV2.js +115 -231
- package/datetimePicker/TimeInput.js +9 -22
- package/datetimePicker/TimePicker.js +94 -151
- package/datetimePicker/TimePickerStyle.js +2 -9
- package/datetimePicker/accordion/Month.js +70 -90
- package/datetimePicker/accordion/Year.js +91 -135
- package/datetimePicker/hooks/index.js +3 -7
- package/datetimePicker/hooks/useChangeNumber.js +14 -27
- package/datetimePicker/hooks/useDecrease.js +19 -35
- package/datetimePicker/hooks/useIncrease.js +19 -35
- package/datetimePicker/index.js +7 -15
- package/datetimePicker/provider/constant.js +2 -3
- package/datetimePicker/subComponent/Accordion.js +108 -158
- package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
- package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
- package/datetimePicker/utils/GMTDate.js +3 -7
- package/datetimePicker/utils/pad.js +2 -6
- package/datetimePicker/utils/toUTC0.js +3 -6
- package/descriptionList/DescriptionDetail.js +5 -10
- package/descriptionList/DescriptionList.js +5 -10
- package/descriptionList/DescriptionTerm.js +2 -9
- package/descriptionList/index.js +3 -7
- package/divider/Divider.js +9 -12
- package/divider/index.js +1 -3
- package/dropdown/Dropdown.js +28 -65
- package/dropdown/DropdownButtonOption.js +2 -9
- package/dropdown/DropdownContent.js +33 -64
- package/dropdown/DropdownDivOption.js +2 -9
- package/dropdown/DropdownItem.js +10 -16
- package/dropdown/DropdownLinkOption.js +2 -9
- package/dropdown/DropdownToggle.js +18 -38
- package/dropdown/index.js +6 -17
- package/dropdown/subComponent/DropdownContext.js +2 -5
- package/dropzone/FileDropzone.js +148 -302
- package/dropzone/ImageDropzone.js +96 -171
- package/dropzone/index.js +2 -5
- package/dropzone/subComponent/Message.js +7 -14
- package/figure/IconFigure.js +9 -16
- package/figure/ImageFigure.js +11 -17
- package/figure/index.js +2 -5
- package/file/HiddenFileInput.js +5 -14
- package/file/index.js +1 -3
- package/form/Checkbox.js +34 -43
- package/form/FormItem.js +2 -9
- package/form/Input.js +13 -15
- package/form/Label.js +10 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +14 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/index.js +9 -19
- package/grid/Column.js +17 -17
- package/grid/Grid.js +13 -14
- package/grid/index.js +2 -5
- package/heading/Heading1.js +5 -10
- package/heading/Heading2.js +9 -12
- package/heading/Heading3.js +21 -18
- package/heading/index.js +3 -7
- package/helmet/Helmet.js +6 -9
- package/helmet/index.js +2 -5
- package/iconbox/ApplicationIconBox.js +25 -31
- package/iconbox/IconBox.js +11 -24
- package/iconbox/IconBoxV2.js +14 -26
- package/iconbox/index.js +3 -7
- package/iconbox/subComponent/IconBoxFigure.js +25 -20
- package/iconbox/subComponent/IconBoxImage.js +15 -18
- package/image/ImageFluid.js +2 -10
- package/image/UploadImage.js +65 -113
- package/image/index.js +2 -5
- package/index.js +44 -130
- package/jsoneditor/JsonEditor.js +10 -32
- package/jsoneditor/index.js +1 -3
- package/keyframe/Pulse.js +2 -7
- package/keyframe/Spin.js +2 -7
- package/link/LinkSpan.js +22 -35
- package/link/index.js +1 -3
- package/map/GoogleMap.js +122 -175
- package/map/GoogleReverseGeolocation.js +79 -186
- package/map/LeafletMap.js +78 -132
- package/map/LeafletReverseGeolocation.js +49 -121
- package/map/index.js +4 -9
- package/map/subComponent/BasicLeafletMap.js +8 -14
- package/map/subComponent/GoogleMapContainer.js +5 -10
- package/map/subComponent/GoogleMapPopup.js +66 -123
- package/map/subComponent/GoogleMapWrapper.js +13 -32
- package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
- package/map/subComponent/LeafletDrawControl.js +47 -84
- package/map/subComponent/LeafletMapContainer.js +5 -10
- package/map/subComponent/MapSearchBoxControl.js +24 -70
- package/modal/StateModal.js +41 -100
- package/modal/TitleModal.js +89 -190
- package/modal/index.js +2 -5
- package/package.json +1 -1
- package/paginate/Paginate.js +40 -54
- package/paginate/index.js +1 -3
- package/popover/Popover.js +39 -87
- package/popover/index.js +1 -3
- package/qrcode/QRCode.js +10 -23
- package/qrcode/QRCodeContainter.js +8 -16
- package/qrcode/index.js +2 -5
- package/ribbon/Ribbon.js +4 -15
- package/ribbon/index.js +1 -3
- package/section/Section.js +57 -39
- package/section/SectionBody.js +15 -22
- package/section/SectionHeader.js +27 -27
- package/section/SectionToolbar.js +2 -9
- package/section/SectionToolbarItem.js +2 -9
- package/section/index.js +5 -11
- package/select/InputSelect.js +103 -215
- package/select/Select.js +204 -362
- package/select/index.js +2 -5
- package/select/subComponent/ListBox.js +9 -12
- package/select/subComponent/Option.js +8 -16
- package/select/subComponent/OptionGroup.js +2 -9
- package/select/subComponent/Options.js +5 -11
- package/select/subComponent/SearchBox.js +9 -29
- package/select/subComponent/SelectedMultiple.js +8 -16
- package/select/subComponent/SelectedSingle.js +2 -9
- package/styles/GlobalStyle.js +169 -91
- package/styles/config/breakpoint.style.js +2 -3
- package/styles/config/header.style.js +2 -3
- package/styles/config/sidebar.style.js +2 -3
- package/styles/index.js +2 -5
- package/styles/mixin/backgroundColor.js +17 -14
- package/styles/mixin/borderColor.js +17 -14
- package/styles/mixin/color.js +17 -14
- package/styles/mixin/colorOnBackground.js +17 -14
- package/styles/mixin/inputPlaceholder.js +3 -9
- package/styles/mixin/media.js +3 -11
- package/styles/mixin/rounded.js +13 -12
- package/styles/mixin/scrollbar.js +7 -13
- package/styles/theme/dark.theme.js +20 -20
- package/styles/theme/light.theme.js +20 -20
- package/styles/theme/white.theme.js +20 -20
- package/styles/themes.js +2 -8
- package/table/GridTable.js +105 -143
- package/table/ImageBox.js +8 -18
- package/table/PermissionTable.js +25 -25
- package/table/Table.js +137 -153
- package/table/__mock__/columns.js +2 -3
- package/table/__mock__/data.js +2 -3
- package/table/hooks/index.js +2 -5
- package/table/hooks/useCalculateDataRange.js +9 -36
- package/table/hooks/useGenerateSort.js +6 -17
- package/table/index.js +4 -9
- package/table/subComponent/BaseTableHeadCell.js +15 -21
- package/table/subComponent/GridTableFooter.js +5 -10
- package/table/subComponent/GridTableHeadCell.js +5 -10
- package/table/subComponent/Resizer.js +17 -44
- package/table/subComponent/TableFooter.js +5 -10
- package/table/subComponent/TableFooterInfo.js +2 -9
- package/table/subComponent/TableFooterPager.js +5 -12
- package/table/subComponent/TableHeadCell.js +2 -9
- package/table/subComponent/TableSort.js +13 -19
- package/tagify/TagifyStyle.js +2 -9
- package/tagify/Tags.js +15 -37
- package/tagify/index.js +2 -5
- package/text/Paragraph.js +25 -20
- package/text/index.js +1 -3
- package/timeline/Timeline.js +28 -37
- package/timeline/index.js +1 -3
- package/toast/CustomToastContainer.js +2 -9
- package/toast/MessageContainer.js +9 -18
- package/toast/index.js +3 -8
- package/toast/show.js +18 -28
- package/tooltip/Tooltip.js +48 -97
- package/tooltip/index.js +1 -3
- package/wizard/Wizard.js +63 -133
- package/wizard/index.js +1 -3
|
@@ -1,184 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = require("react");
|
|
11
|
-
|
|
12
8
|
var _reactI18next = require("react-i18next");
|
|
13
|
-
|
|
14
9
|
var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
|
|
15
|
-
|
|
16
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
|
-
|
|
18
11
|
var _md = require("react-icons/md");
|
|
19
|
-
|
|
20
12
|
var _hooks = require("@cashub/hooks");
|
|
21
|
-
|
|
22
13
|
var _utils = require("@cashub/utils");
|
|
23
|
-
|
|
24
14
|
var _Button = _interopRequireDefault(require("../button/Button"));
|
|
25
|
-
|
|
26
15
|
var _Input = _interopRequireDefault(require("../form/Input"));
|
|
27
|
-
|
|
28
16
|
var _Month = _interopRequireDefault(require("./accordion/Month"));
|
|
29
|
-
|
|
30
17
|
var _Year = _interopRequireDefault(require("./accordion/Year"));
|
|
31
|
-
|
|
32
18
|
var _DateTimePickerContext = _interopRequireDefault(require("./subComponent/DateTimePickerContext"));
|
|
33
|
-
|
|
34
19
|
var _toUTC = _interopRequireDefault(require("./utils/toUTC0"));
|
|
35
|
-
|
|
36
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
37
|
-
|
|
38
21
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
|
-
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
44
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
-
|
|
46
25
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
67
|
-
|
|
68
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
69
|
-
|
|
70
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
71
|
-
|
|
72
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
73
|
-
|
|
74
|
-
var DEFAULT_TIME = '00:00:00';
|
|
75
|
-
|
|
76
|
-
var DatePickerV2 = function DatePickerV2(_ref) {
|
|
77
|
-
var selected = _ref.selected,
|
|
78
|
-
fixedYear = _ref.fixedYear,
|
|
79
|
-
allowClear = _ref.allowClear,
|
|
80
|
-
minDate = _ref.minDate,
|
|
81
|
-
maxDate = _ref.maxDate,
|
|
82
|
-
onConfirm = _ref.onConfirm,
|
|
83
|
-
disabled = _ref.disabled;
|
|
84
|
-
|
|
85
|
-
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
86
|
-
t = _useTranslation.t;
|
|
87
|
-
|
|
88
|
-
var _useState = (0, _react.useState)(null),
|
|
89
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
90
|
-
toggleElement = _useState2[0],
|
|
91
|
-
setToggleElement = _useState2[1];
|
|
92
|
-
|
|
93
|
-
var _useState3 = (0, _react.useState)(null),
|
|
94
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
95
|
-
contentElement = _useState4[0],
|
|
96
|
-
setContentElement = _useState4[1];
|
|
97
|
-
|
|
98
|
-
var _useState5 = (0, _react.useState)(function () {
|
|
99
|
-
var defaultDate = selected ? new Date(selected) : new Date();
|
|
26
|
+
const DEFAULT_TIME = '00:00:00';
|
|
27
|
+
const DatePickerV2 = _ref => {
|
|
28
|
+
let {
|
|
29
|
+
selected,
|
|
30
|
+
fixedYear,
|
|
31
|
+
allowClear,
|
|
32
|
+
minDate,
|
|
33
|
+
maxDate,
|
|
34
|
+
onConfirm,
|
|
35
|
+
disabled
|
|
36
|
+
} = _ref;
|
|
37
|
+
const {
|
|
38
|
+
t
|
|
39
|
+
} = (0, _reactI18next.useTranslation)();
|
|
40
|
+
const [toggleElement, setToggleElement] = (0, _react.useState)(null);
|
|
41
|
+
const [contentElement, setContentElement] = (0, _react.useState)(null);
|
|
42
|
+
const [selectedDate, setSelectedDate] = (0, _react.useState)(() => {
|
|
43
|
+
const defaultDate = selected ? new Date(selected) : new Date();
|
|
100
44
|
return "".concat((0, _utils.formatDate)((0, _toUTC.default)(defaultDate), 'date'), " ").concat(DEFAULT_TIME);
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
setConfirmDate = _useState8[1];
|
|
110
|
-
|
|
111
|
-
var _useState9 = (0, _react.useState)(false),
|
|
112
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
113
|
-
displayPicker = _useState10[0],
|
|
114
|
-
setDisplayPicker = _useState10[1];
|
|
115
|
-
|
|
116
|
-
var _useState11 = (0, _react.useState)(null),
|
|
117
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
118
|
-
accordionCurrentDisplayType = _useState12[0],
|
|
119
|
-
setAccordionCurrentDisplayType = _useState12[1];
|
|
120
|
-
|
|
121
|
-
var weeks = (0, _react.useMemo)(function () {
|
|
122
|
-
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(function (week) {
|
|
123
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
|
|
124
|
-
children: week
|
|
125
|
-
}, week);
|
|
126
|
-
});
|
|
45
|
+
});
|
|
46
|
+
const [confirmDate, setConfirmDate] = (0, _react.useState)(selected ? (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date') : '');
|
|
47
|
+
const [displayPicker, setDisplayPicker] = (0, _react.useState)(false);
|
|
48
|
+
const [accordionCurrentDisplayType, setAccordionCurrentDisplayType] = (0, _react.useState)(null);
|
|
49
|
+
const weeks = (0, _react.useMemo)(() => {
|
|
50
|
+
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(week => /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
|
|
51
|
+
children: week
|
|
52
|
+
}, week));
|
|
127
53
|
}, []);
|
|
128
|
-
|
|
54
|
+
const minDateWithTime = (0, _react.useMemo)(() => {
|
|
129
55
|
if (!minDate) return;
|
|
130
56
|
return "".concat(minDate, " 00:00:00");
|
|
131
57
|
}, [minDate]);
|
|
132
|
-
|
|
58
|
+
const maxDateWithTime = (0, _react.useMemo)(() => {
|
|
133
59
|
if (!maxDate) return;
|
|
134
60
|
return "".concat(maxDate, " 00:00:00");
|
|
135
61
|
}, [maxDate]);
|
|
136
|
-
|
|
137
|
-
|
|
62
|
+
const {
|
|
63
|
+
styles,
|
|
64
|
+
attributes,
|
|
65
|
+
state,
|
|
66
|
+
update
|
|
67
|
+
} = (0, _hooks.useCustomPopper)(toggleElement, contentElement, {
|
|
138
68
|
strategy: 'absolute',
|
|
139
69
|
placement: 'bottom-start'
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
state = _useCustomPopper.state,
|
|
144
|
-
update = _useCustomPopper.update;
|
|
145
|
-
|
|
146
|
-
var context = {
|
|
147
|
-
fixedYear: fixedYear,
|
|
70
|
+
});
|
|
71
|
+
const context = {
|
|
72
|
+
fixedYear,
|
|
148
73
|
minDate: minDateWithTime,
|
|
149
74
|
maxDate: maxDateWithTime,
|
|
150
|
-
selectedDate
|
|
151
|
-
setSelectedDate
|
|
152
|
-
setAccordionCurrentDisplayType
|
|
75
|
+
selectedDate,
|
|
76
|
+
setSelectedDate,
|
|
77
|
+
setAccordionCurrentDisplayType
|
|
153
78
|
};
|
|
154
|
-
|
|
155
|
-
var handleToggle = function handleToggle() {
|
|
79
|
+
const handleToggle = () => {
|
|
156
80
|
setDisplayPicker(!displayPicker);
|
|
157
81
|
update();
|
|
158
82
|
};
|
|
159
|
-
|
|
160
|
-
var changeDisplayAccordion = (0, _react.useCallback)(function (type) {
|
|
83
|
+
const changeDisplayAccordion = (0, _react.useCallback)(type => {
|
|
161
84
|
if (accordionCurrentDisplayType === type) {
|
|
162
85
|
setAccordionCurrentDisplayType(null);
|
|
163
86
|
} else {
|
|
164
87
|
setAccordionCurrentDisplayType(type);
|
|
165
88
|
}
|
|
166
89
|
}, [accordionCurrentDisplayType]);
|
|
167
|
-
|
|
90
|
+
const handleConfirm = (0, _react.useCallback)(() => {
|
|
168
91
|
if (confirmDate) {
|
|
169
92
|
onConfirm(confirmDate);
|
|
170
93
|
}
|
|
171
|
-
|
|
172
94
|
setDisplayPicker(false);
|
|
173
95
|
setAccordionCurrentDisplayType(null);
|
|
174
96
|
}, [confirmDate, onConfirm]);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
97
|
+
const handleChangeDate = (0, _react.useCallback)((daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) => {
|
|
98
|
+
const date = new Date(selectedDate);
|
|
99
|
+
// 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
|
|
178
100
|
date.setDate(1);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
101
|
+
const selectedYear = date.getFullYear();
|
|
102
|
+
const selectedMonth = date.getMonth();
|
|
182
103
|
if (!fixedYear) {
|
|
183
104
|
if (dayIndex < firstWeekOfMonth && selectedYear >= 1) {
|
|
184
105
|
if (selectedMonth === 0) {
|
|
@@ -195,44 +116,34 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
195
116
|
date.setMonth(selectedMonth + 1);
|
|
196
117
|
}
|
|
197
118
|
}
|
|
198
|
-
|
|
199
119
|
date.setDate(day);
|
|
200
120
|
} else if (fixedYear) {
|
|
201
121
|
if (dayIndex < firstWeekOfMonth) {
|
|
202
122
|
if (selectedMonth === 0) {
|
|
203
123
|
return;
|
|
204
124
|
}
|
|
205
|
-
|
|
206
125
|
date.setMonth(selectedMonth - 1);
|
|
207
126
|
} else if (dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
|
|
208
127
|
if (selectedMonth === 11) {
|
|
209
128
|
return;
|
|
210
129
|
}
|
|
211
|
-
|
|
212
130
|
date.setMonth(selectedMonth + 1);
|
|
213
131
|
}
|
|
214
|
-
|
|
215
132
|
date.setDate(day);
|
|
216
133
|
}
|
|
217
|
-
|
|
218
|
-
var formattedDate = (0, _utils.formatDate)(date, 'date');
|
|
134
|
+
const formattedDate = (0, _utils.formatDate)(date, 'date');
|
|
219
135
|
setSelectedDate("".concat(formattedDate, " ").concat(DEFAULT_TIME));
|
|
220
136
|
setConfirmDate(formattedDate);
|
|
221
137
|
}, [fixedYear, selectedDate]);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
_selectedDate$split2 = _slicedToArray(_selectedDate$split, 2),
|
|
225
|
-
year = _selectedDate$split2[0],
|
|
226
|
-
month = _selectedDate$split2[1]; // disabled date before first month of first year
|
|
227
|
-
|
|
138
|
+
const handleDisabled = (0, _react.useCallback)((firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, dayIndex, day) => {
|
|
139
|
+
let [year, month] = selectedDate.split('-');
|
|
228
140
|
|
|
141
|
+
// disabled date before first month of first year
|
|
229
142
|
if (year === '0001' && month === '01' && dayIndex < firstDayOfMonth) {
|
|
230
143
|
return true;
|
|
231
144
|
}
|
|
232
|
-
|
|
233
|
-
var myDay = day.toString();
|
|
145
|
+
let myDay = day.toString();
|
|
234
146
|
if (myDay.length === 1) myDay = "0".concat(myDay);
|
|
235
|
-
|
|
236
147
|
if (fixedYear) {
|
|
237
148
|
if (month === '01') {
|
|
238
149
|
// disabled date before first month
|
|
@@ -241,91 +152,77 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
241
152
|
// disabled date in december
|
|
242
153
|
return dayIndex >= daysOfMonthForSelectedDate + firstDayOfMonth;
|
|
243
154
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
155
|
+
}
|
|
246
156
|
|
|
157
|
+
// previous year's date
|
|
247
158
|
if (month === '01' && firstDayOfMonth !== 0 && dayIndex + 1 <= firstDayOfMonth) {
|
|
248
159
|
year = +year - 1;
|
|
249
|
-
}
|
|
250
|
-
|
|
160
|
+
}
|
|
251
161
|
|
|
162
|
+
// next year's date
|
|
252
163
|
if (month === '12' && lastDayOfMonth !== 6 && day + firstDayOfMonth < dayIndex + 1) {
|
|
253
164
|
year = +year + 1;
|
|
254
165
|
}
|
|
255
|
-
|
|
256
166
|
month = firstDayOfMonth >= dayIndex + 1 ? +month - 1 : daysOfMonthForSelectedDate + firstDayOfMonth < dayIndex + 1 ? +month + 1 : +month;
|
|
257
|
-
|
|
258
167
|
if (month < 1) {
|
|
259
168
|
month = 12;
|
|
260
169
|
} else if (month > 12) {
|
|
261
170
|
month = 1;
|
|
262
171
|
}
|
|
263
|
-
|
|
264
172
|
month = month.toString();
|
|
265
|
-
|
|
266
173
|
if (month.length === 1) {
|
|
267
174
|
month = "0".concat(month);
|
|
268
175
|
}
|
|
269
|
-
|
|
270
176
|
year = year.toString();
|
|
271
177
|
if (year.length === 1) year = "000".concat(year);
|
|
272
178
|
if (year.length === 2) year = "00".concat(year);
|
|
273
179
|
if (year.length === 3) year = "0".concat(year);
|
|
274
|
-
|
|
275
|
-
|
|
180
|
+
const currentDate = "".concat(year, "-").concat(month, "-").concat(myDay, " ").concat(DEFAULT_TIME);
|
|
276
181
|
if (minDateWithTime && currentDate < minDateWithTime) {
|
|
277
182
|
return true;
|
|
278
183
|
}
|
|
279
|
-
|
|
280
184
|
if (maxDateWithTime && currentDate > maxDateWithTime) {
|
|
281
185
|
return true;
|
|
282
186
|
}
|
|
283
|
-
|
|
284
187
|
return false;
|
|
285
188
|
}, [fixedYear, minDateWithTime, maxDateWithTime, selectedDate]);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
189
|
+
const isSelectedDay = (0, _react.useCallback)((day, index, firstDayOfMonth, daysOfMonthForSelectedDate) => {
|
|
190
|
+
const selectedDateObj = new Date(selectedDate);
|
|
191
|
+
const confirmDateObj = (0, _toUTC.default)(new Date(confirmDate));
|
|
290
192
|
if (confirmDateObj.getFullYear() === selectedDateObj.getFullYear() && confirmDateObj.getMonth() === selectedDateObj.getMonth() && confirmDateObj.getDate() === day) {
|
|
291
193
|
if (index + 1 > firstDayOfMonth && index < daysOfMonthForSelectedDate + firstDayOfMonth) {
|
|
292
194
|
return true;
|
|
293
195
|
}
|
|
294
|
-
|
|
295
196
|
return false;
|
|
296
197
|
}
|
|
297
|
-
|
|
298
198
|
return false;
|
|
299
199
|
}, [selectedDate, confirmDate]);
|
|
200
|
+
const getLastDateOfMonth = selectedDate => {
|
|
201
|
+
const date = new Date(selectedDate);
|
|
300
202
|
|
|
301
|
-
|
|
302
|
-
var date = new Date(selectedDate); // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
|
|
303
|
-
|
|
203
|
+
// 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
|
|
304
204
|
date.setDate(1);
|
|
305
205
|
date.setMonth(date.getMonth() + 1);
|
|
306
206
|
date.setDate(0);
|
|
307
207
|
return date;
|
|
308
208
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
var date = new Date(selectedDate);
|
|
209
|
+
const days = (0, _react.useMemo)(() => {
|
|
210
|
+
const lastDateOfSelectedDate = getLastDateOfMonth(selectedDate);
|
|
211
|
+
const daysOfMonthForSelectedDate = lastDateOfSelectedDate.getDate();
|
|
212
|
+
const lastDayOfMonth = lastDateOfSelectedDate.getDay();
|
|
213
|
+
let date = new Date(selectedDate);
|
|
315
214
|
date.setMonth(date.getMonth() + 1 - 1);
|
|
316
215
|
date.setDate(0);
|
|
317
|
-
|
|
318
|
-
date = new Date(selectedDate);
|
|
319
|
-
|
|
216
|
+
const daysOfPrevioueMonthForSelectedDate = date.getDate();
|
|
217
|
+
date = new Date(selectedDate);
|
|
218
|
+
// 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
|
|
320
219
|
date.setDate(1);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var days = _toConsumableArray(Array(daysOfMonthForSelectedDate)).map(function (value, index) {
|
|
220
|
+
const firstDayOfMonth = date.getDay();
|
|
221
|
+
const days = [...Array(daysOfMonthForSelectedDate)].map((value, index) => {
|
|
324
222
|
return index + 1;
|
|
325
223
|
});
|
|
326
|
-
|
|
327
224
|
if (firstDayOfMonth !== 0) {
|
|
328
|
-
for (
|
|
225
|
+
for (let index = daysOfPrevioueMonthForSelectedDate; index > daysOfPrevioueMonthForSelectedDate - firstDayOfMonth; index -= 1) {
|
|
329
226
|
if (date.getFullYear() === 1 && date.getMonth() === 0) {
|
|
330
227
|
days.unshift(null);
|
|
331
228
|
} else {
|
|
@@ -333,17 +230,15 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
333
230
|
}
|
|
334
231
|
}
|
|
335
232
|
}
|
|
336
|
-
|
|
337
233
|
if (lastDayOfMonth !== 6) {
|
|
338
|
-
for (
|
|
339
|
-
days.push(
|
|
234
|
+
for (let index = 1; index <= 6 - lastDayOfMonth; index += 1) {
|
|
235
|
+
days.push(index);
|
|
340
236
|
}
|
|
341
237
|
}
|
|
342
|
-
|
|
343
|
-
return days.map(function (day, index) {
|
|
238
|
+
return days.map((day, index) => {
|
|
344
239
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Day, {
|
|
345
240
|
disabled: handleDisabled(firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, index, day),
|
|
346
|
-
onClick:
|
|
241
|
+
onClick: () => {
|
|
347
242
|
handleChangeDate(daysOfMonthForSelectedDate, firstDayOfMonth, index, day);
|
|
348
243
|
},
|
|
349
244
|
selected: isSelectedDay(day, index, firstDayOfMonth, daysOfMonthForSelectedDate),
|
|
@@ -351,9 +246,9 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
351
246
|
}, index);
|
|
352
247
|
});
|
|
353
248
|
}, [selectedDate, handleChangeDate, isSelectedDay, handleDisabled]);
|
|
354
|
-
(0, _react.useEffect)(
|
|
249
|
+
(0, _react.useEffect)(() => {
|
|
355
250
|
if (selected) {
|
|
356
|
-
|
|
251
|
+
const formattedDate = (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date');
|
|
357
252
|
setSelectedDate("".concat(formattedDate, " ").concat(DEFAULT_TIME));
|
|
358
253
|
setConfirmDate(formattedDate);
|
|
359
254
|
} else {
|
|
@@ -372,12 +267,13 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
372
267
|
onClick: handleToggle,
|
|
373
268
|
readOnly: true
|
|
374
269
|
}), confirmDate && !disabled && allowClear && /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseButton, {
|
|
375
|
-
onClick:
|
|
270
|
+
onClick: () => {
|
|
376
271
|
setConfirmDate('');
|
|
377
272
|
onConfirm('');
|
|
378
273
|
}
|
|
379
274
|
})]
|
|
380
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Picker,
|
|
275
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Picker, {
|
|
276
|
+
...attributes.popper,
|
|
381
277
|
style: styles.popper,
|
|
382
278
|
placement: state && state.placement,
|
|
383
279
|
ref: setContentElement,
|
|
@@ -386,12 +282,12 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
386
282
|
accordionCurrentDisplayType: accordionCurrentDisplayType,
|
|
387
283
|
children: [!fixedYear && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Year.default, {
|
|
388
284
|
expand: accordionCurrentDisplayType === 'year',
|
|
389
|
-
handleDisplayAccordionContent:
|
|
285
|
+
handleDisplayAccordionContent: () => {
|
|
390
286
|
changeDisplayAccordion('year');
|
|
391
287
|
}
|
|
392
288
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Month.default, {
|
|
393
289
|
expand: accordionCurrentDisplayType === 'month',
|
|
394
|
-
handleDisplayAccordionContent:
|
|
290
|
+
handleDisplayAccordionContent: () => {
|
|
395
291
|
changeDisplayAccordion('month');
|
|
396
292
|
},
|
|
397
293
|
confirmDate: confirmDate
|
|
@@ -406,44 +302,43 @@ var DatePickerV2 = function DatePickerV2(_ref) {
|
|
|
406
302
|
children: t('Confirm')
|
|
407
303
|
})
|
|
408
304
|
})]
|
|
409
|
-
})
|
|
305
|
+
})]
|
|
410
306
|
})
|
|
411
307
|
});
|
|
412
308
|
};
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
var CloseButton = (0, _styledComponents.default)(_md.MdClose)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n color: var(--font-on-background);\n font-size: var(--font-body1);\n right: var(--spacing-s);\n cursor: pointer;\n"])));
|
|
309
|
+
const Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
310
|
+
const CloseButton = (0, _styledComponents.default)(_md.MdClose)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n color: var(--font-on-background);\n font-size: var(--font-body1);\n right: var(--spacing-s);\n cursor: pointer;\n"])));
|
|
417
311
|
CloseButton.displayName = 'CloseButton';
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
312
|
+
const Picker = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding-bottom: var(--spacing-s);\n background: var(--color-background1);\n border-radius: var(--border-radius);\n border: var(--border-width) solid var(--border-color);\n box-shadow: var(--box-shadow);\n overflow: hidden;\n width: 286px;\n z-index: 1;\n color: var(--font-on-background);\n\n display: ", ";\n"])), _ref2 => {
|
|
313
|
+
let {
|
|
314
|
+
displayPicker
|
|
315
|
+
} = _ref2;
|
|
421
316
|
return displayPicker ? 'block' : 'none';
|
|
422
317
|
});
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
318
|
+
const Week = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: calc(100% / 7);\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n"])));
|
|
319
|
+
const Body = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", "\n\n overflow: hidden;\n padding: ", ";\n"])), _ref3 => {
|
|
320
|
+
let {
|
|
321
|
+
accordionCurrentDisplayType
|
|
322
|
+
} = _ref3;
|
|
428
323
|
return accordionCurrentDisplayType && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n height: 216px;\n "])));
|
|
429
|
-
},
|
|
430
|
-
|
|
324
|
+
}, _ref4 => {
|
|
325
|
+
let {
|
|
326
|
+
accordionCurrentDisplayType
|
|
327
|
+
} = _ref4;
|
|
431
328
|
return accordionCurrentDisplayType === 'year' ? ' 0 4px var(--spacing-s) var(--spacing-s)' : '0 var(--spacing-s) 0 var(--spacing-s)';
|
|
432
329
|
});
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
330
|
+
const Footer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 0 var(--spacing-s);\n"])));
|
|
331
|
+
const Day = _styledComponents.default.button(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: calc(100% / 7);\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n padding: 0;\n border: 0;\n background: var(--color-background1);\n color: var(--font-on-background);\n &:hover {\n background: var(--color-primary);\n }\n\n ", "\n\n ", "\n"])), _ref5 => {
|
|
332
|
+
let {
|
|
333
|
+
selected
|
|
334
|
+
} = _ref5;
|
|
438
335
|
return selected && 'background: var(--color-hover);';
|
|
439
|
-
},
|
|
440
|
-
|
|
336
|
+
}, _ref6 => {
|
|
337
|
+
let {
|
|
338
|
+
disabled
|
|
339
|
+
} = _ref6;
|
|
441
340
|
return disabled && (0, _styledComponents.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n color: var(--font-on-mute);\n background: none;\n &:hover {\n background: none;\n }\n "])));
|
|
442
341
|
});
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
var DateContent = _styledComponents.default.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
|
|
447
|
-
|
|
448
|
-
var _default = DatePickerV2;
|
|
449
|
-
exports.default = _default;
|
|
342
|
+
const ConfirmButton = (0, _styledComponents.default)(_Button.default)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n margin: 16px auto 0;\n"])));
|
|
343
|
+
const DateContent = _styledComponents.default.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
|
|
344
|
+
var _default = exports.default = DatePickerV2;
|