ods-component-lib 1.18.60 → 1.18.62

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.
@@ -16285,6 +16285,309 @@ function debounce(func, wait, options) {
16285
16285
 
16286
16286
  var debounce_1 = debounce;
16287
16287
 
16288
+ var strictUriEncode = function (str) {
16289
+ return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
16290
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase();
16291
+ });
16292
+ };
16293
+
16294
+ /*
16295
+ object-assign
16296
+ (c) Sindre Sorhus
16297
+ @license MIT
16298
+ */
16299
+ /* eslint-disable no-unused-vars */
16300
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
16301
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
16302
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
16303
+
16304
+ function toObject(val) {
16305
+ if (val === null || val === undefined) {
16306
+ throw new TypeError('Object.assign cannot be called with null or undefined');
16307
+ }
16308
+
16309
+ return Object(val);
16310
+ }
16311
+
16312
+ function shouldUseNative() {
16313
+ try {
16314
+ if (!Object.assign) {
16315
+ return false;
16316
+ }
16317
+
16318
+ // Detect buggy property enumeration order in older V8 versions.
16319
+
16320
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
16321
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
16322
+ test1[5] = 'de';
16323
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
16324
+ return false;
16325
+ }
16326
+
16327
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
16328
+ var test2 = {};
16329
+ for (var i = 0; i < 10; i++) {
16330
+ test2['_' + String.fromCharCode(i)] = i;
16331
+ }
16332
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
16333
+ return test2[n];
16334
+ });
16335
+ if (order2.join('') !== '0123456789') {
16336
+ return false;
16337
+ }
16338
+
16339
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
16340
+ var test3 = {};
16341
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
16342
+ test3[letter] = letter;
16343
+ });
16344
+ if (Object.keys(Object.assign({}, test3)).join('') !==
16345
+ 'abcdefghijklmnopqrst') {
16346
+ return false;
16347
+ }
16348
+
16349
+ return true;
16350
+ } catch (err) {
16351
+ // We don't expect any of the above to throw, but better to be safe.
16352
+ return false;
16353
+ }
16354
+ }
16355
+
16356
+ var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
16357
+ var from;
16358
+ var to = toObject(target);
16359
+ var symbols;
16360
+
16361
+ for (var s = 1; s < arguments.length; s++) {
16362
+ from = Object(arguments[s]);
16363
+
16364
+ for (var key in from) {
16365
+ if (hasOwnProperty$1.call(from, key)) {
16366
+ to[key] = from[key];
16367
+ }
16368
+ }
16369
+
16370
+ if (getOwnPropertySymbols) {
16371
+ symbols = getOwnPropertySymbols(from);
16372
+ for (var i = 0; i < symbols.length; i++) {
16373
+ if (propIsEnumerable.call(from, symbols[i])) {
16374
+ to[symbols[i]] = from[symbols[i]];
16375
+ }
16376
+ }
16377
+ }
16378
+ }
16379
+
16380
+ return to;
16381
+ };
16382
+
16383
+ function encoderForArrayFormat(opts) {
16384
+ switch (opts.arrayFormat) {
16385
+ case 'index':
16386
+ return function (key, value, index) {
16387
+ return value === null ? [
16388
+ encode(key, opts),
16389
+ '[',
16390
+ index,
16391
+ ']'
16392
+ ].join('') : [
16393
+ encode(key, opts),
16394
+ '[',
16395
+ encode(index, opts),
16396
+ ']=',
16397
+ encode(value, opts)
16398
+ ].join('');
16399
+ };
16400
+
16401
+ case 'bracket':
16402
+ return function (key, value) {
16403
+ return value === null ? encode(key, opts) : [
16404
+ encode(key, opts),
16405
+ '[]=',
16406
+ encode(value, opts)
16407
+ ].join('');
16408
+ };
16409
+
16410
+ default:
16411
+ return function (key, value) {
16412
+ return value === null ? encode(key, opts) : [
16413
+ encode(key, opts),
16414
+ '=',
16415
+ encode(value, opts)
16416
+ ].join('');
16417
+ };
16418
+ }
16419
+ }
16420
+
16421
+ function parserForArrayFormat(opts) {
16422
+ var result;
16423
+
16424
+ switch (opts.arrayFormat) {
16425
+ case 'index':
16426
+ return function (key, value, accumulator) {
16427
+ result = /\[(\d*)\]$/.exec(key);
16428
+
16429
+ key = key.replace(/\[\d*\]$/, '');
16430
+
16431
+ if (!result) {
16432
+ accumulator[key] = value;
16433
+ return;
16434
+ }
16435
+
16436
+ if (accumulator[key] === undefined) {
16437
+ accumulator[key] = {};
16438
+ }
16439
+
16440
+ accumulator[key][result[1]] = value;
16441
+ };
16442
+
16443
+ case 'bracket':
16444
+ return function (key, value, accumulator) {
16445
+ result = /(\[\])$/.exec(key);
16446
+ key = key.replace(/\[\]$/, '');
16447
+
16448
+ if (!result) {
16449
+ accumulator[key] = value;
16450
+ return;
16451
+ } else if (accumulator[key] === undefined) {
16452
+ accumulator[key] = [value];
16453
+ return;
16454
+ }
16455
+
16456
+ accumulator[key] = [].concat(accumulator[key], value);
16457
+ };
16458
+
16459
+ default:
16460
+ return function (key, value, accumulator) {
16461
+ if (accumulator[key] === undefined) {
16462
+ accumulator[key] = value;
16463
+ return;
16464
+ }
16465
+
16466
+ accumulator[key] = [].concat(accumulator[key], value);
16467
+ };
16468
+ }
16469
+ }
16470
+
16471
+ function encode(value, opts) {
16472
+ if (opts.encode) {
16473
+ return opts.strict ? strictUriEncode(value) : encodeURIComponent(value);
16474
+ }
16475
+
16476
+ return value;
16477
+ }
16478
+
16479
+ function keysSorter(input) {
16480
+ if (Array.isArray(input)) {
16481
+ return input.sort();
16482
+ } else if (typeof input === 'object') {
16483
+ return keysSorter(Object.keys(input)).sort(function (a, b) {
16484
+ return Number(a) - Number(b);
16485
+ }).map(function (key) {
16486
+ return input[key];
16487
+ });
16488
+ }
16489
+
16490
+ return input;
16491
+ }
16492
+
16493
+ var extract = function (str) {
16494
+ return str.split('?')[1] || '';
16495
+ };
16496
+
16497
+ var parse = function (str, opts) {
16498
+ opts = objectAssign({arrayFormat: 'none'}, opts);
16499
+
16500
+ var formatter = parserForArrayFormat(opts);
16501
+
16502
+ // Create an object with no prototype
16503
+ // https://github.com/sindresorhus/query-string/issues/47
16504
+ var ret = Object.create(null);
16505
+
16506
+ if (typeof str !== 'string') {
16507
+ return ret;
16508
+ }
16509
+
16510
+ str = str.trim().replace(/^(\?|#|&)/, '');
16511
+
16512
+ if (!str) {
16513
+ return ret;
16514
+ }
16515
+
16516
+ str.split('&').forEach(function (param) {
16517
+ var parts = param.replace(/\+/g, ' ').split('=');
16518
+ // Firefox (pre 40) decodes `%3D` to `=`
16519
+ // https://github.com/sindresorhus/query-string/pull/37
16520
+ var key = parts.shift();
16521
+ var val = parts.length > 0 ? parts.join('=') : undefined;
16522
+
16523
+ // missing `=` should be `null`:
16524
+ // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
16525
+ val = val === undefined ? null : decodeURIComponent(val);
16526
+
16527
+ formatter(decodeURIComponent(key), val, ret);
16528
+ });
16529
+
16530
+ return Object.keys(ret).sort().reduce(function (result, key) {
16531
+ var val = ret[key];
16532
+ if (Boolean(val) && typeof val === 'object' && !Array.isArray(val)) {
16533
+ // Sort object keys, not values
16534
+ result[key] = keysSorter(val);
16535
+ } else {
16536
+ result[key] = val;
16537
+ }
16538
+
16539
+ return result;
16540
+ }, Object.create(null));
16541
+ };
16542
+
16543
+ var stringify = function (obj, opts) {
16544
+ var defaults = {
16545
+ encode: true,
16546
+ strict: true,
16547
+ arrayFormat: 'none'
16548
+ };
16549
+
16550
+ opts = objectAssign(defaults, opts);
16551
+
16552
+ var formatter = encoderForArrayFormat(opts);
16553
+
16554
+ return obj ? Object.keys(obj).sort().map(function (key) {
16555
+ var val = obj[key];
16556
+
16557
+ if (val === undefined) {
16558
+ return '';
16559
+ }
16560
+
16561
+ if (val === null) {
16562
+ return encode(key, opts);
16563
+ }
16564
+
16565
+ if (Array.isArray(val)) {
16566
+ var result = [];
16567
+
16568
+ val.slice().forEach(function (val2) {
16569
+ if (val2 === undefined) {
16570
+ return;
16571
+ }
16572
+
16573
+ result.push(formatter(key, val2, result.length));
16574
+ });
16575
+
16576
+ return result.join('&');
16577
+ }
16578
+
16579
+ return encode(key, opts) + '=' + encode(val, opts);
16580
+ }).filter(function (x) {
16581
+ return x.length > 0;
16582
+ }).join('&') : '';
16583
+ };
16584
+
16585
+ var queryString = {
16586
+ extract: extract,
16587
+ parse: parse,
16588
+ stringify: stringify
16589
+ };
16590
+
16288
16591
  var iconComponents = {
16289
16592
  edit: EditIcon,
16290
16593
  "delete": Trash1Icon,
@@ -16311,7 +16614,7 @@ var loadedPageCount = 1;
16311
16614
  var totalRecordCount = 0;
16312
16615
  var useToken$1 = theme.useToken;
16313
16616
  var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
16314
- var _props$axiosRequest2, _props$axiosRequest3, _props$axiosRequest4, _props$axiosRequest5, _props$axiosRequest6, _props$axiosRequest7, _props$axiosRequest8, _props$selectOptions, _props$selectOptions$, _props$selectOptions2, _props$selectOptions$2, _props$selectOptions3;
16617
+ var _props$axiosRequest, _props$axiosRequest2, _props$axiosRequest3, _props$axiosRequest4, _props$axiosRequest5, _props$axiosRequest6, _props$axiosRequest7, _props$selectOptions, _props$selectOptions$, _props$selectOptions2, _props$selectOptions$2, _props$selectOptions3;
16315
16618
  var _useToken = useToken$1(),
16316
16619
  token = _useToken.token;
16317
16620
  var _useState = useState([]),
@@ -16344,15 +16647,14 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
16344
16647
  totalRecordCount = 0;
16345
16648
  }, [props.dataGridPageName]);
16346
16649
  useEffect(function () {
16347
- var _props$axiosRequest;
16348
- if (props.axiosRequest !== undefined && Object.keys((_props$axiosRequest = props.axiosRequest) === null || _props$axiosRequest === void 0 ? void 0 : _props$axiosRequest.requestData).length > 0) {
16650
+ if (props.axiosRequest !== undefined) {
16349
16651
  totalPageCount = 1;
16350
16652
  loadedPageCount = 1;
16351
16653
  totalRecordCount = 0;
16352
16654
  setData([]);
16353
16655
  fetchData();
16354
16656
  }
16355
- }, [(_props$axiosRequest2 = props.axiosRequest) === null || _props$axiosRequest2 === void 0 ? void 0 : _props$axiosRequest2.requestData]);
16657
+ }, [(_props$axiosRequest = props.axiosRequest) === null || _props$axiosRequest === void 0 ? void 0 : _props$axiosRequest.requestData]);
16356
16658
  useEffect(function () {
16357
16659
  if (columns.current !== undefined && columns.current.length > 0) {
16358
16660
  var newColumns = columns.current.map(function (colItem) {
@@ -16412,13 +16714,21 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
16412
16714
  if (props.axiosRequest == undefined) return Promise.resolve();
16413
16715
  var _temp2 = function () {
16414
16716
  if (props.isServerSide) {
16717
+ var _props$axiosRequest$r;
16415
16718
  var apiUrl = props.axiosRequest.environmentUrl + "" + props.axiosRequest.apiUrl;
16416
- if (props.axiosRequest.requestData.PaginatedRequest !== undefined) {
16719
+ if (((_props$axiosRequest$r = props.axiosRequest.requestData) === null || _props$axiosRequest$r === void 0 ? void 0 : _props$axiosRequest$r.PaginatedRequest) !== undefined) {
16417
16720
  props.axiosRequest.requestData.PaginatedRequest.PageNumber = loadedPageCount;
16418
16721
  props.axiosRequest.requestData.PaginatedRequest.PageSize = props.pageSize;
16419
16722
  }
16420
16723
  if (props.axiosRequest.requestQueryString !== undefined) {
16421
- apiUrl = apiUrl + "?" + props.axiosRequest.requestQueryString;
16724
+ var queryParams = queryString.parse(props.axiosRequest.requestQueryString);
16725
+ queryParams.maxResultCount = props.pageSize.toString();
16726
+ var query = props.axiosRequest.requestQueryString;
16727
+ if (loadedPageCount > 1 && totalPageCount >= loadedPageCount) {
16728
+ queryParams.skipCount = ((loadedPageCount - 1) * props.pageSize).toString();
16729
+ }
16730
+ query = queryString.stringify(queryParams);
16731
+ apiUrl = apiUrl + "?" + query;
16422
16732
  }
16423
16733
  var requestOptions = {
16424
16734
  method: props.axiosRequest.requestType,
@@ -16431,17 +16741,15 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
16431
16741
  return Promise.resolve(fetch(apiUrl, requestOptions)).then(function (response) {
16432
16742
  return Promise.resolve(response.json()).then(function (newData) {
16433
16743
  if (loadedPageCount == 1) {
16434
- setData(newData.Data);
16744
+ setData(newData.Data ? newData.Data : newData);
16435
16745
  loadedPageCount = 1;
16436
16746
  } else if (totalPageCount >= loadedPageCount) {
16437
- var newArray = newData.Data;
16747
+ var newArray = newData.Data ? newData.Data : newData;
16438
16748
  setData(function (prevData) {
16439
16749
  return [].concat(prevData, newArray);
16440
16750
  });
16441
16751
  }
16442
- totalPageCount = newData.PageCount;
16443
- totalRecordCount = newData.RowCount;
16444
- setLoading(false);
16752
+ getTotalCount(response, newData);
16445
16753
  });
16446
16754
  });
16447
16755
  }, function (error) {
@@ -16459,7 +16767,21 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
16459
16767
  } catch (e) {
16460
16768
  return Promise.reject(e);
16461
16769
  }
16462
- }, [(_props$axiosRequest3 = props.axiosRequest) === null || _props$axiosRequest3 === void 0 ? void 0 : _props$axiosRequest3.requestData, (_props$axiosRequest4 = props.axiosRequest) === null || _props$axiosRequest4 === void 0 ? void 0 : _props$axiosRequest4.apiUrl, (_props$axiosRequest5 = props.axiosRequest) === null || _props$axiosRequest5 === void 0 ? void 0 : _props$axiosRequest5.environmentUrl, (_props$axiosRequest6 = props.axiosRequest) === null || _props$axiosRequest6 === void 0 ? void 0 : _props$axiosRequest6.requestQueryString, (_props$axiosRequest7 = props.axiosRequest) === null || _props$axiosRequest7 === void 0 ? void 0 : _props$axiosRequest7.requestType, props.pageSize, props.isServerSide]);
16770
+ }, [(_props$axiosRequest2 = props.axiosRequest) === null || _props$axiosRequest2 === void 0 ? void 0 : _props$axiosRequest2.requestData, (_props$axiosRequest3 = props.axiosRequest) === null || _props$axiosRequest3 === void 0 ? void 0 : _props$axiosRequest3.apiUrl, (_props$axiosRequest4 = props.axiosRequest) === null || _props$axiosRequest4 === void 0 ? void 0 : _props$axiosRequest4.environmentUrl, (_props$axiosRequest5 = props.axiosRequest) === null || _props$axiosRequest5 === void 0 ? void 0 : _props$axiosRequest5.requestQueryString, (_props$axiosRequest6 = props.axiosRequest) === null || _props$axiosRequest6 === void 0 ? void 0 : _props$axiosRequest6.requestType, props.pageSize, props.isServerSide]);
16771
+ var getTotalCount = function getTotalCount(response, data) {
16772
+ if (data !== null && data !== void 0 && data.PageCount || data !== null && data !== void 0 && data.RowCount) {
16773
+ totalPageCount = data.PageCount;
16774
+ totalPageCount = data.PageCount;
16775
+ } else {
16776
+ var totalCount;
16777
+ if (response) totalCount = response.headers.get('x-total-count');
16778
+ if (totalCount == null) totalCount = data === null || data === void 0 ? void 0 : data.rowCount;
16779
+ if (totalCount == null) totalCount = data === null || data === void 0 ? void 0 : data.length;
16780
+ totalRecordCount = parseInt(totalCount, 10) || 0;
16781
+ totalPageCount = Math.ceil(totalRecordCount / props.pageSize);
16782
+ }
16783
+ setLoading(false);
16784
+ };
16463
16785
  var onEditorPreparing = useCallback(function (e) {
16464
16786
  if (e.row !== undefined && e.parentType === 'dataRow') {
16465
16787
  if (props.handleEditorPreparing) {
@@ -16612,7 +16934,7 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
16612
16934
  }, [kebabMenuButtons]);
16613
16935
  var onScrollEnd = useCallback(function () {
16614
16936
  getServerSide("reachedBottom");
16615
- }, [(_props$axiosRequest8 = props.axiosRequest) === null || _props$axiosRequest8 === void 0 ? void 0 : _props$axiosRequest8.requestData, getServerSide]);
16937
+ }, [(_props$axiosRequest7 = props.axiosRequest) === null || _props$axiosRequest7 === void 0 ? void 0 : _props$axiosRequest7.requestData, getServerSide]);
16616
16938
  var handleScroll = function handleScroll(e) {
16617
16939
  var run = debounce_1(function (e) {
16618
16940
  var _scrollable$scrollTop, _scrollable$clientHei, _scrollable$scrollHei;