@unbxd-ui/unbxd-react-components 0.2.145 → 0.2.146
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/README.md +17 -1
- package/components/Accordian/Accordian.js +1 -2
- package/components/Accordian/Accordian.stories.js +140 -117
- package/components/Button/Button.stories.js +167 -61
- package/components/Button/DropdownButton.js +1 -2
- package/components/Button/index.js +1 -2
- package/components/DataLoader/DataLoader.js +1 -2
- package/components/DataLoader/DataLoader.stories.js +239 -53
- package/components/Form/Checkbox.js +5 -4
- package/components/Form/DragDropFileUploader.js +1 -2
- package/components/Form/Dropdown.js +1 -2
- package/components/Form/FileUploader.js +1 -2
- package/components/Form/Form.js +1 -2
- package/components/Form/Input.js +1 -2
- package/components/Form/RadioList.js +1 -2
- package/components/Form/RangeSlider.js +1 -2
- package/components/Form/SearchableDropdown.js +563 -0
- package/components/Form/ServerPaginatedDDList.js +17 -11
- package/components/Form/Textarea.js +1 -2
- package/components/Form/Toggle.js +1 -2
- package/components/Form/formCore.css +1 -1
- package/components/Form/formTheme.css +1 -1
- package/components/Form/index.js +7 -0
- package/components/Form/stories/Checkbox.stories.js +138 -39
- package/components/Form/stories/Dropdown.stories.js +322 -91
- package/components/Form/stories/FileUploader.stories.js +177 -18
- package/components/Form/stories/Input.stories.js +115 -0
- package/components/Form/stories/RangeSlider.stories.js +161 -63
- package/components/Form/stories/SearchableDropdown.stories.js +189 -0
- package/components/Form/stories/ServerPaginatedDropdown.stories.js +365 -0
- package/components/Form/stories/Textarea.stories.js +112 -33
- package/components/Form/stories/Toggle.stories.js +192 -13
- package/components/Form/variables.css +0 -0
- package/components/InlineModal/InlineModal.js +1 -2
- package/components/InlineModal/InlineModal.stories.js +239 -45
- package/components/InlineModal/index.js +1 -2
- package/components/InlineModal/inlineModalCore.css +1 -1
- package/components/List/List.stories.js +238 -0
- package/components/Modal/Modal.js +1 -2
- package/components/Modal/Modal.stories.js +256 -37
- package/components/Modal/modalCore.css +1 -1
- package/components/NotificationComponent/NotificationComponent.js +1 -2
- package/components/NotificationComponent/NotificationComponent.stories.js +170 -18
- package/components/PageLoader/PageLoader.js +84 -0
- package/components/PageLoader/PageLoader.stories.js +276 -0
- package/components/PageLoader/index.js +9 -0
- package/components/PageLoader/pageLoaderCore.css +1 -0
- package/components/ProgressBar/ProgressBar.css +0 -0
- package/components/ProgressBar/ProgressBar.stories.js +202 -9
- package/components/ProgressBar/progressBarCore.css +1 -1
- package/components/Table/BaseTable.js +84 -354
- package/components/Table/Table.js +6 -359
- package/components/Table/Table.stories.js +2109 -150
- package/components/Table/TableChild.js +383 -0
- package/components/Table/TableConstants.js +15 -0
- package/components/Table/hooks/usePrevious.js +14 -0
- package/components/Table/index.js +13 -0
- package/components/Table/tableCore.css +1 -1
- package/components/TableOld/BaseTable.js +373 -0
- package/components/TableOld/PaginationComponent.js +86 -0
- package/components/TableOld/TableOld.js +367 -0
- package/components/TableOld/index.js +15 -0
- package/components/TabsComponent/TabsComponent.js +1 -2
- package/components/TabsComponent/TabsComponent.stories.js +290 -52
- package/components/ToastNotification/ToastNotificationWrapper.js +212 -0
- package/components/ToastNotification/ToastNotificationWrapper.stories.js +554 -0
- package/components/ToastNotification/index.js +40 -0
- package/components/ToastNotification/toastNotificationCore.css +1 -0
- package/components/Tooltip/Tooltip.js +221 -83
- package/components/Tooltip/Tooltip.stories.js +379 -14
- package/components/Tooltip/tooltipCore.css +1 -1
- package/components/Tooltip/tooltipTheme.css +1 -1
- package/components/core.css +2 -3
- package/components/core.scss +17 -0
- package/components/index.js +58 -2
- package/components/theme.css +2 -3
- package/core/dataLoader.js +5 -2
- package/index.js +54 -0
- package/package.json +31 -20
- package/components/Button/DropdownButton.stories.js +0 -49
- package/components/Form/stories/DragDropFileUploader.stories.js +0 -25
- package/components/Form/stories/FormDefault.stories.js +0 -115
- package/components/Form/stories/RadioList.stories.js +0 -53
- package/components/Form/stories/TextInput.stories.js +0 -76
- package/components/Form/stories/form.stories.js +0 -233
- package/components/List/list.stories.js +0 -35
- package/core/dataLoader.stories.js +0 -119
|
@@ -1,368 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports["default"] =
|
|
7
|
+
exports["default"] = void 0;
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
9
|
-
var _BaseTable = _interopRequireDefault(require("./BaseTable"));
|
|
10
|
-
var _DataLoader = _interopRequireDefault(require("../DataLoader"));
|
|
11
|
-
var _PaginationComponent = _interopRequireDefault(require("./PaginationComponent"));
|
|
12
|
-
var _utils = _interopRequireDefault(require("../../core/utils"));
|
|
13
|
-
var _dataLoader = _interopRequireDefault(require("../../core/dataLoader"));
|
|
14
|
-
var _excluded = ["className", "wrapperClassName", "records", "columnConfigs", "idAttribute", "searchBy", "getRequestKeys", "showPaginateBar", "paginationPosition", "paginationType", "paginationBar", "requestId", "pageNoKey", "perPageKey", "pageSizeList", "isExpandableTable", "ExpandedRowComponent", "responseFormatter", "noDataComponent", "omitProps", "getUrlParams", "getRequestParams", "checkboxConfig", "tbodyClassName", "refreshFeature", "refreshIconClass", "spinnerIconClass", "onRefreshCB"];
|
|
9
|
+
var _TableChild = _interopRequireDefault(require("./TableChild"));
|
|
15
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
24
|
-
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."); }
|
|
25
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
26
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
27
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
28
|
-
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."); }
|
|
29
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
30
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
31
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
32
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
33
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
34
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
35
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
36
|
-
var getPageRecords = function getPageRecords() {
|
|
37
|
-
var records = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
38
|
-
var pageConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
|
-
var pagIndex = _utils["default"].getPagIndex(pageConfig);
|
|
40
|
-
var start = pagIndex.start,
|
|
41
|
-
end = pagIndex.end;
|
|
42
|
-
return records.slice(start, end);
|
|
43
|
-
};
|
|
44
|
-
var sortNumbersASC = function sortNumbersASC(a, b) {
|
|
45
|
-
return a - b;
|
|
46
|
-
};
|
|
47
|
-
var sortNumbersDSC = function sortNumbersDSC(a, b) {
|
|
48
|
-
return b - a;
|
|
49
|
-
};
|
|
50
|
-
var sortAlphaASC = function sortAlphaASC(a, b) {
|
|
51
|
-
return a < b ? -1 : 1;
|
|
52
|
-
};
|
|
53
|
-
var sortAlphaDSC = function sortAlphaDSC(a, b) {
|
|
54
|
-
return b < a ? -1 : 1;
|
|
55
|
-
};
|
|
56
|
-
var getFilteredRecords = function getFilteredRecords(_ref) {
|
|
57
|
-
var _ref$records = _ref.records,
|
|
58
|
-
records = _ref$records === void 0 ? [] : _ref$records,
|
|
59
|
-
searchBy = _ref.searchBy,
|
|
60
|
-
searchByKey = _ref.searchByKey,
|
|
61
|
-
sortByConfig = _ref.sortByConfig;
|
|
62
|
-
var filteredRecords = records;
|
|
63
|
-
if (searchBy) {
|
|
64
|
-
searchBy = searchBy.toLowerCase();
|
|
65
|
-
filteredRecords = records.filter(function (obj) {
|
|
66
|
-
var val = (obj[searchByKey] ? obj[searchByKey] : "").toLowerCase();
|
|
67
|
-
return val.indexOf(searchBy) !== -1;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (_typeof(sortByConfig) === "object" && !_utils["default"].isObjectEmpty(sortByConfig)) {
|
|
71
|
-
var sortBy = sortByConfig.sortBy,
|
|
72
|
-
sortOrder = sortByConfig.sortOrder,
|
|
73
|
-
columnConfig = sortByConfig.columnConfig;
|
|
74
|
-
var valueFormatter = columnConfig.valueFormatter;
|
|
75
|
-
filteredRecords = records.slice().sort(function (obj1, obj2) {
|
|
76
|
-
var rowValue1 = obj1[sortBy];
|
|
77
|
-
var rowValue2 = obj2[sortBy];
|
|
78
|
-
var sortValue1 = typeof valueFormatter === "function" ? valueFormatter({
|
|
79
|
-
value: rowValue1,
|
|
80
|
-
record: obj1
|
|
81
|
-
}) : rowValue1;
|
|
82
|
-
var sortValue2 = typeof valueFormatter === "function" ? valueFormatter({
|
|
83
|
-
value: rowValue2,
|
|
84
|
-
record: obj2
|
|
85
|
-
}) : rowValue2;
|
|
86
|
-
if (typeof sortValue === "number") {
|
|
87
|
-
return sortOrder === "ASC" ? sortNumbersASC(sortValue1, sortValue2) : sortNumbersDSC(sortValue1, sortValue2);
|
|
88
|
-
} else {
|
|
89
|
-
return sortOrder === "ASC" ? sortAlphaASC(sortValue1, sortValue2) : sortAlphaDSC(sortValue1, sortValue2);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return filteredRecords;
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
var Table = function Table(props) {
|
|
13
|
+
return /*#__PURE__*/_react["default"].createElement(_TableChild["default"], props);
|
|
94
14
|
};
|
|
95
|
-
var REQUEST_KEYS = exports.REQUEST_KEYS = {
|
|
96
|
-
searchBy: "search",
|
|
97
|
-
sortBy: "sortBy",
|
|
98
|
-
sortOrder: "sortOrder",
|
|
99
|
-
sortASC: "ASC",
|
|
100
|
-
sortDSC: "DSC"
|
|
101
|
-
};
|
|
102
|
-
var Table = function Table(props, ref) {
|
|
103
|
-
var className = props.className,
|
|
104
|
-
wrapperClassName = props.wrapperClassName,
|
|
105
|
-
records = props.records,
|
|
106
|
-
columnConfigs = props.columnConfigs,
|
|
107
|
-
idAttribute = props.idAttribute,
|
|
108
|
-
searchBy = props.searchBy,
|
|
109
|
-
getRequestKeys = props.getRequestKeys,
|
|
110
|
-
showPaginateBar = props.showPaginateBar,
|
|
111
|
-
paginationPosition = props.paginationPosition,
|
|
112
|
-
paginationType = props.paginationType,
|
|
113
|
-
paginationBar = props.paginationBar,
|
|
114
|
-
requestId = props.requestId,
|
|
115
|
-
pageNoKey = props.pageNoKey,
|
|
116
|
-
perPageKey = props.perPageKey,
|
|
117
|
-
pageSizeList = props.pageSizeList,
|
|
118
|
-
isExpandableTable = props.isExpandableTable,
|
|
119
|
-
ExpandedRowComponent = props.ExpandedRowComponent,
|
|
120
|
-
responseFormatter = props.responseFormatter,
|
|
121
|
-
noDataComponent = props.noDataComponent,
|
|
122
|
-
omitProps = props.omitProps,
|
|
123
|
-
getUrlParams = props.getUrlParams,
|
|
124
|
-
getRequestParams = props.getRequestParams,
|
|
125
|
-
checkboxConfig = props.checkboxConfig,
|
|
126
|
-
tbodyClassName = props.tbodyClassName,
|
|
127
|
-
_props$refreshFeature = props.refreshFeature,
|
|
128
|
-
refreshFeature = _props$refreshFeature === void 0 ? false : _props$refreshFeature,
|
|
129
|
-
refreshIconClass = props.refreshIconClass,
|
|
130
|
-
spinnerIconClass = props.spinnerIconClass,
|
|
131
|
-
onRefreshCB = props.onRefreshCB,
|
|
132
|
-
restProps = _objectWithoutProperties(props, _excluded);
|
|
133
|
-
/* variables for server data */
|
|
134
|
-
var _useState = (0, _react.useState)([]),
|
|
135
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
136
|
-
serverRecords = _useState2[0],
|
|
137
|
-
setServerRecords = _useState2[1];
|
|
138
|
-
var _useState3 = (0, _react.useState)(0),
|
|
139
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
140
|
-
serverTotal = _useState4[0],
|
|
141
|
-
setServerTotal = _useState4[1];
|
|
142
|
-
|
|
143
|
-
/* variables for search, sort data */
|
|
144
|
-
var _useState5 = (0, _react.useState)(searchBy),
|
|
145
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
146
|
-
searchQuery = _useState6[0],
|
|
147
|
-
setSearchQuery = _useState6[1];
|
|
148
|
-
var _useState7 = (0, _react.useState)({}),
|
|
149
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
150
|
-
sortByConfig = _useState8[0],
|
|
151
|
-
setSortByConfig = _useState8[1];
|
|
152
|
-
var sortBy = sortByConfig.sortBy,
|
|
153
|
-
sortOrder = sortByConfig.sortOrder;
|
|
154
|
-
var _useState9 = (0, _react.useState)(false),
|
|
155
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
156
|
-
isTableRefreshing = _useState10[0],
|
|
157
|
-
setIsTableRefreshing = _useState10[1];
|
|
158
|
-
|
|
159
|
-
/* variables for pagination data */
|
|
160
|
-
var _useState11 = (0, _react.useState)({
|
|
161
|
-
perPageCount: pageSizeList[0].id,
|
|
162
|
-
pageNo: 1
|
|
163
|
-
}),
|
|
164
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
165
|
-
pageConfig = _useState12[0],
|
|
166
|
-
setPageConfig = _useState12[1];
|
|
167
|
-
var perPageCount = pageConfig.perPageCount,
|
|
168
|
-
pageNo = pageConfig.pageNo;
|
|
169
|
-
var omitParams = [pageNoKey, perPageKey].concat(_toConsumableArray(omitProps.split(",")));
|
|
170
|
-
var _REQUEST_KEYS$getRequ = _objectSpread(_objectSpread({}, REQUEST_KEYS), getRequestKeys()),
|
|
171
|
-
searchByKey = _REQUEST_KEYS$getRequ.searchBy,
|
|
172
|
-
sortByKey = _REQUEST_KEYS$getRequ.sortBy,
|
|
173
|
-
sortOrderKey = _REQUEST_KEYS$getRequ.sortOrder,
|
|
174
|
-
ASCEnum = _REQUEST_KEYS$getRequ.sortASC,
|
|
175
|
-
DSCEnum = _REQUEST_KEYS$getRequ.sortDSC;
|
|
176
|
-
var extraParams = _utils["default"].omit(restProps, omitParams);
|
|
177
|
-
var requestParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getRequestParams()), extraParams), {}, _defineProperty(_defineProperty({}, pageNoKey, pageNo), perPageKey, perPageCount), searchQuery && _defineProperty({}, searchByKey, searchQuery)), sortBy && _defineProperty({}, sortByKey, sortBy)), sortOrder && _defineProperty({}, sortOrderKey, sortOrder === "DSC" ? DSCEnum : ASCEnum));
|
|
178
|
-
var requests = [{
|
|
179
|
-
requestId: requestId,
|
|
180
|
-
params: requestParams,
|
|
181
|
-
urlParams: getUrlParams()
|
|
182
|
-
}];
|
|
183
|
-
var onDataLoaded = function onDataLoaded(_ref5) {
|
|
184
|
-
var _ref6 = _slicedToArray(_ref5, 1),
|
|
185
|
-
response = _ref6[0];
|
|
186
|
-
var apiResponse = response;
|
|
187
|
-
if (typeof responseFormatter === "function") {
|
|
188
|
-
apiResponse = responseFormatter(response);
|
|
189
|
-
}
|
|
190
|
-
var _apiResponse = apiResponse,
|
|
191
|
-
entries = _apiResponse.entries,
|
|
192
|
-
total = _apiResponse.total;
|
|
193
|
-
entries = entries || [];
|
|
194
|
-
if (pageNo > 1 && entries.length === 0) {
|
|
195
|
-
/* current page does not have records, so fetch previous page */
|
|
196
|
-
setPageConfig(_objectSpread(_objectSpread({}, pageConfig), {}, {
|
|
197
|
-
pageNo: pageNo - 1
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
setServerRecords(entries);
|
|
201
|
-
setServerTotal(total);
|
|
202
|
-
};
|
|
203
|
-
var onRefreshTableData = function onRefreshTableData() {
|
|
204
|
-
setIsTableRefreshing(true);
|
|
205
|
-
var def = _dataLoader["default"].getRequestDef(requests[0]);
|
|
206
|
-
def.done(function (response) {
|
|
207
|
-
onDataLoaded([response]);
|
|
208
|
-
setIsTableRefreshing(false);
|
|
209
|
-
});
|
|
210
|
-
def["catch"](function (error) {
|
|
211
|
-
setIsTableRefreshing(false);
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
var resetPageNo = function resetPageNo() {
|
|
215
|
-
setPageConfig(_objectSpread(_objectSpread({}, pageConfig), {}, {
|
|
216
|
-
pageNo: 1
|
|
217
|
-
}));
|
|
218
|
-
};
|
|
219
|
-
(0, _react.useEffect)(function () {
|
|
220
|
-
/* Search value changed: reset pageNo. */
|
|
221
|
-
resetPageNo();
|
|
222
|
-
setSearchQuery(searchBy);
|
|
223
|
-
}, [searchBy]);
|
|
224
|
-
var onSort = function onSort(columnConfig) {
|
|
225
|
-
var newSortBy = columnConfig.key;
|
|
226
|
-
var newSortOrder = "ASC";
|
|
227
|
-
if (sortBy === newSortBy) {
|
|
228
|
-
/* clicked sort on the same column */
|
|
229
|
-
newSortOrder = sortOrder === "ASC" ? "DSC" : "ASC";
|
|
230
|
-
}
|
|
231
|
-
setSortByConfig({
|
|
232
|
-
sortBy: newSortBy,
|
|
233
|
-
sortOrder: newSortOrder,
|
|
234
|
-
columnConfig: columnConfig
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
var filteredRecords = getFilteredRecords({
|
|
238
|
-
records: records,
|
|
239
|
-
searchBy: searchBy,
|
|
240
|
-
searchByKey: searchByKey,
|
|
241
|
-
sortByConfig: sortByConfig
|
|
242
|
-
});
|
|
243
|
-
var totalRecords = paginationType === "SERVER" ? serverTotal : filteredRecords.length;
|
|
244
|
-
var paginationProps = {
|
|
245
|
-
pageSizeList: pageSizeList,
|
|
246
|
-
onPageConfigChanged: setPageConfig,
|
|
247
|
-
pageConfig: _objectSpread(_objectSpread({}, pageConfig), {}, {
|
|
248
|
-
total: totalRecords
|
|
249
|
-
})
|
|
250
|
-
};
|
|
251
|
-
var paginationComponent = /*#__PURE__*/_react["default"].createElement("div", {
|
|
252
|
-
className: "RCB-paginate-bar"
|
|
253
|
-
}, paginationBar ? /*#__PURE__*/_react["default"].cloneElement(paginationBar, paginationProps) : /*#__PURE__*/_react["default"].createElement(_PaginationComponent["default"], paginationProps));
|
|
254
|
-
var finalRecords = paginationType === "SERVER" ? serverRecords : showPaginateBar ? getPageRecords(filteredRecords, pageConfig) : filteredRecords;
|
|
255
|
-
var wrappedComponent = /*#__PURE__*/_react["default"].createElement(_BaseTable["default"], {
|
|
256
|
-
ref: ref,
|
|
257
|
-
records: finalRecords,
|
|
258
|
-
columnConfigs: columnConfigs,
|
|
259
|
-
checkboxConfig: checkboxConfig,
|
|
260
|
-
idAttribute: idAttribute,
|
|
261
|
-
noDataComponent: noDataComponent,
|
|
262
|
-
pageNo: pageNo,
|
|
263
|
-
tbodyClassName: tbodyClassName,
|
|
264
|
-
isTableRefreshing: isTableRefreshing,
|
|
265
|
-
refreshFeature: refreshFeature,
|
|
266
|
-
refreshIconClass: refreshIconClass,
|
|
267
|
-
onRefreshCB: onRefreshCB,
|
|
268
|
-
spinnerIconClass: spinnerIconClass,
|
|
269
|
-
onRefreshTableData: onRefreshTableData,
|
|
270
|
-
sortByConfig: sortByConfig,
|
|
271
|
-
onSort: onSort,
|
|
272
|
-
resetPageNo: resetPageNo,
|
|
273
|
-
isExpandableTable: isExpandableTable,
|
|
274
|
-
ExpandedRowComponent: ExpandedRowComponent
|
|
275
|
-
});
|
|
276
|
-
if (paginationType === "SERVER") {
|
|
277
|
-
wrappedComponent = /*#__PURE__*/_react["default"].createElement(_DataLoader["default"], {
|
|
278
|
-
requests: requests,
|
|
279
|
-
onDataLoaded: onDataLoaded
|
|
280
|
-
}, wrappedComponent);
|
|
281
|
-
}
|
|
282
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
283
|
-
className: className
|
|
284
|
-
}, showPaginateBar && paginationPosition === "TOP" && totalRecords > 0 && paginationComponent, /*#__PURE__*/_react["default"].createElement("div", {
|
|
285
|
-
className: wrapperClassName
|
|
286
|
-
}, wrappedComponent), showPaginateBar && paginationPosition === "BOTTOM" && totalRecords > 0 && paginationComponent);
|
|
287
|
-
};
|
|
288
|
-
Table = /*#__PURE__*/(0, _react.forwardRef)(Table);
|
|
289
|
-
Table.propTypes = _objectSpread(_objectSpread({}, _BaseTable["default"].propTypes), {}, {
|
|
290
|
-
/** search value to search data in the table */
|
|
291
|
-
searchBy: _propTypes["default"].string,
|
|
292
|
-
/** list of supported page sizes */
|
|
293
|
-
pageSizeList: _propTypes["default"].array,
|
|
294
|
-
/** set to false to disable pagination bar */
|
|
295
|
-
showPaginateBar: _propTypes["default"].bool,
|
|
296
|
-
/** location where the pagination component must be displayed */
|
|
297
|
-
paginationPosition: _propTypes["default"].oneOf(["TOP", "BOTTOM"]),
|
|
298
|
-
/** CLIENT side pagination or SERVER side pagination */
|
|
299
|
-
paginationType: _propTypes["default"].oneOf(["CLIENT", "SERVER"]),
|
|
300
|
-
/** You can provide a custom component for the pagination bar
|
|
301
|
-
* if you want to add more content to the pagination bar other than the pagination widget.
|
|
302
|
-
* Make sure to include <PagniationComponent /> and pass on all the props sent to this custom component
|
|
303
|
-
*/
|
|
304
|
-
paginationBar: _propTypes["default"].any,
|
|
305
|
-
/** [SERVER side pagination] the ID of the request to call */
|
|
306
|
-
requestId: _propTypes["default"].string,
|
|
307
|
-
/** [SERVER side pagination] key to send the page number value in, to the API */
|
|
308
|
-
pageNoKey: _propTypes["default"].string,
|
|
309
|
-
/** [SERVER side pagination] key to send the page count value in, to the API */
|
|
310
|
-
perPageKey: _propTypes["default"].string,
|
|
311
|
-
/** If paginationType is "SERVER",
|
|
312
|
-
* component expects the response to be of the form
|
|
313
|
-
* { [pageNoKey]: <pageNo>, [perPageKey]: <pageSize>, total: <totalCount>, entries: [{}] }
|
|
314
|
-
* If your data is not in this format, use the responseFormatter to format the data to this structure.
|
|
315
|
-
* Input to this function is the response received from your API
|
|
316
|
-
* */
|
|
317
|
-
responseFormatter: _propTypes["default"].func,
|
|
318
|
-
/** If paginationType is "SERVER",
|
|
319
|
-
* a comma separated list of the props to be omitted from being added to the API request */
|
|
320
|
-
omitProps: _propTypes["default"].string,
|
|
321
|
-
/** If paginationType is "SERVER", function that is expected to return the key configs for the various request settings
|
|
322
|
-
* in the format { searchBy, sortBy, sortOrder }
|
|
323
|
-
*/
|
|
324
|
-
getRequestKeys: _propTypes["default"].func,
|
|
325
|
-
/** If paginationType is "SERVER", function that is expected to return the URL Params object */
|
|
326
|
-
getUrlParams: _propTypes["default"].func,
|
|
327
|
-
/** If paginationType is "SERVER", function that is expected to return the Request Params object */
|
|
328
|
-
getRequestParams: _propTypes["default"].func,
|
|
329
|
-
/** If refreshFeature is true will have refresh option on table */
|
|
330
|
-
refreshFeature: _propTypes["default"].bool,
|
|
331
|
-
/** refresh icon class */
|
|
332
|
-
refreshIconClass: _propTypes["default"].string,
|
|
333
|
-
/** spinnerIcon is used when we have refreshFeature equal to true */
|
|
334
|
-
spinnerIconClass: _propTypes["default"].string,
|
|
335
|
-
/** If on table refresh we want to handle something we can add it in call back */
|
|
336
|
-
onRefreshCB: _propTypes["default"].func
|
|
337
|
-
});
|
|
338
|
-
Table.defaultProps = _objectSpread(_objectSpread({}, _BaseTable["default"].defaultProps), {}, {
|
|
339
|
-
pageSizeList: [{
|
|
340
|
-
id: "10",
|
|
341
|
-
name: "10"
|
|
342
|
-
}, {
|
|
343
|
-
id: "20",
|
|
344
|
-
name: "20"
|
|
345
|
-
}, {
|
|
346
|
-
id: "50",
|
|
347
|
-
name: "50"
|
|
348
|
-
}, {
|
|
349
|
-
id: "100",
|
|
350
|
-
name: "100"
|
|
351
|
-
}],
|
|
352
|
-
showPaginateBar: true,
|
|
353
|
-
paginationPosition: "TOP",
|
|
354
|
-
paginationType: "CLIENT",
|
|
355
|
-
pageNoKey: "page",
|
|
356
|
-
perPageKey: "count",
|
|
357
|
-
omitProps: "",
|
|
358
|
-
getRequestKeys: function getRequestKeys() {
|
|
359
|
-
return {};
|
|
360
|
-
},
|
|
361
|
-
getUrlParams: function getUrlParams() {
|
|
362
|
-
return {};
|
|
363
|
-
},
|
|
364
|
-
getRequestParams: function getRequestParams() {
|
|
365
|
-
return {};
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
15
|
var _default = exports["default"] = Table;
|