@madie/madie-design-system 1.2.64 → 1.2.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madie/madie-design-system",
3
- "version": "1.2.64",
3
+ "version": "1.2.67",
4
4
  "description": "Shared style guide across the Madie program.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/MeasureAuthoringTool/madie-design-system",
@@ -20,8 +20,12 @@
20
20
  border-top: 0;
21
21
  border-bottom-left-radius: 3px;
22
22
  border-bottom-right-radius: 3px;
23
- padding-left: 4px;
24
- padding-right: 4px;
23
+ padding-left: 0.2px;
24
+ padding-right: 0.2px;
25
+
26
+ &.has-error {
27
+ border: 1.5px solid #ae1c1c;
28
+ }
25
29
 
26
30
  :first-child {
27
31
  margin-top: 0;
@@ -188,6 +192,11 @@
188
192
  }
189
193
  }
190
194
  }
195
+
196
+ .rich-text-editor_read_only {
197
+ white-space: pre-wrap;
198
+ }
199
+
191
200
  /* Table-specific styling */
192
201
  table {
193
202
  border-collapse: collapse;
@@ -20,8 +20,12 @@
20
20
  border-top: 0;
21
21
  border-bottom-left-radius: 3px;
22
22
  border-bottom-right-radius: 3px;
23
- padding-left: 4px;
24
- padding-right: 4px;
23
+ padding-left: 0.2px;
24
+ padding-right: 0.2px;
25
+
26
+ &.has-error {
27
+ border: 1.5px solid #ae1c1c;
28
+ }
25
29
 
26
30
  :first-child {
27
31
  margin-top: 0;
@@ -189,6 +193,10 @@
189
193
  }
190
194
  }
191
195
 
196
+ .rich-text-editor_read_only {
197
+ white-space: pre-wrap;
198
+ }
199
+
192
200
  /* Table-specific styling */
193
201
  table {
194
202
  border-collapse: collapse;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { render, screen, fireEvent, waitFor } from "@testing-library/react";
3
3
  import RichTextEditor from "../../components/RichTextEditor/index";
4
+ import DOMPurify from "dompurify";
4
5
 
5
6
  describe("RichTextEditor Component", () => {
6
7
  const mockOnChange = jest.fn();
@@ -88,4 +89,45 @@ describe("RichTextEditor Component", () => {
88
89
  expect(editorContent).toBeInTheDocument();
89
90
  expect(editorContent).toHaveTextContent("Safe Content");
90
91
  });
92
+
93
+ it("test renders sanitized content with preserved whitespace when readOnly is true", () => {
94
+ const content = `this is a statement
95
+ this is a statement
96
+ this is a statement
97
+
98
+ ---------------------
99
+ this is a statement`;
100
+
101
+ render(
102
+ <RichTextEditor
103
+ id="test-editor"
104
+ label="Test Label"
105
+ content={content}
106
+ onChange={mockOnChange}
107
+ readOnly
108
+ />
109
+ );
110
+
111
+ const readOnlyContent = screen.getByTestId("test-editor-value");
112
+
113
+ // Ensure the innerHTML matches the sanitized version of the content
114
+ expect(readOnlyContent.innerHTML).toBe(DOMPurify.sanitize(content));
115
+ });
116
+
117
+ it("displays helper text when error is true", () => {
118
+ render(
119
+ <RichTextEditor
120
+ id="test-editor"
121
+ label="Test Label"
122
+ content={null}
123
+ helperText="This field is required."
124
+ required={true}
125
+ error={true}
126
+ onChange={mockOnChange}
127
+ />
128
+ );
129
+
130
+ const helperTextElement = screen.getByTestId("test-editor-helper-text");
131
+ expect(helperTextElement).toHaveTextContent("This field is required.");
132
+ });
91
133
  });