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

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 (256) hide show
  1. package/dist/asset-manifest.json +16 -16
  2. package/package.json +5 -2
  3. package/.turbo/turbo-build.log +0 -58
  4. package/.turbo/turbo-coverage.log +0 -23
  5. package/.turbo/turbo-format.log +0 -6
  6. package/.turbo/turbo-lint$colon$fix.log +0 -6
  7. package/.turbo/turbo-lint.log +0 -6
  8. package/.turbo/turbo-test.log +0 -1033
  9. package/.turbo/turbo-typecheck.log +0 -5
  10. package/coverage/base.css +0 -224
  11. package/coverage/block-navigation.js +0 -87
  12. package/coverage/email/email.tsx.html +0 -850
  13. package/coverage/email/emailInput.tsx.html +0 -340
  14. package/coverage/email/index.html +0 -131
  15. package/coverage/favicon.png +0 -0
  16. package/coverage/flow/flow.tsx.html +0 -961
  17. package/coverage/flow/flowCompleted.tsx.html +0 -448
  18. package/coverage/flow/flowInit.ts.html +0 -367
  19. package/coverage/flow/flowStart.tsx.html +0 -208
  20. package/coverage/flow/index.html +0 -221
  21. package/coverage/flow/preloadFlow.ts.html +0 -598
  22. package/coverage/flow/unsupportedModule.tsx.html +0 -202
  23. package/coverage/flow/useFlowInitialization.ts.html +0 -469
  24. package/coverage/flow/useModuleLoader.ts.html +0 -361
  25. package/coverage/hooks/index.html +0 -116
  26. package/coverage/hooks/useManager.ts.html +0 -205
  27. package/coverage/index.html +0 -401
  28. package/coverage/permissions/boldWithArrow.tsx.html +0 -208
  29. package/coverage/permissions/denied.tsx.html +0 -172
  30. package/coverage/permissions/deniedAndroid.tsx.html +0 -253
  31. package/coverage/permissions/deniedDesktop.tsx.html +0 -277
  32. package/coverage/permissions/deniedIOS.tsx.html +0 -304
  33. package/coverage/permissions/deniedInstructions.tsx.html +0 -142
  34. package/coverage/permissions/iconWrapper.tsx.html +0 -130
  35. package/coverage/permissions/index.html +0 -251
  36. package/coverage/permissions/learnMore.tsx.html +0 -340
  37. package/coverage/permissions/numberedStep.tsx.html +0 -127
  38. package/coverage/permissions/permissions.tsx.html +0 -289
  39. package/coverage/phone/index.html +0 -116
  40. package/coverage/phone/phoneInput.tsx.html +0 -832
  41. package/coverage/prettify.css +0 -1
  42. package/coverage/prettify.js +0 -2
  43. package/coverage/selfie/index.html +0 -131
  44. package/coverage/selfie/selfie.tsx.html +0 -334
  45. package/coverage/selfie/tutorial.tsx.html +0 -214
  46. package/coverage/shared/baseTutorial/baseTutorial.tsx.html +0 -250
  47. package/coverage/shared/baseTutorial/index.html +0 -131
  48. package/coverage/shared/baseTutorial/replaceBaseTutorial.ts.html +0 -289
  49. package/coverage/shared/button/button.tsx.html +0 -226
  50. package/coverage/shared/button/index.html +0 -116
  51. package/coverage/shared/componentRoot/incodeComponent.tsx.html +0 -121
  52. package/coverage/shared/componentRoot/index.html +0 -116
  53. package/coverage/shared/countries/countries.ts.html +0 -502
  54. package/coverage/shared/countries/index.html +0 -116
  55. package/coverage/shared/icons/chevronDown.tsx.html +0 -151
  56. package/coverage/shared/icons/index.html +0 -131
  57. package/coverage/shared/icons/successIcon.tsx.html +0 -163
  58. package/coverage/shared/loader/index.html +0 -116
  59. package/coverage/shared/loader/loadingIcon.tsx.html +0 -286
  60. package/coverage/shared/otpInput/index.html +0 -116
  61. package/coverage/shared/otpInput/otpInput.tsx.html +0 -808
  62. package/coverage/shared/page/index.html +0 -146
  63. package/coverage/shared/page/page.tsx.html +0 -358
  64. package/coverage/shared/page/pageUiConfig.ts.html +0 -277
  65. package/coverage/shared/page/verifiedByIncode.tsx.html +0 -310
  66. package/coverage/shared/spacer/index.html +0 -116
  67. package/coverage/shared/spacer/spacer.tsx.html +0 -349
  68. package/coverage/shared/spinner/index.html +0 -116
  69. package/coverage/shared/spinner/spinner.tsx.html +0 -280
  70. package/coverage/shared/title/index.html +0 -116
  71. package/coverage/shared/title/title.tsx.html +0 -121
  72. package/coverage/shared/uiConfig/index.html +0 -116
  73. package/coverage/shared/uiConfig/uiConfig.ts.html +0 -193
  74. package/coverage/shared/webComponent/incodeModule.ts.html +0 -172
  75. package/coverage/shared/webComponent/index.html +0 -131
  76. package/coverage/shared/webComponent/registerIncodeElement.ts.html +0 -130
  77. package/coverage/sort-arrow-sprite.png +0 -0
  78. package/coverage/sorter.js +0 -210
  79. package/coverage/styles/cn.tsx.html +0 -148
  80. package/coverage/styles/fetchTheme.ts.html +0 -349
  81. package/coverage/styles/index.html +0 -131
  82. package/dev/README.md +0 -163
  83. package/dev/getToken.ts +0 -36
  84. package/dev/headless.html +0 -875
  85. package/dev/index.html +0 -366
  86. package/dev/main-headless.tsx +0 -1332
  87. package/dev/main-orchestrated-flow.tsx +0 -1158
  88. package/dev/main-preact.tsx +0 -323
  89. package/dev/main-simplified.tsx +0 -123
  90. package/dev/main-web-component.tsx +0 -256
  91. package/dev/main.tsx +0 -332
  92. package/dev/manual.html +0 -27
  93. package/dev/orchestrated-flow.html +0 -64
  94. package/dev/simplified.html +0 -64
  95. package/dev/tiktok-logo.svg +0 -7
  96. package/src/defineCustomElement.tsx +0 -30
  97. package/src/email/email.test.tsx +0 -368
  98. package/src/email/email.tsx +0 -255
  99. package/src/email/emailInput.test.tsx +0 -264
  100. package/src/email/emailInput.tsx +0 -85
  101. package/src/email/styles.css +0 -59
  102. package/src/flow/flow.test.tsx +0 -796
  103. package/src/flow/flow.tsx +0 -292
  104. package/src/flow/flowCompleted.css +0 -30
  105. package/src/flow/flowCompleted.test.tsx +0 -331
  106. package/src/flow/flowCompleted.tsx +0 -121
  107. package/src/flow/flowInit.test.ts +0 -264
  108. package/src/flow/flowInit.ts +0 -94
  109. package/src/flow/flowStart.css +0 -58
  110. package/src/flow/flowStart.test.tsx +0 -49
  111. package/src/flow/flowStart.tsx +0 -41
  112. package/src/flow/incode-logo.svg +0 -8
  113. package/src/flow/index.ts +0 -7
  114. package/src/flow/preloadFlow.test.ts +0 -421
  115. package/src/flow/preloadFlow.ts +0 -171
  116. package/src/flow/styles.css +0 -9
  117. package/src/flow/unsupportedModule.css +0 -21
  118. package/src/flow/unsupportedModule.tsx +0 -39
  119. package/src/flow/useFlowInitialization.test.tsx +0 -292
  120. package/src/flow/useFlowInitialization.ts +0 -128
  121. package/src/flow/useModuleLoader.test.tsx +0 -212
  122. package/src/flow/useModuleLoader.ts +0 -92
  123. package/src/hooks/index.ts +0 -1
  124. package/src/hooks/useManager.test.ts +0 -91
  125. package/src/hooks/useManager.ts +0 -40
  126. package/src/i18n/index.ts +0 -3
  127. package/src/i18n/instance.ts +0 -16
  128. package/src/i18n/setup.ts +0 -184
  129. package/src/i18n/useTranslation.ts +0 -42
  130. package/src/index.ts +0 -27
  131. package/src/permissions/assets/android-dots-icon.svg +0 -7
  132. package/src/permissions/assets/android-settings-icon.svg +0 -16
  133. package/src/permissions/assets/android-toggle-icon.svg +0 -20
  134. package/src/permissions/assets/bank-card-icon.svg +0 -14
  135. package/src/permissions/assets/camera-icon.svg +0 -12
  136. package/src/permissions/assets/camera-ios.svg +0 -53
  137. package/src/permissions/assets/check-icon.svg +0 -8
  138. package/src/permissions/assets/chrome-icon.svg +0 -43
  139. package/src/permissions/assets/password-icon.svg +0 -11
  140. package/src/permissions/assets/permissions-img.svg +0 -51
  141. package/src/permissions/assets/safari-icon.svg +0 -37
  142. package/src/permissions/assets/settings-icon.svg +0 -33
  143. package/src/permissions/assets/toggle-icon.svg +0 -19
  144. package/src/permissions/assets/warning-icon.svg +0 -6
  145. package/src/permissions/boldWithArrow.css +0 -9
  146. package/src/permissions/boldWithArrow.tsx +0 -41
  147. package/src/permissions/denied.css +0 -37
  148. package/src/permissions/denied.tsx +0 -29
  149. package/src/permissions/deniedAndroid.tsx +0 -56
  150. package/src/permissions/deniedDesktop.css +0 -9
  151. package/src/permissions/deniedDesktop.tsx +0 -64
  152. package/src/permissions/deniedIOS.tsx +0 -73
  153. package/src/permissions/deniedInstructions.tsx +0 -19
  154. package/src/permissions/iconWrapper.css +0 -9
  155. package/src/permissions/iconWrapper.tsx +0 -15
  156. package/src/permissions/learnMore.css +0 -37
  157. package/src/permissions/learnMore.tsx +0 -85
  158. package/src/permissions/numberedStep.css +0 -13
  159. package/src/permissions/numberedStep.tsx +0 -14
  160. package/src/permissions/permissions.css +0 -13
  161. package/src/permissions/permissions.tsx +0 -68
  162. package/src/phone/phone.tsx +0 -246
  163. package/src/phone/phoneInput.test.tsx +0 -275
  164. package/src/phone/phoneInput.tsx +0 -249
  165. package/src/phone/styles.css +0 -158
  166. package/src/selfie/cameraButton.css +0 -13
  167. package/src/selfie/cameraButton.tsx +0 -35
  168. package/src/selfie/capture.css +0 -57
  169. package/src/selfie/capture.tsx +0 -232
  170. package/src/selfie/errorModal.tsx +0 -218
  171. package/src/selfie/errorModalContent.css +0 -33
  172. package/src/selfie/errorModalContent.tsx +0 -44
  173. package/src/selfie/faceOutline.css +0 -5
  174. package/src/selfie/faceOutline.tsx +0 -22
  175. package/src/selfie/loadingBorder.css +0 -12
  176. package/src/selfie/loadingBorder.tsx +0 -77
  177. package/src/selfie/manualCaptureButton.css +0 -13
  178. package/src/selfie/manualCaptureButton.tsx +0 -35
  179. package/src/selfie/noMoreAttemptsModal.tsx +0 -44
  180. package/src/selfie/notification.css +0 -9
  181. package/src/selfie/notification.tsx +0 -36
  182. package/src/selfie/retryErrorModal.tsx +0 -56
  183. package/src/selfie/selfie.test.tsx +0 -458
  184. package/src/selfie/selfie.tsx +0 -83
  185. package/src/selfie/selfieTutorial.json +0 -2626
  186. package/src/selfie/styles.css +0 -1
  187. package/src/selfie/tutorial.test.tsx +0 -200
  188. package/src/selfie/tutorial.tsx +0 -43
  189. package/src/setup.ts +0 -33
  190. package/src/shared/baseTutorial/baseTutorial.css +0 -21
  191. package/src/shared/baseTutorial/baseTutorial.test.tsx +0 -184
  192. package/src/shared/baseTutorial/baseTutorial.tsx +0 -55
  193. package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +0 -267
  194. package/src/shared/baseTutorial/replaceBaseTutorial.ts +0 -68
  195. package/src/shared/button/button.css +0 -55
  196. package/src/shared/button/button.test.tsx +0 -101
  197. package/src/shared/button/button.tsx +0 -47
  198. package/src/shared/componentRoot/incodeComponent.tsx +0 -12
  199. package/src/shared/countries/countries.test.ts +0 -75
  200. package/src/shared/countries/countries.ts +0 -139
  201. package/src/shared/countries/index.ts +0 -6
  202. package/src/shared/icons/chevronDown.tsx +0 -22
  203. package/src/shared/icons/index.ts +0 -2
  204. package/src/shared/icons/successIcon.css +0 -5
  205. package/src/shared/icons/successIcon.test.tsx +0 -40
  206. package/src/shared/icons/successIcon.tsx +0 -26
  207. package/src/shared/loader/loadingIcon.css +0 -28
  208. package/src/shared/loader/loadingIcon.tsx +0 -67
  209. package/src/shared/lottie/lottie.tsx +0 -108
  210. package/src/shared/otpInput/otpInput.css +0 -85
  211. package/src/shared/otpInput/otpInput.test.tsx +0 -356
  212. package/src/shared/otpInput/otpInput.tsx +0 -241
  213. package/src/shared/page/incode-logo.svg +0 -3
  214. package/src/shared/page/page.css +0 -47
  215. package/src/shared/page/page.test.tsx +0 -97
  216. package/src/shared/page/page.tsx +0 -91
  217. package/src/shared/page/pageUiConfig.test.ts +0 -112
  218. package/src/shared/page/pageUiConfig.ts +0 -64
  219. package/src/shared/page/verifiedByIncode.css +0 -5
  220. package/src/shared/page/verifiedByIncode.tsx +0 -75
  221. package/src/shared/spacer/spacer.css +0 -149
  222. package/src/shared/spacer/spacer.test.tsx +0 -143
  223. package/src/shared/spacer/spacer.tsx +0 -88
  224. package/src/shared/spinner/index.ts +0 -2
  225. package/src/shared/spinner/spinner.css +0 -28
  226. package/src/shared/spinner/spinner.test.tsx +0 -82
  227. package/src/shared/spinner/spinner.tsx +0 -65
  228. package/src/shared/title/title.css +0 -7
  229. package/src/shared/title/title.tsx +0 -12
  230. package/src/shared/uiConfig/uiConfig.ts +0 -36
  231. package/src/shared/webComponent/incodeModule.ts +0 -29
  232. package/src/shared/webComponent/registerIncodeElement.ts +0 -15
  233. package/src/styles/__mocks__/fetchTheme.ts +0 -19
  234. package/src/styles/applyTheme.ts +0 -37
  235. package/src/styles/cn.test.tsx +0 -57
  236. package/src/styles/cn.tsx +0 -21
  237. package/src/styles/core.css +0 -12
  238. package/src/styles/fetchTheme.test.ts +0 -390
  239. package/src/styles/fetchTheme.ts +0 -88
  240. package/src/styles/generatePalette.ts +0 -111
  241. package/src/styles/reset.css +0 -65
  242. package/src/styles/resolveCssVariableToHex.ts +0 -28
  243. package/src/styles/tailwind.css +0 -291
  244. package/src/styles/themeTypes.ts +0 -18
  245. package/src/styles/tokens/colors.css +0 -190
  246. package/src/styles/tokens/components.css +0 -174
  247. package/src/styles/tokens/index.css +0 -4
  248. package/src/styles/tokens/primitives.css +0 -129
  249. package/src/styles/tokens/semantic.css +0 -51
  250. package/src/svg.d.ts +0 -4
  251. package/src/types/assets.d.ts +0 -1
  252. package/src/types/custom-elements.d.ts +0 -104
  253. package/tsconfig.json +0 -22
  254. package/vite.config.ts +0 -260
  255. package/vitest.config.ts +0 -40
  256. package/vitest.setup.ts +0 -16
@@ -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";