@pixeasy/customizer-stage 0.0.41 → 0.0.44
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 +137 -0
- package/assets/theme/custom-preset.ts +97 -6
- package/index.d.ts +84 -1
- package/package.json +1 -1
- package/pixeasy-customizer.css +1 -1
- package/pixeasy-customizer.min.js +268 -265
package/README.md
CHANGED
|
@@ -359,6 +359,143 @@ export default {
|
|
|
359
359
|
|
|
360
360
|
## Exports
|
|
361
361
|
|
|
362
|
+
### Personalized Design Templates
|
|
363
|
+
|
|
364
|
+
The same npm package also registers `<pixeasy-personalized-customizer>`. This is a separate
|
|
365
|
+
runtime from `<pixeasy-customizer>`: it loads the latest active published template assigned to
|
|
366
|
+
the requested 2D product. Existing `createPixeasyBuilder()` integrations keep their behavior.
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
import {
|
|
370
|
+
createPixeasyPersonalizedBuilder,
|
|
371
|
+
PERSONALIZED_CUSTOMIZER_EVENTS,
|
|
372
|
+
} from '@pixeasy/customizer-stage';
|
|
373
|
+
|
|
374
|
+
const personalizer = createPixeasyPersonalizedBuilder();
|
|
375
|
+
personalizer.on(PERSONALIZED_CUSTOMIZER_EVENTS.READY, ({ version }) => {
|
|
376
|
+
console.log('Published template version', version);
|
|
377
|
+
});
|
|
378
|
+
personalizer.on(PERSONALIZED_CUSTOMIZER_EVENTS.APPLIED, (saved) => {
|
|
379
|
+
// Store these credentials with the customer's account or order.
|
|
380
|
+
// Save saved.designId and saved.editToken on your backend.
|
|
381
|
+
console.log(saved.designId, saved.canvases);
|
|
382
|
+
});
|
|
383
|
+
personalizer.open({
|
|
384
|
+
container: 'personalizer-controls',
|
|
385
|
+
className: 'shop-personalizer',
|
|
386
|
+
canvasContainerId: 'personalizer-canvas',
|
|
387
|
+
apiKey: 'dk_xxx_yyy',
|
|
388
|
+
userUniqueId: 'customer-uuid',
|
|
389
|
+
productId: 'product-uuid',
|
|
390
|
+
templateId: 'published-template-uuid',
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Pass `userUniqueId` to show the customer's logo library beside each editable image field.
|
|
395
|
+
Customers can choose a logo from their library or the shared collection, subject to the field's
|
|
396
|
+
image type and image count limits. For the custom element, use the `user-unique-id` attribute.
|
|
397
|
+
|
|
398
|
+
Apply now calls `POST /public/personalized-designs/apply`. It validates the required fields,
|
|
399
|
+
renders every active canvas at 300 DPI using each placement's printable dimensions, and stores
|
|
400
|
+
the editable values, text and logo overlay snapshots, source images, canvas PNGs, and composed product/variant preview images. Overlay inches are measured from the rendered canvas using the selected assigned product's printable dimensions. The selected variant and color are saved. The submission PDF is generated using the 2D submission layout.
|
|
401
|
+
The design ID is the ID of a record in the shared submissions table. The event contains the saved design ID,
|
|
402
|
+
edit token, revision, and per-canvas PNG URLs. The SDK shows canvas image download buttons after apply. The PDF URL can be empty while generation is pending. Treat the edit token as a customer secret;
|
|
403
|
+
store it on your server with the customer's order or account. Export URLs are temporary.
|
|
404
|
+
The distributor API key needs `ProductRead`, `SubmissionCreate`, and `SubmissionRead` scopes.
|
|
405
|
+
|
|
406
|
+
To reopen the design, pass both saved credentials to `open()` with the same product and template:
|
|
407
|
+
|
|
408
|
+
```ts
|
|
409
|
+
personalizer.open({
|
|
410
|
+
container: 'personalizer-controls',
|
|
411
|
+
canvasContainerId: 'personalizer-canvas',
|
|
412
|
+
apiKey: 'dk_xxx_yyy',
|
|
413
|
+
productId: 'product-uuid',
|
|
414
|
+
templateId: 'published-template-uuid',
|
|
415
|
+
designId: savedDesignId,
|
|
416
|
+
editToken: savedEditToken,
|
|
417
|
+
});
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
The SDK loads the exact published template version used by the design and restores its values
|
|
421
|
+
and image transforms. Applying again updates the same design and increments its revision.
|
|
422
|
+
`GET /public/personalized-designs/{designId}` requires the distributor API key and
|
|
423
|
+
`X-Edit-Token` header; it can refresh expired export links.
|
|
424
|
+
|
|
425
|
+
Provide both divs in the host page:
|
|
426
|
+
|
|
427
|
+
```html
|
|
428
|
+
<div id="personalizer-canvas"></div>
|
|
429
|
+
<div id="personalizer-controls"></div>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
`canvasContainerId` is optional. When supplied, the canvas stage renders inside that div
|
|
433
|
+
and stays synchronized with the controls mounted in `container`. The divs must be distinct
|
|
434
|
+
and already exist when `open()` is called. Without it, the canvas stays inside the controls UI.
|
|
435
|
+
|
|
436
|
+
The personalized-template response includes the distributor's primary and secondary colors
|
|
437
|
+
and the product's admin color pack when available. Color controls start with a custom picker, followed
|
|
438
|
+
by a short palette and a **See all colors** action. Upload fields support both browsing and
|
|
439
|
+
dragging image files into the upload box.
|
|
440
|
+
|
|
441
|
+
The optional `className` sets a class on the custom element. Because the controls use Shadow
|
|
442
|
+
DOM, host styles can use CSS variables and `::part()` to customize them:
|
|
443
|
+
|
|
444
|
+
```css
|
|
445
|
+
.shop-personalizer {
|
|
446
|
+
--personalized-primary: #154f72;
|
|
447
|
+
--personalized-secondary: #f6c65b;
|
|
448
|
+
--personalized-on-primary: white;
|
|
449
|
+
--personalized-background: #f5f8fa;
|
|
450
|
+
--personalized-surface: white;
|
|
451
|
+
--personalized-ink: #172033;
|
|
452
|
+
--personalized-muted: #526078;
|
|
453
|
+
--personalized-border: #dfe4ec;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.shop-personalizer > div::part(field-card) { padding-block: 1.5rem; }
|
|
457
|
+
.shop-personalizer > div::part(text-input),
|
|
458
|
+
.shop-personalizer > div::part(setting-input) { border-radius: 4px; }
|
|
459
|
+
.shop-personalizer > div::part(upload-box) { border-style: solid; }
|
|
460
|
+
.shop-personalizer > div::part(color-swatch) { width: 42px; height: 42px; }
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Other stable parts include `shell`, `header`, `apply-button`, `product-switcher`, `product-button`,
|
|
464
|
+
`variant-switcher`, `variant-button`, `canvas-tabs`, `canvas-tab`,
|
|
465
|
+
`preview-panel`, `form-panel`, `image-card`, `color-control`, `color-options`,
|
|
466
|
+
`color-picker`, `see-colors`, and `range-input` for crop controls. CSS variables take precedence over distributor colors
|
|
467
|
+
when supplied by the host.
|
|
468
|
+
|
|
469
|
+
The custom element also accepts `api-key`, `product-id`, `template-id`, optional
|
|
470
|
+
`canvas-container-id`, `design-id`, `edit-token`, and `readonly`
|
|
471
|
+
attributes. The builder exposes `getDesignState()`, `getCanvasSvg()`, `getCanvasImage()`,
|
|
472
|
+
and `close()`. The canvas export methods return the current product view with the design
|
|
473
|
+
as SVG or a PNG data URL after rendering is ready; they return `null` before that.
|
|
474
|
+
`personalized:changed`
|
|
475
|
+
fires as text or images change, `personalized:applied` fires after the design has been saved,
|
|
476
|
+
and `personalized:error` reports loading failures. The design state contains template
|
|
477
|
+
version, selected product and variant IDs, text values, uploaded image data URLs, per-image positions and scales, and default
|
|
478
|
+
asset IDs. A single-image upload replaces its default; multi-image fields can replace each
|
|
479
|
+
image individually. The published product view is used as the canvas background, with the
|
|
480
|
+
design positioned in the assigned placement. Apply persists a shared design submission and
|
|
481
|
+
links its personalized editing state through `DesignSubmissionId`.
|
|
482
|
+
|
|
483
|
+
Image corner handles resize proportionally; side handles change width or height independently.
|
|
484
|
+
`imageAxisScales` in the emitted design state stores per-image `{ x, y }` scale values.
|
|
485
|
+
The existing `imageScales` field remains for older integrations; it reports the X scale
|
|
486
|
+
when an image has different X and Y values.
|
|
487
|
+
|
|
488
|
+
The published-template endpoint is
|
|
489
|
+
`GET /public/products/{productId}/personalized-design-templates/{templateId}` and requires
|
|
490
|
+
the same `X-API-Key` header as other public SDK endpoints. It returns only an active template
|
|
491
|
+
whose latest published version includes the enabled product. It supplies the shared canvases,
|
|
492
|
+
asset URLs, and product placement maps. The SDK also requests
|
|
493
|
+
`GET /public/products/{productId}/personalized-design-templates/{templateId}/product` for the
|
|
494
|
+
selected product's variants, view images, fonts, and colors. Changing products requests only
|
|
495
|
+
that product's details; changing a variant color uses the product data already loaded.
|
|
496
|
+
Variant choices show the configured color thumbnail image when available, otherwise the color
|
|
497
|
+
code. Hover or keyboard focus reveals the variant name.
|
|
498
|
+
|
|
362
499
|
The package exports the following:
|
|
363
500
|
|
|
364
501
|
### Classes & Functions
|
|
@@ -80,6 +80,16 @@ export const customPreset = definePreset(Aura, {
|
|
|
80
80
|
color: '{primary.700}',
|
|
81
81
|
focusColor: '{primary.700}',
|
|
82
82
|
},
|
|
83
|
+
formField: {
|
|
84
|
+
borderColor: '#727477',
|
|
85
|
+
hoverBorderColor: '#5a5c5f',
|
|
86
|
+
focusBorderColor: '{primary.500}',
|
|
87
|
+
invalidBorderColor: '#ef4444',
|
|
88
|
+
},
|
|
89
|
+
select: {
|
|
90
|
+
borderColor: '#727477',
|
|
91
|
+
hoverBorderColor: '#5a5c5f',
|
|
92
|
+
},
|
|
83
93
|
},
|
|
84
94
|
dark: {
|
|
85
95
|
primary: {
|
|
@@ -109,6 +119,16 @@ export const customPreset = definePreset(Aura, {
|
|
|
109
119
|
color: 'rgba(255, 255, 255, 0.87)',
|
|
110
120
|
focusColor: 'rgba(255, 255, 255, 0.87)',
|
|
111
121
|
},
|
|
122
|
+
formField: {
|
|
123
|
+
borderColor: '#727477',
|
|
124
|
+
hoverBorderColor: '#94a3b8',
|
|
125
|
+
focusBorderColor: '{primary.400}',
|
|
126
|
+
invalidBorderColor: '#f87171',
|
|
127
|
+
},
|
|
128
|
+
select: {
|
|
129
|
+
borderColor: '#727477',
|
|
130
|
+
hoverBorderColor: '#94a3b8',
|
|
131
|
+
},
|
|
112
132
|
},
|
|
113
133
|
},
|
|
114
134
|
// Component-specific tokens (base overrides)
|
|
@@ -125,6 +145,32 @@ export const customPreset = definePreset(Aura, {
|
|
|
125
145
|
root: {
|
|
126
146
|
borderRadius: '8px',
|
|
127
147
|
transitionDuration: '0.3s',
|
|
148
|
+
borderColor: '#727477',
|
|
149
|
+
hoverBorderColor: '#5a5c5f',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
textarea: {
|
|
153
|
+
root: {
|
|
154
|
+
borderRadius: '8px',
|
|
155
|
+
transitionDuration: '0.3s',
|
|
156
|
+
borderColor: '#727477',
|
|
157
|
+
hoverBorderColor: '#5a5c5f',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
select: {
|
|
161
|
+
root: {
|
|
162
|
+
borderRadius: '8px',
|
|
163
|
+
transitionDuration: '0.3s',
|
|
164
|
+
borderColor: '#727477',
|
|
165
|
+
hoverBorderColor: '#5a5c5f',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
multiselect: {
|
|
169
|
+
root: {
|
|
170
|
+
borderRadius: '8px',
|
|
171
|
+
transitionDuration: '0.3s',
|
|
172
|
+
borderColor: '#727477',
|
|
173
|
+
hoverBorderColor: '#5a5c5f',
|
|
128
174
|
},
|
|
129
175
|
},
|
|
130
176
|
// Float label base
|
|
@@ -203,26 +249,53 @@ export const customPreset = definePreset(Aura, {
|
|
|
203
249
|
transform: none ;
|
|
204
250
|
}
|
|
205
251
|
|
|
206
|
-
/*
|
|
207
|
-
.p-inputtext
|
|
208
|
-
|
|
252
|
+
/* Form inputs and dropdowns border & hover */
|
|
253
|
+
.p-inputtext,
|
|
254
|
+
.p-textarea,
|
|
255
|
+
.p-select,
|
|
256
|
+
.p-dropdown,
|
|
257
|
+
.p-multiselect,
|
|
258
|
+
.p-inputnumber {
|
|
259
|
+
border: 1px solid #727477 ;
|
|
209
260
|
border-radius: ${dt('inputtext.root.borderRadius')} ;
|
|
210
261
|
transition: all 0.3s ease ;
|
|
211
262
|
background: rgba(255, 255, 255, 0.8) ;
|
|
212
263
|
backdrop-filter: blur(5px) ;
|
|
213
264
|
}
|
|
214
265
|
|
|
215
|
-
.p-inputtext:
|
|
266
|
+
.p-inputtext:hover,
|
|
267
|
+
.p-textarea:hover,
|
|
268
|
+
.p-select:hover,
|
|
269
|
+
.p-dropdown:hover,
|
|
270
|
+
.p-multiselect:hover,
|
|
271
|
+
.p-inputnumber:hover {
|
|
272
|
+
border-color: #5a5c5f ;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.p-inputtext:focus,
|
|
276
|
+
.p-textarea:focus,
|
|
277
|
+
.p-select:focus,
|
|
278
|
+
.p-select.p-focus,
|
|
279
|
+
.p-dropdown:focus,
|
|
280
|
+
.p-dropdown.p-focus,
|
|
281
|
+
.p-multiselect:focus,
|
|
282
|
+
.p-multiselect.p-focus,
|
|
283
|
+
.p-inputnumber:focus,
|
|
284
|
+
.p-inputnumber.p-focus {
|
|
216
285
|
border-color: ${dt('primary.500')} ;
|
|
217
286
|
box-shadow: 0 0 0 3px rgba(98, 101, 241, 0.1) ;
|
|
218
287
|
}
|
|
219
288
|
|
|
220
|
-
.p-select.field-invalid
|
|
289
|
+
.p-select.field-invalid,
|
|
290
|
+
.p-dropdown.field-invalid,
|
|
291
|
+
.p-multiselect.field-invalid,
|
|
292
|
+
.p-textarea.field-invalid,
|
|
293
|
+
.p-password.field-invalid .p-password-input,
|
|
294
|
+
.p-inputtext.field-invalid {
|
|
221
295
|
border-color: #ef4444 ;
|
|
222
296
|
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) ;
|
|
223
297
|
}
|
|
224
298
|
|
|
225
|
-
|
|
226
299
|
/* p-float-label Styles */
|
|
227
300
|
.p-float-label label {
|
|
228
301
|
color: #6b7280 ;
|
|
@@ -234,6 +307,24 @@ export const customPreset = definePreset(Aura, {
|
|
|
234
307
|
}
|
|
235
308
|
|
|
236
309
|
/* Dark Mode Overrides */
|
|
310
|
+
.dark .p-inputtext,
|
|
311
|
+
.dark .p-textarea,
|
|
312
|
+
.dark .p-select,
|
|
313
|
+
.dark .p-dropdown,
|
|
314
|
+
.dark .p-multiselect,
|
|
315
|
+
.dark .p-inputnumber {
|
|
316
|
+
border-color: #727477 ;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.dark .p-inputtext:hover,
|
|
320
|
+
.dark .p-textarea:hover,
|
|
321
|
+
.dark .p-select:hover,
|
|
322
|
+
.dark .p-dropdown:hover,
|
|
323
|
+
.dark .p-multiselect:hover,
|
|
324
|
+
.dark .p-inputnumber:hover {
|
|
325
|
+
border-color: #94a3b8 ;
|
|
326
|
+
}
|
|
327
|
+
|
|
237
328
|
.dark .p-inputtext.field-invalid {
|
|
238
329
|
border-color: #f87171 ;
|
|
239
330
|
box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1) ;
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,89 @@ export interface PixeasyOpenOptions extends SdkElementConfig {
|
|
|
14
14
|
container: string | HTMLElement;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export interface PersonalizedCustomizerOpenOptions {
|
|
18
|
+
container: string | HTMLElement;
|
|
19
|
+
canvasContainerId?: string;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
productId: string;
|
|
22
|
+
templateId: string;
|
|
23
|
+
readonly?: boolean;
|
|
24
|
+
designId?: string;
|
|
25
|
+
editToken?: string;
|
|
26
|
+
submissionNumber?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PersonalizedAppliedDesign {
|
|
30
|
+
designId: string;
|
|
31
|
+
editToken: string;
|
|
32
|
+
revision: number;
|
|
33
|
+
pdfUrl: string;
|
|
34
|
+
canvases: Array<{ canvasKey: string; pngUrl: string; width: number; height: number }>;
|
|
35
|
+
state: PersonalizedDesignState;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PersonalizedDesignState {
|
|
39
|
+
productId: string;
|
|
40
|
+
variantId?: string;
|
|
41
|
+
templateId: string;
|
|
42
|
+
version: number;
|
|
43
|
+
textValues: Record<string, string>;
|
|
44
|
+
imageValues: Record<string, string[]>;
|
|
45
|
+
defaultAssetIds: Record<string, string[]>;
|
|
46
|
+
imageOffsets: Record<string, { x: number; y: number }[]>;
|
|
47
|
+
imageScales: Record<string, number[]>;
|
|
48
|
+
imageAxisScales?: Record<string, { x: number; y: number }[]>;
|
|
49
|
+
imageRotations: Record<string, number[]>;
|
|
50
|
+
imageCrops: Record<string, { x: number; y: number }>;
|
|
51
|
+
cropDetails?: Record<string, ({ originalUrl: string;
|
|
52
|
+
bounds: { x: number; y: number; w: number; h: number } | null; rotation: number } | null)[]>;
|
|
53
|
+
textStyles: Record<string, {
|
|
54
|
+
fontFamily?: string; fontSize?: number; fillColor?: string; outlineColor?: string;
|
|
55
|
+
outline2Color?: string; letterSpacingEm?: number; shadowColor?: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface PersonalizedReadyEventDetail {
|
|
60
|
+
productId: string;
|
|
61
|
+
templateId: string;
|
|
62
|
+
version: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface PersonalizedErrorEventDetail { message: string; }
|
|
66
|
+
|
|
67
|
+
export type PersonalizedCustomizerEventName =
|
|
68
|
+
| 'personalized:ready' | 'personalized:changed' | 'personalized:applied'
|
|
69
|
+
| 'personalized:error' | 'personalized:closed';
|
|
70
|
+
|
|
71
|
+
export const PERSONALIZED_CUSTOMIZER_EVENTS: {
|
|
72
|
+
readonly READY: 'personalized:ready';
|
|
73
|
+
readonly CHANGED: 'personalized:changed';
|
|
74
|
+
readonly APPLIED: 'personalized:applied';
|
|
75
|
+
readonly ERROR: 'personalized:error';
|
|
76
|
+
readonly CLOSED: 'personalized:closed';
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export class PersonalizedCustomizerBuilder {
|
|
80
|
+
open(options: PersonalizedCustomizerOpenOptions): this;
|
|
81
|
+
on<K extends PersonalizedCustomizerEventName>(name: K, handler: (payload:
|
|
82
|
+
K extends 'personalized:ready' ? PersonalizedReadyEventDetail :
|
|
83
|
+
K extends 'personalized:error' ? PersonalizedErrorEventDetail :
|
|
84
|
+
K extends 'personalized:closed' ? undefined :
|
|
85
|
+
K extends 'personalized:applied' ? PersonalizedAppliedDesign : PersonalizedDesignState) => void): this;
|
|
86
|
+
off<K extends PersonalizedCustomizerEventName>(name: K, handler: (payload:
|
|
87
|
+
K extends 'personalized:ready' ? PersonalizedReadyEventDetail :
|
|
88
|
+
K extends 'personalized:error' ? PersonalizedErrorEventDetail :
|
|
89
|
+
K extends 'personalized:closed' ? undefined :
|
|
90
|
+
K extends 'personalized:applied' ? PersonalizedAppliedDesign : PersonalizedDesignState) => void): this;
|
|
91
|
+
getDesignState(): PersonalizedDesignState | null;
|
|
92
|
+
getCanvasSvg(): string | null;
|
|
93
|
+
getCanvasImage(): string | null;
|
|
94
|
+
close(emitClosed?: boolean): this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function createPixeasyPersonalizedBuilder(): PersonalizedCustomizerBuilder;
|
|
98
|
+
export function definePixeasyPersonalizedCustomizerElement(): void;
|
|
99
|
+
|
|
17
100
|
export interface ManifestLoadedEventDetail {
|
|
18
101
|
productId: string;
|
|
19
102
|
manifestMeta?: {
|
|
@@ -243,5 +326,5 @@ export interface TextOverlaySvgOptions {
|
|
|
243
326
|
|
|
244
327
|
export function generateTextSvg(
|
|
245
328
|
overlaySnapIdOrInput: string | any,
|
|
246
|
-
fontSourceOrOptions: string | ArrayBuffer | { apiUrl: string; authToken?: string; fontSource?: string | ArrayBuffer; textOverride?: string },
|
|
329
|
+
fontSourceOrOptions: string | ArrayBuffer | { apiUrl: string; authToken?: string; fontSource?: string | ArrayBuffer; textOverride?: string; omitPlacementRotation?: boolean },
|
|
247
330
|
): Promise<string>;
|