@linzjs/step-ag-grid 14.9.1 → 14.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # step-ag-grid
2
2
 
3
3
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
4
-
5
4
  > Reusable [ag-grid](https://www.ag-grid.com/) component for LINZ / Toitū te whenua.
6
5
 
7
6
  ## Features
@@ -25,13 +24,13 @@ _Please note this requires React >=17, ag-grid-community >=27, and sass._
25
24
  with npm
26
25
 
27
26
  ```bash
28
- npm install @linz/step-ag-grid
27
+ npm install @linzjs/step-ag-grid
29
28
  ```
30
29
 
31
30
  or with Yarn
32
31
 
33
32
  ```bash
34
- yarn add @linz/step-ag-grid
33
+ yarn add @linzjs/step-ag-grid
35
34
  ```
36
35
 
37
36
  ## Demo
@@ -5,10 +5,4 @@ export declare const findParentWithClass: (className: string, child: Node) => HT
5
5
  export declare const hasParentClass: (className: string, child: Node) => boolean;
6
6
  export declare const stringByteLengthIsInvalid: (str: string, maxBytes: number) => boolean;
7
7
  export declare const fnOrVar: (fn: any, param: any) => any;
8
- /**
9
- * Trim filename and replaces troublesome characters.
10
- *
11
- * e.g. " LT 1235/543 &%//*$ " => "LT_1235-543_&%-$"
12
- * e.g. " @filename here!!!" => "@filename_here!!!"
13
- */
14
8
  export declare const sanitiseFileName: (filename: string) => string;
@@ -3,7 +3,7 @@ import { LuiMiniSpinner, LuiIcon, LuiButton, LuiCheckboxInput, LuiButtonGroup }
3
3
  import { AgGridReact } from 'ag-grid-react';
4
4
  import { negate, isEmpty, xorBy, last, difference, defer as defer$1, omit, sortBy, findIndex, debounce as debounce$1, delay, partition, pick, groupBy, fromPairs, toPairs, isEqual, sumBy, compact, remove, castArray, flatten } from 'lodash-es';
5
5
  import * as React from 'react';
6
- import { createContext, useContext, useEffect, useRef, useCallback, useState, useMemo, forwardRef, useLayoutEffect, memo, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1 } from 'react';
6
+ import { createContext, useContext, useRef, useEffect, useCallback, useState, useMemo, forwardRef, useLayoutEffect, memo, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1 } from 'react';
7
7
  import ReactDOM, { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
8
8
  import require$$0$1 from 'util';
9
9
  import * as testUtils from 'react-dom/test-utils';
@@ -211,154 +211,18 @@ const useTimeoutHook = () => {
211
211
  return invoke;
212
212
  };
213
213
  const useIntervalHook = ({ callback, timeoutMs }) => {
214
+ const callbackRef = useRef(callback);
215
+ callbackRef.current = callback;
214
216
  useEffect(() => {
215
- const interval = setInterval(callback, timeoutMs);
217
+ const interval = setInterval(() => {
218
+ callbackRef.current && callbackRef.current();
219
+ }, timeoutMs);
216
220
  return () => {
217
221
  clearInterval(interval);
218
222
  };
219
- });
223
+ }, [timeoutMs]);
220
224
  };
221
225
 
