@incodetech/web 2.0.0-alpha.1 → 2.0.0-alpha.11

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 (209) hide show
  1. package/dist/base.css +1071 -0
  2. package/dist/browser-ponyfill-B6W6hHVY.js +344 -0
  3. package/dist/email/email.es.js +145 -0
  4. package/dist/email/styles.css +123 -0
  5. package/dist/flow/flow.es.js +555 -0
  6. package/dist/flow/styles.css +1119 -0
  7. package/dist/incodeModule-Dv8Qllrv.js +254 -0
  8. package/dist/index.es.js +6 -0
  9. package/dist/instance-B-q0ZREN.js +2140 -0
  10. package/dist/otpInput-BtoZe0Wz.js +151 -0
  11. package/dist/page-Dh_Zw2ik.js +234 -0
  12. package/dist/phone/phone.es.js +3441 -0
  13. package/dist/phone/styles.css +305 -0
  14. package/dist/selfie/selfie.es.js +893 -0
  15. package/dist/selfie/styles.css +590 -0
  16. package/dist/selfieTutorial-C-u5GufD.js +29 -0
  17. package/dist/setup-wNL83jmW.js +20 -0
  18. package/dist/themes/dark.css +652 -0
  19. package/dist/themes/light.css +543 -0
  20. package/dist/title-BfO5Dlzk.js +25 -0
  21. package/dist/types/base.d.ts +1 -0
  22. package/dist/types/dark.d.ts +1 -0
  23. package/dist/types/email.d.ts +57 -0
  24. package/dist/types/flow.d.ts +69 -0
  25. package/dist/types/index.d.ts +38 -0
  26. package/dist/types/light.d.ts +1 -0
  27. package/dist/types/phone.d.ts +58 -0
  28. package/dist/types/selfie.d.ts +31 -0
  29. package/dist/types/styles.d.ts +1 -0
  30. package/dist/types/themes/dark.d.ts +1 -0
  31. package/dist/types/themes/light.d.ts +1 -0
  32. package/dist/uiConfig-CQ1W9cUD.js +23 -0
  33. package/dist/vendor-preact-CK0WeTOR.js +584 -0
  34. package/package.json +32 -26
  35. package/dev/README.md +0 -163
  36. package/dev/getToken.ts +0 -36
  37. package/dev/headless.html +0 -875
  38. package/dev/index.html +0 -366
  39. package/dev/main-headless.tsx +0 -1332
  40. package/dev/main-orchestrated-flow.tsx +0 -1158
  41. package/dev/main-preact.tsx +0 -323
  42. package/dev/main-simplified.tsx +0 -123
  43. package/dev/main-web-component.tsx +0 -256
  44. package/dev/main.tsx +0 -332
  45. package/dev/manual.html +0 -27
  46. package/dev/orchestrated-flow.html +0 -64
  47. package/dev/simplified.html +0 -64
  48. package/dev/tiktok-logo.svg +0 -7
  49. package/src/defineCustomElement.tsx +0 -30
  50. package/src/email/email.test.tsx +0 -368
  51. package/src/email/email.tsx +0 -255
  52. package/src/email/emailInput.test.tsx +0 -264
  53. package/src/email/emailInput.tsx +0 -85
  54. package/src/email/styles.css +0 -59
  55. package/src/flow/flow.test.tsx +0 -796
  56. package/src/flow/flow.tsx +0 -292
  57. package/src/flow/flowCompleted.css +0 -30
  58. package/src/flow/flowCompleted.test.tsx +0 -331
  59. package/src/flow/flowCompleted.tsx +0 -121
  60. package/src/flow/flowInit.test.ts +0 -264
  61. package/src/flow/flowInit.ts +0 -94
  62. package/src/flow/flowStart.css +0 -58
  63. package/src/flow/flowStart.test.tsx +0 -49
  64. package/src/flow/flowStart.tsx +0 -41
  65. package/src/flow/incode-logo.svg +0 -8
  66. package/src/flow/index.ts +0 -7
  67. package/src/flow/preloadFlow.test.ts +0 -421
  68. package/src/flow/preloadFlow.ts +0 -171
  69. package/src/flow/styles.css +0 -9
  70. package/src/flow/unsupportedModule.css +0 -21
  71. package/src/flow/unsupportedModule.tsx +0 -39
  72. package/src/flow/useFlowInitialization.test.tsx +0 -292
  73. package/src/flow/useFlowInitialization.ts +0 -128
  74. package/src/flow/useModuleLoader.test.tsx +0 -212
  75. package/src/flow/useModuleLoader.ts +0 -92
  76. package/src/hooks/index.ts +0 -1
  77. package/src/hooks/useManager.test.ts +0 -91
  78. package/src/hooks/useManager.ts +0 -40
  79. package/src/i18n/index.ts +0 -3
  80. package/src/i18n/instance.ts +0 -16
  81. package/src/i18n/setup.ts +0 -184
  82. package/src/i18n/useTranslation.ts +0 -42
  83. package/src/index.ts +0 -27
  84. package/src/permissions/assets/android-dots-icon.svg +0 -7
  85. package/src/permissions/assets/android-settings-icon.svg +0 -16
  86. package/src/permissions/assets/android-toggle-icon.svg +0 -20
  87. package/src/permissions/assets/bank-card-icon.svg +0 -14
  88. package/src/permissions/assets/camera-icon.svg +0 -12
  89. package/src/permissions/assets/camera-ios.svg +0 -53
  90. package/src/permissions/assets/check-icon.svg +0 -8
  91. package/src/permissions/assets/chrome-icon.svg +0 -43
  92. package/src/permissions/assets/password-icon.svg +0 -11
  93. package/src/permissions/assets/permissions-img.svg +0 -51
  94. package/src/permissions/assets/safari-icon.svg +0 -37
  95. package/src/permissions/assets/settings-icon.svg +0 -33
  96. package/src/permissions/assets/toggle-icon.svg +0 -19
  97. package/src/permissions/assets/warning-icon.svg +0 -6
  98. package/src/permissions/boldWithArrow.css +0 -9
  99. package/src/permissions/boldWithArrow.tsx +0 -41
  100. package/src/permissions/denied.css +0 -37
  101. package/src/permissions/denied.tsx +0 -29
  102. package/src/permissions/deniedAndroid.tsx +0 -56
  103. package/src/permissions/deniedDesktop.css +0 -9
  104. package/src/permissions/deniedDesktop.tsx +0 -64
  105. package/src/permissions/deniedIOS.tsx +0 -73
  106. package/src/permissions/deniedInstructions.tsx +0 -19
  107. package/src/permissions/iconWrapper.css +0 -9
  108. package/src/permissions/iconWrapper.tsx +0 -15
  109. package/src/permissions/learnMore.css +0 -37
  110. package/src/permissions/learnMore.tsx +0 -85
  111. package/src/permissions/numberedStep.css +0 -13
  112. package/src/permissions/numberedStep.tsx +0 -14
  113. package/src/permissions/permissions.css +0 -13
  114. package/src/permissions/permissions.tsx +0 -68
  115. package/src/phone/phone.tsx +0 -246
  116. package/src/phone/phoneInput.test.tsx +0 -275
  117. package/src/phone/phoneInput.tsx +0 -249
  118. package/src/phone/styles.css +0 -158
  119. package/src/selfie/cameraButton.css +0 -13
  120. package/src/selfie/cameraButton.tsx +0 -35
  121. package/src/selfie/capture.css +0 -57
  122. package/src/selfie/capture.tsx +0 -232
  123. package/src/selfie/errorModal.tsx +0 -218
  124. package/src/selfie/errorModalContent.css +0 -33
  125. package/src/selfie/errorModalContent.tsx +0 -44
  126. package/src/selfie/faceOutline.css +0 -5
  127. package/src/selfie/faceOutline.tsx +0 -22
  128. package/src/selfie/loadingBorder.css +0 -12
  129. package/src/selfie/loadingBorder.tsx +0 -77
  130. package/src/selfie/manualCaptureButton.css +0 -13
  131. package/src/selfie/manualCaptureButton.tsx +0 -35
  132. package/src/selfie/noMoreAttemptsModal.tsx +0 -44
  133. package/src/selfie/notification.css +0 -9
  134. package/src/selfie/notification.tsx +0 -36
  135. package/src/selfie/retryErrorModal.tsx +0 -56
  136. package/src/selfie/selfie.test.tsx +0 -458
  137. package/src/selfie/selfie.tsx +0 -83
  138. package/src/selfie/selfieTutorial.json +0 -2626
  139. package/src/selfie/styles.css +0 -1
  140. package/src/selfie/tutorial.test.tsx +0 -200
  141. package/src/selfie/tutorial.tsx +0 -43
  142. package/src/setup.ts +0 -33
  143. package/src/shared/baseTutorial/baseTutorial.css +0 -21
  144. package/src/shared/baseTutorial/baseTutorial.test.tsx +0 -184
  145. package/src/shared/baseTutorial/baseTutorial.tsx +0 -55
  146. package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +0 -267
  147. package/src/shared/baseTutorial/replaceBaseTutorial.ts +0 -68
  148. package/src/shared/button/button.css +0 -55
  149. package/src/shared/button/button.test.tsx +0 -101
  150. package/src/shared/button/button.tsx +0 -47
  151. package/src/shared/componentRoot/incodeComponent.tsx +0 -12
  152. package/src/shared/countries/countries.test.ts +0 -75
  153. package/src/shared/countries/countries.ts +0 -139
  154. package/src/shared/countries/index.ts +0 -6
  155. package/src/shared/icons/chevronDown.tsx +0 -22
  156. package/src/shared/icons/index.ts +0 -2
  157. package/src/shared/icons/successIcon.css +0 -5
  158. package/src/shared/icons/successIcon.test.tsx +0 -40
  159. package/src/shared/icons/successIcon.tsx +0 -26
  160. package/src/shared/loader/loadingIcon.css +0 -28
  161. package/src/shared/loader/loadingIcon.tsx +0 -67
  162. package/src/shared/lottie/lottie.tsx +0 -108
  163. package/src/shared/otpInput/otpInput.css +0 -85
  164. package/src/shared/otpInput/otpInput.test.tsx +0 -356
  165. package/src/shared/otpInput/otpInput.tsx +0 -241
  166. package/src/shared/page/incode-logo.svg +0 -3
  167. package/src/shared/page/page.css +0 -47
  168. package/src/shared/page/page.test.tsx +0 -97
  169. package/src/shared/page/page.tsx +0 -91
  170. package/src/shared/page/pageUiConfig.test.ts +0 -112
  171. package/src/shared/page/pageUiConfig.ts +0 -64
  172. package/src/shared/page/verifiedByIncode.css +0 -5
  173. package/src/shared/page/verifiedByIncode.tsx +0 -75
  174. package/src/shared/spacer/spacer.css +0 -149
  175. package/src/shared/spacer/spacer.test.tsx +0 -143
  176. package/src/shared/spacer/spacer.tsx +0 -88
  177. package/src/shared/spinner/index.ts +0 -2
  178. package/src/shared/spinner/spinner.css +0 -28
  179. package/src/shared/spinner/spinner.test.tsx +0 -82
  180. package/src/shared/spinner/spinner.tsx +0 -65
  181. package/src/shared/title/title.css +0 -7
  182. package/src/shared/title/title.tsx +0 -12
  183. package/src/shared/uiConfig/uiConfig.ts +0 -36
  184. package/src/shared/webComponent/incodeModule.ts +0 -29
  185. package/src/shared/webComponent/registerIncodeElement.ts +0 -15
  186. package/src/styles/__mocks__/fetchTheme.ts +0 -19
  187. package/src/styles/applyTheme.ts +0 -37
  188. package/src/styles/cn.test.tsx +0 -57
  189. package/src/styles/cn.tsx +0 -21
  190. package/src/styles/core.css +0 -12
  191. package/src/styles/fetchTheme.test.ts +0 -390
  192. package/src/styles/fetchTheme.ts +0 -88
  193. package/src/styles/generatePalette.ts +0 -111
  194. package/src/styles/reset.css +0 -65
  195. package/src/styles/resolveCssVariableToHex.ts +0 -28
  196. package/src/styles/tailwind.css +0 -291
  197. package/src/styles/themeTypes.ts +0 -18
  198. package/src/styles/tokens/colors.css +0 -190
  199. package/src/styles/tokens/components.css +0 -174
  200. package/src/styles/tokens/index.css +0 -4
  201. package/src/styles/tokens/primitives.css +0 -129
  202. package/src/styles/tokens/semantic.css +0 -51
  203. package/src/svg.d.ts +0 -4
  204. package/src/types/assets.d.ts +0 -1
  205. package/src/types/custom-elements.d.ts +0 -104
  206. package/tsconfig.json +0 -22
  207. package/vite.config.ts +0 -260
  208. package/vitest.config.ts +0 -40
  209. package/vitest.setup.ts +0 -16
