@onepercentio/one-ui 0.29.2 → 0.29.5

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 (289) hide show
  1. package/dist/components/Switch/Switch.d.ts +1 -1
  2. package/dist/components/Switch/Switch.js +1 -1
  3. package/dist/hooks/useHero.js +3 -2
  4. package/dist-ts/components/Switch/Switch.d.ts +1 -1
  5. package/dist-ts/hooks/useHero.js +5 -4
  6. package/dist-ts/hooks/useHero.js.map +1 -1
  7. package/package.json +5 -1
  8. package/src/assets/img/svg/checkbox.svg +0 -3
  9. package/src/assets/styles/index.scss +0 -2
  10. package/src/assets/styles/mixins.scss +0 -12
  11. package/src/assets/styles/variables.scss +0 -49
  12. package/src/components/AdaptiveButton/AdaptiveButton.module.scss +0 -7
  13. package/src/components/AdaptiveButton/AdaptiveButton.tsx +0 -26
  14. package/src/components/AdaptiveButton/index.tsx +0 -2
  15. package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +0 -53
  16. package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +0 -200
  17. package/src/components/AdaptiveContainer/index.tsx +0 -2
  18. package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +0 -147
  19. package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +0 -97
  20. package/src/components/AdaptiveDialog/index.tsx +0 -2
  21. package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +0 -49
  22. package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +0 -10
  23. package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +0 -123
  24. package/src/components/AdaptiveSidebar/index.tsx +0 -2
  25. package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +0 -64
  26. package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +0 -250
  27. package/src/components/AnchoredTooltip/index.tsx +0 -2
  28. package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +0 -108
  29. package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +0 -227
  30. package/src/components/AnimatedEntrance/index.tsx +0 -2
  31. package/src/components/AsyncWrapper/AsyncWrapper.tsx +0 -38
  32. package/src/components/AsyncWrapper/index.tsx +0 -2
  33. package/src/components/Avatar/Avatar.module.scss +0 -22
  34. package/src/components/Avatar/Avatar.tsx +0 -31
  35. package/src/components/Avatar/index.tsx +0 -2
  36. package/src/components/BucketFill/BucketFill.module.scss +0 -36
  37. package/src/components/BucketFill/BucketFill.tsx +0 -65
  38. package/src/components/BucketFill/index.tsx +0 -2
  39. package/src/components/Button/Button.module.scss +0 -45
  40. package/src/components/Button/Button.tsx +0 -40
  41. package/src/components/Button/index.tsx +0 -2
  42. package/src/components/Card/Card.module.scss +0 -12
  43. package/src/components/Card/Card.tsx +0 -9
  44. package/src/components/Card/index.tsx +0 -2
  45. package/src/components/Chart/Chart.e2e.ts +0 -4
  46. package/src/components/Chart/Chart.logic.tsx +0 -8
  47. package/src/components/Chart/Chart.module.scss +0 -58
  48. package/src/components/Chart/Chart.tsx +0 -2
  49. package/src/components/Chart/Chart.types.ts +0 -35
  50. package/src/components/Chart/Chart.view.tsx +0 -241
  51. package/src/components/Chart/index.tsx +0 -2
  52. package/src/components/CheckBox/CheckBox.module.scss +0 -36
  53. package/src/components/CheckBox/CheckBox.tsx +0 -63
  54. package/src/components/CheckBox/index.tsx +0 -2
  55. package/src/components/CodeInput/CodeInput.module.scss +0 -5
  56. package/src/components/CodeInput/CodeInput.tsx +0 -84
  57. package/src/components/CodeInput/index.tsx +0 -2
  58. package/src/components/Collapsable/Collapsable.module.scss +0 -42
  59. package/src/components/Collapsable/Collapsable.tsx +0 -253
  60. package/src/components/Collapsable/index.tsx +0 -2
  61. package/src/components/Countdown/Countdown.tsx +0 -130
  62. package/src/components/Countdown/index.tsx +0 -2
  63. package/src/components/CurrencyInput/CurrencyInput.hook.ts +0 -37
  64. package/src/components/CurrencyInput/CurrencyInput.tsx +0 -25
  65. package/src/components/CurrencyInput/index.tsx +0 -2
  66. package/src/components/Divider/Divider.module.scss +0 -7
  67. package/src/components/Divider/Divider.tsx +0 -13
  68. package/src/components/Divider/index.tsx +0 -2
  69. package/src/components/EmailInput/EmailInput.module.scss +0 -0
  70. package/src/components/EmailInput/EmailInput.tsx +0 -51
  71. package/src/components/EmailInput/index.tsx +0 -2
  72. package/src/components/FadeIn/FadeIn.module.scss +0 -9
  73. package/src/components/FadeIn/FadeIn.tsx +0 -77
  74. package/src/components/FadeIn/index.tsx +0 -2
  75. package/src/components/FileInput/FileInput.module.scss +0 -6
  76. package/src/components/FileInput/FileInput.tsx +0 -75
  77. package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +0 -20
  78. package/src/components/FileInput/View/BigFactory/BigFactory.tsx +0 -48
  79. package/src/components/FileInput/View/BigFactory/index.tsx +0 -2
  80. package/src/components/FileInput/View/Compact/Compact.module.scss +0 -68
  81. package/src/components/FileInput/View/Compact/Compact.tsx +0 -151
  82. package/src/components/FileInput/View/Compact/index.tsx +0 -2
  83. package/src/components/FileInput/View/View.types.ts +0 -12
  84. package/src/components/FileInput/index.tsx +0 -2
  85. package/src/components/FlowController/FlowController.module.scss +0 -47
  86. package/src/components/FlowController/FlowController.tsx +0 -93
  87. package/src/components/FlowController/index.tsx +0 -2
  88. package/src/components/Form/Form.tsx +0 -243
  89. package/src/components/Form/index.ts +0 -2
  90. package/src/components/Form/v2/Form.hook.ts +0 -341
  91. package/src/components/Form/v2/Form.module.scss +0 -0
  92. package/src/components/Form/v2/Form.tsx +0 -78
  93. package/src/components/Form/v2/Form.types.ts +0 -118
  94. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
  95. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +0 -73
  96. package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +0 -2
  97. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
  98. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +0 -91
  99. package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +0 -2
  100. package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
  101. package/src/components/Form/v2/FormField/FormField.tsx +0 -378
  102. package/src/components/Form/v2/FormField/FormField.types.ts +0 -129
  103. package/src/components/Form/v2/FormField/index.tsx +0 -2
  104. package/src/components/Form/v2/index.tsx +0 -2
  105. package/src/components/Freeze/Freeze.tsx +0 -9
  106. package/src/components/Freeze/index.tsx +0 -2
  107. package/src/components/HSForms/HSForms.tsx +0 -57
  108. package/src/components/HSForms/index.tsx +0 -2
  109. package/src/components/Header/Header.module.scss +0 -119
  110. package/src/components/Header/Header.tsx +0 -138
  111. package/src/components/Header/index.tsx +0 -2
  112. package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +0 -44
  113. package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +0 -28
  114. package/src/components/HeaderCloseBtn/index.tsx +0 -2
  115. package/src/components/InfinityScroll/InfinityScroll.module.scss +0 -30
  116. package/src/components/InfinityScroll/InfinityScroll.tsx +0 -187
  117. package/src/components/InfinityScroll/index.tsx +0 -2
  118. package/src/components/Input/Input.module.scss +0 -71
  119. package/src/components/Input/Input.tsx +0 -134
  120. package/src/components/Input/index.tsx +0 -2
  121. package/src/components/InstantCounter/InstantCounter.tsx +0 -77
  122. package/src/components/InstantCounter/index.tsx +0 -2
  123. package/src/components/LavaLamp/LavaLamp.data.tsx +0 -114
  124. package/src/components/LavaLamp/LavaLamp.module.scss +0 -26
  125. package/src/components/LavaLamp/LavaLamp.tsx +0 -131
  126. package/src/components/LavaLamp/index.tsx +0 -2
  127. package/src/components/LavaLamp/v2/LavaLamp.module.scss +0 -23
  128. package/src/components/LavaLamp/v2/LavaLamp.tsx +0 -197
  129. package/src/components/LinkToId/LinkToId.module.scss +0 -4
  130. package/src/components/LinkToId/LinkToId.tsx +0 -51
  131. package/src/components/LinkToId/index.tsx +0 -2
  132. package/src/components/Loader/Loader.module.scss +0 -40
  133. package/src/components/Loader/Loader.tsx +0 -18
  134. package/src/components/Loader/index.tsx +0 -2
  135. package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +0 -34
  136. package/src/components/LoaderDotsIndicator/index.tsx +0 -2
  137. package/src/components/LoopableVideo/LoopableVideo.tsx +0 -37
  138. package/src/components/LoopableVideo/index.tsx +0 -2
  139. package/src/components/MainGrid/MainGrid.module.scss +0 -28
  140. package/src/components/MainGrid/MainGrid.tsx +0 -68
  141. package/src/components/MainGrid/index.tsx +0 -2
  142. package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +0 -220
  143. package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +0 -38
  144. package/src/components/MutableHamburgerButton/index.tsx +0 -2
  145. package/src/components/Notification/Notification.module.scss +0 -25
  146. package/src/components/Notification/Notification.tsx +0 -13
  147. package/src/components/Notification/index.tsx +0 -2
  148. package/src/components/OrderableList/OrderableList.module.scss +0 -98
  149. package/src/components/OrderableList/OrderableList.tsx +0 -564
  150. package/src/components/OrderableList/index.tsx +0 -2
  151. package/src/components/PaginationIndicator/PaginationIndicator.tsx +0 -365
  152. package/src/components/PaginationIndicator/index.tsx +0 -2
  153. package/src/components/Parallax/Parallax.module.scss +0 -28
  154. package/src/components/Parallax/Parallax.tsx +0 -225
  155. package/src/components/Parallax/index.tsx +0 -2
  156. package/src/components/Parallax/math/helpers.ts +0 -289
  157. package/src/components/PasswordInput/PasswordInput.module.scss +0 -17
  158. package/src/components/PasswordInput/PasswordInput.tsx +0 -154
  159. package/src/components/PasswordInput/index.tsx +0 -2
  160. package/src/components/PingPongText/PingPongText.module.scss +0 -4
  161. package/src/components/PingPongText/PingPongText.tsx +0 -83
  162. package/src/components/PingPongText/index.tsx +0 -2
  163. package/src/components/PixelatedScan/PixelatedScan.module.scss +0 -86
  164. package/src/components/PixelatedScan/PixelatedScan.tsx +0 -175
  165. package/src/components/PixelatedScan/index.tsx +0 -2
  166. package/src/components/Portal/Portal.module.scss +0 -3
  167. package/src/components/Portal/Portal.tsx +0 -68
  168. package/src/components/Portal/index.tsx +0 -2
  169. package/src/components/ProgressBar/ProgressBar.module.scss +0 -44
  170. package/src/components/ProgressBar/ProgressBar.tsx +0 -124
  171. package/src/components/ProgressBar/index.tsx +0 -2
  172. package/src/components/ProgressTexts/ProgressTexts.module.scss +0 -37
  173. package/src/components/ProgressTexts/ProgressTexts.tsx +0 -85
  174. package/src/components/ProgressTexts/index.tsx +0 -2
  175. package/src/components/Radio/Radio.module.scss +0 -36
  176. package/src/components/Radio/Radio.tsx +0 -53
  177. package/src/components/Radio/index.tsx +0 -2
  178. package/src/components/SectionContainer/SectionContainer.module.scss +0 -30
  179. package/src/components/SectionContainer/SectionContainer.tsx +0 -49
  180. package/src/components/SectionContainer/index.tsx +0 -2
  181. package/src/components/Select/Select.module.scss +0 -58
  182. package/src/components/Select/Select.tsx +0 -192
  183. package/src/components/Select/index.tsx +0 -2
  184. package/src/components/Skeleton/Skeleton.module.scss +0 -21
  185. package/src/components/Skeleton/Skeleton.tsx +0 -29
  186. package/src/components/Skeleton/index.tsx +0 -2
  187. package/src/components/Spacing/Spacing.module.scss +0 -13
  188. package/src/components/Spacing/Spacing.tsx +0 -24
  189. package/src/components/Spacing/index.tsx +0 -2
  190. package/src/components/StaticScroller/StaticScroller.module.scss +0 -14
  191. package/src/components/StaticScroller/StaticScroller.tsx +0 -83
  192. package/src/components/StaticScroller/index.tsx +0 -2
  193. package/src/components/Switch/Switch.module.scss +0 -43
  194. package/src/components/Switch/Switch.tsx +0 -41
  195. package/src/components/Switch/index.tsx +0 -2
  196. package/src/components/Table/Table.module.scss +0 -76
  197. package/src/components/Table/Table.tsx +0 -152
  198. package/src/components/Table/index.tsx +0 -2
  199. package/src/components/Tabs/Tabs.module.scss +0 -40
  200. package/src/components/Tabs/Tabs.tsx +0 -104
  201. package/src/components/Tabs/index.tsx +0 -2
  202. package/src/components/Text/Text.module.scss +0 -81
  203. package/src/components/Text/Text.tsx +0 -42
  204. package/src/components/Text/index.tsx +0 -2
  205. package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +0 -47
  206. package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +0 -78
  207. package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +0 -106
  208. package/src/components/Transition/MasksFactory/SquareToBalls.tsx +0 -66
  209. package/src/components/Transition/MasksFactory/utils.ts +0 -35
  210. package/src/components/Transition/Transition.module.scss +0 -211
  211. package/src/components/Transition/Transition.tsx +0 -495
  212. package/src/components/Transition/index.tsx +0 -2
  213. package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +0 -9
  214. package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +0 -34
  215. package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +0 -143
  216. package/src/components/UncontrolledTransition/index.tsx +0 -2
  217. package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +0 -212
  218. package/src/components/WalletConnectionWrapper/index.tsx +0 -2
  219. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +0 -5
  220. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +0 -52
  221. package/src/components/utilitary/ScrollAndFocusLock/index.tsx +0 -2
  222. package/src/context/AsyncProcess.tsx +0 -107
  223. package/src/context/ContextAsyncControl.tsx +0 -89
  224. package/src/context/CustomBrowserRouter.tsx +0 -55
  225. package/src/context/OneUIProvider.tsx +0 -308
  226. package/src/hooks/logs/useDependencyChangeDetection.ts +0 -25
  227. package/src/hooks/logs/useIsMounting.ts +0 -7
  228. package/src/hooks/persistence/useLocalStorage.ts +0 -45
  229. package/src/hooks/shims/ObjectWatchShim.ts +0 -56
  230. package/src/hooks/ui/useAdaptiveImage.tsx +0 -36
  231. package/src/hooks/ui/useAlternating.tsx +0 -22
  232. package/src/hooks/ui/useBreakpoint.tsx +0 -21
  233. package/src/hooks/ui/useCustomScrollbar.module.scss +0 -20
  234. package/src/hooks/ui/useCustomScrollbar.tsx +0 -22
  235. package/src/hooks/ui/useEffectIf.ts +0 -11
  236. package/src/hooks/ui/useMouseHover.tsx +0 -26
  237. package/src/hooks/ui/usePaginationControls.module.scss +0 -16
  238. package/src/hooks/ui/usePaginationControls.tsx +0 -176
  239. package/src/hooks/ui/useSnapToViewport.module.scss +0 -6
  240. package/src/hooks/ui/useSnapToViewport.ts +0 -28
  241. package/src/hooks/ui/useTilt.tsx +0 -219
  242. package/src/hooks/ui/useZoomable.module.scss +0 -34
  243. package/src/hooks/ui/useZoomable.tsx +0 -144
  244. package/src/hooks/useAsyncControl.ai.md +0 -25
  245. package/src/hooks/useAsyncControl.ts +0 -101
  246. package/src/hooks/useContainedRepositioning.ts +0 -110
  247. package/src/hooks/useCustomHistory.ts +0 -14
  248. package/src/hooks/useElementFit.ts +0 -82
  249. package/src/hooks/useFirestoreWatch.ts +0 -54
  250. package/src/hooks/useForm.ts +0 -49
  251. package/src/hooks/useFreeze.ts +0 -12
  252. package/src/hooks/useHero.module.scss +0 -41
  253. package/src/hooks/useHero.ts +0 -512
  254. package/src/hooks/useIntersection.ts +0 -32
  255. package/src/hooks/useMergeRefs.ts +0 -29
  256. package/src/hooks/useObserve.ts +0 -24
  257. package/src/hooks/usePagination.ts +0 -228
  258. package/src/hooks/usePooledOperation.ts +0 -54
  259. package/src/hooks/usePooling.ts +0 -46
  260. package/src/hooks/useRebound.ts +0 -23
  261. package/src/hooks/useShortIntl.ai.md +0 -5
  262. package/src/hooks/useShortIntl.ts +0 -97
  263. package/src/hooks/utility/useAsyncMemo.ts +0 -43
  264. package/src/hooks/utility/useDepChange.ts +0 -11
  265. package/src/hooks/utility/useEvents.ts +0 -33
  266. package/src/hooks/utility/useImmediate.ts +0 -8
  267. package/src/hooks/utility/useManualInit.ts +0 -24
  268. package/src/hooks/utility/useModule.ts +0 -15
  269. package/src/hooks/utility/useQuery.ts +0 -15
  270. package/src/hooks/utility/useUniqueEffect.ts +0 -22
  271. package/src/index.preprocess.ts +0 -82
  272. package/src/index.ts +0 -229
  273. package/src/models/DebugLogger.ts +0 -7
  274. package/src/models/GenericContract.ts +0 -169
  275. package/src/models/Orbs.ts +0 -97
  276. package/src/reac-app-env.d.ts +0 -6
  277. package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
  278. package/src/storybookUtils/index.tsx +0 -53
  279. package/src/test.tsx +0 -0
  280. package/src/type-utils.ts +0 -49
  281. package/src/types.ts +0 -199
  282. package/src/utility.d.ts +0 -70
  283. package/src/utils/blockchain.ts +0 -43
  284. package/src/utils/e2e.ts +0 -55
  285. package/src/utils/flatten.ts +0 -17
  286. package/src/utils/formatters.ts +0 -36
  287. package/src/utils/html.utils.ts +0 -3
  288. package/src/utils/ownEvent.ts +0 -8
  289. package/src/utils/test.ts +0 -20
