@trycourier/react-designer 0.0.5 → 0.0.6
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/README.md +154 -120
- package/dist/cjs/index.js +44 -41
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/Providers/Providers.types.d.ts +8 -1
- package/dist/components/Providers/TemplateProvider.d.ts +3 -1
- package/dist/components/Providers/index.d.ts +2 -0
- package/dist/components/Providers/store.d.ts +0 -3
- package/dist/components/Providers/useImageUpload.d.ts +10 -0
- package/dist/components/TemplateEditor/Channels/useChannels.d.ts +1 -0
- package/dist/components/TemplateEditor/TemplateEditor.d.ts +1 -0
- package/dist/components/TemplateEditor/TemplateEditor.test.d.ts +1 -0
- package/dist/esm/index.js +44 -41
- package/dist/esm/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,21 +5,13 @@ Courier Create is a package designed to facilitate the editing of templates in a
|
|
|
5
5
|
## Key Features
|
|
6
6
|
|
|
7
7
|
- **Embedded React Integration**
|
|
8
|
-
|
|
9
|
-
Easily integrate the template editor directly into your existing React application.
|
|
10
|
-
|
|
8
|
+
Easily integrate the template editor directly into your existing React application.
|
|
11
9
|
- **Multi-Tenant Support**
|
|
12
|
-
|
|
13
|
-
Seamlessly manage and edit templates for different tenants, each with their own branding.
|
|
14
|
-
|
|
10
|
+
Seamlessly manage and edit templates for different tenants, each with their own branding.
|
|
15
11
|
- **Brand Editing**
|
|
16
|
-
|
|
17
|
-
Customize branding elements such as logos, colors, and styles per tenant to ensure consistency with each client's identity.
|
|
18
|
-
|
|
12
|
+
Customize branding elements such as logos, colors, and styles per tenant to ensure consistency with each client's identity.
|
|
19
13
|
- **Developer Friendly**
|
|
20
|
-
|
|
21
|
-
Designed with intuitive APIs and flexible components to speed up development and integration.
|
|
22
|
-
|
|
14
|
+
Designed with intuitive APIs and flexible components to speed up development and integration.
|
|
23
15
|
|
|
24
16
|
# Getting Started
|
|
25
17
|
|
|
@@ -121,7 +113,7 @@ As template changes are made, they are automatically saved to Courier.
|
|
|
121
113
|
|
|
122
114
|
```tsx
|
|
123
115
|
import "@trycourier/react-designer/styles.css";
|
|
124
|
-
import { TemplateEditor, TemplateProvider } from
|
|
116
|
+
import { TemplateEditor, TemplateProvider } from "@trycourier/react-designer";
|
|
125
117
|
|
|
126
118
|
function App() {
|
|
127
119
|
return (
|
|
@@ -136,19 +128,19 @@ function App() {
|
|
|
136
128
|
|
|
137
129
|
By default, the Courier template editor exposes a publish button that the template editor can interact with after completing changes. To override this default publishing behavior, you can hide the publishing button and interact with the publishing action directly allowing you to tightly integrate with your application's workflow.
|
|
138
130
|
|
|
139
|
-
|
|
131
|
+
_Note:_ `useTemplateActions` _must be used inside of the `<TemplateProvider />` context_
|
|
140
132
|
|
|
141
133
|
```tsx
|
|
142
134
|
import "@trycourier/react-designer/styles.css";
|
|
143
|
-
import { TemplateEditor, TemplateProvider, useTemplateActions } from
|
|
135
|
+
import { TemplateEditor, TemplateProvider, useTemplateActions } from "@trycourier/react-designer";
|
|
144
136
|
|
|
145
137
|
function SaveButtonComponent() {
|
|
146
138
|
const { publishTemplate } = useTemplateActions();
|
|
147
|
-
|
|
139
|
+
|
|
148
140
|
const handlePublishTemplate = async () => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
141
|
+
//... other publish logic
|
|
142
|
+
await publishTemplate();
|
|
143
|
+
};
|
|
152
144
|
|
|
153
145
|
return (
|
|
154
146
|
<div>
|
|
@@ -173,32 +165,32 @@ You can customize the look and feel through the theming API, which allows you to
|
|
|
173
165
|
|
|
174
166
|
```tsx
|
|
175
167
|
import "@trycourier/react-designer/styles.css";
|
|
176
|
-
import { TemplateEditor } from
|
|
168
|
+
import { TemplateEditor } from "@trycourier/react-designer";
|
|
177
169
|
|
|
178
170
|
function App() {
|
|
179
171
|
return (
|
|
180
172
|
<TemplateEditor
|
|
181
173
|
theme={{
|
|
182
|
-
background:
|
|
183
|
-
foreground:
|
|
184
|
-
muted:
|
|
185
|
-
mutedForeground:
|
|
186
|
-
popover:
|
|
187
|
-
popoverForeground:
|
|
188
|
-
border:
|
|
189
|
-
input:
|
|
190
|
-
card:
|
|
191
|
-
cardForeground:
|
|
192
|
-
primary:
|
|
193
|
-
primaryForeground:
|
|
194
|
-
secondary:
|
|
195
|
-
secondaryForeground:
|
|
196
|
-
accent:
|
|
197
|
-
accentForeground:
|
|
198
|
-
destructive:
|
|
199
|
-
destructiveForeground:
|
|
200
|
-
ring:
|
|
201
|
-
radius:
|
|
174
|
+
background: "#ffffff",
|
|
175
|
+
foreground: "#292929",
|
|
176
|
+
muted: "#D9D9D9",
|
|
177
|
+
mutedForeground: "#A3A3A3",
|
|
178
|
+
popover: "#ffffff",
|
|
179
|
+
popoverForeground: "#292929",
|
|
180
|
+
border: "#DCDEE4",
|
|
181
|
+
input: "#DCDEE4",
|
|
182
|
+
card: "#FAF9F8",
|
|
183
|
+
cardForeground: "#292929",
|
|
184
|
+
primary: "#ffffff",
|
|
185
|
+
primaryForeground: "#696F8C",
|
|
186
|
+
secondary: "#F5F5F5",
|
|
187
|
+
secondaryForeground: "#171717",
|
|
188
|
+
accent: "#E5F3FF",
|
|
189
|
+
accentForeground: "#1D4ED8",
|
|
190
|
+
destructive: "#292929",
|
|
191
|
+
destructiveForeground: "#FF3363",
|
|
192
|
+
ring: "#80849D",
|
|
193
|
+
radius: "6px",
|
|
202
194
|
}}
|
|
203
195
|
/>
|
|
204
196
|
);
|
|
@@ -209,20 +201,20 @@ function App() {
|
|
|
209
201
|
|
|
210
202
|
By default, the Courier Editor auto-saves content. To disable this feature, configure the provider as follows
|
|
211
203
|
|
|
212
|
-
|
|
204
|
+
_Note:_ `useTemplateActions` _must be used inside of the `<TemplateProvider />` context_
|
|
213
205
|
|
|
214
206
|
```tsx
|
|
215
207
|
import "@trycourier/react-designer/styles.css";
|
|
216
|
-
import { TemplateEditor, TemplateProvider, useTemplateActions } from
|
|
208
|
+
import { TemplateEditor, TemplateProvider, useTemplateActions } from "@trycourier/react-designer";
|
|
217
209
|
|
|
218
210
|
function SaveButtonComponent() {
|
|
219
211
|
const { saveTemplate, publishTemplate } = useTemplateActions();
|
|
220
|
-
|
|
212
|
+
|
|
221
213
|
const handleSaveTemplate = async () => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
214
|
+
//... other publish logic
|
|
215
|
+
await saveTemplate(); // the template must be saved before publishing
|
|
216
|
+
await publishTemplate();
|
|
217
|
+
};
|
|
226
218
|
|
|
227
219
|
return (
|
|
228
220
|
<div>
|
|
@@ -253,7 +245,7 @@ const courier = new CourierClient({ authorizationToken: "<AUTH_TOKEN>" }); // ge
|
|
|
253
245
|
const { requestId } = await courier.send({
|
|
254
246
|
message: {
|
|
255
247
|
context: {
|
|
256
|
-
tenant_id: "<TENANT_ID>" // The tenant_id should be added to context
|
|
248
|
+
tenant_id: "<TENANT_ID>", // The tenant_id should be added to context
|
|
257
249
|
},
|
|
258
250
|
to: {
|
|
259
251
|
data: {
|
|
@@ -261,7 +253,7 @@ const { requestId } = await courier.send({
|
|
|
261
253
|
},
|
|
262
254
|
email: "marty_mcfly@email.com",
|
|
263
255
|
},
|
|
264
|
-
|
|
256
|
+
template: "tenant/<TEMPLATE_ID>", // The tenant/ qualifier should be added to the template_id
|
|
265
257
|
},
|
|
266
258
|
});
|
|
267
259
|
```
|
|
@@ -274,25 +266,25 @@ The Courier Editor supports nested variable structures:
|
|
|
274
266
|
|
|
275
267
|
```tsx
|
|
276
268
|
import "@trycourier/react-designer/styles.css";
|
|
277
|
-
import { TemplateEditor, TemplateProvider } from
|
|
269
|
+
import { TemplateEditor, TemplateProvider } from "@trycourier/react-designer";
|
|
278
270
|
|
|
279
271
|
function App() {
|
|
280
272
|
return (
|
|
281
273
|
<TemplateProvider templateId="template-123" tenantId="tenant-123" token="jwt">
|
|
282
274
|
<TemplateEditor
|
|
283
275
|
variables={{
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
276
|
+
user: {
|
|
277
|
+
firstName: "John",
|
|
278
|
+
lastName: "Doe",
|
|
279
|
+
email: "john@example.com",
|
|
280
|
+
},
|
|
281
|
+
company: {
|
|
282
|
+
name: "Acme Inc",
|
|
283
|
+
address: {
|
|
284
|
+
street: "123 Main St",
|
|
285
|
+
city: "San Francisco",
|
|
286
|
+
},
|
|
288
287
|
},
|
|
289
|
-
"company": {
|
|
290
|
-
"name": "Acme Inc",
|
|
291
|
-
"address": {
|
|
292
|
-
"street": "123 Main St",
|
|
293
|
-
"city": "San Francisco"
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
288
|
}}
|
|
297
289
|
/>
|
|
298
290
|
</TemplateProvider>
|
|
@@ -313,14 +305,14 @@ The Courier Editor includes a comprehensive error handling system that automatic
|
|
|
313
305
|
|
|
314
306
|
You can programmatically trigger and handle errors using the `useTemplateActions` hook. This is useful for custom validation, user actions, or integration with external systems.
|
|
315
307
|
|
|
316
|
-
|
|
308
|
+
_Note: `useTemplateActions` must be used inside of the `<TemplateProvider />` context_
|
|
317
309
|
|
|
318
310
|
```tsx
|
|
319
|
-
import { useTemplateActions, TemplateEditor, TemplateProvider } from
|
|
311
|
+
import { useTemplateActions, TemplateEditor, TemplateProvider } from "@trycourier/react-designer";
|
|
320
312
|
|
|
321
313
|
function CustomComponent() {
|
|
322
314
|
const { setTemplateError } = useTemplateActions();
|
|
323
|
-
|
|
315
|
+
|
|
324
316
|
const handleCustomAction = async () => {
|
|
325
317
|
try {
|
|
326
318
|
// Your custom logic here
|
|
@@ -328,7 +320,7 @@ function CustomComponent() {
|
|
|
328
320
|
} catch (error) {
|
|
329
321
|
// Simple string error (automatically converted)
|
|
330
322
|
setTemplateError("Something went wrong with your custom action");
|
|
331
|
-
|
|
323
|
+
|
|
332
324
|
// Or create a structured error with custom toast configuration
|
|
333
325
|
setTemplateError({
|
|
334
326
|
message: "Custom error message",
|
|
@@ -338,8 +330,8 @@ function CustomComponent() {
|
|
|
338
330
|
label: "Retry",
|
|
339
331
|
onClick: () => handleCustomAction(),
|
|
340
332
|
},
|
|
341
|
-
description: "Additional context about the error"
|
|
342
|
-
}
|
|
333
|
+
description: "Additional context about the error",
|
|
334
|
+
},
|
|
343
335
|
});
|
|
344
336
|
}
|
|
345
337
|
};
|
|
@@ -368,8 +360,8 @@ All errors use a simple, consistent structure:
|
|
|
368
360
|
```tsx
|
|
369
361
|
// Error interface
|
|
370
362
|
interface TemplateError {
|
|
371
|
-
message: string;
|
|
372
|
-
toastProps?: ExternalToast;
|
|
363
|
+
message: string; // The error message to display
|
|
364
|
+
toastProps?: ExternalToast; // Optional Sonner toast configuration
|
|
373
365
|
}
|
|
374
366
|
|
|
375
367
|
// Usage examples
|
|
@@ -381,8 +373,8 @@ setTemplateError({
|
|
|
381
373
|
action: {
|
|
382
374
|
label: "Try Again",
|
|
383
375
|
onClick: () => retryUpload(),
|
|
384
|
-
}
|
|
385
|
-
}
|
|
376
|
+
},
|
|
377
|
+
},
|
|
386
378
|
});
|
|
387
379
|
|
|
388
380
|
// Different error scenarios
|
|
@@ -395,20 +387,25 @@ setTemplateError({ message: "Validation error", toastProps: { duration: 5000 } }
|
|
|
395
387
|
|
|
396
388
|
The editor includes an error boundary component to catch and handle React rendering errors gracefully.
|
|
397
389
|
|
|
398
|
-
|
|
390
|
+
_Note: `useTemplateActions` must be used inside of the `<TemplateProvider />` context_
|
|
399
391
|
|
|
400
392
|
```tsx
|
|
401
|
-
import {
|
|
393
|
+
import {
|
|
394
|
+
ErrorBoundary,
|
|
395
|
+
useTemplateActions,
|
|
396
|
+
TemplateEditor,
|
|
397
|
+
TemplateProvider,
|
|
398
|
+
} from "@trycourier/react-designer";
|
|
402
399
|
|
|
403
400
|
function TemplateEditorWithErrorHandling() {
|
|
404
401
|
const { setTemplateError } = useTemplateActions();
|
|
405
402
|
|
|
406
403
|
return (
|
|
407
|
-
<ErrorBoundary
|
|
404
|
+
<ErrorBoundary
|
|
408
405
|
onError={(error, errorInfo) => {
|
|
409
406
|
// Custom error logging
|
|
410
|
-
console.error(
|
|
411
|
-
|
|
407
|
+
console.error("Editor error:", error);
|
|
408
|
+
|
|
412
409
|
// Optional: integrate with template error system
|
|
413
410
|
setTemplateError({
|
|
414
411
|
message: `Render error: ${error.message}`,
|
|
@@ -418,7 +415,7 @@ function TemplateEditorWithErrorHandling() {
|
|
|
418
415
|
label: "Reload",
|
|
419
416
|
onClick: () => window.location.reload(),
|
|
420
417
|
},
|
|
421
|
-
}
|
|
418
|
+
},
|
|
422
419
|
});
|
|
423
420
|
}}
|
|
424
421
|
fallback={<div>Something went wrong. Please refresh the page.</div>}
|
|
@@ -441,10 +438,10 @@ function App() {
|
|
|
441
438
|
|
|
442
439
|
To programmatically clear the current error state:
|
|
443
440
|
|
|
444
|
-
|
|
441
|
+
_Note: `useTemplateActions` must be used inside of the `<TemplateProvider />` context_
|
|
445
442
|
|
|
446
443
|
```tsx
|
|
447
|
-
import { useTemplateActions, TemplateEditor, TemplateProvider } from
|
|
444
|
+
import { useTemplateActions, TemplateEditor, TemplateProvider } from "@trycourier/react-designer";
|
|
448
445
|
|
|
449
446
|
function ClearErrorComponent() {
|
|
450
447
|
const { setTemplateError } = useTemplateActions();
|
|
@@ -475,7 +472,7 @@ function App() {
|
|
|
475
472
|
|
|
476
473
|
The Brand Editor component allows you to customize and manage a tenant's brand settings directly within your application. This specialized editor provides an interface for modifying brand colors, logos, and other visual elements that will be applied to your templates.
|
|
477
474
|
|
|
478
|
-
|
|
475
|
+
_Note: For successful authentication it's required to generate a JWT with proper [brand scopes](#scopes)._
|
|
479
476
|
|
|
480
477
|
### Basic
|
|
481
478
|
|
|
@@ -483,7 +480,7 @@ Similar to the basic Template Editor setup, implementing the Brand Editor requir
|
|
|
483
480
|
|
|
484
481
|
```tsx
|
|
485
482
|
import "@trycourier/react-designer/styles.css";
|
|
486
|
-
import { BrandEditor, BrandProvider } from
|
|
483
|
+
import { BrandEditor, BrandProvider } from "@trycourier/react-designer";
|
|
487
484
|
|
|
488
485
|
function App() {
|
|
489
486
|
return (
|
|
@@ -498,19 +495,19 @@ function App() {
|
|
|
498
495
|
|
|
499
496
|
Similar to the Template Editor, the Brand Editor also provides a publishing hook that allows you to customize the publishing behavior. You can use the `useBrandActions` hook to programmatically trigger brand updates and integrate them with your application's workflow.
|
|
500
497
|
|
|
501
|
-
|
|
498
|
+
_Note: `useBrandActions` must be used inside of the `<BrandProvider />` context_
|
|
502
499
|
|
|
503
500
|
```tsx
|
|
504
501
|
import "@trycourier/react-designer/styles.css";
|
|
505
|
-
import { BrandEditor, BrandProvider, useBrandActions } from
|
|
502
|
+
import { BrandEditor, BrandProvider, useBrandActions } from "@trycourier/react-designer";
|
|
506
503
|
|
|
507
504
|
function SaveBrandComponent() {
|
|
508
505
|
const { publishBrand } = useBrandActions();
|
|
509
|
-
|
|
506
|
+
|
|
510
507
|
const handlePublishBrand = () => {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
508
|
+
//... other publish logic
|
|
509
|
+
await publishBrand();
|
|
510
|
+
};
|
|
514
511
|
|
|
515
512
|
return (
|
|
516
513
|
<BrandProvider tenantId="tenant-123" token="jwt | client key">
|
|
@@ -527,7 +524,7 @@ The `@trycourier/react-designer` package allows you to use both the Brand Editor
|
|
|
527
524
|
|
|
528
525
|
```tsx
|
|
529
526
|
import "@trycourier/react-designer/styles.css";
|
|
530
|
-
import { TemplateEditor, TemplateProvider } from
|
|
527
|
+
import { TemplateEditor, TemplateProvider } from "@trycourier/react-designer";
|
|
531
528
|
|
|
532
529
|
function App() {
|
|
533
530
|
return (
|
|
@@ -540,7 +537,7 @@ function App() {
|
|
|
540
537
|
|
|
541
538
|
`TemplaeProvider` supports the both editors – there is no need to add `BrandProvider` in this mode.
|
|
542
539
|
|
|
543
|
-
|
|
540
|
+
_Note: The JWT token must include proper [scopes](#scopes) for both template and brand editing capabilities._
|
|
544
541
|
|
|
545
542
|
# Properties
|
|
546
543
|
|
|
@@ -550,51 +547,83 @@ The Properties section details the configuration options available for both the
|
|
|
550
547
|
|
|
551
548
|
The Editor component is the core element that provides the template editing interface. If you are using the Template Editor with the Template provider, required properties will be provided.
|
|
552
549
|
|
|
553
|
-
| Property
|
|
554
|
-
|
|
|
555
|
-
| autoSave
|
|
556
|
-
| autoSaveDebounce | number
|
|
557
|
-
| brandEditor
|
|
558
|
-
| brandProps
|
|
559
|
-
| hidePublish
|
|
560
|
-
| onChange
|
|
561
|
-
| routing
|
|
562
|
-
| theme
|
|
563
|
-
| value
|
|
564
|
-
| variables
|
|
550
|
+
| Property | Type | Default | Description |
|
|
551
|
+
| ---------------- | -------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
552
|
+
| autoSave | boolean | true | Enables automatic saving of changes to the template. When true, changes are automatically persisted. |
|
|
553
|
+
| autoSaveDebounce | number | 200ms | Time in milliseconds to wait after changes before triggering an auto-save operation. Controls save frequency. |
|
|
554
|
+
| brandEditor | boolean | false | When enabled, shows the brand editor interface alongside the template editor. Allows editing brand settings. |
|
|
555
|
+
| brandProps | BrandEditorProps | | Configuration options for the brand editor when enabled. Passed directly to the BrandEditor component. |
|
|
556
|
+
| hidePublish | boolean | false | When true, hides the "Publish Changes" button in the editor interface. |
|
|
557
|
+
| onChange | (value: ElementalContent) => void | | Callback function that fires whenever the editor content changes, providing the updated ElementalContent structure. |
|
|
558
|
+
| routing | { method: string; channels: string[] } | | Configures multi-channel routing and delivery behavior. The `method` property determines delivery strategy: "single" (deliver via first available channel) or "all" (deliver via all configured channels). The `channels` array defines which delivery channels are available in the editor. |
|
|
559
|
+
| theme | ThemeObj | cssClass | | Controls the visual appearance of the editor. Can be a Theme object with styling properties or a CSS class name. |
|
|
560
|
+
| value | ElementalContent | | Initial content for the editor in ElementalContent format. Used as the starting template when the editor loads. |
|
|
561
|
+
| variables | Record<string, any | | Custom variables available for template personalization. These can be referenced within the template content. |
|
|
562
|
+
|
|
563
|
+
### Multi-Channel Routing
|
|
564
|
+
|
|
565
|
+
The `routing` property allows you to configure which communication channels are available in the template editor and how messages are delivered to recipients. This gives you full control over the delivery strategy for your templates.
|
|
566
|
+
|
|
567
|
+
```tsx
|
|
568
|
+
import "@trycourier/react-designer/styles.css";
|
|
569
|
+
import { TemplateEditor, TemplateProvider } from "@trycourier/react-designer";
|
|
570
|
+
|
|
571
|
+
function App() {
|
|
572
|
+
return (
|
|
573
|
+
<TemplateProvider templateId="template-123" tenantId="tenant-123" token="jwt">
|
|
574
|
+
<TemplateEditor
|
|
575
|
+
routing={{
|
|
576
|
+
method: "single", // "single" for fallback delivery, "all" for simultaneous delivery
|
|
577
|
+
channels: ["email", "sms", "push"] // Available channels in the editor
|
|
578
|
+
}}
|
|
579
|
+
/>
|
|
580
|
+
</TemplateProvider>
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
**Channel Options:**
|
|
586
|
+
- `"email"` - Email delivery
|
|
587
|
+
- `"sms"` - SMS text messaging
|
|
588
|
+
- `"push"` - Push notifications
|
|
589
|
+
- `"inbox"` - In-app messaging
|
|
590
|
+
|
|
591
|
+
**Delivery Methods:**
|
|
592
|
+
- `"single"` - Delivers via the first available channel (fallback strategy)
|
|
593
|
+
- `"all"` - Delivers via all configured channels simultaneously
|
|
565
594
|
|
|
566
595
|
### Template Provider Properties
|
|
567
596
|
|
|
568
|
-
The TemplateProvider component wraps the Editor component and manages the template state, authentication, and data flow. It provides essential context and functionality needed for the editor to operate. Below are the key properties that can be configured when using the
|
|
597
|
+
The TemplateProvider component wraps the Editor component and manages the template state, authentication, and data flow. It provides essential context and functionality needed for the editor to operate. Below are the key properties that can be configured when using the
|
|
569
598
|
|
|
570
|
-
| Property
|
|
571
|
-
|
|
|
572
|
-
| templateId | string | Yes
|
|
573
|
-
| tenantId
|
|
574
|
-
| token
|
|
599
|
+
| Property | Type | Required | Description |
|
|
600
|
+
| ---------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
601
|
+
| templateId | string | Yes | Unique identifier for the template being edited. Required for loading and saving template data. If the template with that ID has not been created yet, it will be on the first save. |
|
|
602
|
+
| tenantId | string | Yes | The tenant ID associated with the template. Used for brand theming and tenant-specific functionality. |
|
|
603
|
+
| token | string | Yes | Authentication token (JWT or ClientKey) used to authorize API requests to Courier services. |
|
|
575
604
|
|
|
576
605
|
### Brand Editor
|
|
577
606
|
|
|
578
607
|
The Brand Editor component accepts properties that allow you to customize its behavior and appearance. These properties provide control over the editing interface and functionality specific to brand management.
|
|
579
608
|
|
|
580
|
-
| Property
|
|
581
|
-
|
|
|
582
|
-
| autoSave
|
|
583
|
-
| autoSaveDebounce | number
|
|
584
|
-
| hidePublish
|
|
585
|
-
| onChange
|
|
586
|
-
| theme
|
|
587
|
-
| value
|
|
588
|
-
| variables
|
|
609
|
+
| Property | Type | Default | Description |
|
|
610
|
+
| ---------------- | ------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
|
|
611
|
+
| autoSave | boolean | true | Enables automatic saving of changes to the template. When true, changes are automatically persisted. |
|
|
612
|
+
| autoSaveDebounce | number | 200ms | Time in milliseconds to wait after changes before triggering an auto-save operation. Controls save frequency. |
|
|
613
|
+
| hidePublish | boolean | false | When true, hides the "Publish Changes" button in the editor interface. |
|
|
614
|
+
| onChange | (value: BrandSettings) => void | | Callback function that fires whenever brand settings are modified, providing the updated brand configuration values. |
|
|
615
|
+
| theme | ThemeObj | cssClass | | Controls the visual appearance of the editor. Can be a Theme object with styling properties or a CSS class name. |
|
|
616
|
+
| value | BrandSettings | | Initial brand settings values to populate the editor with, including colors, logo, social links, and header style preferences. |
|
|
617
|
+
| variables | Record<string, any | | Custom variables available for brand personalization. These can be referenced within the brand footer content. |
|
|
589
618
|
|
|
590
619
|
### Brand Provider
|
|
591
620
|
|
|
592
621
|
The Brand Provider component is responsible for managing brand-related state and context in your application. It wraps the Brand Editor component and handles data flow, authentication, and state management for brand customization. Here are the key properties that can be configured:
|
|
593
622
|
|
|
594
|
-
| Property | Type
|
|
595
|
-
|
|
|
596
|
-
| tenantId | string | Yes
|
|
597
|
-
| token
|
|
623
|
+
| Property | Type | Required | Description |
|
|
624
|
+
| -------- | ------ | -------- | ------------------------------------------------------------------------------------- |
|
|
625
|
+
| tenantId | string | Yes | The unique identifier for the tenant whose brand settings are being edited. |
|
|
626
|
+
| token | string | Yes | Authentication token (JWT or ClientKey) used to authorize brand-related API requests. |
|
|
598
627
|
|
|
599
628
|
# Limitations
|
|
600
629
|
|
|
@@ -633,6 +662,7 @@ This package can be published to npm using the provided scripts. The publishing
|
|
|
633
662
|
- `pnpm release:canary` - Creates a canary release with a unique tag
|
|
634
663
|
|
|
635
664
|
The release script will:
|
|
665
|
+
|
|
636
666
|
- Check if your working directory is clean
|
|
637
667
|
- Build the package
|
|
638
668
|
- Run tests
|
|
@@ -648,11 +678,13 @@ Canary builds are pre-release versions that allow users to test the latest chang
|
|
|
648
678
|
#### Creating a canary build
|
|
649
679
|
|
|
650
680
|
Run the canary release command:
|
|
681
|
+
|
|
651
682
|
```sh
|
|
652
683
|
pnpm release:canary
|
|
653
684
|
```
|
|
654
685
|
|
|
655
686
|
This will:
|
|
687
|
+
|
|
656
688
|
- Generate a unique tag in the format `canary-{timestamp}`
|
|
657
689
|
- Create a version like `0.0.1-canary-1718392847`
|
|
658
690
|
- Publish to npm with the unique tag
|
|
@@ -660,11 +692,13 @@ This will:
|
|
|
660
692
|
#### Installing a specific canary build
|
|
661
693
|
|
|
662
694
|
To see all available canary builds:
|
|
695
|
+
|
|
663
696
|
```sh
|
|
664
697
|
npm dist-tag ls @trycourier/courier-designer
|
|
665
698
|
```
|
|
666
699
|
|
|
667
700
|
To install a specific canary build:
|
|
701
|
+
|
|
668
702
|
```sh
|
|
669
703
|
# Example for a specific canary build
|
|
670
704
|
npm install @trycourier/courier-designer@canary-1718392847
|