@useinsider/guido 1.4.4 → 2.0.0-beta.061e9c9

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 (203) hide show
  1. package/README.md +297 -664
  2. package/dist/@types/config/defaults.js +44 -0
  3. package/dist/@types/config/schemas.js +233 -0
  4. package/dist/@types/config/validator.js +56 -0
  5. package/dist/components/Guido.vue.js +1 -1
  6. package/dist/components/Guido.vue2.js +64 -88
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue2.js +13 -13
  8. package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue.js +5 -5
  9. package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue2.js +13 -13
  10. package/dist/components/organisms/header/LeftSlot.vue.js +1 -1
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +18 -15
  12. package/dist/components/organisms/header/RightSlot.vue.js +10 -10
  13. package/dist/components/organisms/onboarding/NewVersionPopup.vue2.js +22 -19
  14. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +4 -4
  15. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +8 -8
  16. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
  17. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +17 -17
  18. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +10 -10
  19. package/dist/composables/useActionsApi.js +42 -25
  20. package/dist/composables/useBlocksConfig.js +23 -20
  21. package/dist/composables/useConfig.js +51 -5
  22. package/dist/composables/useHtmlCompiler.js +20 -19
  23. package/dist/composables/useHtmlValidator.js +41 -41
  24. package/dist/composables/usePartner.js +19 -9
  25. package/dist/composables/useStripo.js +58 -57
  26. package/dist/composables/useTimerClone.js +53 -0
  27. package/dist/composables/useTranslations.js +3 -2
  28. package/dist/config/compiler/unsubscribeCompilerRules.js +1 -1
  29. package/dist/enums/defaults.js +4 -67
  30. package/dist/enums/unsubscribe.js +23 -20
  31. package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
  32. package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
  33. package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
  34. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
  35. package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
  36. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +158 -68
  37. package/dist/extensions/Blocks/Recommendation/constants.js +10 -1
  38. package/dist/extensions/Blocks/Recommendation/control.js +74 -59
  39. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/index.js +272 -0
  41. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.js +71 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.js +71 -0
  44. package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.js +71 -0
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.js +71 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/priceHideControl.js +60 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/priceInlineLayoutControl.js +160 -0
  48. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
  49. package/dist/extensions/Blocks/Recommendation/extension.js +16 -40
  50. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +124 -71
  51. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +12 -11
  52. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +89 -65
  53. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +56 -19
  54. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +74 -45
  55. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +25 -0
  56. package/dist/extensions/Blocks/controlFactories.js +124 -113
  57. package/dist/guido.css +1 -1
  58. package/dist/library.js +12 -2
  59. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +14 -14
  60. package/dist/node_modules/lodash-es/_arrayLikeKeys.js +10 -10
  61. package/dist/node_modules/valibot/dist/index.js +476 -103
  62. package/dist/services/stripoApi.js +11 -16
  63. package/dist/services/templateLibraryApi.js +18 -18
  64. package/dist/src/@types/config/defaults.d.ts +68 -0
  65. package/dist/src/@types/config/index.d.ts +14 -0
  66. package/dist/src/@types/config/schemas.d.ts +513 -0
  67. package/dist/src/@types/config/types.d.ts +142 -0
  68. package/dist/src/@types/config/validator.d.ts +119 -0
  69. package/dist/src/@types/generic.d.ts +4 -45
  70. package/dist/src/components/Guido.vue.d.ts +13 -12
  71. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  72. package/dist/src/composables/useActionsApi.d.ts +2 -0
  73. package/dist/src/composables/useConfig.d.ts +188 -2
  74. package/dist/src/composables/usePartner.d.ts +8 -0
  75. package/dist/src/composables/useTimerClone.d.ts +6 -0
  76. package/dist/src/enums/defaults.d.ts +5 -6
  77. package/dist/src/enums/unsubscribe.d.ts +5 -1
  78. package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
  79. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
  80. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
  81. package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +54 -3
  82. package/dist/src/extensions/Blocks/Recommendation/constants.d.ts +41 -1
  83. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +5 -2
  84. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +654 -0
  86. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
  87. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +15 -0
  88. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +15 -0
  89. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +15 -0
  90. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +15 -0
  91. package/dist/src/extensions/Blocks/Recommendation/controls/priceHideControl.d.ts +16 -0
  92. package/dist/src/extensions/Blocks/Recommendation/controls/priceInlineLayoutControl.d.ts +50 -0
  93. package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +60 -0
  94. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +3 -3
  95. package/dist/src/extensions/Blocks/Recommendation/templates/migrationTemplate.d.ts +1 -1
  96. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +15 -7
  97. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +19 -0
  98. package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
  99. package/dist/src/library.d.ts +3 -1
  100. package/dist/src/stores/config.d.ts +1581 -102
  101. package/dist/static/styles/components/narrow-panel.css.js +0 -10
  102. package/dist/static/styles/components/wide-panel.css.js +0 -4
  103. package/dist/static/styles/customEditorStyle.css.js +13 -0
  104. package/dist/stores/config.js +141 -9
  105. package/package.json +1 -1
  106. package/dist/extensions/Blocks/Recommendation/controls/button/align.js +0 -13
  107. package/dist/extensions/Blocks/Recommendation/controls/button/border.js +0 -13
  108. package/dist/extensions/Blocks/Recommendation/controls/button/borderRadius.js +0 -13
  109. package/dist/extensions/Blocks/Recommendation/controls/button/color.js +0 -13
  110. package/dist/extensions/Blocks/Recommendation/controls/button/fitToContent.js +0 -13
  111. package/dist/extensions/Blocks/Recommendation/controls/button/fontFamily.js +0 -13
  112. package/dist/extensions/Blocks/Recommendation/controls/button/margins.js +0 -13
  113. package/dist/extensions/Blocks/Recommendation/controls/button/paddings.js +0 -13
  114. package/dist/extensions/Blocks/Recommendation/controls/button/text.js +0 -13
  115. package/dist/extensions/Blocks/Recommendation/controls/button/textSize.js +0 -13
  116. package/dist/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.js +0 -13
  117. package/dist/extensions/Blocks/Recommendation/controls/image/margins.js +0 -13
  118. package/dist/extensions/Blocks/Recommendation/controls/image/size.js +0 -13
  119. package/dist/extensions/Blocks/Recommendation/controls/name/align.js +0 -13
  120. package/dist/extensions/Blocks/Recommendation/controls/name/background.js +0 -13
  121. package/dist/extensions/Blocks/Recommendation/controls/name/color.js +0 -13
  122. package/dist/extensions/Blocks/Recommendation/controls/name/fontFamily.js +0 -13
  123. package/dist/extensions/Blocks/Recommendation/controls/name/paddings.js +0 -13
  124. package/dist/extensions/Blocks/Recommendation/controls/name/size.js +0 -13
  125. package/dist/extensions/Blocks/Recommendation/controls/name/style.js +0 -13
  126. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/align.js +0 -13
  127. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/background.js +0 -13
  128. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/color.js +0 -13
  129. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.js +0 -13
  130. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/paddings.js +0 -13
  131. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/size.js +0 -13
  132. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/style.js +0 -13
  133. package/dist/extensions/Blocks/Recommendation/controls/price/align.js +0 -13
  134. package/dist/extensions/Blocks/Recommendation/controls/price/background.js +0 -13
  135. package/dist/extensions/Blocks/Recommendation/controls/price/color.js +0 -13
  136. package/dist/extensions/Blocks/Recommendation/controls/price/fontFamily.js +0 -13
  137. package/dist/extensions/Blocks/Recommendation/controls/price/paddings.js +0 -13
  138. package/dist/extensions/Blocks/Recommendation/controls/price/size.js +0 -13
  139. package/dist/extensions/Blocks/Recommendation/controls/price/style.js +0 -13
  140. package/dist/node_modules/lodash-es/_apply.js +0 -16
  141. package/dist/node_modules/lodash-es/_assignMergeValue.js +0 -8
  142. package/dist/node_modules/lodash-es/_assignValue.js +0 -10
  143. package/dist/node_modules/lodash-es/_baseAssignValue.js +0 -12
  144. package/dist/node_modules/lodash-es/_baseCreate.js +0 -17
  145. package/dist/node_modules/lodash-es/_baseKeysIn.js +0 -15
  146. package/dist/node_modules/lodash-es/_baseMerge.js +0 -20
  147. package/dist/node_modules/lodash-es/_baseMergeDeep.js +0 -31
  148. package/dist/node_modules/lodash-es/_baseRest.js +0 -9
  149. package/dist/node_modules/lodash-es/_baseSetToString.js +0 -14
  150. package/dist/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
  151. package/dist/node_modules/lodash-es/_cloneBuffer.js +0 -9
  152. package/dist/node_modules/lodash-es/_cloneTypedArray.js +0 -8
  153. package/dist/node_modules/lodash-es/_copyArray.js +0 -9
  154. package/dist/node_modules/lodash-es/_copyObject.js +0 -14
  155. package/dist/node_modules/lodash-es/_createAssigner.js +0 -15
  156. package/dist/node_modules/lodash-es/_defineProperty.js +0 -11
  157. package/dist/node_modules/lodash-es/_getPrototype.js +0 -5
  158. package/dist/node_modules/lodash-es/_initCloneObject.js +0 -9
  159. package/dist/node_modules/lodash-es/_nativeKeysIn.js +0 -10
  160. package/dist/node_modules/lodash-es/_overRest.js +0 -15
  161. package/dist/node_modules/lodash-es/_safeGet.js +0 -7
  162. package/dist/node_modules/lodash-es/_setToString.js +0 -6
  163. package/dist/node_modules/lodash-es/_shortOut.js +0 -16
  164. package/dist/node_modules/lodash-es/constant.js +0 -8
  165. package/dist/node_modules/lodash-es/isArrayLikeObject.js +0 -8
  166. package/dist/node_modules/lodash-es/isPlainObject.js +0 -16
  167. package/dist/node_modules/lodash-es/keysIn.js +0 -9
  168. package/dist/node_modules/lodash-es/merge.js +0 -8
  169. package/dist/node_modules/lodash-es/toPlainObject.js +0 -8
  170. package/dist/src/extensions/Blocks/Recommendation/controls/button/align.d.ts +0 -5
  171. package/dist/src/extensions/Blocks/Recommendation/controls/button/border.d.ts +0 -5
  172. package/dist/src/extensions/Blocks/Recommendation/controls/button/borderRadius.d.ts +0 -5
  173. package/dist/src/extensions/Blocks/Recommendation/controls/button/color.d.ts +0 -5
  174. package/dist/src/extensions/Blocks/Recommendation/controls/button/fitToContent.d.ts +0 -5
  175. package/dist/src/extensions/Blocks/Recommendation/controls/button/fontFamily.d.ts +0 -5
  176. package/dist/src/extensions/Blocks/Recommendation/controls/button/margins.d.ts +0 -5
  177. package/dist/src/extensions/Blocks/Recommendation/controls/button/paddings.d.ts +0 -5
  178. package/dist/src/extensions/Blocks/Recommendation/controls/button/text.d.ts +0 -5
  179. package/dist/src/extensions/Blocks/Recommendation/controls/button/textSize.d.ts +0 -5
  180. package/dist/src/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.d.ts +0 -5
  181. package/dist/src/extensions/Blocks/Recommendation/controls/image/margins.d.ts +0 -5
  182. package/dist/src/extensions/Blocks/Recommendation/controls/image/size.d.ts +0 -5
  183. package/dist/src/extensions/Blocks/Recommendation/controls/name/align.d.ts +0 -5
  184. package/dist/src/extensions/Blocks/Recommendation/controls/name/background.d.ts +0 -5
  185. package/dist/src/extensions/Blocks/Recommendation/controls/name/color.d.ts +0 -5
  186. package/dist/src/extensions/Blocks/Recommendation/controls/name/fontFamily.d.ts +0 -5
  187. package/dist/src/extensions/Blocks/Recommendation/controls/name/paddings.d.ts +0 -5
  188. package/dist/src/extensions/Blocks/Recommendation/controls/name/size.d.ts +0 -5
  189. package/dist/src/extensions/Blocks/Recommendation/controls/name/style.d.ts +0 -5
  190. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/align.d.ts +0 -5
  191. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/background.d.ts +0 -5
  192. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/color.d.ts +0 -5
  193. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.d.ts +0 -5
  194. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/paddings.d.ts +0 -5
  195. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/size.d.ts +0 -5
  196. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/style.d.ts +0 -5
  197. package/dist/src/extensions/Blocks/Recommendation/controls/price/align.d.ts +0 -5
  198. package/dist/src/extensions/Blocks/Recommendation/controls/price/background.d.ts +0 -5
  199. package/dist/src/extensions/Blocks/Recommendation/controls/price/color.d.ts +0 -5
  200. package/dist/src/extensions/Blocks/Recommendation/controls/price/fontFamily.d.ts +0 -5
  201. package/dist/src/extensions/Blocks/Recommendation/controls/price/paddings.d.ts +0 -5
  202. package/dist/src/extensions/Blocks/Recommendation/controls/price/size.d.ts +0 -5
  203. package/dist/src/extensions/Blocks/Recommendation/controls/price/style.d.ts +0 -5
