@crystallize/design-system 1.11.6 → 1.12.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.11.6",
3
+ "version": "1.12.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -58,20 +58,20 @@
58
58
  "@faker-js/faker": "7.6.0",
59
59
  "@ianvs/prettier-plugin-sort-imports": "^3.7.1",
60
60
  "@mdx-js/react": "^2.2.1",
61
- "@storybook/addon-actions": "7.0.0-beta.14",
62
- "@storybook/addon-backgrounds": "7.0.0-beta.14",
63
- "@storybook/addon-docs": "7.0.0-beta.14",
64
- "@storybook/addon-essentials": "7.0.0-beta.14",
65
- "@storybook/addon-highlight": "7.0.0-beta.14",
66
- "@storybook/addon-interactions": "7.0.0-beta.14",
67
- "@storybook/addon-links": "7.0.0-beta.14",
68
- "@storybook/addon-measure": "7.0.0-beta.14",
69
- "@storybook/addon-outline": "7.0.0-beta.14",
61
+ "@storybook/addon-actions": "7.0.7",
62
+ "@storybook/addon-backgrounds": "7.0.7",
63
+ "@storybook/addon-docs": "7.0.7",
64
+ "@storybook/addon-essentials": "7.0.7",
65
+ "@storybook/addon-highlight": "7.0.7",
66
+ "@storybook/addon-interactions": "7.0.7",
67
+ "@storybook/addon-links": "7.0.7",
68
+ "@storybook/addon-measure": "7.0.7",
69
+ "@storybook/addon-outline": "7.0.7",
70
70
  "@storybook/addons": "^6.5.15",
71
- "@storybook/react": "7.0.0-beta.14",
72
- "@storybook/react-vite": "7.0.0-beta.14",
71
+ "@storybook/react": "7.0.7",
72
+ "@storybook/react-vite": "7.0.7",
73
73
  "@storybook/testing-library": "^0.0.13",
74
- "@storybook/theming": "7.0.0-beta.14",
74
+ "@storybook/theming": "7.0.7",
75
75
  "@testing-library/jest-dom": "^5.16.4",
76
76
  "@testing-library/react": "^12.0.0",
77
77
  "@testing-library/user-event": "^14.4.3",
@@ -83,14 +83,14 @@
83
83
  "concurrently": "^7.6.0",
84
84
  "hex-rgb": "4.3.0",
85
85
  "postcss": "^8.4.21",
86
- "storybook": "7.0.0-beta.14",
86
+ "storybook": "7.0.7",
87
87
  "storybook-addon-designs": "^6.3.1",
88
88
  "storybook-dark-mode": "^2.0.5",
89
89
  "tailwindcss": "^3.3.0",
90
90
  "tsup": "^6.5.0",
91
91
  "typescript": "^4.9.4",
92
- "vite": "^4.2.1",
93
- "vitest": "^0.30.1",
92
+ "vite": "4.3.4",
93
+ "vitest": "0.30.1",
94
94
  "tsconfig": "0.0.0"
95
95
  },
96
96
  "keywords": [
@@ -116,7 +116,7 @@
116
116
  "build:storybook": "storybook build -s public",
117
117
  "build:tw": "tailwindcss --content ./src/**/*.tsx,!./src/**/*.stories.tsx -c ./tailwind.config.cjs -i src/index.css -o dist/index.css --minify",
118
118
  "build:tsup": "tsup src/index.ts --format esm,cjs --dts",
119
- "build": "pnpm build:tw && pnpm build:tsup && pnpm build:storybook",
119
+ "build": "pnpm build:tw && pnpm build:tsup",
120
120
  "dev:tw": "tailwindcss --content ./src/**/*.tsx,!./src/**/*.stories.tsx -c ./tailwind.config.cjs -i src/index.css -o dist/index.css --watch & tsup src/index.ts --format esm --dts --watch",
121
121
  "dev:tsup": "tsup src/index.ts --format esm --dts --watch",
122
122
  "dev:storybook": "storybook dev -p 6006 --no-open -s public",
@@ -15,6 +15,10 @@
15
15
  outline-color: currentColor;
16
16
  }
17
17
 
18
+ &:enabled {
19
+ @apply cursor-pointer;
20
+ }
21
+
18
22
  &:not(:disabled):hover {
19
23
  @apply gap-[3px] bg-gray-100-800 outline outline-1 outline-purple-200-700;
20
24
  }
@@ -22,11 +22,12 @@ type ActionMenuProps = ButtonStylesProps & {
22
22
  children: ReactNode;
23
23
  container?: Container;
24
24
  tabIndex?: number;
25
+ disabled?: boolean;
25
26
  };
