@cashub/ui-elv 1.0.1 → 1.0.3
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/chart/BarChart.js +8 -2
- package/chart/DoughnutChart.js +2 -1
- package/chart/LineChart.js +2 -1
- package/chart/utils/customTooltip.js +3 -7
- package/chart/utils/customTooltipLifecyclePlugin.js +21 -0
- package/chart/utils/tooltipElement.js +25 -0
- package/chart/utils/xAxisLabelTooltipPlugin.js +107 -0
- package/datetimePicker/index.js +2 -37
- package/esm/Tab/Tab.js +21 -0
- package/esm/Tab/TabList.js +160 -0
- package/esm/Tab/TabPanel.js +42 -0
- package/esm/Tab/TabTab.js +98 -0
- package/esm/Tab/index.js +23 -0
- package/esm/Tab/subComponent/TabContext.js +3 -0
- package/esm/Tab/subComponent/TabListV2.js +18 -0
- package/esm/Tab/subComponent/TabPanelV2.js +45 -0
- package/esm/Tab/subComponent/TabTabV2.js +56 -0
- package/esm/VerticalTab/TabList.js +20 -0
- package/esm/VerticalTab/TabPanel.js +45 -0
- package/esm/VerticalTab/TabTab.js +63 -0
- package/esm/VerticalTab/VerticalTab.js +34 -0
- package/esm/VerticalTab/index.js +9 -0
- package/esm/VerticalTab/subComponent/TabContext.js +3 -0
- package/esm/alert/Alert.js +22 -0
- package/esm/alert/index.js +1 -0
- package/esm/animate/Collapse.js +65 -0
- package/esm/animate/Loader.js +51 -0
- package/esm/animate/NumberCounter.js +45 -0
- package/esm/animate/PulseRing.js +26 -0
- package/esm/animate/Spinner.js +11 -0
- package/esm/animate/index.js +5 -0
- package/esm/assets/css/autocomplete.css +16 -0
- package/esm/assets/css/font.css +4 -0
- package/esm/assets/css/global.css +2 -0
- package/esm/assets/font/helvetica/Helvetica.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/esm/assets/icons/app-management.png +0 -0
- package/esm/assets/icons/burger-black.png +0 -0
- package/esm/assets/icons/burger-white.png +0 -0
- package/esm/assets/icons/burger.png +0 -0
- package/esm/assets/icons/file.svg +1 -0
- package/esm/assets/icons/map_icon1.png +0 -0
- package/esm/assets/icons/map_icon4.png +0 -0
- package/esm/assets/images/bg-aside.png +0 -0
- package/esm/assets/images/bg-chart-circle.png +0 -0
- package/esm/assets/images/bg-chart-triangle.png +0 -0
- package/esm/assets/images/cashub-logo-only.png +0 -0
- package/esm/assets/images/default-user.jpg +0 -0
- package/esm/assets/images/logo-cashub.png +0 -0
- package/esm/assets/images/map.png +0 -0
- package/esm/assets/images/qrcode.png +0 -0
- package/esm/backdrop/BaseBackdrop.js +11 -0
- package/esm/backdrop/LoadingBackdrop.js +10 -0
- package/esm/backdrop/ModalBackdrop.js +8 -0
- package/esm/backdrop/index.js +3 -0
- package/esm/badge/Badge.js +19 -0
- package/esm/badge/BadgeDot.js +11 -0
- package/esm/badge/BadgeFill.js +42 -0
- package/esm/badge/BadgeFillTriangle.js +138 -0
- package/esm/badge/BadgeWithText.js +24 -0
- package/esm/badge/index.js +5 -0
- package/esm/billing/BarChart.js +45 -0
- package/esm/billing/Grid.js +38 -0
- package/esm/billing/Header2.js +19 -0
- package/esm/billing/Header3.js +31 -0
- package/esm/billing/Paragraph.js +27 -0
- package/esm/billing/ParagraphGroup.js +16 -0
- package/esm/billing/ParagraphText.js +20 -0
- package/esm/billing/Section.js +44 -0
- package/esm/billing/SectionBody.js +11 -0
- package/esm/billing/SectionHeader.js +20 -0
- package/esm/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/esm/billing/__stories__/Grid.stories.js_bak +57 -0
- package/esm/billing/__stories__/Header2.stories.js_bak +62 -0
- package/esm/billing/__stories__/Header3.stories.js_bak +69 -0
- package/esm/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/esm/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/esm/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/esm/billing/__stories__/Section.stories.js_bak +115 -0
- package/esm/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/esm/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/esm/breadcrumb/Breadcrumb.js +71 -0
- package/esm/breadcrumb/index.js +1 -0
- package/esm/button/Button.js +145 -0
- package/esm/button/ButtonGroup.js +54 -0
- package/esm/button/IconButton.js +64 -0
- package/esm/button/ScrollToTopButton.js +47 -0
- package/esm/button/index.js +4 -0
- package/esm/callout/Callout.js +45 -0
- package/esm/callout/index.js +1 -0
- package/esm/chart/BarChart.js +147 -0
- package/esm/chart/DoughnutChart.js +110 -0
- package/esm/chart/LineChart.js +140 -0
- package/esm/chart/SingleBarChart.js +35 -0
- package/esm/chart/index.js +5 -0
- package/esm/chart/utils/centerTextPlugin.js +56 -0
- package/esm/chart/utils/customTooltip.js +84 -0
- package/esm/chart/utils/customTooltipLifecyclePlugin.js +16 -0
- package/esm/chart/utils/htmlLegendPlugin.js +83 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/padEmptyChartBar.js +47 -0
- package/esm/chart/utils/tooltipElement.js +17 -0
- package/esm/chart/utils/xAxisLabelTooltipPlugin.js +101 -0
- package/esm/chart/utils/yAxisTopTitlePlugin.js +43 -0
- package/esm/container/FlexContainer.js +33 -0
- package/esm/container/index.js +1 -0
- package/esm/cropper/Cropper.js +47 -0
- package/esm/cropper/CropperModalHandler.js +34 -0
- package/esm/cropper/index.js +2 -0
- package/esm/cropper/subComponent/CropImageModal.js +72 -0
- package/{datetimePicker/DatetimePicker.js → esm/datetimePicker/DatetimePickerV3.js} +63 -31
- package/esm/datetimePicker/TimeInput.js +49 -0
- package/esm/datetimePicker/TimePickerStyle.js +58 -0
- package/esm/datetimePicker/TimePickerV2.js +199 -0
- package/esm/datetimePicker/accordion/Month.js +245 -0
- package/esm/datetimePicker/accordion/Year.js +275 -0
- package/esm/datetimePicker/index.js +4 -0
- package/esm/datetimePicker/provider/constant.js +38 -0
- package/esm/datetimePicker/subComponent/DateTimePickerContext.js +3 -0
- package/esm/datetimePicker/utils/GMTDate.js +9 -0
- package/esm/datetimePicker/utils/pad.js +7 -0
- package/esm/datetimePicker/utils/toUTC0.js +7 -0
- package/esm/descriptionList/DescriptionDetail.js +21 -0
- package/esm/descriptionList/DescriptionList.js +18 -0
- package/esm/descriptionList/DescriptionTerm.js +7 -0
- package/esm/descriptionList/index.js +3 -0
- package/esm/divider/Divider.js +24 -0
- package/esm/divider/index.js +1 -0
- package/esm/dropdown/Dropdown.js +48 -0
- package/esm/dropdown/DropdownButtonOption.js +36 -0
- package/esm/dropdown/DropdownContent.js +83 -0
- package/esm/dropdown/DropdownDivOption.js +19 -0
- package/esm/dropdown/DropdownItem.js +19 -0
- package/esm/dropdown/DropdownLinkOption.js +17 -0
- package/esm/dropdown/DropdownToggle.js +31 -0
- package/esm/dropdown/index.js +11 -0
- package/esm/dropdown/subComponent/DropdownContext.js +3 -0
- package/esm/dropzone/FileDropzone.js +472 -0
- package/esm/dropzone/ImageDropzone.js +327 -0
- package/esm/dropzone/index.js +2 -0
- package/esm/dropzone/subComponent/Message.js +19 -0
- package/esm/figure/IconFigure.js +35 -0
- package/esm/figure/ImageFigure.js +31 -0
- package/esm/figure/index.js +2 -0
- package/esm/file/HiddenFileInput.js +8 -0
- package/esm/file/index.js +1 -0
- package/esm/form/Checkbox.js +157 -0
- package/esm/form/Fieldset.js +11 -0
- package/esm/form/FormItem.js +15 -0
- package/esm/form/Input.js +59 -0
- package/esm/form/Label.js +54 -0
- package/esm/form/MutedText.js +14 -0
- package/esm/form/PasswordInput.js +40 -0
- package/esm/form/RadioButton.js +94 -0
- package/esm/form/SearchSelect.js +174 -0
- package/esm/form/Searchbox.js +91 -0
- package/esm/form/Slider.js +39 -0
- package/esm/form/SwitchButton.js +97 -0
- package/esm/form/Textarea.js +34 -0
- package/esm/form/TreeView.js +66 -0
- package/esm/form/index.js +14 -0
- package/esm/grid/Column.js +39 -0
- package/esm/grid/Grid.js +28 -0
- package/esm/grid/index.js +2 -0
- package/esm/heading/Heading1.js +14 -0
- package/esm/heading/Heading2.js +21 -0
- package/esm/heading/Heading3.js +42 -0
- package/esm/heading/index.js +3 -0
- package/esm/helmet/Helmet.js +17 -0
- package/esm/helmet/index.js +2 -0
- package/esm/iconbox/ApplicationIconBox.js +74 -0
- package/esm/iconbox/IconBox.js +60 -0
- package/esm/iconbox/IconBoxV2.js +63 -0
- package/esm/iconbox/index.js +3 -0
- package/esm/iconbox/subComponent/IconBoxFigure.js +43 -0
- package/esm/iconbox/subComponent/IconBoxImage.js +35 -0
- package/esm/image/ImageFluid.js +10 -0
- package/esm/image/UploadImage.js +243 -0
- package/esm/image/index.js +2 -0
- package/esm/index.js +47 -0
- package/esm/keyframe/Pulse.js +15 -0
- package/esm/keyframe/Spin.js +7 -0
- package/esm/layout/Aside.js +39 -0
- package/esm/layout/AsideHeader.jsx +27 -0
- package/esm/layout/Backdrop.js +16 -0
- package/esm/layout/Container.js +30 -0
- package/esm/layout/Footer.js +36 -0
- package/esm/layout/Header.jsx +55 -0
- package/esm/layout/Layout.jsx +84 -0
- package/esm/layout/Logo.jsx +17 -0
- package/esm/layout/MenuIcon.jsx +27 -0
- package/esm/layout/Sidebar.jsx +271 -0
- package/esm/layout/index.js +1 -0
- package/esm/link/LinkSpan.js +62 -0
- package/esm/link/index.js +1 -0
- package/esm/map/GoogleMap.js +439 -0
- package/esm/map/GoogleReverseGeolocation.js +193 -0
- package/esm/map/LeafletMap.js +224 -0
- package/esm/map/LeafletReverseGeolocation.js +94 -0
- package/esm/map/index.js +4 -0
- package/esm/map/subComponent/BasicLeafletMap.js +27 -0
- package/esm/map/subComponent/GoogleMapContainer.js +22 -0
- package/esm/map/subComponent/GoogleMapPopup.js +103 -0
- package/esm/map/subComponent/GoogleMapWrapper.js +34 -0
- package/esm/map/subComponent/LeafletDrawControl.js +116 -0
- package/esm/map/subComponent/LeafletMapContainer.js +166 -0
- package/esm/map/subComponent/MapSearchBoxControl.js +47 -0
- package/esm/modal/StateModal.js +169 -0
- package/esm/modal/TitleModal.js +241 -0
- package/esm/modal/index.js +2 -0
- package/esm/page/Disclaimer.js +121 -0
- package/esm/page/index.js +1 -0
- package/esm/paginate/Paginate.js +129 -0
- package/esm/paginate/index.js +1 -0
- package/esm/popover/Popover.js +82 -0
- package/esm/popover/index.js +1 -0
- package/esm/qrcode/QRCode.js +51 -0
- package/esm/qrcode/QRCodeContainter.js +27 -0
- package/esm/qrcode/index.js +2 -0
- package/esm/ribbon/Ribbon.js +35 -0
- package/esm/ribbon/index.js +1 -0
- package/esm/section/Section.js +126 -0
- package/esm/section/SectionBody.js +43 -0
- package/esm/section/SectionHeader.js +61 -0
- package/esm/section/SectionToolbar.js +11 -0
- package/esm/section/SectionToolbarItem.js +10 -0
- package/esm/section/index.js +5 -0
- package/esm/select/InputSelect.js +263 -0
- package/esm/select/Select.js +811 -0
- package/esm/select/index.js +2 -0
- package/esm/select/subComponent/Checkbox.js +40 -0
- package/esm/select/subComponent/Footer.js +6 -0
- package/esm/select/subComponent/ListBox.js +23 -0
- package/esm/select/subComponent/Option.js +37 -0
- package/esm/select/subComponent/OptionGroup.js +16 -0
- package/esm/select/subComponent/Options.js +25 -0
- package/esm/select/subComponent/SearchBox.js +51 -0
- package/esm/select/subComponent/SelectedMultipleCount.js +32 -0
- package/esm/select/subComponent/SelectedMultipleTags.js +47 -0
- package/esm/select/subComponent/SelectedMultipleText.js +63 -0
- package/esm/select/subComponent/SelectedSingle.js +10 -0
- package/esm/styles/GlobalStyle.js +328 -0
- package/esm/styles/config/breakpoint.style.js +7 -0
- package/esm/styles/config/header.style.js +4 -0
- package/esm/styles/config/sidebar.style.js +11 -0
- package/esm/styles/index.js +2 -0
- package/esm/styles/mixin/backgroundColor.js +38 -0
- package/esm/styles/mixin/borderColor.js +31 -0
- package/esm/styles/mixin/color.js +31 -0
- package/esm/styles/mixin/colorOnBackground.js +31 -0
- package/esm/styles/mixin/inputPlaceholder.js +24 -0
- package/esm/styles/mixin/media.js +15 -0
- package/esm/styles/mixin/rounded.js +24 -0
- package/esm/styles/mixin/scrollbar.js +26 -0
- package/esm/styles/theme/dark.theme.js +91 -0
- package/esm/styles/theme/light.theme.js +91 -0
- package/esm/styles/theme/white.theme.js +91 -0
- package/esm/styles/themes.js +9 -0
- package/esm/table/GridTable.js +329 -0
- package/esm/table/ImageBox.js +38 -0
- package/esm/table/InfiniteGridTable.js +396 -0
- package/esm/table/PermissionTable.js +57 -0
- package/esm/table/SimpleGridTable.js +136 -0
- package/esm/table/Table.js +559 -0
- package/esm/table/__mock__/columns.js +64 -0
- package/esm/table/__mock__/data.js +530 -0
- package/esm/table/hooks/index.js +2 -0
- package/esm/table/hooks/useCalculateDataRange.js +22 -0
- package/esm/table/hooks/useGenerateSort.js +32 -0
- package/esm/table/index.js +6 -0
- package/esm/table/subComponent/BaseTableHeadCell.js +54 -0
- package/esm/table/subComponent/GridTableFooter.js +17 -0
- package/esm/table/subComponent/GridTableHeadCell.js +13 -0
- package/esm/table/subComponent/Resizer.js +70 -0
- package/esm/table/subComponent/TableFooter.js +24 -0
- package/esm/table/subComponent/TableFooterInfo.js +6 -0
- package/esm/table/subComponent/TableFooterPager.js +26 -0
- package/esm/table/subComponent/TableHeadCell.js +12 -0
- package/esm/table/subComponent/TableSort.js +31 -0
- package/esm/tagify/TagifyStyle.js +54 -0
- package/esm/tagify/Tags.js +49 -0
- package/esm/tagify/index.js +3 -0
- package/esm/tagify/templates/getCreateButtonTemplate.js +12 -0
- package/esm/text/Paragraph.js +79 -0
- package/esm/text/index.js +1 -0
- package/esm/timeline/Timeline.js +132 -0
- package/esm/timeline/index.js +1 -0
- package/esm/toast/CustomToastContainer.js +38 -0
- package/esm/toast/MessageContainer.js +44 -0
- package/esm/toast/index.js +3 -0
- package/esm/toast/show.js +29 -0
- package/esm/toast/style.css +1 -0
- package/esm/tooltip/Tooltip.js +133 -0
- package/esm/tooltip/index.js +1 -0
- package/esm/treeView/TreeViewV2.js +32 -0
- package/esm/treeView/TreeflexStyle.js +43 -0
- package/esm/treeView/index.js +2 -0
- package/esm/wizard/Wizard.js +244 -0
- package/esm/wizard/index.js +1 -0
- package/index.js +0 -12
- package/layout/Sidebar.jsx +1 -1
- package/package.json +5 -4
- package/datetimePicker/DatePicker.js +0 -363
- package/datetimePicker/DatePickerV2.js +0 -407
- package/datetimePicker/DatetimePickerV2.js +0 -395
- package/datetimePicker/TimePicker.js +0 -317
- package/datetimePicker/hooks/index.js +0 -27
- package/datetimePicker/hooks/useChangeNumber.js +0 -42
- package/datetimePicker/hooks/useDecrease.js +0 -38
- package/datetimePicker/hooks/useIncrease.js +0 -38
- package/datetimePicker/subComponent/Accordion.js +0 -373
- package/datetimePicker/subComponent/CustomTimeInput.js +0 -47
- package/jsoneditor/JsonEditor.js +0 -142
- package/jsoneditor/index.js +0 -13
package/chart/BarChart.js
CHANGED
|
@@ -8,8 +8,10 @@ var _react = require("react");
|
|
|
8
8
|
var _styledComponents = require("styled-components");
|
|
9
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
10
10
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
11
|
+
var _customTooltipLifecyclePlugin = _interopRequireDefault(require("./utils/customTooltipLifecyclePlugin"));
|
|
11
12
|
var _padEmptyChartBar = _interopRequireDefault(require("./utils/padEmptyChartBar"));
|
|
12
13
|
var _yAxisTopTitlePlugin = _interopRequireDefault(require("./utils/yAxisTopTitlePlugin"));
|
|
14
|
+
var _xAxisLabelTooltipPlugin = _interopRequireDefault(require("./utils/xAxisLabelTooltipPlugin"));
|
|
13
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
17
|
const BarChart = _ref => {
|
|
@@ -39,7 +41,8 @@ const BarChart = _ref => {
|
|
|
39
41
|
showLegend: options.showLegend === undefined ? false : options.showLegend,
|
|
40
42
|
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel,
|
|
41
43
|
yAxisTopTitle: yAxisTopTitle ? yAxisTopTitle : '',
|
|
42
|
-
tooltipLabelPostfix: tooltips.labelPostfix || ''
|
|
44
|
+
tooltipLabelPostfix: tooltips.labelPostfix || '',
|
|
45
|
+
showFullLabelOnHover: options.showFullLabelOnHover === undefined ? false : options.showFullLabelOnHover
|
|
43
46
|
};
|
|
44
47
|
}, [options]);
|
|
45
48
|
const defaultOptions = (0, _react.useMemo)(() => {
|
|
@@ -96,6 +99,9 @@ const BarChart = _ref => {
|
|
|
96
99
|
},
|
|
97
100
|
yAxisTopTitle: {
|
|
98
101
|
title: customOptions.yAxisTopTitle
|
|
102
|
+
},
|
|
103
|
+
xAxisLabelTooltip: {
|
|
104
|
+
enabled: customOptions.showFullLabelOnHover
|
|
99
105
|
}
|
|
100
106
|
},
|
|
101
107
|
scales: {
|
|
@@ -141,7 +147,7 @@ const BarChart = _ref => {
|
|
|
141
147
|
height: height,
|
|
142
148
|
data: data,
|
|
143
149
|
options: defaultOptions,
|
|
144
|
-
plugins: [_padEmptyChartBar.default, _yAxisTopTitlePlugin.default],
|
|
150
|
+
plugins: [_padEmptyChartBar.default, _yAxisTopTitlePlugin.default, _xAxisLabelTooltipPlugin.default, _customTooltipLifecyclePlugin.default],
|
|
145
151
|
...props
|
|
146
152
|
});
|
|
147
153
|
};
|
package/chart/DoughnutChart.js
CHANGED
|
@@ -10,6 +10,7 @@ var _reactChartjs = require("react-chartjs-2");
|
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
|
|
11
11
|
var _htmlLegendPlugin = _interopRequireDefault(require("./utils/htmlLegendPlugin"));
|
|
12
12
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
13
|
+
var _customTooltipLifecyclePlugin = _interopRequireDefault(require("./utils/customTooltipLifecyclePlugin"));
|
|
13
14
|
var _centerTextPlugin = _interopRequireDefault(require("./utils/centerTextPlugin"));
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -83,7 +84,7 @@ const DoughnutChart = _ref => {
|
|
|
83
84
|
height: height,
|
|
84
85
|
data: data,
|
|
85
86
|
options: defaultOptions,
|
|
86
|
-
plugins: [_htmlLegendPlugin.default, _centerTextPlugin.default],
|
|
87
|
+
plugins: [_htmlLegendPlugin.default, _centerTextPlugin.default, _customTooltipLifecyclePlugin.default],
|
|
87
88
|
...props
|
|
88
89
|
})
|
|
89
90
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(LegendWrapper, {
|
package/chart/LineChart.js
CHANGED
|
@@ -8,6 +8,7 @@ var _react = require("react");
|
|
|
8
8
|
var _styledComponents = require("styled-components");
|
|
9
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
10
10
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
11
|
+
var _customTooltipLifecyclePlugin = _interopRequireDefault(require("./utils/customTooltipLifecyclePlugin"));
|
|
11
12
|
var _yAxisTopTitlePlugin = _interopRequireDefault(require("./utils/yAxisTopTitlePlugin"));
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -139,7 +140,7 @@ const LineChart = _ref => {
|
|
|
139
140
|
height: height,
|
|
140
141
|
data: data,
|
|
141
142
|
options: defaultOptions,
|
|
142
|
-
plugins: [_yAxisTopTitlePlugin.default],
|
|
143
|
+
plugins: [_yAxisTopTitlePlugin.default, _customTooltipLifecyclePlugin.default],
|
|
143
144
|
...props
|
|
144
145
|
});
|
|
145
146
|
};
|
|
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _tooltipElement = require("./tooltipElement");
|
|
7
8
|
const customTooltip = theme => {
|
|
8
9
|
// optimize: render in react way
|
|
9
10
|
return function (context) {
|
|
10
11
|
// Tooltip Element
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Create element on first render
|
|
14
|
-
if (!tooltipEl) {
|
|
15
|
-
tooltipEl = document.createElement('div');
|
|
16
|
-
tooltipEl.id = 'chartjs-tooltip';
|
|
12
|
+
const tooltipEl = (0, _tooltipElement.getOrCreateTooltipEl)(_tooltipElement.CUSTOM_TOOLTIP_ID);
|
|
13
|
+
if (!tooltipEl.querySelector('table')) {
|
|
17
14
|
tooltipEl.innerHTML = '<table></table>';
|
|
18
|
-
document.body.appendChild(tooltipEl);
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
// Hide tooltip, if no tooltip or no data
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _tooltipElement = require("./tooltipElement");
|
|
8
|
+
// customTooltip.js renders #chartjs-tooltip outside React's tree (appended to
|
|
9
|
+
// document.body), so it needs an explicit hook to hide it when the chart's
|
|
10
|
+
// container resizes or the chart instance is destroyed - otherwise the last
|
|
11
|
+
// rendered tooltip is left floating, detached from the (moved/gone) chart.
|
|
12
|
+
const customTooltipLifecyclePlugin = {
|
|
13
|
+
id: 'customTooltipLifecycle',
|
|
14
|
+
resize() {
|
|
15
|
+
(0, _tooltipElement.hideTooltipEl)(_tooltipElement.CUSTOM_TOOLTIP_ID);
|
|
16
|
+
},
|
|
17
|
+
afterDestroy() {
|
|
18
|
+
(0, _tooltipElement.hideTooltipEl)(_tooltipElement.CUSTOM_TOOLTIP_ID);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var _default = exports.default = customTooltipLifecyclePlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hideTooltipEl = exports.getOrCreateTooltipEl = exports.CUSTOM_TOOLTIP_ID = exports.AXIS_TOOLTIP_ID = void 0;
|
|
7
|
+
const CUSTOM_TOOLTIP_ID = exports.CUSTOM_TOOLTIP_ID = 'chartjs-tooltip';
|
|
8
|
+
const AXIS_TOOLTIP_ID = exports.AXIS_TOOLTIP_ID = 'chartjs-axis-tooltip';
|
|
9
|
+
const getOrCreateTooltipEl = id => {
|
|
10
|
+
let tooltipEl = document.getElementById(id);
|
|
11
|
+
if (!tooltipEl) {
|
|
12
|
+
tooltipEl = document.createElement('div');
|
|
13
|
+
tooltipEl.id = id;
|
|
14
|
+
document.body.appendChild(tooltipEl);
|
|
15
|
+
}
|
|
16
|
+
return tooltipEl;
|
|
17
|
+
};
|
|
18
|
+
exports.getOrCreateTooltipEl = getOrCreateTooltipEl;
|
|
19
|
+
const hideTooltipEl = id => {
|
|
20
|
+
const tooltipEl = document.getElementById(id);
|
|
21
|
+
if (tooltipEl) {
|
|
22
|
+
tooltipEl.style.display = 'none';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.hideTooltipEl = hideTooltipEl;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _tooltipElement = require("./tooltipElement");
|
|
8
|
+
const hideTooltip = () => (0, _tooltipElement.hideTooltipEl)(_tooltipElement.AXIS_TOOLTIP_ID);
|
|
9
|
+
const getTooltipEl = () => {
|
|
10
|
+
const tooltipEl = (0, _tooltipElement.getOrCreateTooltipEl)(_tooltipElement.AXIS_TOOLTIP_ID);
|
|
11
|
+
tooltipEl.style.position = 'absolute';
|
|
12
|
+
tooltipEl.style.pointerEvents = 'none';
|
|
13
|
+
tooltipEl.style.zIndex = 80;
|
|
14
|
+
tooltipEl.style.maxWidth = '50vw';
|
|
15
|
+
tooltipEl.style.wordBreak = 'break-word';
|
|
16
|
+
tooltipEl.style.whiteSpace = 'nowrap';
|
|
17
|
+
tooltipEl.style.textAlign = 'left';
|
|
18
|
+
tooltipEl.style.border = '1px solid var(--border-color)';
|
|
19
|
+
tooltipEl.style.color = 'var(--font-on-background)';
|
|
20
|
+
tooltipEl.style.background = 'var(--color-background2)';
|
|
21
|
+
tooltipEl.style.boxShadow = 'var(--box-shadow)';
|
|
22
|
+
tooltipEl.style.borderRadius = 'calc(var(--border-radius) / 2)';
|
|
23
|
+
tooltipEl.style.padding = 'var(--spacing-xs)';
|
|
24
|
+
tooltipEl.style.fontSize = 'var(--font-body1)';
|
|
25
|
+
return tooltipEl;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// approximate hit-box per rendered tick: stable public getPixelForTick() + chartArea,
|
|
29
|
+
// not Chart.js's private _labelItems/_computeLabelItems (undocumented, version-fragile).
|
|
30
|
+
//
|
|
31
|
+
// Ticks are matched via xScale.ticks (the array Chart.js actually renders) rather than
|
|
32
|
+
// chart.data.labels directly, because ticks.autoSkip (on by default) drops entries when
|
|
33
|
+
// labels don't all fit - exactly the case this feature targets. Each rendered tick's
|
|
34
|
+
// `.value` is the original index into chart.data.labels, which getPixelForTick(i) does
|
|
35
|
+
// NOT return (it returns a pixel, and its `i` argument is a position in the possibly-
|
|
36
|
+
// skipped ticks array, not a label index) - so the original label index must be read
|
|
37
|
+
// back off ticks[i].value, not off the loop counter.
|
|
38
|
+
const findHoveredTickIndex = (chart, x, y) => {
|
|
39
|
+
const xScale = chart.scales.x;
|
|
40
|
+
if (!xScale) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
const {
|
|
44
|
+
ticks
|
|
45
|
+
} = xScale;
|
|
46
|
+
if (!ticks || ticks.length === 0) {
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
const {
|
|
50
|
+
chartArea
|
|
51
|
+
} = chart;
|
|
52
|
+
if (y < chartArea.bottom || y > xScale.bottom || x < chartArea.left || x > chartArea.right) {
|
|
53
|
+
return -1;
|
|
54
|
+
}
|
|
55
|
+
const halfStep = ticks.length > 1 ? Math.abs(xScale.getPixelForTick(1) - xScale.getPixelForTick(0)) / 2 : (xScale.right - xScale.left) / 2;
|
|
56
|
+
for (let i = 0; i < ticks.length; i += 1) {
|
|
57
|
+
const tickPixel = xScale.getPixelForTick(i);
|
|
58
|
+
if (tickPixel !== null && Math.abs(x - tickPixel) <= halfStep) {
|
|
59
|
+
return ticks[i].value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return -1;
|
|
63
|
+
};
|
|
64
|
+
const xAxisLabelTooltipPlugin = {
|
|
65
|
+
id: 'xAxisLabelTooltip',
|
|
66
|
+
afterEvent(chart, args) {
|
|
67
|
+
const config = chart.config.options.plugins.xAxisLabelTooltip;
|
|
68
|
+
if (!config || !config.enabled) {
|
|
69
|
+
hideTooltip();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const {
|
|
73
|
+
event
|
|
74
|
+
} = args;
|
|
75
|
+
if (event.type === 'mouseout') {
|
|
76
|
+
hideTooltip();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (event.type !== 'mousemove') {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const index = findHoveredTickIndex(chart, event.x, event.y);
|
|
83
|
+
const label = index === -1 ? undefined : chart.data.labels[index];
|
|
84
|
+
if (typeof label !== 'string' || !label) {
|
|
85
|
+
hideTooltip();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const tooltipEl = getTooltipEl();
|
|
89
|
+
tooltipEl.textContent = label;
|
|
90
|
+
tooltipEl.style.display = 'block';
|
|
91
|
+
const canvasRect = chart.canvas.getBoundingClientRect();
|
|
92
|
+
// index here is the original label index (see findHoveredTickIndex), so the pixel
|
|
93
|
+
// must come from getPixelForValue(index), not getPixelForTick(index) - the latter
|
|
94
|
+
// expects a position in the (possibly autoSkip-reduced) ticks array, not a label index.
|
|
95
|
+
const tickX = chart.scales.x.getPixelForValue(index);
|
|
96
|
+
tooltipEl.style.transform = 'translateX(-50%)';
|
|
97
|
+
tooltipEl.style.left = `${canvasRect.left + window.pageXOffset + tickX}px`;
|
|
98
|
+
tooltipEl.style.top = `${canvasRect.top + window.pageYOffset + chart.chartArea.bottom + 8}px`;
|
|
99
|
+
},
|
|
100
|
+
resize() {
|
|
101
|
+
hideTooltip();
|
|
102
|
+
},
|
|
103
|
+
afterDestroy() {
|
|
104
|
+
hideTooltip();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var _default = exports.default = xAxisLabelTooltipPlugin;
|
package/datetimePicker/index.js
CHANGED
|
@@ -3,34 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "DatePicker", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _DatePicker.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "DatePickerV2", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _DatePickerV.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "DatetimePicker", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _DatetimePicker.default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "DatetimePickerV2", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _DatetimePickerV.default;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
6
|
Object.defineProperty(exports, "DatetimePickerV3", {
|
|
31
7
|
enumerable: true,
|
|
32
8
|
get: function () {
|
|
33
|
-
return
|
|
9
|
+
return _DatetimePickerV.default;
|
|
34
10
|
}
|
|
35
11
|
});
|
|
36
12
|
Object.defineProperty(exports, "TimeInput", {
|
|
@@ -39,12 +15,6 @@ Object.defineProperty(exports, "TimeInput", {
|
|
|
39
15
|
return _TimeInput.default;
|
|
40
16
|
}
|
|
41
17
|
});
|
|
42
|
-
Object.defineProperty(exports, "TimePicker", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _TimePicker.default;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
18
|
Object.defineProperty(exports, "TimePickerStyle", {
|
|
49
19
|
enumerable: true,
|
|
50
20
|
get: function () {
|
|
@@ -57,13 +27,8 @@ Object.defineProperty(exports, "TimePickerV2", {
|
|
|
57
27
|
return _TimePickerV.default;
|
|
58
28
|
}
|
|
59
29
|
});
|
|
60
|
-
var
|
|
61
|
-
var _DatePickerV = _interopRequireDefault(require("./DatePickerV2"));
|
|
62
|
-
var _DatetimePicker = _interopRequireDefault(require("./DatetimePicker"));
|
|
63
|
-
var _DatetimePickerV = _interopRequireDefault(require("./DatetimePickerV2"));
|
|
64
|
-
var _DatetimePickerV2 = _interopRequireDefault(require("./DatetimePickerV3"));
|
|
30
|
+
var _DatetimePickerV = _interopRequireDefault(require("./DatetimePickerV3"));
|
|
65
31
|
var _TimeInput = _interopRequireDefault(require("./TimeInput"));
|
|
66
|
-
var _TimePicker = _interopRequireDefault(require("./TimePicker"));
|
|
67
32
|
var _TimePickerV = _interopRequireDefault(require("./TimePickerV2"));
|
|
68
33
|
var _TimePickerStyle = _interopRequireDefault(require("./TimePickerStyle"));
|
|
69
34
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/esm/Tab/Tab.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import TabContext from './subComponent/TabContext';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const Tab = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
selected,
|
|
7
|
+
onChange,
|
|
8
|
+
mode = 'view',
|
|
9
|
+
onTitleChange
|
|
10
|
+
} = _ref;
|
|
11
|
+
return /*#__PURE__*/_jsx(TabContext.Provider, {
|
|
12
|
+
value: {
|
|
13
|
+
selected,
|
|
14
|
+
onChange,
|
|
15
|
+
mode,
|
|
16
|
+
onTitleChange
|
|
17
|
+
},
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export default Tab;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { FaAngleLeft, FaAngleRight } from 'react-icons/fa/index.esm';
|
|
4
|
+
import { Button } from '../button';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
+
const MAX_MOVE_PIXEL = 300;
|
|
7
|
+
const TabList = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
wrap = true,
|
|
11
|
+
...props
|
|
12
|
+
} = _ref;
|
|
13
|
+
const wrapperRef = useRef(null);
|
|
14
|
+
const [exceedContainerWidth, setExceedContainerWidth] = useState(false);
|
|
15
|
+
const [hasPrevious, setHasPrevious] = useState(false);
|
|
16
|
+
const [hasNext, setHasNext] = useState(false);
|
|
17
|
+
const checkExceedContainerWidth = useCallback(() => {
|
|
18
|
+
if (wrapperRef.current) {
|
|
19
|
+
const {
|
|
20
|
+
offsetWidth,
|
|
21
|
+
scrollWidth
|
|
22
|
+
} = wrapperRef.current;
|
|
23
|
+
let {
|
|
24
|
+
marginLeft
|
|
25
|
+
} = getComputedStyle(wrapperRef.current);
|
|
26
|
+
const currentMarginLeft = Math.abs(parseInt(marginLeft));
|
|
27
|
+
setHasPrevious(currentMarginLeft > 0);
|
|
28
|
+
setHasNext(scrollWidth - offsetWidth > 0);
|
|
29
|
+
setExceedContainerWidth(scrollWidth > offsetWidth - currentMarginLeft);
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
const handleResize = useCallback(() => {
|
|
33
|
+
checkExceedContainerWidth();
|
|
34
|
+
}, []);
|
|
35
|
+
const handleTransitionend = useCallback(event => {
|
|
36
|
+
// only allow margin-left transition event
|
|
37
|
+
if (event && event.propertyName !== 'margin-left') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
checkExceedContainerWidth();
|
|
41
|
+
}, []);
|
|
42
|
+
const getMovePixel = offsetWidth => {
|
|
43
|
+
// move 1/3 pixel as default
|
|
44
|
+
const defaultMovePixel = Math.ceil(offsetWidth / 3);
|
|
45
|
+
return defaultMovePixel > MAX_MOVE_PIXEL ? MAX_MOVE_PIXEL : defaultMovePixel;
|
|
46
|
+
};
|
|
47
|
+
const updateScrollPosition = marginLeft => {
|
|
48
|
+
wrapperRef.current.style.marginLeft = marginLeft;
|
|
49
|
+
};
|
|
50
|
+
const handlePrevious = () => {
|
|
51
|
+
const {
|
|
52
|
+
offsetWidth
|
|
53
|
+
} = wrapperRef.current;
|
|
54
|
+
const {
|
|
55
|
+
marginLeft
|
|
56
|
+
} = getComputedStyle(wrapperRef.current);
|
|
57
|
+
const currentMarginLeft = Math.abs(parseInt(marginLeft));
|
|
58
|
+
const availableMovePixel = currentMarginLeft;
|
|
59
|
+
const movePixel = getMovePixel(offsetWidth - currentMarginLeft);
|
|
60
|
+
if (movePixel > availableMovePixel) {
|
|
61
|
+
// exceed edge, so move to edge only
|
|
62
|
+
updateScrollPosition('0px');
|
|
63
|
+
} else {
|
|
64
|
+
updateScrollPosition(`-${currentMarginLeft - movePixel}px`);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleNext = () => {
|
|
68
|
+
const {
|
|
69
|
+
offsetWidth,
|
|
70
|
+
scrollWidth
|
|
71
|
+
} = wrapperRef.current;
|
|
72
|
+
const {
|
|
73
|
+
marginLeft
|
|
74
|
+
} = getComputedStyle(wrapperRef.current);
|
|
75
|
+
const currentMarginLeft = Math.abs(parseInt(marginLeft));
|
|
76
|
+
const availableMovePixel = scrollWidth - offsetWidth;
|
|
77
|
+
const movePixel = getMovePixel(offsetWidth - currentMarginLeft);
|
|
78
|
+
if (movePixel > availableMovePixel) {
|
|
79
|
+
// exceed edge, so move to edge only
|
|
80
|
+
updateScrollPosition(`-${currentMarginLeft + availableMovePixel}px`);
|
|
81
|
+
} else {
|
|
82
|
+
updateScrollPosition(`-${currentMarginLeft + movePixel}px`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
window.addEventListener('resize', handleResize);
|
|
87
|
+
handleResize();
|
|
88
|
+
return () => {
|
|
89
|
+
window.removeEventListener('resize', handleResize);
|
|
90
|
+
};
|
|
91
|
+
}, [wrap, children]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (wrapperRef.current) {
|
|
94
|
+
wrapperRef.current.addEventListener('transitionend', handleTransitionend);
|
|
95
|
+
}
|
|
96
|
+
}, [wrap]);
|
|
97
|
+
return /*#__PURE__*/_jsx(Container, {
|
|
98
|
+
role: "tablist",
|
|
99
|
+
$wrap: wrap,
|
|
100
|
+
...props,
|
|
101
|
+
children: wrap ? children : /*#__PURE__*/_jsxs(_Fragment, {
|
|
102
|
+
children: [/*#__PURE__*/_jsx(TabWrapper, {
|
|
103
|
+
ref: wrapperRef,
|
|
104
|
+
children: children
|
|
105
|
+
}), exceedContainerWidth && /*#__PURE__*/_jsxs(Paginate, {
|
|
106
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
107
|
+
"aria-label": "Previous",
|
|
108
|
+
reverse: true,
|
|
109
|
+
onClick: handlePrevious,
|
|
110
|
+
iconOnly: true,
|
|
111
|
+
disabled: !hasPrevious,
|
|
112
|
+
children: /*#__PURE__*/_jsx(FaAngleLeft, {})
|
|
113
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
114
|
+
"aria-label": "Next",
|
|
115
|
+
reverse: true,
|
|
116
|
+
onClick: handleNext,
|
|
117
|
+
iconOnly: true,
|
|
118
|
+
disabled: !hasNext,
|
|
119
|
+
children: /*#__PURE__*/_jsx(FaAngleRight, {})
|
|
120
|
+
})]
|
|
121
|
+
})]
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
const Container = styled.div`
|
|
126
|
+
position: relative;
|
|
127
|
+
border-bottom: var(--border-width) solid var(--border-color);
|
|
128
|
+
margin-bottom: var(--spacing);
|
|
129
|
+
|
|
130
|
+
${_ref2 => {
|
|
131
|
+
let {
|
|
132
|
+
$wrap
|
|
133
|
+
} = _ref2;
|
|
134
|
+
return !$wrap && 'white-space: nowrap;';
|
|
135
|
+
}}
|
|
136
|
+
|
|
137
|
+
${_ref3 => {
|
|
138
|
+
let {
|
|
139
|
+
noMargin
|
|
140
|
+
} = _ref3;
|
|
141
|
+
return noMargin && 'margin-bottom: 0;';
|
|
142
|
+
}}
|
|
143
|
+
`;
|
|
144
|
+
const TabWrapper = styled.div`
|
|
145
|
+
margin-right: calc(1rem * 2 + 10px * 4 + var(--spacing-xs) * 2);
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
margin-left: 0;
|
|
148
|
+
transition: margin-left 0.3s;
|
|
149
|
+
`;
|
|
150
|
+
const Paginate = styled.div`
|
|
151
|
+
display: flex;
|
|
152
|
+
position: absolute;
|
|
153
|
+
top: 0;
|
|
154
|
+
right: 0;
|
|
155
|
+
|
|
156
|
+
> :not(:last-child) {
|
|
157
|
+
margin-right: var(--spacing-xs);
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
|
+
export default TabList;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useContext, useEffect, useState, useMemo } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import TabContext from './subComponent/TabContext';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const TabPanel = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
name,
|
|
9
|
+
...props
|
|
10
|
+
} = _ref;
|
|
11
|
+
const {
|
|
12
|
+
selected
|
|
13
|
+
} = useContext(TabContext);
|
|
14
|
+
const [rendered, setRendered] = useState(false);
|
|
15
|
+
const tabContent = useMemo(() => {
|
|
16
|
+
if (rendered) {
|
|
17
|
+
return children;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}, [rendered, children]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (name === selected) {
|
|
23
|
+
setRendered(true);
|
|
24
|
+
}
|
|
25
|
+
}, [selected, name]);
|
|
26
|
+
return /*#__PURE__*/_jsx(Panel, {
|
|
27
|
+
role: "tabpanel",
|
|
28
|
+
$display: selected === name,
|
|
29
|
+
...props,
|
|
30
|
+
children: tabContent
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const Panel = styled.div`
|
|
34
|
+
display: ${_ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
$display
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return $display ? 'block' : 'none';
|
|
39
|
+
}};
|
|
40
|
+
position: relative;
|
|
41
|
+
`;
|
|
42
|
+
export default TabPanel;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useContext, useState, useCallback } from 'react';
|
|
2
|
+
import { KEY_CODE } from '@cashub/utils';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import TabContext from './subComponent/TabContext';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const TabTab = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
name,
|
|
10
|
+
title,
|
|
11
|
+
onClick,
|
|
12
|
+
...props
|
|
13
|
+
} = _ref;
|
|
14
|
+
const {
|
|
15
|
+
selected,
|
|
16
|
+
onChange,
|
|
17
|
+
mode,
|
|
18
|
+
onTitleChange
|
|
19
|
+
} = useContext(TabContext);
|
|
20
|
+
const [isModify, setIsModify] = useState(false);
|
|
21
|
+
const [currentTitle, setCurrentTitle] = useState(title);
|
|
22
|
+
const handleClick = useCallback(() => {
|
|
23
|
+
if (selected !== name) {
|
|
24
|
+
onChange(name);
|
|
25
|
+
}
|
|
26
|
+
if (onClick && typeof onClick === 'function') {
|
|
27
|
+
onClick();
|
|
28
|
+
}
|
|
29
|
+
}, [name, selected, onChange, onClick]);
|
|
30
|
+
const handleDoubleClick = () => {
|
|
31
|
+
if (mode !== 'modify') return;
|
|
32
|
+
setIsModify(true);
|
|
33
|
+
};
|
|
34
|
+
const handleBlur = () => {
|
|
35
|
+
onTitleChange(name, currentTitle);
|
|
36
|
+
setIsModify(false);
|
|
37
|
+
};
|
|
38
|
+
const handleKeyUp = event => {
|
|
39
|
+
const key = event.keyCode;
|
|
40
|
+
if (key === KEY_CODE.ENTER) {
|
|
41
|
+
onTitleChange(name, currentTitle);
|
|
42
|
+
setIsModify(false);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return isModify ? /*#__PURE__*/_jsx(InputTab, {
|
|
46
|
+
role: "tab",
|
|
47
|
+
type: "text",
|
|
48
|
+
value: currentTitle,
|
|
49
|
+
onChange: event => {
|
|
50
|
+
setCurrentTitle(event.target.value);
|
|
51
|
+
},
|
|
52
|
+
onBlur: handleBlur,
|
|
53
|
+
onKeyUp: handleKeyUp,
|
|
54
|
+
autoFocus: true
|
|
55
|
+
}) : /*#__PURE__*/_jsx(ButtonTab, {
|
|
56
|
+
role: "tab",
|
|
57
|
+
onClick: handleClick,
|
|
58
|
+
onDoubleClick: handleDoubleClick,
|
|
59
|
+
active: selected === name,
|
|
60
|
+
...props,
|
|
61
|
+
children: children
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const Tab = styled.div`
|
|
65
|
+
background: transparent;
|
|
66
|
+
padding: 10px var(--spacing-s);
|
|
67
|
+
border: none;
|
|
68
|
+
border-bottom: 4px solid transparent;
|
|
69
|
+
`;
|
|
70
|
+
const ButtonTab = styled(Tab).attrs({
|
|
71
|
+
as: 'button'
|
|
72
|
+
})`
|
|
73
|
+
color: var(--font-on-mute);
|
|
74
|
+
transition: color 0.3s, border 0.3s;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
|
|
77
|
+
&:hover {
|
|
78
|
+
color: var(--font-on-background);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
${_ref2 => {
|
|
82
|
+
let {
|
|
83
|
+
active
|
|
84
|
+
} = _ref2;
|
|
85
|
+
return active && `
|
|
86
|
+
border-color: var(--color-primary);
|
|
87
|
+
color: var(--font-on-background);
|
|
88
|
+
`;
|
|
89
|
+
}}
|
|
90
|
+
`;
|
|
91
|
+
const InputTab = styled(Tab).attrs({
|
|
92
|
+
as: 'input'
|
|
93
|
+
})`
|
|
94
|
+
color: var(--font-on-background);
|
|
95
|
+
border-color: var(--color-primary);
|
|
96
|
+
outline: none;
|
|
97
|
+
`;
|
|
98
|
+
export default TabTab;
|
package/esm/Tab/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Tab from './Tab';
|
|
2
|
+
import TabList from './TabList';
|
|
3
|
+
import TabTab from './TabTab';
|
|
4
|
+
import TabPanel from './TabPanel';
|
|
5
|
+
import TabListV2 from './subComponent/TabListV2';
|
|
6
|
+
import TabTabV2 from './subComponent/TabTabV2';
|
|
7
|
+
import TabPanelV2 from './subComponent/TabPanelV2';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export default Object.assign(Tab, {
|
|
10
|
+
List: TabList,
|
|
11
|
+
Tab: TabTab,
|
|
12
|
+
Panel: TabPanel
|
|
13
|
+
});
|
|
14
|
+
const TabV2Base = props => {
|
|
15
|
+
return /*#__PURE__*/_jsx(Tab, {
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export const TabV2 = Object.assign(TabV2Base, {
|
|
20
|
+
List: TabListV2,
|
|
21
|
+
Tab: TabTabV2,
|
|
22
|
+
Panel: TabPanelV2
|
|
23
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const TabListV2 = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
...props
|
|
7
|
+
} = _ref;
|
|
8
|
+
return /*#__PURE__*/_jsx(Container, {
|
|
9
|
+
role: "tablist",
|
|
10
|
+
...props,
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const Container = styled.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-wrap: wrap;
|
|
17
|
+
`;
|
|
18
|
+
export default TabListV2;
|