package/README.md CHANGED
@@ -4,789 +4,422 @@
4
4
  </a>
5
5
  </p>
6
6
 
7
-
8
7
  # @useinsider/guido
9
8
 
10
- Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, customizable interface.
9
+ Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
11
10
 
12
- ## 📦 Install
11
+ ## Installation
13
12
 
14
13
  ```bash
15
14
  npm install @useinsider/guido
16
15
  ```
16
+
17
17
  ### Prerequisites
18
- 🍍 Your project should have `pinia`
19
- You need to be sure those lines added in your config file:
20
-
21
- ℹ️ It helps to optimize your dependencies and sharing by Guido. This is why Guido pretty fast and tiny.
22
-
23
- #### For Webpack
24
- `/webpack.config.js` or `/vue.config.js`
25
- ```js
26
- // ... Previous Configs
27
- shared: {
28
- vue: { singleton: true },
29
- pinia: { singleton: true },
30
- },
31
- // ... Upcoming Configs
32
- ```
33
-
34
- ##### For Vite:
35
- `/vite.config.js`
36
- ```js
37
- // ... Previous Configs
38
- resolve: {
39
- dedupe: ['vue', 'pinia'],
40
- },
41
- // ... Upcoming Configs
42
- ```
18
+
19
+ Your project needs:
20
+ - Vue 2.7+
21
+ - Pinia (state management)
22
+
23
+ Add these to your bundler config to optimize dependencies:
24
+
25
+ **Webpack** (`webpack.config.js` or `vue.config.js`):
26
+ ```js
27
+ shared: {
28
+ vue: { singleton: true },
29
+ pinia: { singleton: true },
30
+ },
31
+ ```
32
+
33
+ **Vite** (`vite.config.js`):
34
+ ```js
35
+ resolve: {
36
+ dedupe: ['vue', 'pinia'],
37
+ },
38
+ ```
39
+
43
40
  ---
