@incodetech/web 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (273) hide show
  1. package/dist/{styles/core.css → base.css} +53 -57
  2. package/dist/email/email.es.js +1 -1
  3. package/dist/email/styles.css +11 -11
  4. package/dist/flow/styles.css +688 -1
  5. package/dist/{incodeModule-BF5MX9GT.js → incodeModule-Ct9jp5k6.js} +22 -19
  6. package/dist/index.es.js +18 -18
  7. package/dist/phone/phone.es.js +1 -1
  8. package/dist/phone/styles.css +31 -31
  9. package/dist/selfie/selfie.es.js +16 -16
  10. package/dist/selfie/styles.css +0 -51
  11. package/dist/themes/dark.css +652 -0
  12. package/dist/types/dark.d.ts +1 -0
  13. package/dist/types/light.d.ts +1 -0
  14. package/dist/types/themes/light.d.ts +1 -0
  15. package/package.json +12 -6
  16. package/.turbo/turbo-build.log +0 -58
  17. package/.turbo/turbo-coverage.log +0 -23
  18. package/.turbo/turbo-format.log +0 -6
  19. package/.turbo/turbo-lint$colon$fix.log +0 -6
  20. package/.turbo/turbo-lint.log +0 -6
  21. package/.turbo/turbo-test.log +0 -1033
  22. package/.turbo/turbo-typecheck.log +0 -5
  23. package/coverage/base.css +0 -224
  24. package/coverage/block-navigation.js +0 -87
  25. package/coverage/email/email.tsx.html +0 -850
  26. package/coverage/email/emailInput.tsx.html +0 -340
  27. package/coverage/email/index.html +0 -131
  28. package/coverage/favicon.png +0 -0
  29. package/coverage/flow/flow.tsx.html +0 -961
  30. package/coverage/flow/flowCompleted.tsx.html +0 -448
  31. package/coverage/flow/flowInit.ts.html +0 -367
  32. package/coverage/flow/flowStart.tsx.html +0 -208
  33. package/coverage/flow/index.html +0 -221
  34. package/coverage/flow/preloadFlow.ts.html +0 -598
  35. package/coverage/flow/unsupportedModule.tsx.html +0 -202
  36. package/coverage/flow/useFlowInitialization.ts.html +0 -469
  37. package/coverage/flow/useModuleLoader.ts.html +0 -361
  38. package/coverage/hooks/index.html +0 -116
  39. package/coverage/hooks/useManager.ts.html +0 -205
  40. package/coverage/index.html +0 -401
  41. package/coverage/permissions/boldWithArrow.tsx.html +0 -208
  42. package/coverage/permissions/denied.tsx.html +0 -172
  43. package/coverage/permissions/deniedAndroid.tsx.html +0 -253
  44. package/coverage/permissions/deniedDesktop.tsx.html +0 -277
  45. package/coverage/permissions/deniedIOS.tsx.html +0 -304
  46. package/coverage/permissions/deniedInstructions.tsx.html +0 -142
  47. package/coverage/permissions/iconWrapper.tsx.html +0 -130
  48. package/coverage/permissions/index.html +0 -251
  49. package/coverage/permissions/learnMore.tsx.html +0 -340
  50. package/coverage/permissions/numberedStep.tsx.html +0 -127
  51. package/coverage/permissions/permissions.tsx.html +0 -289
  52. package/coverage/phone/index.html +0 -116
  53. package/coverage/phone/phoneInput.tsx.html +0 -832
  54. package/coverage/prettify.css +0 -1
  55. package/coverage/prettify.js +0 -2
  56. package/coverage/selfie/index.html +0 -131
  57. package/coverage/selfie/selfie.tsx.html +0 -334
  58. package/coverage/selfie/tutorial.tsx.html +0 -214
  59. package/coverage/shared/baseTutorial/baseTutorial.tsx.html +0 -250
  60. package/coverage/shared/baseTutorial/index.html +0 -131
  61. package/coverage/shared/baseTutorial/replaceBaseTutorial.ts.html +0 -289
  62. package/coverage/shared/button/button.tsx.html +0 -226
  63. package/coverage/shared/button/index.html +0 -116
  64. package/coverage/shared/componentRoot/incodeComponent.tsx.html +0 -121
  65. package/coverage/shared/componentRoot/index.html +0 -116
  66. package/coverage/shared/countries/countries.ts.html +0 -502
  67. package/coverage/shared/countries/index.html +0 -116
  68. package/coverage/shared/icons/chevronDown.tsx.html +0 -151
  69. package/coverage/shared/icons/index.html +0 -131
  70. package/coverage/shared/icons/successIcon.tsx.html +0 -163
  71. package/coverage/shared/loader/index.html +0 -116
  72. package/coverage/shared/loader/loadingIcon.tsx.html +0 -286
  73. package/coverage/shared/otpInput/index.html +0 -116
  74. package/coverage/shared/otpInput/otpInput.tsx.html +0 -808
  75. package/coverage/shared/page/index.html +0 -146
  76. package/coverage/shared/page/page.tsx.html +0 -358
  77. package/coverage/shared/page/pageUiConfig.ts.html +0 -277
  78. package/coverage/shared/page/verifiedByIncode.tsx.html +0 -310
  79. package/coverage/shared/spacer/index.html +0 -116
  80. package/coverage/shared/spacer/spacer.tsx.html +0 -349
  81. package/coverage/shared/spinner/index.html +0 -116
  82. package/coverage/shared/spinner/spinner.tsx.html +0 -280
  83. package/coverage/shared/title/index.html +0 -116
  84. package/coverage/shared/title/title.tsx.html +0 -121
  85. package/coverage/shared/uiConfig/index.html +0 -116
  86. package/coverage/shared/uiConfig/uiConfig.ts.html +0 -193
  87. package/coverage/shared/webComponent/incodeModule.ts.html +0 -172
  88. package/coverage/shared/webComponent/index.html +0 -131
  89. package/coverage/shared/webComponent/registerIncodeElement.ts.html +0 -130
  90. package/coverage/sort-arrow-sprite.png +0 -0
  91. package/coverage/sorter.js +0 -210
  92. package/coverage/styles/cn.tsx.html +0 -148
  93. package/coverage/styles/fetchTheme.ts.html +0 -349
  94. package/coverage/styles/index.html +0 -131
  95. package/dev/README.md +0 -163
  96. package/dev/getToken.ts +0 -36
  97. package/dev/headless.html +0 -875
  98. package/dev/index.html +0 -366
  99. package/dev/main-headless.tsx +0 -1332
  100. package/dev/main-orchestrated-flow.tsx +0 -1158
  101. package/dev/main-preact.tsx +0 -323
  102. package/dev/main-simplified.tsx +0 -123
  103. package/dev/main-web-component.tsx +0 -256
  104. package/dev/main.tsx +0 -332
  105. package/dev/manual.html +0 -27
  106. package/dev/orchestrated-flow.html +0 -64
  107. package/dev/simplified.html +0 -64
  108. package/dev/tiktok-logo.svg +0 -7
  109. package/dist/asset-manifest.json +0 -18
  110. package/src/defineCustomElement.tsx +0 -30
  111. package/src/email/email.test.tsx +0 -368
  112. package/src/email/email.tsx +0 -255
  113. package/src/email/emailInput.test.tsx +0 -264
  114. package/src/email/emailInput.tsx +0 -85
  115. package/src/email/styles.css +0 -59
  116. package/src/flow/flow.test.tsx +0 -796
  117. package/src/flow/flow.tsx +0 -292
  118. package/src/flow/flowCompleted.css +0 -30
  119. package/src/flow/flowCompleted.test.tsx +0 -331
  120. package/src/flow/flowCompleted.tsx +0 -121
  121. package/src/flow/flowInit.test.ts +0 -264
  122. package/src/flow/flowInit.ts +0 -94
  123. package/src/flow/flowStart.css +0 -58
  124. package/src/flow/flowStart.test.tsx +0 -49
  125. package/src/flow/flowStart.tsx +0 -41
  126. package/src/flow/incode-logo.svg +0 -8
  127. package/src/flow/index.ts +0 -7
  128. package/src/flow/preloadFlow.test.ts +0 -421
  129. package/src/flow/preloadFlow.ts +0 -171
  130. package/src/flow/styles.css +0 -9
  131. package/src/flow/unsupportedModule.css +0 -21
  132. package/src/flow/unsupportedModule.tsx +0 -39
  133. package/src/flow/useFlowInitialization.test.tsx +0 -292
  134. package/src/flow/useFlowInitialization.ts +0 -128
  135. package/src/flow/useModuleLoader.test.tsx +0 -212
  136. package/src/flow/useModuleLoader.ts +0 -92
  137. package/src/hooks/index.ts +0 -1
  138. package/src/hooks/useManager.test.ts +0 -91
  139. package/src/hooks/useManager.ts +0 -40
  140. package/src/i18n/index.ts +0 -3
  141. package/src/i18n/instance.ts +0 -16
  142. package/src/i18n/setup.ts +0 -184
  143. package/src/i18n/useTranslation.ts +0 -42
  144. package/src/index.ts +0 -27
  145. package/src/permissions/assets/android-dots-icon.svg +0 -7
  146. package/src/permissions/assets/android-settings-icon.svg +0 -16
  147. package/src/permissions/assets/android-toggle-icon.svg +0 -20
  148. package/src/permissions/assets/bank-card-icon.svg +0 -14
  149. package/src/permissions/assets/camera-icon.svg +0 -12
  150. package/src/permissions/assets/camera-ios.svg +0 -53
  151. package/src/permissions/assets/check-icon.svg +0 -8
  152. package/src/permissions/assets/chrome-icon.svg +0 -43
  153. package/src/permissions/assets/password-icon.svg +0 -11
  154. package/src/permissions/assets/permissions-img.svg +0 -51
  155. package/src/permissions/assets/safari-icon.svg +0 -37
  156. package/src/permissions/assets/settings-icon.svg +0 -33
  157. package/src/permissions/assets/toggle-icon.svg +0 -19
  158. package/src/permissions/assets/warning-icon.svg +0 -6
  159. package/src/permissions/boldWithArrow.css +0 -9
  160. package/src/permissions/boldWithArrow.tsx +0 -41
  161. package/src/permissions/denied.css +0 -37
  162. package/src/permissions/denied.tsx +0 -29
  163. package/src/permissions/deniedAndroid.tsx +0 -56
  164. package/src/permissions/deniedDesktop.css +0 -9
  165. package/src/permissions/deniedDesktop.tsx +0 -64
  166. package/src/permissions/deniedIOS.tsx +0 -73
  167. package/src/permissions/deniedInstructions.tsx +0 -19
  168. package/src/permissions/iconWrapper.css +0 -9
  169. package/src/permissions/iconWrapper.tsx +0 -15
  170. package/src/permissions/learnMore.css +0 -37
  171. package/src/permissions/learnMore.tsx +0 -85
  172. package/src/permissions/numberedStep.css +0 -13
  173. package/src/permissions/numberedStep.tsx +0 -14
  174. package/src/permissions/permissions.css +0 -13
  175. package/src/permissions/permissions.tsx +0 -68
  176. package/src/phone/phone.tsx +0 -246
  177. package/src/phone/phoneInput.test.tsx +0 -275
  178. package/src/phone/phoneInput.tsx +0 -249
  179. package/src/phone/styles.css +0 -158
  180. package/src/selfie/cameraButton.css +0 -13
  181. package/src/selfie/cameraButton.tsx +0 -35
  182. package/src/selfie/capture.css +0 -57
  183. package/src/selfie/capture.tsx +0 -232
  184. package/src/selfie/errorModal.tsx +0 -218
  185. package/src/selfie/errorModalContent.css +0 -33
  186. package/src/selfie/errorModalContent.tsx +0 -44
  187. package/src/selfie/faceOutline.css +0 -5
  188. package/src/selfie/faceOutline.tsx +0 -22
  189. package/src/selfie/loadingBorder.css +0 -12
  190. package/src/selfie/loadingBorder.tsx +0 -77
  191. package/src/selfie/manualCaptureButton.css +0 -13
  192. package/src/selfie/manualCaptureButton.tsx +0 -35
  193. package/src/selfie/noMoreAttemptsModal.tsx +0 -44
  194. package/src/selfie/notification.css +0 -9
  195. package/src/selfie/notification.tsx +0 -36
  196. package/src/selfie/retryErrorModal.tsx +0 -56
  197. package/src/selfie/selfie.test.tsx +0 -458
  198. package/src/selfie/selfie.tsx +0 -83
  199. package/src/selfie/selfieTutorial.json +0 -2626
  200. package/src/selfie/styles.css +0 -1
  201. package/src/selfie/tutorial.test.tsx +0 -200
  202. package/src/selfie/tutorial.tsx +0 -43
  203. package/src/setup.ts +0 -33
  204. package/src/shared/baseTutorial/baseTutorial.css +0 -21
  205. package/src/shared/baseTutorial/baseTutorial.test.tsx +0 -184
  206. package/src/shared/baseTutorial/baseTutorial.tsx +0 -55
  207. package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +0 -267
  208. package/src/shared/baseTutorial/replaceBaseTutorial.ts +0 -68
  209. package/src/shared/button/button.css +0 -55
  210. package/src/shared/button/button.test.tsx +0 -101
  211. package/src/shared/button/button.tsx +0 -47
  212. package/src/shared/componentRoot/incodeComponent.tsx +0 -12
  213. package/src/shared/countries/countries.test.ts +0 -75
  214. package/src/shared/countries/countries.ts +0 -139
  215. package/src/shared/countries/index.ts +0 -6
  216. package/src/shared/icons/chevronDown.tsx +0 -22
  217. package/src/shared/icons/index.ts +0 -2
  218. package/src/shared/icons/successIcon.css +0 -5
  219. package/src/shared/icons/successIcon.test.tsx +0 -40
  220. package/src/shared/icons/successIcon.tsx +0 -26
  221. package/src/shared/loader/loadingIcon.css +0 -28
  222. package/src/shared/loader/loadingIcon.tsx +0 -67
  223. package/src/shared/lottie/lottie.tsx +0 -108
  224. package/src/shared/otpInput/otpInput.css +0 -85
  225. package/src/shared/otpInput/otpInput.test.tsx +0 -356
  226. package/src/shared/otpInput/otpInput.tsx +0 -241
  227. package/src/shared/page/incode-logo.svg +0 -3
  228. package/src/shared/page/page.css +0 -47
  229. package/src/shared/page/page.test.tsx +0 -97
  230. package/src/shared/page/page.tsx +0 -91
  231. package/src/shared/page/pageUiConfig.test.ts +0 -112
  232. package/src/shared/page/pageUiConfig.ts +0 -64
  233. package/src/shared/page/verifiedByIncode.css +0 -5
  234. package/src/shared/page/verifiedByIncode.tsx +0 -75
  235. package/src/shared/spacer/spacer.css +0 -149
  236. package/src/shared/spacer/spacer.test.tsx +0 -143
  237. package/src/shared/spacer/spacer.tsx +0 -88
  238. package/src/shared/spinner/index.ts +0 -2
  239. package/src/shared/spinner/spinner.css +0 -28
  240. package/src/shared/spinner/spinner.test.tsx +0 -82
  241. package/src/shared/spinner/spinner.tsx +0 -65
  242. package/src/shared/title/title.css +0 -7
  243. package/src/shared/title/title.tsx +0 -12
  244. package/src/shared/uiConfig/uiConfig.ts +0 -36
  245. package/src/shared/webComponent/incodeModule.ts +0 -29
  246. package/src/shared/webComponent/registerIncodeElement.ts +0 -15
  247. package/src/styles/__mocks__/fetchTheme.ts +0 -19
  248. package/src/styles/applyTheme.ts +0 -37
  249. package/src/styles/cn.test.tsx +0 -57
  250. package/src/styles/cn.tsx +0 -21
  251. package/src/styles/core.css +0 -12
  252. package/src/styles/fetchTheme.test.ts +0 -390
  253. package/src/styles/fetchTheme.ts +0 -88
  254. package/src/styles/generatePalette.ts +0 -111
  255. package/src/styles/reset.css +0 -65
  256. package/src/styles/resolveCssVariableToHex.ts +0 -28
  257. package/src/styles/tailwind.css +0 -291
  258. package/src/styles/themeTypes.ts +0 -18
  259. package/src/styles/tokens/colors.css +0 -190
  260. package/src/styles/tokens/components.css +0 -174
  261. package/src/styles/tokens/index.css +0 -4
  262. package/src/styles/tokens/primitives.css +0 -129
  263. package/src/styles/tokens/semantic.css +0 -51
  264. package/src/svg.d.ts +0 -4
  265. package/src/types/assets.d.ts +0 -1
  266. package/src/types/custom-elements.d.ts +0 -104
  267. package/tsconfig.json +0 -22
  268. package/vite.config.ts +0 -260
  269. package/vitest.config.ts +0 -40
  270. package/vitest.setup.ts +0 -16
  271. /package/dist/{styles/tokens.css → themes/light.css} +0 -0
  272. /package/dist/types/{core.d.ts → base.d.ts} +0 -0
  273. /package/dist/types/{styles/core.d.ts → themes/dark.d.ts} +0 -0
