@fixefy/fixefy-ui-components 0.2.28 → 0.2.30

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,4 +1,4 @@
1
- export declare const getJPart: (j: any, jsonPath: string, defaultValue?: any) => any;
1
+ export declare const getJPart: (j: any, jsonPath: string, defaultValue?: any, separator?: string, replacer?: string, joiner?: string) => any;
2
2
  export declare const isArrayValid: (arr: any[], minLength?: number, maxLength?: number) => boolean;
3
3
  export declare const isObjectValid: (obj: any, isCheckKeys?: boolean) => boolean;
4
4
  export declare const isStringValid: (str: string, minLength?: number | null, maxLength?: number | null, isValidateType?: boolean) => boolean;
@@ -28,101 +28,44 @@ _export(exports, {
28
28
  return toPascalCase;
29
29
  }
30
30
  });
31
- function _define_property(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- } else {
40
- obj[key] = value;
41
- }
42
- return obj;
43
- }
44
- function _object_spread(target) {
45
- for(var i = 1; i < arguments.length; i++){
46
- var source = arguments[i] != null ? arguments[i] : {};
47
- var ownKeys = Object.keys(source);
48
- if (typeof Object.getOwnPropertySymbols === "function") {
49
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
50
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
51
- }));
52
- }
53
- ownKeys.forEach(function(key) {
54
- _define_property(target, key, source[key]);
55
- });
56
- }
57
- return target;
58
- }
59
- function ownKeys(object, enumerableOnly) {
60
- var keys = Object.keys(object);
61
- if (Object.getOwnPropertySymbols) {
62
- var symbols = Object.getOwnPropertySymbols(object);
63
- if (enumerableOnly) {
64
- symbols = symbols.filter(function(sym) {
65
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
66
- });
67
- }
68
- keys.push.apply(keys, symbols);
69
- }
70
- return keys;
71
- }
72
- function _object_spread_props(target, source) {
73
- source = source != null ? source : {};
74
- if (Object.getOwnPropertyDescriptors) {
75
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
76
- } else {
77
- ownKeys(Object(source)).forEach(function(key) {
78
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
79
- });
80
- }
81
- return target;
82
- }
83
- const getJPart = (j, jsonPath, defaultValue)=>{
84
- // input check - if key is invalid - return error
85
- if (isObjectValid(j) === false) return defaultValue;
31
+ const getJPart = (j, jsonPath, defaultValue, separator = '.', replacer = '^\\.*', joiner = '.')=>{
32
+ // if key is invalid - return error
33
+ if (j == null) return defaultValue;
86
34
  // convert indexes to properties
87
- jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
88
- // strip a leading dot
89
- jsonPath = jsonPath.replace(/^\./, '');
35
+ jsonPath = jsonPath.replace(/\[(['"]?)(.*?)\1\]/g, `${separator}$2`);
36
+ // strip all leading dots
37
+ jsonPath = jsonPath.replace(replacer, '');
90
38
  // split path by '.'
91
- let _isArrayValid = false;
92
- let _isStringValid = false;
93
- let currentPathPart;
94
- let isLoop = true;
95
- const pathParts = jsonPath.split('.');
96
- for(let i = 0, n = pathParts.length; isLoop && i < n; ++i){
39
+ let isArrValid = false, isStrValid = false, currentPathPart;
40
+ const pathParts = jsonPath.split(separator);
41
+ for(let i = 0, n = pathParts.length; i < n; ++i){
97
42
  currentPathPart = pathParts[i];
98
- _isStringValid = isStringValid(j);
99
- _isArrayValid = isArrayValid(j);
100
- if (_isStringValid === true || _isArrayValid === true) {
101
- if (_isStringValid === true) {
43
+ isStrValid = isStringValid(j);
44
+ isArrValid = isArrayValid(j);
45
+ if (isStrValid === true || isArrValid === true) {
46
+ if (isStrValid === true) {
102
47
  j = JSON.parse(j);
103
48
  } else {
104
49
  j = j.reduce((acc, cur)=>{
105
- const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
50
+ const innerJ = getJPart(cur, pathParts.slice(i).join(joiner !== null && joiner !== void 0 ? joiner : separator), defaultValue);
106
51
  if (isArrayValid(innerJ)) {
107
52
  acc.push(...innerJ);
108
53
  } else {
109
- acc.push(_object_spread_props(_object_spread({}, innerJ), {
110
- value: innerJ._id
111
- }));
54
+ acc.push(innerJ);
112
55
  }
113
56
  return acc;
114
57
  }, []);
115
- isLoop = false;
58
+ break;
116
59
  }
117
60
  } else {
118
- if (currentPathPart in j) {
61
+ if (j[currentPathPart] != null && currentPathPart in j) {
119
62
  j = j[currentPathPart];
120
63
  } else {
121
64
  // if something in the process failed:
122
65
  // 1. set the rv as the default value
123
66
  // 2. stop the loop`
124
67
  j = defaultValue;
125
- isLoop = false;
68
+ break;
126
69
  }
127
70
  }
128
71
  }
@@ -66,6 +66,11 @@ const FxModalWithButton = ({ btnValue, modalData, onClick })=>{
66
66
  setIsOpen(false);
67
67
  setAnchorEl(null);
68
68
  };
69
+ (0, _react.useEffect)(()=>{
70
+ setIsOpen(false);
71
+ }, [
72
+ btnValue
73
+ ]);
69
74
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
70
75
  children: [
71
76
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
@@ -1,6 +1,2 @@
1
- export declare const getJPart: (j: any, jsonPath: string, defaultValue?: any) => any;
2
- export declare const isArrayValid: (arr: any[], minLength?: number, maxLength?: number) => boolean;
3
- export declare const isObjectValid: (obj: any, isCheckKeys?: boolean) => boolean;
4
- export declare const isStringValid: (str: string, minLength?: number | null, maxLength?: number | null, isValidateType?: boolean) => boolean;
5
1
  export declare const titleCase: (str?: string) => string;
6
2
  export declare const toPascalCase: (string: string, title?: boolean) => string;
@@ -9,18 +9,6 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- getJPart: function() {
13
- return getJPart;
14
- },
15
- isArrayValid: function() {
16
- return isArrayValid;
17
- },
18
- isObjectValid: function() {
19
- return isObjectValid;
20
- },
21
- isStringValid: function() {
22
- return isStringValid;
23
- },
24
12
  titleCase: function() {
25
13
  return titleCase;
26
14
  },
@@ -28,133 +16,6 @@ _export(exports, {
28
16
  return toPascalCase;
29
17
  }
30
18
  });
31
- function _define_property(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- } else {
40
- obj[key] = value;
41
- }
42
- return obj;
43
- }
44
- function _object_spread(target) {
45
- for(var i = 1; i < arguments.length; i++){
46
- var source = arguments[i] != null ? arguments[i] : {};
47
- var ownKeys = Object.keys(source);
48
- if (typeof Object.getOwnPropertySymbols === "function") {
49
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
50
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
51
- }));
52
- }
53
- ownKeys.forEach(function(key) {
54
- _define_property(target, key, source[key]);
55
- });
56
- }
57
- return target;
58
- }
59
- function ownKeys(object, enumerableOnly) {
60
- var keys = Object.keys(object);
61
- if (Object.getOwnPropertySymbols) {
62
- var symbols = Object.getOwnPropertySymbols(object);
63
- if (enumerableOnly) {
64
- symbols = symbols.filter(function(sym) {
65
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
66
- });
67
- }
68
- keys.push.apply(keys, symbols);
69
- }
70
- return keys;
71
- }
72
- function _object_spread_props(target, source) {
73
- source = source != null ? source : {};
74
- if (Object.getOwnPropertyDescriptors) {
75
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
76
- } else {
77
- ownKeys(Object(source)).forEach(function(key) {
78
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
79
- });
80
- }
81
- return target;
82
- }
83
- const getJPart = (j, jsonPath, defaultValue)=>{
84
- // input check - if key is invalid - return error
85
- if (isObjectValid(j) === false) return defaultValue;
86
- // convert indexes to properties
87
- jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
88
- // strip a leading dot
89
- jsonPath = jsonPath.replace(/^\./, '');
90
- // split path by '.'
91
- let _isArrayValid = false;
92
- let _isStringValid = false;
93
- let currentPathPart;
94
- let isLoop = true;
95
- const pathParts = jsonPath.split('.');
96
- for(let i = 0, n = pathParts.length; isLoop && i < n; ++i){
97
- currentPathPart = pathParts[i];
98
- _isStringValid = isStringValid(j);
99
- _isArrayValid = isArrayValid(j);
100
- if (_isStringValid === true || _isArrayValid === true) {
101
- if (_isStringValid === true) {
102
- j = JSON.parse(j);
103
- } else {
104
- j = j.reduce((acc, cur)=>{
105
- const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
106
- if (isArrayValid(innerJ)) {
107
- acc.push(...innerJ);
108
- } else {
109
- acc.push(_object_spread_props(_object_spread({}, innerJ), {
110
- value: innerJ._id
111
- }));
112
- }
113
- return acc;
114
- }, []);
115
- isLoop = false;
116
- }
117
- } else {
118
- if (currentPathPart in j) {
119
- j = j[currentPathPart];
120
- } else {
121
- // if something in the process failed:
122
- // 1. set the rv as the default value
123
- // 2. stop the loop`
124
- j = defaultValue;
125
- isLoop = false;
126
- }
127
- }
128
- }
129
- return j;
130
- };
131
- const isArrayValid = (arr, minLength = 1, maxLength = 0)=>{
132
- let rv = isObjectValid(arr) && arr.length >= minLength && //arr instanceof Array
133
- Object.prototype.toString.call(arr) == '[object Array]';
134
- if (maxLength > 0) {
135
- rv = rv && arr.length <= maxLength;
136
- }
137
- return rv;
138
- };
139
- const isObjectValid = (obj, isCheckKeys = false)=>{
140
- let rv = typeof obj !== 'undefined' && obj !== null;
141
- if (isCheckKeys) {
142
- rv = rv && Object.keys(obj).length > 0;
143
- }
144
- return rv;
145
- };
146
- const isStringValid = (str, minLength = null, maxLength = null, isValidateType = true)=>{
147
- let rv = isObjectValid(str) && str.toString().length > 0 && (isValidateType ? typeof str === 'string' : true);
148
- if (rv === false) return false;
149
- if (minLength && isNaN(minLength) === false && minLength > 0) {
150
- rv = rv && str.toString().length >= minLength;
151
- }
152
- if (rv === false) return false;
153
- if (maxLength && isNaN(maxLength) === false && maxLength > 0) {
154
- rv = rv && str.toString().length <= maxLength;
155
- }
156
- return rv;
157
- };
158
19
  const titleCase = (str = '')=>str && toPascalCase(str.toString(), true);
159
20
  const toPascalCase = (string, title = false)=>{
160
21
  return string && string.replace(/(_[a-z])?(^[a-z])?(_|\s[a-z])?/g, ($1)=>$1.toUpperCase().replace('_', title ? ' ' : ''));
package/package.json CHANGED
@@ -65,5 +65,5 @@
65
65
  "require": "./dist/index.js"
66
66
  }
67
67
  },
68
- "version": "0.2.28"
68
+ "version": "0.2.30"
69
69
  }