@@ -1,267 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
- import { getCssVariableAsHex, replaceLottieColor } from './replaceBaseTutorial';
3
-
4
- describe('getCssVariableAsHex', () => {
5
- beforeEach(() => {
6
- document.documentElement.style.setProperty('--test-color', '#ff0000');
7
- document.documentElement.style.setProperty('--test-rgb', 'rgb(0, 255, 0)');
8
- document.documentElement.style.setProperty(
9
- '--test-rgba',
10
- 'rgba(0, 0, 255, 0.5)',
11
- );
12
- document.documentElement.style.setProperty('--test-empty', '');
13
- });
14
-
15
- afterEach(() => {
16
- document.documentElement.style.removeProperty('--test-color');
17
- document.documentElement.style.removeProperty('--test-rgb');
18
- document.documentElement.style.removeProperty('--test-rgba');
19
- document.documentElement.style.removeProperty('--test-empty');
20
- });
21
-
22
- it('returns hex value when CSS variable is hex', () => {
23
- const result = getCssVariableAsHex('--test-color');
24
- expect(result).toBe('#ff0000');
25
- });
26
-
27
- it('returns hex value when CSS variable is rgb', () => {
28
- const result = getCssVariableAsHex('--test-rgb');
29
- expect(result).toBe('#00ff00');
30
- });
31
-
32
- it('returns hex value when CSS variable is rgba', () => {
33
- const result = getCssVariableAsHex('--test-rgba');
34
- expect(result).toBe('#0000ff');
35
- });
36
-
37
- it('returns null when CSS variable does not exist', () => {
38
- const result = getCssVariableAsHex('--non-existent');
39
- expect(result).toBeNull();
40
- });
41
-
42
- it('returns null when CSS variable is empty', () => {
43
- const result = getCssVariableAsHex('--test-empty');
44
- expect(result).toBeNull();
45
- });
46
-
47
- it('uses provided element instead of documentElement', () => {
48
- const element = document.createElement('div');
49
- element.style.setProperty('--custom-color', '#abcdef');
50
- document.body.appendChild(element);
51
-
52
- const result = getCssVariableAsHex('--custom-color', element);
53
- expect(result).toBe('#abcdef');
54
-
55
- document.body.removeChild(element);
56
- });
57
-
58
- it('returns null when document is not available', () => {
59
- const originalDocument = global.document;
60
- Object.defineProperty(global, 'document', {
61
- value: undefined,
62
- writable: true,
63
- configurable: true,
64
- });
65
-
66
- const result = getCssVariableAsHex('--test-color');
67
-
68
- Object.defineProperty(global, 'document', {
69
- value: originalDocument,
70
- writable: true,
71
- configurable: true,
72
- });
73
-
74
- expect(result).toBeNull();
75
- });
76
-
77
- it('handles rgb with spaces', () => {
78
- document.documentElement.style.setProperty(
79
- '--test-spaced-rgb',
80
- 'rgb( 100 , 200 , 50 )',
81
- );
82
- const result = getCssVariableAsHex('--test-spaced-rgb');
83
- expect(result).toBe('#64c832');
84
- document.documentElement.style.removeProperty('--test-spaced-rgb');
85
- });
86
-
87
- it('returns null for invalid rgb format', () => {
88
- document.documentElement.style.setProperty(
89
- '--test-invalid',
90
- 'rgb(invalid)',
91
- );
92
- const result = getCssVariableAsHex('--test-invalid');
93
- expect(result).toBeNull();
94
- document.documentElement.style.removeProperty('--test-invalid');
95
- });
96
-
97
- it('returns null when rgb has less than 3 numbers', () => {
98
- document.documentElement.style.setProperty(
99
- '--test-rgb-short',
100
- 'rgb(100, 200)',
101
- );
102
- const result = getCssVariableAsHex('--test-rgb-short');
103
- expect(result).toBeNull();
104
- document.documentElement.style.removeProperty('--test-rgb-short');
105
- });
106
-
107
- it('returns null when rgb has no numbers', () => {
108
- document.documentElement.style.setProperty(
109
- '--test-rgb-no-numbers',
110
- 'rgb(abc, def, ghi)',
111
- );
112
- const result = getCssVariableAsHex('--test-rgb-no-numbers');
113
- expect(result).toBeNull();
114
- document.documentElement.style.removeProperty('--test-rgb-no-numbers');
115
- });
116
-
117
- it('handles rgba format', () => {
118
- document.documentElement.style.setProperty(
119
- '--test-rgba-full',
120
- 'rgba(255, 0, 0, 1)',
121
- );
122
- const result = getCssVariableAsHex('--test-rgba-full');
123
- expect(result).toBe('#ff0000');
124
- document.documentElement.style.removeProperty('--test-rgba-full');
125
- });
126
-
127
- it('returns null when CSS variable value is not hex or rgb', () => {
128
- document.documentElement.style.setProperty('--test-named-color', 'blue');
129
- const result = getCssVariableAsHex('--test-named-color');
130
- expect(result).toBeNull();
131
- document.documentElement.style.removeProperty('--test-named-color');
132
- });
133
- });
134
-
135
- describe('replaceLottieColor', () => {
136
- it('replaces replaceColorWithYours with hex color', () => {
137
- const lottieJson = {
138
- layers: [
139
- {
140
- shapes: [
141
- {
142
- it: [
143
- {
144
- c: {
145
- k: ['replaceColorWithYours'],
146
- },
147
- },
148
- ],
149
- },
150
- ],
151
- },
152
- ],
153
- };
154
-
155
- const result = replaceLottieColor(
156
- lottieJson,
157
- '#ff0000',
158
- ) as typeof lottieJson;
159
- const jsonString = JSON.stringify(result);
160
- expect(jsonString).toContain('[1,0,0,1]');
161
- expect(jsonString).not.toContain('replaceColorWithYours');
162
- });
163
-
164
- it('replaces replaceR, replaceG, replaceB with color values', () => {
165
- const lottieJson = {
166
- test: {
167
- k: [0, 'replaceR', 'replaceG', 'replaceB', 1],
168
- },
169
- };
170
-
171
- const result = replaceLottieColor(
172
- lottieJson,
173
- '#00ff00',
174
- ) as typeof lottieJson;
175
- const jsonString = JSON.stringify(result);
176
- expect(jsonString).toContain('0');
177
- expect(jsonString).toContain('1');
178
- expect(jsonString).not.toContain('replaceR');
179
- expect(jsonString).not.toContain('replaceG');
180
- expect(jsonString).not.toContain('replaceB');
181
- const parsed = JSON.parse(jsonString);
182
- expect(parsed.test.k).toEqual([0, 0, 1, 0, 1]);
183
- });
184
-
185
- it('returns original json when hex color is invalid', () => {
186
- const lottieJson = { test: 'value' };
187
- const result = replaceLottieColor(lottieJson, 'invalid');
188
- expect(result).toEqual(lottieJson);
189
- });
190
-
191
- it('handles short hex color', () => {
192
- const lottieJson = {
193
- color: ['replaceColorWithYours'],
194
- };
195
-
196
- const result = replaceLottieColor(lottieJson, '#f00') as typeof lottieJson;
197
- const jsonString = JSON.stringify(result);
198
- expect(jsonString).toContain('[1,0,0,1]');
199
- });
200
-
201
- it('handles hex color without #', () => {
202
- const lottieJson = {
203
- color: ['replaceColorWithYours'],
204
- };
205
-
206
- const result = replaceLottieColor(
207
- lottieJson,
208
- '00ff00',
209
- ) as typeof lottieJson;
210
- const jsonString = JSON.stringify(result);
211
- expect(jsonString).toContain('[0,1,0,1]');
212
- });
213
-
214
- it('handles complex nested structure', () => {
215
- const lottieJson = {
216
- v: '5.5.7',
217
- fr: 30,
218
- ip: 0,
219
- op: 60,
220
- w: 100,
221
- h: 100,
222
- layers: [
223
- {
224
- shapes: [
225
- {
226
- it: [
227
- {
228
- c: {
229
- k: ['replaceColorWithYours'],
230
- },
231
- },
232
- ],
233
- },
234
- ],
235
- },
236
- ],
237
- meta: {
238
- k: [0, 'replaceR', 'replaceG', 'replaceB', 1],
239
- },
240
- };
241
-
242
- const result = replaceLottieColor(
243
- lottieJson,
244
- '#123456',
245
- ) as typeof lottieJson;
246
- const jsonString = JSON.stringify(result);
247
- expect(jsonString).not.toContain('replaceColorWithYours');
248
- expect(jsonString).not.toContain('replaceR');
249
- expect(jsonString).not.toContain('replaceG');
250
- expect(jsonString).not.toContain('replaceB');
251
- const parsed = JSON.parse(jsonString);
252
- const colorArray = parsed.layers[0].shapes[0].it[0].c.k;
253
- expect(colorArray).toHaveLength(4);
254
- expect(colorArray[0]).toBeCloseTo(0.07058823529411765, 10);
255
- expect(colorArray[1]).toBeCloseTo(0.20392156862745098, 10);
256
- expect(colorArray[2]).toBeCloseTo(0.33725490196078434, 10);
257
- expect(colorArray[3]).toBe(1);
258
-
259
- const metaArray = parsed.meta.k;
260
- expect(metaArray).toHaveLength(5);
261
- expect(metaArray[0]).toBe(0);
262
- expect(metaArray[1]).toBeCloseTo(0.07058823529411765, 10);
263
- expect(metaArray[2]).toBeCloseTo(0.20392156862745098, 10);
264
- expect(metaArray[3]).toBeCloseTo(0.33725490196078434, 10);
265
- expect(metaArray[4]).toBe(1);
266
- });
267
- });
@@ -1,68 +0,0 @@
1
- const hexToRgb = (hex: string) => {
2
- let normalizedHex = hex.replace('#', '');
3
- if (normalizedHex.length === 3) {
4
- normalizedHex = normalizedHex
5
- .split('')
6
- .map((char) => char + char)
7
- .join('');
8
- }
9
- const result = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(normalizedHex);
10
- return result?.[1] && result?.[2] && result?.[3]
11
- ? {
12
- r: Number.parseInt(result[1], 16) / 255,
13
- g: Number.parseInt(result[2], 16) / 255,
14
- b: Number.parseInt(result[3], 16) / 255,
15
- }
16
- : null;
17
- };
18
-
19
- const rgbToHex = (r: number, g: number, b: number) => {
20
- const toHex = (n: number) => {
21
- const hex = Math.round(n * 255).toString(16);
22
- return hex.length === 1 ? `0${hex}` : hex;
23
- };
24
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
25
- };
26
-
27
- export function getCssVariableAsHex(
28
- cssVar: string,
29
- element?: HTMLElement,
30
- ): string | null {
31
- const el =
32
- element ||
33
- (typeof document !== 'undefined' ? document.documentElement : null);
34
- if (!el) return null;
35
-
36
- const computedValue = getComputedStyle(el).getPropertyValue(cssVar).trim();
37
- if (!computedValue) return null;
38
-
39
- if (computedValue.startsWith('#')) {
40
- return computedValue;
41
- }
42
-
43
- if (computedValue.startsWith('rgb')) {
44
- const rgbMatch = computedValue.match(/\d+/g);
45
- if (rgbMatch && rgbMatch.length >= 3) {
46
- const r = Number.parseInt(rgbMatch[0], 10) / 255;
47
- const g = Number.parseInt(rgbMatch[1], 10) / 255;
48
- const b = Number.parseInt(rgbMatch[2], 10) / 255;
49
- return rgbToHex(r, g, b);
50
- }
51
- }
52
-
53
- return null;
54
- }
55
-
56
- export function replaceLottieColor(lottieJson: unknown, newColor: string) {
57
- const newColorRgba = hexToRgb(newColor);
58
- if (!newColorRgba) return lottieJson;
59
- const lottieColor = [newColorRgba.r, newColorRgba.g, newColorRgba.b, 1];
60
-
61
- return JSON.parse(
62
- JSON.stringify(lottieJson)
63
- .replace(/"replaceColorWithYours"/g, lottieColor.join(', '))
64
- .replace(/"replaceR"/g, newColorRgba.r.toString())
65
- .replace(/"replaceG"/g, newColorRgba.g.toString())
66
- .replace(/"replaceB"/g, newColorRgba.b.toString()),
67
- );
68
- }
@@ -1,55 +0,0 @@
1
- @reference "../../styles/tailwind.css";
2
-
3
- .IncodeButton {
4
- @apply block w-full rounded-button-primary text-center max-w-[420px] mx-auto;
5
- @apply transition-colors duration-200;
6
-
7
- &.IncodeButtonPrimary {
8
- @apply bg-button-primary-surface-default text-button-primary-text-default;
9
- @apply text-18 font-medium py-[18px] px-32;
10
- @apply border-[1.5px] border-button-primary-border-default;
11
-
12
- &:active {
13
- @apply bg-button-primary-surface-pressed;
14
- }
15
-
16
- &:not(.IncodeButtonLoading):disabled {
17
- @apply bg-button-primary-surface-disabled text-button-primary-text-disabled;
18
- @apply border border-button-primary-border-disabled cursor-not-allowed;
19
- }
20
-
21
- &.IncodeButtonLoading {
22
- @apply p-0 min-h-[56px] flex justify-center items-center;
23
- @apply cursor-not-allowed pointer-events-none;
24
-
25
- .IncodeLoadingIconPrimaryIcon {
26
- fill: var(--button-primary-text-default);
27
- }
28
-
29
- .IncodeLoadingIconSecondaryIcon {
30
- fill: var(--surface-brand-400-static);
31
- }
32
- }
33
- }
34
- &.IncodeButtonLink {
35
- @apply bg-transparent text-button-primary-surface-default underline;
36
- @apply text-16 font-normal border-none;
37
- @apply w-full h-[56px];
38
-
39
- &:disabled {
40
- @apply opacity-50 cursor-not-allowed;
41
- }
42
-
43
- &.IncodeButtonLoading {
44
- @apply cursor-not-allowed pointer-events-none;
45
-
46
- .IncodeLoadingIconPrimaryIcon {
47
- fill: var(--button-primary-surface-default);
48
- }
49
-
50
- .IncodeLoadingIconSecondaryIcon {
51
- fill: var(--surface-brand-400-static);
52
- }
53
- }
54
- }
55
- }
@@ -1,101 +0,0 @@
1
- import { render, screen } from '@testing-library/preact';
2
- import { describe, expect, it, vi } from 'vitest';
3
- import { Button } from './button';
4
-
5
- describe('Button', () => {
6
- it('renders children correctly', () => {
7
- render(<Button>Click me</Button>);
8
- expect(screen.getByText('Click me')).toBeTruthy();
9
- });
10
-
11
- it('renders with default variant', () => {
12
- const { container } = render(<Button>Test</Button>);
13
- const button = container.querySelector('button');
14
- expect(button?.classList.contains('IncodeButtonPrimary')).toBe(true);
15
- });
16
-
17
- it('renders with link variant', () => {
18
- const { container } = render(<Button variant="link">Link</Button>);
19
- const button = container.querySelector('button');
20
- expect(button?.classList.contains('IncodeButtonLink')).toBe(true);
21
- });
22
-
23
- it('shows loading icon when isLoading is true', () => {
24
- render(<Button isLoading>Test</Button>);
25
- const button = screen.getByRole('button');
26
- expect(button.classList.contains('IncodeButtonLoading')).toBe(true);
27
- expect(button.querySelector('.IncodeLoadingIcon')).toBeTruthy();
28
- });
29
-
30
- it('hides children when loading', () => {
31
- render(<Button isLoading>Should not see this</Button>);
32
- expect(screen.queryByText('Should not see this')).toBeNull();
33
- });
34
-
35
- it('is disabled when isLoading is true', () => {
36
- render(<Button isLoading>Test</Button>);
37
- const button = screen.getByRole('button');
38
- expect(button.hasAttribute('disabled')).toBe(true);
39
- });
40
-
41
- it('is disabled when disabled prop is true', () => {
42
- render(<Button disabled>Test</Button>);
43
- const button = screen.getByRole('button');
44
- expect(button.hasAttribute('disabled')).toBe(true);
45
- });
46
-
47
- it('calls onClick handler when clicked', () => {
48
- const handleClick = vi.fn();
49
- render(<Button onClick={handleClick}>Click me</Button>);
50
- const button = screen.getByRole('button');
51
- button.click();
52
- expect(handleClick).toHaveBeenCalledTimes(1);
53
- });
54
-
55
- it('does not call onClick when disabled', () => {
56
- const handleClick = vi.fn();
57
- render(
58
- <Button onClick={handleClick} disabled>
59
- Click me
60
- </Button>,
61
- );
62
- const button = screen.getByRole('button');
63
- button.click();
64
- expect(handleClick).not.toHaveBeenCalled();
65
- });
66
-
67
- it('does not call onClick when loading', () => {
68
- const handleClick = vi.fn();
69
- render(
70
- <Button onClick={handleClick} isLoading>
71
- Click me
72
- </Button>,
73
- );
74
- const button = screen.getByRole('button');
75
- button.click();
76
- expect(handleClick).not.toHaveBeenCalled();
77
- });
78
-
79
- it('renders with custom class', () => {
80
- const { container } = render(<Button class="custom-class">Test</Button>);
81
- const button = container.querySelector('button');
82
- expect(button?.classList.contains('custom-class')).toBe(true);
83
- });
84
-
85
- it('renders with data-testid', () => {
86
- render(<Button data-testid="test-button">Test</Button>);
87
- expect(screen.getByTestId('test-button')).toBeTruthy();
88
- });
89
-
90
- it('renders with default type button', () => {
91
- render(<Button>Test</Button>);
92
- const button = screen.getByRole('button');
93
- expect(button.getAttribute('type')).toBe('button');
94
- });
95
-
96
- it('renders with submit type', () => {
97
- render(<Button type="submit">Submit</Button>);
98
- const button = screen.getByRole('button');
99
- expect(button.getAttribute('type')).toBe('submit');
100
- });
101
- });
@@ -1,47 +0,0 @@
1
- import type { ComponentChildren, HTMLAttributes } from 'preact';
2
- import { cn } from '../../styles/cn';
3
- import { LoadingIcon } from '../loader/loadingIcon';
4
- import './button.css';
5
-
6
- export type ButtonProps = Omit<
7
- HTMLAttributes<HTMLButtonElement>,
8
- 'class' | 'type'
9
- > & {
10
- isLoading?: boolean;
11
- children?: ComponentChildren;
12
- class?: string;
13
- type?: 'button' | 'submit' | 'reset';
14
- variant?: 'primary' | 'link';
15
- disabled?: boolean;
16
- };
17
-
18
- const buttonVariants = {
19
- primary: 'IncodeButtonPrimary',
20
- link: 'IncodeButtonLink',
21
- };
22
- export const Button = (props: ButtonProps) => {
23
- const {
24
- isLoading = false,
25
- variant = 'primary',
26
- class: className,
27
- type = 'button',
28
- children,
29
- disabled,
30
- ...rest
31
- } = props;
32
- return (
33
- <button
34
- {...rest}
35
- class={cn(
36
- 'IncodeButton',
37
- isLoading ? 'IncodeButtonLoading' : '',
38
- buttonVariants[variant],
39
- className,
40
- )}
41
- disabled={disabled || isLoading}
42
- type={type}
43
- >
44
- {isLoading ? <LoadingIcon size={30} /> : children}
45
- </button>
46
- );
47
- };
@@ -1,12 +0,0 @@
1
- import type { ComponentChildren, VNode } from 'preact';
2
-
3
- type IncodeComponentProps = {
4
- children?: ComponentChildren;
5
- };
6
-
7
- /**
8
- * Wraps UI modules with the standard container.
9
- */
10
- export function IncodeComponent({ children }: IncodeComponentProps): VNode {
11
- return <div class="IncodeComponent">{children}</div>;
12
- }
@@ -1,75 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- countries,
4
- getCountryByCallingCode,
5
- getCountryByCode,
6
- } from './countries';
7
-
8
- describe('countries', () => {
9
- it('exports countries array', () => {
10
- expect(Array.isArray(countries)).toBe(true);
11
- expect(countries.length).toBeGreaterThan(0);
12
- });
13
-
14
- it('each country has required properties', () => {
15
- const country = countries[0];
16
- expect(country).toHaveProperty('code');
17
- expect(country).toHaveProperty('emoji');
18
- expect(country).toHaveProperty('name');
19
- expect(country).toHaveProperty('callingCode');
20
- });
21
-
22
- it('calling codes start with +', () => {
23
- countries.forEach((country) => {
24
- expect(country.callingCode).toMatch(/^\+\d+/);
25
- });
26
- });
27
- });
28
-
29
- describe('getCountryByCode', () => {
30
- it('finds country by uppercase code', () => {
31
- const country = getCountryByCode('US');
32
- expect(country).toBeDefined();
33
- expect(country?.code).toBe('US');
34
- });
35
-
36
- it('finds country by lowercase code', () => {
37
- const country = getCountryByCode('us');
38
- expect(country).toBeDefined();
39
- expect(country?.code).toBe('US');
40
- });
41
-
42
- it('returns undefined for invalid code', () => {
43
- const country = getCountryByCode('XX');
44
- expect(country).toBeUndefined();
45
- });
46
- });
47
-
48
- describe('getCountryByCallingCode', () => {
49
- it('finds country by calling code with +', () => {
50
- const country = getCountryByCallingCode('+1');
51
- expect(country).toBeDefined();
52
- expect(country?.callingCode).toBe('+1');
53
- });
54
-
55
- it('finds country by calling code without +', () => {
56
- const country = getCountryByCallingCode('1');
57
- expect(country).toBeDefined();
58
- expect(country?.callingCode).toBe('+1');
59
- });
60
-
61
- it('returns undefined for invalid calling code', () => {
62
- const country = getCountryByCallingCode('+999');
63
- expect(country).toBeUndefined();
64
- });
65
-
66
- it('handles empty string', () => {
67
- const country = getCountryByCallingCode('');
68
- expect(country).toBeUndefined();
69
- });
70
-
71
- it('handles calling code with multiple + signs', () => {
72
- const country = getCountryByCallingCode('++1');
73
- expect(country).toBeUndefined();
74
- });
75
- });