@mrshmllw/smores-react 6.0.4 → 6.1.0

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,6 @@
1
+ import { FC } from 'react';
2
+ import { MarginProps } from '../utils/space';
3
+ export interface RichTextProps extends MarginProps {
4
+ htmlString: string;
5
+ }
6
+ export declare const RichText: FC<RichTextProps>;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { Box } from '../Box';
3
+ import domPurify from 'dompurify';
4
+ import styled from 'styled-components';
5
+ import { theme } from '../theme';
6
+ import { Icon } from '../Icon';
7
+ export const RichText = ({ htmlString, ...props }) => {
8
+ const sanitisedHtml = domPurify.sanitize(htmlString);
9
+ if (!domPurify.isSupported) {
10
+ return (React.createElement(Box, { ...props },
11
+ React.createElement(WarningText, null,
12
+ React.createElement(Icon, { render: "warning" }),
13
+ "Your browser is not supported, please upgrade to a newer version"),
14
+ htmlString));
15
+ }
16
+ else {
17
+ return (React.createElement(HtmlBox, { ...props, dangerouslySetInnerHTML: { __html: sanitisedHtml } }));
18
+ }
19
+ };
20
+ const WarningText = styled(Box) `
21
+ background-color: ${theme.colors.sherbert};
22
+ padding: 16px;
23
+ border-radius: 16px;
24
+ width: fit-content;
25
+ display: flex;
26
+ align-items: center;
27
+ gap: 16px;
28
+ margin-bottom: 16px;
29
+ `;
30
+ const HtmlBox = styled(Box) `
31
+ * {
32
+ all: revert;
33
+ }
34
+ `;
35
+ //# sourceMappingURL=RichText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichText.js","sourceRoot":"","sources":["../../src/RichText/RichText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAM9B,MAAM,CAAC,MAAM,QAAQ,GAAsB,CAAC,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACtE,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IAEpD,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAC3B,OAAO,CACL,oBAAC,GAAG,OAAK,KAAK;YACZ,oBAAC,WAAW;gBACV,oBAAC,IAAI,IAAC,MAAM,EAAC,SAAS,GAAG;mFAEb;YACb,UAAU,CACP,CACP,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CACL,oBAAC,OAAO,OAAK,KAAK,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,GAAI,CAC3E,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;sBACT,KAAK,CAAC,MAAM,CAAC,QAAQ;;;;;;;;CAQ1C,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;CAI1B,CAAA"}
@@ -0,0 +1 @@
1
+ export { RichText } from './RichText';
@@ -0,0 +1,2 @@
1
+ export { RichText } from './RichText';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/RichText/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrshmllw/smores-react",
3
- "version": "6.0.4",
3
+ "version": "6.1.0",
4
4
  "main": "./dist/index.js",
5
5
  "description": "Collection of React components used by Marshmallow Technology",
6
6
  "keywords": [
@@ -49,6 +49,7 @@
49
49
  "@storybook/storybook-deployer": "^2.8.16",
50
50
  "@testing-library/react": "^14.0.0",
51
51
  "@types/body-scroll-lock": "^3.1.0",
52
+ "@types/dompurify": "^3.0.5",
52
53
  "@types/node": "^20.1.2",
53
54
  "@types/react": "^18.0.24",
54
55
  "@types/react-dom": "^18.0.8",
@@ -76,6 +77,7 @@
76
77
  "dependencies": {
77
78
  "body-scroll-lock": "^4.0.0-beta.0",
78
79
  "date-fns": "^2.16.1",
80
+ "dompurify": "^3.0.9",
79
81
  "polished": "^4.1.3"
80
82
  },
81
83
  "peerDependencies": {