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

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,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";