@bigbinary/neeto-commons-frontend 2.0.11 → 2.0.13

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/react-utils.js CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { useState, useEffect, useMemo, useRef, useReducer } from 'react';
3
3
  import { Search, Check, Copy, Help, LeftArrow as LeftArrow$1, User, Settings } from '@bigbinary/neeto-icons';
4
4
  import { Dropdown, Input, Checkbox, Typography, Tooltip, Button, Toastr, Modal, PageLoader } from '@bigbinary/neetoui';
5
- import { curry, isNil, complement as complement$1, isEmpty, includes, __, filter, trim, toLower, identity, without, append, fromPairs, keys, values, last, pluck, any, uniq, intersection, mergeLeft, not as not$2, assoc } from 'ramda';
5
+ import { curryN, isNil, complement as complement$1, isEmpty, curry, includes, __, filter, trim, toLower, identity, without, append, fromPairs, keys, values, last, pluck, any, uniq, intersection, mergeLeft, not as not$2, toPairs, assoc } from 'ramda';
6
6
  import dayjs from 'dayjs';
7
7
  import relativeTime from 'dayjs/plugin/relativeTime';
8
8
  import updateLocale from 'dayjs/plugin/updateLocale';
@@ -120,9 +120,57 @@ function _typeof$3(obj) {
120
120
  }, _typeof$3(obj);
121
121
  }
122
122
 
123
+ /**
124
+ * @template {Function} T
125
+ * @param {T} func
126
+ * @returns {T}
127
+ */
128
+
129
+ var nullSafe = function nullSafe(func) {
130
+ return (// @ts-ignore
131
+ curryN(func.length, function () {
132
+ var _ref;
133
+
134
+ var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
135
+ return isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
136
+ })
137
+ );
138
+ };
139
+ var noop$2 = function noop() {};
140
+ var isNotEmpty = /*#__PURE__*/complement$1(isEmpty);
141
+
142
+ var slugify = function slugify(string) {
143
+ return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
144
+ .replace(/&/g, "-and-") // Replace & with 'and'
145
+ .replace(/[^\w-]+/g, "") // Remove all non-word characters
146
+ .replace(/--+/g, "-") // Replace multiple - with single -
147
+ .replace(/^-+/, "") // Trim - from start of text
148
+ .replace(/-+$/, "");
149
+ }; // Trim - from end of text
150
+
151
+ var humanize = function humanize(string) {
152
+ string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
153
+ string = string.charAt(0).toUpperCase() + string.slice(1);
154
+ return string;
155
+ };
156
+ var snakeToCamelCase = function snakeToCamelCase(string) {
157
+ return string.replace(/(_\w)/g, function (letter) {
158
+ return letter[1].toUpperCase();
159
+ });
160
+ };
161
+ var camelToSnakeCase = function camelToSnakeCase(string) {
162
+ return string.replace(/[A-Z]/g, function (letter) {
163
+ return "_".concat(letter.toLowerCase());
164
+ });
165
+ };
123
166
  var capitalize = function capitalize(string) {
124
167
  return string.charAt(0).toUpperCase() + string.slice(1);
125
168
  };
169
+ nullSafe(slugify);
170
+ nullSafe(humanize);
171
+ nullSafe(snakeToCamelCase);
172
+ nullSafe(camelToSnakeCase);
173
+ nullSafe(capitalize);
126
174
 