26
27
 
27
- export function ActionMenu({ children, container, tabIndex, size }: ActionMenuProps) {
28
+ export function ActionMenu({ children, container, tabIndex, size, disabled }: ActionMenuProps) {
28
29
  return (
29
- <DropdownMenu.Root content={children} alignContent="center" container={container}>
30
+ <DropdownMenu.Root content={children} alignContent="center" container={container} disabled={disabled}>
30
31
  <button
31
32
  aria-label="more options"
32
33
  className={buttonStyles({ size })}
@@ -1,11 +1,10 @@
1
1
  import type { ReactNode, RefAttributes } from 'react';
2
- import * as DialogPrimitive from '@radix-ui/react-dialog';
3
2
  import { cva, cx, VariantProps } from 'class-variance-authority';
3
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
4
4
 
5
5
  import { Button } from '../button';
6
6
  import { Icon } from '../iconography';
7
7
  import type { DialogFuncProps } from './types';
8
-
9
8
  import './dialog.css';
10
9
 
11
10
  const IconMap = {
@@ -0,0 +1,34 @@
1
+ import { forwardRef, SVGProps } from 'react';
2
+
3
+ type BinProps = SVGProps<SVGSVGElement>;
4
+
5
+ type BinRef = SVGSVGElement;
6
+
7
+ export const Bin = forwardRef<BinRef, BinProps>((delegated, ref) => {
8
+ return (
9
+ <svg ref={ref} width="22" height="22" viewBox="0 0 22 22" fill="none" {...delegated}>
10
+ <path fill="#BFF6F8" d="M5.5 6h11v13h-11V6Z" />
11
+ <path
12
+ fill="#528693"
13
+ fillRule="evenodd"
14
+ d="M4.9 6a.6.6 0 0 1 .6-.6h11a.6.6 0 0 1 .6.6v13a.6.6 0 0 1-.6.6h-11a.6.6 0 0 1-.6-.6V6Zm.6 0v13h11V6h-11Z"
15
+ clipRule="evenodd"
16
+ />
17
+ <path fill="#BFF6F8" d="M15.25 4.5h-8.5a2 2 0 0 0-2 2h12.5a2 2 0 0 0-2-2Z" />
18
+ <path
19
+ fill="#528693"
20
+ fillRule="evenodd"
21
+ d="M17.85 7.1H4.15v-.6a2.6 2.6 0 0 1 2.6-2.6h8.5a2.6 2.6 0 0 1 2.6 2.6v.6ZM4.842 5.9A2 2 0 0 1 6.75 4.5h8.5a2 2 0 0 1 2 2H4.75a2 2 0 0 1 .092-.6Z"
22
+ clipRule="evenodd"
23
+ />
24
+ <path
25
+ fill="#528693"
26
+ fillRule="evenodd"
27
+ d="M8.45 4a1.6 1.6 0 0 1 1.6-1.6h1.9a1.6 1.6 0 0 1 1.6 1.6h-.6a1 1 0 0 0-1-1h-1.9a1 1 0 0 0-1 1h-.6ZM8.4 8.2a.3.3 0 0 1 .3.3v9a.3.3 0 1 1-.6 0v-9a.3.3 0 0 1 .3-.3ZM11 8.2a.3.3 0 0 1 .3.3v9a.3.3 0 1 1-.6 0v-9a.3.3 0 0 1 .3-.3ZM13.6 8.2a.3.3 0 0 1 .3.3v9a.3.3 0 1 1-.6 0v-9a.3.3 0 0 1 .3-.3Z"
28
+ clipRule="evenodd"
29
+ />
30
+ </svg>
31
+ );
32
+ });
33
+
34
+ Bin.displayName = 'BinIcon';
@@ -6,24 +6,16 @@ type EditRef = SVGSVGElement;
6
6
 
7
7
  export const Edit = forwardRef<EditRef, EditProps>((delegated, ref) => {
8
8
  return (
9
- <svg
10
- ref={ref}
11
- width="22"
12
- height="22"
13
- viewBox="0 0 22 22"
14
- fill="none"
15
- xmlns="http://www.w3.org/2000/svg"
16
- {...delegated}
17
- >
9
+ <svg ref={ref} width="22" height="22" viewBox="0 0 22 22" fill="none" {...delegated}>
18
10
  <path
19
- d="M18.4051 7.1124C18.41 7.09758 18.4248 7.10252 18.4347 7.09264C17.1224 5.77326 16.3152 5.0028 15.0079 3.67566L4.87616 13.916L3.71256 18.5L8.3771 16.9118L12.4481 13.0002C15.2506 10.2669 15.6069 9.86404 18.4051 7.1124Z"
20
11
  fill="#BFF6F8"
12
+ d="M18.293 7.112c.005-.014.02-.01.03-.02-1.313-1.319-2.12-2.09-3.428-3.416L4.764 13.916 3.6 18.5l4.665-1.588L12.335 13c2.803-2.733 3.16-3.136 5.957-5.888Z"
21
13
  />
22
14
  <path
23
- fill-rule="evenodd"
24
- clip-rule="evenodd"
25
- d="M18.8601 6.66954C19.0934 6.90404 19.0929 7.28307 18.859 7.51694C18.8345 7.54136 18.8098 7.56205 18.7858 7.57957C17.5816 8.76397 16.8308 9.51236 16.1327 10.2081C15.2384 11.0996 14.4307 11.9047 12.8671 13.4298L12.8638 13.4329L8.79281 17.3445C8.7295 17.4053 8.6536 17.4515 8.57049 17.4798L3.90595 19.068C3.69763 19.1389 3.46719 19.0901 3.30551 18.9408C3.14383 18.7915 3.07686 18.5657 3.13101 18.3524L4.2946 13.7684C4.32091 13.6648 4.37444 13.5701 4.44964 13.494L14.5813 3.25369C14.6942 3.13962 14.848 3.07551 15.0085 3.07568C15.169 3.07586 15.3227 3.1403 15.4353 3.25461C16.1648 3.99512 16.7297 4.55358 17.3157 5.13286C17.7852 5.59695 18.2682 6.07441 18.8601 6.66954ZM18.0109 6.66797C18.0089 6.66601 18.007 6.66405 18.005 6.66209C17.6061 6.26368 17.2496 5.91124 16.8996 5.56518C16.4274 5.09833 15.9669 4.64309 15.4298 4.10229C15.2945 3.96604 15.1543 3.82435 15.0079 3.67568L4.87616 13.916L3.71256 18.5L8.3771 16.9118L12.4481 13.0002C14.0128 11.4741 14.815 10.6745 15.7054 9.78696C16.3298 9.16449 16.9976 8.49875 18.0024 7.50881C18.1309 7.38218 18.2649 7.25025 18.4051 7.11242C18.408 7.10379 18.4142 7.10186 18.4208 7.0998C18.4256 7.09834 18.4305 7.09681 18.4346 7.09274C18.4346 7.09277 18.4347 7.09272 18.4346 7.09274C18.2875 6.94479 18.1468 6.80367 18.0109 6.66797Z"
26
15
  fill="#528693"
16
+ fillRule="evenodd"
17
+ d="M18.748 6.67a.6.6 0 0 1-.075.91c-1.204 1.184-1.955 1.932-2.653 2.628a359.59 359.59 0 0 1-3.265 3.222l-.004.003-4.07 3.912a.6.6 0 0 1-.223.135l-4.665 1.588a.6.6 0 0 1-.775-.716l1.164-4.584a.6.6 0 0 1 .155-.274L14.47 3.254a.6.6 0 0 1 .854 0c.73.741 1.294 1.3 1.88 1.879.47.464.953.941 1.545 1.537Zm-.85-.002-.006-.006c-.398-.398-.755-.75-1.105-1.097a216.01 216.01 0 0 1-1.892-1.89L4.764 13.917 3.6 18.5l4.665-1.588L12.335 13c1.565-1.526 2.367-2.325 3.258-3.213.624-.623 1.292-1.288 2.297-2.278l.402-.397c.003-.008.01-.01.016-.012.005-.002.01-.003.014-.007l-.424-.425Z"
18
+ clipRule="evenodd"
27
19
  />
28
20
  </svg>
29
21
  );
@@ -3,6 +3,7 @@ import { App } from './app';
3
3
  import { Arrow } from './arrow';
4
4
  import { Atom } from './atom';
5
5
  import { BillingPayments } from './billing-payments';
6
+ import { Bin } from './bin';
6
7
  import { Cancel } from './cancel';
7
8
  import { Catalogue } from './catalogue';
8
9
  import { CheckWithCircle } from './check-with-circle';
@@ -28,6 +29,7 @@ import { Key } from './key';
28
29
  import { Language } from './language';
29
30
  import { LockClosed } from './lock-closed';
30
31
  import { Multilingual } from './multilingual';
32
+ import { Mushroom } from './mushroom';
31
33
  import { NailPolish } from './nail-polish';
32
34
  import { Order } from './order';
33
35
  import { Particle } from './particle';
@@ -44,6 +46,7 @@ import { SubscriptionContracts } from './subscription-contracts';
44
46
  import { SubscriptionPlans } from './subscription-plans';
45
47
  import { Target } from './target';
46
48
  import { Topics } from './topics';
49
+ import { Unpublish } from './unpublish';
47
50
  import { Usage } from './usage';
48
51
  import { UsageMeter } from './usage-meter';
49
52
  import { UserCard } from './user-card';
@@ -56,6 +59,7 @@ export const Icon = {
56
59
  Arrow,
57
60
  Atom,
58
61
  BillingPayments,
62
+ Bin,
59
63
  Cancel,
60
64
  Catalogue,
61
65
  CheckWithCircle,
@@ -81,6 +85,7 @@ export const Icon = {
81
85
  Language,
82
86
  LockClosed,
83
87
  Multilingual,
88
+ Mushroom,
84
89
  NailPolish,
85
90
  Order,
86
91
  Particle,
@@ -101,6 +106,7 @@ export const Icon = {
101
106
  Target,
102
107
  Topics,
103
108
  UsageMeter,
109
+ Unpublish,
104
110
  Usage,
105
111
  UserCard,
106
112
  Users,
@@ -0,0 +1,74 @@
1
+ import { forwardRef, SVGProps } from 'react';
2
+
3
+ type MushroomProps = SVGProps<SVGSVGElement>;
4
+
5
+ type MushroomRef = SVGSVGElement;
6
+
7
+ export const Mushroom = forwardRef<MushroomRef, MushroomProps>((delegated, ref) => {
8
+ return (
9
+ <svg ref={ref} width="22" height="22" viewBox="0 0 22 22" fill="none" {...delegated}>
10
+ <path
11
+ fill="#fff"
12
+ d="m6.102 13.239 2.683 1.042 6.438-.722s.33 3.881-1.237 4.711c-1.71.906-6.004.714-6.976-.83-1.092-1.735-.908-4.201-.908-4.201Z"
13
+ />
14
+ <path
15
+ fill="#468695"
16
+ fillRule="evenodd"
17
+ d="m5.564 12.386 3.301 1.283 6.904-.775.052.614-.598.051-6.438.722-2.683-1.042-.598-.045.06-.808Zm.53 1.493c-.01-.393.008-.64.008-.64l-.598-.045v.012l-.002.026a8.228 8.228 0 0 0-.01.419c-.002.275.01.66.058 1.103.095.873.337 2.027.953 3.006.34.541.928.905 1.549 1.147.632.247 1.371.397 2.115.464 1.46.133 3.096-.04 4.1-.57.572-.304.917-.854 1.132-1.397.217-.551.33-1.174.39-1.738a12.514 12.514 0 0 0 .036-2.106l-.003-.037V13.51l-.001-.002-.598.051c0 .003.02.237.027.601.02 1.123-.082 3.484-1.264 4.11-1.71.906-6.004.714-6.976-.83-.746-1.185-.896-2.713-.917-3.561Z"
18
+ clipRule="evenodd"
19
+ />
20
+ <path
21
+ fill="#BFF6F8"
22
+ d="M17.618 9.944c0 3.195-3.875 4.271-6.712 4.271-5.683 0-6.976-2.556-6.976-4.512 0-2.837 4.138-7.1 6.976-7.1 2.837 0 6.712 3.22 6.712 7.34Z"
23
+ />
24
+ <path
25
+ fill="#468695"
26
+ fillRule="evenodd"
27
+ d="M15.596 13.813c-1.433.724-3.212 1.002-4.69 1.002-2.921 0-4.827-.656-6.009-1.666-1.195-1.022-1.567-2.334-1.567-3.446 0-.845.304-1.744.763-2.592.463-.854 1.104-1.697 1.832-2.441.727-.744 1.555-1.403 2.399-1.879.837-.472 1.731-.788 2.582-.788 1.622 0 3.444.905 4.843 2.3 1.411 1.407 2.469 3.388 2.469 5.64 0 1.9-1.174 3.139-2.622 3.87Zm-4.69.402c2.837 0 6.712-1.076 6.712-4.271 0-4.122-3.875-7.34-6.712-7.34-2.838 0-6.976 4.262-6.976 7.1 0 1.954 1.293 4.511 6.976 4.511Z"
28
+ clipRule="evenodd"
29
+ />
30
+ <path
31
+ fill="#fff"
32
+ d="M4.06 8.155c3.643 2.103 2.76 4.098 1.826 5.403 0 0-.953-.59-1.365-1.153a4.633 4.633 0 0 1-.865-2.058c-.147-.933.404-2.192.404-2.192Z"
33
+ />
34
+ <path
35
+ fill="#468695"
36
+ fillRule="evenodd"
37
+ d="M4.279 12.582a4.933 4.933 0 0 1-.92-2.189c-.083-.53.032-1.13.154-1.572a6.909 6.909 0 0 1 .264-.769l.005-.012.002-.004c0-.001 0-.002.276.119l-.276-.12.135-.308.29.168c1.86 1.073 2.643 2.164 2.778 3.223.133 1.044-.382 1.95-.857 2.615l-.163.228-.239-.148-.003-.002-.01-.006-.033-.02a8.67 8.67 0 0 1-.505-.352c-.293-.222-.664-.532-.898-.851Zm1.527.563c.383-.584.676-1.244.586-1.951-.095-.745-.63-1.637-2.18-2.599-.038.11-.08.241-.12.386-.117.42-.203.918-.14 1.32.112.713.382 1.34.811 1.926.179.244.49.51.776.726.097.073.189.139.267.192Z"
38
+ clipRule="evenodd"
39
+ />
40
+ <path
41
+ fill="#fff"
42
+ d="M15.12 13.599c-1.09-4.064.945-4.85 2.529-5.113 0 0 .348 1.312.24 2.002-.118.764-.389 1.176-.843 1.8-.556.764-1.927 1.311-1.927 1.311Z"
43
+ />
44
+ <path
45
+ fill="#468695"
46
+ fillRule="evenodd"
47
+ d="M18.186 10.534c-.13.837-.436 1.296-.898 1.931-.317.436-.847.79-1.267 1.026a7.779 7.779 0 0 1-.772.379l-.013.005-.004.002-.113-.278.112.278-.314.126-.088-.326c-.555-2.074-.337-3.4.316-4.243.644-.833 1.65-1.11 2.454-1.244l.27-.044.07.263v.005l.004.012.011.045.04.163c.031.138.073.329.11.542.074.414.144.959.082 1.358Zm-.763-1.7c-.688.141-1.365.4-1.804.967-.46.594-.712 1.602-.296 3.378.116-.056.255-.127.404-.21.405-.229.838-.53 1.076-.857.448-.615.683-.98.79-1.67.045-.29-.006-.746-.08-1.161-.03-.17-.062-.325-.09-.448Z"
48
+ clipRule="evenodd"
49
+ />
50
+ <path
51
+ fill="#fff"
52
+ d="M13.758 3.166C10.783 6.141 8.7 4.81 7.68 3.57c0 0 1.192-.774 1.843-1.027.72-.279 1.269-.29 2.037-.21.938.1 2.197.834 2.197.834Z"
53
+ />
54
+ <path
55
+ fill="#468695"
56
+ fillRule="evenodd"
57
+ d="M9.416 2.263c.78-.303 1.382-.313 2.177-.229.519.055 1.104.28 1.542.48a10.064 10.064 0 0 1 .713.359l.044.024.012.007.004.002.337.197-.275.275c-1.527 1.527-2.877 1.998-4.018 1.868-1.13-.128-1.969-.837-2.503-1.486l-.213-.26.281-.183.004-.002.01-.007.04-.025a20.263 20.263 0 0 1 .634-.39c.379-.225.86-.494 1.21-.63ZM8.139 3.634c.47.493 1.103.927 1.88 1.016.838.095 1.919-.202 3.234-1.414a9.412 9.412 0 0 0-.366-.176c-.426-.193-.939-.385-1.358-.429-.741-.079-1.237-.065-1.896.191-.3.116-.741.36-1.122.586-.138.083-.266.16-.372.226Z"
58
+ clipRule="evenodd"
59
+ />
60
+ <path
61
+ fill="#fff"
62
+ d="M12.719 9.265c0 .918-.549 2.113-1.492 2.113s-1.924-1.195-1.924-2.113c0-.92-.055-1.88.888-1.88.943 0 2.528.96 2.528 1.88Z"
63
+ />
64
+ <path
65
+ fill="#468695"
66
+ fillRule="evenodd"
67
+ d="M12.837 10.98c-.316.513-.852.998-1.61.998-.713 0-1.345-.436-1.766-.916-.426-.485-.758-1.148-.758-1.797V9.12c-.002-.394-.005-.9.115-1.31.073-.248.205-.52.457-.725.257-.211.575-.3.916-.3.634 0 1.384.304 1.959.7.295.205.576.454.788.739.21.281.38.637.38 1.04 0 .563-.163 1.202-.48 1.716Zm-1.61.398c.943 0 1.492-1.195 1.492-2.113 0-.92-1.585-1.88-2.528-1.88-.893 0-.89.863-.888 1.735v.145c0 .918.98 2.113 1.924 2.113ZM10.913 15.51c.237 0 .43.134.43.3v.966c0 .166-.193.3-.43.3-.238 0-.43-.134-.43-.3v-.966c0-.166.192-.3.43-.3ZM13.815 15.158c.238 0 .43.135.43.3v.966c0 .166-.192.3-.43.3-.237 0-.43-.134-.43-.3v-.966c0-.165.193-.3.43-.3Z"
68
+ clipRule="evenodd"
69
+ />
70
+ </svg>
71
+ );
72
+ });
73
+
74
+ Mushroom.displayName = 'MushroomIcon';
@@ -0,0 +1,43 @@
1
+ import { forwardRef, SVGProps } from 'react';
2
+
3
+ type UnpublishProps = SVGProps<SVGSVGElement>;
4
+
5
+ type UnpublishRef = SVGSVGElement;
6
+
7
+ export const Unpublish = forwardRef<UnpublishRef, UnpublishProps>((delegated, ref) => {
8
+ return (
9
+ <svg ref={ref} width="22" height="22" viewBox="0 0 22 22" fill="none" {...delegated}>
10
+ <path
11
+ fill="#fff"
12
+ d="M19.055 13.054c-.595 1.263-1.441 1.553-3.22 1.553-3.734 0-5.845-.123-9.562-.123-1.725 0-3.546-.242-4.082-1.92-.34-1.064-.153-2.123.496-2.817.473-.493 1.014-.699 1.76-.763.563-.048 1.429.226 1.429.226s-.324-2.173.61-2.764c.37-.234.64-.306 1.078-.308.343-.003.86.18.86.18l.911.642s1.164-2.957 3.686-2.957c.217 0 .434.022.647.067 1.136.242 2.228.971 2.757 2.259.405.986.05 2.729.05 2.729s1.887.405 2.454 1.338c.54.888.57 1.718.126 2.658Z"
13
+ />
14
+ <path
15
+ fill="#528693"
16
+ fillRule="evenodd"
17
+ d="M2.254 9.331c.6-.625 1.294-.872 2.143-.944.27-.023.568.008.825.052a6.314 6.314 0 0 1 .01-.424c.02-.339.072-.727.199-1.087.125-.357.344-.742.734-.989.219-.138.432-.244.671-.311a2.67 2.67 0 0 1 .724-.09c.255-.002.534.061.715.109a5.195 5.195 0 0 1 .317.094l.022.008.006.002h.002l.001.001-.2.566s-.516-.183-.86-.18c-.437.002-.707.074-1.077.308-.607.384-.683 1.436-.662 2.125.012.372.052.639.052.639s-.279-.088-.622-.156c-.263-.05-.563-.09-.806-.07-.747.064-1.288.27-1.76.763-.65.694-.837 1.753-.497 2.817.536 1.678 2.357 1.92 4.082 1.92 1.856 0 3.312.03 4.77.062 1.46.03 2.923.061 4.793.061 1.778 0 2.624-.29 3.22-1.553.442-.94.412-1.77-.127-2.658-.567-.933-2.455-1.338-2.455-1.338s.357-1.743-.049-2.73c-.529-1.287-1.621-2.016-2.757-2.258a3.144 3.144 0 0 0-.647-.067c-1.83 0-2.945 1.557-3.419 2.411-.18.324-.267.546-.267.546l-.911-.642.2-.566a.602.602 0 0 1 .146.075l.34.24c.158-.28.376-.622.658-.966.66-.805 1.735-1.698 3.252-1.698.26 0 .517.026.77.08h.003C15.09 3.759 16.364 4.6 16.98 6.1c.26.63.26 1.432.22 2.003-.013.19-.031.365-.05.517.166.051.36.118.562.2.552.22 1.336.615 1.73 1.263.311.513.493 1.04.518 1.594.025.554-.109 1.094-.362 1.632-.342.725-.792 1.237-1.461 1.54-.632.287-1.399.357-2.301.357-1.875 0-3.342-.03-4.801-.061h-.004c-1.458-.031-2.908-.062-4.758-.062-.876 0-1.851-.059-2.693-.367-.87-.319-1.624-.916-1.96-1.97-.393-1.228-.197-2.527.629-3.41l.005-.006Z"
18
+ clipRule="evenodd"
19
+ />
20
+ <path fill="#BFF6F8" d="M14.8 14.25a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" />
21
+ <path
22
+ fill="#528693"
23
+ fillRule="evenodd"
24
+ d="M15.4 14.25a4.35 4.35 0 1 1-8.7 0 4.35 4.35 0 0 1 8.7 0ZM11.05 18a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z"
25
+ clipRule="evenodd"
26
+ />
27
+ <path
28
+ fill="#528693"
29
+ fillRule="evenodd"
30
+ d="M9.088 12.288a.3.3 0 0 1 .424 0l3.5 3.5a.3.3 0 1 1-.424.424l-3.5-3.5a.3.3 0 0 1 0-.424Z"
31
+ clipRule="evenodd"
32
+ />
33
+ <path
34
+ fill="#528693"
35
+ fillRule="evenodd"
36
+ d="M9.088 16.212a.3.3 0 0 1 0-.424l3.5-3.5a.3.3 0 1 1 .424.424l-3.5 3.5a.3.3 0 0 1-.424 0Z"
37
+ clipRule="evenodd"
38
+ />
39
+ </svg>
40
+ );
41
+ });
42
+
43
+ Unpublish.displayName = 'UnpublishIcon';
@@ -15,13 +15,12 @@ import { $createHeadingNode, $createQuoteNode } from '@lexical/rich-text';
15
15
  import { $createTableCellNode, $createTableNode, $createTableRowNode } from '@lexical/table';
16
16
 
17
17
  import type { CrystallizeRichTextNode, CrystallizeRichText } from '../types/crystallize-rich-text-types';
18
+ import { parseInitialState } from './parse-initial-state';
18
19
 
19
20
  export function composeInitialState({ richText }: { richText: CrystallizeRichText }) {
20
21
  return function setLexicalState() {
21
22
  const root = $getRoot();
22
23
 
23
- const richTextArray = Array.isArray(richText) ? richText : [richText];
24
-
25
24
  function handleNode({
26
25
  crystallizeContentNode,
27
26
  lexicalParent,
@@ -196,7 +195,9 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
196
195
  }
197
196
  }
198
197
 
199
- richTextArray.forEach(crystallizeContentNode => handleNode({ crystallizeContentNode, lexicalParent: root }));
198
+ parseInitialState({ richText }).forEach(crystallizeContentNode =>
199
+ handleNode({ crystallizeContentNode, lexicalParent: root }),
200
+ );
200
201
  };
201
202
  }
202
203
 
@@ -0,0 +1,48 @@
1
+ /* eslint-disable no-console */
2
+
3
+ import type { CrystallizeRichText } from '../rich-text-editor';
4
+ import { parseInitialState } from './parse-initial-state';
5
+
6
+ describe('RichTextEditor parseInitialState', () => {
7
+ it('ensures that the initial state is an array', async () => {
8
+ expect(
9
+ parseInitialState({
10
+ richText: {
11
+ kind: 'block',
12
+ type: 'paragraph',
13
+ textContent: 'hello',
14
+ },
15
+ }),
16
+ ).toEqual([
17
+ {
18
+ kind: 'block',
19
+ type: 'paragraph',
20
+ textContent: 'hello',
21
+ },
22
+ ]);
23
+ });
24
+
25
+ it('ensures that all root nodes are block elements', async () => {
26
+ expect(
27
+ parseInitialState({
28
+ richText: [
29
+ {
30
+ kind: 'inline',
31
+ textContent: 'hello',
32
+ },
33
+ ],
34
+ }),
35
+ ).toEqual([
36
+ {
37
+ kind: 'block',
38
+ type: 'paragraph',
39
+ children: [
40
+ {
41
+ kind: 'inline',
42
+ textContent: 'hello',
43
+ },
44
+ ],
45
+ } as CrystallizeRichText,
46
+ ]);
47
+ });
48
+ });
@@ -0,0 +1,20 @@
1
+ import type { CrystallizeRichText, CrystallizeRichTextNode } from '../types/crystallize-rich-text-types';
2
+
3
+ export function parseInitialState({ richText }: { richText: CrystallizeRichText }): CrystallizeRichTextNode[] {
4
+ let richTextArray = Array.isArray(richText) ? richText : [richText];
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
+ }
15
+
16
+ return rootNode;
17
+ });
18
+
19
+ return richTextArray;
20
+ }
@@ -459,3 +459,16 @@ export const CustomTranslation: Story = {
459
459
  },
460
460
  },
461
461
  };
462
+
463
+ export const Bug: Story = {
464
+ args: {
465
+ initialData: [
466
+ {
467
+ kind: 'inline',
468
+ type: null,
469
+ textContent:
470
+ 'Krigsårene frem mot 1814 inneholder noen av de mest dramatiske begivenhetene i både dansk og norsk historie. I denne boken finner du for første gang en samlet fremstilling av krigsårene mellom 1807 og 1814 fra et felles dansk-norsk perspektiv.Dette verket er et sentralt bidrag i markeringen av 200-årsjubileet for grunnloven og den dansk-norske skilsmissen, skrevet av en dansk og en norsk historiker. I boken forteller de om krigsbegivenhetene både til lands og til sjøs, hvordan de ble opplevd blant ulike samfunnslag fra elitene i København, Christiania og Kiel, til husmenn i Østerdalen, bønder på Lolland-Falster og småhandelsfolk i Slesvig-Holstein.1814 var det moderne Norges fødsel. Norge ble selvstendig med en av Europas mest liberale grunnlover, og både selvstendigheten og grunnloven fikk leve videre selv om Norge mot slutten av året ble forent med Sverige i en løs union. Politisk sett gjorde dette Norge til en av Napoleonskrigenes vinnere, men ""mirakelåret"" 1814 ble født av et nederlag.',
471
+ },
472
+ ],
473
+ },
474
+ };
package/src/tag/tag.css CHANGED
@@ -1,7 +1,37 @@
1
1
  .c-tag {
2
- @apply inline-flex items-center rounded border border-solid border-gray-200-700 bg-purple-50-900 p-1 text-center text-xs font-medium text-gray-700-200 shadow-sm;
2
+ @apply inline-grid grid-flow-col items-center gap-2 whitespace-nowrap;
3
+ @apply rounded font-medium text-gray-700-200;
4
+ @apply border border-solid border-transparent;
5
+
6
+ &__prepend {
7
+ @apply -ml-2 flex items-center;
8
+ }
9
+
10
+ &__remove-button {
11
+ @apply m-0 -mr-2 cursor-pointer border-none bg-transparent p-0 text-[0];
12
+ }
13
+ }
14
+
15
+ .c-tag-default {
16
+ @apply border-gray-200-700 bg-purple-50-900;
3
17
  }
4
18
 
5
19
  .c-tag-elevate {
6
- @apply bg-elevate;
20
+ @apply bg-elevate shadow;
21
+ }
22
+
23
+ .c-tag-xs {
24
+ @apply h-6 px-2 text-xs;
25
+ }
26
+
27
+ .c-tag-sm {
28
+ @apply h-9 px-4 text-sm;
29
+ }
30
+
31
+ .c-tag-md {
32
+ @apply h-11 px-6 text-base;
33
+ }
34
+
35
+ .c-tag-lg {
36
+ @apply h-14 px-6 text-lg;
7
37
  }
package/src/tag/tag.tsx CHANGED
@@ -1,27 +1,52 @@
1
1
  import { cva, VariantProps } from 'class-variance-authority';
2
- import type { ComponentProps } from 'react';
3
2
 
3
+ import { Icon } from '../iconography';
4
4
  import './tag.css';
5
5
 
6
6
  type TagStylesProps = VariantProps<typeof tagStyles>;
7
7
  const tagStyles = cva('c-tag', {
8
8
  variants: {
9
9
  variant: {
10
- default: '',
10
+ default: 'c-tag-default',
11
11
  elevate: 'c-tag-elevate',
12
12
  },
13
+ size: {
14
+ xs: 'c-tag-xs',
15
+ sm: 'c-tag-sm',
16
+ md: 'c-tag-md',
17
+ lg: 'c-tag-lg',
18
+ },
13
19
  },
14
20
  defaultVariants: {
15
21
  variant: 'default',
22
+ size: 'xs',
16
23
  },
17
24
  });
18
25
 
19
- export type TagProps = ComponentProps<'span'> & TagStylesProps;
26
+ export type TagProps = React.ComponentProps<'div'> &
27
+ TagStylesProps & {
28
+ prepend?: React.ReactNode;
29
+ onRemove?: () => void;
30
+ };
20
31
 
21
- export function Tag({ children, className, variant, ...delegated }: TagProps) {
32
+ export function Tag({ children, className, variant, size, prepend, onRemove, ...delegated }: TagProps) {
22
33
  return (
23
- <span className={tagStyles({ className, variant })} {...delegated}>
34
+ <div className={tagStyles({ className, variant, size })} {...delegated}>
35
+ {!prepend ? null : <span className="c-tag__prepend">{prepend}</span>}
24
36
  {children}
25
- </span>
37
+ {onRemove && (
38
+ <button
39
+ type="button"
40
+ className="c-tag__remove-button"
41
+ onClick={e => {
42
+ e.stopPropagation();
43
+ onRemove();
44
+ }}
45
+ >
46
+ <Icon.Cancel width={12} height={12} />
47
+ <span className="sr-only">Remove</span>
48
+ </button>
49
+ )}
50
+ </div>
26
51
  );
27
52
  }