@etsoo/materialui 1.5.20 → 1.5.22

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,14 @@
1
+ /**
2
+ * Custom HTML element properties
3
+ * 自定义 HTML 元素属性
4
+ */
5
+ export type HtmlDivProps = Omit<HTMLElement, "children"> & {
6
+ children: React.ReactNode;
7
+ };
8
+ /**
9
+ * Custom HTML element that sanitizes and displays HTML content
10
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
11
+ * @param props Properties
12
+ * @returns Component
13
+ */
14
+ export declare function HtmlDiv(props: HtmlDivProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
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
+ this.textContent = null; // Clear the textContent to avoid duplication
21
+ }
22
+ shadow.appendChild(wrapper);
23
+ }
24
+ }
25
+ // Define the custom element only once
26
+ if (!customElements.get("html-div")) {
27
+ customElements.define("html-div", HtmlDivElement);
28
+ }
29
+ /**
30
+ * Custom HTML element that sanitizes and displays HTML content
31
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
32
+ * @param props Properties
33
+ * @returns Component
34
+ */
35
+ function HtmlDiv(props) {
36
+ // Destruct
37
+ const { children, ...rest } = props;
38
+ // Layout
39
+ return (0, jsx_runtime_1.jsx)("html-div", { ...rest, children: children });
40
+ }
@@ -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,14 @@
1
+ /**
2
+ * Custom HTML element properties
3
+ * 自定义 HTML 元素属性
4
+ */
5
+ export type HtmlDivProps = Omit<HTMLElement, "children"> & {
6
+ children: React.ReactNode;
7
+ };
8
+ /**
9
+ * Custom HTML element that sanitizes and displays HTML content
10
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
11
+ * @param props Properties
12
+ * @returns Component
13
+ */
14
+ export declare function HtmlDiv(props: HtmlDivProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
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
+ this.textContent = null; // Clear the textContent to avoid duplication
15
+ }
16
+ shadow.appendChild(wrapper);
17
+ }
18
+ }
19
+ // Define the custom element only once
20
+ if (!customElements.get("html-div")) {
21
+ customElements.define("html-div", HtmlDivElement);
22
+ }
23
+ /**
24
+ * Custom HTML element that sanitizes and displays HTML content
25
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
26
+ * @param props Properties
27
+ * @returns Component
28
+ */
29
+ export function HtmlDiv(props) {
30
+ // Destruct
31
+ const { children, ...rest } = props;
32
+ // Layout
33
+ return _jsx("html-div", { ...rest, children: children });
34
+ }
@@ -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.22",
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";
4
+ }
5
+ }
@@ -0,0 +1,48 @@
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
+ this.textContent = null; // Clear the textContent to avoid duplication
17
+ }
18
+
19
+ shadow.appendChild(wrapper);
20
+ }
21
+ }
22
+
23
+ // Define the custom element only once
24
+ if (!customElements.get("html-div")) {
25
+ customElements.define("html-div", HtmlDivElement);
26
+ }
27
+
28
+ /**
29
+ * Custom HTML element properties
30
+ * 自定义 HTML 元素属性
31
+ */
32
+ export type HtmlDivProps = Omit<HTMLElement, "children"> & {
33
+ children: React.ReactNode;
34
+ };
35
+
36
+ /**
37
+ * Custom HTML element that sanitizes and displays HTML content
38
+ * 自定义 HTML 元素,用于清理和显示 HTML 内容
39
+ * @param props Properties
40
+ * @returns Component
41
+ */
42
+ export function HtmlDiv(props: HtmlDivProps) {
43
+ // Destruct
44
+ const { children, ...rest } = props;
45
+
46
+ // Layout
47
+ return <html-div {...rest}>{children}</html-div>;
48
+ }
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";