127
175
  var matchesImpl = function matchesImpl(pattern, object) {
128
176
  var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
@@ -142,6 +190,21 @@ var matchesImpl = function matchesImpl(pattern, object) {
142
190
  var matches = /*#__PURE__*/curry(function (pattern, object) {
143
191
  return matchesImpl(pattern, object);
144
192
  });
193
+ var filterNonNull = function filterNonNull(object) {
194
+ return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
195
+ var _ref6 = _slicedToArray(_ref5, 2),
196
+ v = _ref6[1];
197
+
198
+ return !isNil(v);
199
+ }).map(function (_ref7) {
200
+ var _ref8 = _slicedToArray(_ref7, 2),
201
+ k = _ref8[0],
202
+ v = _ref8[1];
203
+
204
+ return [k, _typeof$3(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
205
+ }));
206
+ };
207
+ nullSafe(filterNonNull);
145
208
 
146
209
  function _defineProperty$1(obj, key, value) {
147
210
  if (key in obj) {
@@ -162,9 +225,6 @@ var removeBy = /*#__PURE__*/curry(function (pattern, array) {
162
225
  return array.filter(complement$1(matches(pattern)));
163
226
  });
164
227
 
165
- var noop$2 = function noop() {};
166
- var isNotEmpty = /*#__PURE__*/complement$1(isEmpty);
167
-
168
228
  var getStorageValue = function getStorageValue(key, defaultValue) {
169
229
  var saved = localStorage.getItem(key);
170
230
  return JSON.parse(saved) || defaultValue;
@@ -51454,7 +51514,7 @@ var languageLoaders = {
51454
51514
  return Promise.resolve().then(function () { return agda$1; });
51455
51515
  }),
51456
51516
  al: createLanguageAsyncLoader("al", function () {
51457
- return Promise.resolve().then(function () { return al; });
51517
+ return Promise.resolve().then(function () { return al$1; });
51458
51518
  }),
51459
51519
  antlr4: createLanguageAsyncLoader("antlr4", function () {
51460
51520
  return Promise.resolve().then(function () { return antlr4$1; });
@@ -51466,7 +51526,7 @@ var languageLoaders = {
51466
51526
  return Promise.resolve().then(function () { return apex$1; });
51467
51527
  }),
51468
51528
  apl: createLanguageAsyncLoader("apl", function () {
51469
- return Promise.resolve().then(function () { return apl$1; });
51529
+ return Promise.resolve().then(function () { return apl; });
51470
51530
  }),
51471
51531
  applescript: createLanguageAsyncLoader("applescript", function () {
51472
51532
  return Promise.resolve().then(function () { return applescript$2; });
@@ -60974,47 +61034,43 @@ var agda$1 = /*#__PURE__*/_mergeNamespaces({
60974
61034
  'default': agda_1
60975
61035
  }, [agda_1]);
60976
61036
 
60977
- var al_1;
60978
- var hasRequiredAl;
60979
-
60980
- function requireAl () {
60981
- if (hasRequiredAl) return al_1;
60982
- hasRequiredAl = 1;
60983
-
60984
- al_1 = al;
60985
- al.displayName = 'al';
60986
- al.aliases = [];
60987
- function al(Prism) {
60988
- // based on https://github.com/microsoft/AL/blob/master/grammar/alsyntax.tmlanguage
60989
- Prism.languages.al = {
60990
- comment: /\/\/.*|\/\*[\s\S]*?\*\//,
60991
- string: {
60992
- pattern: /'(?:''|[^'\r\n])*'(?!')|"(?:""|[^"\r\n])*"(?!")/,
60993
- greedy: true
60994
- },
60995
- function: {
60996
- pattern:
60997
- /(\b(?:event|procedure|trigger)\s+|(?:^|[^.])\.\s*)[a-z_]\w*(?=\s*\()/i,
60998
- lookbehind: true
60999
- },
61000
- keyword: [
61001
- // keywords
61002
- /\b(?:array|asserterror|begin|break|case|do|downto|else|end|event|exit|for|foreach|function|if|implements|in|indataset|interface|internal|local|of|procedure|program|protected|repeat|runonclient|securityfiltering|suppressdispose|temporary|then|to|trigger|until|var|while|with|withevents)\b/i, // objects and metadata that are used like keywords
61003
- /\b(?:action|actions|addafter|addbefore|addfirst|addlast|area|assembly|chartpart|codeunit|column|controladdin|cuegroup|customizes|dataitem|dataset|dotnet|elements|enum|enumextension|extends|field|fieldattribute|fieldelement|fieldgroup|fieldgroups|fields|filter|fixed|grid|group|key|keys|label|labels|layout|modify|moveafter|movebefore|movefirst|movelast|page|pagecustomization|pageextension|part|profile|query|repeater|report|requestpage|schema|separator|systempart|table|tableelement|tableextension|textattribute|textelement|type|usercontrol|value|xmlport)\b/i
61004
- ],
61005
- number:
61006
- /\b(?:0x[\da-f]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(?:F|LL?|U(?:LL?)?)?\b/i,
61007
- boolean: /\b(?:false|true)\b/i,
61008
- variable: /\b(?:Curr(?:FieldNo|Page|Report)|x?Rec|RequestOptionsPage)\b/,
61009
- 'class-name':
61010
- /\b(?:automation|biginteger|bigtext|blob|boolean|byte|char|clienttype|code|completiontriggererrorlevel|connectiontype|database|dataclassification|datascope|date|dateformula|datetime|decimal|defaultlayout|dialog|dictionary|dotnetassembly|dotnettypedeclaration|duration|errorinfo|errortype|executioncontext|executionmode|fieldclass|fieldref|fieldtype|file|filterpagebuilder|guid|httpclient|httpcontent|httpheaders|httprequestmessage|httpresponsemessage|instream|integer|joker|jsonarray|jsonobject|jsontoken|jsonvalue|keyref|list|moduledependencyinfo|moduleinfo|none|notification|notificationscope|objecttype|option|outstream|pageresult|record|recordid|recordref|reportformat|securityfilter|sessionsettings|tableconnectiontype|tablefilter|testaction|testfield|testfilterfield|testpage|testpermissions|testrequestpage|text|textbuilder|textconst|textencoding|time|transactionmodel|transactiontype|variant|verbosity|version|view|views|webserviceactioncontext|webserviceactionresultcode|xmlattribute|xmlattributecollection|xmlcdata|xmlcomment|xmldeclaration|xmldocument|xmldocumenttype|xmlelement|xmlnamespacemanager|xmlnametable|xmlnode|xmlnodelist|xmlprocessinginstruction|xmlreadoptions|xmltext|xmlwriteoptions)\b/i,
61011
- operator: /\.\.|:[=:]|[-+*/]=?|<>|[<>]=?|=|\b(?:and|div|mod|not|or|xor)\b/i,
61012
- punctuation: /[()\[\]{}:.;,]/
61013
- };
61014
- }
61015
- return al_1;
61037
+ var al_1 = al;
61038
+ al.displayName = 'al';
61039
+ al.aliases = [];
61040
+ function al(Prism) {
61041
+ // based on https://github.com/microsoft/AL/blob/master/grammar/alsyntax.tmlanguage
61042
+ Prism.languages.al = {
61043
+ comment: /\/\/.*|\/\*[\s\S]*?\*\//,
61044
+ string: {
61045
+ pattern: /'(?:''|[^'\r\n])*'(?!')|"(?:""|[^"\r\n])*"(?!")/,
61046
+ greedy: true
61047
+ },
61048
+ function: {
61049
+ pattern:
61050
+ /(\b(?:event|procedure|trigger)\s+|(?:^|[^.])\.\s*)[a-z_]\w*(?=\s*\()/i,
61051
+ lookbehind: true
61052
+ },
61053
+ keyword: [
61054
+ // keywords
61055
+ /\b(?:array|asserterror|begin|break|case|do|downto|else|end|event|exit|for|foreach|function|if|implements|in|indataset|interface|internal|local|of|procedure|program|protected|repeat|runonclient|securityfiltering|suppressdispose|temporary|then|to|trigger|until|var|while|with|withevents)\b/i, // objects and metadata that are used like keywords
61056
+ /\b(?:action|actions|addafter|addbefore|addfirst|addlast|area|assembly|chartpart|codeunit|column|controladdin|cuegroup|customizes|dataitem|dataset|dotnet|elements|enum|enumextension|extends|field|fieldattribute|fieldelement|fieldgroup|fieldgroups|fields|filter|fixed|grid|group|key|keys|label|labels|layout|modify|moveafter|movebefore|movefirst|movelast|page|pagecustomization|pageextension|part|profile|query|repeater|report|requestpage|schema|separator|systempart|table|tableelement|tableextension|textattribute|textelement|type|usercontrol|value|xmlport)\b/i
61057
+ ],
61058
+ number:
61059
+ /\b(?:0x[\da-f]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(?:F|LL?|U(?:LL?)?)?\b/i,
61060
+ boolean: /\b(?:false|true)\b/i,
61061
+ variable: /\b(?:Curr(?:FieldNo|Page|Report)|x?Rec|RequestOptionsPage)\b/,
61062
+ 'class-name':
61063
+ /\b(?:automation|biginteger|bigtext|blob|boolean|byte|char|clienttype|code|completiontriggererrorlevel|connectiontype|database|dataclassification|datascope|date|dateformula|datetime|decimal|defaultlayout|dialog|dictionary|dotnetassembly|dotnettypedeclaration|duration|errorinfo|errortype|executioncontext|executionmode|fieldclass|fieldref|fieldtype|file|filterpagebuilder|guid|httpclient|httpcontent|httpheaders|httprequestmessage|httpresponsemessage|instream|integer|joker|jsonarray|jsonobject|jsontoken|jsonvalue|keyref|list|moduledependencyinfo|moduleinfo|none|notification|notificationscope|objecttype|option|outstream|pageresult|record|recordid|recordref|reportformat|securityfilter|sessionsettings|tableconnectiontype|tablefilter|testaction|testfield|testfilterfield|testpage|testpermissions|testrequestpage|text|textbuilder|textconst|textencoding|time|transactionmodel|transactiontype|variant|verbosity|version|view|views|webserviceactioncontext|webserviceactionresultcode|xmlattribute|xmlattributecollection|xmlcdata|xmlcomment|xmldeclaration|xmldocument|xmldocumenttype|xmlelement|xmlnamespacemanager|xmlnametable|xmlnode|xmlnodelist|xmlprocessinginstruction|xmlreadoptions|xmltext|xmlwriteoptions)\b/i,
61064
+ operator: /\.\.|:[=:]|[-+*/]=?|<>|[<>]=?|=|\b(?:and|div|mod|not|or|xor)\b/i,
61065
+ punctuation: /[()\[\]{}:.;,]/
61066
+ };
61016
61067
  }
