@crystallize/design-system 1.24.5 → 1.24.7

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/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  showError,
18
18
  showInfo,
19
19
  showWarning
20
- } from "./chunk-7K3KQDTQ.mjs";
20
+ } from "./chunk-BNSEEMOM.mjs";
21
21
  import "./chunk-NIH5ZMPE.mjs";
22
22
 
23
23
  // src/card/card.tsx
@@ -417,7 +417,7 @@ function Tag({
417
417
  // src/rich-text-editor/index.tsx
418
418
  import { lazy, Suspense } from "react";
419
419
  import { jsx as jsx13 } from "react/jsx-runtime";
420
- var LazyRichTextEditor = lazy(() => import("./rich-text-editor-ZJS3XSIV.mjs"));
420
+ var LazyRichTextEditor = lazy(() => import("./rich-text-editor-BSPSXJSK.mjs"));
421
421
  var RichTextEditor = (props) => {
422
422
  return /* @__PURE__ */ jsx13(Suspense, {
423
423
  fallback: null,
@@ -6,7 +6,7 @@ import {
6
6
  Icon,
7
7
  IconButton,
8
8
  InputWithLabel
9
- } from "./chunk-7K3KQDTQ.mjs";
9
+ } from "./chunk-BNSEEMOM.mjs";
10
10
  import "./chunk-NIH5ZMPE.mjs";
11
11
 
12
12
  // src/rich-text-editor/rich-text-editor.tsx
@@ -160,7 +160,7 @@ import { $createTableCellNode, $createTableNode, $createTableRowNode } from "@le
160
160
  function parseInitialState({ richText }) {
161
161
  let richTextArray = Array.isArray(richText) ? richText : [richText];
162
162
  richTextArray = richTextArray.map((rootNode) => {
163
- if (!rootNode.kind || rootNode.kind === "inline") {
163
+ if (!rootNode?.kind || rootNode.kind === "inline") {
164
164
  return {
165
165
  type: "paragraph",
166
166
  kind: "block",
@@ -180,7 +180,7 @@ function composeInitialState({ richText }) {
180
180
  crystallizeContentNode,
181
181
  lexicalParent
182
182
  }) {
183
- const { textContent, kind, type, children, metadata } = crystallizeContentNode;
183
+ const { textContent, kind, type, children, metadata } = crystallizeContentNode ?? {};
184
184
  let lexicalNode = null;
185
185
  let insertedTextContent = false;
186
186
  const customTextFormat = getLexicalTextFormat(crystallizeContentNode);
@@ -275,10 +275,14 @@ function composeInitialState({ richText }) {
275
275
  );
276
276
  break;
277
277
  }
278
+ case "container":
278
279
  case "preformatted": {
279
280
  lexicalNode = lexicalParent;
280
281
  if (children) {
281
282
  children.forEach((n) => handleNode({ crystallizeContentNode: n, lexicalParent }));
283
+ } else if (typeof textContent === "string" && kind === "inline") {
284
+ const textNode = $createTextNode(textContent);
285
+ lexicalNode.append(textNode);
282
286
  }
283
287
  return;
284
288
  }
@@ -301,11 +305,11 @@ function composeInitialState({ richText }) {
301
305
  if (textFormat && !lexicalNode.hasFormat(textFormat)) {
302
306
  lexicalNode.toggleFormat(textFormat);
303
307
  }
304
- if (child.textContent) {
308
+ if (child?.textContent) {
305
309
  lexicalNode.setTextContent(child.textContent);
306
310
  }
307
311
  }
308
- if ("children" in child) {
312
+ if (child && "children" in child) {
309
313
  child.children?.forEach(handleInlineTextChild);
310
314
  }
311
315
  };
@@ -323,7 +327,7 @@ function composeInitialState({ richText }) {
323
327
  };
324
328
  }
325
329
  function getLexicalTextFormat(node) {
326
- switch (node.type) {
330
+ switch (node?.type) {
327
331
  case "strong":
328
332
  return "bold";
329
333
  case "emphasized":
@@ -337,7 +341,7 @@ function getLexicalTextFormat(node) {
337
341
  case "deleted":
338
342
  return "strikethrough";
339
343
  case "code": {
340
- if (node.kind === "inline") {
344
+ if (node?.kind === "inline") {
341
345
  return "code";
342
346
  }
343
347
  break;
@@ -467,8 +471,8 @@ function lexicalToCrystallizeRichText({
467
471
  const [first] = children;
468
472
  if ($isTextNode2(first)) {
469
473
  const childTextNode = getTextChild(first);
470
- if (!childTextNode.type) {
471
- crystallizeNode.textContent = childTextNode.textContent;
474
+ if (!childTextNode?.type) {
475
+ crystallizeNode.textContent = childTextNode?.textContent;
472
476
  onlyChildIsPureTextContent = true;
473
477
  }
474
478
  }
@@ -520,14 +524,9 @@ function getTextChild(n) {
520
524
  kind: "inline",
521
525
  type
522
526
  };
523
- } else {
524
- currentChild.children = [
525
- {
526
- kind: "inline",
527
- type
528
- }
529
- ];
530
- currentChild = currentChild.children[0];
527
+ } else if (!!currentChild) {
528
+ currentChild.children = [{ kind: "inline", type }];
529
+ currentChild = currentChild?.children[0];
531
530
  }
532
531
  }
533
532
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.24.5",
3
+ "version": "1.24.7",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -94,7 +94,7 @@
94
94
  "tailwindcss": "^3.3.5",
95
95
  "tsup": "^6.5.0",
96
96
  "typescript": "4.9.4",
97
- "vite": "4.3.4",
97
+ "vite": "5.2.8",
98
98
  "vitest": "0.30.1",
99
99
  "tsconfig": "0.0.0"
100
100
  },
@@ -6,7 +6,7 @@
6
6
  @apply flex gap-2 items-center;
7
7
 
8
8
  &.arrow-right {
9
- @apply flex-row-reverse justify-end;
9
+ @apply flex-row-reverse;
10
10
  }
11
11
  }
12
12
 
@@ -57,6 +57,7 @@ import { LockClosed } from './lock-closed';
57
57
  import { LockOpen } from './lock-open';
58
58
  import { Magnifier } from './magnifier';
59
59
  import { Multilingual } from './multilingual';
60
+ import { MultipleChoice } from './multiple-choice';
60
61
  import { Mushroom } from './mushroom';
61
62
  import { NailPolish } from './nail-polish';
62
63
  import { Numeric } from './numeric';
@@ -147,6 +148,7 @@ export const Icon = {
147
148
  LockClosed,
148
149
  LockOpen,
149
150
  Multilingual,
151
+ MultipleChoice,
150
152
  Magnifier,
151
153
  Mushroom,
152
154
  NailPolish,
@@ -0,0 +1,57 @@
1
+ import { forwardRef, SVGProps } from 'react';
2
+
3
+ type MultipleChoiceProps = SVGProps<SVGSVGElement>;
4
+
5
+ type MultipleChoiceRef = SVGSVGElement;
6
+
7
+ export const MultipleChoice = forwardRef<MultipleChoiceRef, MultipleChoiceProps>((delegated, ref) => {
8
+ return (
9
+ <svg ref={ref} width="22" height="22" viewBox="0 0 22 22" fill="currentColor" {...delegated}>
10
+ <g clipPath="url(#a)">
11
+ <path
12
+ fill="#528693"
13
+ fillRule="evenodd"
14
+ d="M18.933 15.77a.2.2 0 0 0 .005-.37l-.91-.382a.3.3 0 1 1 .232-.553l.91.381c.663.278.651 1.221-.018 1.483l-.914.358a.3.3 0 1 1-.219-.56l.915-.357ZM16.6 14.095a.3.3 0 0 1-.392.16l-1.82-.763a.3.3 0 1 1 .231-.553l1.82.763a.3.3 0 0 1 .161.393Zm-3.64-1.526a.3.3 0 0 1-.393.16l-.91-.38a1.7 1.7 0 0 0-1.314 0l-.91.38a.3.3 0 0 1-.232-.553l.91-.381a2.3 2.3 0 0 1 1.778 0l.91.381a.3.3 0 0 1 .16.393Zm3.62 4.444a.3.3 0 0 1-.17.389l-1.83.715a.3.3 0 1 1-.218-.559l1.829-.715a.3.3 0 0 1 .388.17ZM7.772 13.1a.3.3 0 0 1-.16.393l-1.82.762a.3.3 0 1 1-.233-.553l1.82-.763a.3.3 0 0 1 .393.16Zm5.15 5.344a.3.3 0 0 1-.17.389l-.915.357a2.3 2.3 0 0 1-1.676 0l-.914-.358a.3.3 0 1 1 .218-.558l.915.357a1.7 1.7 0 0 0 1.238 0l.915-.357a.3.3 0 0 1 .388.17Zm-5.115-.497a.3.3 0 0 1-.389.17l-1.828-.715a.3.3 0 1 1 .218-.559l1.829.715a.3.3 0 0 1 .17.39Zm-3.675-3.322a.3.3 0 0 1-.16.393l-.911.381a.2.2 0 0 0 .004.371l.915.358a.3.3 0 0 1-.219.559l-.914-.358a.8.8 0 0 1-.018-1.483l.91-.381a.3.3 0 0 1 .393.16Z"
15
+ clipRule="evenodd"
16
+ />
17
+ <path
18
+ fill="#BFF6F8"
19
+ d="M10.227 8.842a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926l-7.811 3.056a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
20
+ />
21
+ <path
22
+ fill="#528693"
23
+ fillRule="evenodd"
24
+ d="m19.091 12.56-7.55-3.165a1.4 1.4 0 0 0-1.082 0l-7.55 3.164 7.581 2.966a1.4 1.4 0 0 0 1.02 0l7.581-2.966Zm-7.318-3.718a2 2 0 0 0-1.546 0l-7.778 3.26a.5.5 0 0 0 .011.926l7.811 3.056a2 2 0 0 0 1.458 0l7.81-3.056a.5.5 0 0 0 .012-.927l-7.778-3.26Z"
25
+ clipRule="evenodd"
26
+ />
27
+ <path
28
+ fill="#fff"
29
+ d="M10.227 5.685a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926l-7.811 3.056a2 2 0 0 1-1.458 0L2.461 9.87a.5.5 0 0 1-.012-.927l7.778-3.26Z"
30
+ />
31
+ <path
32
+ fill="#528693"
33
+ fillRule="evenodd"
34
+ d="m19.091 9.402-7.55-3.164a1.4 1.4 0 0 0-1.082 0l-7.55 3.164 7.581 2.966a1.4 1.4 0 0 0 1.02 0l7.581-2.966Zm-7.318-3.717a2 2 0 0 0-1.546 0l-7.778 3.26a.5.5 0 0 0 .011.926l7.811 3.056a2 2 0 0 0 1.458 0l7.81-3.056a.5.5 0 0 0 .012-.927l-7.778-3.26Z"
35
+ clipRule="evenodd"
36
+ />
37
+ <path
38
+ fill="#BFF6F8"
39
+ d="M10.227 2.528a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926L11.729 9.77a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
40
+ />
41
+ <path
42
+ fill="#528693"
43
+ fillRule="evenodd"
44
+ d="m19.091 6.245-7.55-3.164a1.4 1.4 0 0 0-1.082 0l-7.55 3.164 7.581 2.966a1.4 1.4 0 0 0 1.02 0l7.581-2.966Zm-7.318-3.717a2 2 0 0 0-1.546 0l-7.778 3.26a.5.5 0 0 0 .011.926l7.811 3.056a2 2 0 0 0 1.458 0l7.81-3.056a.5.5 0 0 0 .012-.927l-7.778-3.26Z"
45
+ clipRule="evenodd"
46
+ />
47
+ </g>
48
+ <defs>
49
+ <clipPath id="a">
50
+ <path fill="#fff" d="M0 0h22v22H0z" />
51
+ </clipPath>
52
+ </defs>
53
+ </svg>
54
+ );
55
+ });
56
+
57
+ MultipleChoice.displayName = 'MultipleChoiceIcon';
@@ -28,7 +28,7 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
28
28
  crystallizeContentNode: CrystallizeRichTextNode;
29
29
  lexicalParent: LexicalNode;
30
30
  }) {
31
- const { textContent, kind, type, children, metadata } = crystallizeContentNode;
31
+ const { textContent, kind, type, children, metadata } = crystallizeContentNode ?? {};
32
32
  let lexicalNode: LexicalNode | null = null;
33
33
 
34
34
  let insertedTextContent = false;
@@ -76,7 +76,6 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
76
76
  lexicalNode = $createCodeNode(language);
77
77
  lexicalNode.append($createCodeHighlightNode(textContent ?? ''));
78
78
  insertedTextContent = true;
79
-
80
79
  break;
81
80
  }
82
81
  case 'ordered-list': {
@@ -137,13 +136,15 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
137
136
  );
138
137
  break;
139
138
  }
139
+ // We do not deal with these tags. They should just be skipped.
140
+ case 'container':
140
141
  case 'preformatted': {
141
- /**
142
- * We do not deal with this tag. It should just be skipped.
143
- */
144
142
  lexicalNode = lexicalParent;
145
143
  if (children) {
146
144
  children.forEach(n => handleNode({ crystallizeContentNode: n, lexicalParent }));
145
+ } else if (typeof textContent === 'string' && kind === 'inline') {
146
+ const textNode = $createTextNode(textContent);
147
+ lexicalNode.append(textNode);
147
148
  }
148
149
  return;
149
150
  }
@@ -175,12 +176,12 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
175
176
  }
176
177
 
177
178
  // Text content will be stored at the deepest nested child
178
- if (child.textContent) {
179
+ if (child?.textContent) {
179
180
  lexicalNode.setTextContent(child.textContent);
180
181
  }
181
182
  }
182
183
 
183
- if ('children' in child) {
184
+ if (child && 'children' in child) {
184
185
  child.children?.forEach(handleInlineTextChild);
185
186
  }
186
187
  };
@@ -202,7 +203,7 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
202
203
  }
203
204
 
204
205
  function getLexicalTextFormat(node: CrystallizeRichTextNode): null | TextFormatType {
205
- switch (node.type) {
206
+ switch (node?.type) {
206
207
  case 'strong':
207
208
  return 'bold';
208
209
  case 'emphasized':
@@ -216,7 +217,7 @@ function getLexicalTextFormat(node: CrystallizeRichTextNode): null | TextFormatT
216
217
  case 'deleted':
217
218
  return 'strikethrough';
218
219
  case 'code': {
219
- if (node.kind === 'inline') {
220
+ if (node?.kind === 'inline') {
220
221
  return 'code';
221
222
  }
222
223
  break;
@@ -39,7 +39,7 @@ export function lexicalToCrystallizeRichText({
39
39
  editor?: LexicalEditor;
40
40
  editorState: EditorState;
41
41
  }): CrystallizeRichText {
42
- const crystallizeRichText: CrystallizeRichTextNode['children'] = [];
42
+ const crystallizeRichText: NonNullable<CrystallizeRichTextNode>['children'] | undefined = [];
43
43
 
44
44
  editorState.read(() => {
45
45
  handleNode($getRoot(), crystallizeRichText);
@@ -157,7 +157,7 @@ export function lexicalToCrystallizeRichText({
157
157
  */
158
158
  let onlyChildIsPureTextContent = false;
159
159
 
160
- const children = lexicalNode.getChildren();
160
+ const children = lexicalNode.getChildren() as ElementNode[];
161
161
  if (children?.length > 0) {
162
162
  let parentChildrenToUse = parentChildren;
163
163
  if (crystallizeNode) {
@@ -165,8 +165,8 @@ export function lexicalToCrystallizeRichText({
165
165
  const [first] = children;
166
166
  if ($isTextNode(first)) {
167
167
  const childTextNode = getTextChild(first);
168
- if (!childTextNode.type) {
169
- crystallizeNode.textContent = childTextNode.textContent;
168
+ if (!childTextNode?.type) {
169
+ crystallizeNode.textContent = childTextNode?.textContent;
170
170
  onlyChildIsPureTextContent = true;
171
171
  }
172
172
  }
@@ -228,15 +228,9 @@ function getTextChild(n: TextNode): CrystallizeRichTextNode {
228
228
  kind: 'inline',
229
229
  type,
230
230
  } as CrystallizeRichTextNode;
231
- } else {
232
- currentChild.children = [
233
- {
234
- kind: 'inline',
235
- type,
236
- },
237
- ];
238
-
239
- currentChild = currentChild.children[0];
231
+ } else if (!!currentChild) {
232
+ currentChild.children = [{ kind: 'inline', type }];
233
+ currentChild = currentChild?.children[0];
240
234
  }
241
235
  }
242
236
  }
@@ -5,7 +5,7 @@ export function parseInitialState({ richText }: { richText: CrystallizeRichText
5
5
 
6
6
  // Ensure all root items are block elements
7
7
  richTextArray = richTextArray.map(rootNode => {
8
- if (!rootNode.kind || rootNode.kind === 'inline') {
8
+ if (!rootNode?.kind || rootNode.kind === 'inline') {
9
9
  return {
10
10
  type: 'paragraph',
11
11
  kind: 'block',
@@ -54,14 +54,16 @@ export type CrystallizeRichTextInlineFormattedNodes = {
54
54
  type: 'deleted' | 'strong' | 'subscripted' | 'superscripted' | 'underlined' | 'emphasized' | 'code' | 'highlight';
55
55
  };
56
56
 
57
- export type CrystallizeRichTextNode = CrystallizeRichTextNodeBase &
58
- (
59
- | CrystallizeRichTextParagraphNode
60
- | CrystallizeRichTextHeadingNodes
61
- | CrystallizeRichTextCodeNodes
62
- | CrystallizeRichTextGenericNode
63
- | CrystallizeRichTextLinkNode
64
- | CrystallizeRichTextTableNodes
65
- | CrystallizeRichTextHorizontalLineNode
66
- | CrystallizeRichTextInlineFormattedNodes
67
- );
57
+ export type CrystallizeRichTextNode =
58
+ | (CrystallizeRichTextNodeBase &
59
+ (
60
+ | CrystallizeRichTextParagraphNode
61
+ | CrystallizeRichTextHeadingNodes
62
+ | CrystallizeRichTextCodeNodes
63
+ | CrystallizeRichTextGenericNode
64
+ | CrystallizeRichTextLinkNode
65
+ | CrystallizeRichTextTableNodes
66
+ | CrystallizeRichTextHorizontalLineNode
67
+ | CrystallizeRichTextInlineFormattedNodes
68
+ ))
69
+ | null;
package/src/tag/tag.css CHANGED
@@ -36,10 +36,16 @@
36
36
 
37
37
  .c-tag-xxs {
38
38
  @apply h-5 px-2 text-xs;
39
+ .c-tag__prepend {
40
+ @apply -ml-1;
41
+ }
39
42
  }
40
43
 
41
44
  .c-tag-xs {
42
45
  @apply h-6 px-2 text-xs;
46
+ .c-tag__prepend {
47
+ @apply -ml-1;
48
+ }
43
49
  }
44
50
 
45
51
  .c-tag-sm {