@bigbinary/neeto-commons-frontend 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/initializers.cjs.js +13 -17
- package/initializers.js +13 -17
- package/package.json +6 -4
- package/pure.cjs.js +28 -24
- package/pure.d.ts +3 -1
- package/pure.js +28 -25
- package/react-utils.cjs.js +51 -14
- package/react-utils.d.ts +9 -3
- package/react-utils.js +53 -17
- package/utils.cjs.js +1966 -537
- package/utils.js +1964 -536
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The commons frontend library for Neeto Applications.
|
|
|
7
7
|
Install from npm:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
yarn add "@bigbinary/neeto-commons-frontend@2.0.
|
|
10
|
+
yarn add "@bigbinary/neeto-commons-frontend@2.0.10"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
This package relies on the host project's tailwind configuration. So add
|
package/initializers.cjs.js
CHANGED
|
@@ -113,9 +113,15 @@ var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
116
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
117
|
+
|
|
118
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
119
|
+
object = objectPreProcessor(object);
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
if (Array.isArray(object)) {
|
|
117
123
|
return object.map(function (obj) {
|
|
118
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
124
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
119
125
|
});
|
|
120
126
|
} else if (object === null || _typeof(object) !== "object") {
|
|
121
127
|
return object;
|
|
@@ -126,7 +132,7 @@ var transformObjectDeep = function transformObjectDeep(object, keyValueTransform
|
|
|
126
132
|
key = _ref4[0],
|
|
127
133
|
value = _ref4[1];
|
|
128
134
|
|
|
129
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
135
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
130
136
|
}));
|
|
131
137
|
};
|
|
132
138
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -135,21 +141,11 @@ var keysToCamelCase = function keysToCamelCase(object) {
|
|
|
135
141
|
});
|
|
136
142
|
};
|
|
137
143
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
return serializedObj;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return Object.fromEntries(Object.entries(serializedObj).map(function (_ref5) {
|
|
147
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
148
|
-
key = _ref6[0],
|
|
149
|
-
value = _ref6[1];
|
|
150
|
-
|
|
151
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
152
|
-
}));
|
|
144
|
+
return transformObjectDeep(object, function (key, value) {
|
|
145
|
+
return [camelToSnakeCase(key), value];
|
|
146
|
+
}, function (object) {
|
|
147
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
148
|
+
});
|
|
153
149
|
};
|
|
154
150
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
155
151
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
package/initializers.js
CHANGED
|
@@ -103,9 +103,15 @@ var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
106
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
107
|
+
|
|
108
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
109
|
+
object = objectPreProcessor(object);
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
if (Array.isArray(object)) {
|
|
107
113
|
return object.map(function (obj) {
|
|
108
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
114
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
109
115
|
});
|
|
110
116
|
} else if (object === null || _typeof(object) !== "object") {
|
|
111
117
|
return object;
|
|
@@ -116,7 +122,7 @@ var transformObjectDeep = function transformObjectDeep(object, keyValueTransform
|
|
|
116
122
|
key = _ref4[0],
|
|
117
123
|
value = _ref4[1];
|
|
118
124
|
|
|
119
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
125
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
120
126
|
}));
|
|
121
127
|
};
|
|
122
128
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -125,21 +131,11 @@ var keysToCamelCase = function keysToCamelCase(object) {
|
|
|
125
131
|
});
|
|
126
132
|
};
|
|
127
133
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
return serializedObj;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return Object.fromEntries(Object.entries(serializedObj).map(function (_ref5) {
|
|
137
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
138
|
-
key = _ref6[0],
|
|
139
|
-
value = _ref6[1];
|
|
140
|
-
|
|
141
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
142
|
-
}));
|
|
134
|
+
return transformObjectDeep(object, function (key, value) {
|
|
135
|
+
return [camelToSnakeCase(key), value];
|
|
136
|
+
}, function (object) {
|
|
137
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
138
|
+
});
|
|
143
139
|
};
|
|
144
140
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
145
141
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -47,7 +47,9 @@
|
|
|
47
47
|
"@babel/preset-env": "^7.17.10",
|
|
48
48
|
"@babel/preset-react": "^7.16.7",
|
|
49
49
|
"@bigbinary/neeto-icons": "^1.8.35",
|
|
50
|
-
"@bigbinary/neetoui": "^
|
|
50
|
+
"@bigbinary/neetoui": "^4.0.0",
|
|
51
|
+
"antd": "4.18.7",
|
|
52
|
+
"react-toastify": "^9.0.8",
|
|
51
53
|
"@honeybadger-io/react": "2.0.1",
|
|
52
54
|
"@rollup/plugin-alias": "^3.1.9",
|
|
53
55
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -81,7 +83,7 @@
|
|
|
81
83
|
"lint-staged": "^12.3.7",
|
|
82
84
|
"mixpanel-browser": "^2.45.0",
|
|
83
85
|
"prettier": "^2.6.2",
|
|
84
|
-
"
|
|
86
|
+
"qs": "^6.11.0",
|
|
85
87
|
"ramda": "^0.28.0",
|
|
86
88
|
"react": "^17.0.2",
|
|
87
89
|
"react-dom": "17.0.2",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
"dependencies": {},
|
|
97
99
|
"peerDependencies": {
|
|
98
100
|
"@bigbinary/neeto-icons": "^1.8.35",
|
|
99
|
-
"@bigbinary/neetoui": "^
|
|
101
|
+
"@bigbinary/neetoui": "^4.0.0",
|
|
100
102
|
"@honeybadger-io/react": "2.0.1",
|
|
101
103
|
"axios": "^0.27.2",
|
|
102
104
|
"dayjs": "1.11.1",
|
package/pure.cjs.js
CHANGED
|
@@ -123,9 +123,15 @@ var matchesImpl = function matchesImpl(pattern, object) {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
126
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
127
|
+
|
|
128
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
129
|
+
object = objectPreProcessor(object);
|
|
130
|
+
}
|
|
131
|
+
|
|
126
132
|
if (Array.isArray(object)) {
|
|
127
133
|
return object.map(function (obj) {
|
|
128
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
134
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
129
135
|
});
|
|
130
136
|
} else if (object === null || _typeof(object) !== "object") {
|
|
131
137
|
return object;
|
|
@@ -136,7 +142,7 @@ var transformObjectDeep = function transformObjectDeep(object, keyValueTransform
|
|
|
136
142
|
key = _ref4[0],
|
|
137
143
|
value = _ref4[1];
|
|
138
144
|
|
|
139
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
145
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
140
146
|
}));
|
|
141
147
|
};
|
|
142
148
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -150,21 +156,18 @@ var keysToSnakeCase = function keysToSnakeCase(object) {
|
|
|
150
156
|
});
|
|
151
157
|
};
|
|
152
158
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
167
|
-
}));
|
|
159
|
+
return transformObjectDeep(object, function (key, value) {
|
|
160
|
+
return [camelToSnakeCase(key), value];
|
|
161
|
+
}, function (object) {
|
|
162
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
166
|
+
return transformObjectDeep(object, function (key, value) {
|
|
167
|
+
return [key, value];
|
|
168
|
+
}, function (object) {
|
|
169
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
170
|
+
});
|
|
168
171
|
};
|
|
169
172
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
170
173
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
|
@@ -180,15 +183,15 @@ var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
|
|
|
180
183
|
return matchesImpl(pattern, object);
|
|
181
184
|
});
|
|
182
185
|
var filterNonNull = function filterNonNull(object) {
|
|
183
|
-
return Object.fromEntries(Object.entries(object).filter(function (
|
|
184
|
-
var
|
|
185
|
-
v =
|
|
186
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
187
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
188
|
+
v = _ref6[1];
|
|
186
189
|
|
|
187
190
|
return !ramda.isNil(v);
|
|
188
|
-
}).map(function (
|
|
189
|
-
var
|
|
190
|
-
k =
|
|
191
|
-
v =
|
|
191
|
+
}).map(function (_ref7) {
|
|
192
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
193
|
+
k = _ref8[0],
|
|
194
|
+
v = _ref8[1];
|
|
192
195
|
|
|
193
196
|
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
194
197
|
}));
|
|
@@ -400,6 +403,7 @@ exports.modifyById = modifyById;
|
|
|
400
403
|
exports.noop = noop;
|
|
401
404
|
exports.notEquals = notEquals;
|
|
402
405
|
exports.notEqualsDeep = notEqualsDeep;
|
|
406
|
+
exports.preprocessForSerialization = preprocessForSerialization;
|
|
403
407
|
exports.randomPick = randomPick;
|
|
404
408
|
exports.removeBy = removeBy;
|
|
405
409
|
exports.removeById = removeById;
|
package/pure.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ export function replaceById<T>(id: any, entityArray: T[]): T[];
|
|
|
170
170
|
export function replaceById(id: any): <T>(entityArray: T[]) => T[];
|
|
171
171
|
|
|
172
172
|
export function serializeKeysToSnakeCase(object: object): object;
|
|
173
|
+
export function preprocessForSerialization(object: object): object;
|
|
173
174
|
export function slugify(string: string): string;
|
|
174
175
|
export function snakeToCamelCase(string: string): string;
|
|
175
176
|
export function toLabelAndValue(string: string): {
|
|
@@ -178,7 +179,8 @@ export function toLabelAndValue(string: string): {
|
|
|
178
179
|
};
|
|
179
180
|
export function transformObjectDeep(
|
|
180
181
|
object: object,
|
|
181
|
-
keyValueTransformer: (key: string | number | symbol, object: any) => any[]
|
|
182
|
+
keyValueTransformer: (key: string | number | symbol, object: any) => any[],
|
|
183
|
+
objectPreProcessor?: (object: any) => any
|
|
182
184
|
): object;
|
|
183
185
|
|
|
184
186
|
export function truncate(string: string, length: number): string;
|
package/pure.js
CHANGED
|
@@ -119,9 +119,15 @@ var matchesImpl = function matchesImpl(pattern, object) {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
122
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
123
|
+
|
|
124
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
125
|
+
object = objectPreProcessor(object);
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
if (Array.isArray(object)) {
|
|
123
129
|
return object.map(function (obj) {
|
|
124
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
130
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
125
131
|
});
|
|
126
132
|
} else if (object === null || _typeof(object) !== "object") {
|
|
127
133
|
return object;
|
|
@@ -132,7 +138,7 @@ var transformObjectDeep = function transformObjectDeep(object, keyValueTransform
|
|
|
132
138
|
key = _ref4[0],
|
|
133
139
|
value = _ref4[1];
|
|
134
140
|
|
|
135
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
141
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
136
142
|
}));
|
|
137
143
|
};
|
|
138
144
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -146,21 +152,18 @@ var keysToSnakeCase = function keysToSnakeCase(object) {
|
|
|
146
152
|
});
|
|
147
153
|
};
|
|
148
154
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
163
|
-
}));
|
|
155
|
+
return transformObjectDeep(object, function (key, value) {
|
|
156
|
+
return [camelToSnakeCase(key), value];
|
|
157
|
+
}, function (object) {
|
|
158
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
162
|
+
return transformObjectDeep(object, function (key, value) {
|
|
163
|
+
return [key, value];
|
|
164
|
+
}, function (object) {
|
|
165
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
166
|
+
});
|
|
164
167
|
};
|
|
165
168
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
166
169
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
|
@@ -176,15 +179,15 @@ var matches = /*#__PURE__*/curry(function (pattern, object) {
|
|
|
176
179
|
return matchesImpl(pattern, object);
|
|
177
180
|
});
|
|
178
181
|
var filterNonNull = function filterNonNull(object) {
|
|
179
|
-
return Object.fromEntries(Object.entries(object).filter(function (
|
|
180
|
-
var
|
|
181
|
-
v =
|
|
182
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
183
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
184
|
+
v = _ref6[1];
|
|
182
185
|
|
|
183
186
|
return !isNil(v);
|
|
184
|
-
}).map(function (
|
|
185
|
-
var
|
|
186
|
-
k =
|
|
187
|
-
v =
|
|
187
|
+
}).map(function (_ref7) {
|
|
188
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
189
|
+
k = _ref8[0],
|
|
190
|
+
v = _ref8[1];
|
|
188
191
|
|
|
189
192
|
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
190
193
|
}));
|
|
@@ -365,4 +368,4 @@ var isNot = notEquals;
|
|
|
365
368
|
var notEqualsDeep = /*#__PURE__*/complement(equals);
|
|
366
369
|
var isNotEqualDeep = notEqualsDeep;
|
|
367
370
|
|
|
368
|
-
export { camelToSnakeCase, capitalize, copyKeys, copyKeysDeep, countBy, deepFreezeObject, dynamicArray, existsBy, existsById, filterBy, filterNonNull, findBy, findById, findIndexBy, findIndexById, findLastBy, findLastIndexBy, getRandomInt, humanize, isNot, isNotEmpty, isNotEqualDeep, isNotNil, keysToCamelCase, keysToSnakeCase, matches, modifyBy, modifyById, noop, notEquals, notEqualsDeep, randomPick, removeBy, removeById, renameKeys, replaceBy, replaceById, serializeKeysToSnakeCase, slugify, snakeToCamelCase, toLabelAndValue, transformObjectDeep, truncate };
|
|
371
|
+
export { camelToSnakeCase, capitalize, copyKeys, copyKeysDeep, countBy, deepFreezeObject, dynamicArray, existsBy, existsById, filterBy, filterNonNull, findBy, findById, findIndexBy, findIndexById, findLastBy, findLastIndexBy, getRandomInt, humanize, isNot, isNotEmpty, isNotEqualDeep, isNotNil, keysToCamelCase, keysToSnakeCase, matches, modifyBy, modifyById, noop, notEquals, notEqualsDeep, preprocessForSerialization, randomPick, removeBy, removeById, renameKeys, replaceBy, replaceById, serializeKeysToSnakeCase, slugify, snakeToCamelCase, toLabelAndValue, transformObjectDeep, truncate };
|
package/react-utils.cjs.js
CHANGED
|
@@ -108,7 +108,8 @@ var DateFormat = ramda.fromPairs(ramda.keys(timeFormat).map(function (key) {
|
|
|
108
108
|
_ref$typographyProps = _ref.typographyProps,
|
|
109
109
|
typographyProps = _ref$typographyProps === void 0 ? {} : _ref$typographyProps;
|
|
110
110
|
var dateDisplay = /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, _extends$3({
|
|
111
|
-
component: "span"
|
|
111
|
+
component: "span",
|
|
112
|
+
style: "body2"
|
|
112
113
|
}, typographyProps), timeFormat[key](date));
|
|
113
114
|
return key === "extended" ? dateDisplay : /*#__PURE__*/React__default["default"].createElement(neetoui.Tooltip, _extends$3({
|
|
114
115
|
position: "top",
|
|
@@ -239,24 +240,19 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
239
240
|
return target;
|
|
240
241
|
}
|
|
241
242
|
|
|
242
|
-
var _excluded = ["
|
|
243
|
+
var _excluded = ["condition", "redirectRoute"];
|
|
243
244
|
|
|
244
245
|
var PrivateRoute = function PrivateRoute(_ref) {
|
|
245
|
-
var
|
|
246
|
-
condition = _ref.condition,
|
|
247
|
-
path = _ref.path,
|
|
246
|
+
var _ref$condition = _ref.condition,
|
|
247
|
+
condition = _ref$condition === void 0 ? globalProps.authenticated : _ref$condition,
|
|
248
248
|
redirectRoute = _ref.redirectRoute,
|
|
249
249
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
return condition ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Route, props) : /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Redirect, {
|
|
252
252
|
to: {
|
|
253
253
|
pathname: redirectRoute
|
|
254
254
|
}
|
|
255
255
|
});
|
|
256
|
-
return /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Route, _extends$3({
|
|
257
|
-
path: path,
|
|
258
|
-
component: Component
|
|
259
|
-
}, props));
|
|
260
256
|
};
|
|
261
257
|
|
|
262
258
|
function _arrayWithHoles(arr) {
|
|
@@ -470,6 +466,43 @@ var useFuncDebounce = function useFuncDebounce(func) {
|
|
|
470
466
|
return debouncedFunc;
|
|
471
467
|
};
|
|
472
468
|
|
|
469
|
+
var useForceUpdate = function useForceUpdate() {
|
|
470
|
+
var _useState = React.useState(0),
|
|
471
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
472
|
+
setValue = _useState2[1];
|
|
473
|
+
|
|
474
|
+
return function () {
|
|
475
|
+
return setValue(function (value) {
|
|
476
|
+
return value + 1;
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
482
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
483
|
+
|
|
484
|
+
var _useState = React.useState(false),
|
|
485
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
486
|
+
isIntersecting = _useState2[0],
|
|
487
|
+
setIntersecting = _useState2[1];
|
|
488
|
+
|
|
489
|
+
var forceUpdate = useForceUpdate();
|
|
490
|
+
React.useEffect(function () {
|
|
491
|
+
if (!target) return forceUpdate();
|
|
492
|
+
var observer = new IntersectionObserver(function (_ref) {
|
|
493
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
494
|
+
entry = _ref2[0];
|
|
495
|
+
|
|
496
|
+
return setIntersecting(entry.isIntersecting);
|
|
497
|
+
}, options);
|
|
498
|
+
observer.observe(target);
|
|
499
|
+
return function () {
|
|
500
|
+
return observer.unobserve(target);
|
|
501
|
+
};
|
|
502
|
+
}, [target, options]);
|
|
503
|
+
return isIntersecting;
|
|
504
|
+
};
|
|
505
|
+
|
|
473
506
|
var getStorageValue = function getStorageValue(key, defaultValue) {
|
|
474
507
|
var saved = localStorage.getItem(key);
|
|
475
508
|
return JSON.parse(saved) || defaultValue;
|
|
@@ -682,7 +715,10 @@ var SvgNeetoLogo = function SvgNeetoLogo(props) {
|
|
|
682
715
|
})))));
|
|
683
716
|
};
|
|
684
717
|
|
|
685
|
-
var ErrorPage = function ErrorPage() {
|
|
718
|
+
var ErrorPage = function ErrorPage(_ref) {
|
|
719
|
+
var _ref$homeUrl = _ref.homeUrl,
|
|
720
|
+
homeUrl = _ref$homeUrl === void 0 ? "/" : _ref$homeUrl;
|
|
721
|
+
|
|
686
722
|
var _useTranslation = reactI18next.useTranslation(),
|
|
687
723
|
t = _useTranslation.t;
|
|
688
724
|
|
|
@@ -710,7 +746,7 @@ var ErrorPage = function ErrorPage() {
|
|
|
710
746
|
className: "flex flex-row items-center justify-center"
|
|
711
747
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
712
748
|
style: "primary",
|
|
713
|
-
href:
|
|
749
|
+
href: homeUrl,
|
|
714
750
|
size: "large",
|
|
715
751
|
label: t("neetoCommons.errorPage.goToHome")
|
|
716
752
|
}))))));
|
|
@@ -1157,11 +1193,11 @@ function SignInForm(_ref) {
|
|
|
1157
1193
|
var handleFormSubmit = _ref.handleFormSubmit;
|
|
1158
1194
|
|
|
1159
1195
|
var emailFromSearchParams = function emailFromSearchParams() {
|
|
1160
|
-
return new URLSearchParams(window.location.
|
|
1196
|
+
return new URLSearchParams(window.location.search).get("email") || "";
|
|
1161
1197
|
};
|
|
1162
1198
|
|
|
1163
1199
|
var emailPrefilledInitialValues = function emailPrefilledInitialValues() {
|
|
1164
|
-
return ramda.
|
|
1200
|
+
return ramda.assoc("email", emailFromSearchParams(), INITIAL_FORM_VALUES);
|
|
1165
1201
|
};
|
|
1166
1202
|
|
|
1167
1203
|
if (formik.Button === undefined) {
|
|
@@ -1312,6 +1348,7 @@ exports.TimeFormat = TimeFormat;
|
|
|
1312
1348
|
exports.createContext = createContext;
|
|
1313
1349
|
exports.useDebounce = useDebounce;
|
|
1314
1350
|
exports.useFuncDebounce = useFuncDebounce;
|
|
1351
|
+
exports.useIsElementVisibleInDom = useIsElementVisibleInDom;
|
|
1315
1352
|
exports.useLocalStorage = useLocalStorage;
|
|
1316
1353
|
exports.useOnClickOutside = useOnClickOutside;
|
|
1317
1354
|
exports.usePrevious = usePrevious;
|
package/react-utils.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const HoneybadgerErrorBoundary: React.FC<{
|
|
|
10
10
|
}>;
|
|
11
11
|
export function PrivateRoute(
|
|
12
12
|
props: {
|
|
13
|
-
condition
|
|
13
|
+
condition?: boolean;
|
|
14
14
|
redirectRoute: string;
|
|
15
15
|
} & RouteProps
|
|
16
16
|
): JSX.Element;
|
|
@@ -36,11 +36,17 @@ export const Sidebar: React.FC<{
|
|
|
36
36
|
showAppSwitcher?: boolean;
|
|
37
37
|
}>;
|
|
38
38
|
|
|
39
|
+
type OptionsType = {
|
|
40
|
+
root?: Element | null,
|
|
41
|
+
rootMargin?: String,
|
|
42
|
+
threshold?: Number | Number[]
|
|
43
|
+
}
|
|
44
|
+
export function useIsElementVisibleInDom(target: Element | null, options?: OptionsType): Boolean
|
|
39
45
|
export function useDebounce<T>(value: T, delay?: number): T;
|
|
40
46
|
export function useFuncDebounce<F extends Function>(
|
|
41
47
|
func: F,
|
|
42
48
|
delay?: number
|
|
43
|
-
):
|
|
49
|
+
): F & { cancel: () => void };
|
|
44
50
|
export function useLocalStorage<T>(
|
|
45
51
|
key: string,
|
|
46
52
|
initialValue?: T
|
|
@@ -72,7 +78,7 @@ export function createContext<T>(
|
|
|
72
78
|
useContext: [T, (action: ActionType<T>) => void];
|
|
73
79
|
};
|
|
74
80
|
|
|
75
|
-
export const ErrorPage: React.FC<{}>;
|
|
81
|
+
export const ErrorPage: React.FC<{ homeUrl?: string }>;
|
|
76
82
|
export const LoginPage: React.FC<{
|
|
77
83
|
handleSubmit: (data: {
|
|
78
84
|
user: {
|
package/react-utils.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { useState, useEffect, useRef, useReducer } from 'react';
|
|
3
3
|
import { Typography, Tooltip, Button, Toastr } from '@bigbinary/neetoui';
|
|
4
|
-
import { fromPairs, keys, values, mergeLeft, toLower, not, isNil,
|
|
4
|
+
import { fromPairs, keys, values, mergeLeft, toLower, not, isNil, assoc } from 'ramda';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
7
7
|
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
8
8
|
import { Honeybadger, HoneybadgerErrorBoundary as HoneybadgerErrorBoundary$1 } from '@honeybadger-io/react';
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
10
|
-
import {
|
|
10
|
+
import { Route, Redirect, useLocation } from 'react-router-dom';
|
|
11
11
|
import { Settings, LeftArrow, Help, User } from '@bigbinary/neeto-icons';
|
|
12
12
|
import { Sidebar as Sidebar$1, AppSwitcher } from '@bigbinary/neetoui/layouts';
|
|
13
13
|
import i18next from 'i18next';
|
|
@@ -76,7 +76,8 @@ var DateFormat = fromPairs(keys(timeFormat).map(function (key) {
|
|
|
76
76
|
_ref$typographyProps = _ref.typographyProps,
|
|
77
77
|
typographyProps = _ref$typographyProps === void 0 ? {} : _ref$typographyProps;
|
|
78
78
|
var dateDisplay = /*#__PURE__*/React__default.createElement(Typography, _extends$3({
|
|
79
|
-
component: "span"
|
|
79
|
+
component: "span",
|
|
80
|
+
style: "body2"
|
|
80
81
|
}, typographyProps), timeFormat[key](date));
|
|
81
82
|
return key === "extended" ? dateDisplay : /*#__PURE__*/React__default.createElement(Tooltip, _extends$3({
|
|
82
83
|
position: "top",
|
|
@@ -207,24 +208,19 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
207
208
|
return target;
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
var _excluded = ["
|
|
211
|
+
var _excluded = ["condition", "redirectRoute"];
|
|
211
212
|
|
|
212
213
|
var PrivateRoute = function PrivateRoute(_ref) {
|
|
213
|
-
var
|
|
214
|
-
condition = _ref.condition,
|
|
215
|
-
path = _ref.path,
|
|
214
|
+
var _ref$condition = _ref.condition,
|
|
215
|
+
condition = _ref$condition === void 0 ? globalProps.authenticated : _ref$condition,
|
|
216
216
|
redirectRoute = _ref.redirectRoute,
|
|
217
217
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
return condition ? /*#__PURE__*/React__default.createElement(Route, props) : /*#__PURE__*/React__default.createElement(Redirect, {
|
|
220
220
|
to: {
|
|
221
221
|
pathname: redirectRoute
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
|
-
return /*#__PURE__*/React__default.createElement(Route, _extends$3({
|
|
225
|
-
path: path,
|
|
226
|
-
component: Component
|
|
227
|
-
}, props));
|
|
228
224
|
};
|
|
229
225
|
|
|
230
226
|
function _arrayWithHoles(arr) {
|
|
@@ -438,6 +434,43 @@ var useFuncDebounce = function useFuncDebounce(func) {
|
|
|
438
434
|
return debouncedFunc;
|
|
439
435
|
};
|
|
440
436
|
|
|
437
|
+
var useForceUpdate = function useForceUpdate() {
|
|
438
|
+
var _useState = useState(0),
|
|
439
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
440
|
+
setValue = _useState2[1];
|
|
441
|
+
|
|
442
|
+
return function () {
|
|
443
|
+
return setValue(function (value) {
|
|
444
|
+
return value + 1;
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
450
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
451
|
+
|
|
452
|
+
var _useState = useState(false),
|
|
453
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
454
|
+
isIntersecting = _useState2[0],
|
|
455
|
+
setIntersecting = _useState2[1];
|
|
456
|
+
|
|
457
|
+
var forceUpdate = useForceUpdate();
|
|
458
|
+
useEffect(function () {
|
|
459
|
+
if (!target) return forceUpdate();
|
|
460
|
+
var observer = new IntersectionObserver(function (_ref) {
|
|
461
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
462
|
+
entry = _ref2[0];
|
|
463
|
+
|
|
464
|
+
return setIntersecting(entry.isIntersecting);
|
|
465
|
+
}, options);
|
|
466
|
+
observer.observe(target);
|
|
467
|
+
return function () {
|
|
468
|
+
return observer.unobserve(target);
|
|
469
|
+
};
|
|
470
|
+
}, [target, options]);
|
|
471
|
+
return isIntersecting;
|
|
472
|
+
};
|
|
473
|
+
|
|
441
474
|
var getStorageValue = function getStorageValue(key, defaultValue) {
|
|
442
475
|
var saved = localStorage.getItem(key);
|
|
443
476
|
return JSON.parse(saved) || defaultValue;
|
|
@@ -650,7 +683,10 @@ var SvgNeetoLogo = function SvgNeetoLogo(props) {
|
|
|
650
683
|
})))));
|
|
651
684
|
};
|
|
652
685
|
|
|
653
|
-
var ErrorPage = function ErrorPage() {
|
|
686
|
+
var ErrorPage = function ErrorPage(_ref) {
|
|
687
|
+
var _ref$homeUrl = _ref.homeUrl,
|
|
688
|
+
homeUrl = _ref$homeUrl === void 0 ? "/" : _ref$homeUrl;
|
|
689
|
+
|
|
654
690
|
var _useTranslation = useTranslation(),
|
|
655
691
|
t = _useTranslation.t;
|
|
656
692
|
|
|
@@ -678,7 +714,7 @@ var ErrorPage = function ErrorPage() {
|
|
|
678
714
|
className: "flex flex-row items-center justify-center"
|
|
679
715
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
680
716
|
style: "primary",
|
|
681
|
-
href:
|
|
717
|
+
href: homeUrl,
|
|
682
718
|
size: "large",
|
|
683
719
|
label: t("neetoCommons.errorPage.goToHome")
|
|
684
720
|
}))))));
|
|
@@ -1125,11 +1161,11 @@ function SignInForm(_ref) {
|
|
|
1125
1161
|
var handleFormSubmit = _ref.handleFormSubmit;
|
|
1126
1162
|
|
|
1127
1163
|
var emailFromSearchParams = function emailFromSearchParams() {
|
|
1128
|
-
return new URLSearchParams(window.location.
|
|
1164
|
+
return new URLSearchParams(window.location.search).get("email") || "";
|
|
1129
1165
|
};
|
|
1130
1166
|
|
|
1131
1167
|
var emailPrefilledInitialValues = function emailPrefilledInitialValues() {
|
|
1132
|
-
return
|
|
1168
|
+
return assoc("email", emailFromSearchParams(), INITIAL_FORM_VALUES);
|
|
1133
1169
|
};
|
|
1134
1170
|
|
|
1135
1171
|
if (Button$1 === undefined) {
|
|
@@ -1270,4 +1306,4 @@ function SignIn(_ref) {
|
|
|
1270
1306
|
})));
|
|
1271
1307
|
}
|
|
1272
1308
|
|
|
1273
|
-
export { DateFormat, ErrorPage, HoneybadgerErrorBoundary, SignIn as LoginPage, PrivateRoute, Sidebar, TimeFormat, createContext, useDebounce, useFuncDebounce, useLocalStorage, useOnClickOutside, usePrevious, useUpdateEffect };
|
|
1309
|
+
export { DateFormat, ErrorPage, HoneybadgerErrorBoundary, SignIn as LoginPage, PrivateRoute, Sidebar, TimeFormat, createContext, useDebounce, useFuncDebounce, useIsElementVisibleInDom, useLocalStorage, useOnClickOutside, usePrevious, useUpdateEffect };
|