44
- ## 🚀 Usage
45
41
 
46
- ### Basic Usage
42
+ ## Quick Start
47
43
 
48
- ```html
44
+ ```vue
49
45
  <template>
50
- <div>
51
- <Guido
52
- ref="guidoEditor"
53
- :template-id="templateId"
54
- :user-id="userId"
55
- :migration-date="migrationDate"
56
- :guido-config="guidoConfig"
57
- :html="initialHtml"
58
- :css="initialCss"
59
- @dynamic-content:open="handleDynamicContentOpen"
60
- @back="handleBack"
61
- @save:start="handleSaveStart"
62
- @save:complete="handleSaveComplete"
63
- />
64
- </div>
46
+ <Guido
47
+ ref="guidoRef"
48
+ :config="config"
49
+ @ready="onReady"
50
+ @dynamic-content:open="onDynamicContentOpen"
51
+ @save:complete="onSaveComplete"
52
+ />
65
53
  </template>
66
54
 
67
- <script lang="ts">
55
+ <script setup lang="ts">
56
+ import { ref } from 'vue';
68
57
  import { Guido } from '@useinsider/guido';
58
+ import type { GuidoConfigInput } from '@useinsider/guido';
59
+
60
+ const guidoRef = ref<InstanceType<typeof Guido> | null>(null);
69
61
 
