@react-fabric/utilities 1.0.0-beta.9 → 1.0.2

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.
Files changed (168) hide show
  1. package/dist/cjs/css/boundingBox.js +72 -0
  2. package/dist/cjs/css/cn.js +39 -0
  3. package/dist/cjs/css/imageColorset.js +96 -0
  4. package/dist/cjs/data/countries.js +98 -0
  5. package/dist/cjs/{_fileType.js → data/fileType.js} +37 -19
  6. package/dist/cjs/data/format.js +136 -0
  7. package/dist/cjs/helpers/debounce.js +63 -0
  8. package/dist/cjs/{useLogger.js → helpers/getLogger.js} +96 -96
  9. package/dist/cjs/helpers/lonlat.js +99 -0
  10. package/dist/cjs/index.js +99 -76
  11. package/dist/cjs/lists/dedupe.js +54 -0
  12. package/dist/cjs/lists/flatten.js +66 -0
  13. package/dist/cjs/{_getByPath.js → lists/getByPath.js} +58 -37
  14. package/dist/cjs/lists/groupBy.js +49 -0
  15. package/dist/cjs/matchers/compare.js +70 -0
  16. package/dist/cjs/matchers/isEmpty.js +34 -0
  17. package/dist/cjs/matchers/isEqual.js +82 -0
  18. package/dist/cjs/matchers/nullChecks.js +61 -0
  19. package/dist/cjs/matchers/typeChecks.js +127 -0
  20. package/dist/cjs/strings/ascii.js +105 -0
  21. package/dist/cjs/strings/hash.js +75 -0
  22. package/dist/cjs/strings/interpolate.js +47 -0
  23. package/dist/cjs/strings/matchString.js +54 -0
  24. package/dist/cjs/strings/template.js +48 -0
  25. package/dist/cjs/strings/tokenize.js +83 -0
  26. package/dist/cjs/utils/mergeRefs.js +56 -0
  27. package/dist/esm/css/boundingBox.js +71 -0
  28. package/dist/esm/css/cn.js +39 -0
  29. package/dist/esm/css/imageColorset.js +96 -0
  30. package/dist/esm/data/countries.js +98 -0
  31. package/dist/esm/{_fileType.js → data/fileType.js} +37 -19
  32. package/dist/esm/data/format.js +138 -0
  33. package/dist/esm/helpers/debounce.js +63 -0
  34. package/dist/esm/{useLogger.js → helpers/getLogger.js} +96 -96
  35. package/dist/esm/helpers/lonlat.js +97 -0
  36. package/dist/esm/index.js +54 -36
  37. package/dist/esm/lists/dedupe.js +54 -0
  38. package/dist/esm/lists/flatten.js +65 -0
  39. package/dist/esm/{_getByPath.js → lists/getByPath.js} +50 -29
  40. package/dist/esm/lists/groupBy.js +49 -0
  41. package/dist/esm/matchers/compare.js +70 -0
  42. package/dist/esm/matchers/isEmpty.js +34 -0
  43. package/dist/esm/matchers/isEqual.js +82 -0
  44. package/dist/esm/matchers/nullChecks.js +58 -0
  45. package/dist/esm/matchers/typeChecks.js +119 -0
  46. package/dist/esm/strings/ascii.js +105 -0
  47. package/dist/esm/strings/hash.js +73 -0
  48. package/dist/esm/strings/interpolate.js +47 -0
  49. package/dist/esm/strings/matchString.js +54 -0
  50. package/dist/esm/strings/template.js +48 -0
  51. package/dist/esm/strings/tokenize.js +82 -0
  52. package/dist/esm/utils/mergeRefs.js +56 -0
  53. package/dist/types/css/boundingBox.d.ts +46 -0
  54. package/dist/types/css/cn.d.ts +26 -0
  55. package/dist/types/css/imageColorset.d.ts +37 -0
  56. package/dist/types/data/countries.d.ts +136 -0
  57. package/dist/types/{_fileType.d.ts → data/fileType.d.ts} +41 -1
  58. package/dist/types/data/format.d.ts +122 -0
  59. package/dist/types/helpers/debounce.d.ts +38 -0
  60. package/dist/types/helpers/getLogger.d.ts +49 -0
  61. package/dist/types/helpers/lonlat.d.ts +48 -0
  62. package/dist/types/index.d.ts +54 -20
  63. package/dist/types/lists/dedupe.d.ts +36 -0
  64. package/dist/types/lists/flatten.d.ts +47 -0
  65. package/dist/types/lists/getByPath.d.ts +45 -0
  66. package/dist/types/lists/groupBy.d.ts +36 -0
  67. package/dist/types/matchers/compare.d.ts +38 -0
  68. package/dist/types/matchers/isEmpty.d.ts +38 -0
  69. package/dist/types/matchers/isEqual.d.ts +39 -0
  70. package/dist/types/matchers/nullChecks.d.ts +43 -0
  71. package/dist/types/matchers/typeChecks.d.ts +107 -0
  72. package/dist/types/strings/ascii.d.ts +34 -0
  73. package/dist/types/strings/hash.d.ts +46 -0
  74. package/dist/types/strings/interpolate.d.ts +34 -0
  75. package/dist/types/strings/matchString.d.ts +41 -0
  76. package/dist/types/strings/template.d.ts +35 -0
  77. package/dist/types/strings/tokenize.d.ts +44 -0
  78. package/dist/types/utils/mergeRefs.d.ts +36 -0
  79. package/package.json +13 -11
  80. package/src/css/boundingBox.ts +80 -0
  81. package/src/css/cn.ts +32 -0
  82. package/src/css/imageColorset.ts +97 -0
  83. package/src/data/countries.ts +126 -0
  84. package/src/{_fileType.ts → data/fileType.ts} +72 -89
  85. package/src/data/format.ts +192 -0
  86. package/src/helpers/debounce.ts +49 -0
  87. package/src/{useLogger.ts → helpers/getLogger.ts} +52 -101
  88. package/src/helpers/lonlat.ts +124 -0
  89. package/src/index.ts +57 -37
  90. package/src/lists/dedupe.ts +46 -0
  91. package/src/lists/flatten.ts +56 -0
  92. package/src/lists/getByPath.ts +122 -0
  93. package/src/lists/groupBy.ts +47 -0
  94. package/src/matchers/compare.ts +64 -0
  95. package/src/matchers/isEmpty.ts +54 -0
  96. package/src/matchers/isEqual.ts +71 -0
  97. package/src/matchers/nullChecks.ts +55 -0
  98. package/src/matchers/typeChecks.ts +146 -0
  99. package/src/strings/ascii.ts +100 -0
  100. package/src/strings/hash.ts +68 -0
  101. package/src/strings/interpolate.ts +42 -0
  102. package/src/strings/matchString.ts +49 -0
  103. package/src/strings/template.ts +43 -0
  104. package/src/strings/tokenize.ts +77 -0
  105. package/src/utils/mergeRefs.ts +47 -0
  106. package/src/{yup.ts → utils/yup.ts} +3 -3
  107. package/dist/cjs/_ascii.js +0 -76
  108. package/dist/cjs/_boundingBox.js +0 -59
  109. package/dist/cjs/_countries.js +0 -2805
  110. package/dist/cjs/_debounce.js +0 -53
  111. package/dist/cjs/_dedupe.js +0 -63
  112. package/dist/cjs/_fetch.js +0 -128
  113. package/dist/cjs/_format.js +0 -118
  114. package/dist/cjs/_hash.js +0 -67
  115. package/dist/cjs/_interpolate.js +0 -47
  116. package/dist/cjs/_isEqual.js +0 -108
  117. package/dist/cjs/_isType.js +0 -98
  118. package/dist/cjs/_mergeRefs.js +0 -40
  119. package/dist/cjs/_tokenize.js +0 -67
  120. package/dist/cjs/getImageColorset.js +0 -70
  121. package/dist/esm/_ascii.js +0 -76
  122. package/dist/esm/_boundingBox.js +0 -58
  123. package/dist/esm/_countries.js +0 -2805
  124. package/dist/esm/_debounce.js +0 -53
  125. package/dist/esm/_dedupe.js +0 -60
  126. package/dist/esm/_fetch.js +0 -128
  127. package/dist/esm/_format.js +0 -120
  128. package/dist/esm/_hash.js +0 -65
  129. package/dist/esm/_interpolate.js +0 -46
  130. package/dist/esm/_isEqual.js +0 -106
  131. package/dist/esm/_isType.js +0 -85
  132. package/dist/esm/_mergeRefs.js +0 -40
  133. package/dist/esm/_tokenize.js +0 -66
  134. package/dist/esm/getImageColorset.js +0 -70
  135. package/dist/types/_ascii.d.ts +0 -5
  136. package/dist/types/_boundingBox.d.ts +0 -10
  137. package/dist/types/_countries.d.ts +0 -85
  138. package/dist/types/_debounce.d.ts +0 -8
  139. package/dist/types/_dedupe.d.ts +0 -4
  140. package/dist/types/_fetch.d.ts +0 -23
  141. package/dist/types/_format.d.ts +0 -27
  142. package/dist/types/_getByPath.d.ts +0 -10
  143. package/dist/types/_hash.d.ts +0 -16
  144. package/dist/types/_interpolate.d.ts +0 -6
  145. package/dist/types/_isEqual.d.ts +0 -15
  146. package/dist/types/_isType.d.ts +0 -14
  147. package/dist/types/_mergeRefs.d.ts +0 -1
  148. package/dist/types/_tokenize.d.ts +0 -8
  149. package/dist/types/getImageColorset.d.ts +0 -1
  150. package/dist/types/useLogger.d.ts +0 -25
  151. package/src/_ascii.ts +0 -93
  152. package/src/_boundingBox.ts +0 -72
  153. package/src/_countries.ts +0 -3046
  154. package/src/_debounce.ts +0 -42
  155. package/src/_dedupe.ts +0 -56
  156. package/src/_fetch.ts +0 -109
  157. package/src/_format.ts +0 -141
  158. package/src/_getByPath.ts +0 -108
  159. package/src/_hash.ts +0 -62
  160. package/src/_interpolate.ts +0 -42
  161. package/src/_isEqual.ts +0 -102
  162. package/src/_isType.ts +0 -105
  163. package/src/_mergeRefs.ts +0 -33
  164. package/src/_tokenize.ts +0 -69
  165. package/src/getImageColorset.ts +0 -81
  166. /package/dist/cjs/{yup.js → utils/yup.js} +0 -0
  167. /package/dist/esm/{yup.js → utils/yup.js} +0 -0
  168. /package/dist/types/{yup.d.ts → utils/yup.d.ts} +0 -0