61017
61068
 
61069
+ var al$1 = /*#__PURE__*/_mergeNamespaces({
61070
+ __proto__: null,
61071
+ 'default': al_1
61072
+ }, [al_1]);
61073
+
61018
61074
  var antlr4_1 = antlr4;
61019
61075
  antlr4.displayName = 'antlr4';
61020
61076
  antlr4.aliases = ['g4'];
@@ -61287,49 +61343,53 @@ var apex$1 = /*#__PURE__*/_mergeNamespaces({
61287
61343
  'default': apex_1
61288
61344
  }, [apex_1]);
61289
61345
 
61290
- var apl_1 = apl;
61291
- apl.displayName = 'apl';
61292
- apl.aliases = [];
61293
- function apl(Prism) {
61294
- Prism.languages.apl = {
61295
- comment: /(?:⍝|#[! ]).*$/m,
61296
- string: {
61297
- pattern: /'(?:[^'\r\n]|'')*'/,
61298
- greedy: true
61299
- },
61300
- number:
61301
- /¯?(?:\d*\.?\b\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:(?:\d+(?:\.\d+)?|\.\d+)(?:e[+¯]?\d+)?|¯|∞))?/i,
61302
- statement: /:[A-Z][a-z][A-Za-z]*\b/,
61303
- 'system-function': {
61304
- pattern: /⎕[A-Z]+/i,
61305
- alias: 'function'
61306
- },
61307
- constant: /[⍬⌾#⎕⍞]/,
61308
- function: /[-+×÷⌈⌊∣|⍳⍸?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⊆⊇⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/,
61309
- 'monadic-operator': {
61310
- pattern: /[\\\/⌿⍀¨⍨⌶&∥]/,
61311
- alias: 'operator'
61312
- },
61313
- 'dyadic-operator': {
61314
- pattern: /[.⍣⍠⍤∘⌸@⌺⍥]/,
61315
- alias: 'operator'
61316
- },
61317
- assignment: {
61318
- pattern: /←/,
61319
- alias: 'keyword'
61320
- },
61321
- punctuation: /[\[;\]()◇⋄]/,
61322
- dfn: {
61323
- pattern: /[{}⍺⍵⍶⍹∇⍫:]/,
61324
- alias: 'builtin'
61325
- }
61326
- };
61327
- }
61346
+ var apl_1;
61347
+ var hasRequiredApl;
61328
61348
 