70
- export default {
71
- components: {
72
- Guido
62
+ const config = ref<GuidoConfigInput>({
63
+ identity: {
64
+ templateId: 'template-123',
65
+ userId: 'user-456',
73
66
  },
74
- data() {
75
- return {
76
- templateId: 'template-123',
77
- userId: 'user-456',
78
- migrationDate: 1699488000,
79
- initialHtml: '<p>Initial HTML content</p>',
80
- initialCss: 'p { color: #333; }',
81
- guidoConfig: {
82
- translationsPath: 'window.trans.en',
83
- htmlCompilerRules: [],
84
- ignoreDefaultHtmlCompilerRules: false,
85
- backButtonLabel?: "Back to Design",
86
- features: {
87
- dynamicContent: true,
88
- saveAsTemplate: true,
89
- versionHistory: true,
90
- testMessage: true
91
- }
92
- },
93
- dynamicContentModalVisible: false
94
- };
67
+ partner: {
68
+ name: 'your-partner-name',
95
69
  },
70
+ template: {
71
+ html: '<p>Initial content</p>',
72
+ css: '',
73
+ },
74
+ });
96
75
 
97
- methods: {
98
- handleDynamicContentOpen(detail) {
99
- console.log('Dynamic content requested:', detail);
100
- this.dynamicContentModalVisible = true;
101
- },
102
-
103
- handleBack() {
104
- console.log('User clicked back button');
105
- // Handle navigation back
106
- },
107
-
108
- handleSaveStart() {
109
- console.log('Save process started');
110
- // Show loading indicator
111
- },
112
-
113
- handleSaveComplete(template) {
114
- console.log('Save completed:', template);
115
- // Handle saved template data
116
- },
117
-
118
- // ⚠️ Your own Dynamic Content Modal should have this id: #guido-dynamic-content-modal
119
- handleDynamicContentInsert() {
120
- this.$refs.guidoEditor?.dynamicContent.insert({
121
- text: 'Display Text',
122
- value: 'actual-value',
123
- fallback: 'Fallback Text'
124
- });
125
-
126
- this.dynamicContentModalVisible = false;
127
- },
128
-
129
- // ⚠️ It's mandatory. There is no way to understand if user closes the modal without selection.
130
- handleDynamicContentClose() {
131
- this.$refs.guidoEditor?.dynamicContent.close();
132
- },
133
-
134
- // If you need to trigger save manually like leave modal cases, you can use this method.
135
- save () {
136
- this.$refs.guidoEditor?.saveSilent();
137
- }
138
- }
139
- };
76
+ const onReady = () => console.log('Editor ready');
77
+ const onDynamicContentOpen = () => console.log('Dynamic content requested');
78
+ const onSaveComplete = (template) => console.log('Saved:', template);
140
79
  </script>
141
80
  ```
142
81
 
143
- ## 📚 API
144
-
145
- ### Guido Component Props
82
+ ---
146
83
 
147
- | Prop | Type | Required | Default | Description |
148
- |------|------|----------|---------|-------------|
149
- | `templateId` | `string` | ✅ | - | Unique identifier for the email template |
150
- | `userId` | `string` | ✅ | - | Unique identifier for the user |
151
- | `guidoConfig` | `GuidoConfig` | ✅ | - | Configuration object for the editor |
152
- | `migrationDate` | `number` | ✅ | - | Stripo migration date in Unix timestamp (seconds). Retrieved from backend `/partner-settings` endpoint as `migrationDate`. Used for onboarding process |
153
- | `partnerName` | `string` | ⚪ | From URL host | Partner identifier |
154
- | `productType` | `string` | ⚪ | From URL path | Product type identifier |
155
- | `username` | `string` | ⚪ | `'Guido User'` | Display name for the user |
156
- | `html` | `string` | ⚪ | `''` | Initial HTML content for the template |
157
- | `css` | `string` | ⚪ | `''` | Initial CSS styles for the template |
84
+ ## Configuration
158
85
 
159
- ### Guido Component Events
86
+ Guido uses a single, validated `config` prop organized by domain:
160
87
 
161
- | Event | Payload | Description |
162
- |-------|---------|-------------|
163
- | `dynamic-content:open` | `DynamicContent \| null` | Fired when user requests to insert dynamic content |
164
- | `back` | - | Fired when user clicks the back button |
165
- | `save:start` | - | Fired when the save process begins |
166
- | `save:complete` | `Omit<Template, 'forceRecreate'>` | Fired when template is successfully saved |
167
- | `on-change` | void | It Fires once for managing leave modal etc. |
168
- | `ready` | void | Fired when the editor is ready and template is loaded |
169
- | `onboarding-finished` | void | Fired when the onboarding popup is dismissed or completed, allowing parent applications to track onboarding state |
170
- | `test-email:click` | - | Fired when user clicks the test email button in the header |
171
-
172
- ### Guido Exposed Methods
173
88
  ```typescript
174
- dynamicContent.insert(DynamicContent);
175
- dynamicContent.close();
176
- saveSilent();
177
- ```
178
-
179
- ### Guido Interfaces
89
+ import type { GuidoConfigInput } from '@useinsider/guido';
90
+
91
+ const config: GuidoConfigInput = {
92
+ // Required: Identity
93
+ identity: {
94
+ templateId: string, // Required - Template identifier
95
+ userId: string, // Required - User identifier
96
+ variationId?: string, // Optional - A/B test variation
97
+ },
180
98
 
181
- ```typescript
182
- interface GuidoConfig {
183
- translationsPath: string;
184
- htmlCompilerRules?: CompilerRule[];
185
- ignoreDefaultHtmlCompilerRules?: boolean;
186
- useHeader: boolean
187
- emailHeader: {
188
- senderName: string;
189
- subject: string;
190
- };
99
+ // Required: Partner
191
100
  partner: {
192
- partnerName: string;
193
- productType: number;
194
- messageType: number;
195
- };
196
- features: {
197
- dynamicContent: boolean;
198
- saveAsTemplate: boolean;
199
- versionHistory: boolean;
200
- testMessage: boolean;
201
- displayConditions: boolean;
202
- };
203
- blocks?: {
204
- excludeDefaults?: GuidoBlockType[];
205
- includeCustoms?: GuidoCustomBlockType[];
206
- };
207
- }
208
- ```
101
+ name: string, // Required - Partner name
102
+ productType?: number, // Optional - Default: 60 (Email)
103
+ messageType?: number, // Optional - Default: 1 (Promotional)
104
+ username?: string, // Optional - Default: 'Guido User'
105
+ },
209
106
 
210
- | Property | Type | Default | Description |
211
- |----------|------|---------|-------------|
212
- | `translationsPath` | `string` | `'window.trans.en'` | JavaScript path to the translations object |
213
- | `htmlCompilerRules` | `CompilerRule[]` | `[]` | Additional compiler rules to apply to HTML content. See [HTML Compiler Rules](#-html-compiler-rules) section below |
214
- | `ignoreDefaultHtmlCompilerRules` | `boolean` | `false` | Skip default compiler rules and only use custom rules. Default rules: `src/config/compiler/htmlCompilerRules.ts` |
215
- | `useHeader` | `boolean` | `true` | Adds extra spaces to height for adjusting. If you don't use Inone Page header, override as `false` |
216
- | `features` | `Features` | `{ dynamicContent: true, saveAsTemplate: true, versionHistory: true }` | Feature flags to enable/disable editor functionality |
217
- | `features.dynamicContent` | `boolean` | `true` | Enable dynamic content insertion feature |
218
- | `features.saveAsTemplate` | `boolean` | `true` | Enable save as template feature |
219
- | `features.versionHistory` | `boolean` | `true` | Enable version history feature |
220
- | `features.displayConditions` | `boolean` | `true` | Enable display conditions |
221
- | `blocks` | `BlocksConfig` | `{ excludeDefaults: [], includeCustoms: [] }` | Block configuration for excluding default blocks and including custom blocks. See [Blocks Configuration](#-blocks-configuration) section below |
222
- | `blocks.excludeDefaults` | `GuidoBlockType[]` | `[]` | Array of default Stripo blocks to exclude from the editor |
223
- | `blocks.includeCustoms` | `GuidoCustomBlockType[]` | `[]` | Array of custom blocks to include in the editor |
107
+ // Optional: Template content
108
+ template?: {
109
+ html?: string,
110
+ css?: string,
111
+ preselectedDynamicContent?: DynamicContent[],
112
+ selectedUnsubscribePages?: number[],
113
+ forceRecreate?: boolean, // Default: false - Force recreate template in Stripo storage
114
+ },
224
115
 
225
- ```typescript
226
- interface DynamicContent {
227
- value: string;
228
- text: string;
229
- fallback?: string;
230
- }
231
- ```
232
- ---
116
+ // Optional: Editor settings
117
+ editor?: {
118
+ locale?: string, // Default: 'en'
119
+ translationsPath?: string, // Default: 'window.trans.en'
120
+ migrationDate?: number, // Stripo migration timestamp
121
+ emailHeader?: {
122
+ senderName?: string,
123
+ subject?: string,
124
+ },
125
+ },
233
126
 
234
- | Property | Type | Default | Description |
235
- |----------|------|---------|-------------|
236
- | `value` | `string` | '' | Value of the dynamic content |
237
- | `text` | `string` | '' | Visible value of the dynamic content |
238
- | `fallback?` | `string` | '' | Fallback value of the dynamic content. Optional |
127
+ // Optional: UI settings
128
+ ui?: {
129
+ showHeader?: boolean, // Default: true
130
+ backButtonLabel?: string,
131
+ },
239
132
 
240
- ## 🧱 Blocks Configuration
133
+ // Optional: Feature toggles
134
+ features?: {
135
+ dynamicContent?: boolean, // Default: true
136
+ saveAsTemplate?: boolean, // Default: true
137
+ versionHistory?: boolean, // Default: true
138
+ testMessage?: boolean, // Default: true
139
+ displayConditions?: boolean, // Default: true
140
+ unsubscribe?: boolean, // Default: true
141
+ modulesDisabled?: boolean, // Default: false - Disable modules panel
142
+ },
241
143
 
242
- Guido allows you to customize which blocks are available in the editor. You can exclude default Stripo blocks and selectively include custom blocks to create tailored editing experiences for different product types.
144
+ // Optional: Block configuration
145
+ blocks?: {
146
+ excludeDefaults?: DefaultBlockType[],
147
+ includeCustoms?: CustomBlockType[],
148
+ },
243
149
 
244
- ### Block Types
150
+ // Optional: HTML compiler
151
+ compiler?: {
152
+ customRules?: CompilerRule[],
153
+ ignoreDefaultRules?: boolean, // Default: false
154
+ },
155
+ };
156
+ ```
245
157
 
246
- #### Default Blocks (GuidoBlockType)
158
+ ---
247
159
 
248
- These are the standard Stripo email editor blocks that can be excluded:
160
+ ## Events
249
161
 
250
- ```typescript
251
- type GuidoBlockType =
252
- | 'amp-accordion' // AMP accordion component
253
- | 'amp-carousel' // AMP image carousel
254
- | 'amp-form-controls' // AMP form elements
255
- | 'banner-block' // Banner/hero section
256
- | 'button-block' // Call-to-action buttons
257
- | 'html-block' // Custom HTML
258
- | 'image-block' // Image elements
259
- | 'menu-block' // Navigation menu
260
- | 'social-block' // Social media links
261
- | 'spacer-block' // Vertical spacing
262
- | 'text-block' // Text content
263
- | 'timer-block' // Countdown timer
264
- | 'video-block' // Video embeds
265
- ```
162
+ | Event | Payload | Description |
163
+ |-------|---------|-------------|
164
+ | `ready` | - | Editor is loaded and ready |
165
+ | `dynamic-content:open` | `DynamicContent \| null` | User wants to insert dynamic content |
166
+ | `back` | - | Back button clicked |
167
+ | `save:start` | - | Save process started |
168
+ | `save:complete` | `Template` | Save completed successfully |
169
+ | `on-change` | - | Template was modified |
170
+ | `test-email:click` | - | Test email button clicked |
171
+ | `onboarding-finished` | - | Onboarding popup dismissed |
266
172
 
267
- #### Custom Blocks (GuidoCustomBlockType)
173
+ ---
268
174
 
269
- These are custom blocks that can be selectively included:
175
+ ## Exposed Methods
270
176
 
271
177
  ```typescript
272
- type GuidoCustomBlockType =
273
- | 'dynamic-content' // Dynamic content merge tags
274
- | 'checkbox-block' // Checkbox form input
275
- | 'radio-button-block' // Radio button form input
276
- | 'recommendation-block' // Product recommendations
277
- | 'unsubscribe-block' // Unsubscribe link
278
- | 'coupon-block' // Coupon/promo code
279
- | 'items-block' // Cart items display
178
+ const guidoRef = ref<InstanceType<typeof Guido> | null>(null);
179
+
180
+ // Insert dynamic content
181
+ guidoRef.value?.dynamicContent.insert({
182
+ text: 'Display Name',
183
+ value: 'variable_name',
184
+ fallback: 'Default Value',
185
+ });
186
+
187
+ // Close dynamic content modal
188
+ guidoRef.value?.dynamicContent.close();
189
+
190
+ // Silent save (no UI feedback)
191
+ guidoRef.value?.saveSilent();
280
192
  ```
281
193
 
282
- ### Configuration Examples
194
+ ---
283
195
 
284
- #### Example 1: Exclude Specific Default Blocks
196
+ ## Block Configuration
285
197
 
286
- Disable button, image, and video blocks while keeping all custom blocks:
198
+ ### Default Blocks (can be excluded)
287
199
 
288
200
  ```typescript
289
- const guidoConfig = {
290
- translationsPath: 'window.trans.en',
291
- features: {
292
- dynamicContent: true,
293
- saveAsTemplate: true,
294
- versionHistory: true,
295
- testMessage: true
296
- },
297
- blocks: {
298
- excludeDefaults: ['button-block', 'image-block', 'video-block']
299
- }
300
- };
301
- ```
302
-
303
- **Result:**
304
- - Button, Image, Video blocks disabled
305
- - All other default blocks enabled
306
- - All custom blocks are disabled.
201
+ type DefaultBlockType =
202
+ | 'amp-accordion'
203
+ | 'amp-carousel'
204
+ | 'amp-form-controls'
205
+ | 'banner-block'
206
+ | 'button-block'
207
+ | 'html-block'
208
+ | 'image-block'
209
+ | 'menu-block'
210
+ | 'social-block'
211
+ | 'spacer-block'
212
+ | 'text-block'
213
+ | 'timer-block'
214
+ | 'video-block';
215
+ ```
216
+
217
+ ### Custom Blocks (opt-in)
307
218
 
308
- #### Example 2: Include Only Specific Custom Blocks
219
+ ```typescript
220
+ type CustomBlockType =
221
+ | 'dynamic-content'
222
+ | 'checkbox-block'
223
+ | 'radio-button-block'
224
+ | 'recommendation-block'
225
+ | 'unsubscribe-block'
226
+ | 'coupon-block'
227
+ | 'items-block';
228
+ ```
309
229
 
310
- Enable only coupon and recommendation blocks:
230
+ ### Examples
311
231
 
312
232
  ```typescript
313
- const guidoConfig = {
314
- translationsPath: 'window.trans.en',
315
- features: {
316
- dynamicContent: true,
317
- saveAsTemplate: true,
318
- versionHistory: true,
319
- testMessage: true
233
+ // Exclude specific default blocks
234
+ const config: GuidoConfigInput = {
235
+ identity: { templateId: 'tpl-123', userId: 'user-456' },
236
+ partner: { name: 'partner' },
237
+ blocks: {
238
+ excludeDefaults: ['timer-block', 'video-block'],
320
239
  },
240
+ };
241
+
242
+ // Include custom blocks
243
+ const config: GuidoConfigInput = {
244
+ identity: { templateId: 'tpl-123', userId: 'user-456' },
245
+ partner: { name: 'partner' },
321
246
  blocks: {
322
- includeCustoms: ['coupon-block', 'recommendation-block']
323
- }
247
+ includeCustoms: ['recommendation-block', 'coupon-block', 'dynamic-content'],
248
+ },
324
249
  };
325
250
  ```
326
251
 
327
- **Result:**
328
- - All default blocks enabled
329
- - Only Coupon and Recommendation extensions enabled.
330
- - Other custom blocks are disabled
252
+ ---
331
253
 
332
- ### Default Behavior
254
+ ## HTML Compiler Rules
333
255
 
334
- When `blocks` is not provided or is `undefined`:
256
+ Add custom rules to transform HTML during export:
335
257
 
336
258
  ```typescript
337
- const guidoConfig = {
338
- translationsPath: 'window.trans.en',
339
- features: {
340
- dynamicContent: true,
341
- saveAsTemplate: true,
342
- versionHistory: true,
343
- testMessage: true
259
+ const config: GuidoConfigInput = {
260
+ identity: { templateId: 'tpl-123', userId: 'user-456' },
261
+ partner: { name: 'partner' },
262
+ compiler: {
263
+ customRules: [
264
+ // Replace rule
265
+ {
266
+ id: 'replace-domain',
267
+ type: 'replace',
268
+ search: 'old-domain.com',
269
+ replacement: 'new-domain.com',
270
+ priority: 10,
271
+ },
272
+ // Regex rule
273
+ {
274
+ id: 'remove-comments',
275
+ type: 'regex',
276
+ pattern: '<!--.*?-->',
277
+ replacement: '',
278
+ flags: 'g',
279
+ priority: 20,
280
+ },
281
+ // Custom processor
282
+ {
283
+ id: 'add-tracking',
284
+ type: 'custom',
285
+ processor: (html) => html.replace('</body>', '<img src="track.gif"/></body>'),
286
+ priority: 30,
287
+ },
288
+ ],
289
+ ignoreDefaultRules: false, // Set true to skip built-in rules
344
290
  },
345
- // No blocks config
346
291
  };
347
292
  ```
348
293
 
349
- **Result:**
350
- - All 13 default Stripo blocks enabled
351
- - All custom blocks are disabled.
352
-
353
- ### Block Configuration Interface
354
-
355
- ```typescript
356
- interface BlocksConfig {
357
- excludeDefaults?: GuidoBlockType[];
358
- includeCustoms?: GuidoCustomBlockType[];
359
- }
360
- ```
361
-
362
- ### TypeScript Types
294
+ ---
363
295
 
364
- The library exports the following TypeScript types:
296
+ ## TypeScript Exports
365
297
 
366
298
  ```typescript
367
- // Main component
299
+ // Component
368
300
  import { Guido } from '@useinsider/guido';
369
301
 
370
302
  // Types
371
- import type { GuidoConfig } from '@useinsider/guido';
372
- import type { StripoEventType } from '@useinsider/guido';
303
+ import type {
304
+ GuidoConfig,
305
+ GuidoConfigInput,
306
+ IdentityConfig,
307
+ PartnerConfig,
308
+ TemplateConfig,
309
+ EditorConfig,
310
+ UIConfig,
311
+ FeaturesConfig,
312
+ BlocksConfig,
313
+ CompilerConfig,
314
+ DynamicContent,
315
+ DefaultBlockType,
316
+ CustomBlockType,
317
+ } from '@useinsider/guido';
318
+
319
+ // Utilities
320
+ import {
321
+ validateConfig,
322
+ parseConfig,
323
+ MessageType,
324
+ ProductType,
325
+ } from '@useinsider/guido';
326
+
327
+ // Styles
328
+ import '@useinsider/guido/style';
373
329
  ```
374
330
 
375
- ## 🔨 HTML Compiler Rules
376
-
377
- Guido includes a powerful HTML compiler system that allows you to transform HTML content with custom rules. You can define additional rules and optionally ignore the default rules.
378
-
379
- ### Rule Types
380
-
381
- There are 4 types of compiler rules:
331
+ ---
382
332
 
383
- #### 1. Replace Rule
384
- Replace specific strings in HTML content.
333
+ ## Constants
385
334
 
386
335
  ```typescript
387
- {
388
- id: 'fix-encoding',
389
- description: 'Fix URL encoding issues',
390
- type: 'replace',
391
- search: '{%22', // String to find
392
- replacement: '%7B%22', // String to replace with
393
- replaceAll: true, // Replace all occurrences (default: true)
394
- priority: 10 // Execution priority (lower = earlier)
395
- }
396
- ```
336
+ import { MessageType, ProductType } from '@useinsider/guido';
397
337
 
398
- #### 2. Regex Rule
399
- Use regular expressions for complex pattern matching and replacement.
338
+ MessageType.PROMOTIONAL // 1
339
+ MessageType.TRANSACTIONAL // 2
400
340
 
401
- ```typescript
402
- {
403
- id: 'remove-comments',
404
- description: 'Remove HTML comments',
405
- type: 'regex',
406
- pattern: '<!--.*?-->', // Regex pattern
407
- replacement: '', // Replacement string
408
- flags: 'g', // Regex flags (default: 'g')
409
- priority: 20
410
- }
341
+ ProductType.EMAIL // 60
342
+ ProductType.ARCHITECT // 49
343
+ ProductType.UNSUBSCRIBE_PAGES // 97
411
344
  ```
412
345
 
413
- #### 3. Remove Rule
414
- Remove specific strings or patterns from HTML content.
346
+ ---
415
347
 
416
- ```typescript
417
- {
418
- id: 'cleanup-scripts',
419
- description: 'Remove unwanted script tags',
420
- type: 'remove',
421
- targets: [ // Array of strings or RegExp objects
422
- '<script src="unwanted.js"></script>',
423
- /onclick="[^"]*"/g
424
- ],
425
- priority: 30
426
- }
427
- ```
348
+ ## Dynamic Content Modal
428
349
 
429
- #### 4. Custom Rule
430
- Define complex transformation logic with a custom processor function.
350
+ When the `dynamic-content:open` event fires, show your custom modal and call the insert method:
431
351
 
432
- ```typescript
433
- {
434
- id: 'add-meta-tags',
435
- description: 'Add custom meta tags to head',
436
- type: 'custom',
437
- processor: (html: string): string => {
438
- // Custom transformation logic
439
- const metaTags = '<meta name="custom" content="value">';
440
- return html.replace('</head>', `${metaTags}</head>`);
441
- },
442
- priority: 40
443
- }
444
- ```
352
+ ```vue
353
+ <template>
354
+ <Guido ref="guidoRef" :config="config" @dynamic-content:open="showModal = true" />
445
355
 
446
- ### Using HTML Compiler Rules
356
+ <!-- Your modal must have id="guido-dynamic-content-modal" -->
357
+ <YourModal v-if="showModal" id="guido-dynamic-content-modal" @select="insertContent" @close="closeModal" />
358
+ </template>
447
359
 
448
- #### Basic Usage with Custom Rules
360
+ <script setup>
361
+ const showModal = ref(false);
449
362
 
450
- ```typescript
451
- const guidoConfig = {
452
- translationsPath: 'window.trans.en',
453
- features: {
454
- dynamicContent: true,
455
- saveAsTemplate: true,
456
- versionHistory: false, // Disable version history
457
- testMessage: true
458
- },
459
- htmlCompilerRules: [
460
- {
461
- id: 'replace-domain',
462
- description: 'Replace old domain with new one',
463
- type: 'replace',
464
- search: 'old-domain.com',
465
- replacement: 'new-domain.com',
466
- replaceAll: true,
467
- priority: 10
468
- },
469
- {
470
- id: 'remove-tracking',
471
- description: 'Remove tracking pixels',
472
- type: 'regex',
473
- pattern: '<img[^>]*tracking[^>]*>',
474
- replacement: '',
475
- flags: 'gi',
476
- priority: 20
477
- }
478
- ]
363
+ const insertContent = (content) => {
364
+ guidoRef.value?.dynamicContent.insert({
365
+ text: content.label,
366
+ value: content.value,
367
+ fallback: content.fallback || '',
368
+ });
369
+ showModal.value = false;
479
370
  };
480
- ```
481
-
482
- #### Ignoring Default Rules
483
371
 
484
- ```typescript
485
- const guidoConfig = {
486
- translationsPath: 'window.trans.en',
487
- features: {
488
- dynamicContent: true,
489
- saveAsTemplate: true,
490
- versionHistory: true,
491
- testMessage: true
492
- },
493
- ignoreDefaultHtmlCompilerRules: true, // Skip all default rules
494
- htmlCompilerRules: [
495
- // Only your custom rules will be applied
496
- {
497
- id: 'custom-transformation',
498
- type: 'replace',
499
- search: 'old-text',
500
- replacement: 'new-text',
501
- priority: 1
502
- }
503
- ]
372
+ const closeModal = () => {
373
+ guidoRef.value?.dynamicContent.close();
374
+ showModal.value = false;
504
375
  };
505
- ```
506
-
507
- ### Rule Execution Order
508
-
509
- Rules are executed in priority order (lower numbers first). Rules with the same priority are executed in array order.
510
-
511
- - **Priority 1-99**: Reserved for critical transformations
512
- - **Priority 100-999**: Standard transformations
513
- - **Priority 1000+**: Additional custom rules (automatically assigned)
514
-
515
- ### Default Rules
516
-
517
- Guido includes several default rules for common email HTML optimizations:
518
-
519
- - **URL encoding fixes**: Fixes malformed URL encoding in dynamic content
520
- - **Template tag restoration**: Restores `{{}}` template tags that got URL encoded
521
- - **HTML entity decoding**: Converts `&lt;` and `&gt;` back to `<` and `>`
522
- - **Cleanup rules**: Removes unwanted iframe and style elements
523
- - **MSO conditions**: Manages Outlook-specific conditional comments
524
- - **Domain replacement**: Updates old image domains to current ones
525
-
526
- You can view all default rules in: `src/config/compiler/htmlCompilerRules.ts`
527
-
528
- ### CompilerRule Interface
529
-
530
- ```typescript
531
- type CompilerRuleType = 'replace' | 'regex' | 'remove' | 'custom';
532
-
533
- interface BaseCompilerRule {
534
- id: string;
535
- description?: string;
536
- priority: number;
537
- }
538
-
539
- interface ReplaceRule extends BaseCompilerRule {
540
- type: 'replace';
541
- search: string;
542
- replacement: string;
543
- replaceAll?: boolean; // Default: true
544
- }
545
-
546
- interface RegexRule extends BaseCompilerRule {
547
- type: 'regex';
548
- pattern: string;
549
- replacement: string;
550
- flags?: string; // Default: 'g'
551
- }
552
-
553
- interface RemoveRule extends BaseCompilerRule {
554
- type: 'remove';
555
- targets: (string | RegExp)[]; // Array of strings or RegExp objects
556
- }
557
-
558
- interface CustomRule extends BaseCompilerRule {
559
- type: 'custom';
560
- processor: (html: string) => string;
561
- }
562
-
563
- type CompilerRule = ReplaceRule | RegexRule | RemoveRule | CustomRule;
376
+ </script>
564
377
  ```
565
378
 
566
379
  ---
567
380
 
568
- ## 🔧 Development
569
-
570
- ### Prerequisites
571
-
572
- - 🧄 `Bun` (strongly recommended)
573
- or
574
- - NodeJS 18+ & `npm`
575
-
576
- ### Setup
381
+ ## Development
577
382
 
578
383
  ```bash
579
- # Install dependencies
384
+ # Install
580
385
  bun install
581
386
 
582
- # Start development server
387
+ # Start dev server
583
388
  bun start
584
389
 
585
- # Build for production
390
+ # Build
586
391
  bun run build
587
392
 
588
- # Type checking
589
- bun run type-check
590
-
591
- # Linting
393
+ # Lint & type-check
592
394
  bun run lint
593
395
  ```
594
396
 
595
397
  ### Environment Variables
596
398
 
597
- Create a `.env` file with the following variables: (You can get env variables from your senior)
598
-
599
399
  ```env
600
400
  VITE_STRIPO_PLUGIN_ID=your_plugin_id
601
401
  VITE_STRIPO_SECRET_KEY=your_secret_key
602
402
  VITE_STRIPO_ROLE=your_role
603
-
604
- # Playwright Test Configuration (Optional - for local debugging only)
605
- HEADED=false # Set to 'true' to run tests with visible browser
606
- ```
607
-
608
- ### Project Structure
609
-
610
- ```
611
- src/
612
- ├── components/ # Vue components
613
- ├── composables/ # Vue composables & business logic
614
- ├── services/ # API layer
615
- ├── stores/ # State management
616
- ├── @types/ # TypeScript definitions
617
- ├── static/ # Static assets & templates
618
- ├── utils/ # Utility functions
619
- ├── enums/ # Constants & enums
620
- ├── mock/ # Mock data for development
621
- ├── plugins/ # Vue plugins
622
- └── library.ts # Main export
623
- ```
624
-
625
- ## 🔌 Provide/Inject Utilities
626
-
627
- Guido includes type-safe utilities for Vue's provide/inject system to facilitate dependency injection between components.
628
-
629
- ### useProvideInject
630
-
631
- The `useProvideInject` composable provides two helper functions for type-safe dependency injection:
632
-
633
- #### Basic Usage
634
-
635
- ```typescript
636
- // Parent component
637
- import { provideValue } from '@useinsider/guido';
638
- import { InjectionKey } from 'vue';
639
-
640
- // Define a typed injection key
641
- const MyServiceKey: InjectionKey<MyService> = Symbol('MyService');
642
-
643
- // Provide the value
644
- const myService = new MyService();
645
- provideValue(MyServiceKey, myService);
646
-
647
- // Child component
648
- import { useInjectedValue } from '@useinsider/guido';
649
-
650
- // Inject the value with type safety
651
- const myService = useInjectedValue(MyServiceKey);
652
- ```
653
-
654
- #### With Default Value
655
-
656
- ```typescript
657
- // Inject with a fallback value
658
- const myService = useInjectedValue(MyServiceKey, new DefaultService());
659
403
  ```
660
404
 
661
- #### Error Handling
662
-
663
- The `useInjectedValue` function will throw a descriptive error if no provider is found and no default value is provided:
664
-
665
- ```typescript
666
- // This will throw an error if no provider exists
667
- try {
668
- const myService = useInjectedValue(MyServiceKey);
669
- } catch (error) {
670
- console.error('No provider found for MyService');
671
- }
672
- ```
673
-
674
- ### API Reference
675
-
676
- #### `provideValue`
677
-
678
- ```typescript
679
- provideValue<T>(key: InjectionKey<T>, value: T): void
680
- ```
681
-
682
- Provides a value using Vue's provide system with type safety.
683
-
684
- | Parameter | Type | Description |
685
- |-----------|------|-------------|
686
- | `key` | `InjectionKey<T>` | The typed injection key |
687
- | `value` | `T` | The value to provide |
688
-
689
- #### `useInjectedValue`
690
-
691
- ```typescript
692
- useInjectedValue<T>(key: InjectionKey<T>, defaultValue?: T): T
693
- ```
694
-
695
- Injects a value using Vue's inject system with type safety and error handling.
696
-
697
- | Parameter | Type | Required | Description |
698
- |-----------|------|----------|-------------|
699
- | `key` | `InjectionKey<T>` | ✅ | The typed injection key |
700
- | `defaultValue` | `T` | ⚪ | Optional fallback value |
701
-
702
- **Returns:** `T` - The injected value
703
-
704
- **Throws:** `Error` - When no provider is found and no default value is provided
705
-
706
- ## 🌐 i18n
707
- Before running the project, it sends to request to inone.useinsider.com/translations and writes the JSON file into - [trans.json](src/mock/responses/trans.json).
708
- It allows to use production or local translations on your code. 🚀
709
- Example usage:
710
- ```js
711
- import { useTranslations } from '@@/Composables/useTranslations';
712
-
713
- const trans = useTranslations();
714
-
715
- // use everywhere like this:
716
- trans('foo.bar')
717
- ```
405
+ ---
718
406
 
719
- ## 📦 Local Building (Recommended)
407
+ ## Local Testing
720
408
 
721
- Run this commands if you want to test the package on your local before sending to NPM.
722
- ```sh
409
+ ```bash
410
+ # Build the package
723
411
  bun run build
724
- ```
725
412
 
726
- Since bun does not have packaging yet, use npm here: 🥲
727
- ```sh
413
+ # Create tarball
728
414
  npm pack
729
- ```
730
-
731
- It'll crate like `useinsider-guido-1.0.0.tgz` file.
732
415
 
733
- Move this file to your project path like: `email-fe` via:
734
- ```sh
735
- cp useinsider-guido-1.0.0.tgz ../email-fe
416
+ # Install in your project
417
+ cd ../your-project
418
+ npm install ../guido/useinsider-guido-1.0.0.tgz
736
419
  ```
737
420
 
738
- Install the file to your project:
739
- ```sh
740
- npm i ./useinsider-guido-1.0.0.tgz
741
- ```
742
-
743
- Then you just need to rebuild to your project or restart the Container. 🎉
744
-
745
- For Future, we can create a shell script for it. Feel free to help 🙃
746
-
747
- ## 📦 Build Output
748
-
749
- The library builds to multiple formats:
750
-
751
- - **ES Module**: `dist/library.js` (recommended)
752
- - **CSS**: `dist/guido.css` (custom styles)
753
-
754
- ### Package Exports
755
-
756
- ```json
757
- {
758
- "exports": {
759
- ".": {
760
- "import": "./dist/library.js",
761
- "types": "./dist/components/Guido.vue.d.ts",
762
- "require": "./dist/components/Guido.vue.js"
763
- },
764
- "./style": "./dist/guido.css"
765
- }
766
- }
767
- ```
768
-
769
- ## 🤝 Contributing
770
- - PR Titles should be structured like `TASK-ID | 🔥 | Some Clear Task Descriptions`
771
- - PR Labels should be filled.
772
- - PR Assignee required.
773
- - Tests should be covered.
774
- - All required checks should be passed before sending review request.
775
-
776
- ## 📄 License
777
-
778
- ISC License
779
-
780
421
  ---
781
422
 
782
- ## 🔗 Related
423
+ ## License
783
424
 
784
- - [Stripo Email Editor](https://stripo.email/) - The underlying email editor
785
- - [@useinsider/design-system-vue](https://github.com/useinsider/design-system-vue) - Insider's Vue design system
786
-
787
- ## 🎯 TODO:
788
- - CSS part should be optimized with variables & `sass-loader`.
789
- - Master Version Generator should be fixed.
790
- - Playwright integrationBoilerplate/control.ts
791
- - Commitlint & Precommit Hooks integration
792
- - Get Pre-built display conditions from API
425
+ ISC License