222
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
223
-
224
- function getDefaultExportFromCjs (x) {
225
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
226
- }
227
-
228
- function getAugmentedNamespace(n) {
229
- if (n.__esModule) return n;
230
- var f = n.default;
231
- if (typeof f == "function") {
232
- var a = function a () {
233
- if (this instanceof a) {
234
- var args = [null];
235
- args.push.apply(args, arguments);
236
- var Ctor = Function.bind.apply(f, args);
237
- return new Ctor();
238
- }
239
- return f.apply(this, arguments);
240
- };
241
- a.prototype = f.prototype;
242
- } else a = {};
243
- Object.defineProperty(a, '__esModule', {value: true});
244
- Object.keys(n).forEach(function (k) {
245
- var d = Object.getOwnPropertyDescriptor(n, k);
246
- Object.defineProperty(a, k, d.get ? d : {
247
- enumerable: true,
248
- get: function () {
249
- return n[k];
250
- }
251
- });
252
- });
253
- return a;
254
- }
255
-
256
- function isHighSurrogate(codePoint) {
257
- return codePoint >= 0xd800 && codePoint <= 0xdbff;
258
- }
259
-
260
- function isLowSurrogate(codePoint) {
261
- return codePoint >= 0xdc00 && codePoint <= 0xdfff;
262
- }
263
-
264
- // Truncate string by size in bytes
265
- var truncate$2 = function truncate(getLength, string, byteLength) {
266
- if (typeof string !== "string") {
267
- throw new Error("Input must be string");
268
- }
269
-
270
- var charLength = string.length;
271
- var curByteLength = 0;
272
- var codePoint;
273
- var segment;
274
-
275
- for (var i = 0; i < charLength; i += 1) {
276
- codePoint = string.charCodeAt(i);
277
- segment = string[i];
278
-
279
- if (isHighSurrogate(codePoint) && isLowSurrogate(string.charCodeAt(i + 1))) {
280
- i += 1;
281
- segment += string[i];
282
- }
283
-
284
- curByteLength += getLength(segment);
285
-
286
- if (curByteLength === byteLength) {
287
- return string.slice(0, i + 1);
288
- }
289
- else if (curByteLength > byteLength) {
290
- return string.slice(0, i - segment.length + 1);
291
- }
292
- }
293
-
294
- return string;
295
- };
296
-
297
- var truncate$1 = truncate$2;
298
- var getLength = Buffer.byteLength.bind(Buffer);
299
- var truncateUtf8Bytes = truncate$1.bind(null, getLength);
300
-
301
- /*jshint node:true*/
302
-
303
- /**
304
- * Replaces characters in strings that are illegal/unsafe for filenames.
305
- * Unsafe characters are either removed or replaced by a substitute set
306
- * in the optional `options` object.
307
- *
308
- * Illegal Characters on Various Operating Systems
309
- * / ? < > \ : * | "
310
- * https://kb.acronis.com/content/39790
311
- *
312
- * Unicode Control codes
313
- * C0 0x00-0x1f & C1 (0x80-0x9f)
314
- * http://en.wikipedia.org/wiki/C0_and_C1_control_codes
315
- *
316
- * Reserved filenames on Unix-based systems (".", "..")
317
- * Reserved filenames in Windows ("CON", "PRN", "AUX", "NUL", "COM1",
318
- * "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
319
- * "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", and
320
- * "LPT9") case-insesitively and with or without filename extensions.
321
- *
322
- * Capped at 255 characters in length.
323
- * http://unix.stackexchange.com/questions/32795/what-is-the-maximum-allowed-filename-and-folder-size-with-ecryptfs
324
- *
325
- * @param {String} input Original filename
326
- * @param {Object} options {replacement: String | Function }
327
- * @return {String} Sanitized filename
328
- */
329
-
330
- var truncate = truncateUtf8Bytes;
331
-
332
- var illegalRe = /[\/\?<>\\:\*\|"]/g;
333
- var controlRe = /[\x00-\x1f\x80-\x9f]/g;
334
- var reservedRe = /^\.+$/;
335
- var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
336
- var windowsTrailingRe = /[\. ]+$/;
337
-
338
- function sanitize(input, replacement) {
339
- if (typeof input !== 'string') {
340
- throw new Error('Input must be string');
341
- }
342
- var sanitized = input
343
- .replace(illegalRe, replacement)
344
- .replace(controlRe, replacement)
345
- .replace(reservedRe, replacement)
346
- .replace(windowsReservedRe, replacement)
347
- .replace(windowsTrailingRe, replacement);
348
- return truncate(sanitized, 255);
349
- }
350
-
351
- var sanitizeFilename = function (input, options) {
352
- var replacement = (options && options.replacement) || '';
353
- var output = sanitize(input, replacement);
354
- if (replacement === '') {
355
- return output;
356
- }
357
- return sanitize(output, '');
358
- };
359
-
360
- var sanitize$1 = /*@__PURE__*/getDefaultExportFromCjs(sanitizeFilename);
361
-
362
226
  const isNotEmpty = negate(isEmpty);
363
227
  const wait$2 = (timeoutMs) => new Promise((resolve) => {
364
228
  setTimeout(resolve, timeoutMs);
@@ -397,13 +261,19 @@ const hasParentClass = function (className, child) {
397
261
  };
398
262
  const stringByteLengthIsInvalid = (str, maxBytes) => new TextEncoder().encode(str).length > maxBytes;
399
263
  const fnOrVar = (fn, param) => (typeof fn === "function" ? fn(param) : fn);
400
- /**
401
- * Trim filename and replaces troublesome characters.
402
- *
403
- * e.g. " LT 1235/543 &%//*$ " => "LT_1235-543_&%-$"
404
- * e.g. " @filename here!!!" => "@filename_here!!!"
405
- */
406
- const sanitiseFileName = (filename) => sanitize$1(filename.trim().replaceAll(/(\/|\\)+/g, "-")).replaceAll(/\s+/g, "_");
264
+ const sanitiseFileName = (filename) => {
265
+ const valid = filename
266
+ .trim()
267
+ .replaceAll(/(\/|\\)+/g, "-")
268
+ .replaceAll(/\s+/g, "_")
269
+ .replaceAll(/[^\w\-āēīōūĀĒĪŌŪ.]/g, "");
270
+ const parts = valid.split(".");
271
+ const fileExt = parts.length > 1 ? parts.pop() : undefined;
272
+ // Arbitrary max filename length of 64 chars + extension
273
+ if (!fileExt)
274
+ return valid.slice().slice(0, 64);
275
+ return valid.slice(0, -fileExt.length - 1).slice(0, 64) + "." + fileExt;
276
+ };
407
277
 
408
278
  const GridNoRowsOverlay = (params) => (jsx("span", { children: isEmpty(params.rowData)
409
279
  ? params.noRowsOverlayText ?? "There are currently no rows"
@@ -621,7 +491,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
621
491
  return;
622
492
  }
623
493
  const headerCellCount = gridDivRef.current?.getElementsByClassName("ag-header-cell-label")?.length;
624
- if (headerCellCount != params.columnDefs.length) {
494
+ if (headerCellCount < 2) {
625
495
  // Don't resize grids until all the columns are visible
626
496
  // as `autoSizeColumns` will fail silently in this case
627
497
  needsAutoSize.current = true;
@@ -3164,6 +3034,40 @@ const GridFilterDownloadCsvButton = (csvExportParams) => {
3164
3034
  } })) : (jsx(GridFilterHeaderIconButton, { icon: "ic_csv_file", title: "Download CSV", onClick: handleDownloadClick, disabled: downloading }));
3165
3035
  };
3166
3036
 
3037
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3038
+
3039
+ function getDefaultExportFromCjs (x) {
3040
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3041
+ }
3042
+
3043
+ function getAugmentedNamespace(n) {
3044
+ if (n.__esModule) return n;
3045
+ var f = n.default;
3046
+ if (typeof f == "function") {
3047
+ var a = function a () {
3048
+ if (this instanceof a) {
3049
+ var args = [null];
3050
+ args.push.apply(args, arguments);
3051
+ var Ctor = Function.bind.apply(f, args);
3052
+ return new Ctor();
3053
+ }
3054
+ return f.apply(this, arguments);
3055
+ };
3056
+ a.prototype = f.prototype;
3057
+ } else a = {};
3058
+ Object.defineProperty(a, '__esModule', {value: true});
3059
+ Object.keys(n).forEach(function (k) {
3060
+ var d = Object.getOwnPropertyDescriptor(n, k);
3061
+ Object.defineProperty(a, k, d.get ? d : {
3062
+ enumerable: true,
3063
+ get: function () {
3064
+ return n[k];
3065
+ }
3066
+ });
3067
+ });
3068
+ return a;
3069
+ }
3070
+
3167
3071
  /* global setTimeout, clearTimeout */
3168
3072
 
3169
3073
  var dist$1 = function debounce(fn) {