@fixefy/fixefy-ui-utils 0.2.70 → 0.2.72

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.
@@ -1,2 +1,2 @@
1
1
  export declare const attachAuth: (ctx: any, headers: any) => any;
2
- export declare const getToken: (ctx: any) => string | undefined;
2
+ export declare const getToken: (ctx: any) => string;
@@ -2,7 +2,7 @@ import { Currency } from '../constants';
2
2
  export declare const defaultHeaders: any;
3
3
  export declare const getHeaders: (ctx: any) => any;
4
4
  export declare const setHeaders: (ctx: any, _headers: any) => void;
5
- export declare const getWorkspace: (ctx: any) => any;
5
+ export declare const getWorkspace: (ctx: any) => string;
6
6
  export declare const setWorkspace: (ctx: any, ws: string) => void;
7
7
  export declare const flushWorkspace: (ctx: any) => void;
8
8
  export declare const flushAll: (ctx: any) => void;
@@ -532,28 +532,28 @@ const palette = {
532
532
  background: '#87ACB6'
533
533
  },
534
534
  in_progress: {
535
- border: '#EB5757',
536
- background: '#EB5757',
535
+ border: '#EE6868',
536
+ background: '#EE6868',
537
537
  light: '#FEF6F6'
538
538
  },
539
539
  pending: {
540
- border: '#ECC631',
541
- background: '#ECC631',
542
- light: '#FEFCEE'
540
+ border: '#2D9CDB',
541
+ background: '#2D9CDB',
542
+ light: '#F3F9FD'
543
543
  },
544
544
  approved: {
545
545
  border: '#88C00D',
546
546
  background: '#88C00D',
547
- light: '#D4EFDF'
547
+ light: '#F6FAEC'
548
548
  },
549
549
  declined: {
550
- border: '#C4A603',
551
- background: '#C4A603',
552
- light: '#FEF6F6'
550
+ border: '#F2994A',
551
+ background: '#F2994A',
552
+ light: '#FEF7F1'
553
553
  },
554
554
  refunded: {
555
- border: '#27AE60',
556
- background: '#27AE60',
555
+ border: '#EC6AC8',
556
+ background: '#EC6AC8',
557
557
  light: '#FBF6FD'
558
558
  },
