@trycourier/react-designer 0.3.0 → 0.4.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.
Files changed (37) hide show
  1. package/README.md +114 -2
  2. package/dist/cjs/index.js +55 -55
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +34 -0
  5. package/dist/components/BrandEditor/Editor/Editor.d.ts +16 -1
  6. package/dist/components/TemplateEditor/Channels/Email/Email.d.ts +1 -1
  7. package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +2 -1
  8. package/dist/components/TemplateEditor/Channels/Email/EmailLayout.d.ts +1 -1
  9. package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +1 -1
  10. package/dist/components/TemplateEditor/Channels/Inbox/InboxLayout.d.ts +1 -1
  11. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +1 -1
  12. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsLayout.d.ts +1 -1
  13. package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +1 -1
  14. package/dist/components/TemplateEditor/Channels/Push/PushLayout.d.ts +1 -1
  15. package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +1 -1
  16. package/dist/components/TemplateEditor/Channels/SMS/SMSLayout.d.ts +1 -1
  17. package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +1 -1
  18. package/dist/components/TemplateEditor/Channels/Slack/SlackLayout.d.ts +1 -1
  19. package/dist/components/TemplateEditor/Channels/useChannels.d.ts +8 -0
  20. package/dist/components/TemplateEditor/TemplateEditor.d.ts +16 -1
  21. package/dist/components/TemplateEditor/index.d.ts +1 -1
  22. package/dist/components/TemplateEditor/store.d.ts +10 -0
  23. package/dist/components/extensions/Variable/Variable.d.ts +8 -4
  24. package/dist/components/extensions/Variable/Variable.types.d.ts +3 -14
  25. package/dist/components/extensions/Variable/VariableSuggestions.d.ts +7 -0
  26. package/dist/components/extensions/Variable/index.d.ts +1 -0
  27. package/dist/components/extensions/Variable/suggestion.d.ts +2 -0
  28. package/dist/components/extensions/extension-kit.d.ts +7 -2
  29. package/dist/components/ui/VariableEditor/VariableAutocomplete.d.ts +16 -0
  30. package/dist/esm/index.js +55 -55
  31. package/dist/esm/index.js.map +4 -4
  32. package/dist/esm/styles.css +34 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/styles.css +34 -0
  35. package/dist/types/index.d.ts +1 -0
  36. package/dist/types/validation.types.d.ts +53 -0
  37. package/package.json +1 -1