61329
- var apl$1 = /*#__PURE__*/_mergeNamespaces({
61330
- __proto__: null,
61331
- 'default': apl_1
61332
- }, [apl_1]);
61349
+ function requireApl () {
61350
+ if (hasRequiredApl) return apl_1;
61351
+ hasRequiredApl = 1;
61352
+
61353
+ apl_1 = apl;
61354
+ apl.displayName = 'apl';
61355
+ apl.aliases = [];
61356
+ function apl(Prism) {
61357
+ Prism.languages.apl = {
61358
+ comment: /(?:⍝|#[! ]).*$/m,
61359
+ string: {
61360
+ pattern: /'(?:[^'\r\n]|'')*'/,
61361
+ greedy: true
61362
+ },
61363
+ number:
61364
+ /¯?(?:\d*\.?\b\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:(?:\d+(?:\.\d+)?|\.\d+)(?:e[+¯]?\d+)?|¯|∞))?/i,
61365
+ statement: /:[A-Z][a-z][A-Za-z]*\b/,
61366
+ 'system-function': {
61367
+ pattern: /⎕[A-Z]+/i,
61368
+ alias: 'function'
61369
+ },
61370
+ constant: /[⍬⌾#⎕⍞]/,
61371
+ function: /[-+×÷⌈⌊∣|⍳⍸?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⊆⊇⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/,
61372
+ 'monadic-operator': {
61373
+ pattern: /[\\\/⌿⍀¨⍨⌶&∥]/,
61374
+ alias: 'operator'
61375
+ },
61376
+ 'dyadic-operator': {
61377
+ pattern: /[.⍣⍠⍤∘⌸@⌺⍥]/,
61378
+ alias: 'operator'
61379
+ },
61380
+ assignment: {
61381
+ pattern: /←/,
61382
+ alias: 'keyword'
61383
+ },
61384
+ punctuation: /[\[;\]()◇⋄]/,
61385
+ dfn: {
61386
+ pattern: /[{}⍺⍵⍶⍹∇⍫:]/,
61387
+ alias: 'builtin'
61388
+ }
61389
+ };
61390
+ }
61391
+ return apl_1;
61392
+ }
61333
61393
 
