@simpleview/cms-foundation 0.0.15 → 0.0.17
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/dist/components/ErrorBoundary/ErrorBoundary.js +30 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js.map +7 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.types.js +1 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.types.js.map +7 -0
- package/dist/components/ErrorBoundary/index.js +3 -0
- package/dist/components/ErrorBoundary/index.js.map +7 -0
- package/dist/components/Section/SectionItemCiv.js +1 -1
- package/dist/components/Section/SectionItemCiv.js.map +2 -2
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +2 -2
- package/dist/contexts/ComponentMapContext.js +6 -1
- package/dist/contexts/ComponentMapContext.js.map +2 -2
- package/dist/types/components/ErrorBoundary/ErrorBoundary.d.ts +8 -0
- package/dist/types/components/ErrorBoundary/ErrorBoundary.types.d.ts +9 -0
- package/dist/types/components/ErrorBoundary/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/contexts/ComponentMapContext.d.ts +4 -2
- package/package.json +4 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { Component } from "react";
|
|
3
|
+
class ErrorBoundary extends Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.state = { hasError: false };
|
|
7
|
+
}
|
|
8
|
+
static getDerivedStateFromError(error) {
|
|
9
|
+
return { hasError: true, error };
|
|
10
|
+
}
|
|
11
|
+
componentDidCatch(error, errorInfo) {
|
|
12
|
+
console.error("ErrorBoundary caught an error:", error, errorInfo);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
if (this.state.hasError) {
|
|
16
|
+
if (this.props.fallback) {
|
|
17
|
+
return this.props.fallback;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", { style: { padding: "20px", textAlign: "center" }, children: [
|
|
20
|
+
/* @__PURE__ */ jsx("h1", { children: "Something went wrong" }),
|
|
21
|
+
/* @__PURE__ */ jsx("p", { children: this.state.error?.message })
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
return this.props.children;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
ErrorBoundary
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/ErrorBoundary/ErrorBoundary.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { Component, type ErrorInfo, type ReactNode } from \"react\";\r\nimport type {\r\n\tErrorBoundaryProps,\r\n\tErrorBoundaryState,\r\n} from \"./ErrorBoundary.types.js\";\r\n\r\nexport class ErrorBoundary extends Component<\r\n\tErrorBoundaryProps,\r\n\tErrorBoundaryState\r\n> {\r\n\tconstructor(props: ErrorBoundaryProps) {\r\n\t\tsuper(props);\r\n\t\tthis.state = { hasError: false };\r\n\t}\r\n\r\n\tstatic getDerivedStateFromError(error: Error): ErrorBoundaryState {\r\n\t\treturn { hasError: true, error };\r\n\t}\r\n\r\n\tcomponentDidCatch(error: Error, errorInfo: ErrorInfo): void {\r\n\t\tconsole.error(\"ErrorBoundary caught an error:\", error, errorInfo);\r\n\t}\r\n\r\n\trender(): ReactNode {\r\n\t\tif (this.state.hasError) {\r\n\t\t\tif (this.props.fallback) {\r\n\t\t\t\treturn this.props.fallback;\r\n\t\t\t}\r\n\r\n\t\t\treturn (\r\n\t\t\t\t<div style={{ padding: \"20px\", textAlign: \"center\" }}>\r\n\t\t\t\t\t<h1>Something went wrong</h1>\r\n\t\t\t\t\t<p>{this.state.error?.message}</p>\r\n\t\t\t\t</div>\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn this.props.children;\r\n\t}\r\n}\r\n"],
|
|
5
|
+
"mappings": "AA8BI,SACC,KADD;AA9BJ,OAAO,SAAS,iBAAiD;AAM1D,MAAM,sBAAsB,UAGjC;AAAA,EACD,YAAY,OAA2B;AACtC,UAAM,KAAK;AACX,SAAK,QAAQ,EAAE,UAAU,MAAM;AAAA,EAChC;AAAA,EAEA,OAAO,yBAAyB,OAAkC;AACjE,WAAO,EAAE,UAAU,MAAM,MAAM;AAAA,EAChC;AAAA,EAEA,kBAAkB,OAAc,WAA4B;AAC3D,YAAQ,MAAM,kCAAkC,OAAO,SAAS;AAAA,EACjE;AAAA,EAEA,SAAoB;AACnB,QAAI,KAAK,MAAM,UAAU;AACxB,UAAI,KAAK,MAAM,UAAU;AACxB,eAAO,KAAK,MAAM;AAAA,MACnB;AAEA,aACC,qBAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,WAAW,SAAS,GAClD;AAAA,4BAAC,QAAG,kCAAoB;AAAA,QACxB,oBAAC,OAAG,eAAK,MAAM,OAAO,SAAQ;AAAA,SAC/B;AAAA,IAEF;AAEA,WAAO,KAAK,MAAM;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ErrorBoundary.types.js.map
|
|
@@ -15,7 +15,7 @@ function SectionItemCiv(civ) {
|
|
|
15
15
|
if (Component === void 0) {
|
|
16
16
|
return /* @__PURE__ */ jsx(map.Unknown, { ...civ });
|
|
17
17
|
}
|
|
18
|
-
return /* @__PURE__ */ jsx(Component, { ...civ });
|
|
18
|
+
return /* @__PURE__ */ jsx(map.ErrorBoundary, { children: /* @__PURE__ */ jsx(Component, { ...civ }) });
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
21
21
|
SectionItemCiv
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Section/SectionItemCiv.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useComponentMap } from \"../../contexts/index.js\";\r\nimport type { CivProps } from \"../../types/index.js\";\r\n\r\nexport function SectionItemCiv(civ: CivProps) {\r\n\tconst map = useComponentMap();\r\n\r\n\tif (civ === undefined) {\r\n\t\treturn (\r\n\t\t\t<map.Error\r\n\t\t\t\tstatus={500}\r\n\t\t\t\tmessage=\"Is the CMS API running? I bet it isn't \uD83D\uDE09\"\r\n\t\t\t/>\r\n\t\t);\r\n\t}\r\n\r\n\tconst Component = map.civs[civ.component];\r\n\r\n\tif (Component === undefined) {\r\n\t\treturn <map.Unknown {...civ} />;\r\n\t}\r\n\r\n\treturn <Component {...civ}
|
|
5
|
-
"mappings": "AAQG;AARH,SAAS,uBAAuB;AAGzB,SAAS,eAAe,KAAe;AAC7C,QAAM,MAAM,gBAAgB;AAE5B,MAAI,QAAQ,QAAW;AACtB,WACC;AAAA,MAAC,IAAI;AAAA,MAAJ;AAAA,QACA,QAAQ;AAAA,QACR,SAAQ;AAAA;AAAA,IACT;AAAA,EAEF;AAEA,QAAM,YAAY,IAAI,KAAK,IAAI,SAAS;AAExC,MAAI,cAAc,QAAW;AAC5B,WAAO,oBAAC,IAAI,SAAJ,EAAa,GAAG,KAAK;AAAA,EAC9B;AAEA,
|
|
4
|
+
"sourcesContent": ["import { useComponentMap } from \"../../contexts/index.js\";\r\nimport type { CivProps } from \"../../types/index.js\";\r\n\r\nexport function SectionItemCiv(civ: CivProps) {\r\n\tconst map = useComponentMap();\r\n\r\n\tif (civ === undefined) {\r\n\t\treturn (\r\n\t\t\t<map.Error\r\n\t\t\t\tstatus={500}\r\n\t\t\t\tmessage=\"Is the CMS API running? I bet it isn't \uD83D\uDE09\"\r\n\t\t\t/>\r\n\t\t);\r\n\t}\r\n\r\n\tconst Component = map.civs[civ.component];\r\n\r\n\tif (Component === undefined) {\r\n\t\treturn <map.Unknown {...civ} />;\r\n\t}\r\n\r\n\treturn (\r\n\t\t<map.ErrorBoundary>\r\n\t\t\t<Component {...civ} />\r\n\t\t</map.ErrorBoundary>\r\n\t);\r\n}\r\n"],
|
|
5
|
+
"mappings": "AAQG;AARH,SAAS,uBAAuB;AAGzB,SAAS,eAAe,KAAe;AAC7C,QAAM,MAAM,gBAAgB;AAE5B,MAAI,QAAQ,QAAW;AACtB,WACC;AAAA,MAAC,IAAI;AAAA,MAAJ;AAAA,QACA,QAAQ;AAAA,QACR,SAAQ;AAAA;AAAA,IACT;AAAA,EAEF;AAEA,QAAM,YAAY,IAAI,KAAK,IAAI,SAAS;AAExC,MAAI,cAAc,QAAW;AAC5B,WAAO,oBAAC,IAAI,SAAJ,EAAa,GAAG,KAAK;AAAA,EAC9B;AAEA,SACC,oBAAC,IAAI,eAAJ,EACA,8BAAC,aAAW,GAAG,KAAK,GACrB;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/components/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./App/index.js\";\r\nexport * from \"./Error/index.js\";\r\nexport * from \"./Layout/index.js\";\r\nexport * from \"./Preview/index.js\";\r\nexport * from \"./Section/index.js\";\r\nexport * from \"./Unknown/index.js\";\r\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from \"./App/index.js\";\r\nexport * from \"./Error/index.js\";\r\nexport * from \"./ErrorBoundary/index.js\";\r\nexport * from \"./Layout/index.js\";\r\nexport * from \"./Preview/index.js\";\r\nexport * from \"./Section/index.js\";\r\nexport * from \"./Unknown/index.js\";\r\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Unknown,
|
|
3
|
+
Error,
|
|
4
|
+
ErrorBoundary
|
|
5
|
+
} from "../components/index.js";
|
|
2
6
|
import { createContext, useContext } from "react";
|
|
3
7
|
const ComponentMapContext = createContext({
|
|
4
8
|
civs: {},
|
|
5
9
|
Error,
|
|
10
|
+
ErrorBoundary,
|
|
6
11
|
Unknown
|
|
7
12
|
});
|
|
8
13
|
const ComponentMapProvider = ComponentMapContext.Provider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/contexts/ComponentMapContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import {\r\n\tUnknown,\r\n\tError,\r\n\tErrorBoundary,\r\n\ttype ErrorProps,\r\n\ttype ErrorBoundaryProps,\r\n} from \"../components/index.js\";\r\nimport type { CivProps, ComponentMap } from \"../types/index.js\";\r\nimport { createContext, useContext, type FC, type ComponentClass } from \"react\";\r\n\r\nconst ComponentMapContext = createContext<{\r\n\tcivs: ComponentMap;\r\n\tError: FC<ErrorProps>;\r\n\tErrorBoundary: ComponentClass<ErrorBoundaryProps>;\r\n\tUnknown: FC<CivProps>;\r\n}>({\r\n\tcivs: {},\r\n\tError,\r\n\tErrorBoundary,\r\n\tUnknown,\r\n});\r\n\r\nexport const ComponentMapProvider = ComponentMapContext.Provider;\r\n\r\nexport const useComponentMap = () => useContext(ComponentMapContext);\r\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAEP,SAAS,eAAe,kBAAgD;AAExE,MAAM,sBAAsB,cAKzB;AAAA,EACF,MAAM,CAAC;AAAA,EACP;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAEM,MAAM,uBAAuB,oBAAoB;AAEjD,MAAM,kBAAkB,MAAM,WAAW,mBAAmB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
2
|
+
import type { ErrorBoundaryProps, ErrorBoundaryState } from "./ErrorBoundary.types.js";
|
|
3
|
+
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
4
|
+
constructor(props: ErrorBoundaryProps);
|
|
5
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
6
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
7
|
+
render(): ReactNode;
|
|
8
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { type ErrorProps } from "../components/index.js";
|
|
1
|
+
import { type ErrorProps, type ErrorBoundaryProps } from "../components/index.js";
|
|
2
2
|
import type { CivProps, ComponentMap } from "../types/index.js";
|
|
3
|
-
import { type FC } from "react";
|
|
3
|
+
import { type FC, type ComponentClass } from "react";
|
|
4
4
|
export declare const ComponentMapProvider: import("react").Provider<{
|
|
5
5
|
civs: ComponentMap;
|
|
6
6
|
Error: FC<ErrorProps>;
|
|
7
|
+
ErrorBoundary: ComponentClass<ErrorBoundaryProps>;
|
|
7
8
|
Unknown: FC<CivProps>;
|
|
8
9
|
}>;
|
|
9
10
|
export declare const useComponentMap: () => {
|
|
10
11
|
civs: ComponentMap;
|
|
11
12
|
Error: FC<ErrorProps>;
|
|
13
|
+
ErrorBoundary: ComponentClass<ErrorBoundaryProps>;
|
|
12
14
|
Unknown: FC<CivProps>;
|
|
13
15
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleview/cms-foundation",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.17",
|
|
5
5
|
"description": "Provides helper types and components to assist when working with Granicus CMS Reactor.",
|
|
6
6
|
"packageManager": "yarn@4.6.0+sha224.acd0786f07ffc6c933940eb65fc1d627131ddf5455bddcc295dc90fd",
|
|
7
7
|
"scripts": {
|
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
"tsx": "^4.20.3",
|
|
40
40
|
"typescript": "^5.8.3"
|
|
41
41
|
},
|
|
42
|
-
"
|
|
42
|
+
"peerDependencies": {
|
|
43
43
|
"react": "19.1.1",
|
|
44
44
|
"react-dom": "19.1.1",
|
|
45
|
-
"react-router": "7.7.0"
|
|
45
|
+
"react-router": "7.7.0",
|
|
46
|
+
"vite": "6.2.2"
|
|
46
47
|
},
|
|
47
48
|
"files": [
|
|
48
49
|
"dist/"
|