@carbonorm/carbonreact 3.0.6 → 3.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonorm/carbonreact",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,12 +1,12 @@
1
1
  import classNames from "classnames";
2
2
  import OutsideClickHandler from 'react-outside-click-handler';
3
3
  import getStyles from "hoc/getStyles";
4
+ import {PropsWithChildren} from "react";
4
5
 
5
6
 
6
7
  interface iPopupProperties {
7
8
  open?: boolean;
8
9
  handleClose: () => any;
9
- children: any;
10
10
  minWidth?: string;
11
11
  maxWidth?: string;
12
12
 
@@ -18,23 +18,22 @@ export default function Popup({
18
18
  handleClose,
19
19
  children,
20
20
  maxWidth,
21
- }: iPopupProperties) {
21
+ }: PropsWithChildren<iPopupProperties>) {
22
22
 
23
23
  if (false === open) {
24
24
 
25
+ // @link https://legacy.reactjs.org/docs/conditional-rendering.html#preventing-component-from-rendering
25
26
  return null;
26
27
 
27
28
  }
28
29
 
29
30
  const dig = getStyles()
30
31
 
31
- return <>
32
- <div className={classNames(dig.modal, dig.fade, dig.show, dig.dBlock)}
32
+ return <div className={classNames(dig.modal, dig.fade, dig.show, dig.dBlock)}
33
33
  style={{backgroundColor: "rgba(0,0,0,0.8)"}}
34
34
  id="exampleModalCenter"
35
35
  tabIndex={-1} aria-labelledby="exampleModalCenterTitle"
36
36
  aria-modal="true" role="dialog">
37
-
38
37
  <div
39
38
  style={{maxWidth: maxWidth}}
40
39
  className={classNames(
@@ -49,7 +48,6 @@ export default function Popup({
49
48
  </div>
50
49
 
51
50
  </div>
52
- </>
53
51
 
54
52
  }
55
53
 
@@ -0,0 +1,34 @@
1
+ import {AxiosResponse} from "axios";
2
+
3
+
4
+ export default function setCookies(cookies: string[], req: AxiosResponse | undefined = undefined): void {
5
+
6
+ console.log("Setting cookies", cookies);
7
+
8
+ cookies.map(cookie => {
9
+
10
+ const newCookie = cookie
11
+ .replace("HttpOnly", "")
12
+ .replace("secure", "");
13
+
14
+ if (document === undefined || document === null) {
15
+
16
+ const getStackTrace = function () {
17
+ let obj: any = {};
18
+ Error.captureStackTrace(obj, getStackTrace);
19
+ return obj.stack;
20
+ };
21
+
22
+ console.error(req)
23
+
24
+ console.log('Testing error, document not defined', req)
25
+
26
+ throw new Error("Document is undefined while trying to set cookie: (" + newCookie + ") in axiosInterceptors.tsx after (" + JSON.stringify([req?.config, req?.data], undefined, 4) + ") Please make sure all requests are wrapped in an act() from import {act} from '@testing-library/react'; (" + JSON.stringify(getStackTrace(), undefined, 4) + ")");
27
+
28
+ }
29
+
30
+ document.cookie = newCookie
31
+
32
+ });
33
+
34
+ }
package/src/index.ts CHANGED
@@ -37,6 +37,8 @@ export * from "./hoc/isEdgeBrowser";
37
37
  export * from "./hoc/parseMultipleJson";
38
38
  export { default as scrollIntoView } from "./hoc/scrollIntoView";
39
39
  export * from "./hoc/scrollIntoView";
40
+ export { default as setCookies } from "./hoc/setCookies";
41
+ export * from "./hoc/setCookies";
40
42
  export { default as setUrl } from "./hoc/setUrl";
41
43
  export * from "./hoc/setUrl";
42
44
  export { default as updateRestfulObjectArrays } from "./hoc/updateRestfulObjectArrays";