@@ -1,308 +0,0 @@
1
- import { JSX } from "react";
2
- import get from "lodash/get";
3
- import merge from "lodash/merge";
4
- import clone from "lodash/cloneDeep";
5
- import { Get } from "type-fest";
6
- import React, { ComponentProps, ReactElement, ReactNode, useMemo } from "react";
7
- import { createContext, PropsWithChildren, useContext } from "react";
8
- import { ImageScales } from "@muritavo/webpack-microfrontend-scripts/bin/types/ImageScales";
9
- import { UploadTask } from "firebase/storage";
10
- import { FieldPath } from "../type-utils";
11
- import useAdaptiveImage from "../hooks/ui/useAdaptiveImage";
12
- import Button from "../components/Button";
13
- import CheckBox from "../components/CheckBox";
14
- import Radio from "../components/Radio/Radio";
15
- import { FileInputViewProps } from "../components/FileInput/View/View.types";
16
- import {
17
- AnswerByField,
18
- GenericFormFieldProps,
19
- } from "../components/Form/v2/FormField/FormField.types";
20
- import { BaseQuestion } from "../components/Form/v2/Form.types";
21
-
22
- type DeepPartial<T> = {
23
- [P in keyof T]?: NonNullable<T[P]> extends Function
24
- ? T[P]
25
- : DeepPartial<T[P]>;
26
- };
27
-
28
- export type OneUIContextSpecs = {
29
- component: {
30
- spacing: {
31
- variants: {
32
- [k in OnepercentUtility.UIElements.SpacingVariants]: string;
33
- };
34
- };
35
- collapsable: {
36
- className: string;
37
- };
38
- form: {
39
- titleVariant: OnepercentUtility.UIElements.TextVariants;
40
- labelVariant: OnepercentUtility.UIElements.TextVariants;
41
- /** Label shown when a field is optional */
42
- optionalLabel: string;
43
-
44
- /** Label shown when a required field was not provided */
45
- requiredLabel: string;
46
-
47
- onFileUpload(questionId: string, file: File): UploadTask;
48
-
49
- extensions?: {
50
- [K in OnepercentUtility.UIElements.FormExtension["fields"]["type"]]: {
51
- Input: (props: GenericFormFieldProps<K>) => ReactElement;
52
- validator: (
53
- answer: AnswerByField<{ type: K }>,
54
- question: BaseQuestion &
55
- (OnepercentUtility.UIElements.FormExtension["fields"] & {
56
- type: K;
57
- })
58
- ) => {
59
- isValid: boolean;
60
- error?: string;
61
- };
62
- };
63
- };
64
- };
65
- text?: {
66
- className?: {
67
- [k in React.ComponentProps<
68
- typeof import("../components/Text")["default"]
69
- >["type"]]?: string;
70
- };
71
- htmlTag?: {
72
- [k in React.ComponentProps<
73
- typeof import("../components/Text")["default"]
74
- >["type"]]?: "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
75
- };
76
- };
77
- button?: {
78
- className?: {
79
- [k in NonNullable<
80
- React.ComponentProps<
81
- typeof import("../components/Button")["default"]
82
- >["variant"]
83
- >]?: string;
84
- };
85
- Component?: (props: ComponentProps<typeof Button>) => ReactElement;
86
- };
87
- input: {
88
- className: string;
89
- border: boolean;
90
- };
91
- fileInput: {
92
- View: (props: FileInputViewProps) => ReactElement;
93
- };
94
- passwordInput: {
95
- iconSrc: {
96
- passwordHidden: string;
97
- passwordVisible: string;
98
- };
99
- };
100
- asyncWrapper: {
101
- LoadingComponent?: () => JSX.Element;
102
- messages: {
103
- error: {
104
- title: string;
105
- retryBtn: string;
106
- };
107
- };
108
- };
109
- select: {
110
- StateIndicator: (props: { open: boolean }) => JSX.Element;
111
- className?: {
112
- dropdown?: string;
113
- item?: string;
114
- selectedItem?: string;
115
- input?: string;
116
- };
117
- };
118
- header: {
119
- LogoImage: () => JSX.Element;
120
- MoreOptions: ({ open }: { open: boolean }) => JSX.Element;
121
- };
122
- table: {
123
- controls: {
124
- PrevPage: ({ disabled }: { disabled: boolean }) => JSX.Element;
125
- NextPage: ({ disabled }: { disabled: boolean }) => JSX.Element;
126
- };
127
- };
128
- tooltip: {
129
- className?: string;
130
- };
131
- adaptiveDialog: {
132
- dialogClassName: string;
133
- backdropClassName: string;
134
- variant: {
135
- [k in OnepercentUtility.UIElements.AdaptiveDialogVariants]: string;
136
- };
137
- };
138
- adaptiveSidebar: {
139
- className: string;
140
- controlClassName: string;
141
- };
142
- checkbox: {
143
- Component?: (props: ComponentProps<typeof CheckBox>) => ReactElement;
144
- };
145
- radio: {
146
- Component?: (props: ComponentProps<typeof Radio>) => ReactElement;
147
- };
148
- };
149
- hook: {
150
- ui: {
151
- usePaginationControls: {
152
- LeftControl: () => ReactElement;
153
- RightControl: () => ReactElement;
154
- className?: string;
155
- };
156
- };
157
- };
158
- state: {
159
- imageScale: ImageScales;
160
- };
161
- };
162
-
163
- type ContextConfigSpecs = DeepPartial<OneUIContextSpecs>;
164
-
165
- const Context = createContext<ContextConfigSpecs>(null as any);
166
-
167
- function OneUIProvider({
168
- children,
169
- config,
170
- }: PropsWithChildren<{ config: ContextConfigSpecs }>) {
171
- const prevCtx = useContext(Context);
172
- const scale = useAdaptiveImage();
173
- const mergedConfig = useMemo(() => {
174
- return merge(clone(prevCtx), config, {
175
- state: {
176
- imageScale: scale,
177
- },
178
- });
179
- }, [prevCtx, config, scale]);
180
-
181
- return <Context.Provider value={mergedConfig}>{children}</Context.Provider>;
182
- }
183
-
184
- export default OneUIProvider;
185
-
186
- function pathToJson(
187
- path: string,
188
- key?: string | Symbol,
189
- exampleConfig = "THE_MISSING_CONFIG"
190
- ) {
191
- if (!key) {
192
- key = path.split(".").slice(-1)[0];
193
- path = path.replace(`.${key}`, "");
194
- }
195
-
196
- return path
197
- .split(".")
198
- .concat(key as string)
199
- .reduce((result, key, idx, arr) => {
200
- (arr.slice(0, idx).reduce((r, k) => (r as any)[k], result) as any)[key] =
201
- idx === arr.length - 1 ? exampleConfig : {};
202
- return result;
203
- }, {});
204
- }
205
-
206
- function ErrorWrapper(
207
- originalObject: any,
208
- path: string = "config"
209
- ): typeof Proxy {
210
- return new Proxy(
211
- typeof originalObject !== "object" ? {} : originalObject || {},
212
- {
213
- get(_target, key) {
214
- if (key === Symbol.toPrimitive) {
215
- return () => _target[key];
216
- }
217
- try {
218
- const value = originalObject[key];
219
- if (typeof value === "undefined") return undefined;
220
- if (typeof value === "object")
221
- return ErrorWrapper(value, [path, key].filter(Boolean).join("."));
222
- return value;
223
- } catch (e) {
224
- const pathJson = pathToJson(path, key);
225
- throw new Error(
226
- `A component is using the UI config ${[path, key].join(".")}.
227
-
228
- Please define it using:
229
- import OneUIProvider from "@onepercent/one-ui/dist/context/OneUIProvider";
230
-
231
- ...
232
- ${`<OneUIProvider config={${JSON.stringify(pathJson, null, 4)}}>
233
- ...
234
- </OneUIProvider>`.replace(/[ ]/g, "-")}`
235
- );
236
- }
237
- },
238
- }
239
- );
240
- }
241
-
242
- export function useOneUIContext() {
243
- const context = useContext(Context);
244
-
245
- if (process.env.NODE_ENV === "development")
246
- return ErrorWrapper(context) as unknown as OneUIContextSpecs;
247
-
248
- return context as OneUIContextSpecs;
249
- }
250
-
251
- export function useOneUIView<P extends FieldPath<OneUIContextSpecs>>(
252
- oneuiConfigPath: P,
253
- componentName: string
254
- ) {
255
- const providedValue = useOneUIConfig(oneuiConfigPath);
256
- if (!providedValue) {
257
- throw new Error(`The component ${componentName} requires a view to be set on OneUI initialization
258
-
259
- Views ready for use with this component shall be available at:
260
- import SomeView from "@onepercentio/one-ui/dist/components/${componentName}/View/SomeView";
261
-
262
- Please define it using:
263
- import OneUIProvider from "@onepercentio/one-ui/dist/context/OneUIProvider";
264
-
265
- ...
266
- ${`<OneUIProvider config={${JSON.stringify(
267
- pathToJson(oneuiConfigPath, undefined, "SomeView"),
268
- null,
269
- 4
270
- )}}>
271
- ...
272
- </OneUIProvider>`.replace(/[ ]/g, "-")}`);
273
- }
274
-
275
- return providedValue;
276
- }
277
-
278
- export function useOneUIConfig<
279
- P extends FieldPath<OneUIContextSpecs>,
280
- T extends Get<OneUIContextSpecs, P>
281
- >(prop: P, defaultValue?: T): NonNullable<Get<OneUIContextSpecs, P>> {
282
- const context = useContext(Context);
283
- if (process.env.NODE_ENV === "development") {
284
- const val = useMemo(() => {
285
- return get(context, prop);
286
- }, [context, prop]);
287
- if (
288
- typeof val === "string" ||
289
- typeof val === "function" ||
290
- prop.endsWith(".Component") ||
291
- prop.endsWith(".View")
292
- )
293
- return (val as any) || defaultValue;
294
-
295
- if (typeof val === "boolean") return val as any;
296
- return ErrorWrapper(val || defaultValue) as unknown as NonNullable<T>;
297
- }
298
- const value = useMemo(() => {
299
- return get(context, prop);
300
- }, [context, prop]);
301
- return value || defaultValue;
302
- }
303
-
304
- export function useCurrentImageScale() {
305
- const context = useContext(Context);
306
-
307
- return context.state!.imageScale!;
308
- }
@@ -1,25 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
-
3
- export default function useDependencyChangeDetection(
4
- tag: string,
5
- dependencyArray: any[]
6
- ) {
7
- for (let dependencyIndex in dependencyArray) {
8
- const prevValue = useRef<any>(undefined);
9
- useEffect(() => {
10
- if (!prevValue.current) return;
11
- if (process.env.NODE_ENV === "development")
12
- require('../../models/DebugLogger').default(
13
- `${useDependencyChangeDetection.name}:${tag}`,
14
- `Element index ${dependencyIndex} (prev: ${JSON.stringify(
15
- prevValue.current
16
- )}) (new: ${JSON.stringify(
17
- dependencyArray[dependencyIndex]
18
- )}) has changed`
19
- );
20
- }, [dependencyArray[dependencyIndex]]);
21
- useEffect(() => {
22
- prevValue.current = dependencyArray[dependencyIndex];
23
- }, [dependencyArray[dependencyIndex]]);
24
- }
25
- }
@@ -1,7 +0,0 @@
1
- import { useEffect } from "react";
2
-
3
- export default function useIsMounting(tag: string) {
4
- useEffect(() => {
5
- console.log(tag + " is mounting")
6
- }, []);
7
- }
@@ -1,45 +0,0 @@
1
- import { useCallback, useEffect, useState } from "react";
2
- const DUD = typeof "";
3
- type AvailablePrimitives = typeof DUD;
4
- const toString = (val: any) => {
5
- switch (typeof val) {
6
- case "boolean":
7
- return !val ? "0" : "1";
8
- case "string":
9
- return val;
10
- case "object":
11
- return JSON.stringify(val);
12
- default:
13
- throw new Error("Doesn't know how to handle type " + typeof val);
14
- }
15
- };
16
- const fromString = (type: AvailablePrimitives, value: string) => {
17
- switch (type) {
18
- case "boolean":
19
- return value === "1";
20
- case "string":
21
- return value;
22
- case "object":
23
- return JSON.parse(value);
24
- default:
25
- throw new Error("Doesn't know how to handle type " + type);
26
- }
27
- };
28
- export default function useLocalStorage<T extends any>(
29
- id: string,
30
- defaultValue: Exclude<T, undefined>
31
- ) {
32
- const [val, setVal] = useState<T>(() => {
33
- const persistedValue = localStorage.getItem(id);
34
- if (persistedValue === null) return defaultValue as T;
35
- return fromString(typeof defaultValue, persistedValue) as T;
36
- });
37
- useEffect(() => {
38
- if (val !== defaultValue) localStorage.setItem(id, toString(val));
39
- }, [val]);
40
- const del = useCallback(() => {
41
- localStorage.removeItem(id);
42
- setVal(defaultValue);
43
- }, []);
44
- return [val, setVal, del] as const;
45
- }
@@ -1,56 +0,0 @@
1
- // @ts-nocheck
2
- // object.watch
3
- if (!Object.prototype.watch) {
4
- Object.prototype.watch = function (propsToWatchFor, handler) {
5
- (this._handlers || (this._handlers = [])).push(handler)
6
- propsToWatchFor.forEach((prop) => {
7
- var oldval = this[prop],
8
- newval = oldval,
9
- getter = function () {
10
- return newval;
11
- },
12
- setter = function (val) {
13
- if (this._watchTimer) clearTimeout(this._watchTimer);
14
- this._watchTimer = setTimeout(() => {
15
- for (let handler of this._handlers)
16
- handler.call();
17
- clearTimeout(this._watchTimer);
18
- delete this._watchTimer;
19
- }, 0);
20
- oldval = newval;
21
- newval = val;
22
- return true;
23
- };
24
- try {
25
-
26
- if (delete this[prop]) {
27
- // can't watch constants
28
- if (Object.defineProperty) {
29
- // ECMAScript 5
30
- Object.defineProperty(this, prop, {
31
- get: getter,
32
- set: setter,
33
- });
34
- }
35
- else if (
36
- Object.prototype.__defineGetter__ &&
37
- Object.prototype.__defineSetter__
38
- ) {
39
- // legacy
40
- Object.prototype.__defineGetter__.call(this, prop, getter);
41
- Object.prototype.__defineSetter__.call(this, prop, setter);
42
- }
43
- }
44
- } catch (e) { }
45
- });
46
-
47
- return () => {
48
- this._handlers.splice(this._handlers.indexOf(handler), 1);
49
- };
50
- };
51
- Object.defineProperty(Object.prototype, 'watch', {
52
- enumerable: false,
53
- configurable: true
54
- });
55
- }
56
- export {}
@@ -1,36 +0,0 @@
1
- import { ImageScales } from "@muritavo/webpack-microfrontend-scripts/bin/types/ImageScales";
2
- import throttle from "lodash/throttle";
3
- import { useEffect, useState } from "react";
4
-
5
- /**
6
- * This hooks is built over the implementation of this loader https://github.com/Muritavo/webpack-microfrontend-scripts#imageresolutionoptimizer
7
- *
8
- */
9
- function useAdaptiveImage(): ImageScales {
10
- function ScaleFromCurrentWidth() {
11
- if ((window as any).PRERENDER) return ImageScales.LARGE;
12
- const width = window.visualViewport!.width;
13
- if (width < 480) return ImageScales.SMALL;
14
- if (width < 800) return ImageScales.NORMAL;
15
- if (width < 1280) return ImageScales.BIG;
16
- if (width < 1920) return ImageScales.LARGE;
17
- else return ImageScales.EXTRA_LARGE;
18
- }
19
-
20
- const [currentScale, setCurrentScale] = useState<ImageScales>(() =>
21
- ScaleFromCurrentWidth()
22
- );
23
-
24
- useEffect(() => {
25
- const onResizeThrottle = throttle(() => {
26
- setCurrentScale(ScaleFromCurrentWidth());
27
- }, 1000 / 4);
28
- const onResize = () => onResizeThrottle();
29
- window.addEventListener("resize", onResize);
30
- return () => window.removeEventListener("resize", onResize);
31
- }, []);
32
-
33
- return currentScale;
34
- }
35
-
36
- export default useAdaptiveImage
@@ -1,22 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- /**
4
- * Receives a list and keeps alternating between the list elements every 5 seconds
5
- */
6
- export default function useAlternating<X>(list: X[]) {
7
- const [current, setCurrent] = useState(list[0]);
8
-
9
- useEffect(() => {
10
- const interval = setInterval(() => {
11
- setCurrent((prev) => {
12
- const currentIndex = list.indexOf(prev);
13
- if (list[currentIndex + 1]) return list[currentIndex + 1];
14
- else return list[0];
15
- });
16
- }, 5000);
17
-
18
- return () => clearInterval(interval);
19
- }, []);
20
-
21
- return current;
22
- }
@@ -1,21 +0,0 @@
1
- import throttle from "lodash/throttle";
2
- import { useEffect, useState } from "react";
3
-
4
- /**
5
- * A hook to trigger changes when the screen resizes
6
- * @returns If the current resolution is lower than the specified width
7
- */
8
- export default function useBreakpoint(breakInto: number) {
9
- const [lowerThanBreakpoint, setIsLowerThanBreakpoint] = useState(
10
- () => window.visualViewport!.width < breakInto
11
- );
12
- useEffect(() => {
13
- const onResizeThrottle = throttle(() => {
14
- setIsLowerThanBreakpoint(window.visualViewport!.width < breakInto);
15
- }, 1000 / 4);
16
- const onResize = () => onResizeThrottle();
17
- window.addEventListener("resize", onResize);
18
- return () => window.removeEventListener("resize", onResize);
19
- }, []);
20
- return lowerThanBreakpoint;
21
- }
@@ -1,20 +0,0 @@
1
- @import "../../assets/styles/index.scss";
2
-
3
- .scrollBarRoot {
4
- &,
5
- &.propagate * {
6
- &::-webkit-scrollbar {
7
- background-color: transparent;
8
- height: 8px;
9
- width: 8px;
10
- z-index: 1000;
11
- }
12
-
13
- &::-webkit-scrollbar-thumb {
14
- background-color: var(--scrollbar-color, $primaryColor);
15
- width: 8px;
16
- height: 8px;
17
- border-radius: 4px;
18
- }
19
- }
20
- }
@@ -1,22 +0,0 @@
1
- import { useEffect, useLayoutEffect, useRef } from "react";
2
- import Styles from "./useCustomScrollbar.module.scss";
3
-
4
- export default function useCustomScrollBar({
5
- color = "",
6
- propagate = false
7
- }: { color?: string, propagate?: boolean } | undefined = {}) {
8
- const elRef = useRef<HTMLDivElement>(null);
9
-
10
- useLayoutEffect(() => {
11
- elRef.current!.style.setProperty("--scrollbar-color", color);
12
- elRef.current!.classList.add(Styles.scrollBarRoot);
13
- if (propagate) {
14
- elRef.current!.classList.add(Styles.propagate);
15
- }
16
- }, []);
17
-
18
- return {
19
- /** The element that dhould have a custom scrollbar */
20
- elRef,
21
- };
22
- }
@@ -1,11 +0,0 @@
1
- import { useEffect } from "react";
2
-
3
- export default function useEffectIf(
4
- effect: Parameters<typeof useEffect>[0],
5
- depsToCheck: any[]
6
- ) {
7
- useEffect(() => {
8
- const someUndefined = depsToCheck.some((dep) => !dep);
9
- if (!someUndefined) return effect();
10
- }, depsToCheck);
11
- }
@@ -1,26 +0,0 @@
1
- import { useMemo, useState } from "react";
2
- import ownEvent from "../../utils/ownEvent";
3
-
4
- /**
5
- * A small hook for binding the hover control over some HTML element
6
- * @returns uiEvents: The events to spread to the html element hovering: the hover state
7
- */
8
- export default function useMouseHover() {
9
- const [hovering, setHovering] = useState(false);
10
- const uiEvents = useMemo(
11
- () => ({
12
- onMouseEnter: ownEvent<MouseEvent>(() => {
13
- setHovering(true);
14
- }),
15
- onMouseOut: ownEvent<MouseEvent>(() => {
16
- setHovering(false);
17
- }),
18
- }),
19
- []
20
- );
21
-
22
- return {
23
- uiEvents,
24
- hovering,
25
- };
26
- }
@@ -1,16 +0,0 @@
1
- .control {
2
- position: absolute;
3
- top: 0px;
4
- bottom: 0px;
5
- display: flex;
6
- align-items: center;
7
- justify-content: center;
8
- }
9
-
10
- .right {
11
- right: 0px;
12
- }
13
-
14
- .left {
15
- left: 0px;
16
- }