ods-component-lib 1.18.60 → 1.18.61

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