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