zakeke-configurator-react 0.1.280-prod → 0.1.282-prod

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 CHANGED
@@ -1,244 +1,284 @@
1
+ # 🌐 Zakeke Configurator for React 🚀
1
2
 
2
- # Zakeke Configurator for React
3
+ This library allows you to build a custom UI for the Zakeke 3D configurator tool. Create your own unique and immersive 3D experience with ease!
3
4
 
4
-
5
+ # 🔧 Prerequisites 🛠️
5
6
 
6
- This library let you build a custom UI for the Zakeke 3D configurator tool.
7
+ Before you can use this project, you will need to install Node.js, a JavaScript runtime built on Chrome's V8 JavaScript engine. Here's how to do it:
7
8
 
8
-
9
+ 1. Download the latest version of Node.js from the [official Node.js website](https://nodejs.org/en/download/).
9
10
 
10
- ## How to install and run a basic example
11
+ 2. Run the installation file and follow the prompts in the Node.js Setup Wizard.
11
12
 
12
-
13
+ 3. To confirm that Node.js was installed correctly, open your command prompt and run the following command:
13
14
 
14
- git clone https://github.com/UpCommerce/zakeke-configurator-react-example.git
15
- npm install
16
- npm run start
15
+ ```shell
16
+ node -v
17
+ ```
17
18
 
18
-
19
+ You should see your installed version of Node.js displayed in the command prompt.
19
20
 
20
- After running the example you will see a blank page running on `localhost:3000` , that because Zakeke must have some parameters to know what product to load.
21
21
 
22
- The parameters are automatically sent from the plugins with a postMessage but, for testing, we can pass them as query string in the URL.
22
+ ## 🛠️ Installation and Running a Basic Example 🏃‍♂️
23
23
 
24
- The easiest way to have all the parameters is:
24
+ To get started with this project, follow these steps:
25
25
 
26
-
26
+ 1. Clone the project repository using the following command:
27
27
 
28
- 1. Go in Zakeke configurator backoffice
28
+ ```shell
29
+ git clone https://github.com/UpCommerce/zakeke-configurator-react-example.git
30
+ ```
29
31
 
30
- 2. Add or edit a new product
32
+ 2. Install the necessary dependencies:
31
33
 
32
- 3. Go in the Shopping Preview page
34
+ ```shell
35
+ npm install
36
+ ```
33
37
 
34
- 4. Right click on the page -> inspect element
38
+ 3. Start the project:
35
39
 
36
- 5. Find the zakeke `<iframe>` src attribute and copy all query string parameters
40
+ ```shell
41
+ npm run start
42
+ ```
37
43
 
38
- 6. Paste the parameters in the localhost page.
39
-
40
- You should have something like:
41
-
42
- http://localhost:3000?modelCode=XXX&culture=XX&token=XXXXXX....
43
-
44
-
45
-
46
- With these parameter you should see the product loading in a basic UI interface.
47
-
48
- You can start customizing it.
49
-
50
-
51
-
52
- ## References
53
-
54
- The library exposes 4 elements:
55
-
56
-
57
-
58
- - a ZakekeEnvironment class that contains the state of the current scene
59
-
60
- - a ZakekeProvider react component that should wrap your application
61
-
62
- - a ZakekeViewer react component that will render the 3D scene
63
-
64
- - a useZakeke effect to get the data and methods to execute
65
-
66
-
67
-
68
- A basic Zakeke theme should be like:
69
-
70
- const zakekeEnvironment = new ZakekeEnvironment();
71
-
72
- <ZakekeProvider environment={zakekeEnvironment}>
73
- <div>
74
- <ZakekeViewer />
75
- </div>
76
- </ZakekeProvider>
77
-
78
-
79
-
80
- ## Properties and methods
81
-
82
- price: number;
83
-
84
- culture: string;
85
-
86
- currency: string;
87
-
88
- isSceneLoading: boolean;
89
-
90
- isAddToCartLoading: boolean;
91
-
92
- isViewerReady: boolean;
93
-
94
- fonts: FontFamily[];
95
-
96
- groups: Group[];
97
-
98
- templates: Template[];
99
-
100
- currentTemplate: Template | null;
101
-
102
- items: Item[];
103
-
104
- productName: string;
105
-
106
- productCode: string;
107
-
108
- product: Product | null;
109
-
110
- cameras: Camera[];
111
-
112
-
113
-
114
- selectOption: (optionId: number) => void;
115
-
116
- setTemplate: (templateId: number) => void;
117
-
118
- isAreaVisible: (areaId: number) => boolean;
119
-
120
-
121
-
122
- saveComposition: () => Promise<string>;
123
-
124
- loadComposition: (id: string) => Promise<void>;
125
-
126
- addToCart: (additionalProperties: Record<string, any>) => Promise<void>;
127
-
128
-
129
-
130
- getPDF: () => Promise<string>;
131
-
132
- getOnlineScreenshot: (width: number, height: number, backgroundColor?: string, padding?: number) => Promise<string>;
133
-
134
-
44
+ After running the example, a blank page will open on `localhost:3000`. This is because Zakeke requires some parameters to know what product to load. Let's get these parameters!
135
45
 
136
- setCamera: (id: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
46
+ ## 🎯 Getting the Parameters 🌐
137
47
 
138
- setCameraByName: (name: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
48
+ Follow these steps to get all the parameters:
139
49
 
140
- setCameraZoomEnabled: (enabled: boolean) => void;
50
+ 1. Go to the Zakeke configurator backoffice.
141
51
 
142
- resetCameraPivot: () => void;
52
+ 2. Add or edit a new product.
143
53
 
144
- setCameraPivot: (meshId: string) => void;
54
+ 3. Navigate to the Shopping Preview page.
145
55
 
146
-
56
+ 4. Right-click on the page -> inspect element.
147
57
 
148
- getImages: (categoryId: number) => Promise<Image[]>;
58
+ 5. Find the Zakeke `<iframe>` src attribute and copy all query string parameters.
149
59
 
150
- getMacroCategories: () => Promise<ImageMacroCategory[]>;
151
-
152
- previewOnly__setItemImageFromBase64: (guid: string, base64: string) => void;
153
-
154
-
155
-
156
- setItemImageFromFile: (guid: string, file: File) => Promise<void>;
157
-
158
- addItemImage: (id: number, areaId: number) => Promise<void>;
159
-
160
- createImage: (file: File, progress?: (percentage: number) => void) => Promise<Image>;
161
-
162
- createImageFromUrl: (url: string) => Promise<Image>;
163
-
164
- setItemImage: (guid: string, imageId: number) => Promise<void>;
165
-
166
- setItemFontFamily: (guid: string, fontFamily: string) => void;
167
-
168
- setItemColor: (guid: string, color: string) => void;
169
-
170
- setItemBold: (guid: string, bold: boolean) => void;
171
-
172
- setItemItalic: (guid: string, italic: boolean) => void;
173
-
174
- setItemText: (guid: string, text: string) => void;
175
-
176
- addItemText: (settings: { text: string, fontFamily: string }, areaId: number) => Promise<void>;
177
-
178
- removeItem: (guid: string) => Promise<void>;
179
-
180
-
181
-
182
- switchFullscreen: () => void;
183
-
184
- isFullscreenMode: boolean;
185
-
186
- zoomIn: () => void;
187
-
188
- zoomOut: () => void;
189
-
190
-
191
-
192
- updateView: (adjustCamera?: boolean) => void;
193
-
194
- setHighlightSettings: (settings: { color: string, size: number }) => void;
195
-
196
- hasExplodedMode: () => boolean;
197
-
198
- isExplodedMode: boolean;
199
-
200
- setExplodedMode: (exploded: boolean) => void;
201
-
202
-
203
-
204
- // Scene manipulation
205
-
206
- getMeshIDbyName: (name: string) => string | undefined | null,
207
-
208
- hideMeshAndSaveState: (meshId: string) => void,
209
-
210
- restoreMeshVisibility: (meshId: string) => void,
211
-
212
- setMeshDesignVisibility: (meshId: string, visible: boolean) => void,
213
-
214
-
215
-
216
- // Events
217
-
218
- clearListeners: () => void;
219
-
220
- addFocusAttributesListener: (listenerFunction: FocusAttributesEventListener) => void;
221
-
222
- focusAttribute: (attributeId: number) => void;
223
-
224
-
225
-
226
- // AR
227
-
228
- getQrCodeArUrl: (device: 'iOS' | 'Android') => Promise<string>;
229
-
230
- getMobileArUrl: (useCacheWithDesign?: boolean) => Promise<string | null>;
231
-
232
- openArMobile: (url: string) => void;
233
-
234
- isSceneArEnabled: () => boolean;
235
-
236
-
237
-
238
- IS_ANDROID: boolean;
239
-
240
- IS_IOS: boolean;
60
+ 6. Paste the parameters in the localhost page.
241
61
 
242
-
62
+ Your URL should look something like this:
243
63
 
244
- setBackgroundColor: (color: string, alpha: number) => void;
64
+ ```
65
+ http://localhost:3000?modelCode=XXX&culture=XX&token=XXXXXX....
66
+ ```
67
+
68
+ With these parameters, you should see the product loading in a basic UI interface. Start customizing it to your needs!
69
+
70
+ ## 📚 References 📖
71
+
72
+ The library exposes four key elements:
73
+
74
+ - `ZakekeEnvironment`: A class that contains the state of the current scene.
75
+
76
+ - `ZakekeProvider`: A React component that should wrap your application.
77
+
78
+ - `ZakekeViewer`: A React component that will render the 3D scene.
79
+
80
+ - `useZakeke`: An effect to retrieve data and execute methods.
81
+
82
+ Here is how a basic Zakeke theme would look like:
83
+
84
+ ```jsx
85
+ const zakekeEnvironment = new ZakekeEnvironment();
86
+
87
+ <ZakekeProvider environment={zakekeEnvironment}>
88
+ <div>
89
+ <ZakekeViewer />
90
+ </div>
91
+ </ZakekeProvider>
92
+ ```
93
+
94
+ # 📚 Documentation Reference 📚
95
+
96
+ `useZakeke` exposes the following values:
97
+
98
+ ```ts
99
+ price: number;
100
+ isOutOfStock: boolean;
101
+ culture: string;
102
+ currency: string;
103
+ isSceneLoading: boolean;
104
+ isAddToCartLoading: boolean;
105
+ isInfoPointContentVisible: boolean;
106
+ isViewerReady: boolean;
107
+ fonts: FontFamily[];
108
+ disableTextColors: boolean;
109
+ defaultColor: string;
110
+ textColors: RestrictionColor[];
111
+ groups: Group[];
112
+ templates: Template[];
113
+ loadedComposition: { templateName: string; attributesOptions: Map<number, number>; selectedCategoryID: number | null } | null;
114
+ currentTemplate: Template | null;
115
+ items: Item[];
116
+ productName: string;
117
+ productCode: string;
118
+ product: Product | null;
119
+ cameras: Camera[];
120
+ sellerSettings: SellerSettings | null;
121
+ quantityRule: ProductQuantityRule | null;
122
+ eventMessages: EventMessage[] | null;
123
+ personalizedMessages: EventMessage[] | null;
124
+ visibleEventMessages: VisibleEventMessage[];
125
+ isAssetsLoading: boolean;
126
+ draftCompositions: ThemeCompositions[] | null;
127
+ additionalCustomProperties: { name: string; value: number; label: string; formatString: string }[] | null;
128
+ currentAttributesSelection: object | null;
129
+ currentCompositionInfo: { compositionId: string | null; compositionName: string | null; compositionTags: string[] | null } | null;
130
+ translations: Translations | null;
131
+ nftSettings: NftSettings | null;
132
+ useLegacyScreenshot: boolean;
133
+ isAIEnabled: boolean;
134
+ uiConfig: UIConfig | null;
135
+ backgroundColor: string;
136
+ removeBackground: boolean;
137
+ setMouseWheelZoomEnabled: (enabled: boolean) => void;
138
+ selectOption: (optionId: number) => void;
139
+ /**
140
+ * @internal
141
+ */
142
+ internalAppendViewer: (container: HTMLElement) => void;
143
+ getPrintingMethodsRestrictions: () => PrintingMethodsRestrictions;
144
+ designUpdate: () => void;
145
+ createQuote: (formData: any) => Promise<any>;
146
+ setTemplate: (templateId: number) => Promise<void>;
147
+ isAreaVisible: (areaId: number) => boolean;
148
+ quantity: number;
149
+ saveTemplate: (templateName: string, selectedCategoryID: number | null, attributesOptions: Map<number, number>) => Promise<void>;
150
+ addToCart: (
151
+ additionalProperties: Record<string, any>,
152
+ OnBeforeSendDataToParent?: (data: OnBeforeSendDataToParent) => Promise<Record<string, any>>,
153
+ legacyScreenshot?: boolean,
154
+ nftForm?: NftForm
155
+ ) => Promise<void>;
156
+ /**
157
+ * Create a PDF of the current configuration
158
+ * @returns The URL of the PDF
159
+ */
160
+ getPDF: () => Promise<string>;
161
+ getOnlineScreenshot: (
162
+ width: number,
163
+ height: number,
164
+ legacyScreenshot?: boolean,
165
+ backgroundColor?: string,
166
+ padding?: number
167
+ ) => Promise<{ originalUrl: string; rewrittenUrl: string }>;
168
+
169
+ setCamera: (id: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
170
+ setCameraByName: (name: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
171
+ setCameraZoomEnabled: (enabled: boolean) => void;
172
+ resetCameraPivot: () => void;
173
+
174
+ setCameraPivot: (meshId: string) => void;
175
+ fullyLoadFont: (fontFamily: string | FontFamily) => Promise<FontFamily>;
176
+ sanitizeString: (family: FontFamily, text: string) => string;
177
+ getSanitationText: (family: FontFamily, text: string) => TextSanitationResult;
178
+ getImages: (categoryId: number) => Promise<ZakekeImage[]>;
179
+ getMacroCategories: () => Promise<ImageMacroCategory[]>;
180
+
181
+ previewOnly__setItemImageFromBase64: (guid: string, base64: string) => void;
182
+ setItemImageFromFile: (guid: string, file: File) => Promise<void>;
183
+ addItemImage: (id: number, areaId: number) => Promise<void>;
184
+ /**
185
+ * Upload an image and get the uploaded image
186
+ * @param file The file to upload
187
+ * @param progress A callback to get the upload progress
188
+ * @returns The uploaded image
189
+ */
190
+ createImage: (file: File, progress?: (percentage: number) => void) => Promise<ZakekeImage>;
191
+ createImageFromUrl: (url: string) => Promise<ZakekeImage>;
192
+ setItemImage: (guid: string, imageId: number) => Promise<void>;
193
+ setItemFontFamily: (guid: string, fontFamily: string) => void;
194
+ setItemColor: (guid: string, color: string) => void;
195
+ setItemBold: (guid: string, bold: boolean) => void;
196
+ setItemItalic: (guid: string, italic: boolean) => void;
197
+ setItemTextOnPath: (guid: string, areaId: number, value: boolean) => void;
198
+ setItemText: (guid: string, text: string) => void;
199
+ addItemText: (settings: { text: string; fontFamily: string }, areaId: number) => Promise<void>;
200
+ /**
201
+ * Remove an item from the customization
202
+ * @param guid The guid of the item to remove
203
+ */
204
+ removeItem: (guid: string) => Promise<void>;
205
+ setQuantity: (quantity: number) => void;
206
+ getShareCompositionUrl: () => Promise<string>;
207
+ saveComposition: (customPreviewSize?: CustomPreviewSize) => Promise<void>;
208
+ loadComposition: (id: string) => Promise<void>;
209
+ switchFullscreen: () => void;
210
+ openSecondScreen: () => void;
211
+ isFullscreenMode: boolean;
212
+ zoomIn: () => void;
213
+ zoomOut: () => void;
214
+ updateView: (adjustCamera?: boolean) => void;
215
+ setHighlightSettings: (settings: { color: string; size: number }) => void;
216
+
217
+ hasExplodedMode: () => boolean;
218
+ isExplodedMode: boolean;
219
+ setExplodedMode: (exploded: boolean) => void;
220
+
221
+ // Scene manipulation
222
+ getMeshIDbyName: (name: string) => string | undefined | null;
223
+ hideMeshAndSaveState: (meshId: string) => void;
224
+ restoreMeshVisibility: (meshId: string) => void;
225
+ setMeshDesignVisibility: (meshId: string, visible: boolean) => void;
226
+
227
+ // Events
228
+ clearListeners: () => void;
229
+ addFocusAttributesListener: (listenerFunction: FocusAttributesEventListener) => void;
230
+ focusAttribute: (attributeId: number) => void;
231
+
232
+ // Highlight
233
+ highlightGroup: (groupId: number) => void;
234
+ highlightAttribute: (attributeId: number) => void;
235
+ // AR
236
+ getQrCodeArUrl: (device: 'iOS' | 'Android') => Promise<string>;
237
+ getMobileArUrl: (onFlyArUrl?: string) => Promise<Blob | string | null>;
238
+ openArMobile: (url: string) => void;
239
+ isSceneArEnabled: () => boolean;
240
+ isArDeviceCompliant: () => boolean;
241
+ IS_ANDROID: boolean;
242
+ IS_IOS: boolean;
243
+
244
+ setBackgroundColor: (color: string, alpha: number) => void;
245
+ getTryOnUrl: (tryOnUrl?: string) => Promise<string>;
246
+ isSceneTryOnEnabled: () => boolean;
247
+ setCameraLocked: (isBlocked: boolean) => void;
248
+ getTemplateUploadRestrictictions: (templateId: number, areaId: number) => TemplateUploadRestrictictions;
249
+ saveDraftsComposition: (name: string, tags: string[], isCopy?: boolean) => Promise<void>;
250
+ loadSavedComposition: (docID: string) => Promise<void>;
251
+ deleteSavedComposition: (docId: string) => Promise<void>;
252
+ exportSceneToGlb: () => Promise<string | Blob | null>;
253
+ // reset, undo, redo
254
+ reset: () => Promise<void>;
255
+ undo: () => Promise<void>;
256
+ redo: () => Promise<void>;
257
+
258
+ // copyright checkbox
259
+ getCopyrightMessageAccepted: () => boolean;
260
+ setCopyrightMessageAccepted: (copyrightMandatoryCheckbox: boolean) => void;
261
+
262
+ validationNFTEmail: (email: string) => boolean;
263
+ validationNFTWalletAddress: (walletAddress: string) => boolean;
264
+
265
+ templateMacroCategories: TemplateMacroCategory[] | null;
266
+ applyTemplate: (templateGroupCompositionId: number) => Promise<void>;
267
+
268
+ configureByAI: (text: string) => Promise<void>;
269
+ hasVTryOnEnabled: boolean;
270
+ canUseTryOn: boolean;
271
+ canUsePD: boolean;
272
+ getTryOnSettings: () => Zakeke.TryOnSettings | undefined;
273
+ isTryOnMeshVisible: boolean;
274
+ isMandatoryPD: boolean;
275
+ isVisibleMeshShownForTryOn: boolean;
276
+ setPDDistance: (distance: number) => void;
277
+ pdDistance: () => number;
278
+ exportTryOnMeshToGlb: () => Promise<string | Blob | null>;
279
+ ```
280
+
281
+ You can find a full and updated list of the values exposed by `useZakeke` in the source code (the definitions files) of the library.
282
+ Please refer to the source code comments for a detailed understanding of each value and their usage.
283
+
284
+ _Note: Always ensure to handle these values appropriately in your React components to ensure a smooth user experience._
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface QRCodeGeneratorProps {
3
+ url: string;
4
+ }
5
+ declare const DeepARQrCodeContentContainer: React.FC<QRCodeGeneratorProps>;
6
+ export default DeepARQrCodeContentContainer;
@@ -353,5 +353,6 @@ export declare class ZakekeEnvironment {
353
353
  * Le restrizioni sul printing method o quelle di default
354
354
  */
355
355
  getPrintingMethodsRestrictions: () => PrintingMethodsRestrictions;
356
+ setMouseWheelZoomEnabled: (enabled: boolean) => void;
356
357
  }
357
358
  export {};
@@ -219,6 +219,7 @@ export interface Item {
219
219
  guid: string;
220
220
  name: string;
221
221
  areaId: number;
222
+ index: number;
222
223
  constraints: {
223
224
  [key: string]: any;
224
225
  } | null;
@@ -88,6 +88,7 @@ export interface Zakeke {
88
88
  uiConfig: UIConfig | null;
89
89
  backgroundColor: string;
90
90
  removeBackground: boolean;
91
+ setMouseWheelZoomEnabled: (enabled: boolean) => void;
91
92
  selectOption: (optionId: number) => void;
92
93
  /**
93
94
  * @internal