@@ -1000,6 +1000,9 @@ body {
1000
1000
  .courier-z-50 {
1001
1001
  z-index: 50;
1002
1002
  }
1003
+ .courier-z-\[9999\] {
1004
+ z-index: 9999;
1005
+ }
1003
1006
  .courier-z-\[999\] {
1004
1007
  z-index: 999;
1005
1008
  }
@@ -1276,6 +1279,9 @@ body {
1276
1279
  .courier-h-px {
1277
1280
  height: 1px;
1278
1281
  }
1282
+ .courier-max-h-60 {
1283
+ max-height: 15rem;
1284
+ }
1279
1285
  .courier-max-h-\[88px\] {
1280
1286
  max-height: 88px;
1281
1287
  }
@@ -4645,6 +4651,10 @@ body {
4645
4651
  .hover\:courier-bg-card:hover {
4646
4652
  background-color: var(--card);
4647
4653
  }
4654
+ .hover\:courier-bg-gray-100:hover {
4655
+ --tw-bg-opacity: 1;
4656
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
4657
+ }
4648
4658
  .hover\:courier-bg-neutral-100:hover {
4649
4659
  --tw-bg-opacity: 1;
4650
4660
  background-color: rgb(245 245 245 / var(--tw-bg-opacity, 1));
@@ -4686,12 +4696,20 @@ body {
4686
4696
  .focus\:courier-bg-accent:focus {
4687
4697
  background-color: var(--accent);
4688
4698
  }
4699
+ .focus\:courier-bg-gray-100:focus {
4700
+ --tw-bg-opacity: 1;
4701
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
4702
+ }
4689
4703
  .focus\:courier-text-accent-foreground:focus {
4690
4704
  color: var(--accent-foreground);
4691
4705
  }
4692
4706
  .focus\:courier-text-foreground:focus {
4693
4707
  color: var(--foreground);
4694
4708
  }
4709
+ .focus\:courier-outline-none:focus {
4710
+ outline: 2px solid transparent;
4711
+ outline-offset: 2px;
4712
+ }
4695
4713
  .focus-visible\:courier-outline-none:focus-visible {
4696
4714
  outline: 2px solid transparent;
4697
4715
  outline-offset: 2px;
@@ -4913,6 +4931,14 @@ body {
4913
4931
  .dark\:courier-bg-foreground:is(.courier-dark *) {
4914
4932
  background-color: var(--foreground);
4915
4933
  }
4934
+ .dark\:courier-bg-gray-700:is(.courier-dark *) {
4935
+ --tw-bg-opacity: 1;
4936
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
4937
+ }
4938
+ .dark\:courier-bg-gray-800:is(.courier-dark *) {
4939
+ --tw-bg-opacity: 1;
4940
+ background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
4941
+ }
4916
4942
  .dark\:courier-bg-neutral-700:is(.courier-dark *) {
4917
4943
  --tw-bg-opacity: 1;
4918
4944
  background-color: rgb(64 64 64 / var(--tw-bg-opacity, 1));
@@ -4981,6 +5007,10 @@ body {
4981
5007
  .dark\:courier-outline-neutral-300:is(.courier-dark *) {
4982
5008
  outline-color: #d4d4d4;
4983
5009
  }
5010
+ .dark\:hover\:courier-bg-gray-700:hover:is(.courier-dark *) {
5011
+ --tw-bg-opacity: 1;
5012
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
5013
+ }
4984
5014
  .dark\:hover\:courier-bg-neutral-600:hover:is(.courier-dark *) {
4985
5015
  --tw-bg-opacity: 1;
4986
5016
  background-color: rgb(82 82 82 / var(--tw-bg-opacity, 1));
@@ -5022,6 +5052,10 @@ body {
5022
5052
  --tw-text-opacity: 1;
5023
5053
  color: rgb(239 68 68 / var(--tw-text-opacity, 1));
5024
5054
  }
5055
+ .dark\:focus\:courier-bg-gray-700:focus:is(.courier-dark *) {
5056
+ --tw-bg-opacity: 1;
5057
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
5058
+ }
5025
5059
  .dark\:active\:courier-bg-neutral-700:active:is(.courier-dark *) {
5026
5060
  --tw-bg-opacity: 1;
5027
5061
  background-color: rgb(64 64 64 / var(--tw-bg-opacity, 1));
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ export * from "./components/TemplateEditor";
2
2
  export * from "./components/BrandEditor";
3
3
  export * from "./components/Providers";
4
4
  export * from "./components/hooks";
5
+ export type { VariableValidationConfig } from "./types/validation.types";
5
6
  export * from "./lib/utils/errors";
6
7
  export * from "./components/ui-kit/ErrorBoundary";
package/dist/styles.css CHANGED
@@ -1000,6 +1000,9 @@ body {
1000
1000
  .courier-z-50 {
1001
1001
  z-index: 50;
1002
1002
  }
1003
+ .courier-z-\[9999\] {
1004
+ z-index: 9999;
1005
+ }
1003
1006
  .courier-z-\[999\] {
1004
1007
  z-index: 999;
1005
1008
  }
@@ -1276,6 +1279,9 @@ body {
1276
1279
  .courier-h-px {
1277
1280
  height: 1px;
1278
1281
  }
1282
+ .courier-max-h-60 {
1283
+ max-height: 15rem;
1284
+ }
1279
1285
  .courier-max-h-\[88px\] {
1280
1286
  max-height: 88px;
1281
1287
  }
@@ -4645,6 +4651,10 @@ body {
4645
4651
  .hover\:courier-bg-card:hover {
4646
4652
  background-color: var(--card);
4647
4653
  }
4654
+ .hover\:courier-bg-gray-100:hover {
4655
+ --tw-bg-opacity: 1;
4656
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
4657
+ }
4648
4658
  .hover\:courier-bg-neutral-100:hover {
4649
4659
  --tw-bg-opacity: 1;
4650
4660
  background-color: rgb(245 245 245 / var(--tw-bg-opacity, 1));
@@ -4686,12 +4696,20 @@ body {
4686
4696
  .focus\:courier-bg-accent:focus {
4687
4697
  background-color: var(--accent);
4688
4698
  }
4699
+ .focus\:courier-bg-gray-100:focus {
4700
+ --tw-bg-opacity: 1;
4701
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
4702
+ }
4689
4703
  .focus\:courier-text-accent-foreground:focus {
4690
4704
  color: var(--accent-foreground);
4691
4705
  }
4692
4706
  .focus\:courier-text-foreground:focus {
4693
4707
  color: var(--foreground);
4694
4708
  }
4709
+ .focus\:courier-outline-none:focus {
4710
+ outline: 2px solid transparent;
4711
+ outline-offset: 2px;
4712
+ }
4695
4713
  .focus-visible\:courier-outline-none:focus-visible {
4696
4714
  outline: 2px solid transparent;
4697
4715
  outline-offset: 2px;
@@ -4913,6 +4931,14 @@ body {
4913
4931
  .dark\:courier-bg-foreground:is(.courier-dark *) {
4914
4932
  background-color: var(--foreground);
4915
4933
  }
4934
+ .dark\:courier-bg-gray-700:is(.courier-dark *) {
4935
+ --tw-bg-opacity: 1;
4936
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
4937
+ }
4938
+ .dark\:courier-bg-gray-800:is(.courier-dark *) {
4939
+ --tw-bg-opacity: 1;
4940
+ background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
4941
+ }
4916
4942
  .dark\:courier-bg-neutral-700:is(.courier-dark *) {
4917
4943
  --tw-bg-opacity: 1;
4918
4944
  background-color: rgb(64 64 64 / var(--tw-bg-opacity, 1));
@@ -4981,6 +5007,10 @@ body {
4981
5007
  .dark\:courier-outline-neutral-300:is(.courier-dark *) {
4982
5008
  outline-color: #d4d4d4;
4983
5009
  }
5010
+ .dark\:hover\:courier-bg-gray-700:hover:is(.courier-dark *) {
5011
+ --tw-bg-opacity: 1;
5012
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
5013
+ }
4984
5014
  .dark\:hover\:courier-bg-neutral-600:hover:is(.courier-dark *) {
4985
5015
  --tw-bg-opacity: 1;
4986
5016
  background-color: rgb(82 82 82 / var(--tw-bg-opacity, 1));
@@ -5022,6 +5052,10 @@ body {
5022
5052
  --tw-text-opacity: 1;
5023
5053
  color: rgb(239 68 68 / var(--tw-text-opacity, 1));
5024
5054
  }
5055
+ .dark\:focus\:courier-bg-gray-700:focus:is(.courier-dark *) {
5056
+ --tw-bg-opacity: 1;
5057
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
5058
+ }
5025
5059
  .dark\:active\:courier-bg-neutral-700:active:is(.courier-dark *) {
5026
5060
  --tw-bg-opacity: 1;
5027
5061
  background-color: rgb(64 64 64 / var(--tw-bg-opacity, 1));
@@ -1,3 +1,4 @@
1
1
  export * from "./tiptap.types";
2
2
  export * from "./elemental.types";
3
3
  export * from "./elemental.schema";
4
+ export * from "./validation.types";
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Configuration for custom variable validation in the editor.
3
+ * Allows consumers to restrict which variable names are allowed and
4
+ * define the behavior when validation fails.
5
+ */
6
+ export interface VariableValidationConfig {
7
+ /**
8
+ * Custom validator function that runs AFTER built-in format validation passes
9
+ * (unless `overrideFormatValidation` is true).
10
+ *
11
+ * @param variableName - The variable name to validate (without curly braces)
12
+ * @returns true if the variable is allowed, false otherwise
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * // Only allow variables from a predefined list
17
+ * validate: (name) => ['user.name', 'user.email', 'order.total'].includes(name)
18
+ * ```
19
+ */
20
+ validate?: (variableName: string) => boolean;
21
+ /**
22
+ * Behavior when validation fails.
23
+ * - 'mark': Keep the chip with invalid styling (default, shows red styling)
24
+ * - 'remove': Delete the chip entirely
25
+ *
26
+ * @default 'mark'
27
+ */
28
+ onInvalid?: "mark" | "remove";
29
+ /**
30
+ * Message to show as a toast notification when validation fails.
31
+ * Can be a static string or a function that receives the variable name
32
+ * for dynamic messages.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // Static message
37
+ * invalidMessage: "This variable is not available"
38
+ *
39
+ * // Dynamic message
40
+ * invalidMessage: (name) => `Variable "${name}" is not in the allowed list`
41
+ * ```
42
+ */
43
+ invalidMessage?: string | ((variableName: string) => string);
44
+ /**
45
+ * If true, bypasses the built-in format validation entirely.
46
+ * Only the custom `validate` function will be used for validation.
47
+ *
48
+ * Use with caution - invalid formats may cause issues with downstream processing.
49
+ *
50
+ * @default false
51
+ */
52
+ overrideFormatValidation?: boolean;
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/react-designer",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "React-based rich text designer component",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",