61334
61394
  var applescript_1 = applescript$1;
61335
61395
  applescript$1.displayName = 'applescript';
@@ -84053,11 +84113,11 @@ refractor.register(abnf_1);
84053
84113
  refractor.register(actionscript_1);
84054
84114
  refractor.register(ada_1);
84055
84115
  refractor.register(agda_1);
84056
- refractor.register(requireAl());
84116
+ refractor.register(al_1);
84057
84117
  refractor.register(antlr4_1);
84058
84118
  refractor.register(apacheconf_1);
84059
84119
  refractor.register(apex_1);
84060
- refractor.register(apl_1);
84120
+ refractor.register(requireApl());
84061
84121
  refractor.register(applescript_1);
84062
84122
  refractor.register(aql_1);
84063
84123
  refractor.register(arduino_1);
@@ -86356,6 +86416,33 @@ var createContext = function createContext(initialValue) {
86356
86416
  }), _ref3;
86357
86417
  };
86358
86418
 
86419
+ var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
86420
+ return function (partial) {
86421
+ return set(function (previous) {
86422
+ if (typeof partial === "function") partial = partial(previous);
86423
+ var isOverwritingActions = toPairs(partial).some(function (_ref) {
86424
+ var _ref2 = _slicedToArray(_ref, 2),
86425
+ key = _ref2[0],
86426
+ value = _ref2[1];
86427
+
86428
+ return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && value !== previous[key];
86429
+ });
86430
+
86431
+ if (isOverwritingActions) {
86432
+ throw new Error("Actions should not be modified");
86433
+ }
86434
+
86435
+ return partial;
86436
+ }, false);
86437
+ };
86438
+ };
86439
+
86440
+ var withImmutableActions = function withImmutableActions(config) {
86441
+ return function (set, get, api) {
86442
+ return config(setWithoutModifyingActions(set), get, api);
86443
+ };
86444
+ };
86445
+
86359
86446
  var _path$1, _path2, _path3, _path4, _path5, _path6, _path7;
86360
86447
 
86361
86448
  function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
@@ -87953,12 +88040,12 @@ var zephir = /*#__PURE__*/_mergeNamespaces({
87953
88040
  'default': zephirExports
87954
88041
  }, [zephirExports]);
87955
88042
 
87956
- var alExports = requireAl();
88043
+ var aplExports = requireApl();
87957
88044
 