559
559
  closed: {
@@ -561,9 +561,9 @@ const palette = {
561
561
  background: '#8B9092'
562
562
  },
563
563
  resolved: {
564
- border: '#EC6AC8',
565
- background: '#EC6AC8',
566
- light: '#FBF6FD'
564
+ border: '#6FCF97',
565
+ background: '#6FCF97',
566
+ light: '#F0FAF4'
567
567
  },
568
568
  submitted_for_billing: {
569
569
  border: '#88C00D',
package/package.json CHANGED
@@ -4,7 +4,6 @@
4
4
  "fs": false
5
5
  },
6
6
  "peerDependencies": {
7
- "@fixefy/fixefy-cookies": ">=0.1.0",
8
7
  "@fixefy/fixefy-entities": ">=0.1.20",
9
8
  "@fixefy/fixefy-numeric": ">=0.1.3",
10
9
  "@fixefy/fixefy-validate": ">=0.1.25",
@@ -16,6 +15,7 @@
16
15
  "graphql-tag": ">=2.12.6",
17
16
  "jss": ">=10.10.0",
18
17
  "next": ">=14.2.26",
18
+ "nookies": ">=2.5.2",
19
19
  "pluralize": ">=8.0.0",
20
20
  "react": ">=18.3.1",
21
21
  "react-dom": ">=18.3.1",
@@ -59,6 +59,7 @@
59
59
  "files": [
60
60
  "dist/**/*"
61
61
  ],
62
+ "private": false,
62
63
  "main": "./dist/index.js",
63
64
  "module": "./dist/index.js",
64
65
  "exports": {
@@ -67,5 +68,5 @@
67
68
  "require": "./dist/index.js"
68
69
  }
69
70
  },
70
- "version": "0.2.70"
71
+ "version": "0.2.72"
71
72
  }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- attachAuth: function() {
13
- return attachAuth;
14
- },
15
- getToken: function() {
16
- return getToken;
17
- }
18
- });
19
- const _fixefycookies = require("@fixefy/fixefy-cookies");
20
- function _define_property(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
32
- }
33
- function _object_spread(target) {
34
- for(var i = 1; i < arguments.length; i++){
35
- var source = arguments[i] != null ? arguments[i] : {};
36
- var ownKeys = Object.keys(source);
37
- if (typeof Object.getOwnPropertySymbols === "function") {
38
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
39
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
40
- }));
41
- }
42
- ownKeys.forEach(function(key) {
43
- _define_property(target, key, source[key]);
44
- });
45
- }
46
- return target;
47
- }
48
- function ownKeys(object, enumerableOnly) {
49
- var keys = Object.keys(object);
50
- if (Object.getOwnPropertySymbols) {
51
- var symbols = Object.getOwnPropertySymbols(object);
52
- if (enumerableOnly) {
53
- symbols = symbols.filter(function(sym) {
54
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
55
- });
56
- }
57
- keys.push.apply(keys, symbols);
58
- }
59
- return keys;
60
- }
61
- function _object_spread_props(target, source) {
62
- source = source != null ? source : {};
63
- if (Object.getOwnPropertyDescriptors) {
64
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
65
- } else {
66
- ownKeys(Object(source)).forEach(function(key) {
67
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
68
- });
69
- }
70
- return target;
71
- }
72
- const attachAuth = (ctx, headers)=>{
73
- const token = getToken(ctx);
74
- return _object_spread_props(_object_spread({}, headers), {
75
- authorization: `Bearer ${token}`
76
- });
77
- };
78
- const getToken = (ctx)=>{
79
- return _fixefycookies.CookieHelper.get(ctx, 'token');
80
- };
@@ -1,391 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- buildCode: function() {
13
- return buildCode;
14
- },
15
- convertToString: function() {
16
- return convertToString;
17
- },
18
- copyToClipboard: function() {
19
- return copyToClipboard;
20
- },
21
- determineIconByEvent: function() {
22
- return determineIconByEvent;
23
- },
24
- formatNumberWithCommas: function() {
25
- return formatNumberWithCommas;
26
- },
27
- getNormalizationKeyForEntity: function() {
28
- return getNormalizationKeyForEntity;
29
- },
30
- getScoreColor: function() {
31
- return getScoreColor;
32
- },
33
- getStringValueByValueType: function() {
34
- return getStringValueByValueType;
35
- },
36
- getVal: function() {
37
- return getVal;
38
- },
39
- isInServer: function() {
40
- return isInServer;
41
- },
42
- isValidTimestamp: function() {
43
- return isValidTimestamp;
44
- },
45
- lineString: function() {
46
- return lineString;
47
- },
48
- makeString: function() {
49
- return makeString;
50
- },
51
- nest: function() {
52
- return nest;
53
- },
54
- normalizeStringBodyRaw: function() {
55
- return normalizeStringBodyRaw;
56
- },
57
- normalizeTimestamp: function() {
58
- return normalizeTimestamp;
59
- },
60
- titleCase: function() {
61
- return titleCase;
62
- },
63
- toCamelCase: function() {
64
- return toCamelCase;
65
- },
66
- toCamelCaseString: function() {
67
- return toCamelCaseString;
68
- },
69
- toCurrency: function() {
70
- return toCurrency;
71
- },
72
- toInitials: function() {
73
- return toInitials;
74
- },
75
- toPascalCase: function() {
76
- return toPascalCase;
77
- },
78
- toWords: function() {
79
- return toWords;
80
- },
81
- trimRuleCode: function() {
82
- return trimRuleCode;
83
- },
84
- useStatePromisify: function() {
85
- return useStatePromisify;
86
- }
87
- });
88
- const _constants = require("../constants");
89
- const _datefns = require("date-fns");
90
- const _react = require("react");
91
- const _fixefynumeric = /*#__PURE__*/ _interop_require_default(require("@fixefy/fixefy-numeric"));
92
- function _define_property(obj, key, value) {
93
- if (key in obj) {
94
- Object.defineProperty(obj, key, {
95
- value: value,
96
- enumerable: true,
97
- configurable: true,
98
- writable: true
99
- });
100
- } else {
101
- obj[key] = value;
102
- }
103
- return obj;
104
- }
105
- function _interop_require_default(obj) {
106
- return obj && obj.__esModule ? obj : {
107
- default: obj
108
- };
109
- }
110
- function _object_spread(target) {
111
- for(var i = 1; i < arguments.length; i++){
112
- var source = arguments[i] != null ? arguments[i] : {};
113
- var ownKeys = Object.keys(source);
114
- if (typeof Object.getOwnPropertySymbols === "function") {
115
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
116
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
117
- }));
118
- }
119
- ownKeys.forEach(function(key) {
120
- _define_property(target, key, source[key]);
121
- });
122
- }
123
- return target;
124
- }
125
- function ownKeys(object, enumerableOnly) {
126
- var keys = Object.keys(object);
127
- if (Object.getOwnPropertySymbols) {
128
- var symbols = Object.getOwnPropertySymbols(object);
129
- if (enumerableOnly) {
130
- symbols = symbols.filter(function(sym) {
131
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
132
- });
133
- }
134
- keys.push.apply(keys, symbols);
135
- }
136
- return keys;
137
- }
138
- function _object_spread_props(target, source) {
139
- source = source != null ? source : {};
140
- if (Object.getOwnPropertyDescriptors) {
141
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
142
- } else {
143
- ownKeys(Object(source)).forEach(function(key) {
144
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
145
- });
146
- }
147
- return target;
148
- }
149
- const buildCode = (obj, level = 0, name)=>{
150
- const toRender = [];
151
- const keys = Object.keys(obj);
152
- if (keys.length < 1) {
153
- toRender.push(lineString(level, name) + '{}');
154
- return toRender;
155
- }
156
- toRender.push(lineString(level, name) + '{');
157
- keys.forEach((key)=>{
158
- if (key === '__typename') return;
159
- if (typeof obj[key] === 'object' && obj[key] !== null) {
160
- toRender.push(...buildCode(obj[key], level + 1, key));
161
- } else {
162
- const val = getVal(obj[key]);
163
- toRender.push(lineString(level + 1, key) + val);
164
- }
165
- });
166
- toRender.push(lineString(level) + '}');
167
- return toRender;
168
- };
169
- const copyToClipboard = (str)=>{
170
- if (window == undefined) return;
171
- const el = document.createElement('textarea');
172
- el.value = str;
173
- el.setAttribute('readonly', '');
174
- el.style.position = 'absolute';
175
- el.style.left = '-9999px';
176
- document.body.appendChild(el);
177
- el.select();
178
- document.execCommand('copy');
179
- document.body.removeChild(el);
180
- };
181
- const convertToString = (input)=>{
182
- if (input) {
183
- return typeof input === 'string' ? input : String(input);
184
- } else {
185
- return null;
186
- }
187
- };
188
- const determineIconByEvent = (event)=>{
189
- let rv;
190
- if (event) {
191
- switch(event.type){
192
- case 'charged':
193
- rv = '../../static/images/transactions/billing.svg';
194
- break;
195
- case 'packed':
196
- rv = '../../static/images/transactions/system.svg';
197
- break;
198
- default:
199
- rv = '../../static/images/transactions/user.svg';
200
- break;
201
- }
202
- }
203
- return rv;
204
- };
205
- const formatNumberWithCommas = (number)=>{
206
- return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
207
- };
208
- const getNormalizationKeyForEntity = (entity_type)=>{
209
- let rv;
210
- switch(entity_type.toLowerCase()){
211
- case _constants.EntityTypes.User:
212
- rv = 'username';
213
- break;
214
- case _constants.EntityTypes.Pricing:
215
- rv = 'value';
216
- break;
217
- case _constants.EntityTypes.Metadata:
218
- rv = 'title';
219
- break;
220
- case _constants.EntityTypes.Transaction:
221
- case _constants.EntityTypes.Transmission:
222
- rv = 'readable_id';
223
- break;
224
- default:
225
- rv = 'title';
226
- break;
227
- }
228
- return rv;
229
- };
230
- const getStringValueByValueType = ({ value, name })=>{
231
- let rv;
232
- let entity_type;
233
- let roundedValue;
234
- let formattedValue;
235
- switch(typeof value){
236
- case 'boolean':
237
- rv = value === true ? 'YES' : 'NO';
238
- break;
239
- case 'number':
240
- if (isValidTimestamp(value)) {
241
- rv = normalizeTimestamp(value, false);
242
- break;
243
- }
244
- roundedValue = Number(value) === value && value % 1 === 0 ? value : value.toFixed(2);
245
- formattedValue = name === 'variance' ? `${(roundedValue * 100).toFixed(1)}%` : roundedValue;
246
- rv = formattedValue;
247
- break;
248
- case 'object':
249
- if (Array.isArray(value)) {
250
- rv = value.join(', ');
251
- } else {
252
- entity_type = value && value.__typename && value.__typename.toLowerCase();
253
- rv = titleCase(value[getNormalizationKeyForEntity(entity_type)]);
254
- }
255
- break;
256
- case 'string':
257
- rv = titleCase(value);
258
- break;
259
- }
260
- return rv;
261
- };
262
- const getVal = (val)=>{
263
- if (typeof val === 'number') return val;
264
- if (typeof val === 'string') return `"${val}"`;
265
- return val;
266
- };
267
- const isInServer = ()=>typeof window === 'undefined';
268
- const isValidTimestamp = (_timestamp)=>{
269
- const parsedNumber = typeof _timestamp == 'string' ? parseInt(_timestamp) : _timestamp;
270
- const newTimestamp = new Date(parsedNumber).getTime();
271
- const rv = _fixefynumeric.default.isFloat(newTimestamp) || _fixefynumeric.default.isInt(newTimestamp) && newTimestamp.toString().length >= 10;
272
- return rv;
273
- };
274
- const lineString = (level, name)=>{
275
- let str = '';
276
- for(let i = 0; i < level; i++){
277
- str += ' ';
278
- }
279
- if (name) {
280
- str += name + ': ';
281
- }
282
- return str;
283
- };
284
- const makeString = (len = 5)=>{
285
- let text = '';
286
- const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
287
- for(let i = 0; i < len; i++)text += possible.charAt(Math.floor(Math.random() * possible.length));
288
- return text;
289
- };
290
- const nest = ({ items })=>{
291
- const mappedArray = Object.create(null);
292
- items.forEach((item)=>mappedArray[item.id] = _object_spread_props(_object_spread({}, item), {
293
- children: []
294
- }));
295
- const nestedArray = [];
296
- items.forEach((item)=>{
297
- if (item) {
298
- if (item.parent) {
299
- if (mappedArray[item.parent]) mappedArray[item.parent].children.push(mappedArray[item.id]);
300
- } else nestedArray.push(mappedArray[item.id]);
301
- }
302
- });
303
- return nestedArray;
304
- };
305
- const normalizeTimestamp = (timestamp, options)=>{
306
- const { dateOnly, format: _format } = options || {};
307
- const _timestamp = typeof timestamp == 'string' ? parseInt(timestamp) : timestamp;
308
- const rv = (0, _datefns.format)(new Date(_timestamp), _format ? _format : dateOnly ? 'dd/MM/yyyy' : 'dd/MM/yyyy hh:mm');
309
- return rv;
310
- };
311
- const normalizeStringBodyRaw = (key, body)=>{
312
- return typeof body[key] === 'string' && (key === 'body' || key === 'raw') ? JSON.parse(body[key]) : body[key];
313
- };
314
- const titleCase = (str = '')=>str && toPascalCase(str.toString(), true);
315
- const toCamelCase = (inputArray)=>{
316
- let result = '';
317
- var _inputArray_length;
318
- for(let i = 0, len = (_inputArray_length = inputArray === null || inputArray === void 0 ? void 0 : inputArray.length) !== null && _inputArray_length !== void 0 ? _inputArray_length : 0; i < len; i++){
319
- const currentStr = inputArray === null || inputArray === void 0 ? void 0 : inputArray.at(i);
320
- let tempStr = currentStr.toLowerCase();
321
- if (i != 0) {
322
- // convert first letter to upper case (the word is in lowercase)
323
- tempStr = tempStr.substr(0, 1).toUpperCase() + tempStr.substr(1);
324
- }
325
- result += tempStr;
326
- }
327
- return result;
328
- };
329
- const toCamelCaseString = (input)=>{
330
- const words = toWords(input);
331
- return toCamelCase(words);
332
- };
333
- const toCurrency = (input, options)=>{
334
- return input ? typeof input == 'number' ? input.toFixed((options === null || options === void 0 ? void 0 : options.decimel) || 2).replace(/\B(?=(\d{3})+(?!\d))/g, ',') : input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') : input;
335
- };
336
- const toInitials = (str)=>{
337
- if (str === '') return str;
338
- const matches = str.match(/\b(\w)/g);
339
- return matches === null || matches === void 0 ? void 0 : matches.join('').toUpperCase();
340
- };
341
- const toPascalCase = (string, title = false)=>{
342
- return string && string.replace(/(_[a-z])?(^[a-z])?(_|\s[a-z])?/g, ($1)=>$1.toUpperCase().replace('_', title ? ' ' : ''));
343
- };
344
- const toWords = (input)=>{
345
- input = convertToString(input);
346
- const regex = /[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g;
347
- return input === null || input === void 0 ? void 0 : input.match(regex);
348
- };
349
- const trimRuleCode = (input)=>{
350
- const stringefied = typeof input == 'string' ? input : JSON.stringify(input);
351
- const match = stringefied.substring(stringefied.indexOf('{') + 1, stringefied.lastIndexOf('}'));
352
- return match ? match : '';
353
- };
354
- const useStatePromisify = (_state)=>{
355
- const [state, setState] = (0, _react.useState)(_state);
356
- const resolverRef = (0, _react.useRef)(null);
357
- (0, _react.useEffect)(()=>{
358
- if (resolverRef.current) {
359
- resolverRef.current(state);
360
- resolverRef.current = null;
361
- }
362
- }, [
363
- resolverRef,
364
- state
365
- ]);
366
- const handleSetState = (0, _react.useCallback)((stateAction)=>{
367
- setState(stateAction);
368
- return new Promise((resolve)=>{
369
- resolverRef.current = resolve;
370
- });
371
- }, [
372
- setState
373
- ]);
374
- return [
375
- state,
376
- handleSetState
377
- ];
378
- };
379
- const getScoreColor = (value)=>{
380
- if (value <= 20) {
381
- return 'bad';
382
- } else if (value <= 40) {
383
- return 'low';
384
- } else if (value <= 60) {
385
- return 'medium';
386
- } else if (value <= 80) {
387
- return 'high';
388
- } else {
389
- return 'excellent';
390
- }
391
- };