@cashub/ui 0.4.1 → 0.5.0
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 +28 -0
- package/Tab/TabContext.js +12 -0
- package/Tab/TabList.js +47 -0
- package/Tab/TabPanel.js +85 -0
- package/Tab/TabTab.js +63 -0
- package/Tab/index.js +24 -0
- package/assets/font/helvetica/Helvetica.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/assets/icons/app-management.png +0 -0
- package/assets/icons/burger.png +0 -0
- package/assets/icons/file.svg +1 -0
- package/assets/icons/map_icon1.png +0 -0
- package/assets/icons/map_icon4.png +0 -0
- package/assets/images/bg-chart-circle.png +0 -0
- package/assets/images/bg-chart-triangle.png +0 -0
- package/assets/images/cashub-logo-only.png +0 -0
- package/assets/images/default-user.jpg +0 -0
- package/assets/images/logo-cashub.png +0 -0
- package/assets/images/map.png +0 -0
- package/assets/images/qrcode.png +0 -0
- package/billing/BarChart.js +58 -0
- package/billing/Grid.js +49 -0
- package/billing/Header2.js +28 -0
- package/billing/Header3.js +44 -0
- package/billing/Paragraph.js +39 -0
- package/billing/ParagraphGroup.js +25 -0
- package/billing/ParagraphText.js +31 -0
- package/billing/Section.js +60 -0
- package/billing/SectionBody.js +20 -0
- package/billing/SectionHeader.js +31 -0
- package/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/billing/__stories__/Grid.stories.js_bak +57 -0
- package/billing/__stories__/Header2.stories.js_bak +62 -0
- package/billing/__stories__/Header3.stories.js_bak +69 -0
- package/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/billing/__stories__/Section.stories.js_bak +115 -0
- package/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/callout/Callout.js +36 -0
- package/callout/index.js +15 -0
- package/chart/BarChart.js +130 -0
- package/chart/DoughnutChart.js +59 -0
- package/chart/LineChart.js +121 -0
- package/chart/SingleBarChart.js +31 -0
- package/chart/index.js +39 -0
- package/container/FlexContainer.js +25 -0
- package/container/index.js +15 -0
- package/datetimePicker/Accordion.js +342 -0
- package/datetimePicker/CustomTimeInput.js +77 -0
- package/datetimePicker/DatePicker.js +401 -0
- package/datetimePicker/DatePickerV2.js +432 -0
- package/datetimePicker/DateTimePickerContext.js +12 -0
- package/datetimePicker/DatetimePicker.js +80 -0
- package/datetimePicker/DatetimePickerV2.js +438 -0
- package/datetimePicker/TimeInput.js +37 -0
- package/datetimePicker/TimePicker.js +324 -0
- package/datetimePicker/accordion/Month.js +188 -0
- package/datetimePicker/accordion/Year.js +247 -0
- package/datetimePicker/hooks/index.js +31 -0
- package/datetimePicker/hooks/useChangeNumber.js +55 -0
- package/datetimePicker/hooks/useDecrease.js +54 -0
- package/datetimePicker/hooks/useIncrease.js +54 -0
- package/datetimePicker/index.js +47 -0
- package/datetimePicker/provider/constant.js +44 -0
- package/datetimePicker/utils/pad.js +17 -0
- package/descriptionList/DescriptionDetail.js +22 -0
- package/descriptionList/DescriptionList.js +22 -0
- package/descriptionList/DescriptionTerm.js +19 -0
- package/descriptionList/index.js +31 -0
- package/divider/Divider.js +22 -0
- package/divider/index.js +15 -0
- package/dropdown/Dropdown.js +92 -0
- package/dropdown/DropdownButtonOption.js +19 -0
- package/dropdown/DropdownContent.js +94 -0
- package/dropdown/DropdownContext.js +12 -0
- package/dropdown/DropdownDivOption.js +19 -0
- package/dropdown/DropdownItem.js +32 -0
- package/dropdown/DropdownLinkOption.js +20 -0
- package/dropdown/DropdownToggle.js +58 -0
- package/dropdown/index.js +53 -0
- package/geolocation/MapInteractor.js +41 -0
- package/geolocation/MapSearchBoxControl.js +100 -0
- package/geolocation/ReverseGeolocation.js +160 -0
- package/geolocation/index.js +23 -0
- package/grid/Column.js +33 -0
- package/grid/Grid.js +28 -0
- package/grid/index.js +23 -0
- package/heading/Heading1.js +22 -0
- package/heading/Heading2.js +25 -0
- package/heading/Heading3.js +4 -4
- package/heading/index.js +31 -0
- package/icon/IconFigure.js +36 -0
- package/icon/index.js +15 -0
- package/iconbox/ApplicationIconBox.js +51 -0
- package/iconbox/IconBox.js +56 -0
- package/iconbox/IconBoxFigure.js +37 -0
- package/iconbox/IconBoxImage.js +32 -0
- package/iconbox/IconBoxV2.js +42 -0
- package/iconbox/index.js +31 -0
- package/index.js +377 -0
- package/jsoneditor/JsonEditor.js +53 -0
- package/jsoneditor/index.js +15 -0
- package/layout/Backdrop.js +25 -0
- package/layout/Container.js +34 -0
- package/layout/Footer.js +32 -0
- package/layout/Logo.js +34 -0
- package/layout/MenuIcon.js +43 -0
- package/link/LinkSpan.js +57 -0
- package/link/index.js +15 -0
- package/map/CustomLeafletMapContainer.js +23 -0
- package/map/LeafletMap.js +224 -0
- package/map/index.js +23 -0
- package/module/geolocation/api.js +51 -0
- package/module/message/index.js +59 -0
- package/package.json +16 -1
- package/paginate/Paginate.js +110 -0
- package/paginate/index.js +15 -0
- package/popover/Popover.js +122 -0
- package/popover/index.js +15 -0
- package/qrcode/QRCode.js +57 -0
- package/qrcode/QRCodeContainter.js +34 -0
- package/qrcode/index.js +23 -0
- package/ribbon/Ribbon.js +28 -0
- package/ribbon/index.js +15 -0
- package/section/Section.js +64 -0
- package/section/SectionBody.js +38 -0
- package/section/SectionHeader.js +42 -0
- package/section/SectionToolbar.js +22 -0
- package/section/index.js +50 -0
- package/select/ListBox.js +26 -0
- package/select/Option.js +28 -0
- package/select/OptionGroup.js +20 -0
- package/select/Options.js +25 -0
- package/select/SearchBox.js +52 -0
- package/select/Select.js +625 -0
- package/select/SelectedMultiple.js +34 -0
- package/select/SelectedSingle.js +20 -0
- package/select/index.js +15 -0
- package/services/api/index.js +73 -0
- package/styles/header.style.js +11 -0
- package/styles/sidebar.style.js +18 -0
- package/styles/theme/dark.theme.js +95 -0
- package/styles/theme/index.js +16 -0
- package/table/ImageBox.js +39 -0
- package/table/Logo.js +40 -0
- package/table/PermissionTable.js +42 -0
- package/table/Table.js +377 -0
- package/table/TableFooter.js +19 -0
- package/table/TableFooterInfo.js +19 -0
- package/table/TableFooterPager.js +19 -0
- package/table/TableHeadCell.js +39 -0
- package/table/TableSort.js +34 -0
- package/table/hooks/index.js +31 -0
- package/table/hooks/useLimitChange.js +34 -0
- package/table/hooks/usePageChange.js +33 -0
- package/table/hooks/useSortChange.js +35 -0
- package/table/index.js +31 -0
- package/tagify/Tags.js +55 -0
- package/tagify/index.js +15 -0
- package/text/Paragraph.js +34 -0
- package/text/index.js +15 -0
- package/timeline/Timeline.js +51 -0
- package/timeline/index.js +15 -0
- package/toast/CustomToastContainer.js +20 -0
- package/toast/index.js +23 -0
- package/tooltip/Tooltip.js +154 -0
- package/tooltip/index.js +15 -0
- package/utils/array/generateRange.js +19 -0
- package/utils/chart/customTooltip.js +89 -0
- package/utils/chart/padEmptyChartBar.js +48 -0
- package/utils/format/datetimeFormat.js +71 -0
- package/utils/format/formatDate.js +46 -0
- package/utils/hooks/useCustomPopper.js +50 -0
- package/utils/hooks/useForkRef.js +28 -0
- package/utils/hooks/usePagination.js +86 -0
- package/utils/react/setRef.js +17 -0
- package/utils/regex/check.js +13 -0
- package/wizard/Wizard.js +217 -0
- package/wizard/index.js +15 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _reactI18next = require("react-i18next");
|
|
15
|
+
|
|
16
|
+
var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
|
|
17
|
+
|
|
18
|
+
var _useCustomPopper2 = _interopRequireDefault(require("../utils/hooks/useCustomPopper"));
|
|
19
|
+
|
|
20
|
+
var _formatDate = _interopRequireDefault(require("../utils/format/formatDate"));
|
|
21
|
+
|
|
22
|
+
var _Button = _interopRequireDefault(require("../button/Button"));
|
|
23
|
+
|
|
24
|
+
var _Accordion = _interopRequireDefault(require("./Accordion"));
|
|
25
|
+
|
|
26
|
+
var _Input = _interopRequireDefault(require("../form/Input"));
|
|
27
|
+
|
|
28
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
+
|
|
30
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
31
|
+
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
+
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
+
|
|
44
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
|
+
|
|
46
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
47
|
+
|
|
48
|
+
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."); }
|
|
49
|
+
|
|
50
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
51
|
+
|
|
52
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
53
|
+
|
|
54
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
55
|
+
|
|
56
|
+
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."); }
|
|
57
|
+
|
|
58
|
+
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); }
|
|
59
|
+
|
|
60
|
+
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; }
|
|
61
|
+
|
|
62
|
+
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; }
|
|
63
|
+
|
|
64
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
65
|
+
|
|
66
|
+
var DatePicker = function DatePicker(_ref) {
|
|
67
|
+
var onConfirm = _ref.onConfirm,
|
|
68
|
+
selected = _ref.selected,
|
|
69
|
+
minDate = _ref.minDate,
|
|
70
|
+
maxDate = _ref.maxDate,
|
|
71
|
+
fixedYear = _ref.fixedYear;
|
|
72
|
+
|
|
73
|
+
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
74
|
+
t = _useTranslation.t;
|
|
75
|
+
|
|
76
|
+
var _useState = (0, _react.useState)(null),
|
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
+
currentDisplayType = _useState2[0],
|
|
79
|
+
setCurrentDisplayType = _useState2[1];
|
|
80
|
+
|
|
81
|
+
var _useState3 = (0, _react.useState)(false),
|
|
82
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
83
|
+
displayPicker = _useState4[0],
|
|
84
|
+
setDisplayPicker = _useState4[1];
|
|
85
|
+
|
|
86
|
+
var _useState5 = (0, _react.useState)(new Date(selected).getFullYear()),
|
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
+
selectedYear = _useState6[0],
|
|
89
|
+
setSelectedYear = _useState6[1];
|
|
90
|
+
|
|
91
|
+
var _useState7 = (0, _react.useState)(new Date(selected).getMonth()),
|
|
92
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
93
|
+
selectedMonth = _useState8[0],
|
|
94
|
+
setSelectedMonth = _useState8[1];
|
|
95
|
+
|
|
96
|
+
var _useState9 = (0, _react.useState)(new Date(selected).getDate()),
|
|
97
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
98
|
+
selectedDay = _useState10[0],
|
|
99
|
+
setSelectedDay = _useState10[1];
|
|
100
|
+
|
|
101
|
+
var _useState11 = (0, _react.useState)(new Date(selected).getFullYear()),
|
|
102
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
103
|
+
confirmYear = _useState12[0],
|
|
104
|
+
setConfirmYear = _useState12[1];
|
|
105
|
+
|
|
106
|
+
var _useState13 = (0, _react.useState)(new Date(selected).getMonth()),
|
|
107
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
108
|
+
confirmMonth = _useState14[0],
|
|
109
|
+
setConfirmMonth = _useState14[1];
|
|
110
|
+
|
|
111
|
+
var _useState15 = (0, _react.useState)(new Date(selected).getDate()),
|
|
112
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
113
|
+
confirmDay = _useState16[0],
|
|
114
|
+
setConfirmDay = _useState16[1];
|
|
115
|
+
|
|
116
|
+
var _useState17 = (0, _react.useState)(selected),
|
|
117
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
118
|
+
inputValue = _useState18[0],
|
|
119
|
+
setInputValue = _useState18[1];
|
|
120
|
+
|
|
121
|
+
var _useState19 = (0, _react.useState)(null),
|
|
122
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
123
|
+
toggleElement = _useState20[0],
|
|
124
|
+
setToggleElement = _useState20[1];
|
|
125
|
+
|
|
126
|
+
var _useState21 = (0, _react.useState)(null),
|
|
127
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
128
|
+
contentElement = _useState22[0],
|
|
129
|
+
setContentElement = _useState22[1];
|
|
130
|
+
|
|
131
|
+
var _useCustomPopper = (0, _useCustomPopper2.default)(toggleElement, contentElement, {
|
|
132
|
+
strategy: 'absolute',
|
|
133
|
+
placement: 'bottom-start'
|
|
134
|
+
}),
|
|
135
|
+
styles = _useCustomPopper.styles,
|
|
136
|
+
attributes = _useCustomPopper.attributes,
|
|
137
|
+
state = _useCustomPopper.state,
|
|
138
|
+
update = _useCustomPopper.update;
|
|
139
|
+
|
|
140
|
+
var weeks = (0, _react.useMemo)(function () {
|
|
141
|
+
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(function (week) {
|
|
142
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
|
|
143
|
+
children: week
|
|
144
|
+
}, week);
|
|
145
|
+
});
|
|
146
|
+
}, []);
|
|
147
|
+
|
|
148
|
+
var _handleDisplayAccordionContent = (0, _react.useCallback)(function (type) {
|
|
149
|
+
if (currentDisplayType === type) {
|
|
150
|
+
setCurrentDisplayType(null);
|
|
151
|
+
} else {
|
|
152
|
+
setCurrentDisplayType(type);
|
|
153
|
+
}
|
|
154
|
+
}, [currentDisplayType]);
|
|
155
|
+
|
|
156
|
+
var handleChangeYear = function handleChangeYear(selected) {
|
|
157
|
+
if (selected === 'previous') {
|
|
158
|
+
setSelectedYear(function (previousParams) {
|
|
159
|
+
if (previousParams <= 1) return previousParams;else return previousParams -= 1;
|
|
160
|
+
});
|
|
161
|
+
} else if (selected === 'next') {
|
|
162
|
+
setSelectedYear(function (previousParams) {
|
|
163
|
+
return previousParams += 1;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setCurrentDisplayType(null);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var handleChangeMonth = function handleChangeMonth(selected) {
|
|
171
|
+
if (selected === 'previous') {
|
|
172
|
+
setSelectedMonth(function (previousParams) {
|
|
173
|
+
return previousParams <= 0 ? 11 : previousParams -= 1;
|
|
174
|
+
});
|
|
175
|
+
} else if (selected === 'next') {
|
|
176
|
+
setSelectedMonth(function (previousParams) {
|
|
177
|
+
return previousParams >= 11 ? 0 : previousParams += 1;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
setCurrentDisplayType(null);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
var handleDisabled = (0, _react.useCallback)(function (firstWeekOfMonth, daysOfMonthForSelectedDate, dayIndex, day) {
|
|
185
|
+
var selectedDate = (0, _formatDate.default)(new Date(selectedYear, firstWeekOfMonth >= dayIndex + 1 ? selectedMonth - 1 : daysOfMonthForSelectedDate + firstWeekOfMonth < dayIndex + 1 ? selectedMonth + 1 : selectedMonth, day).getTime() + 86399 * 1000);
|
|
186
|
+
|
|
187
|
+
if (minDate && minDate > selectedDate || maxDate && maxDate < selectedDate) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (fixedYear) {
|
|
192
|
+
var disabledDateInDec = selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth;
|
|
193
|
+
var disabledDateInJan = selectedMonth === 0 && dayIndex < firstWeekOfMonth;
|
|
194
|
+
return disabledDateInDec || disabledDateInJan ? true : false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return false;
|
|
198
|
+
}, [fixedYear, minDate, maxDate, selectedMonth, selectedYear]);
|
|
199
|
+
var handleChangeDate = (0, _react.useCallback)(function (daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) {
|
|
200
|
+
if (!fixedYear) {
|
|
201
|
+
setSelectedYear(function () {
|
|
202
|
+
if (selectedMonth === 0 && dayIndex < firstWeekOfMonth && selectedYear > 1) {
|
|
203
|
+
return selectedYear - 1;
|
|
204
|
+
} else if (selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
|
|
205
|
+
return selectedYear + 1;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return selectedYear;
|
|
209
|
+
});
|
|
210
|
+
setConfirmYear(function () {
|
|
211
|
+
if (selectedMonth === 0 && dayIndex < firstWeekOfMonth && selectedYear > 1) {
|
|
212
|
+
return selectedYear - 1;
|
|
213
|
+
} else if (selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
|
|
214
|
+
return selectedYear + 1;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return selectedYear;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
setSelectedMonth(function () {
|
|
222
|
+
if (firstWeekOfMonth > dayIndex) {
|
|
223
|
+
return selectedMonth !== 0 ? selectedMonth - 1 : 11;
|
|
224
|
+
} else if (daysOfMonthForSelectedDate + firstWeekOfMonth <= dayIndex) {
|
|
225
|
+
return selectedMonth !== 11 ? selectedMonth + 1 : 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return selectedMonth;
|
|
229
|
+
});
|
|
230
|
+
setConfirmMonth(function () {
|
|
231
|
+
if (firstWeekOfMonth > dayIndex) {
|
|
232
|
+
return selectedMonth !== 0 ? selectedMonth - 1 : 11;
|
|
233
|
+
} else if (daysOfMonthForSelectedDate + firstWeekOfMonth <= dayIndex) {
|
|
234
|
+
return selectedMonth !== 11 ? selectedMonth + 1 : 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return selectedMonth;
|
|
238
|
+
});
|
|
239
|
+
setConfirmDay(day);
|
|
240
|
+
}, [fixedYear, selectedMonth, selectedYear]);
|
|
241
|
+
var handleSelectedDay = (0, _react.useCallback)(function (day, daysOfMonthForSelectedDate, index, firstWeekOfMonth, lastWeekOfMonth) {
|
|
242
|
+
if (confirmDay === day && confirmYear === selectedYear && confirmMonth === selectedMonth) {
|
|
243
|
+
if (firstWeekOfMonth === 6 && lastWeekOfMonth === 6) {
|
|
244
|
+
return true;
|
|
245
|
+
} else if (firstWeekOfMonth !== 6 && lastWeekOfMonth === 6) {
|
|
246
|
+
return index + 1 > firstWeekOfMonth ? true : false;
|
|
247
|
+
} else {
|
|
248
|
+
return index + 1 >= firstWeekOfMonth && index + 1 <= daysOfMonthForSelectedDate + firstWeekOfMonth ? true : false;
|
|
249
|
+
}
|
|
250
|
+
} else return false;
|
|
251
|
+
}, [confirmYear, confirmMonth, confirmDay, selectedYear, selectedMonth]);
|
|
252
|
+
var handleDisplayDays = (0, _react.useMemo)(function () {
|
|
253
|
+
var daysOfMonthForSelectedDate = new Date(selectedYear, selectedMonth + 1, 0).getDate();
|
|
254
|
+
var daysOfPrevioueMonthForSelectedDate = new Date(selectedYear, selectedMonth + 1 - 1, 0).getDate();
|
|
255
|
+
var firstWeekOfMonth = new Date("".concat(selectedYear, "/").concat(selectedMonth + 1, "/1")).getDay();
|
|
256
|
+
var lastWeekOfMonth = new Date("".concat(selectedYear, "/").concat(selectedMonth + 1, "/").concat(daysOfMonthForSelectedDate)).getDay();
|
|
257
|
+
var days = [];
|
|
258
|
+
|
|
259
|
+
for (var _i2 = 0, _arr2 = _toConsumableArray(Array(daysOfMonthForSelectedDate).keys()); _i2 < _arr2.length; _i2++) {
|
|
260
|
+
var day = _arr2[_i2];
|
|
261
|
+
days.push(day + 1);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (firstWeekOfMonth !== 0) {
|
|
265
|
+
for (var i = daysOfPrevioueMonthForSelectedDate; i > daysOfPrevioueMonthForSelectedDate - firstWeekOfMonth; i--) {
|
|
266
|
+
days.unshift(i);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (lastWeekOfMonth !== 6) {
|
|
271
|
+
for (var _i3 = 1; _i3 <= 6 - lastWeekOfMonth; _i3++) {
|
|
272
|
+
days.push(_i3);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return days.map(function (day, index) {
|
|
277
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Day, {
|
|
278
|
+
disabled: handleDisabled(firstWeekOfMonth, daysOfMonthForSelectedDate, index, day),
|
|
279
|
+
onClick: function onClick() {
|
|
280
|
+
handleChangeDate(daysOfMonthForSelectedDate, firstWeekOfMonth, index, day);
|
|
281
|
+
},
|
|
282
|
+
selected: handleSelectedDay(day, daysOfMonthForSelectedDate, index, firstWeekOfMonth, lastWeekOfMonth),
|
|
283
|
+
children: day
|
|
284
|
+
}, index);
|
|
285
|
+
});
|
|
286
|
+
}, [selectedMonth, selectedYear, handleDisabled, handleChangeDate, handleSelectedDay]);
|
|
287
|
+
|
|
288
|
+
var handleToggle = function handleToggle() {
|
|
289
|
+
setDisplayPicker(!displayPicker);
|
|
290
|
+
update();
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
var handleConfirm = function handleConfirm() {
|
|
294
|
+
onConfirm(inputValue);
|
|
295
|
+
setDisplayPicker(false);
|
|
296
|
+
setCurrentDisplayType(null);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
(0, _react.useEffect)(function () {
|
|
300
|
+
var date = new Date(selected);
|
|
301
|
+
setSelectedYear(date.getFullYear());
|
|
302
|
+
setSelectedMonth(date.getMonth());
|
|
303
|
+
setSelectedDay(date.getDate());
|
|
304
|
+
setConfirmYear(date.getFullYear());
|
|
305
|
+
setConfirmMonth(date.getMonth());
|
|
306
|
+
setConfirmDay(date.getDate());
|
|
307
|
+
setInputValue(selected);
|
|
308
|
+
}, [selected]);
|
|
309
|
+
(0, _react.useEffect)(function () {
|
|
310
|
+
setInputValue((0, _formatDate.default)(new Date(confirmYear, confirmMonth, confirmDay), 'date'));
|
|
311
|
+
}, [confirmYear, confirmMonth, confirmDay]);
|
|
312
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactOutsideClickHandler.default, {
|
|
313
|
+
onOutsideClick: handleConfirm,
|
|
314
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PickerInput, {
|
|
315
|
+
ref: setToggleElement,
|
|
316
|
+
value: inputValue,
|
|
317
|
+
onClick: handleToggle,
|
|
318
|
+
readOnly: true
|
|
319
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, _objectSpread(_objectSpread({}, attributes.popper), {}, {
|
|
320
|
+
style: styles.popper,
|
|
321
|
+
placement: state && state.placement,
|
|
322
|
+
ref: setContentElement,
|
|
323
|
+
displayPicker: displayPicker,
|
|
324
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(Body, {
|
|
325
|
+
displayType: currentDisplayType,
|
|
326
|
+
children: [!fixedYear && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Accordion.default, {
|
|
327
|
+
type: "year",
|
|
328
|
+
handleDisplayAccordionContent: function handleDisplayAccordionContent() {
|
|
329
|
+
_handleDisplayAccordionContent('year');
|
|
330
|
+
},
|
|
331
|
+
handleChangeTitle: handleChangeYear,
|
|
332
|
+
setCurrentDisplayType: setCurrentDisplayType,
|
|
333
|
+
currentDisplayType: currentDisplayType,
|
|
334
|
+
selectedYear: selectedYear,
|
|
335
|
+
setSelectedYear: setSelectedYear,
|
|
336
|
+
selectedDay: selectedDay,
|
|
337
|
+
minDate: minDate,
|
|
338
|
+
maxDate: maxDate,
|
|
339
|
+
fixedYear: fixedYear
|
|
340
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Accordion.default, {
|
|
341
|
+
type: "month",
|
|
342
|
+
handleDisplayAccordionContent: function handleDisplayAccordionContent() {
|
|
343
|
+
_handleDisplayAccordionContent('month');
|
|
344
|
+
},
|
|
345
|
+
handleChangeTitle: handleChangeMonth,
|
|
346
|
+
setCurrentDisplayType: setCurrentDisplayType,
|
|
347
|
+
currentDisplayType: currentDisplayType,
|
|
348
|
+
selectedMonth: selectedMonth,
|
|
349
|
+
setSelectedMonth: setSelectedMonth,
|
|
350
|
+
selectedYear: selectedYear,
|
|
351
|
+
selectedDay: selectedDay,
|
|
352
|
+
fixedYear: fixedYear,
|
|
353
|
+
minDate: minDate,
|
|
354
|
+
maxDate: maxDate
|
|
355
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateContent, {
|
|
356
|
+
children: [weeks, handleDisplayDays]
|
|
357
|
+
})]
|
|
358
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Footer, {
|
|
359
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfirmButton, {
|
|
360
|
+
fullWidth: true,
|
|
361
|
+
alignCenter: true,
|
|
362
|
+
onClick: handleConfirm,
|
|
363
|
+
children: t('Confirm')
|
|
364
|
+
})
|
|
365
|
+
})]
|
|
366
|
+
}))]
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _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\n display: ", ";\n"])), function (_ref2) {
|
|
371
|
+
var displayPicker = _ref2.displayPicker;
|
|
372
|
+
return displayPicker ? 'block' : 'none';
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
var Week = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 36px;\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n"])));
|
|
376
|
+
|
|
377
|
+
var Day = _styledComponents.default.button(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n min-width: 36px;\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(--color-white);\n &:hover {\n background: var(--color-primary);\n }\n ", "\n ", "\n"])), function (_ref3) {
|
|
378
|
+
var selected = _ref3.selected;
|
|
379
|
+
return selected && "background: var(--color-hover);";
|
|
380
|
+
}, function (_ref4) {
|
|
381
|
+
var disabled = _ref4.disabled;
|
|
382
|
+
return disabled && (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: var(--font-on-mute);\n background: none;\n &:hover {\n background: none;\n }\n "])));
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
var DateContent = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
|
|
386
|
+
|
|
387
|
+
var PickerInput = (0, _styledComponents.default)(_Input.default)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n &:disabled {\n cursor: auto;\n opacity: 1;\n }\n"])));
|
|
388
|
+
var ConfirmButton = (0, _styledComponents.default)(_Button.default)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin: 16px auto 0;\n"])));
|
|
389
|
+
|
|
390
|
+
var Body = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n ", "\n\n overflow: hidden;\n padding: ", ";\n"])), function (_ref5) {
|
|
391
|
+
var displayType = _ref5.displayType;
|
|
392
|
+
return displayType && (0, _styledComponents.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n height: 216px;\n "])));
|
|
393
|
+
}, function (_ref6) {
|
|
394
|
+
var displayType = _ref6.displayType;
|
|
395
|
+
return displayType === 'year' ? ' 0 4px var(--spacing-s) var(--spacing-s)' : '0 var(--spacing-s) 0 var(--spacing-s)';
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
var Footer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 0 var(--spacing-s);\n"])));
|
|
399
|
+
|
|
400
|
+
var _default = DatePicker;
|
|
401
|
+
exports.default = _default;
|