@@ -1,143 +0,0 @@
1
- import { render } from '@testing-library/preact';
2
- import { describe, expect, it } from 'vitest';
3
- import { Spacer } from './spacer';
4
-
5
- describe('Spacer', () => {
6
- it('renders with default vertical direction', () => {
7
- const { container } = render(<Spacer size={16} />);
8
- const spacer = container.querySelector('div');
9
- expect(spacer?.classList.contains('IncodeSpacerVertical16')).toBe(true);
10
- });
11
-
12
- it('renders with horizontal direction', () => {
13
- const { container } = render(<Spacer size={16} direction="horizontal" />);
14
- const spacer = container.querySelector('div');
15
- expect(spacer?.classList.contains('IncodeSpacerHorizontal16')).toBe(true);
16
- });
17
-
18
- it('renders with vertical direction explicitly', () => {
19
- const { container } = render(<Spacer size={16} direction="vertical" />);
20
- const spacer = container.querySelector('div');
21
- expect(spacer?.classList.contains('IncodeSpacerVertical16')).toBe(true);
22
- });
23
-
24
- it('renders with all vertical scale token sizes', () => {
25
- const sizes = [
26
- 0, 2, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 80, 96, 104, 120, 200,
27
- ];
28
- sizes.forEach((size) => {
29
- const { container } = render(<Spacer size={size} />);
30
- const spacer = container.querySelector('div');
31
- expect(spacer?.classList.contains(`IncodeSpacerVertical${size}`)).toBe(
32
- true,
33
- );
34
- });
35
- });
36
-
37
- it('renders with all horizontal scale token sizes', () => {
38
- const sizes = [
39
- 0, 2, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 80, 96, 104, 120, 200,
40
- ];
41
- sizes.forEach((size) => {
42
- const { container } = render(
43
- <Spacer size={size} direction="horizontal" />,
44
- );
45
- const spacer = container.querySelector('div');
46
- expect(spacer?.classList.contains(`IncodeSpacerHorizontal${size}`)).toBe(
47
- true,
48
- );
49
- });
50
- });
51
-
52
- it('renders flex spacer when size is undefined', () => {
53
- const { container } = render(<Spacer />);
54
- const spacer = container.querySelector('div');
55
- expect(spacer?.classList.contains('IncodeSpacerFlex')).toBe(true);
56
- });
57
-
58
- it('renders with custom className', () => {
59
- const { container } = render(<Spacer size={16} className="custom-class" />);
60
- const spacer = container.querySelector('div');
61
- expect(spacer?.classList.contains('IncodeSpacerVertical16')).toBe(true);
62
- expect(spacer?.classList.contains('custom-class')).toBe(true);
63
- });
64
-
65
- it('renders flex spacer with custom className', () => {
66
- const { container } = render(<Spacer className="custom-flex" />);
67
- const spacer = container.querySelector('div');
68
- expect(spacer?.classList.contains('IncodeSpacerFlex')).toBe(true);
69
- expect(spacer?.classList.contains('custom-flex')).toBe(true);
70
- });
71
-
72
- it('handles non-scale token number size', () => {
73
- const { container } = render(<Spacer size={99} />);
74
- const spacer = container.querySelector('div');
75
- expect(spacer?.classList.length).toBe(0);
76
- });
77
-
78
- it('handles string size', () => {
79
- const { container } = render(<Spacer size="20px" />);
80
- const spacer = container.querySelector('div');
81
- expect(spacer?.classList.length).toBe(0);
82
- });
83
-
84
- it('handles non-scale token number with horizontal direction', () => {
85
- const { container } = render(<Spacer size={99} direction="horizontal" />);
86
- const spacer = container.querySelector('div');
87
- expect(spacer?.classList.length).toBe(0);
88
- });
89
-
90
- it('handles string size with horizontal direction', () => {
91
- const { container } = render(<Spacer size="20px" direction="horizontal" />);
92
- const spacer = container.querySelector('div');
93
- expect(spacer?.classList.length).toBe(0);
94
- });
95
-
96
- it('handles empty className string', () => {
97
- const { container } = render(<Spacer size={16} className="" />);
98
- const spacer = container.querySelector('div');
99
- expect(spacer?.classList.contains('IncodeSpacerVertical16')).toBe(true);
100
- });
101
-
102
- it('applies correct CSS classes for vertical spacer', () => {
103
- const { container } = render(<Spacer size={8} direction="vertical" />);
104
- const spacer = container.querySelector('div');
105
- const classes = Array.from(spacer?.classList || []);
106
- expect(classes).toContain('IncodeSpacerVertical8');
107
- });
108
-
109
- it('applies correct CSS classes for horizontal spacer', () => {
110
- const { container } = render(<Spacer size={8} direction="horizontal" />);
111
- const spacer = container.querySelector('div');
112
- const classes = Array.from(spacer?.classList || []);
113
- expect(classes).toContain('IncodeSpacerHorizontal8');
114
- });
115
-
116
- it('applies correct CSS class for flex spacer', () => {
117
- const { container } = render(<Spacer />);
118
- const spacer = container.querySelector('div');
119
- const classes = Array.from(spacer?.classList || []);
120
- expect(classes).toContain('IncodeSpacerFlex');
121
- });
122
-
123
- it('handles invalid direction value', () => {
124
- const { container } = render(
125
- <Spacer size={16} direction={'invalid' as 'horizontal'} />,
126
- );
127
- const spacer = container.querySelector('div');
128
- expect(spacer?.classList.length).toBe(0);
129
- });
130
-
131
- it('handles invalid direction with className', () => {
132
- const { container } = render(
133
- <Spacer
134
- size={16}
135
- direction={'invalid' as 'horizontal'}
136
- className="custom"
137
- />,
138
- );
139
- const spacer = container.querySelector('div');
140
- expect(spacer?.classList.contains('custom')).toBe(true);
141
- expect(spacer?.classList.length).toBe(1);
142
- });
143
- });
@@ -1,88 +0,0 @@
1
- import './spacer.css';
2
-
3
- type SpacerProps = {
4
- size?: number | string;
5
- direction?: 'horizontal' | 'vertical';
6
- className?: string;
7
- };
8
-
9
- const scaleTokens = new Set([
10
- 0, 2, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 80, 96, 104, 120, 160, 200,
11
- ]);
12
-
13
- const scaleToClassName = (
14
- size: number,
15
- direction: 'horizontal' | 'vertical',
16
- ) => {
17
- if (direction === 'horizontal') {
18
- return {
19
- 0: 'IncodeSpacerHorizontal0',
20
- 2: 'IncodeSpacerHorizontal2',
21
- 4: 'IncodeSpacerHorizontal4',
22
- 8: 'IncodeSpacerHorizontal8',
23
- 12: 'IncodeSpacerHorizontal12',
24
- 16: 'IncodeSpacerHorizontal16',
25
- 20: 'IncodeSpacerHorizontal20',
26
- 24: 'IncodeSpacerHorizontal24',
27
- 32: 'IncodeSpacerHorizontal32',
28
- 40: 'IncodeSpacerHorizontal40',
29
- 48: 'IncodeSpacerHorizontal48',
30
- 64: 'IncodeSpacerHorizontal64',
31
- 80: 'IncodeSpacerHorizontal80',
32
- 96: 'IncodeSpacerHorizontal96',
33
- 104: 'IncodeSpacerHorizontal104',
34
- 120: 'IncodeSpacerHorizontal120',
35
- 160: 'IncodeSpacerHorizontal160',
36
- 200: 'IncodeSpacerHorizontal200',
37
- }[size];
38
- }
39
- return {
40
- 0: 'IncodeSpacerVertical0',
41
- 2: 'IncodeSpacerVertical2',
42
- 4: 'IncodeSpacerVertical4',
43
- 8: 'IncodeSpacerVertical8',
44
- 12: 'IncodeSpacerVertical12',
45
- 16: 'IncodeSpacerVertical16',
46
- 20: 'IncodeSpacerVertical20',
47
- 24: 'IncodeSpacerVertical24',
48
- 32: 'IncodeSpacerVertical32',
49
- 40: 'IncodeSpacerVertical40',
50
- 48: 'IncodeSpacerVertical48',
51
- 64: 'IncodeSpacerVertical64',
52
- 80: 'IncodeSpacerVertical80',
53
- 96: 'IncodeSpacerVertical96',
54
- 104: 'IncodeSpacerVertical104',
55
- 120: 'IncodeSpacerVertical120',
56
- 160: 'IncodeSpacerVertical160',
57
- 200: 'IncodeSpacerVertical200',
58
- }[size];
59
- };
60
-
61
- export const Spacer = ({
62
- size,
63
- className,
64
- direction = 'vertical',
65
- }: SpacerProps) => {
66
- if (size === undefined) {
67
- return <div class={`IncodeSpacerFlex ${className || ''}`} />;
68
- }
69
-
70
- const dimension =
71
- direction === 'horizontal'
72
- ? 'w'
73
- : direction === 'vertical'
74
- ? 'h'
75
- : undefined;
76
-
77
- if (!dimension) {
78
- return <div class={`${className || ''}`} />;
79
- }
80
-
81
- if (typeof size === 'number' && scaleTokens.has(size)) {
82
- return (
83
- <div class={`${scaleToClassName(size, direction)} ${className || ''}`} />
84
- );
85
- }
86
-
87
- return <div class={`${className || ''}`} />;
88
- };
@@ -1,2 +0,0 @@
1
- export type { SpinnerProps, SpinnerSize } from './spinner';
2
- export { Spinner } from './spinner';
@@ -1,28 +0,0 @@
1
- @reference "../../styles/tailwind.css";
2
-
3
- .IncodeSpinner {
4
- @apply flex items-center justify-center;
5
- }
6
-
7
- .IncodeSpinner.IncodeSpinnerFullScreen {
8
- @apply fixed inset-0 z-50;
9
- background-color: var(--spinner-surface-overlay);
10
- opacity: var(--spinner-surface-overlay-opacity, 1);
11
- }
12
-
13
- .IncodeSpinnerContent {
14
- @apply flex flex-col items-center justify-center;
15
- }
16
-
17
- .IncodeSpinnerText {
18
- @apply flex flex-col items-center text-center;
19
- }
20
-
21
- .IncodeSpinnerTitle {
22
- color: var(--spinner-text-title);
23
- }
24
-
25
- .IncodeSpinnerSubtitle {
26
- @apply text-base;
27
- color: var(--spinner-text-subtitle);
28
- }
@@ -1,82 +0,0 @@
1
- import { render, screen } from '@testing-library/preact';
2
- import { describe, expect, it, vi } from 'vitest';
3
- import { Spinner } from './spinner';
4
-
5
- vi.mock('../loader/loadingIcon', () => ({
6
- LoadingIcon: ({ size }: { size: number }) => (
7
- <div data-testid="loading-icon" data-size={size}>
8
- Loading Icon
9
- </div>
10
- ),
11
- }));
12
-
13
- describe('Spinner', () => {
14
- it('renders with default props (icon only, no text)', () => {
15
- const { container } = render(<Spinner />);
16
- const spinner = container.querySelector('.IncodeSpinner');
17
- expect(spinner).toBeTruthy();
18
- expect(spinner?.classList.contains('IncodeSpinnerFullScreen')).toBe(true);
19
- // No text by default
20
- expect(container.querySelector('.IncodeSpinnerText')).toBeNull();
21
- });
22
-
23
- it('renders with fullScreen false', () => {
24
- const { container } = render(<Spinner fullScreen={false} />);
25
- const spinner = container.querySelector('.IncodeSpinner');
26
- expect(spinner).toBeTruthy();
27
- expect(spinner?.classList.contains('IncodeSpinnerFullScreen')).toBe(false);
28
- });
29
-
30
- it('renders LoadingIcon with default medium size', () => {
31
- render(<Spinner />);
32
- const icon = screen.getByTestId('loading-icon');
33
- expect(icon).toBeTruthy();
34
- expect(icon.getAttribute('data-size')).toBe('48');
35
- });
36
-
37
- it('renders LoadingIcon with small size', () => {
38
- render(<Spinner size="small" />);
39
- const icon = screen.getByTestId('loading-icon');
40
- expect(icon.getAttribute('data-size')).toBe('24');
41
- });
42
-
43
- it('renders LoadingIcon with large size', () => {
44
- render(<Spinner size="large" />);
45
- const icon = screen.getByTestId('loading-icon');
46
- expect(icon.getAttribute('data-size')).toBe('64');
47
- });
48
-
49
- it('renders with title', () => {
50
- render(<Spinner title="Loading..." />);
51
- expect(screen.getByText('Loading...')).toBeTruthy();
52
- });
53
-
54
- it('renders with subtitle', () => {
55
- render(<Spinner subtitle="Please wait" />);
56
- expect(screen.getByText('Please wait')).toBeTruthy();
57
- });
58
-
59
- it('renders with both title and subtitle', () => {
60
- render(<Spinner title="Loading..." subtitle="Please wait" />);
61
- expect(screen.getByText('Loading...')).toBeTruthy();
62
- expect(screen.getByText('Please wait')).toBeTruthy();
63
- });
64
-
65
- it('applies custom className', () => {
66
- const { container } = render(<Spinner className="custom-class" />);
67
- const spinner = container.querySelector('.IncodeSpinner');
68
- expect(spinner?.classList.contains('custom-class')).toBe(true);
69
- });
70
-
71
- it('renders text container when title is provided', () => {
72
- const { container } = render(<Spinner title="Loading" />);
73
- const textContainer = container.querySelector('.IncodeSpinnerText');
74
- expect(textContainer).toBeTruthy();
75
- });
76
-
77
- it('renders text container when subtitle is provided', () => {
78
- const { container } = render(<Spinner subtitle="Please wait" />);
79
- const textContainer = container.querySelector('.IncodeSpinnerText');
80
- expect(textContainer).toBeTruthy();
81
- });
82
- });
@@ -1,65 +0,0 @@
1
- import type { FC } from 'preact/compat';
2
- import { cn } from '@/styles/cn';
3
- import { LoadingIcon } from '../loader/loadingIcon';
4
- import { Spacer } from '../spacer/spacer';
5
- import { Title } from '../title/title';
6
- import './spinner.css';
7
-
8
- export type SpinnerSize = 'small' | 'medium' | 'large';
9
-
10
- export type SpinnerProps = {
11
- /** Title text to display below the spinner */
12
- title?: string;
13
- /** Subtitle text to display below the title */
14
- subtitle?: string;
15
- /** Size of the spinner icon */
16
- size?: SpinnerSize;
17
- /** Whether to display as full-screen overlay */
18
- fullScreen?: boolean;
19
- /** Additional CSS class name */
20
- className?: string;
21
- };
22
-
23
- const sizeMap: Record<SpinnerSize, number> = {
24
- small: 24,
25
- medium: 48,
26
- large: 64,
27
- };
28
-
29
- export const Spinner: FC<SpinnerProps> = ({
30
- title,
31
- subtitle,
32
- size = 'medium',
33
- fullScreen = true,
34
- className,
35
- }) => {
36
- const iconSize = sizeMap[size];
37
-
38
- const containerClass = cn(
39
- 'IncodeSpinner',
40
- fullScreen && 'IncodeSpinnerFullScreen',
41
- className,
42
- );
43
-
44
- return (
45
- <div class={containerClass}>
46
- <div class="IncodeSpinnerContent">
47
- <LoadingIcon size={iconSize} />
48
- {(title || subtitle) && (
49
- <>
50
- <Spacer size={16} />
51
- <div class="IncodeSpinnerText">
52
- {title && <Title className="IncodeSpinnerTitle">{title}</Title>}
53
- {subtitle && (
54
- <>
55
- {title && <Spacer size={12} />}
56
- <p class="IncodeSpinnerSubtitle">{subtitle}</p>
57
- </>
58
- )}
59
- </div>
60
- </>
61
- )}
62
- </div>
63
- </div>
64
- );
65
- };
@@ -1,7 +0,0 @@
1
- @reference "../../styles/tailwind.css";
2
-
3
- .IncodeComponent {
4
- .IncodeTitle {
5
- @apply text-2xl font-bold text-center tracking-[-1px] leading-[125%] text-text-body-primary;
6
- }
7
- }
@@ -1,12 +0,0 @@
1
- import type { ComponentChildren } from 'preact';
2
- import type { FC } from 'preact/compat';
3
- import './title.css';
4
-
5
- type TitleProps = {
6
- children: ComponentChildren;
7
- className?: string;
8
- };
9
-
10
- export const Title: FC<TitleProps> = ({ children, className }) => {
11
- return <h2 class={`IncodeTitle ${className ?? ''}`}>{children}</h2>;
12
- };
@@ -1,36 +0,0 @@
1
- import { useSyncExternalStore } from 'preact/compat';
2
-
3
- export type UiConfig = {
4
- logoSrc?: string;
5
- logoHeight?: string;
6
- hideHeader?: boolean;
7
- hideFooterBranding?: boolean;
8
- };
9
-
10
- let uiConfig: UiConfig = {};
11
- const listeners = new Set<() => void>();
12
-
13
- function subscribe(listener: () => void): () => void {
14
- listeners.add(listener);
15
- return () => {
16
- listeners.delete(listener);
17
- };
18
- }
19
-
20
- function getSnapshot(): UiConfig {
21
- return uiConfig;
22
- }
23
-
24
- /**
25
- * Sets global UI configuration defaults for `@incodetech/ui`.
26
- */
27
- export function setUiConfig(next: UiConfig): void {
28
- uiConfig = next;
29
- for (const listener of listeners) {
30
- listener();
31
- }
32
- }
33
-
34
- export function useUiConfig(): UiConfig {
35
- return useSyncExternalStore(subscribe, getSnapshot);
36
- }
@@ -1,29 +0,0 @@
1
- import type { ComponentType } from 'preact';
2
- import { registerIncodeElement } from './registerIncodeElement';
3
-
4
- export type IncodeModuleProps<TConfig> = {
5
- /**
6
- * Module configuration required to render the flow.
7
- * For Web Components, this is typically assigned via `element.config = ...`.
8
- */
9
- config?: TConfig;
10
-
11
- /**
12
- * Callback invoked when the module completes successfully.
13
- */
14
- onFinish?: () => void;
15
-
16
- /**
17
- * Callback invoked when a fatal module error occurs.
18
- */
19
- onError?: (error: string | undefined) => void;
20
- };
21
-
22
- export const incodeModulePropKeys = ['config', 'onFinish', 'onError'] as const;
23
-
24
- export function registerIncodeModuleElement<TConfig>(
25
- component: ComponentType<IncodeModuleProps<TConfig>>,
26
- tagName: string,
27
- ): void {
28
- registerIncodeElement(component, tagName, incodeModulePropKeys);
29
- }
@@ -1,15 +0,0 @@
1
- import type { ComponentType } from 'preact';
2
- import register from 'preact-custom-element';
3
-
4
- /**
5
- * Registers a Preact component as a Web Component with `shadow: false`.
6
- */
7
- export function registerIncodeElement<TProps>(
8
- component: ComponentType<TProps>,
9
- tagName: string,
10
- props: readonly (keyof TProps)[],
11
- ): void {
12
- register(component, tagName, [...props], {
13
- shadow: false,
14
- });
15
- }
@@ -1,19 +0,0 @@
1
- import { vi } from 'vitest';
2
- import type { ThemeConfig } from '../themeTypes';
3
-
4
- export const mockFetchTheme = vi.fn<() => Promise<ThemeConfig>>();
5
- export const mockFetchAssets = vi.fn();
6
- export const mockFetchAndApplyTheme = vi.fn<() => Promise<ThemeConfig>>();
7
-
8
- export const createMockThemeConfig = (
9
- overrides?: Partial<ThemeConfig>,
10
- ): ThemeConfig => ({
11
- main: '#ff0000',
12
- buttonColor: '#ffffff',
13
- ...overrides,
14
- });
15
-
16
- export const createMockAssetsResponse = () => ({
17
- theme: '/api/theme.json',
18
- 'logo.png': 'https://example.com/logo.png',
19
- });
@@ -1,37 +0,0 @@
1
- import { generateBrandPalette } from './generatePalette';
2
-
3
- export function applyTheme(mainColor: string, buttonColor?: string): void {
4
- if (typeof document === 'undefined') {
5
- return;
6
- }
7
-
8
- const palette = generateBrandPalette(mainColor);
9
-
10
- let styleElement = document.getElementById(
11
- 'incode-theme',
12
- ) as HTMLStyleElement | null;
13
-
14
- if (!styleElement) {
15
- styleElement = document.createElement('style');
16
- styleElement.id = 'incode-theme';
17
- document.head.appendChild(styleElement);
18
- }
19
-
20
- const buttonTextColor = buttonColor || '#ffffff';
21
-
22
- const css = `
23
- :root,
24
- :host {
25
- --primitive-color-brand-50: ${palette['50']};
26
- --primitive-color-brand-200: ${palette['200']};
27
- --primitive-color-brand-300: ${palette['300']};
28
- --primitive-color-brand-400: ${palette['400']};
29
- --primitive-color-brand-500: ${palette['500']};
30
- --primitive-color-brand-600: ${palette['600']};
31
- --primitive-color-brand-900: ${palette['900']};
32
- --button-primary-text-default: ${buttonTextColor};
33
- }
34
- `;
35
-
36
- styleElement.textContent = css;
37
- }
@@ -1,57 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { cn } from './cn';
3
-
4
- describe('cn', () => {
5
- it('should return empty string for no arguments', () => {
6
- expect(cn()).toBe('');
7
- });
8
-
9
- it('should return single string class', () => {
10
- expect(cn('foo')).toBe('foo');
11
- });
12
-
13
- it('should join multiple string classes', () => {
14
- expect(cn('foo', 'bar', 'baz')).toBe('foo bar baz');
15
- });
16
-
17
- it('should filter out null values', () => {
18
- expect(cn('foo', null, 'bar')).toBe('foo bar');
19
- });
20
-
21
- it('should filter out undefined values', () => {
22
- expect(cn('foo', undefined, 'bar')).toBe('foo bar');
23
- });
24
-
25
- it('should filter out false values', () => {
26
- expect(cn('foo', false, 'bar')).toBe('foo bar');
27
- });
28
-
29
- it('should handle object with truthy values', () => {
30
- expect(cn({ foo: true, bar: true })).toBe('foo bar');
31
- });
32
-
33
- it('should filter out object keys with falsy values', () => {
34
- expect(cn({ foo: true, bar: false, baz: true })).toBe('foo baz');
35
- });
36
-
37
- it('should handle mixed string and object classes', () => {
38
- expect(cn('base', { active: true, disabled: false })).toBe('base active');
39
- });
40
-
41
- it('should handle empty object', () => {
42
- expect(cn({})).toBe('');
43
- });
44
-
45
- it('should handle complex combinations', () => {
46
- expect(
47
- cn(
48
- 'btn',
49
- null,
50
- { primary: true, large: false },
51
- undefined,
52
- 'extra',
53
- false,
54
- ),
55
- ).toBe('btn primary extra');
56
- });
57
- });
package/src/styles/cn.tsx DELETED
@@ -1,21 +0,0 @@
1
- type ClassValue = string | null | undefined | false | Record<string, boolean>;
2
-
3
- export const cn = (...classes: ClassValue[]) => {
4
- const result: string[] = [];
5
-
6
- for (const cls of classes) {
7
- if (!cls) continue;
8
-
9
- if (typeof cls === 'string') {
10
- result.push(cls);
11
- } else if (typeof cls === 'object') {
12
- for (const [key, value] of Object.entries(cls)) {
13
- if (value) {
14
- result.push(key);
15
- }
16
- }
17
- }
18
- }
19
-
20
- return result.join(' ');
21
- };
@@ -1,12 +0,0 @@
1
- @import "./tailwind.css";
2
-
3
- @import "../shared/button/button.css";
4
- @import "../shared/otpInput/otpInput.css";
5
- @import "../shared/page/page.css";
6
- @import "../shared/page/verifiedByIncode.css";
7
- @import "../shared/title/title.css";
8
- @import "../shared/icons/successIcon.css";
9
- @import "../shared/spacer/spacer.css";
10
- @import "../shared/loader/loadingIcon.css";
11
- @import "../shared/baseTutorial/baseTutorial.css";
12
- @import "../shared/spinner/spinner.css";