buildgrid-ui 1.16.0 → 1.17.1

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.
@@ -10,3 +10,4 @@ export * from './use-local-storage';
10
10
  export * from './use-media-query';
11
11
  export * from './use-mobile';
12
12
  export * from './use-pwa-install';
13
+ export * from './use-sanitized-html';
@@ -0,0 +1,59 @@
1
+ export interface UseSanitizedHtmlOptions {
2
+ /**
3
+ * Custom DOMPurify configuration options
4
+ */
5
+ sanitizeOptions?: any;
6
+ /**
7
+ * Whether to allow all HTML tags and attributes (less secure)
8
+ * @default false
9
+ */
10
+ allowAll?: boolean;
11
+ }
12
+ /**
13
+ * Hook to sanitize HTML content using DOMPurify
14
+ *
15
+ * @param htmlContent - The HTML string to sanitize
16
+ * @param options - Sanitization options
17
+ * @returns Sanitized HTML string
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * const sanitizedHtml = useSanitizedHtml('<p>Hello <script>alert("xss")</script></p>')
22
+ * // Returns: '<p>Hello </p>'
23
+ * ```
24
+ */
25
+ export declare const useSanitizedHtml: (htmlContent: string, options?: UseSanitizedHtmlOptions) => string;
26
+ /**
27
+ * Predefined sanitization presets for common use cases
28
+ */
29
+ export declare const sanitizePresets: {
30
+ /**
31
+ * Basic text formatting only (p, br, strong, em, u)
32
+ */
33
+ basic: {
34
+ ALLOWED_TAGS: string[];
35
+ ALLOWED_ATTR: string[];
36
+ };
37
+ /**
38
+ * Rich text with headings and lists
39
+ */
40
+ rich: {
41
+ ALLOWED_TAGS: string[];
42
+ ALLOWED_ATTR: string[];
43
+ };
44
+ /**
45
+ * Full content including links and media
46
+ */
47
+ full: {
48
+ ALLOWED_TAGS: string[];
49
+ ALLOWED_ATTR: string[];
50
+ };
51
+ /**
52
+ * Comments and user-generated content (very restrictive)
53
+ */
54
+ comments: {
55
+ ALLOWED_TAGS: string[];
56
+ ALLOWED_ATTR: string[];
57
+ FORBID_ATTR: string[];
58
+ };
59
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buildgrid-ui",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "homepage": "http://adrianomaringolo.github.io/buildgrid-ui",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -85,6 +85,7 @@
85
85
  "cva-extended": "^2.0.0",
86
86
  "date-fns": "^4.1.0",
87
87
  "date-fns-tz": "^3.2.0",
88
+ "dompurify": "^3.3.1",
88
89
  "embla-carousel-react": "^8.6.0",
89
90
  "highlight.js": "^11.11.1",
90
91
  "lucide-react": "^0.539.0",
@@ -112,6 +113,7 @@
112
113
  "@storybook/react-vite": "^10.1.10",
113
114
  "@testing-library/jest-dom": "^6.6.4",
114
115
  "@testing-library/react": "^16.3.0",
116
+ "@types/dompurify": "^3.0.5",
115
117
  "@types/jest": "^30.0.0",
116
118
  "@types/node": "^24.2.1",
117
119
  "@types/react": "^19.1.9",