@@ -1,53 +0,0 @@
1
- 'use client';
2
-
3
- /*
4
- * React Fabric
5
- * @version: 1.0.0
6
- *
7
- *
8
- * The MIT License (MIT)
9
- * Copyright (c) 2024 Adarsh Pastakia
10
- *
11
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
12
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
13
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
15
- * subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in all copies or substantial
18
- * portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
21
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
- */
25
-
26
- /* istanbul ignore file */
27
-
28
- /**
29
- * debounce callback
30
- * @internal
31
- */
32
- var debounce = function debounce(fn) {
33
- var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
34
- /** ***************** create debounce timer id using callback hash *******************/
35
- var _timer;
36
-
37
- /** ***************** return debounced function *******************/
38
- var cb = function cb() {
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- clearTimeout(_timer);
43
- if (typeof window !== "undefined") _timer = window.setTimeout(function () {
44
- return fn === null || fn === void 0 ? void 0 : fn.apply(void 0, args);
45
- }, timeout);
46
- };
47
- cb.cancel = function () {
48
- return clearTimeout(_timer);
49
- };
50
- return cb;
51
- };
52
-
53
- export { debounce };
@@ -1,60 +0,0 @@
1
- 'use client';
2
-
3
- import { isEmpty } from './_isType.js';
4
-
5
- /*
6
- * React Fabric
7
- * @version: 1.0.0
8
- *
9
- *
10
- * The MIT License (MIT)
11
- * Copyright (c) 2024 Adarsh Pastakia
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
14
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
15
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
17
- * subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all copies or substantial
20
- * portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
23
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- var dedupe = function dedupe(list, key) {
29
- var filtered = list.filter(function (i) {
30
- return !isEmpty(i);
31
- });
32
- if (!key) {
33
- return Array.from(new Set(filtered).values());
34
- }
35
- return Array.from(new Map(filtered.map(function (obj) {
36
- var _obj$key;
37
- return [(_obj$key = obj[key]) !== null && _obj$key !== void 0 ? _obj$key : obj, obj];
38
- })).values());
39
- };
40
- var flatten = function flatten(list) {
41
- return list.flat(5).filter(function (i) {
42
- return !isEmpty(i);
43
- });
44
- };
45
- var flattenAndDedupe = function flattenAndDedupe() {
46
- var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
47
- var key = arguments.length > 1 ? arguments[1] : undefined;
48
- return dedupe(flatten(list), key);
49
- };
50
- var groupBy = function groupBy(list, prop, missingKey) {
51
- return list.reduce(function (r, i) {
52
- var _i$prop;
53
- var key = (_i$prop = i[prop]) !== null && _i$prop !== void 0 ? _i$prop : missingKey;
54
- if (!r[key]) r[key] = [];
55
- r[key].push(i);
56
- return r;
57
- }, {});
58
- };
59
-
60
- export { dedupe, flatten, flattenAndDedupe, groupBy };
@@ -1,128 +0,0 @@
1
- 'use client';
2
-
3
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
- import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
5
- import _regeneratorRuntime from '@babel/runtime/regenerator';
6
- import { isString } from './_isType.js';
7
-
8
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
- 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; }
10
- var _signals = new Map();
11
-
12
- /**
13
- * Fetch helper
14
- * @param method
15
- * @param url
16
- * @param options.headers
17
- * @param options.body
18
- * @param options.signal
19
- * @internal
20
- */
21
- var _fetch = /*#__PURE__*/function () {
22
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(method, url, _ref) {
23
- var _ref$headers, headers, body, signal, options, _s, ac;
24
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
25
- while (1) switch (_context2.prev = _context2.next) {
26
- case 0:
27
- _ref$headers = _ref.headers, headers = _ref$headers === void 0 ? {} : _ref$headers, body = _ref.body, signal = _ref.signal;
28
- options = {
29
- method: method
30
- };
31
- headers.accept = "application/json";
32
- if (method === "post" || method === "put") {
33
- options.body = body;
34
- /** ***************** set body to json when not FormData *******************/
35
- if (!(body instanceof FormData)) {
36
- headers["content-type"] = "application/json";
37
- options.body = JSON.stringify(body);
38
- }
39
- }
40
-
41
- /** ***************** reset abort signal *******************/
42
- if (signal && isString(signal)) {
43
- if (_signals.has(signal)) {
44
- _s = _signals.get(signal);
45
- _s === null || _s === void 0 || _s.abort();
46
- _signals["delete"](signal);
47
- }
48
- ac = new AbortController();
49
- options.signal = ac.signal;
50
- _signals.set(signal, ac);
51
- } else if (signal instanceof AbortSignal) {
52
- options.signal = signal;
53
- }
54
- _context2.next = 7;
55
- return fetch(url, _objectSpread(_objectSpread({}, options), {}, {
56
- headers: headers
57
- })).then( /*#__PURE__*/function () {
58
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resp) {
59
- return _regeneratorRuntime.wrap(function _callee$(_context) {
60
- while (1) switch (_context.prev = _context.next) {
61
- case 0:
62
- if (!(resp.status >= 200 && resp.status < 300)) {
63
- _context.next = 4;
64
- break;
65
- }
66
- _context.next = 3;
67
- return resp.json();
68
- case 3:
69
- return _context.abrupt("return", _context.sent);
70
- case 4:
71
- throw {
72
- status: resp.status,
73
- code: -1,
74
- message: resp.statusText
75
- };
76
- case 5:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee);
81
- }));
82
- return function (_x4) {
83
- return _ref3.apply(this, arguments);
84
- };
85
- }()).then(function (resp) {
86
- var _ref4, _resp$error_code, _ref5, _resp$error_message;
87
- /** ***************** check for possible error code propeties in response *******************/
88
- var code = (_ref4 = (_resp$error_code = resp.error_code) !== null && _resp$error_code !== void 0 ? _resp$error_code : resp.errorCode) !== null && _ref4 !== void 0 ? _ref4 : resp.error;
89
- var message = (_ref5 = (_resp$error_message = resp.error_message) !== null && _resp$error_message !== void 0 ? _resp$error_message : resp.errorMessage) !== null && _ref5 !== void 0 ? _ref5 : resp.message;
90
- if (resp.status === "error" || code) {
91
- // eslint-disable-next-line @typescript-eslint/no-throw-literal
92
- throw {
93
- status: 500,
94
- code: code,
95
- message: message
96
- };
97
- }
98
- return resp;
99
- });
100
- case 7:
101
- return _context2.abrupt("return", _context2.sent);
102
- case 8:
103
- case "end":
104
- return _context2.stop();
105
- }
106
- }, _callee2);
107
- }));
108
- return function _fetch(_x, _x2, _x3) {
109
- return _ref2.apply(this, arguments);
110
- };
111
- }();
112
-
113
- /** ***************** attach isAborted helper to fetch method *******************/
114
- _fetch.isAborted = function (_ref6) {
115
- var name = _ref6.name;
116
- return name === "AbortError";
117
- };
118
-
119
- /** ***************** attach abort helper to fetch method *******************/
120
- _fetch.abort = function (signal) {
121
- if (_signals.has(signal)) {
122
- var _s = _signals.get(signal);
123
- _s === null || _s === void 0 || _s.abort();
124
- _signals["delete"](signal);
125
- }
126
- };
127
-
128
- export { _fetch };
@@ -1,120 +0,0 @@
1
- 'use client';
2
-
3
- import { format, differenceInDays, parseISO } from 'date-fns';
4
- import { parsePhoneNumberFromString } from 'libphonenumber-js';
5
- import numeral from 'numeral';
6
- import Countries from './_countries.js';
7
- import { isEmpty, isNil } from './_isType.js';
8
-
9
- /*
10
- * React Fabric
11
- * @version: 1.0.0
12
- *
13
- *
14
- * The MIT License (MIT)
15
- * Copyright (c) 2024 Adarsh Pastakia
16
- *
17
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
18
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
19
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
20
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
21
- * subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all copies or substantial
24
- * portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
27
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- */
31
-
32
-
33
- // eslint-disable-next-line @typescript-eslint/no-namespace
34
- var Format;
35
- (function (_Format) {
36
- /** ***************** get phone number object using `libphonenumber-js` *******************/
37
- var getPhone = function getPhone(value, country) {
38
- var phone = value.match(/^[0+]/) != null ? value.replace(/^00/, "+") : "+".concat(value);
39
- var number = parsePhoneNumberFromString(phone, country);
40
- /* istanbul ignore next */
41
- return number !== null && number !== void 0 ? number : {
42
- country: "",
43
- formatInternational: function formatInternational() {
44
- return value;
45
- }
46
- };
47
- };
48
-
49
- /** ***************** common number format method using `numeral` *******************/
50
- var numberFormat = function numberFormat(number) {
51
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "0,0[.]00a";
52
- if (isNil(number)) {
53
- return "";
54
- }
55
- var prefix = "".concat(number).startsWith("+") ? "+" : "";
56
- return prefix + numeral(number).format(format);
57
- };
58
- var makeDuration = function makeDuration(value) {
59
- var fmt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "HH:mm:ss.SSS";
60
- if (!isNaN(value)) {
61
- var days = differenceInDays(value, 0);
62
- var prefix = days > 0 ? "".concat(days, "d:") : "";
63
- var time = format(parseISO(new Date(value).toISOString().replace("Z", "")), fmt);
64
- if (!prefix) time = time.replace(/^00:/, "");
65
- return "".concat(prefix).concat(time);
66
- }
67
- };
68
-
69
- /** ***************** format phone number using `libphonenumber-js` *******************/
70
- _Format.phone = function (value) {
71
- var _phone$country;
72
- var country = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "AE";
73
- var useCss = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
74
- if (isEmpty(value) || value.length < 6 || !/^[\d+\s\-()]+$/.test(value)) return value;
75
- var phone = getPhone(value, country);
76
- /* istanbul ignore next */
77
- return "".concat(useCss ? "<span class=\"flag ".concat(phone.country, "\"></span>") : Countries.emoji((_phone$country = phone.country) !== null && _phone$country !== void 0 ? _phone$country : ""), " ").concat(phone.formatInternational());
78
- };
79
- _Format.number = function (number, format) {
80
- return numberFormat(number, format);
81
- };
82
- _Format.bytes = function (number) {
83
- return numberFormat(number, "0,0[.]00b");
84
- };
85
- _Format.percent = function (number) {
86
- return numberFormat(number, "0,0[.]00%");
87
- };
88
- _Format.date = function (date) {
89
- var fmt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "d-M-y";
90
- return date ? format(new Date(date), fmt) : "";
91
- };
92
- _Format.duration = function (number, isFraction) {
93
- if (isNil(number)) {
94
- return "00:00.000";
95
- }
96
- if (number === Infinity) {
97
- return "∞";
98
- }
99
- var value = parseFloat("".concat(number)) * (isFraction ? 1000 : 1);
100
- if (!isNaN(value)) {
101
- return makeDuration(value);
102
- }
103
- return "00:00.000";
104
- };
105
- _Format.durationSeconds = function (number, isFraction) {
106
- if (isNil(number)) {
107
- return "00:00";
108
- }
109
- if (number === Infinity) {
110
- return "∞";
111
- }
112
- var value = parseFloat("".concat(number)) * (isFraction ? 1000 : 1);
113
- if (!isNaN(value)) {
114
- return makeDuration(value, "HH:mm:ss");
115
- }
116
- return "00:00";
117
- };
118
- })(Format || (Format = {}));
119
-
120
- export { Format };
package/dist/esm/_hash.js DELETED
@@ -1,65 +0,0 @@
1
- 'use client';
2
-
3
- import { isEmpty } from './_isType.js';
4
-
5
- /*
6
- * React Fabric
7
- * @version: 1.0.0
8
- *
9
- *
10
- * The MIT License (MIT)
11
- * Copyright (c) 2024 Adarsh Pastakia
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
14
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
15
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
17
- * subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all copies or substantial
20
- * portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
23
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
-
29
- /**
30
- * calculate hash from string
31
- * @param str
32
- * @internal
33
- */
34
- var hash = function hash(str) {
35
- var hash = 0;
36
- var i;
37
- var chr;
38
- if (isEmpty(str)) return hash;
39
- for (i = 0; i < str.length; i++) {
40
- chr = str.charCodeAt(i);
41
- hash = (hash << 5) - hash + chr;
42
- hash |= 0; // Convert to 32bit integer
43
- }
44
- return hash;
45
- };
46
-
47
- /**
48
- * generate short hash from current time
49
- * @internal
50
- */
51
- var shortHash = function shortHash() {
52
- return (new Date().getTime() + Math.trunc(Math.random() * 1000)).toString(36);
53
- };
54
-
55
- /**
56
- * generate uuid using `crypto.getRandomValues`
57
- * @internal
58
- */
59
- var uuid = function uuid() {
60
- return [1e7, 1e3, 4e3, 8e3, 1e11].join("-").replace(/[018]/g, function (c) {
61
- return (+c ^ Math.random() * 16 & 15 >> +c / 4).toString(16);
62
- });
63
- };
64
-
65
- export { hash, shortHash, uuid };
@@ -1,46 +0,0 @@
1
- 'use client';
2
-
3
- import { getByPath } from './_getByPath.js';
4
-
5
- /*
6
- * React Fabric
7
- * @version: 1.0.0
8
- *
9
- *
10
- * The MIT License (MIT)
11
- * Copyright (c) 2024 Adarsh Pastakia
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
14
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
15
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
17
- * subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all copies or substantial
20
- * portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
23
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
-
29
- /**
30
- * interpolate string template using model
31
- * @internal
32
- */
33
- var interpolate = function interpolate(str, model) {
34
- return str.replace(/\${([^{}]*)}/g, function (a, b) {
35
- var r = getByPath(model, b);
36
- return typeof r === "string" || typeof r === "number" ? "".concat(r) : "";
37
- });
38
- };
39
- var renderTemplate = function renderTemplate(str, model) {
40
- return str.replace(/{{([^{}]*)}}/g, function (a, b) {
41
- var r = getByPath(model, b);
42
- return typeof r === "string" || typeof r === "number" ? "".concat(r) : "";
43
- });
44
- };
45
-
46
- export { interpolate, renderTemplate };
@@ -1,106 +0,0 @@
1
- 'use client';
2
-
3
- import { ascii } from './_ascii.js';
4
- import { isString, isNumber, isBoolean, isObject } from './_isType.js';
5
-
6
- /*
7
- * React Fabric
8
- * @version: 1.0.0
9
- *
10
- *
11
- * The MIT License (MIT)
12
- * Copyright (c) 2024 Adarsh Pastakia
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
15
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
16
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all copies or substantial
21
- * portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
24
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
- */
28
-
29
-
30
- /**
31
- * check equality of objects
32
- * @internal
33
- */
34
- var isEqual = function isEqual(obj, test) {
35
- if (isString(obj) || isNumber(obj) || isBoolean(obj)) {
36
- return obj === test;
37
- } else if (Array.isArray(obj) && Array.isArray(test)) {
38
- // if length dont match return false
39
- if (obj.length !== test.length) {
40
- return false;
41
- }
42
- // check if some value is false
43
- return !obj.some(function (o, i) {
44
- return !isEqual(o, test[i]);
45
- });
46
- } else if (isObject(obj) && isObject(test)) {
47
- var okeys = Object.keys(obj);
48
- var tkeys = Object.keys(test);
49
- // if keys length dont match return false
50
- if (okeys.length !== tkeys.length) {
51
- return false;
52
- }
53
- // if keys dont match return false
54
- if (okeys.some(function (k) {
55
- return !tkeys.includes(k);
56
- })) {
57
- return false;
58
- }
59
- // check if some value is false
60
- return !Object.keys(obj).some(function (k) {
61
- return !isEqual(obj[k], test[k]);
62
- });
63
- }
64
- return false;
65
- };
66
-
67
- /**
68
- * match strings
69
- * @internal
70
- */
71
- var matchString = function matchString(base, match) {
72
- var equality = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
73
- var _base = ascii(base).toLowerCase();
74
- var _match = ascii(match).toLowerCase();
75
- return equality === true ? _base === _match : equality === "start" ? _base.startsWith(_match) : _base.includes(_match);
76
- };
77
-
78
- /**
79
- * compare values
80
- * @internal
81
- */
82
- var compareValues = function compareValues() {
83
- var order = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "asc";
84
- var key = arguments.length > 1 ? arguments[1] : undefined;
85
- return function (a, b) {
86
- var aValue = key && isObject(a) ? a[key] : a;
87
- var bValue = key && isObject(b) ? b[key] : b;
88
- var bigger = order === "asc" ? 1 : -1;
89
- var smaller = order === "desc" ? 1 : -1;
90
- // return 0 when equal, allowing for multiple sorting properties
91
- if (aValue === bValue) return 0;
92
- // if numbers check greater
93
- if (isNumber(aValue) && isNumber(bValue)) {
94
- return aValue > bValue ? bigger : smaller;
95
- }
96
- // if boolean sort true first
97
- if (isBoolean(aValue) && isBoolean(bValue)) {
98
- return aValue ? smaller : bigger;
99
- }
100
- var _a = ascii(aValue).toLowerCase();
101
- var _b = ascii(bValue).toLowerCase();
102
- return _a.localeCompare(_b) === 1 ? bigger : smaller;
103
- };
104
- };
105
-
106
- export { compareValues, isEqual, matchString };
@@ -1,85 +0,0 @@
1
- 'use client';
2
-
3
- import _typeof from '@babel/runtime/helpers/typeof';
4
-
5
- /*
6
- * React Fabric
7
- * @version: 1.0.0
8
- *
9
- *
10
- * The MIT License (MIT)
11
- * Copyright (c) 2024 Adarsh Pastakia
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
14
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
15
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
17
- * subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all copies or substantial
20
- * portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
23
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- var isUndefined = function isUndefined(value) {
29
- return value === undefined;
30
- };
31
- var isNull = function isNull(value) {
32
- return value === null;
33
- };
34
- var isNil = function isNil(val) {
35
- return val === undefined || val === null;
36
- };
37
- var isEmpty = function isEmpty(val) {
38
- if (val instanceof Date) return false;
39
- if (isNil(val) || val === "") {
40
- return true;
41
- }
42
- if (Array.isArray(val) && val.filter(Boolean).length === 0) {
43
- return true;
44
- }
45
- if (val instanceof Map || val instanceof Set) return val.size === 0;
46
- if (["boolean", "number", "bigint", "function"].includes(_typeof(val))) {
47
- return false;
48
- }
49
- return !!val && _typeof(val) === "object" && Object.entries(val).length === 0;
50
- };
51
- var isObject = function isObject(val) {
52
- return !isNil(val) && !(val instanceof Date) && _typeof(val) === "object" && !Array.isArray(val);
53
- };
54
- var isArray = function isArray(val) {
55
- return Array.isArray(val);
56
- };
57
- var isString = function isString(value) {
58
- return typeof value === "string";
59
- };
60
- var isNumber = function isNumber(value) {
61
- return typeof value === "number";
62
- };
63
- var isBoolean = function isBoolean(value) {
64
- return typeof value === "boolean";
65
- };
66
- var isTrue = function isTrue() {
67
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
68
- return value === true || value === 1 || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "yes" || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "true";
69
- };
70
- var isFalse = function isFalse() {
71
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
72
- return value === false || value === 0 || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "no" || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "false";
73
- };
74
- var isColor = function isColor(color) {
75
- var _color$startsWith, _color$startsWith2, _color$startsWith3, _color$startsWith4;
76
- return ((_color$startsWith = color.startsWith) === null || _color$startsWith === void 0 ? void 0 : _color$startsWith.call(color, "#")) || ((_color$startsWith2 = color.startsWith) === null || _color$startsWith2 === void 0 ? void 0 : _color$startsWith2.call(color, "rgb")) || ((_color$startsWith3 = color.startsWith) === null || _color$startsWith3 === void 0 ? void 0 : _color$startsWith3.call(color, "hsl")) || ((_color$startsWith4 = color.startsWith) === null || _color$startsWith4 === void 0 ? void 0 : _color$startsWith4.call(color, "lab")) || color === "transparent";
77
- };
78
- var isSvgPath = function isSvgPath(value) {
79
- return typeof value === "string" && value.match(/^[Mm][\d.].*[\dzZ]$/) !== null;
80
- };
81
- var isRtl = function isRtl() {
82
- return getComputedStyle(document.documentElement).direction === "rtl";
83
- };
84
-
85
- export { isArray, isBoolean, isColor, isEmpty, isFalse, isNil, isNull, isNumber, isObject, isRtl, isString, isSvgPath, isTrue, isUndefined };