@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,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
|
|
10
|
+
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."); }
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
|
|
20
|
+
var datetimeTFormat = function datetimeTFormat(timestamp) {
|
|
21
|
+
var d = new Date(timestamp);
|
|
22
|
+
|
|
23
|
+
if (typeof timestamp === 'string') {
|
|
24
|
+
var _timestamp$split = timestamp.split('-'),
|
|
25
|
+
_timestamp$split2 = _slicedToArray(_timestamp$split, 3),
|
|
26
|
+
_year = _timestamp$split2[0],
|
|
27
|
+
_month = _timestamp$split2[1],
|
|
28
|
+
dayAndTime = _timestamp$split2[2];
|
|
29
|
+
|
|
30
|
+
if (_year.length === 1) _year = "000".concat(_year);
|
|
31
|
+
if (_year.length === 2) _year = "00".concat(_year);
|
|
32
|
+
if (_year.length === 3) _year = "0".concat(_year);
|
|
33
|
+
if (_month.length < 2) _month = "0".concat(_month);
|
|
34
|
+
|
|
35
|
+
var _dayAndTime$split = dayAndTime.split(' '),
|
|
36
|
+
_dayAndTime$split2 = _slicedToArray(_dayAndTime$split, 2),
|
|
37
|
+
_day = _dayAndTime$split2[0],
|
|
38
|
+
time = _dayAndTime$split2[1];
|
|
39
|
+
|
|
40
|
+
var _time$split = time.split(':'),
|
|
41
|
+
_time$split2 = _slicedToArray(_time$split, 3),
|
|
42
|
+
_hour = _time$split2[0],
|
|
43
|
+
_minutes = _time$split2[1],
|
|
44
|
+
_second = _time$split2[2];
|
|
45
|
+
|
|
46
|
+
if (_day.length < 2) _day = "0".concat(_day);
|
|
47
|
+
if (_hour.length < 2) _hour = "0".concat(_hour);
|
|
48
|
+
if (_minutes.length < 2) _minutes = "0".concat(_minutes);
|
|
49
|
+
if (_second.length < 2) _second = "0".concat(_second);
|
|
50
|
+
return "".concat(_year, "-").concat(_month, "-").concat(_day, "T").concat(_hour, ":").concat(_minutes, ":").concat(_second);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var second = "".concat(d.getSeconds());
|
|
54
|
+
var minutes = "".concat(d.getMinutes());
|
|
55
|
+
var hour = "".concat(d.getHours());
|
|
56
|
+
var month = "".concat(d.getMonth() + 1);
|
|
57
|
+
var day = "".concat(d.getDate());
|
|
58
|
+
var year = "".concat(d.getFullYear());
|
|
59
|
+
if (year.length === 1) year = "000".concat(year);
|
|
60
|
+
if (year.length === 2) year = "00".concat(year);
|
|
61
|
+
if (year.length === 3) year = "0".concat(year);
|
|
62
|
+
if (month.length < 2) month = "0".concat(month);
|
|
63
|
+
if (day.length < 2) day = "0".concat(day);
|
|
64
|
+
if (hour.length < 2) hour = "0".concat(hour);
|
|
65
|
+
if (minutes.length < 2) minutes = "0".concat(minutes);
|
|
66
|
+
if (second.length < 2) second = "0".concat(second);
|
|
67
|
+
return "".concat(year, "-").concat(month, "-").concat(day, "T").concat(hour, ":").concat(minutes, ":").concat(second);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var _default = datetimeTFormat;
|
|
71
|
+
exports.default = _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Convert a timestamp into a date and return specific format
|
|
10
|
+
*
|
|
11
|
+
* @param {String|Integer} timestamp The timestamp in unix of YYYY-MM-DD HH:MM:SS format
|
|
12
|
+
* @param {String} format currently accept date for YYYY-MM-DD, time for HH:MM:SS and others for YYYY-MM-DD HH:MM:SS
|
|
13
|
+
*
|
|
14
|
+
* @return {String}
|
|
15
|
+
*/
|
|
16
|
+
var formatDate = function formatDate(timestamp) {
|
|
17
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
18
|
+
var d = new Date(timestamp);
|
|
19
|
+
var second = "".concat(d.getSeconds());
|
|
20
|
+
var minutes = "".concat(d.getMinutes());
|
|
21
|
+
var hour = "".concat(d.getHours());
|
|
22
|
+
var month = "".concat(d.getMonth() + 1);
|
|
23
|
+
var day = "".concat(d.getDate());
|
|
24
|
+
var year = "".concat(d.getFullYear());
|
|
25
|
+
if (year.length === 1) year = "000".concat(year);
|
|
26
|
+
if (year.length === 2) year = "00".concat(year);
|
|
27
|
+
if (month.length < 2) month = "0".concat(month);
|
|
28
|
+
if (day.length < 2) day = "0".concat(day);
|
|
29
|
+
if (hour.length < 2) hour = "0".concat(hour);
|
|
30
|
+
if (minutes.length < 2) minutes = "0".concat(minutes);
|
|
31
|
+
if (second.length < 2) second = "0".concat(second);
|
|
32
|
+
|
|
33
|
+
switch (format) {
|
|
34
|
+
case 'date':
|
|
35
|
+
return "".concat(year, "-").concat(month, "-").concat(day);
|
|
36
|
+
|
|
37
|
+
case 'time':
|
|
38
|
+
return "".concat(hour, ":").concat(minutes, ":").concat(second);
|
|
39
|
+
|
|
40
|
+
default:
|
|
41
|
+
return "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hour, ":").concat(minutes, ":").concat(second);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var _default = formatDate;
|
|
46
|
+
exports.default = _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactPopper = require("react-popper");
|
|
9
|
+
|
|
10
|
+
var useCustomPopper = function useCustomPopper(targetElement, popperElement) {
|
|
11
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
12
|
+
_ref$strategy = _ref.strategy,
|
|
13
|
+
strategy = _ref$strategy === void 0 ? 'absolute' : _ref$strategy,
|
|
14
|
+
_ref$arrowElement = _ref.arrowElement,
|
|
15
|
+
arrowElement = _ref$arrowElement === void 0 ? null : _ref$arrowElement,
|
|
16
|
+
_ref$boundary = _ref.boundary,
|
|
17
|
+
boundary = _ref$boundary === void 0 ? 'clippingParents' : _ref$boundary;
|
|
18
|
+
|
|
19
|
+
return (0, _reactPopper.usePopper)(targetElement, popperElement, {
|
|
20
|
+
placement: 'bottom',
|
|
21
|
+
strategy: strategy,
|
|
22
|
+
modifiers: [{
|
|
23
|
+
name: 'flip',
|
|
24
|
+
//當reference元素將超出邊界時,定位popper元素
|
|
25
|
+
enabled: true,
|
|
26
|
+
options: {
|
|
27
|
+
padding: 8
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
name: 'preventOverflow',
|
|
31
|
+
options: {
|
|
32
|
+
padding: 8,
|
|
33
|
+
boundary: boundary
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
name: 'offset',
|
|
37
|
+
options: {
|
|
38
|
+
offset: [0, 8]
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
name: 'arrow',
|
|
42
|
+
options: {
|
|
43
|
+
element: arrowElement
|
|
44
|
+
}
|
|
45
|
+
}]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var _default = useCustomPopper;
|
|
50
|
+
exports.default = _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _setRef = _interopRequireDefault(require("../react/setRef"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
var useForkRef = function useForkRef(refA, refB) {
|
|
15
|
+
return (0, _react.useMemo)(function () {
|
|
16
|
+
if (refA == null && refB == null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return function (refValue) {
|
|
21
|
+
(0, _setRef.default)(refA, refValue);
|
|
22
|
+
(0, _setRef.default)(refB, refValue);
|
|
23
|
+
};
|
|
24
|
+
}, [refA, refB]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var _default = useForkRef;
|
|
28
|
+
exports.default = _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePagination = exports.DOTS = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
+
|
|
12
|
+
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."); }
|
|
13
|
+
|
|
14
|
+
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); }
|
|
15
|
+
|
|
16
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
+
|
|
18
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var DOTS = '...';
|
|
23
|
+
exports.DOTS = DOTS;
|
|
24
|
+
|
|
25
|
+
var range = function range(start, end) {
|
|
26
|
+
var length = end - start + 1;
|
|
27
|
+
return Array.from({
|
|
28
|
+
length: length
|
|
29
|
+
}, function (_, idx) {
|
|
30
|
+
return idx + start;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var usePagination = function usePagination(_ref) {
|
|
35
|
+
var totalCount = _ref.totalCount,
|
|
36
|
+
pageSize = _ref.pageSize,
|
|
37
|
+
_ref$siblingCount = _ref.siblingCount,
|
|
38
|
+
siblingCount = _ref$siblingCount === void 0 ? 1 : _ref$siblingCount,
|
|
39
|
+
currentPage = _ref.currentPage;
|
|
40
|
+
var paginationRange = (0, _react.useMemo)(function () {
|
|
41
|
+
var totalPageCount = Math.ceil(totalCount / pageSize); // Pages count is determined as siblingCount + firstPage + lastPage + currentPage + 2 * DOTS
|
|
42
|
+
|
|
43
|
+
var totalPageNumbers = siblingCount + 5;
|
|
44
|
+
/*
|
|
45
|
+
If the number of pages is less than the page numbers we want to show in our
|
|
46
|
+
paginationComponent, we return the range [1..totalPageCount]
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
if (totalPageNumbers >= totalPageCount) {
|
|
50
|
+
return range(1, totalPageCount);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
|
|
54
|
+
var rightSiblingIndex = Math.min(currentPage + siblingCount, totalPageCount);
|
|
55
|
+
/*
|
|
56
|
+
We do not want to show dots if there is only one position left
|
|
57
|
+
after/before the left/right page count as that would lead to a change if our Pagination
|
|
58
|
+
component size which we do not want
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
var shouldShowLeftDots = leftSiblingIndex > 3;
|
|
62
|
+
var shouldShowRightDots = rightSiblingIndex < totalPageCount - 1;
|
|
63
|
+
var firstPageIndex = 1;
|
|
64
|
+
var lastPageIndex = totalPageCount;
|
|
65
|
+
|
|
66
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
67
|
+
var leftItemCount = 3 + 2 * siblingCount;
|
|
68
|
+
var leftRange = range(1, leftItemCount);
|
|
69
|
+
return [].concat(_toConsumableArray(leftRange), [DOTS, totalPageCount]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
73
|
+
var rightItemCount = 3 + 2 * siblingCount;
|
|
74
|
+
var rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
|
|
75
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(rightRange));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
79
|
+
var middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
80
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(middleRange), [DOTS, lastPageIndex]);
|
|
81
|
+
}
|
|
82
|
+
}, [totalCount, pageSize, siblingCount, currentPage]);
|
|
83
|
+
return paginationRange;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
exports.usePagination = usePagination;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var setRef = function setRef(ref, value) {
|
|
9
|
+
if (typeof ref === "function") {
|
|
10
|
+
ref(value);
|
|
11
|
+
} else if (ref) {
|
|
12
|
+
ref.current = value;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var _default = setRef;
|
|
17
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.testInteger = void 0;
|
|
7
|
+
|
|
8
|
+
var testInteger = function testInteger(value) {
|
|
9
|
+
var intRegex = /^[0-9]\d*$/;
|
|
10
|
+
return intRegex.test(value);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.testInteger = testInteger;
|
package/wizard/Wizard.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
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 _fa = require("react-icons/fa");
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _isReactComponent = _interopRequireDefault(require("../utils/react/isReactComponent"));
|
|
17
|
+
|
|
18
|
+
var _media = _interopRequireDefault(require("../styles/mixin/media"));
|
|
19
|
+
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
|
|
22
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
27
|
+
|
|
28
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
29
|
+
|
|
30
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
31
|
+
|
|
32
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
33
|
+
|
|
34
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
|
+
|
|
36
|
+
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."); }
|
|
37
|
+
|
|
38
|
+
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); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
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; }
|
|
43
|
+
|
|
44
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
|
+
|
|
46
|
+
var Wizard = function Wizard(props) {
|
|
47
|
+
var _props$navNames = props.navNames,
|
|
48
|
+
navNames = _props$navNames === void 0 ? [] : _props$navNames,
|
|
49
|
+
_props$defaultStep = props.defaultStep,
|
|
50
|
+
defaultStep = _props$defaultStep === void 0 ? 1 : _props$defaultStep,
|
|
51
|
+
children = props.children,
|
|
52
|
+
beforeNext = props.beforeNext,
|
|
53
|
+
beforePrevious = props.beforePrevious,
|
|
54
|
+
_props$clickableSteps = props.clickableSteps,
|
|
55
|
+
clickableSteps = _props$clickableSteps === void 0 ? true : _props$clickableSteps;
|
|
56
|
+
|
|
57
|
+
var _useState = (0, _react.useState)(defaultStep),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
currentStep = _useState2[0],
|
|
60
|
+
setCurrentStep = _useState2[1];
|
|
61
|
+
|
|
62
|
+
var goToStep = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
63
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(step) {
|
|
64
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
65
|
+
while (1) {
|
|
66
|
+
switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
if (step > currentStep) {
|
|
69
|
+
if (!beforeNext) {
|
|
70
|
+
setCurrentStep(step);
|
|
71
|
+
} else {
|
|
72
|
+
beforeNext({
|
|
73
|
+
current: currentStep
|
|
74
|
+
}).then(function () {
|
|
75
|
+
setCurrentStep(step);
|
|
76
|
+
}).catch(function (error) {});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (step < currentStep) {
|
|
81
|
+
if (!beforePrevious) {
|
|
82
|
+
setCurrentStep(step);
|
|
83
|
+
} else {
|
|
84
|
+
beforePrevious({
|
|
85
|
+
current: currentStep
|
|
86
|
+
}).then(function () {
|
|
87
|
+
setCurrentStep(step);
|
|
88
|
+
}).catch(function (error) {});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case 2:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context.stop();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, _callee);
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
return function (_x) {
|
|
101
|
+
return _ref.apply(this, arguments);
|
|
102
|
+
};
|
|
103
|
+
}(), [currentStep, beforeNext, beforePrevious]);
|
|
104
|
+
var nextStep = (0, _react.useCallback)(function () {
|
|
105
|
+
console.log("next");
|
|
106
|
+
var next = currentStep + 1;
|
|
107
|
+
|
|
108
|
+
if (next > navNames.length) {
|
|
109
|
+
next = navNames.length;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log("1");
|
|
113
|
+
|
|
114
|
+
if (!beforeNext) {
|
|
115
|
+
console.log("2");
|
|
116
|
+
setCurrentStep(next);
|
|
117
|
+
} else {
|
|
118
|
+
console.log("3");
|
|
119
|
+
beforeNext({
|
|
120
|
+
current: currentStep
|
|
121
|
+
}).then(function () {
|
|
122
|
+
setCurrentStep(next);
|
|
123
|
+
}).catch(function (error) {});
|
|
124
|
+
}
|
|
125
|
+
}, [navNames.length, beforeNext, currentStep]);
|
|
126
|
+
var previousStep = (0, _react.useCallback)(function () {
|
|
127
|
+
var previous = currentStep - 1;
|
|
128
|
+
|
|
129
|
+
if (previous < 1) {
|
|
130
|
+
previous = 1;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!beforePrevious) {
|
|
134
|
+
setCurrentStep(previous);
|
|
135
|
+
} else {
|
|
136
|
+
beforePrevious({
|
|
137
|
+
current: currentStep
|
|
138
|
+
}).then(function () {
|
|
139
|
+
setCurrentStep(previous);
|
|
140
|
+
}).catch(function (error) {});
|
|
141
|
+
}
|
|
142
|
+
}, [beforePrevious, currentStep]);
|
|
143
|
+
var isLastStep = (0, _react.useCallback)(function () {
|
|
144
|
+
return currentStep === navNames.length;
|
|
145
|
+
}, [currentStep, navNames.length]);
|
|
146
|
+
var api = (0, _react.useMemo)(function () {
|
|
147
|
+
console.log("api");
|
|
148
|
+
return {
|
|
149
|
+
goToStep: goToStep,
|
|
150
|
+
nextStep: nextStep,
|
|
151
|
+
previousStep: previousStep,
|
|
152
|
+
isLastStep: isLastStep
|
|
153
|
+
};
|
|
154
|
+
}, [goToStep, isLastStep, nextStep, previousStep]);
|
|
155
|
+
var childrenWithProps = (0, _react.useMemo)(function () {
|
|
156
|
+
var validChildren = children.filter(function (child) {
|
|
157
|
+
return !!child;
|
|
158
|
+
});
|
|
159
|
+
return _react.Children.map(validChildren, function (child, index) {
|
|
160
|
+
console.log("isReactComponent(child)", (0, _isReactComponent.default)(child));
|
|
161
|
+
if (!child) return null;
|
|
162
|
+
var className = index + 1 === currentStep && "active";
|
|
163
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Step, {
|
|
164
|
+
className: className,
|
|
165
|
+
children: (0, _isReactComponent.default)(child) ? /*#__PURE__*/(0, _react.cloneElement)(child, api) : child
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}, [api, children, currentStep]);
|
|
169
|
+
(0, _react.useEffect)(function () {
|
|
170
|
+
setCurrentStep(defaultStep);
|
|
171
|
+
}, [defaultStep]);
|
|
172
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
173
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Nav, {
|
|
174
|
+
children: navNames.map(function (name, index, arr) {
|
|
175
|
+
var step = index + 1;
|
|
176
|
+
var arrow = step === currentStep && step !== arr.length ? "arrow" : undefined;
|
|
177
|
+
var className = "";
|
|
178
|
+
|
|
179
|
+
if (step === currentStep) {
|
|
180
|
+
className += "current";
|
|
181
|
+
} else if (step < currentStep) {
|
|
182
|
+
className += "done";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NavItem, {
|
|
186
|
+
className: className,
|
|
187
|
+
onClick: function onClick() {
|
|
188
|
+
return clickableSteps === true && goToStep(step);
|
|
189
|
+
},
|
|
190
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(NavTitle, {
|
|
191
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
192
|
+
children: step
|
|
193
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
194
|
+
children: name
|
|
195
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
196
|
+
className: arrow,
|
|
197
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaCaretRight, {})
|
|
198
|
+
})]
|
|
199
|
+
})
|
|
200
|
+
}, step);
|
|
201
|
+
})
|
|
202
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
203
|
+
children: childrenWithProps
|
|
204
|
+
})]
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
var Nav = _styledComponents.default.ul(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n background: var(--color-background2);\n border-radius: var(--border-radius-l);\n margin-bottom: var(--spacing);\n\n ", "\n"])), _media.default.mobile(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: block;\n "]))));
|
|
209
|
+
|
|
210
|
+
var NavItem = _styledComponents.default.li(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: var(--font-on-mute);\n font-size: var(--font-body1);\n font-weight: var(--font-bold);\n padding: 0 var(--spacing-xs);\n width: 100%;\n height: 36px;\n line-height: 36px;\n transition: 0.3s;\n overflow: hidden;\n flex: 1;\n cursor: pointer;\n\n &.current,\n &.done {\n background: var(--color-primary);\n color: var(--font-on-primary);\n\n > div > span:first-of-type {\n color: var(--color-primary);\n background: var(--font-on-primary);\n }\n }\n\n &.current {\n background: var(--color-primary);\n color: var(--font-on-primary);\n border-radius: 0 var(--border-radius-l) var(--border-radius-l) 0;\n\n &:first-child {\n border-radius: var(--border-radius-l);\n }\n\n ", "\n }\n\n &.done {\n background: var(--color-primary);\n color: var(--font-on-primary);\n\n &:first-child {\n border-radius: var(--border-radius-l) 0 0 var(--border-radius-l);\n\n ", "\n }\n }\n\n &:hover {\n > div > p {\n color: var(--font-on-primary);\n }\n > div > span:first-of-type {\n color: var(--color-primary);\n background: var(--font-on-primary);\n }\n }\n"])), _media.default.mobile(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-radius: 0 0 var(--border-radius) var(--border-radius);\n "]))), _media.default.mobile(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-radius: var(--border-radius) var(--border-radius) 0 0;\n "]))));
|
|
211
|
+
|
|
212
|
+
var NavTitle = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n\n > span:first-of-type {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: var(--spacing-xs);\n color: var(--font-on-mute);\n flex: 0 0;\n flex-basis: 24px;\n width: 24px;\n height: 24px;\n border-radius: var(--border-radius-l);\n background: var(--font-on-mute);\n }\n\n > p {\n margin-right: auto;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n > span:last-of-type {\n display: none;\n\n &.arrow {\n display: flex;\n align-self: center;\n }\n\n ", "\n }\n"])), _media.default.mobile(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n transform: rotate(90deg);\n "]))));
|
|
213
|
+
|
|
214
|
+
var Step = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: none;\n\n &.active {\n display: block;\n }\n"])));
|
|
215
|
+
|
|
216
|
+
var _default = Wizard;
|
|
217
|
+
exports.default = _default;
|
package/wizard/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Wizard", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Wizard.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _Wizard = _interopRequireDefault(require("./Wizard"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|