87958
- var al = /*#__PURE__*/_mergeNamespaces({
88045
+ var apl = /*#__PURE__*/_mergeNamespaces({
87959
88046
  __proto__: null,
87960
- 'default': alExports
87961
- }, [alExports]);
88047
+ 'default': aplExports
88048
+ }, [aplExports]);
87962
88049
 
87963
88050
  var avroIdlExports = requireAvroIdl();
87964
88051
 
@@ -89717,4 +89804,4 @@ var zig = /*#__PURE__*/_mergeNamespaces({
89717
89804
  'default': zigExports
89718
89805
  }, [zigExports]);
89719
89806
 
89720
- export { Columns, DateFormat, ErrorPage, HoneybadgerErrorBoundary, SignIn as LoginPage, NeetoWidget, PrivateRoute, Sidebar, TimeFormat, createContext, useDebounce, useFuncDebounce, useIsElementVisibleInDom, useLocalStorage, useOnClickOutside, usePrevious, useUpdateEffect };
89807
+ export { Columns, DateFormat, ErrorPage, HoneybadgerErrorBoundary, SignIn as LoginPage, NeetoWidget, PrivateRoute, Sidebar, TimeFormat, createContext, useDebounce, useFuncDebounce, useIsElementVisibleInDom, useLocalStorage, useOnClickOutside, usePrevious, useUpdateEffect, withImmutableActions };
package/utils.cjs.js CHANGED
@@ -534,6 +534,22 @@ try {
534
534
  }
535
535
  }
536
536
 
537
+ /**
538
+ * @template {Function} T
539
+ * @param {T} func
540
+ * @returns {T}
541
+ */
542
+
543
+ var nullSafe = function nullSafe(func) {
544
+ return (// @ts-ignore
545
+ ramda.curryN(func.length, function () {
546
+ var _ref;
547
+
548
+ var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
549
+ return ramda.isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
550
+ })
551
+ );
552
+ };
537
553
  var getRandomInt = function getRandomInt() {
538
554
  var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
539
555
  var b = arguments.length > 1 ? arguments[1] : undefined;
@@ -559,6 +575,39 @@ function _typeof(obj) {
559
575
  }, _typeof(obj);
560
576
  }
561
577
 
578
+ var slugify = function slugify(string) {
579
+ return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
580
+ .replace(/&/g, "-and-") // Replace & with 'and'
581
+ .replace(/[^\w-]+/g, "") // Remove all non-word characters
582
+ .replace(/--+/g, "-") // Replace multiple - with single -
583
+ .replace(/^-+/, "") // Trim - from start of text
584
+ .replace(/-+$/, "");
585
+ }; // Trim - from end of text
586
+
587
+ var humanize = function humanize(string) {
588
+ string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
589
+ string = string.charAt(0).toUpperCase() + string.slice(1);
590
+ return string;
591
+ };
592
+ var snakeToCamelCase = function snakeToCamelCase(string) {
593
+ return string.replace(/(_\w)/g, function (letter) {
594
+ return letter[1].toUpperCase();
595
+ });
596
+ };
597
+ var camelToSnakeCase = function camelToSnakeCase(string) {
598
+ return string.replace(/[A-Z]/g, function (letter) {
599
+ return "_".concat(letter.toLowerCase());
600
+ });
601
+ };
602
+ var capitalize = function capitalize(string) {
603
+ return string.charAt(0).toUpperCase() + string.slice(1);
604
+ };
605
+ nullSafe(slugify);
606
+ nullSafe(humanize);
607
+ nullSafe(snakeToCamelCase);
608
+ nullSafe(camelToSnakeCase);
609
+ nullSafe(capitalize);
610
+
562
611
  var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
563
612
  var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
564
613
 
@@ -589,6 +638,21 @@ var preprocessForSerialization = function preprocessForSerialization(object) {
589
638
  return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
590
639
  });
591
640
  };
641
+ var filterNonNull = function filterNonNull(object) {
642
+ return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
643
+ var _ref6 = _slicedToArray(_ref5, 2),
644
+ v = _ref6[1];
645
+
646
+ return !ramda.isNil(v);
647
+ }).map(function (_ref7) {
648
+ var _ref8 = _slicedToArray(_ref7, 2),
649
+ k = _ref8[0],
650
+ v = _ref8[1];
651
+
652
+ return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
653
+ }));
654
+ };
655
+ nullSafe(filterNonNull);
592
656
 
