@etsoo/materialui 1.5.20 → 1.5.21

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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Custom HTML element that sanitizes and displays HTML content
3
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
4
+ * @param props Properties
5
+ * @returns Component
6
+ */
7
+ export declare function HtmlDiv(props: React.PropsWithChildren<HTMLElement>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HtmlDiv = HtmlDiv;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const dompurify_1 = __importDefault(require("dompurify"));
9
+ class HtmlDivElement extends HTMLElement {
10
+ constructor() {
11
+ super();
12
+ }
13
+ connectedCallback() {
14
+ // Create a shadow root
15
+ const shadow = this.attachShadow({ mode: "open" });
16
+ // Create a wrapper element to hold the sanitized HTML content
17
+ const wrapper = document.createElement("div");
18
+ if (this.textContent) {
19
+ wrapper.innerHTML = dompurify_1.default.sanitize(this.textContent);
20
+ }
21
+ shadow.appendChild(wrapper);
22
+ }
23
+ }
24
+ // Define the custom element only once
25
+ if (!customElements.get("html-div")) {
26
+ customElements.define("html-div", HtmlDivElement);
27
+ }
28
+ /**
29
+ * Custom HTML element that sanitizes and displays HTML content
30
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
31
+ * @param props Properties
32
+ * @returns Component
33
+ */
34
+ function HtmlDiv(props) {
35
+ // Destruct
36
+ const { children, ...rest } = props;
37
+ // Layout
38
+ return (0, jsx_runtime_1.jsx)("html-div", { ...rest, children: children });
39
+ }
@@ -9,6 +9,7 @@ export * from "./app/ServiceApp";
9
9
  export * from "./custom/CustomFieldUtils";
10
10
  export * from "./custom/CustomFieldViewer";
11
11
  export * from "./custom/CustomFieldWindow";
12
+ export * from "./html/HtmlDiv";
12
13
  export * from "./messages/MessageUtils";
13
14
  export * from "./messages/OperationMessageContainer";
14
15
  export * from "./messages/OperationMessageDto";
package/lib/cjs/index.js CHANGED
@@ -25,6 +25,7 @@ __exportStar(require("./app/ServiceApp"), exports);
25
25
  __exportStar(require("./custom/CustomFieldUtils"), exports);
26
26
  __exportStar(require("./custom/CustomFieldViewer"), exports);
27
27
  __exportStar(require("./custom/CustomFieldWindow"), exports);
28
+ __exportStar(require("./html/HtmlDiv"), exports);
28
29
  __exportStar(require("./messages/MessageUtils"), exports);
29
30
  __exportStar(require("./messages/OperationMessageContainer"), exports);
30
31
  __exportStar(require("./messages/OperationMessageDto"), exports);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Custom HTML element that sanitizes and displays HTML content
3
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
4
+ * @param props Properties
5
+ * @returns Component
6
+ */
7
+ export declare function HtmlDiv(props: React.PropsWithChildren<HTMLElement>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import DOMPurify from "dompurify";
3
+ class HtmlDivElement extends HTMLElement {
4
+ constructor() {
5
+ super();
6
+ }
7
+ connectedCallback() {
8
+ // Create a shadow root
9
+ const shadow = this.attachShadow({ mode: "open" });
10
+ // Create a wrapper element to hold the sanitized HTML content
11
+ const wrapper = document.createElement("div");
12
+ if (this.textContent) {
13
+ wrapper.innerHTML = DOMPurify.sanitize(this.textContent);
14
+ }
15
+ shadow.appendChild(wrapper);
16
+ }
17
+ }
18
+ // Define the custom element only once
19
+ if (!customElements.get("html-div")) {
20
+ customElements.define("html-div", HtmlDivElement);
21
+ }
22
+ /**
23
+ * Custom HTML element that sanitizes and displays HTML content
24
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
25
+ * @param props Properties
26
+ * @returns Component
27
+ */
28
+ export function HtmlDiv(props) {
29
+ // Destruct
30
+ const { children, ...rest } = props;
31
+ // Layout
32
+ return _jsx("html-div", { ...rest, children: children });
33
+ }
@@ -9,6 +9,7 @@ export * from "./app/ServiceApp";
9
9
  export * from "./custom/CustomFieldUtils";
10
10
  export * from "./custom/CustomFieldViewer";
11
11
  export * from "./custom/CustomFieldWindow";
12
+ export * from "./html/HtmlDiv";
12
13
  export * from "./messages/MessageUtils";
13
14
  export * from "./messages/OperationMessageContainer";
14
15
  export * from "./messages/OperationMessageDto";
package/lib/mjs/index.js CHANGED
@@ -9,6 +9,7 @@ export * from "./app/ServiceApp";
9
9
  export * from "./custom/CustomFieldUtils";
10
10
  export * from "./custom/CustomFieldViewer";
11
11
  export * from "./custom/CustomFieldWindow";
12
+ export * from "./html/HtmlDiv";
12
13
  export * from "./messages/MessageUtils";
13
14
  export * from "./messages/OperationMessageContainer";
14
15
  export * from "./messages/OperationMessageDto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.20",
3
+ "version": "1.5.21",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -44,11 +44,12 @@
44
44
  "@etsoo/notificationbase": "^1.1.60",
45
45
  "@etsoo/react": "^1.8.38",
46
46
  "@etsoo/shared": "^1.2.66",
47
- "@mui/icons-material": "^7.0.1",
48
- "@mui/material": "^7.0.1",
47
+ "@mui/icons-material": "^7.0.2",
48
+ "@mui/material": "^7.0.2",
49
49
  "@mui/x-data-grid": "^7.28.3",
50
50
  "chart.js": "^4.4.8",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
+ "dompurify": "^3.2.5",
52
53
  "eventemitter3": "^5.0.1",
53
54
  "pica": "^9.0.1",
54
55
  "pulltorefreshjs": "^0.1.22",
@@ -0,0 +1,5 @@
1
+ declare namespace JSX {
2
+ interface IntrinsicElements {
3
+ "html-div": HTMLElement;
4
+ }
5
+ }
@@ -0,0 +1,39 @@
1
+ import DOMPurify from "dompurify";
2
+
3
+ class HtmlDivElement extends HTMLElement {
4
+ constructor() {
5
+ super();
6
+ }
7
+
8
+ connectedCallback() {
9
+ // Create a shadow root
10
+ const shadow = this.attachShadow({ mode: "open" });
11
+
12
+ // Create a wrapper element to hold the sanitized HTML content
13
+ const wrapper = document.createElement("div");
14
+ if (this.textContent) {
15
+ wrapper.innerHTML = DOMPurify.sanitize(this.textContent);
16
+ }
17
+
18
+ shadow.appendChild(wrapper);
19
+ }
20
+ }
21
+
22
+ // Define the custom element only once
23
+ if (!customElements.get("html-div")) {
24
+ customElements.define("html-div", HtmlDivElement);
25
+ }
26
+
27
+ /**
28
+ * Custom HTML element that sanitizes and displays HTML content
29
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
30
+ * @param props Properties
31
+ * @returns Component
32
+ */
33
+ export function HtmlDiv(props: React.PropsWithChildren<HTMLElement>) {
34
+ // Destruct
35
+ const { children, ...rest } = props;
36
+
37
+ // Layout
38
+ return <html-div {...rest}>{children}</html-div>;
39
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,8 @@ export * from "./custom/CustomFieldUtils";
11
11
  export * from "./custom/CustomFieldViewer";
12
12
  export * from "./custom/CustomFieldWindow";
13
13
 
14
+ export * from "./html/HtmlDiv";
15
+
14
16
  export * from "./messages/MessageUtils";
15
17
  export * from "./messages/OperationMessageContainer";
16
18
  export * from "./messages/OperationMessageDto";