@crystallize/design-system 1.24.12 → 1.24.14

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
@@ -191,15 +191,79 @@ var InlineRadio = {
191
191
  Item: InlineRadioItem
192
192
  };
193
193
 
194
- // src/progress/progress.tsx
194
+ // src/popover/popover.tsx
195
195
  import { cx as cx3 } from "class-variance-authority";
196
- import * as ProgressPrimitives from "@radix-ui/react-progress";
196
+ import * as PopoverPrimitive2 from "@radix-ui/react-popover";
197
+
198
+ // src/popover/popover-close.tsx
199
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
197
200
  import { jsx as jsx6 } from "react/jsx-runtime";
201
+ function PopoverClose(props) {
202
+ const { asChild, children } = props;
203
+ return /* @__PURE__ */ jsx6(PopoverPrimitive.Close, {
204
+ asChild,
205
+ className: "c-popover-close",
206
+ children: children ?? /* @__PURE__ */ jsx6(Icon.Cancel, {
207
+ width: 16,
208
+ height: 16
209
+ })
210
+ });
211
+ }
212
+
213
+ // src/popover/popover.tsx
214
+ import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
215
+ function Popover({
216
+ children,
217
+ closeButton,
218
+ content,
219
+ side,
220
+ open,
221
+ onOpenChange,
222
+ className,
223
+ container,
224
+ hasArrow = true,
225
+ ...delegatedContent
226
+ }) {
227
+ return /* @__PURE__ */ jsxs3(PopoverPrimitive2.Root, {
228
+ open,
229
+ onOpenChange,
230
+ children: [
231
+ /* @__PURE__ */ jsx7(PopoverPrimitive2.Trigger, {
232
+ asChild: true,
233
+ children
234
+ }),
235
+ /* @__PURE__ */ jsx7(PopoverPrimitive2.Portal, {
236
+ container,
237
+ children: /* @__PURE__ */ jsxs3(PopoverPrimitive2.Content, {
238
+ ...delegatedContent,
239
+ side,
240
+ className: cx3("c-popover-content", className),
241
+ children: [
242
+ !closeButton ? null : /* @__PURE__ */ jsx7(PopoverClose, {
243
+ asChild: typeof closeButton !== "boolean",
244
+ children: typeof closeButton !== "boolean" ? closeButton : null
245
+ }),
246
+ hasArrow && /* @__PURE__ */ jsx7(PopoverPrimitive2.Arrow, {
247
+ className: "c-popover-arrow",
248
+ offset: 5
249
+ }),
250
+ content
251
+ ]
252
+ })
253
+ })
254
+ ]
255
+ });
256
+ }
257
+
258
+ // src/progress/progress.tsx
259
+ import { cx as cx4 } from "class-variance-authority";
260
+ import * as ProgressPrimitives from "@radix-ui/react-progress";
261
+ import { jsx as jsx8 } from "react/jsx-runtime";
198
262
  function Progress({ className, value }) {
199
- return /* @__PURE__ */ jsx6(ProgressPrimitives.Root, {
200
- className: cx3(className, "c-progress-root"),
263
+ return /* @__PURE__ */ jsx8(ProgressPrimitives.Root, {
264
+ className: cx4(className, "c-progress-root"),
201
265
  value,
202
- children: /* @__PURE__ */ jsx6(ProgressPrimitives.Indicator, {
266
+ children: /* @__PURE__ */ jsx8(ProgressPrimitives.Indicator, {
203
267
  className: "c-progress-indicator",
204
268
  style: { transform: `translateX(-${100 - (value ?? 0)}%)` }
205
269
  })
@@ -208,12 +272,12 @@ function Progress({ className, value }) {
208
272
 
209
273
  // src/radio/radio.tsx
210
274
  import * as RadioGroupPrimitive2 from "@radix-ui/react-radio-group";
211
- import { jsx as jsx7 } from "react/jsx-runtime";
275
+ import { jsx as jsx9 } from "react/jsx-runtime";
212
276
  function RadioGroupItem(props) {
213
- return /* @__PURE__ */ jsx7(RadioGroupPrimitive2.Item, {
277
+ return /* @__PURE__ */ jsx9(RadioGroupPrimitive2.Item, {
214
278
  ...props,
215
279
  className: "c-radio-item",
216
- children: /* @__PURE__ */ jsx7(RadioGroupPrimitive2.Indicator, {
280
+ children: /* @__PURE__ */ jsx9(RadioGroupPrimitive2.Indicator, {
217
281
  className: "c-radio-indicator"
218
282
  })
219
283
  });
@@ -225,20 +289,20 @@ var Radio = {
225
289
 
226
290
  // src/select/select-item.tsx
227
291
  import { forwardRef as forwardRef3 } from "react";
228
- import { cx as cx4 } from "class-variance-authority";
292
+ import { cx as cx5 } from "class-variance-authority";
229
293
  import * as SelectPrimitives from "@radix-ui/react-select";
230
- import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
294
+ import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
231
295
  var SelectItem = forwardRef3((props, ref) => {
232
296
  const { children, className, ...delegated } = props;
233
- return /* @__PURE__ */ jsxs3(SelectPrimitives.Item, {
234
- className: cx4("c-select-item", className),
297
+ return /* @__PURE__ */ jsxs4(SelectPrimitives.Item, {
298
+ className: cx5("c-select-item", className),
235
299
  ref,
236
300
  ...delegated,
237
301
  children: [
238
- /* @__PURE__ */ jsx8(SelectPrimitives.ItemText, {
302
+ /* @__PURE__ */ jsx10(SelectPrimitives.ItemText, {
239
303
  children
240
304
  }),
241
- /* @__PURE__ */ jsx8(SelectPrimitives.ItemIndicator, {})
305
+ /* @__PURE__ */ jsx10(SelectPrimitives.ItemIndicator, {})
242
306
  ]
243
307
  });
244
308
  });
@@ -248,7 +312,7 @@ SelectItem.displayName = "SelectItem";
248
312
  import { forwardRef as forwardRef4 } from "react";
249
313
  import { cva as cva4 } from "class-variance-authority";
250
314
  import * as SelectPrimitives2 from "@radix-ui/react-select";
251
- import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
315
+ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
252
316
  var selectTriggerStyles = cva4("c-select-trigger", {
253
317
  variants: {
254
318
  size: {
@@ -264,34 +328,34 @@ var selectTriggerStyles = cva4("c-select-trigger", {
264
328
  });
265
329
  var SelectContainer = forwardRef4(
266
330
  ({ children, id, placeholder, disabled, size, triggerClassName, ...delegated }, ref) => {
267
- return /* @__PURE__ */ jsxs4(SelectPrimitives2.Root, {
331
+ return /* @__PURE__ */ jsxs5(SelectPrimitives2.Root, {
268
332
  ...delegated,
269
333
  children: [
270
- /* @__PURE__ */ jsxs4(SelectPrimitives2.Trigger, {
334
+ /* @__PURE__ */ jsxs5(SelectPrimitives2.Trigger, {
271
335
  ref,
272
336
  className: selectTriggerStyles({ size, className: triggerClassName }),
273
337
  disabled,
274
338
  id,
275
339
  children: [
276
- /* @__PURE__ */ jsx9(SelectPrimitives2.Value, {
277
- placeholder: /* @__PURE__ */ jsx9("span", {
340
+ /* @__PURE__ */ jsx11(SelectPrimitives2.Value, {
341
+ placeholder: /* @__PURE__ */ jsx11("span", {
278
342
  className: "c-select-value",
279
343
  children: placeholder ?? "Select..."
280
344
  })
281
345
  }),
282
- /* @__PURE__ */ jsx9(Icon.Arrow, {})
346
+ /* @__PURE__ */ jsx11(Icon.Arrow, {})
283
347
  ]
284
348
  }),
285
- /* @__PURE__ */ jsx9(SelectPrimitives2.Portal, {
286
- children: /* @__PURE__ */ jsxs4(SelectPrimitives2.Content, {
349
+ /* @__PURE__ */ jsx11(SelectPrimitives2.Portal, {
350
+ children: /* @__PURE__ */ jsxs5(SelectPrimitives2.Content, {
287
351
  className: "c-select-content",
288
352
  children: [
289
- /* @__PURE__ */ jsx9(SelectPrimitives2.ScrollUpButton, {}),
290
- /* @__PURE__ */ jsx9(SelectPrimitives2.Viewport, {
353
+ /* @__PURE__ */ jsx11(SelectPrimitives2.ScrollUpButton, {}),
354
+ /* @__PURE__ */ jsx11(SelectPrimitives2.Viewport, {
291
355
  className: "c-select-viewport",
292
356
  children
293
357
  }),
294
- /* @__PURE__ */ jsx9(SelectPrimitives2.ScrollDownButton, {})
358
+ /* @__PURE__ */ jsx11(SelectPrimitives2.ScrollDownButton, {})
295
359
  ]
296
360
  })
297
361
  })
@@ -309,22 +373,22 @@ var Select = {
309
373
 
310
374
  // src/slider/slider.tsx
311
375
  import { forwardRef as forwardRef5 } from "react";
312
- import { cx as cx5 } from "class-variance-authority";
376
+ import { cx as cx6 } from "class-variance-authority";
313
377
  import * as SliderPrimitive from "@radix-ui/react-slider";
314
- import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
378
+ import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
315
379
  var Slider = forwardRef5(({ className, transparentRange, ...delegated }, ref) => {
316
- return /* @__PURE__ */ jsxs5(SliderPrimitive.Root, {
317
- className: cx5("c-slider-root", className),
380
+ return /* @__PURE__ */ jsxs6(SliderPrimitive.Root, {
381
+ className: cx6("c-slider-root", className),
318
382
  ref,
319
383
  ...delegated,
320
384
  children: [
321
- /* @__PURE__ */ jsx10(SliderPrimitive.Track, {
385
+ /* @__PURE__ */ jsx12(SliderPrimitive.Track, {
322
386
  className: "c-slider-track",
323
- children: /* @__PURE__ */ jsx10(SliderPrimitive.Range, {
387
+ children: /* @__PURE__ */ jsx12(SliderPrimitive.Range, {
324
388
  className: `c-slider-range ${transparentRange ? "c-slider-range-transparent" : ""}`
325
389
  })
326
390
  }),
327
- /* @__PURE__ */ jsx10(SliderPrimitive.Thumb, {
391
+ /* @__PURE__ */ jsx12(SliderPrimitive.Thumb, {
328
392
  className: "c-slider-thumb"
329
393
  })
330
394
  ]
@@ -332,15 +396,15 @@ var Slider = forwardRef5(({ className, transparentRange, ...delegated }, ref) =>
332
396
  });
333
397
 
334
398
  // src/stack-icon/stack-icon.tsx
335
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
399
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
336
400
  function StackIcon({ type, children, size = 18 }) {
337
- return /* @__PURE__ */ jsxs6("span", {
401
+ return /* @__PURE__ */ jsxs7("span", {
338
402
  className: "c-stack-icon",
339
403
  children: [
340
- type === "create" && /* @__PURE__ */ jsx11("span", {
404
+ type === "create" && /* @__PURE__ */ jsx13("span", {
341
405
  style: { width: size, height: size },
342
406
  className: "c-stack-icon__icon",
343
- children: /* @__PURE__ */ jsx11(Icon.Add, {
407
+ children: /* @__PURE__ */ jsx13(Icon.Add, {
344
408
  width: size - 4,
345
409
  height: size - 4
346
410
  })
@@ -351,8 +415,8 @@ function StackIcon({ type, children, size = 18 }) {
351
415
  }
352
416
 
353
417
  // src/tag/tag.tsx
354
- import { cva as cva5, cx as cx6 } from "class-variance-authority";
355
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
418
+ import { cva as cva5, cx as cx7 } from "class-variance-authority";
419
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
356
420
  var tagStyles = cva5("c-tag", {
357
421
  variants: {
358
422
  variant: {
@@ -382,28 +446,28 @@ function Tag({
382
446
  showRemoveOnHover,
383
447
  ...delegated
384
448
  }) {
385
- return /* @__PURE__ */ jsxs7("div", {
449
+ return /* @__PURE__ */ jsxs8("div", {
386
450
  className: tagStyles({ className, variant, size }),
387
451
  ...delegated,
388
452
  children: [
389
- !prepend ? null : /* @__PURE__ */ jsx12("span", {
453
+ !prepend ? null : /* @__PURE__ */ jsx14("span", {
390
454
  className: "c-tag__prepend",
391
455
  children: prepend
392
456
  }),
393
457
  children,
394
- onRemove && /* @__PURE__ */ jsxs7("button", {
458
+ onRemove && /* @__PURE__ */ jsxs8("button", {
395
459
  type: "button",
396
- className: cx6("c-tag__remove-button", showRemoveOnHover ? "c-tag__remove-button--hover" : ""),
460
+ className: cx7("c-tag__remove-button", showRemoveOnHover ? "c-tag__remove-button--hover" : ""),
397
461
  onClick: (e) => {
398
462
  e.stopPropagation();
399
463
  onRemove();
400
464
  },
401
465
  children: [
402
- /* @__PURE__ */ jsx12(Icon.Cancel, {
466
+ /* @__PURE__ */ jsx14(Icon.Cancel, {
403
467
  width: 12,
404
468
  height: 12
405
469
  }),
406
- /* @__PURE__ */ jsx12("span", {
470
+ /* @__PURE__ */ jsx14("span", {
407
471
  className: "c-tag__remove-button-text",
408
472
  children: "Remove"
409
473
  })
@@ -415,12 +479,12 @@ function Tag({
415
479
 
416
480
  // src/rich-text-editor/index.tsx
417
481
  import { lazy, Suspense } from "react";
418
- import { jsx as jsx13 } from "react/jsx-runtime";
419
- var LazyRichTextEditor = lazy(() => import("./rich-text-editor-VSCYKBXX.mjs"));
482
+ import { jsx as jsx15 } from "react/jsx-runtime";
483
+ var LazyRichTextEditor = lazy(() => import("./rich-text-editor-4KH7E76T.mjs"));
420
484
  var RichTextEditor = (props) => {
421
- return /* @__PURE__ */ jsx13(Suspense, {
485
+ return /* @__PURE__ */ jsx15(Suspense, {
422
486
  fallback: null,
423
- children: /* @__PURE__ */ jsx13(LazyRichTextEditor, {
487
+ children: /* @__PURE__ */ jsx15(LazyRichTextEditor, {
424
488
  ...props
425
489
  })
426
490
  });
@@ -430,9 +494,9 @@ var RichTextEditor = (props) => {
430
494
  import { Toaster } from "sonner";
431
495
 
432
496
  // src/toast/toast.tsx
433
- import { cva as cva6, cx as cx7 } from "class-variance-authority";
497
+ import { cva as cva6, cx as cx8 } from "class-variance-authority";
434
498
  import { toast as sonnerToast } from "sonner";
435
- import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
499
+ import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
436
500
  var toastStyles = cva6("c-toast", {
437
501
  variants: {
438
502
  type: {
@@ -457,34 +521,34 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
457
521
  const withMessage = !!message;
458
522
  const toastId = Date.now().toString();
459
523
  sonnerToast.custom(
460
- (id) => /* @__PURE__ */ jsxs8("div", {
524
+ (id) => /* @__PURE__ */ jsxs9("div", {
461
525
  "data-testid": `toast-${type}`,
462
- className: cx7(toastStyles({ type }), withMessage ? "c-toast-with-message" : "c-toast-title-only"),
526
+ className: cx8(toastStyles({ type }), withMessage ? "c-toast-with-message" : "c-toast-title-only"),
463
527
  children: [
464
- /* @__PURE__ */ jsx14("div", {
465
- children: /* @__PURE__ */ jsx14(ToastIcon, {
528
+ /* @__PURE__ */ jsx16("div", {
529
+ children: /* @__PURE__ */ jsx16(ToastIcon, {
466
530
  width: 26,
467
531
  height: 26
468
532
  })
469
533
  }),
470
- /* @__PURE__ */ jsxs8("div", {
534
+ /* @__PURE__ */ jsxs9("div", {
471
535
  children: [
472
- /* @__PURE__ */ jsx14("div", {
536
+ /* @__PURE__ */ jsx16("div", {
473
537
  className: "c-toast-title",
474
538
  children: title
475
539
  }),
476
- !!message && /* @__PURE__ */ jsx14("div", {
540
+ !!message && /* @__PURE__ */ jsx16("div", {
477
541
  className: "c-toast-message",
478
542
  children: message
479
543
  })
480
544
  ]
481
545
  }),
482
- /* @__PURE__ */ jsx14("div", {
546
+ /* @__PURE__ */ jsx16("div", {
483
547
  className: "c-toast-close",
484
- children: /* @__PURE__ */ jsx14(IconButton, {
548
+ children: /* @__PURE__ */ jsx16(IconButton, {
485
549
  onClick: () => sonnerToast.dismiss(id),
486
550
  size: "xs",
487
- children: /* @__PURE__ */ jsx14(Icon.Cancel, {
551
+ children: /* @__PURE__ */ jsx16(Icon.Cancel, {
488
552
  width: 12,
489
553
  height: 12
490
554
  })
@@ -503,9 +567,9 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
503
567
  toast.dismiss = sonnerToast.dismiss;
504
568
 
505
569
  // src/switch/switch.tsx
506
- import { cva as cva7, cx as cx8 } from "class-variance-authority";
570
+ import { cva as cva7, cx as cx9 } from "class-variance-authority";
507
571
  import * as RadixSwitch from "@radix-ui/react-switch";
508
- import { jsx as jsx15 } from "react/jsx-runtime";
572
+ import { jsx as jsx17 } from "react/jsx-runtime";
509
573
  var switchStyles = cva7(["c-switch-root"], {
510
574
  variants: {
511
575
  size: {
@@ -518,12 +582,12 @@ var switchStyles = cva7(["c-switch-root"], {
518
582
  }
519
583
  });
520
584
  function Switch({ size, checked, ...props }) {
521
- return /* @__PURE__ */ jsx15(RadixSwitch.Root, {
585
+ return /* @__PURE__ */ jsx17(RadixSwitch.Root, {
522
586
  ...props,
523
587
  checked,
524
588
  className: switchStyles({ size }),
525
- children: /* @__PURE__ */ jsx15(RadixSwitch.Thumb, {
526
- className: cx8("c-switch-thumb", checked === null ? "middle-position" : "")
589
+ children: /* @__PURE__ */ jsx17(RadixSwitch.Thumb, {
590
+ className: cx9("c-switch-thumb", checked === null ? "middle-position" : "")
527
591
  })
528
592
  });
529
593
  }
@@ -549,6 +613,7 @@ export {
549
613
  Input,
550
614
  InputWithLabel,
551
615
  Label,
616
+ Popover,
552
617
  Progress,
553
618
  Radio,
554
619
  RichTextEditor,
@@ -159,7 +159,10 @@ import { $createTableCellNode, $createTableNode, $createTableRowNode } from "@le
159
159
  // src/rich-text-editor/model/parse-initial-state.ts
160
160
  function parseInitialState({ richText }) {
161
161
  let richTextArray = Array.isArray(richText) ? richText : [richText];
162
- richTextArray = richTextArray.map((rootNode) => {
162
+ const ensureRootBlockElements = (richTextArray2) => richTextArray2.flatMap((rootNode) => {
163
+ if (Array.isArray(rootNode)) {
164
+ return ensureRootBlockElements(rootNode);
165
+ }
163
166
  if (!rootNode?.kind || rootNode.kind === "inline") {
164
167
  return {
165
168
  type: "paragraph",
@@ -169,6 +172,7 @@ function parseInitialState({ richText }) {
169
172
  }
170
173
  return rootNode;
171
174
  });
175
+ richTextArray = ensureRootBlockElements(richTextArray);
172
176
  return richTextArray;
173
177
  }
174
178
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.24.12",
3
+ "version": "1.24.14",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -41,7 +41,7 @@
41
41
  "@radix-ui/react-collapsible": "1.0.0",
42
42
  "@radix-ui/react-dialog": "1.0.5",
43
43
  "@radix-ui/react-dropdown-menu": "2.0.6",
44
- "@radix-ui/react-popover": "1.0.0",
44
+ "@radix-ui/react-popover": "1.0.7",
45
45
  "@radix-ui/react-progress": "^1.0.1",
46
46
  "@radix-ui/react-radio-group": "1.1.0",
47
47
  "@radix-ui/react-select": "1.1.2",
package/src/index.ts CHANGED
@@ -17,6 +17,7 @@ export * from './inline-radio';
17
17
  export * from './input-with-label';
18
18
  export * from './input';
19
19
  export * from './label';
20
+ export * from './popover';
20
21
  export * from './progress';
21
22
  export * from './radio';
22
23
  export * from './select';
@@ -12,6 +12,7 @@ type PopoverProps = Pick<PopoverPrimitive.PopoverProps, 'open' | 'onOpenChange'>
12
12
  closeButton?: boolean | JSX.Element;
13
13
  hasArrow?: boolean;
14
14
  content: ReactNode;
15
+ onOpenAutoFocus?: (e: Event) => void;
15
16
  };
16
17
 
17
18
  export function Popover({
@@ -3,18 +3,25 @@ import type { CrystallizeRichText, CrystallizeRichTextNode } from '../types/crys
3
3
  export function parseInitialState({ richText }: { richText: CrystallizeRichText }): CrystallizeRichTextNode[] {
4
4
  let richTextArray = Array.isArray(richText) ? richText : [richText];
5
5
 
6
- // Ensure all root items are block elements
7
- richTextArray = richTextArray.map(rootNode => {
8
- if (!rootNode?.kind || rootNode.kind === 'inline') {
9
- return {
10
- type: 'paragraph',
11
- kind: 'block',
12
- children: [rootNode],
13
- };
14
- }
6
+ const ensureRootBlockElements = (richTextArray: CrystallizeRichText): CrystallizeRichText =>
7
+ richTextArray.flatMap(rootNode => {
8
+ if (Array.isArray(rootNode)) {
9
+ return ensureRootBlockElements(rootNode);
10
+ }
11
+
12
+ if (!rootNode?.kind || rootNode.kind === 'inline') {
13
+ return {
14
+ type: 'paragraph',
15
+ kind: 'block',
16
+ children: [rootNode],
17
+ };
18
+ }
15
19
 
16
- return rootNode;
17
- });
20
+ return rootNode;
21
+ });
22
+
23
+ // Ensure all root items are block elements
24
+ richTextArray = ensureRootBlockElements(richTextArray);
18
25
 
19
26
  return richTextArray;
20
27
  }