593
657
  /* eslint complexity: [2, 18], max-statements: [2, 33] */
594
658
  var shams = function hasSymbols() {
package/utils.d.ts CHANGED
@@ -15,14 +15,14 @@ export function withEventTargetValue(
15
15
  export function getSubdomain(): string;
16
16
  export function simulateApiCall<T>(
17
17
  result: T,
18
- error: any,
18
+ error?: any,
19
19
  errorProbability?: number,
20
20
  delayMs?: number
21
21
  ): Promise<T>;
22
22
 
23
23
  export function copyToClipboard(
24
24
  text: string,
25
- configs: { showToastr: boolean; message: string }
25
+ configs?: { showToastr?: boolean; message?: string }
26
26
  ): void;
27
27
 
28
28
  export function buildUrl(route: string, params: object): string;
package/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { values, curry, toPairs, pipe, omit, isEmpty } from 'ramda';
2
+ import { values, curryN, isNil, curry, toPairs, pipe, omit, isEmpty } from 'ramda';
3
3
  import { Toastr } from '@bigbinary/neetoui';
4
4
  import i18next from 'i18next';
5
5
  import require$$0 from 'util';
@@ -521,6 +521,22 @@ try {
521
521
  }
522
522
  }
523
523
 
524
+ /**
525
+ * @template {Function} T
526
+ * @param {T} func
527
+ * @returns {T}
528
+ */
529
+
530
+ var nullSafe = function nullSafe(func) {
531
+ return (// @ts-ignore
532
+ curryN(func.length, function () {
533
+ var _ref;
534
+
535
+ var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
536
+ return isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
537
+ })
538
+ );
539
+ };
524
540
  var getRandomInt = function getRandomInt() {
525
541
  var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
526
542
  var b = arguments.length > 1 ? arguments[1] : undefined;
@@ -546,6 +562,39 @@ function _typeof(obj) {
546
562
  }, _typeof(obj);
547
563
  }
548
564
 
565
+ var slugify = function slugify(string) {
566
+ return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
567
+ .replace(/&/g, "-and-") // Replace & with 'and'
568
+ .replace(/[^\w-]+/g, "") // Remove all non-word characters
569
+ .replace(/--+/g, "-") // Replace multiple - with single -
570
+ .replace(/^-+/, "") // Trim - from start of text
571
+ .replace(/-+$/, "");
572
+ }; // Trim - from end of text
573
+
574
+ var humanize = function humanize(string) {
575
+ string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
576
+ string = string.charAt(0).toUpperCase() + string.slice(1);
577
+ return string;
578
+ };
579
+ var snakeToCamelCase = function snakeToCamelCase(string) {
580
+ return string.replace(/(_\w)/g, function (letter) {
581
+ return letter[1].toUpperCase();
582
+ });
583
+ };
584
+ var camelToSnakeCase = function camelToSnakeCase(string) {
585
+ return string.replace(/[A-Z]/g, function (letter) {
586
+ return "_".concat(letter.toLowerCase());
587
+ });
588
+ };
589
+ var capitalize = function capitalize(string) {
590
+ return string.charAt(0).toUpperCase() + string.slice(1);
591
+ };
592
+ nullSafe(slugify);
593
+ nullSafe(humanize);
594
+ nullSafe(snakeToCamelCase);
595
+ nullSafe(camelToSnakeCase);
596
+ nullSafe(capitalize);
597
+
549
598
  var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
550
599
  var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
551
600
 
@@ -576,6 +625,21 @@ var preprocessForSerialization = function preprocessForSerialization(object) {
576
625
  return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
577
626
  });
578
627
  };
628
+ var filterNonNull = function filterNonNull(object) {
629
+ return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
630
+ var _ref6 = _slicedToArray(_ref5, 2),
631
+ v = _ref6[1];
632
+
633
+ return !isNil(v);
634
+ }).map(function (_ref7) {
635
+ var _ref8 = _slicedToArray(_ref7, 2),
636
+ k = _ref8[0],
637
+ v = _ref8[1];
638
+
639
+ return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
640
+ }));
641
+ };
642
+ nullSafe(filterNonNull);
579
643
 
580
644
  /* eslint complexity: [2, 18], max-statements: [2, 33] */
581
645
  var shams = function hasSymbols() {