@onepercentio/one-ui 0.28.7 → 0.28.9

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 (278) hide show
  1. package/package.json +8 -5
  2. package/src/assets/img/svg/checkbox.svg +3 -0
  3. package/src/assets/styles/index.scss +2 -0
  4. package/src/assets/styles/mixins.scss +12 -0
  5. package/src/assets/styles/variables.scss +49 -0
  6. package/src/components/AdaptiveButton/AdaptiveButton.module.scss +7 -0
  7. package/src/components/AdaptiveButton/AdaptiveButton.tsx +26 -0
  8. package/src/components/AdaptiveButton/index.tsx +1 -0
  9. package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +53 -0
  10. package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +200 -0
  11. package/src/components/AdaptiveContainer/index.tsx +1 -0
  12. package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +147 -0
  13. package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +97 -0
  14. package/src/components/AdaptiveDialog/index.tsx +1 -0
  15. package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +49 -0
  16. package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +10 -0
  17. package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +123 -0
  18. package/src/components/AdaptiveSidebar/index.tsx +1 -0
  19. package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +64 -0
  20. package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +250 -0
  21. package/src/components/AnchoredTooltip/index.tsx +1 -0
  22. package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +108 -0
  23. package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +227 -0
  24. package/src/components/AnimatedEntrance/index.tsx +5 -0
  25. package/src/components/AsyncWrapper/AsyncWrapper.tsx +38 -0
  26. package/src/components/AsyncWrapper/index.tsx +1 -0
  27. package/src/components/Avatar/Avatar.module.scss +22 -0
  28. package/src/components/Avatar/Avatar.tsx +31 -0
  29. package/src/components/Avatar/index.tsx +1 -0
  30. package/src/components/BucketFill/BucketFill.module.scss +36 -0
  31. package/src/components/BucketFill/BucketFill.tsx +65 -0
  32. package/src/components/BucketFill/index.tsx +1 -0
  33. package/src/components/Button/Button.module.scss +45 -0
  34. package/src/components/Button/Button.tsx +40 -0
  35. package/src/components/Button/index.tsx +1 -0
  36. package/src/components/Card/Card.module.scss +12 -0
  37. package/src/components/Card/Card.tsx +9 -0
  38. package/src/components/Card/index.tsx +1 -0
  39. package/src/components/Chart/Chart.e2e.ts +4 -0
  40. package/src/components/Chart/Chart.logic.tsx +8 -0
  41. package/src/components/Chart/Chart.module.scss +58 -0
  42. package/src/components/Chart/Chart.types.ts +35 -0
  43. package/src/components/Chart/Chart.view.tsx +240 -0
  44. package/src/components/Chart/index.tsx +1 -0
  45. package/src/components/CheckBox/CheckBox.module.scss +36 -0
  46. package/src/components/CheckBox/CheckBox.tsx +63 -0
  47. package/src/components/CheckBox/index.tsx +1 -0
  48. package/src/components/CodeInput/CodeInput.module.scss +5 -0
  49. package/src/components/CodeInput/CodeInput.tsx +84 -0
  50. package/src/components/CodeInput/index.tsx +1 -0
  51. package/src/components/Collapsable/Collapsable.module.scss +42 -0
  52. package/src/components/Collapsable/Collapsable.tsx +253 -0
  53. package/src/components/Collapsable/index.tsx +1 -0
  54. package/src/components/Countdown/Countdown.tsx +130 -0
  55. package/src/components/Countdown/index.tsx +1 -0
  56. package/src/components/CurrencyInput/CurrencyInput.hook.ts +37 -0
  57. package/src/components/CurrencyInput/CurrencyInput.tsx +25 -0
  58. package/src/components/CurrencyInput/index.tsx +1 -0
  59. package/src/components/Divider/Divider.module.scss +7 -0
  60. package/src/components/Divider/Divider.tsx +13 -0
  61. package/src/components/Divider/index.tsx +1 -0
  62. package/src/components/EmailInput/EmailInput.module.scss +0 -0
  63. package/src/components/EmailInput/EmailInput.tsx +51 -0
  64. package/src/components/EmailInput/index.tsx +1 -0
  65. package/src/components/FadeIn/FadeIn.module.scss +9 -0
  66. package/src/components/FadeIn/FadeIn.tsx +77 -0
  67. package/src/components/FadeIn/index.tsx +1 -0
  68. package/src/components/FileInput/FileInput.module.scss +6 -0
  69. package/src/components/FileInput/FileInput.tsx +75 -0
  70. package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +20 -0
  71. package/src/components/FileInput/View/BigFactory/BigFactory.tsx +48 -0
  72. package/src/components/FileInput/View/BigFactory/index.tsx +1 -0
  73. package/src/components/FileInput/View/Compact/Compact.module.scss +68 -0
  74. package/src/components/FileInput/View/Compact/Compact.tsx +151 -0
  75. package/src/components/FileInput/View/Compact/index.tsx +1 -0
  76. package/src/components/FileInput/View/View.types.ts +12 -0
  77. package/src/components/FileInput/index.tsx +1 -0
  78. package/src/components/FlowController/FlowController.module.scss +47 -0
  79. package/src/components/FlowController/FlowController.tsx +93 -0
  80. package/src/components/FlowController/index.tsx +1 -0
  81. package/src/components/Form/Form.tsx +243 -0
  82. package/src/components/Form/index.ts +1 -0
  83. package/src/components/Form/v2/Form.hook.ts +341 -0
  84. package/src/components/Form/v2/Form.module.scss +0 -0
  85. package/src/components/Form/v2/Form.tsx +78 -0
  86. package/src/components/Form/v2/Form.types.ts +118 -0
  87. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
  88. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +73 -0
  89. package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +1 -0
  90. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
  91. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +91 -0
  92. package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +1 -0
  93. package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
  94. package/src/components/Form/v2/FormField/FormField.tsx +378 -0
  95. package/src/components/Form/v2/FormField/FormField.types.ts +129 -0
  96. package/src/components/Form/v2/FormField/index.tsx +1 -0
  97. package/src/components/Form/v2/index.tsx +1 -0
  98. package/src/components/Freeze/Freeze.tsx +9 -0
  99. package/src/components/Freeze/index.tsx +1 -0
  100. package/src/components/HSForms/HSForms.tsx +57 -0
  101. package/src/components/HSForms/index.tsx +1 -0
  102. package/src/components/Header/Header.module.scss +119 -0
  103. package/src/components/Header/Header.tsx +138 -0
  104. package/src/components/Header/index.tsx +1 -0
  105. package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +44 -0
  106. package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +28 -0
  107. package/src/components/HeaderCloseBtn/index.tsx +1 -0
  108. package/src/components/InfinityScroll/InfinityScroll.module.scss +30 -0
  109. package/src/components/InfinityScroll/InfinityScroll.tsx +187 -0
  110. package/src/components/InfinityScroll/index.tsx +1 -0
  111. package/src/components/Input/Input.module.scss +71 -0
  112. package/src/components/Input/Input.tsx +134 -0
  113. package/src/components/Input/index.tsx +1 -0
  114. package/src/components/InstantCounter/InstantCounter.tsx +77 -0
  115. package/src/components/InstantCounter/index.tsx +1 -0
  116. package/src/components/LavaLamp/LavaLamp.data.tsx +114 -0
  117. package/src/components/LavaLamp/LavaLamp.module.scss +26 -0
  118. package/src/components/LavaLamp/LavaLamp.tsx +131 -0
  119. package/src/components/LavaLamp/index.tsx +1 -0
  120. package/src/components/LavaLamp/v2/LavaLamp.module.scss +23 -0
  121. package/src/components/LavaLamp/v2/LavaLamp.tsx +197 -0
  122. package/src/components/LinkToId/LinkToId.module.scss +4 -0
  123. package/src/components/LinkToId/LinkToId.tsx +51 -0
  124. package/src/components/LinkToId/index.tsx +1 -0
  125. package/src/components/Loader/Loader.module.scss +40 -0
  126. package/src/components/Loader/Loader.tsx +18 -0
  127. package/src/components/Loader/index.tsx +1 -0
  128. package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +34 -0
  129. package/src/components/LoaderDotsIndicator/index.tsx +1 -0
  130. package/src/components/LoopableVideo/LoopableVideo.tsx +37 -0
  131. package/src/components/LoopableVideo/index.tsx +1 -0
  132. package/src/components/MainGrid/MainGrid.module.scss +28 -0
  133. package/src/components/MainGrid/MainGrid.tsx +68 -0
  134. package/src/components/MainGrid/index.tsx +1 -0
  135. package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +220 -0
  136. package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +38 -0
  137. package/src/components/MutableHamburgerButton/index.tsx +1 -0
  138. package/src/components/Notification/Notification.module.scss +25 -0
  139. package/src/components/Notification/Notification.tsx +13 -0
  140. package/src/components/Notification/index.tsx +1 -0
  141. package/src/components/OrderableList/OrderableList.module.scss +98 -0
  142. package/src/components/OrderableList/OrderableList.tsx +564 -0
  143. package/src/components/OrderableList/index.tsx +1 -0
  144. package/src/components/PaginationIndicator/PaginationIndicator.tsx +365 -0
  145. package/src/components/PaginationIndicator/index.tsx +1 -0
  146. package/src/components/Parallax/Parallax.module.scss +28 -0
  147. package/src/components/Parallax/Parallax.tsx +248 -0
  148. package/src/components/Parallax/index.tsx +1 -0
  149. package/src/components/Parallax/math/helpers.ts +289 -0
  150. package/src/components/PasswordInput/PasswordInput.module.scss +17 -0
  151. package/src/components/PasswordInput/PasswordInput.tsx +154 -0
  152. package/src/components/PasswordInput/index.tsx +1 -0
  153. package/src/components/PingPongText/PingPongText.module.scss +4 -0
  154. package/src/components/PingPongText/PingPongText.tsx +83 -0
  155. package/src/components/PingPongText/index.tsx +1 -0
  156. package/src/components/PixelatedScan/PixelatedScan.module.scss +86 -0
  157. package/src/components/PixelatedScan/PixelatedScan.tsx +175 -0
  158. package/src/components/PixelatedScan/index.tsx +1 -0
  159. package/src/components/Portal/Portal.module.scss +3 -0
  160. package/src/components/Portal/Portal.tsx +68 -0
  161. package/src/components/Portal/index.tsx +1 -0
  162. package/src/components/ProgressBar/ProgressBar.module.scss +44 -0
  163. package/src/components/ProgressBar/ProgressBar.tsx +124 -0
  164. package/src/components/ProgressBar/index.tsx +1 -0
  165. package/src/components/ProgressTexts/ProgressTexts.module.scss +37 -0
  166. package/src/components/ProgressTexts/ProgressTexts.tsx +85 -0
  167. package/src/components/ProgressTexts/index.tsx +1 -0
  168. package/src/components/Radio/Radio.module.scss +36 -0
  169. package/src/components/Radio/Radio.tsx +53 -0
  170. package/src/components/Radio/index.tsx +1 -0
  171. package/src/components/SectionContainer/SectionContainer.module.scss +30 -0
  172. package/src/components/SectionContainer/SectionContainer.tsx +49 -0
  173. package/src/components/SectionContainer/index.tsx +1 -0
  174. package/src/components/Select/Select.module.scss +58 -0
  175. package/src/components/Select/Select.tsx +192 -0
  176. package/src/components/Select/index.tsx +1 -0
  177. package/src/components/Skeleton/Skeleton.module.scss +21 -0
  178. package/src/components/Skeleton/Skeleton.tsx +29 -0
  179. package/src/components/Skeleton/index.tsx +1 -0
  180. package/src/components/Spacing/Spacing.module.scss +13 -0
  181. package/src/components/Spacing/Spacing.tsx +24 -0
  182. package/src/components/Spacing/index.tsx +1 -0
  183. package/src/components/StaticScroller/StaticScroller.module.scss +14 -0
  184. package/src/components/StaticScroller/StaticScroller.tsx +83 -0
  185. package/src/components/StaticScroller/index.tsx +1 -0
  186. package/src/components/Switch/Switch.module.scss +43 -0
  187. package/src/components/Switch/Switch.tsx +41 -0
  188. package/src/components/Switch/index.tsx +1 -0
  189. package/src/components/Table/Table.module.scss +76 -0
  190. package/src/components/Table/Table.tsx +152 -0
  191. package/src/components/Table/index.tsx +1 -0
  192. package/src/components/Tabs/Tabs.module.scss +40 -0
  193. package/src/components/Tabs/Tabs.tsx +104 -0
  194. package/src/components/Tabs/index.tsx +1 -0
  195. package/src/components/Text/Text.module.scss +81 -0
  196. package/src/components/Text/Text.tsx +42 -0
  197. package/src/components/Text/index.tsx +1 -0
  198. package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +47 -0
  199. package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +78 -0
  200. package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +106 -0
  201. package/src/components/Transition/MasksFactory/SquareToBalls.tsx +66 -0
  202. package/src/components/Transition/MasksFactory/utils.ts +35 -0
  203. package/src/components/Transition/Transition.module.scss +211 -0
  204. package/src/components/Transition/Transition.tsx +495 -0
  205. package/src/components/Transition/index.tsx +1 -0
  206. package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +9 -0
  207. package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +34 -0
  208. package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +143 -0
  209. package/src/components/UncontrolledTransition/index.tsx +2 -0
  210. package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +212 -0
  211. package/src/components/WalletConnectionWrapper/index.tsx +1 -0
  212. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +5 -0
  213. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +52 -0
  214. package/src/components/utilitary/ScrollAndFocusLock/index.tsx +1 -0
  215. package/src/context/AsyncProcess.tsx +107 -0
  216. package/src/context/ContextAsyncControl.tsx +89 -0
  217. package/src/context/CustomBrowserRouter.tsx +55 -0
  218. package/src/context/OneUIProvider.tsx +308 -0
  219. package/src/hooks/logs/useDependencyChangeDetection.ts +25 -0
  220. package/src/hooks/logs/useIsMounting.ts +7 -0
  221. package/src/hooks/persistence/useLocalStorage.ts +45 -0
  222. package/src/hooks/shims/ObjectWatchShim.ts +56 -0
  223. package/src/hooks/ui/useAdaptiveImage.tsx +36 -0
  224. package/src/hooks/ui/useAlternating.tsx +22 -0
  225. package/src/hooks/ui/useBreakpoint.tsx +21 -0
  226. package/src/hooks/ui/useCustomScrollbar.module.scss +20 -0
  227. package/src/hooks/ui/useCustomScrollbar.tsx +22 -0
  228. package/src/hooks/ui/useEffectIf.ts +11 -0
  229. package/src/hooks/ui/useMouseHover.tsx +26 -0
  230. package/src/hooks/ui/usePaginationControls.module.scss +16 -0
  231. package/src/hooks/ui/usePaginationControls.tsx +176 -0
  232. package/src/hooks/ui/useSnapToViewport.module.scss +6 -0
  233. package/src/hooks/ui/useSnapToViewport.ts +28 -0
  234. package/src/hooks/ui/useTilt.tsx +219 -0
  235. package/src/hooks/ui/useZoomable.module.scss +34 -0
  236. package/src/hooks/ui/useZoomable.tsx +144 -0
  237. package/src/hooks/useAsyncControl.ai.md +25 -0
  238. package/src/hooks/useAsyncControl.ts +101 -0
  239. package/src/hooks/useContainedRepositioning.ts +110 -0
  240. package/src/hooks/useCustomHistory.ts +14 -0
  241. package/src/hooks/useElementFit.ts +82 -0
  242. package/src/hooks/useFirestoreWatch.ts +54 -0
  243. package/src/hooks/useForm.ts +49 -0
  244. package/src/hooks/useFreeze.ts +12 -0
  245. package/src/hooks/useHero.module.scss +41 -0
  246. package/src/hooks/useHero.ts +512 -0
  247. package/src/hooks/useIntersection.ts +32 -0
  248. package/src/hooks/useMergeRefs.ts +29 -0
  249. package/src/hooks/useObserve.ts +24 -0
  250. package/src/hooks/usePagination.ts +228 -0
  251. package/src/hooks/usePooledOperation.ts +54 -0
  252. package/src/hooks/usePooling.ts +46 -0
  253. package/src/hooks/useRebound.ts +23 -0
  254. package/src/hooks/useShortIntl.ai.md +5 -0
  255. package/src/hooks/useShortIntl.ts +97 -0
  256. package/src/hooks/utility/useAsyncMemo.ts +43 -0
  257. package/src/hooks/utility/useDepChange.ts +11 -0
  258. package/src/hooks/utility/useEvents.ts +33 -0
  259. package/src/hooks/utility/useImmediate.ts +8 -0
  260. package/src/hooks/utility/useManualInit.ts +24 -0
  261. package/src/hooks/utility/useModule.ts +15 -0
  262. package/src/hooks/utility/useQuery.ts +15 -0
  263. package/src/hooks/utility/useUniqueEffect.ts +22 -0
  264. package/src/index.ts +3 -0
  265. package/src/models/DebugLogger.ts +7 -0
  266. package/src/models/GenericContract.ts +169 -0
  267. package/src/models/Orbs.ts +97 -0
  268. package/src/reac-app-env.d.ts +6 -0
  269. package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
  270. package/src/storybookUtils/index.tsx +53 -0
  271. package/src/type-utils.ts +49 -0
  272. package/src/utility.d.ts +70 -0
  273. package/src/utils/blockchain.ts +43 -0
  274. package/src/utils/flatten.ts +17 -0
  275. package/src/utils/formatters.ts +36 -0
  276. package/src/utils/html.utils.ts +3 -0
  277. package/src/utils/ownEvent.ts +8 -0
  278. package/src/utils/test.ts +19 -0
