@cashub/ui 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Tab/Tab.js +9 -13
- package/Tab/TabList.js +14 -32
- package/Tab/TabPanel.js +21 -58
- package/Tab/TabTab.js +20 -40
- package/Tab/index.js +2 -10
- package/Tab/subComponent/TabContext.js +2 -5
- package/animate/Collapse.js +26 -53
- package/animate/Loader.js +21 -26
- package/animate/NumberCounter.js +22 -44
- package/animate/PulseRing.js +9 -21
- package/animate/Spinner.js +2 -10
- package/animate/index.js +5 -11
- package/backdrop/BaseBackdrop.js +2 -9
- package/backdrop/LoadingBackdrop.js +2 -9
- package/backdrop/ModalBackdrop.js +2 -9
- package/backdrop/index.js +3 -7
- package/badge/Badge.js +2 -11
- package/badge/BadgeDot.js +2 -10
- package/badge/BadgeFill.js +15 -20
- package/badge/BadgeWithText.js +6 -13
- package/badge/index.js +4 -9
- package/billing/BarChart.js +10 -17
- package/billing/Grid.js +11 -15
- package/billing/Header2.js +6 -9
- package/billing/Header3.js +9 -16
- package/billing/Paragraph.js +8 -14
- package/billing/ParagraphGroup.js +6 -9
- package/billing/ParagraphText.js +7 -12
- package/billing/Section.js +13 -23
- package/billing/SectionBody.js +5 -8
- package/billing/SectionHeader.js +7 -12
- package/breadcrumb/Breadcrumb.js +11 -21
- package/breadcrumb/index.js +1 -3
- package/button/Button.js +41 -38
- package/button/ButtonGroup.js +21 -18
- package/button/IconButton.js +29 -29
- package/button/ScrollToTopButton.js +12 -39
- package/button/index.js +4 -9
- package/callout/Callout.js +13 -26
- package/callout/index.js +1 -3
- package/chart/BarChart.js +28 -53
- package/chart/DoughnutChart.js +23 -62
- package/chart/LineChart.js +33 -55
- package/chart/SingleBarChart.js +11 -17
- package/chart/index.js +5 -12
- package/chart/utils/customTooltip.js +26 -43
- package/chart/utils/htmlLegendPlugin.js +24 -30
- package/chart/utils/index.js +3 -7
- package/chart/utils/padEmptyChartBar.js +24 -22
- package/container/FlexContainer.js +9 -12
- package/container/index.js +1 -3
- package/cropper/Cropper.js +21 -34
- package/cropper/CropperModalHandler.js +15 -21
- package/cropper/index.js +2 -5
- package/cropper/subComponent/CropImageModal.js +23 -58
- package/datetimePicker/DatePicker.js +103 -217
- package/datetimePicker/DatePickerV2.js +116 -221
- package/datetimePicker/DatetimePicker.js +27 -48
- package/datetimePicker/DatetimePickerV2.js +115 -231
- package/datetimePicker/TimeInput.js +9 -22
- package/datetimePicker/TimePicker.js +94 -151
- package/datetimePicker/TimePickerStyle.js +2 -9
- package/datetimePicker/accordion/Month.js +70 -90
- package/datetimePicker/accordion/Year.js +91 -135
- package/datetimePicker/hooks/index.js +3 -7
- package/datetimePicker/hooks/useChangeNumber.js +14 -27
- package/datetimePicker/hooks/useDecrease.js +19 -35
- package/datetimePicker/hooks/useIncrease.js +19 -35
- package/datetimePicker/index.js +7 -15
- package/datetimePicker/provider/constant.js +2 -3
- package/datetimePicker/subComponent/Accordion.js +108 -158
- package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
- package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
- package/datetimePicker/utils/GMTDate.js +3 -7
- package/datetimePicker/utils/pad.js +2 -6
- package/datetimePicker/utils/toUTC0.js +3 -6
- package/descriptionList/DescriptionDetail.js +5 -10
- package/descriptionList/DescriptionList.js +5 -10
- package/descriptionList/DescriptionTerm.js +2 -9
- package/descriptionList/index.js +3 -7
- package/divider/Divider.js +9 -12
- package/divider/index.js +1 -3
- package/dropdown/Dropdown.js +28 -65
- package/dropdown/DropdownButtonOption.js +2 -9
- package/dropdown/DropdownContent.js +33 -64
- package/dropdown/DropdownDivOption.js +2 -9
- package/dropdown/DropdownItem.js +10 -16
- package/dropdown/DropdownLinkOption.js +2 -9
- package/dropdown/DropdownToggle.js +18 -38
- package/dropdown/index.js +6 -17
- package/dropdown/subComponent/DropdownContext.js +2 -5
- package/dropzone/FileDropzone.js +148 -302
- package/dropzone/ImageDropzone.js +96 -171
- package/dropzone/index.js +2 -5
- package/dropzone/subComponent/Message.js +7 -14
- package/figure/IconFigure.js +9 -16
- package/figure/ImageFigure.js +11 -17
- package/figure/index.js +2 -5
- package/file/HiddenFileInput.js +5 -14
- package/file/index.js +1 -3
- package/form/Checkbox.js +34 -43
- package/form/FormItem.js +2 -9
- package/form/Input.js +13 -15
- package/form/Label.js +10 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +14 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/index.js +9 -19
- package/grid/Column.js +17 -17
- package/grid/Grid.js +13 -14
- package/grid/index.js +2 -5
- package/heading/Heading1.js +5 -10
- package/heading/Heading2.js +9 -12
- package/heading/Heading3.js +21 -18
- package/heading/index.js +3 -7
- package/helmet/Helmet.js +6 -9
- package/helmet/index.js +2 -5
- package/iconbox/ApplicationIconBox.js +25 -31
- package/iconbox/IconBox.js +11 -24
- package/iconbox/IconBoxV2.js +14 -26
- package/iconbox/index.js +3 -7
- package/iconbox/subComponent/IconBoxFigure.js +25 -20
- package/iconbox/subComponent/IconBoxImage.js +15 -18
- package/image/ImageFluid.js +2 -10
- package/image/UploadImage.js +65 -113
- package/image/index.js +2 -5
- package/index.js +44 -130
- package/jsoneditor/JsonEditor.js +10 -32
- package/jsoneditor/index.js +1 -3
- package/keyframe/Pulse.js +2 -7
- package/keyframe/Spin.js +2 -7
- package/link/LinkSpan.js +22 -35
- package/link/index.js +1 -3
- package/map/GoogleMap.js +122 -175
- package/map/GoogleReverseGeolocation.js +79 -186
- package/map/LeafletMap.js +78 -132
- package/map/LeafletReverseGeolocation.js +49 -121
- package/map/index.js +4 -9
- package/map/subComponent/BasicLeafletMap.js +8 -14
- package/map/subComponent/GoogleMapContainer.js +5 -10
- package/map/subComponent/GoogleMapPopup.js +66 -123
- package/map/subComponent/GoogleMapWrapper.js +13 -32
- package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
- package/map/subComponent/LeafletDrawControl.js +47 -84
- package/map/subComponent/LeafletMapContainer.js +5 -10
- package/map/subComponent/MapSearchBoxControl.js +24 -70
- package/modal/StateModal.js +41 -100
- package/modal/TitleModal.js +89 -190
- package/modal/index.js +2 -5
- package/package.json +1 -1
- package/paginate/Paginate.js +40 -54
- package/paginate/index.js +1 -3
- package/popover/Popover.js +39 -87
- package/popover/index.js +1 -3
- package/qrcode/QRCode.js +10 -23
- package/qrcode/QRCodeContainter.js +8 -16
- package/qrcode/index.js +2 -5
- package/ribbon/Ribbon.js +4 -15
- package/ribbon/index.js +1 -3
- package/section/Section.js +57 -39
- package/section/SectionBody.js +15 -22
- package/section/SectionHeader.js +27 -27
- package/section/SectionToolbar.js +2 -9
- package/section/SectionToolbarItem.js +2 -9
- package/section/index.js +5 -11
- package/select/InputSelect.js +103 -215
- package/select/Select.js +204 -362
- package/select/index.js +2 -5
- package/select/subComponent/ListBox.js +9 -12
- package/select/subComponent/Option.js +8 -16
- package/select/subComponent/OptionGroup.js +2 -9
- package/select/subComponent/Options.js +5 -11
- package/select/subComponent/SearchBox.js +9 -29
- package/select/subComponent/SelectedMultiple.js +8 -16
- package/select/subComponent/SelectedSingle.js +2 -9
- package/styles/GlobalStyle.js +169 -91
- package/styles/config/breakpoint.style.js +2 -3
- package/styles/config/header.style.js +2 -3
- package/styles/config/sidebar.style.js +2 -3
- package/styles/index.js +2 -5
- package/styles/mixin/backgroundColor.js +17 -14
- package/styles/mixin/borderColor.js +17 -14
- package/styles/mixin/color.js +17 -14
- package/styles/mixin/colorOnBackground.js +17 -14
- package/styles/mixin/inputPlaceholder.js +3 -9
- package/styles/mixin/media.js +3 -11
- package/styles/mixin/rounded.js +13 -12
- package/styles/mixin/scrollbar.js +7 -13
- package/styles/theme/dark.theme.js +20 -20
- package/styles/theme/light.theme.js +20 -20
- package/styles/theme/white.theme.js +20 -20
- package/styles/themes.js +2 -8
- package/table/GridTable.js +105 -143
- package/table/ImageBox.js +8 -18
- package/table/PermissionTable.js +25 -25
- package/table/Table.js +137 -153
- package/table/__mock__/columns.js +2 -3
- package/table/__mock__/data.js +2 -3
- package/table/hooks/index.js +2 -5
- package/table/hooks/useCalculateDataRange.js +9 -36
- package/table/hooks/useGenerateSort.js +6 -17
- package/table/index.js +4 -9
- package/table/subComponent/BaseTableHeadCell.js +15 -21
- package/table/subComponent/GridTableFooter.js +5 -10
- package/table/subComponent/GridTableHeadCell.js +5 -10
- package/table/subComponent/Resizer.js +17 -44
- package/table/subComponent/TableFooter.js +5 -10
- package/table/subComponent/TableFooterInfo.js +2 -9
- package/table/subComponent/TableFooterPager.js +5 -12
- package/table/subComponent/TableHeadCell.js +2 -9
- package/table/subComponent/TableSort.js +13 -19
- package/tagify/TagifyStyle.js +2 -9
- package/tagify/Tags.js +15 -37
- package/tagify/index.js +2 -5
- package/text/Paragraph.js +25 -20
- package/text/index.js +1 -3
- package/timeline/Timeline.js +28 -37
- package/timeline/index.js +1 -3
- package/toast/CustomToastContainer.js +2 -9
- package/toast/MessageContainer.js +9 -18
- package/toast/index.js +3 -8
- package/toast/show.js +18 -28
- package/tooltip/Tooltip.js +48 -97
- package/tooltip/index.js +1 -3
- package/wizard/Wizard.js +63 -133
- package/wizard/index.js +1 -3
package/table/Table.js
CHANGED
|
@@ -1,138 +1,114 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = require("react");
|
|
11
|
-
|
|
12
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
13
|
-
|
|
14
9
|
var _media = _interopRequireDefault(require("../styles/mixin/media"));
|
|
15
|
-
|
|
16
10
|
var _hooks = require("./hooks");
|
|
17
|
-
|
|
18
11
|
var _TableHeadCell = _interopRequireDefault(require("./subComponent/TableHeadCell"));
|
|
19
|
-
|
|
20
12
|
var _TableFooter = _interopRequireDefault(require("./subComponent/TableFooter"));
|
|
21
|
-
|
|
22
13
|
var _TableFooterInfo = _interopRequireDefault(require("./subComponent/TableFooterInfo"));
|
|
23
|
-
|
|
24
14
|
var _TableFooterPager = _interopRequireDefault(require("./subComponent/TableFooterPager"));
|
|
25
|
-
|
|
26
15
|
var _Paginate = _interopRequireDefault(require("../paginate/Paginate"));
|
|
27
|
-
|
|
28
16
|
var _Select = _interopRequireDefault(require("../select/Select"));
|
|
29
|
-
|
|
30
17
|
var _Popover = _interopRequireDefault(require("../popover/Popover"));
|
|
31
|
-
|
|
32
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
|
-
|
|
34
19
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
35
|
-
|
|
36
|
-
var _excluded = ["title", "fieldName", "render", "custom"];
|
|
37
|
-
|
|
38
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
|
-
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
44
23
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
popoverContainer = _ref.popoverContainer,
|
|
74
|
-
_ref$centerFooter = _ref.centerFooter,
|
|
75
|
-
centerFooter = _ref$centerFooter === void 0 ? false : _ref$centerFooter;
|
|
76
|
-
var tableRef = (0, _react.useRef)(null);
|
|
77
|
-
|
|
78
|
-
var _useCalculateDataRang = (0, _hooks.useCalculateDataRange)(currentPage, limit, total),
|
|
79
|
-
start = _useCalculateDataRang.start,
|
|
80
|
-
end = _useCalculateDataRang.end;
|
|
81
|
-
|
|
82
|
-
var texts = (0, _react.useMemo)(function () {
|
|
83
|
-
var defaultTexts = {
|
|
24
|
+
const Table = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
columns,
|
|
27
|
+
data,
|
|
28
|
+
currentPage,
|
|
29
|
+
limit,
|
|
30
|
+
total,
|
|
31
|
+
onPageChange,
|
|
32
|
+
onLimitChange,
|
|
33
|
+
sortColumn,
|
|
34
|
+
sortType,
|
|
35
|
+
onSortChange,
|
|
36
|
+
select,
|
|
37
|
+
selected,
|
|
38
|
+
onRowClick,
|
|
39
|
+
backgroundReverse,
|
|
40
|
+
translation,
|
|
41
|
+
beforeCreateRow,
|
|
42
|
+
popoverContainer,
|
|
43
|
+
centerFooter = false
|
|
44
|
+
} = _ref;
|
|
45
|
+
const tableRef = (0, _react.useRef)(null);
|
|
46
|
+
const {
|
|
47
|
+
start,
|
|
48
|
+
end
|
|
49
|
+
} = (0, _hooks.useCalculateDataRange)(currentPage, limit, total);
|
|
50
|
+
const texts = (0, _react.useMemo)(() => {
|
|
51
|
+
const defaultTexts = {
|
|
84
52
|
info: 'Showing _START_ to _END_ of _TOTAL_ entries',
|
|
85
53
|
empty: 'No data available in table'
|
|
86
54
|
};
|
|
87
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
...defaultTexts,
|
|
57
|
+
...translation
|
|
58
|
+
};
|
|
88
59
|
}, [translation]);
|
|
89
|
-
|
|
60
|
+
const handleSortChange = (0, _react.useCallback)(columnName => {
|
|
90
61
|
if (onSortChange) {
|
|
91
62
|
onSortChange(columnName);
|
|
92
63
|
}
|
|
93
64
|
}, [onSortChange]);
|
|
94
|
-
|
|
65
|
+
const handleRowClick = (0, _react.useCallback)((event, rowData) => {
|
|
95
66
|
if (onRowClick) {
|
|
96
67
|
onRowClick(event, rowData);
|
|
97
68
|
}
|
|
98
69
|
}, [onRowClick]);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
70
|
+
const showFullValue = (0, _react.useCallback)(event => {
|
|
71
|
+
let {
|
|
72
|
+
id
|
|
73
|
+
} = event.target;
|
|
102
74
|
if (!id) {
|
|
103
|
-
|
|
75
|
+
({
|
|
76
|
+
id
|
|
77
|
+
} = event.currentTarget);
|
|
104
78
|
event.target.id = id;
|
|
105
79
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
80
|
+
const {
|
|
81
|
+
offsetWidth,
|
|
82
|
+
scrollWidth,
|
|
83
|
+
innerText
|
|
84
|
+
} = event.target;
|
|
112
85
|
if (scrollWidth >= offsetWidth && innerText) {
|
|
113
86
|
event.stopPropagation();
|
|
114
87
|
(0, _Popover.default)({
|
|
115
|
-
id
|
|
88
|
+
id,
|
|
116
89
|
container: popoverContainer,
|
|
117
90
|
target: event.target,
|
|
118
91
|
content: innerText,
|
|
119
92
|
boundary: tableRef.current
|
|
120
93
|
});
|
|
121
94
|
}
|
|
122
|
-
}, [popoverContainer]);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
95
|
+
}, [popoverContainer]);
|
|
96
|
+
|
|
97
|
+
// generate sort icon area
|
|
98
|
+
const generateSort = (0, _hooks.useGenerateSort)(sortColumn, sortType);
|
|
99
|
+
const tableHeads = (0, _react.useMemo)(() => {
|
|
100
|
+
return columns.map((column, index) => {
|
|
101
|
+
const {
|
|
102
|
+
title,
|
|
103
|
+
fieldName,
|
|
104
|
+
width,
|
|
105
|
+
sortable,
|
|
106
|
+
align
|
|
107
|
+
} = column;
|
|
132
108
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TableHeadCell.default, {
|
|
133
109
|
width: width,
|
|
134
110
|
sortable: sortable,
|
|
135
|
-
onClick:
|
|
111
|
+
onClick: () => {
|
|
136
112
|
sortable && handleSortChange(fieldName);
|
|
137
113
|
},
|
|
138
114
|
align: align,
|
|
@@ -146,52 +122,49 @@ var Table = function Table(_ref) {
|
|
|
146
122
|
}, "TH".concat(index));
|
|
147
123
|
});
|
|
148
124
|
}, [columns, handleSortChange, generateSort, showFullValue]);
|
|
149
|
-
|
|
125
|
+
const tableRows = (0, _react.useMemo)(() => {
|
|
150
126
|
if (data.length === 0) {
|
|
151
127
|
return null;
|
|
152
128
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var rowConfig = {};
|
|
161
|
-
|
|
129
|
+
const {
|
|
130
|
+
matcher,
|
|
131
|
+
type
|
|
132
|
+
} = select || {};
|
|
133
|
+
return data.map((row, rowIndex) => {
|
|
134
|
+
let active = false;
|
|
135
|
+
let rowConfig = {};
|
|
162
136
|
if (beforeCreateRow) {
|
|
163
137
|
rowConfig = beforeCreateRow(row) || {};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// row data cell
|
|
141
|
+
const tds = columns.map((column, columnIndex) => {
|
|
142
|
+
const {
|
|
143
|
+
title,
|
|
144
|
+
fieldName,
|
|
145
|
+
render,
|
|
146
|
+
custom,
|
|
147
|
+
...props
|
|
148
|
+
} = column;
|
|
149
|
+
const key = rowIndex + columnIndex.toString();
|
|
150
|
+
let value = row[fieldName];
|
|
151
|
+
|
|
152
|
+
// 如果有matcher,比對當前 column 的 fieldName 是不是等於 matcher
|
|
177
153
|
if (matcher && fieldName === matcher) {
|
|
178
154
|
if (type === 'single' && selected === value) {
|
|
179
155
|
active = true;
|
|
180
156
|
}
|
|
181
|
-
|
|
182
157
|
if (type === 'multiple' && selected.includes(value)) {
|
|
183
158
|
active = true;
|
|
184
159
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
160
|
+
}
|
|
187
161
|
|
|
162
|
+
// convert to an empty string
|
|
188
163
|
if (value === null || value === undefined) {
|
|
189
164
|
value = '';
|
|
190
165
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
var renderedData = null;
|
|
194
|
-
|
|
166
|
+
let isCustom = false;
|
|
167
|
+
let renderedData = null;
|
|
195
168
|
if (custom && render) {
|
|
196
169
|
// call render function to get custom data(fully)
|
|
197
170
|
isCustom = true;
|
|
@@ -204,28 +177,27 @@ var Table = function Table(_ref) {
|
|
|
204
177
|
children: render ? render(value, row) : String(value)
|
|
205
178
|
});
|
|
206
179
|
}
|
|
207
|
-
|
|
208
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TableDataCell, _objectSpread(_objectSpread({
|
|
180
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TableDataCell, {
|
|
209
181
|
"data-label": title,
|
|
210
182
|
backgroundReverse: backgroundReverse,
|
|
211
|
-
custom: isCustom
|
|
212
|
-
|
|
183
|
+
custom: isCustom,
|
|
184
|
+
...props,
|
|
213
185
|
children: renderedData
|
|
214
|
-
}
|
|
186
|
+
}, columnIndex);
|
|
215
187
|
});
|
|
216
188
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BodyTR, {
|
|
217
189
|
clickable: onRowClick,
|
|
218
190
|
active: active,
|
|
219
191
|
primary: rowConfig.primary,
|
|
220
192
|
backgroundReverse: backgroundReverse,
|
|
221
|
-
onClick:
|
|
193
|
+
onClick: event => {
|
|
222
194
|
handleRowClick(event, row);
|
|
223
195
|
},
|
|
224
196
|
children: tds
|
|
225
197
|
}, rowIndex);
|
|
226
198
|
});
|
|
227
199
|
}, [backgroundReverse, beforeCreateRow, columns, data, handleRowClick, onRowClick, select, selected, showFullValue]);
|
|
228
|
-
|
|
200
|
+
const generateEmptyMessage = (0, _react.useCallback)(() => {
|
|
229
201
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BodyTR, {
|
|
230
202
|
noData: true,
|
|
231
203
|
backgroundReverse: backgroundReverse,
|
|
@@ -286,43 +258,55 @@ var Table = function Table(_ref) {
|
|
|
286
258
|
})]
|
|
287
259
|
});
|
|
288
260
|
};
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
primary = _ref3.primary;
|
|
261
|
+
const ResponsiveTable = _styledComponents.default.table(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n border-collapse: separate;\n margin-top: calc(var(--spacing-s) * -1);\n border-spacing: 0 var(--spacing-s);\n color: var(--font-on-background);\n table-layout: fixed;\n"])));
|
|
262
|
+
const TableHead = _styledComponents.default.thead(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n"])), _media.default.mobile(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
263
|
+
const BodyTR = _styledComponents.default.tr(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n &:hover {\n > td {\n border-color: var(--color-primary);\n }\n }\n\n ", "\n\n ", "\n \n ", "\n"])), _ref2 => {
|
|
264
|
+
let {
|
|
265
|
+
active,
|
|
266
|
+
primary
|
|
267
|
+
} = _ref2;
|
|
297
268
|
return (active || primary) && (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n > td {\n background: var(--color-background3);\n }\n "])));
|
|
298
|
-
},
|
|
299
|
-
|
|
269
|
+
}, _ref3 => {
|
|
270
|
+
let {
|
|
271
|
+
clickable
|
|
272
|
+
} = _ref3;
|
|
300
273
|
return clickable && 'pointer: cursor;';
|
|
301
|
-
}, _media.default.mobile(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n position: relative;\n transition: .3s;\n display: block;\n margin-bottom: 0.75rem;\n padding: var(--spacing-xs) var(--spacing-s);\n background: var(\n --color-background", "\n );\n border-radius: var(--border-radius);\n transition: .3s;\n border: 1px solid transparent;\n\n &:hover {\n border: var(--border-width) solid var(--color-primary);\n }\n\n ", "\n\n ", "\n "])),
|
|
302
|
-
|
|
274
|
+
}, _media.default.mobile(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n position: relative;\n transition: .3s;\n display: block;\n margin-bottom: 0.75rem;\n padding: var(--spacing-xs) var(--spacing-s);\n background: var(\n --color-background", "\n );\n border-radius: var(--border-radius);\n transition: .3s;\n border: 1px solid transparent;\n\n &:hover {\n border: var(--border-width) solid var(--color-primary);\n }\n\n ", "\n\n ", "\n "])), _ref4 => {
|
|
275
|
+
let {
|
|
276
|
+
backgroundReverse
|
|
277
|
+
} = _ref4;
|
|
303
278
|
return backgroundReverse ? 1 : 2;
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
|
|
279
|
+
}, _ref5 => {
|
|
280
|
+
let {
|
|
281
|
+
active,
|
|
282
|
+
primary
|
|
283
|
+
} = _ref5;
|
|
307
284
|
return (active || primary) && (0, _styledComponents.css)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n background: var(--color-background3);\n "])));
|
|
308
|
-
},
|
|
309
|
-
|
|
285
|
+
}, _ref6 => {
|
|
286
|
+
let {
|
|
287
|
+
noData
|
|
288
|
+
} = _ref6;
|
|
310
289
|
return noData && (0, _styledComponents.css)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n height: 168px;\n\n > td {\n &:first-child:before {\n display: none;\n }\n }\n "])));
|
|
311
290
|
}));
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
291
|
+
const TableDataCell = _styledComponents.default.td(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n height: 48px;\n background: ", ";\n padding: 0 var(--spacing-xs);\n max-width: 0px;\n text-align: ", ";\n vertical-align: middle;\n border-top: var(--border-width) solid transparent;\n border-bottom: var(--border-width) solid transparent;\n transition: border-color 0.3s;\n\n &:first-child {\n border-left: var(--border-width) solid transparent;\n border-top-left-radius: var(--border-radius-l);\n border-bottom-left-radius: var(--border-radius-l);\n padding-left: var(--spacing);\n }\n\n &:last-child {\n border-right: var(--border-width) solid transparent;\n border-top-right-radius: var(--border-radius-l);\n border-bottom-right-radius: var(--border-radius-l);\n padding-right: var(--spacing);\n }\n\n > span {\n display: inline-block;\n width: 100%;\n overflow: hidden;\n white-space: pre;\n text-overflow: ellipsis;\n }\n\n ", "\n\n ", "\n"])), _ref7 => {
|
|
292
|
+
let {
|
|
293
|
+
backgroundReverse
|
|
294
|
+
} = _ref7;
|
|
315
295
|
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
316
|
-
},
|
|
317
|
-
|
|
296
|
+
}, _ref8 => {
|
|
297
|
+
let {
|
|
298
|
+
center
|
|
299
|
+
} = _ref8;
|
|
318
300
|
return center ? 'center' : 'left';
|
|
319
|
-
},
|
|
320
|
-
|
|
301
|
+
}, _ref9 => {
|
|
302
|
+
let {
|
|
303
|
+
noData
|
|
304
|
+
} = _ref9;
|
|
321
305
|
return noData && (0, _styledComponents.css)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 20px 0;\n "])));
|
|
322
|
-
}, _media.default.mobile(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n height: auto;\n margin-bottom: var(--spacing-xs);\n background: transparent !important;\n border: none !important;\n min-width: 100%;\n \n &:first-child {\n padding: var(--spacing-xs) 0 0 var(--spacing-xs);\n }\n\n &:last-child {\n padding-right: var(--spacing-xs);\n }\n\n &:before {\n content: attr(data-label) \": \";\n font-weight: bold;\n padding-right: var(--spacing-xs);\n }\n\n > span {\n flex: 1;\n }\n \n ", "\n "])),
|
|
323
|
-
|
|
306
|
+
}, _media.default.mobile(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n height: auto;\n margin-bottom: var(--spacing-xs);\n background: transparent !important;\n border: none !important;\n min-width: 100%;\n \n &:first-child {\n padding: var(--spacing-xs) 0 0 var(--spacing-xs);\n }\n\n &:last-child {\n padding-right: var(--spacing-xs);\n }\n\n &:before {\n content: attr(data-label) \": \";\n font-weight: bold;\n padding-right: var(--spacing-xs);\n }\n\n > span {\n flex: 1;\n }\n \n ", "\n "])), _ref10 => {
|
|
307
|
+
let {
|
|
308
|
+
custom
|
|
309
|
+
} = _ref10;
|
|
324
310
|
return custom && (0, _styledComponents.css)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n &:last-child:before {\n display: none;\n }\n\n &:last-child {\n padding: 0;\n position: absolute;\n right: 0.75rem;\n top: var(--spacing-xs);\n justify-content: flex-end;\n }\n "])));
|
|
325
311
|
}));
|
|
326
|
-
|
|
327
|
-
var _default = Table;
|
|
328
|
-
exports.default = _default;
|
|
312
|
+
var _default = exports.default = Table;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
7
|
+
const columns = [{
|
|
8
8
|
title: 'Name',
|
|
9
9
|
fieldName: 'name',
|
|
10
10
|
sortable: true,
|
|
@@ -25,5 +25,4 @@ var columns = [{
|
|
|
25
25
|
sortable: false,
|
|
26
26
|
width: '400px'
|
|
27
27
|
}];
|
|
28
|
-
var _default = columns;
|
|
29
|
-
exports.default = _default;
|
|
28
|
+
var _default = exports.default = columns;
|
package/table/__mock__/data.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
7
|
+
const data = [{
|
|
8
8
|
logoUrl: 'http://localhost:10084/cashub/images/2022/04/20/9qxPfgv13Vd7HnDJVmFLOFocO4mb2CFMmQfXzo2L.png',
|
|
9
9
|
name: 'User A',
|
|
10
10
|
contact: 'Admin A',
|
|
@@ -275,5 +275,4 @@ var data = [{
|
|
|
275
275
|
telephone: '0912345678',
|
|
276
276
|
description: ''
|
|
277
277
|
}];
|
|
278
|
-
var _default = data;
|
|
279
|
-
exports.default = _default;
|
|
278
|
+
var _default = exports.default = data;
|
package/table/hooks/index.js
CHANGED
|
@@ -5,19 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "useCalculateDataRange", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _useCalculateDataRange.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "useGenerateSort", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _useGenerateSort.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
|
|
19
18
|
var _useCalculateDataRange = _interopRequireDefault(require("./useCalculateDataRange"));
|
|
20
|
-
|
|
21
19
|
var _useGenerateSort = _interopRequireDefault(require("./useGenerateSort"));
|
|
22
|
-
|
|
23
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -4,52 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
|
|
22
|
-
var useCalculateDataRange = function useCalculateDataRange(page, limit, total) {
|
|
23
|
-
var _useState = (0, _react.useState)(0),
|
|
24
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
-
start = _useState2[0],
|
|
26
|
-
setStart = _useState2[1];
|
|
27
|
-
|
|
28
|
-
var _useState3 = (0, _react.useState)(0),
|
|
29
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
-
end = _useState4[0],
|
|
31
|
-
setEnd = _useState4[1];
|
|
32
|
-
|
|
33
|
-
(0, _react.useEffect)(function () {
|
|
34
|
-
var start = 0;
|
|
35
|
-
var end = page * limit;
|
|
36
|
-
|
|
8
|
+
const useCalculateDataRange = (page, limit, total) => {
|
|
9
|
+
const [start, setStart] = (0, _react.useState)(0);
|
|
10
|
+
const [end, setEnd] = (0, _react.useState)(0);
|
|
11
|
+
(0, _react.useEffect)(() => {
|
|
12
|
+
let start = 0;
|
|
13
|
+
let end = page * limit;
|
|
37
14
|
if (total !== 0) {
|
|
38
15
|
start = (page - 1) * limit + 1;
|
|
39
16
|
}
|
|
40
|
-
|
|
41
17
|
if (end > total) {
|
|
42
18
|
end = total;
|
|
43
19
|
}
|
|
44
|
-
|
|
45
20
|
setStart(start);
|
|
46
21
|
setEnd(end);
|
|
47
22
|
}, [page, limit, total]);
|
|
48
23
|
return {
|
|
49
|
-
start
|
|
50
|
-
end
|
|
24
|
+
start,
|
|
25
|
+
end
|
|
51
26
|
};
|
|
52
27
|
};
|
|
53
|
-
|
|
54
|
-
var _default = useCalculateDataRange;
|
|
55
|
-
exports.default = _default;
|
|
28
|
+
var _default = exports.default = useCalculateDataRange;
|
|
@@ -4,28 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _TableSort = _interopRequireDefault(require("../subComponent/TableSort"));
|
|
11
|
-
|
|
12
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var isActiveDesc = false;
|
|
20
|
-
|
|
11
|
+
const useGenerateSort = (sortColumn, sortType) => {
|
|
12
|
+
return (0, _react.useCallback)(fieldName => {
|
|
13
|
+
let isActiveAsc = false;
|
|
14
|
+
let isActiveDesc = false;
|
|
21
15
|
if (Array.isArray(sortColumn) && Array.isArray(sortType)) {
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const sortColumnIndex = sortColumn.indexOf(fieldName);
|
|
24
17
|
if (sortColumnIndex !== -1) {
|
|
25
18
|
if (sortType[sortColumnIndex] === 'asc') {
|
|
26
19
|
isActiveAsc = true;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
if (sortType[sortColumnIndex] === 'desc') {
|
|
30
22
|
isActiveDesc = true;
|
|
31
23
|
}
|
|
@@ -35,7 +27,6 @@ var useGenerateSort = function useGenerateSort(sortColumn, sortType) {
|
|
|
35
27
|
} else if (fieldName === sortColumn && sortType === 'desc') {
|
|
36
28
|
isActiveDesc = true;
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_TableSort.default, {
|
|
40
31
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TableSort.default.UpIcon, {
|
|
41
32
|
$active: isActiveAsc
|
|
@@ -45,6 +36,4 @@ var useGenerateSort = function useGenerateSort(sortColumn, sortType) {
|
|
|
45
36
|
});
|
|
46
37
|
}, [sortColumn, sortType]);
|
|
47
38
|
};
|
|
48
|
-
|
|
49
|
-
var _default = useGenerateSort;
|
|
50
|
-
exports.default = _default;
|
|
39
|
+
var _default = exports.default = useGenerateSort;
|
package/table/index.js
CHANGED
|
@@ -5,35 +5,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "GridTable", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _GridTable.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "ImageBox", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _ImageBox.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "PermissionTable", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _PermissionTable.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "Table", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _Table.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
|
|
31
30
|
var _GridTable = _interopRequireDefault(require("./GridTable"));
|
|
32
|
-
|
|
33
31
|
var _Table = _interopRequireDefault(require("./Table"));
|
|
34
|
-
|
|
35
32
|
var _PermissionTable = _interopRequireDefault(require("./PermissionTable"));
|
|
36
|
-
|
|
37
33
|
var _ImageBox = _interopRequireDefault(require("./ImageBox"));
|
|
38
|
-
|
|
39
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|