@@ -0,0 +1,289 @@
1
+ export type Matrix3D = [
2
+ [number, number, number, number],
3
+ [number, number, number, number],
4
+ [number, number, number, number],
5
+ [number, number, number, number]
6
+ ];
7
+ export type OperationData =
8
+ | {
9
+ type: "rotateX" | "rotateY" | "rotateZ";
10
+ angle: number;
11
+ }
12
+ | {
13
+ type: "translate";
14
+ x: number;
15
+ y: number;
16
+ z: number;
17
+ }
18
+ | {
19
+ type: "scale";
20
+ factorX: number;
21
+ factorY: number;
22
+ factorZ: number;
23
+ }
24
+ | {
25
+ type: "perspective";
26
+ fieldOfViewInRadians: number;
27
+ aspect: number;
28
+ near: number;
29
+ far: number;
30
+ }
31
+ | {
32
+ type: "matrix";
33
+ matrix: Matrix3D;
34
+ };
35
+ export function IDENTITY_MATRIX() {
36
+ return [
37
+ [1, 0, 0, 0], // cos, -sin, ?
38
+ [0, 1, 0, 0], // sin, cos, ?
39
+ [0, 0, 1, 0], // TranslationX, TranslationY, ?
40
+ [0, 0, 0, 1],
41
+ ] as Matrix3D;
42
+ }
43
+ export function generateMatrixFromOperations(
44
+ ...operations: OperationData[]
45
+ ): Matrix3D {
46
+ let resultingMatrix: Matrix3D | undefined = undefined;
47
+ for (let operation of operations) {
48
+ const matrix =
49
+ operation.type === "matrix" ? operation.matrix : IDENTITY_MATRIX();
50
+ switch (operation.type) {
51
+ case "perspective":
52
+ const f = Math.tan(
53
+ Math.PI * 0.5 - 0.5 * operation.fieldOfViewInRadians
54
+ );
55
+ const rangeInv = 1.0 / (operation.near - operation.far);
56
+
57
+ matrix[0][0] = f / operation.aspect;
58
+ matrix[1][1] = f;
59
+ matrix[2][2] = (operation.near + operation.far) * rangeInv;
60
+ matrix[2][3] = -1;
61
+ matrix[3][2] = operation.near * operation.far * rangeInv * 2;
62
+ matrix[3][3] = 0;
63
+ break;
64
+ case "translate":
65
+ matrix[3][0] = operation.x;
66
+ matrix[3][1] = operation.y;
67
+ matrix[3][2] = operation.z;
68
+ break;
69
+ case "rotateX":
70
+ case "rotateY":
71
+ case "rotateZ":
72
+ const angleToRadians = (operation.angle * Math.PI) / 180;
73
+ const sinAngle = Math.sin(angleToRadians);
74
+ const cosAngle = Math.cos(angleToRadians);
75
+ switch (operation.type) {
76
+ case "rotateZ":
77
+ matrix[0][0] = cosAngle;
78
+ matrix[1][1] = cosAngle;
79
+ matrix[1][0] = -sinAngle;
80
+ matrix[0][1] = sinAngle;
81
+ break;
82
+ case "rotateY":
83
+ matrix[0][0] = cosAngle;
84
+ matrix[2][2] = cosAngle;
85
+ matrix[0][2] = -sinAngle;
86
+ matrix[2][0] = sinAngle;
87
+ break;
88
+ case "rotateX":
89
+ matrix[1][1] = cosAngle;
90
+ matrix[2][2] = cosAngle;
91
+ matrix[2][1] = -sinAngle;
92
+ matrix[1][2] = sinAngle;
93
+ break;
94
+ }
95
+ break;
96
+ case "scale":
97
+ matrix[0][0] = operation.factorX;
98
+ matrix[1][1] = operation.factorY;
99
+ matrix[2][2] = operation.factorZ;
100
+ break;
101
+ }
102
+ if (resultingMatrix) {
103
+ resultingMatrix = multiplyMatrixes(resultingMatrix, matrix) as Matrix3D;
104
+ } else {
105
+ resultingMatrix = matrix;
106
+ }
107
+ }
108
+
109
+ return resultingMatrix || IDENTITY_MATRIX();
110
+ }
111
+
112
+ type NumberMatrix = readonly (readonly number[])[];
113
+ export function multiplyMatrixes<X extends NumberMatrix>(
114
+ matrix1: X,
115
+ matrix2: NumberMatrix & { length: X[number]["length"] }
116
+ ) {
117
+ const resultingMatrix: number[][] = [];
118
+ if (
119
+ process.env.NODE_ENV === "development" &&
120
+ matrix2.length !== matrix1[0].length
121
+ ) {
122
+ throw new Error(`For the multiplication of matrixes to work you need to provide the matrix1 containing the amount of columns as the same amount of rows from matrix 2.
123
+ You provided ${matrix1[0].length} columns and ${matrix2.length} rows`);
124
+ }
125
+ for (let i0 in matrix1) {
126
+ for (let i in matrix2[0]) {
127
+ let dimensionResult = 0;
128
+ for (let i2 in matrix1[0]) {
129
+ dimensionResult += matrix1[i0][i2] * matrix2[i2][i];
130
+ }
131
+ if (!resultingMatrix[i0]) resultingMatrix[i0] = [];
132
+ resultingMatrix[i0][i] = dimensionResult;
133
+ }
134
+ }
135
+ return resultingMatrix;
136
+ }
137
+
138
+ export function invertMatrix(matrix: Matrix3D) {
139
+ const m = flattenMatrix(matrix);
140
+ let det: number = 0;
141
+ const inv = [];
142
+
143
+ inv[0] =
144
+ m[5] * m[10] * m[15] -
145
+ m[5] * m[11] * m[14] -
146
+ m[9] * m[6] * m[15] +
147
+ m[9] * m[7] * m[14] +
148
+ m[13] * m[6] * m[11] -
149
+ m[13] * m[7] * m[10];
150
+
151
+ inv[4] =
152
+ -m[4] * m[10] * m[15] +
153
+ m[4] * m[11] * m[14] +
154
+ m[8] * m[6] * m[15] -
155
+ m[8] * m[7] * m[14] -
156
+ m[12] * m[6] * m[11] +
157
+ m[12] * m[7] * m[10];
158
+
159
+ inv[8] =
160
+ m[4] * m[9] * m[15] -
161
+ m[4] * m[11] * m[13] -
162
+ m[8] * m[5] * m[15] +
163
+ m[8] * m[7] * m[13] +
164
+ m[12] * m[5] * m[11] -
165
+ m[12] * m[7] * m[9];
166
+
167
+ inv[12] =
168
+ -m[4] * m[9] * m[14] +
169
+ m[4] * m[10] * m[13] +
170
+ m[8] * m[5] * m[14] -
171
+ m[8] * m[6] * m[13] -
172
+ m[12] * m[5] * m[10] +
173
+ m[12] * m[6] * m[9];
174
+
175
+ inv[1] =
176
+ -m[1] * m[10] * m[15] +
177
+ m[1] * m[11] * m[14] +
178
+ m[9] * m[2] * m[15] -
179
+ m[9] * m[3] * m[14] -
180
+ m[13] * m[2] * m[11] +
181
+ m[13] * m[3] * m[10];
182
+
183
+ inv[5] =
184
+ m[0] * m[10] * m[15] -
185
+ m[0] * m[11] * m[14] -
186
+ m[8] * m[2] * m[15] +
187
+ m[8] * m[3] * m[14] +
188
+ m[12] * m[2] * m[11] -
189
+ m[12] * m[3] * m[10];
190
+
191
+ inv[9] =
192
+ -m[0] * m[9] * m[15] +
193
+ m[0] * m[11] * m[13] +
194
+ m[8] * m[1] * m[15] -
195
+ m[8] * m[3] * m[13] -
196
+ m[12] * m[1] * m[11] +
197
+ m[12] * m[3] * m[9];
198
+
199
+ inv[13] =
200
+ m[0] * m[9] * m[14] -
201
+ m[0] * m[10] * m[13] -
202
+ m[8] * m[1] * m[14] +
203
+ m[8] * m[2] * m[13] +
204
+ m[12] * m[1] * m[10] -
205
+ m[12] * m[2] * m[9];
206
+
207
+ inv[2] =
208
+ m[1] * m[6] * m[15] -
209
+ m[1] * m[7] * m[14] -
210
+ m[5] * m[2] * m[15] +
211
+ m[5] * m[3] * m[14] +
212
+ m[13] * m[2] * m[7] -
213
+ m[13] * m[3] * m[6];
214
+
215
+ inv[6] =
216
+ -m[0] * m[6] * m[15] +
217
+ m[0] * m[7] * m[14] +
218
+ m[4] * m[2] * m[15] -
219
+ m[4] * m[3] * m[14] -
220
+ m[12] * m[2] * m[7] +
221
+ m[12] * m[3] * m[6];
222
+
223
+ inv[10] =
224
+ m[0] * m[5] * m[15] -
225
+ m[0] * m[7] * m[13] -
226
+ m[4] * m[1] * m[15] +
227
+ m[4] * m[3] * m[13] +
228
+ m[12] * m[1] * m[7] -
229
+ m[12] * m[3] * m[5];
230
+
231
+ inv[14] =
232
+ -m[0] * m[5] * m[14] +
233
+ m[0] * m[6] * m[13] +
234
+ m[4] * m[1] * m[14] -
235
+ m[4] * m[2] * m[13] -
236
+ m[12] * m[1] * m[6] +
237
+ m[12] * m[2] * m[5];
238
+
239
+ inv[3] =
240
+ -m[1] * m[6] * m[11] +
241
+ m[1] * m[7] * m[10] +
242
+ m[5] * m[2] * m[11] -
243
+ m[5] * m[3] * m[10] -
244
+ m[9] * m[2] * m[7] +
245
+ m[9] * m[3] * m[6];
246
+
247
+ inv[7] =
248
+ m[0] * m[6] * m[11] -
249
+ m[0] * m[7] * m[10] -
250
+ m[4] * m[2] * m[11] +
251
+ m[4] * m[3] * m[10] +
252
+ m[8] * m[2] * m[7] -
253
+ m[8] * m[3] * m[6];
254
+
255
+ inv[11] =
256
+ -m[0] * m[5] * m[11] +
257
+ m[0] * m[7] * m[9] +
258
+ m[4] * m[1] * m[11] -
259
+ m[4] * m[3] * m[9] -
260
+ m[8] * m[1] * m[7] +
261
+ m[8] * m[3] * m[5];
262
+
263
+ inv[15] =
264
+ m[0] * m[5] * m[10] -
265
+ m[0] * m[6] * m[9] -
266
+ m[4] * m[1] * m[10] +
267
+ m[4] * m[2] * m[9] +
268
+ m[8] * m[1] * m[6] -
269
+ m[8] * m[2] * m[5];
270
+
271
+ det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
272
+
273
+ if (det === 0)
274
+ throw new Error(
275
+ "Determinator is equal to 0. This matrix cannot be inverted"
276
+ );
277
+
278
+ det = 1.0 / det;
279
+
280
+ return inv.reduce((r, val, i) => {
281
+ const row = Math.floor(i / 4);
282
+ if (!r[row]) r[row] = [];
283
+ r[row][i % 4] = val * det;
284
+ return r;
285
+ }, [] as number[][]) as Matrix3D;
286
+ }
287
+ export function flattenMatrix(matrix: number[][]) {
288
+ return matrix.reduce((f, dimension) => [...f, ...dimension], [] as number[]);
289
+ }
@@ -0,0 +1,17 @@
1
+ .inputContainer {
2
+ &.creation {
3
+ padding-bottom: 54px;
4
+ }
5
+ position: relative;
6
+
7
+ .rules {
8
+ position: absolute;
9
+ bottom: 0px;
10
+ }
11
+
12
+ &.icon > :first-child > :last-child {
13
+ top: initial;
14
+ align-self: center;
15
+ margin-top: -18px;
16
+ }
17
+ }
@@ -0,0 +1,154 @@
1
+ import React, {
2
+ ChangeEvent,
3
+ ForwardedRef,
4
+ forwardRef,
5
+ useImperativeHandle,
6
+ useState,
7
+ } from "react";
8
+ import { useOneUIConfig } from "../../context/OneUIProvider";
9
+ import Input from "../Input";
10
+ import Text from "../Text";
11
+ import Styles from "./PasswordInput.module.scss";
12
+
13
+ export type AVAILABLE_PASSWORD_VALIDATION_RULES = "size" | "duplication";
14
+
15
+ const BASE_VALIDATION = [
16
+ { code: "size", validate: (pass: string) => pass.length >= 8 },
17
+ ] as const;
18
+ const RULES = [
19
+ {
20
+ code: "duplication",
21
+ validate: (pass: string) => {
22
+ for (let i = 0; i < pass.length; i++) {
23
+ const charCode = pass.charCodeAt(i);
24
+ const [firstNext, secondNext] = [
25
+ pass.charCodeAt(i + 1) || 0,
26
+ pass.charCodeAt(i + 2) || 0,
27
+ ];
28
+
29
+ if (firstNext - charCode === 1 && secondNext - firstNext === 1) {
30
+ return false;
31
+ }
32
+ }
33
+ return true;
34
+ },
35
+ },
36
+ ...BASE_VALIDATION,
37
+ ] as const;
38
+
39
+ function _PasswordInput(
40
+ props: ({
41
+ value: string;
42
+ error?: string;
43
+ } & (
44
+ | {
45
+ mode: "input";
46
+ onChange: (password: string) => void;
47
+ }
48
+ | {
49
+ mode: "creation";
50
+ onChange: (password: string, isValid: boolean) => void;
51
+ messages: {
52
+ invalidRules: { [r in AVAILABLE_PASSWORD_VALIDATION_RULES]: string };
53
+ rulesTitle: string;
54
+ };
55
+ }
56
+ | {
57
+ mode: "comparision";
58
+ otherPassword: string;
59
+ onChange: (password: string, isEqual: boolean) => void;
60
+ messages: {
61
+ passwordsAreDifferent: string;
62
+ };
63
+ }
64
+ )) &
65
+ Omit<React.ComponentProps<typeof Input>, "value" | "onChange" | "ref">,
66
+ ref: ForwardedRef<{ validatePassword: (pass: string) => boolean }>
67
+ ) {
68
+ const [isPasswordVisibile, setIPV] = useState(false);
69
+ const { passwordHidden, passwordVisible } = useOneUIConfig(
70
+ "component.passwordInput.iconSrc"
71
+ );
72
+ function _validatePassword(password: string) {
73
+ switch (props.mode) {
74
+ case "creation":
75
+ return RULES.reduce(
76
+ (isValid, R) => isValid && R.validate(password),
77
+ true as boolean
78
+ );
79
+ case "comparision":
80
+ return password === props.otherPassword;
81
+ case "input":
82
+ return BASE_VALIDATION.reduce(
83
+ (isValid, R) => isValid && R.validate(password),
84
+ true as boolean
85
+ );
86
+ }
87
+ }
88
+
89
+ useImperativeHandle(ref, () => ({
90
+ validatePassword: (pass) => _validatePassword(pass),
91
+ }));
92
+
93
+ function _onChange(e: ChangeEvent<HTMLInputElement>) {
94
+ const password = e.target.value;
95
+ switch (props.mode) {
96
+ case "comparision":
97
+ case "creation":
98
+ props.onChange(password, _validatePassword(password));
99
+ break;
100
+ case "input":
101
+ props.onChange(password);
102
+ break;
103
+ }
104
+ }
105
+
106
+ return (
107
+ <div
108
+ className={`${Styles.inputContainer} ${Styles[props.mode]} ${
109
+ Styles.icon
110
+ }`}
111
+ >
112
+ <Input
113
+ value={props.value}
114
+ onChange={_onChange}
115
+ type={!isPasswordVisibile ? "password" : ""}
116
+ icon={{
117
+ src: isPasswordVisibile ? passwordHidden : passwordVisible,
118
+ onMouseLeave: () => setIPV(false),
119
+ onMouseDown: () => setIPV(true),
120
+ onMouseUp: () => setIPV(false),
121
+ onTouchMove: () => setIPV(false),
122
+ onTouchStart: () => setIPV(true),
123
+ onTouchEnd: () => setIPV(false),
124
+ }}
125
+ error={
126
+ props.mode === "comparision" && !_validatePassword(props.value)
127
+ ? props.messages.passwordsAreDifferent
128
+ : props.error
129
+ }
130
+ disabled={props.disabled}
131
+ placeholder={props.placeholder}
132
+ />
133
+ {props.mode === "creation" && (
134
+ <div className={Styles.rules} data-testid="password-rules">
135
+ <Text type="caption">{props.messages.rulesTitle}</Text>
136
+ {RULES.map((R) => (
137
+ <Text
138
+ key={R.code}
139
+ type={R.validate(props.value) ? "caption" : "error"}
140
+ >
141
+ - {props.messages.invalidRules[R.code]}
142
+ </Text>
143
+ ))}
144
+ </div>
145
+ )}
146
+ </div>
147
+ );
148
+ }
149
+
150
+ /**
151
+ * A Input based wrapper to handle inputing of password
152
+ **/
153
+ const PasswordInput = forwardRef(_PasswordInput);
154
+ export default PasswordInput;
@@ -0,0 +1 @@
1
+ export { default } from './PasswordInput';
@@ -0,0 +1,4 @@
1
+ .pingPong {
2
+ width: 100%;
3
+ overflow: hidden;
4
+ }
@@ -0,0 +1,83 @@
1
+ import React, {
2
+ ComponentProps,
3
+ PropsWithChildren,
4
+ useEffect,
5
+ useRef,
6
+ } from "react";
7
+ import Text from "../Text/Text";
8
+ import Styles from "./PingPongText.module.scss";
9
+ import useMouseHover from "../../hooks/ui/useMouseHover";
10
+
11
+ const HOW_MUCH_PIXELS_TO_SCROLL_PER_SECOND = 50;
12
+ const RIGHT_TEXT_MULTIPLIER = 5;
13
+
14
+ /**
15
+ * A component that keeps an overflow piece of text visible by continously scrolling it back and forward
16
+ **/
17
+ export default function PingPongText({
18
+ ...props
19
+ }: ComponentProps<typeof Text>) {
20
+ const textRef = useRef<HTMLParagraphElement>(null);
21
+ const { uiEvents, hovering } = useMouseHover();
22
+
23
+ useEffect(() => {
24
+ if (!hovering) {
25
+ let scrollingInterval: NodeJS.Timeout;
26
+ let scrollStartTimeout: NodeJS.Timeout;
27
+ scrollStartTimeout = setTimeout(() => {
28
+ const textEl = textRef.current;
29
+ if (!textEl) return;
30
+ const overflowWidth = textEl.scrollWidth;
31
+ const viewWidth = textEl.clientWidth;
32
+ const secondsPerFrame = 1000 / 60;
33
+ const howMuchToMove =
34
+ (secondsPerFrame * HOW_MUCH_PIXELS_TO_SCROLL_PER_SECOND) / 1000;
35
+
36
+ if (overflowWidth > viewWidth) {
37
+ scrollingInterval = scrollText();
38
+ function scrollText(direction: "l" | "r" = "r") {
39
+ return setInterval(() => {
40
+ const reachedEnd =
41
+ direction === "r"
42
+ ? textEl!.scrollLeft >= overflowWidth - viewWidth
43
+ : textEl!.scrollLeft === 0;
44
+ if (reachedEnd) {
45
+ clearInterval(scrollingInterval);
46
+ scrollStartTimeout = setTimeout(
47
+ () => {
48
+ scrollingInterval = scrollText(
49
+ direction === "r" ? "l" : "r"
50
+ );
51
+ },
52
+ direction === "r" ? 2000 : 1000
53
+ );
54
+ } else {
55
+ if (direction === "r")
56
+ textEl!.scrollTo(textEl!.scrollLeft + howMuchToMove, 0);
57
+ else {
58
+ textEl!.scrollTo(
59
+ textEl!.scrollLeft - howMuchToMove * RIGHT_TEXT_MULTIPLIER,
60
+ 0
61
+ );
62
+ }
63
+ }
64
+ }, secondsPerFrame);
65
+ }
66
+ }
67
+ }, 1000);
68
+ return () => {
69
+ clearTimeout(scrollStartTimeout);
70
+ clearInterval(scrollingInterval);
71
+ };
72
+ }
73
+ }, [hovering]);
74
+
75
+ return (
76
+ <Text
77
+ ref={textRef}
78
+ {...(uiEvents as any)}
79
+ {...props}
80
+ className={`${Styles.pingPong} ${props.className || ""}`}
81
+ />
82
+ );
83
+ }
@@ -0,0 +1 @@
1
+ export { default } from './PingPongText';
@@ -0,0 +1,86 @@
1
+ @import "../../assets/styles/index.scss";
2
+
3
+ $animationDurationMs: 2000;
4
+
5
+ @value animationDuration #{$animationDurationMs};
6
+
7
+ $animationDuration: #{$animationDurationMs}ms;
8
+
9
+ .guide {
10
+ width: 100%;
11
+ position: absolute;
12
+ animation-duration: $animationDuration;
13
+ display: flex;
14
+ flex-direction: column;
15
+ justify-content: flex-end;
16
+ animation-fill-mode: forwards;
17
+ animation-timing-function: linear;
18
+ min-height: 10px;
19
+ top: 0;
20
+ &::after {
21
+ content: " ";
22
+ width: 100%;
23
+ height: 10px;
24
+ background: $pixelatedGuideBackground;
25
+ }
26
+ }
27
+
28
+ .grid {
29
+ position: absolute;
30
+ top: 0px;
31
+ right: 0px;
32
+ left: 0px;
33
+ bottom: 0px;
34
+ overflow: hidden;
35
+ > * {
36
+ display: flex;
37
+ opacity: 0;
38
+ &.guide {
39
+ opacity: 1;
40
+ }
41
+ }
42
+ &.inverse {
43
+ transform: rotateX(180deg);
44
+ }
45
+ }
46
+
47
+ .gridItem {
48
+ background-color: var(--pixel-color);
49
+ }
50
+
51
+ .gridAnimate {
52
+ animation-duration: #{$animationDurationMs}ms;
53
+ }
54
+
55
+ .iterate {
56
+ .guide {
57
+ animation-name: upAndDown;
58
+ }
59
+ .gridAnimate {
60
+ animation-name: onAndOff;
61
+ will-change: opacity;
62
+ }
63
+ }
64
+
65
+ @keyframes onAndOff {
66
+ 0% {
67
+ opacity: 0;
68
+ }
69
+
70
+ 10% {
71
+ opacity: 1;
72
+ }
73
+
74
+ 100% {
75
+ opacity: 0;
76
+ }
77
+ }
78
+
79
+ @keyframes upAndDown {
80
+ 0% {
81
+ height: 0%;
82
+ }
83
+ 100% {
84
+ height: 100%;
85
+ }
86
+ }