@homecode/ui 4.11.1

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 (267) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/dist/esm/index.js +78 -0
  4. package/dist/esm/node_modules/style-inject/dist/style-inject.es.js +28 -0
  5. package/dist/esm/src/components/AssistiveText/AssistiveText.js +10 -0
  6. package/dist/esm/src/components/AssistiveText/AssistiveText.styl.js +7 -0
  7. package/dist/esm/src/components/Button/Button.helpers.js +12 -0
  8. package/dist/esm/src/components/Button/Button.js +38 -0
  9. package/dist/esm/src/components/Button/Button.styl.js +7 -0
  10. package/dist/esm/src/components/ButtonGroup/ButtonGroup.js +10 -0
  11. package/dist/esm/src/components/ButtonGroup/ButtonGroup.styl.js +7 -0
  12. package/dist/esm/src/components/Checkbox/Checkbox.js +48 -0
  13. package/dist/esm/src/components/Checkbox/Checkbox.styl.js +7 -0
  14. package/dist/esm/src/components/Container/Container.js +12 -0
  15. package/dist/esm/src/components/Container/Container.styl.js +7 -0
  16. package/dist/esm/src/components/DateTime/DateTime.js +17 -0
  17. package/dist/esm/src/components/Draggable/Draggable.js +136 -0
  18. package/dist/esm/src/components/Draggable/Draggable.styl.js +7 -0
  19. package/dist/esm/src/components/Expand/Expand.js +24 -0
  20. package/dist/esm/src/components/Expand/Expand.styl.js +7 -0
  21. package/dist/esm/src/components/Form/Form.helpers.js +42 -0
  22. package/dist/esm/src/components/Form/Form.js +286 -0
  23. package/dist/esm/src/components/Form/Form.styl.js +7 -0
  24. package/dist/esm/src/components/Form/Form.types.js +1 -0
  25. package/dist/esm/src/components/Form/SubmitButtons/SubmitButtons.js +8 -0
  26. package/dist/esm/src/components/Form/SubmitButtons/SubmitButtons.styl.js +7 -0
  27. package/dist/esm/src/components/Form/Validator.js +36 -0
  28. package/dist/esm/src/components/Gallery/Dots/Dots.js +9 -0
  29. package/dist/esm/src/components/Gallery/Dots/Dots.styl.js +7 -0
  30. package/dist/esm/src/components/Gallery/Gallery.js +180 -0
  31. package/dist/esm/src/components/Gallery/Gallery.styl.js +7 -0
  32. package/dist/esm/src/components/Heading/Heading.js +37 -0
  33. package/dist/esm/src/components/Heading/Heading.styl.js +7 -0
  34. package/dist/esm/src/components/Icon/Icon.js +27 -0
  35. package/dist/esm/src/components/Icon/Icon.styl.js +7 -0
  36. package/dist/esm/src/components/Icon/icons/avatar.svg.js +15 -0
  37. package/dist/esm/src/components/Icon/icons/brokenImage.svg.js +15 -0
  38. package/dist/esm/src/components/Icon/icons/check.svg.js +19 -0
  39. package/dist/esm/src/components/Icon/icons/chevronDown.svg.js +20 -0
  40. package/dist/esm/src/components/Icon/icons/chevronLeft.svg.js +20 -0
  41. package/dist/esm/src/components/Icon/icons/chevronRight.svg.js +20 -0
  42. package/dist/esm/src/components/Icon/icons/chevronUp.svg.js +20 -0
  43. package/dist/esm/src/components/Icon/icons/close.svg.js +15 -0
  44. package/dist/esm/src/components/Icon/icons/colors.svg.js +60 -0
  45. package/dist/esm/src/components/Icon/icons/copy.svg.js +15 -0
  46. package/dist/esm/src/components/Icon/icons/delete.svg.js +15 -0
  47. package/dist/esm/src/components/Icon/icons/draft.svg.js +15 -0
  48. package/dist/esm/src/components/Icon/icons/edit.svg.js +15 -0
  49. package/dist/esm/src/components/Icon/icons/externalLink.svg.js +15 -0
  50. package/dist/esm/src/components/Icon/icons/fullscreen.svg.js +15 -0
  51. package/dist/esm/src/components/Icon/icons/fullscreenExit.svg.js +15 -0
  52. package/dist/esm/src/components/Icon/icons/gear.svg.js +20 -0
  53. package/dist/esm/src/components/Icon/icons/history.svg.js +17 -0
  54. package/dist/esm/src/components/Icon/icons/home.svg.js +19 -0
  55. package/dist/esm/src/components/Icon/icons/index.js +41 -0
  56. package/dist/esm/src/components/Icon/icons/loader.svg.js +45 -0
  57. package/dist/esm/src/components/Icon/icons/menu.svg.js +18 -0
  58. package/dist/esm/src/components/Icon/icons/mic.svg.js +15 -0
  59. package/dist/esm/src/components/Icon/icons/minus.svg.js +15 -0
  60. package/dist/esm/src/components/Icon/icons/moreHorizontal.svg.js +15 -0
  61. package/dist/esm/src/components/Icon/icons/moreVertical.svg.js +15 -0
  62. package/dist/esm/src/components/Icon/icons/plus.svg.js +15 -0
  63. package/dist/esm/src/components/Icon/icons/redo.svg.js +15 -0
  64. package/dist/esm/src/components/Icon/icons/requiredStar.svg.js +15 -0
  65. package/dist/esm/src/components/Icon/icons/save.svg.js +17 -0
  66. package/dist/esm/src/components/Icon/icons/send.svg.js +16 -0
  67. package/dist/esm/src/components/Icon/icons/settings.svg.js +52 -0
  68. package/dist/esm/src/components/Icon/icons/shoppingBag.svg.js +17 -0
  69. package/dist/esm/src/components/Icon/icons/social_email.svg.js +15 -0
  70. package/dist/esm/src/components/Icon/icons/social_instagram.svg.js +15 -0
  71. package/dist/esm/src/components/Icon/icons/social_telegram.svg.js +19 -0
  72. package/dist/esm/src/components/Icon/icons/undo.svg.js +15 -0
  73. package/dist/esm/src/components/Input/Input.js +331 -0
  74. package/dist/esm/src/components/Input/Input.styl.js +7 -0
  75. package/dist/esm/src/components/InputFile/InputFile.js +292 -0
  76. package/dist/esm/src/components/InputFile/InputFile.styl.js +7 -0
  77. package/dist/esm/src/components/InputFile/InputFile.types.js +1 -0
  78. package/dist/esm/src/components/InputFile/Item/Item.js +18 -0
  79. package/dist/esm/src/components/InputFile/Item/Item.styl.js +7 -0
  80. package/dist/esm/src/components/Label/Label.constants.json.js +8 -0
  81. package/dist/esm/src/components/Label/Label.helpers.js +35 -0
  82. package/dist/esm/src/components/Label/Label.js +58 -0
  83. package/dist/esm/src/components/Label/Label.styl.js +7 -0
  84. package/dist/esm/src/components/Lazy/Lazy.js +65 -0
  85. package/dist/esm/src/components/LightBox/LightBox.js +28 -0
  86. package/dist/esm/src/components/LightBox/LightBox.styl.js +7 -0
  87. package/dist/esm/src/components/Notifications/Notifications.constants.json.js +6 -0
  88. package/dist/esm/src/components/Notifications/Notifications.js +67 -0
  89. package/dist/esm/src/components/Notifications/Notifications.styl.js +7 -0
  90. package/dist/esm/src/components/Notifications/store.js +62 -0
  91. package/dist/esm/src/components/Paranja/Paranja.js +14 -0
  92. package/dist/esm/src/components/Paranja/Paranja.styl.js +7 -0
  93. package/dist/esm/src/components/Popup/Popup.helpers.js +31 -0
  94. package/dist/esm/src/components/Popup/Popup.js +396 -0
  95. package/dist/esm/src/components/Popup/Popup.styl.js +7 -0
  96. package/dist/esm/src/components/PopupMenu/PopupMenu.js +15 -0
  97. package/dist/esm/src/components/PopupMenu/PopupMenu.styl.js +7 -0
  98. package/dist/esm/src/components/Portal/Portal.js +19 -0
  99. package/dist/esm/src/components/RequiredStar/RequiredStar.js +12 -0
  100. package/dist/esm/src/components/RequiredStar/RequiredStar.styl.js +7 -0
  101. package/dist/esm/src/components/Router/Link/Link.js +61 -0
  102. package/dist/esm/src/components/Router/Link/Link.styl.js +7 -0
  103. package/dist/esm/src/components/Router/Redirect.js +12 -0
  104. package/dist/esm/src/components/Router/Route.js +4 -0
  105. package/dist/esm/src/components/Router/Router.helpers.js +33 -0
  106. package/dist/esm/src/components/Router/Router.js +68 -0
  107. package/dist/esm/src/components/Router/context.js +5 -0
  108. package/dist/esm/src/components/Router/store.js +55 -0
  109. package/dist/esm/src/components/Scroll/Scroll.js +274 -0
  110. package/dist/esm/src/components/Scroll/Scroll.styl.js +7 -0
  111. package/dist/esm/src/components/Select/Select.helpers.js +37 -0
  112. package/dist/esm/src/components/Select/Select.js +583 -0
  113. package/dist/esm/src/components/Select/Select.styl.js +7 -0
  114. package/dist/esm/src/components/Spinner/Spinner.js +11 -0
  115. package/dist/esm/src/components/Spinner/Spinner.styl.js +7 -0
  116. package/dist/esm/src/components/Spinner/spinner.svg.js +24 -0
  117. package/dist/esm/src/components/Table/Table.js +24 -0
  118. package/dist/esm/src/components/Table/Table.styl.js +7 -0
  119. package/dist/esm/src/components/Tabs/Tabs.js +43 -0
  120. package/dist/esm/src/components/Tabs/Tabs.styl.js +7 -0
  121. package/dist/esm/src/components/Text/Text.js +44 -0
  122. package/dist/esm/src/components/Text/Text.styl.js +7 -0
  123. package/dist/esm/src/components/Theme/Theme.defaults.js +50 -0
  124. package/dist/esm/src/components/Theme/Theme.helpers.js +67 -0
  125. package/dist/esm/src/components/Theme/Theme.js +13 -0
  126. package/dist/esm/src/components/VH/VH.js +33 -0
  127. package/dist/esm/src/components/Virtualized/List/List.js +124 -0
  128. package/dist/esm/src/components/Virtualized/List/List.styl.js +7 -0
  129. package/dist/esm/src/components/Virtualized/List/ListScroll.js +21 -0
  130. package/dist/esm/src/components/Virtualized/List/ListScroll.styl.js +7 -0
  131. package/dist/esm/src/components/Virtualized/Virtualized.helpers.js +14 -0
  132. package/dist/esm/src/components/Virtualized/Virtualized.js +200 -0
  133. package/dist/esm/src/components/Virtualized/Virtualized.styl.js +7 -0
  134. package/dist/esm/src/components/Virtualized/Virtualized.types.js +1 -0
  135. package/dist/esm/src/services/i18n.js +68 -0
  136. package/dist/esm/src/tools/array.js +60 -0
  137. package/dist/esm/src/tools/config.js +9 -0
  138. package/dist/esm/src/tools/debounce.js +11 -0
  139. package/dist/esm/src/tools/dom.js +46 -0
  140. package/dist/esm/src/tools/env.js +3 -0
  141. package/dist/esm/src/tools/file.js +11 -0
  142. package/dist/esm/src/tools/localStorage.js +31 -0
  143. package/dist/esm/src/tools/number.js +27 -0
  144. package/dist/esm/src/tools/object.js +5 -0
  145. package/dist/esm/src/tools/queryParams.js +20 -0
  146. package/dist/esm/src/tools/rangeMap.js +3 -0
  147. package/dist/esm/src/tools/resizeObserver.js +64 -0
  148. package/dist/esm/src/tools/scroll.js +41 -0
  149. package/dist/esm/src/tools/string.js +7 -0
  150. package/dist/esm/src/tools/throttle.js +30 -0
  151. package/dist/esm/src/tools/uid.js +7 -0
  152. package/dist/esm/types/index.d.ts +1 -0
  153. package/dist/esm/types/src/components/AssistiveText/AssistiveText.d.ts +3 -0
  154. package/dist/esm/types/src/components/AssistiveText/AssistiveText.types.d.ts +7 -0
  155. package/dist/esm/types/src/components/Button/Button.d.ts +4 -0
  156. package/dist/esm/types/src/components/Button/Button.helpers.d.ts +1 -0
  157. package/dist/esm/types/src/components/Button/Button.types.d.ts +14 -0
  158. package/dist/esm/types/src/components/ButtonGroup/ButtonGroup.d.ts +3 -0
  159. package/dist/esm/types/src/components/ButtonGroup/ButtonGroup.types.d.ts +5 -0
  160. package/dist/esm/types/src/components/Checkbox/Checkbox.d.ts +18 -0
  161. package/dist/esm/types/src/components/Checkbox/Checkbox.types.d.ts +10 -0
  162. package/dist/esm/types/src/components/Container/Container.d.ts +3 -0
  163. package/dist/esm/types/src/components/Container/Container.types.d.ts +13 -0
  164. package/dist/esm/types/src/components/DateTime/DateTime.d.ts +8 -0
  165. package/dist/esm/types/src/components/DateTime/DateTime.types.d.ts +6 -0
  166. package/dist/esm/types/src/components/Draggable/Draggable.d.ts +24 -0
  167. package/dist/esm/types/src/components/Draggable/Draggable.types.d.ts +11 -0
  168. package/dist/esm/types/src/components/Expand/Expand.d.ts +3 -0
  169. package/dist/esm/types/src/components/Expand/Expand.types.d.ts +16 -0
  170. package/dist/esm/types/src/components/Form/Form.d.ts +32 -0
  171. package/dist/esm/types/src/components/Form/Form.helpers.d.ts +6 -0
  172. package/dist/esm/types/src/components/Form/Form.types.d.ts +71 -0
  173. package/dist/esm/types/src/components/Form/SubmitButtons/SubmitButtons.d.ts +13 -0
  174. package/dist/esm/types/src/components/Form/Validator.d.ts +2 -0
  175. package/dist/esm/types/src/components/Form/index.d.ts +2 -0
  176. package/dist/esm/types/src/components/Gallery/Dots/Dots.d.ts +5 -0
  177. package/dist/esm/types/src/components/Gallery/Gallery.d.ts +36 -0
  178. package/dist/esm/types/src/components/Gallery/Gallery.types.d.ts +12 -0
  179. package/dist/esm/types/src/components/Heading/Heading.d.ts +3 -0
  180. package/dist/esm/types/src/components/Heading/Heading.types.d.ts +5 -0
  181. package/dist/esm/types/src/components/Icon/Icon.d.ts +45 -0
  182. package/dist/esm/types/src/components/Icon/Icon.example.d.ts +3 -0
  183. package/dist/esm/types/src/components/Icon/Icon.helpers.d.ts +1 -0
  184. package/dist/esm/types/src/components/Icon/Icon.types.d.ts +8 -0
  185. package/dist/esm/types/src/components/Icon/icons/index.d.ts +39 -0
  186. package/dist/esm/types/src/components/Input/Input.d.ts +42 -0
  187. package/dist/esm/types/src/components/Input/Input.types.d.ts +21 -0
  188. package/dist/esm/types/src/components/InputFile/InputFile.d.ts +48 -0
  189. package/dist/esm/types/src/components/InputFile/InputFile.types.d.ts +22 -0
  190. package/dist/esm/types/src/components/InputFile/Item/Item.d.ts +16 -0
  191. package/dist/esm/types/src/components/Label/Label.d.ts +19 -0
  192. package/dist/esm/types/src/components/Label/Label.helpers.d.ts +1 -0
  193. package/dist/esm/types/src/components/Label/Label.types.d.ts +8 -0
  194. package/dist/esm/types/src/components/Lazy/Lazy.d.ts +18 -0
  195. package/dist/esm/types/src/components/Lazy/Lazy.types.d.ts +15 -0
  196. package/dist/esm/types/src/components/LightBox/LightBox.d.ts +3 -0
  197. package/dist/esm/types/src/components/LightBox/LightBox.types.d.ts +7 -0
  198. package/dist/esm/types/src/components/Notifications/Notifications.d.ts +2 -0
  199. package/dist/esm/types/src/components/Notifications/Notifications.types.d.ts +19 -0
  200. package/dist/esm/types/src/components/Notifications/store.d.ts +2 -0
  201. package/dist/esm/types/src/components/Paranja/Paranja.d.ts +3 -0
  202. package/dist/esm/types/src/components/Paranja/Paranja.types.d.ts +8 -0
  203. package/dist/esm/types/src/components/Popup/Popup.d.ts +73 -0
  204. package/dist/esm/types/src/components/Popup/Popup.helpers.d.ts +8 -0
  205. package/dist/esm/types/src/components/Popup/Popup.types.d.ts +34 -0
  206. package/dist/esm/types/src/components/PopupMenu/PopupMenu.d.ts +3 -0
  207. package/dist/esm/types/src/components/PopupMenu/PopupMenu.types.d.ts +13 -0
  208. package/dist/esm/types/src/components/Portal/Portal.d.ts +7 -0
  209. package/dist/esm/types/src/components/RequiredStar/RequiredStar.d.ts +3 -0
  210. package/dist/esm/types/src/components/RequiredStar/RequiredStar.types.d.ts +6 -0
  211. package/dist/esm/types/src/components/Router/Link/Link.d.ts +1 -0
  212. package/dist/esm/types/src/components/Router/Link/Link.types.d.ts +12 -0
  213. package/dist/esm/types/src/components/Router/Redirect.d.ts +5 -0
  214. package/dist/esm/types/src/components/Router/Route.d.ts +5 -0
  215. package/dist/esm/types/src/components/Router/Router.d.ts +7 -0
  216. package/dist/esm/types/src/components/Router/Router.helpers.d.ts +2 -0
  217. package/dist/esm/types/src/components/Router/Router.types.d.ts +18 -0
  218. package/dist/esm/types/src/components/Router/context.d.ts +6 -0
  219. package/dist/esm/types/src/components/Router/store.d.ts +2 -0
  220. package/dist/esm/types/src/components/Scroll/Scroll.d.ts +67 -0
  221. package/dist/esm/types/src/components/Scroll/Scroll.types.d.ts +27 -0
  222. package/dist/esm/types/src/components/Select/Select.d.ts +94 -0
  223. package/dist/esm/types/src/components/Select/Select.helpers.d.ts +14 -0
  224. package/dist/esm/types/src/components/Select/Select.types.d.ts +74 -0
  225. package/dist/esm/types/src/components/Spinner/Spinner.d.ts +3 -0
  226. package/dist/esm/types/src/components/Spinner/Spinner.types.d.ts +4 -0
  227. package/dist/esm/types/src/components/Table/Table.d.ts +8 -0
  228. package/dist/esm/types/src/components/Table/Table.types.d.ts +19 -0
  229. package/dist/esm/types/src/components/Tabs/Tabs.d.ts +3 -0
  230. package/dist/esm/types/src/components/Tabs/Tabs.types.d.ts +27 -0
  231. package/dist/esm/types/src/components/Text/Text.d.ts +7 -0
  232. package/dist/esm/types/src/components/Theme/Theme.d.ts +5 -0
  233. package/dist/esm/types/src/components/Theme/Theme.defaults.d.ts +32 -0
  234. package/dist/esm/types/src/components/Theme/Theme.helpers.d.ts +15 -0
  235. package/dist/esm/types/src/components/Theme/Theme.types.d.ts +6 -0
  236. package/dist/esm/types/src/components/VH/VH.d.ts +12 -0
  237. package/dist/esm/types/src/components/Virtualized/Cards/Cards.d.ts +26 -0
  238. package/dist/esm/types/src/components/Virtualized/List/List.d.ts +44 -0
  239. package/dist/esm/types/src/components/Virtualized/List/ListScroll.d.ts +8 -0
  240. package/dist/esm/types/src/components/Virtualized/Table/Table.d.ts +26 -0
  241. package/dist/esm/types/src/components/Virtualized/Virtualized.d.ts +34 -0
  242. package/dist/esm/types/src/components/Virtualized/Virtualized.helpers.d.ts +18 -0
  243. package/dist/esm/types/src/components/Virtualized/Virtualized.types.d.ts +53 -0
  244. package/dist/esm/types/src/components/Virtualized/index.d.ts +4 -0
  245. package/dist/esm/types/src/components/index.d.ts +33 -0
  246. package/dist/esm/types/src/index.d.ts +3 -0
  247. package/dist/esm/types/src/services/i18n.d.ts +16 -0
  248. package/dist/esm/types/src/services/index.d.ts +1 -0
  249. package/dist/esm/types/src/tools/array.d.ts +8 -0
  250. package/dist/esm/types/src/tools/config.d.ts +10 -0
  251. package/dist/esm/types/src/tools/debounce.d.ts +1 -0
  252. package/dist/esm/types/src/tools/dom.d.ts +12 -0
  253. package/dist/esm/types/src/tools/env.d.ts +1 -0
  254. package/dist/esm/types/src/tools/file.d.ts +1 -0
  255. package/dist/esm/types/src/tools/index.d.ts +16 -0
  256. package/dist/esm/types/src/tools/localStorage.d.ts +12 -0
  257. package/dist/esm/types/src/tools/number.d.ts +5 -0
  258. package/dist/esm/types/src/tools/object.d.ts +1 -0
  259. package/dist/esm/types/src/tools/queryParams.d.ts +3 -0
  260. package/dist/esm/types/src/tools/rangeMap.d.ts +2 -0
  261. package/dist/esm/types/src/tools/resizeObserver.d.ts +2 -0
  262. package/dist/esm/types/src/tools/scroll.d.ts +5 -0
  263. package/dist/esm/types/src/tools/string.d.ts +1 -0
  264. package/dist/esm/types/src/tools/throttle.d.ts +6 -0
  265. package/dist/esm/types/src/tools/uid.d.ts +1 -0
  266. package/dist/esm/types/src/types.d.ts +15 -0
  267. package/package.json +117 -0
@@ -0,0 +1,68 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { memo } from 'react';
3
+ import { nanoid } from 'nanoid';
4
+ import { createStore, withStore } from 'justorm/react';
5
+ import _i18n from 'roddeh-i18n';
6
+ import LS from '../tools/localStorage.js';
7
+ import { queryParams } from '../tools/queryParams.js';
8
+
9
+ const DEFAULT_LANG = 'en';
10
+ const modules = {};
11
+ const queryLang = queryParams.lang;
12
+ if (queryLang)
13
+ LS.set('lang', queryLang);
14
+ const store = createStore('i18n', {
15
+ lang: LS.get('lang') ?? DEFAULT_LANG,
16
+ async changeLang(lang) {
17
+ // TODO: use WebWorker for requests?
18
+ const requests = modules[lang].map(loader => loader());
19
+ await Promise.all(requests);
20
+ modules[lang] = [];
21
+ this.lang = lang;
22
+ LS.set('lang', lang);
23
+ },
24
+ });
25
+ function init(config) {
26
+ const langs = Object.keys(config);
27
+ const texts = langs.reduce((acc, lang) => ({ ...acc, [lang]: _i18n.create({ values: {} }) }), {});
28
+ const _getText = (lang, key, props) => {
29
+ if (texts[lang]?.translator.data.values[key]) {
30
+ return texts[lang](key, ...props);
31
+ }
32
+ return null;
33
+ };
34
+ function getTrans(key, props = []) {
35
+ return _getText(store.lang, key, props) || key;
36
+ }
37
+ const storeName = `i18n-${nanoid()}`;
38
+ const componentStore = createStore(storeName, { _updated: '' });
39
+ const callLoader = async (loader, lang) => {
40
+ const values = typeof loader === 'function' ? (await loader()).default : loader;
41
+ texts[lang].translator.add({ values });
42
+ componentStore._updated = nanoid();
43
+ };
44
+ Object.entries(config).forEach(([lang, loader]) => {
45
+ if (!modules[lang])
46
+ modules[lang] = [];
47
+ if (lang === store.lang)
48
+ return callLoader(loader, lang);
49
+ modules[lang].push(() => callLoader(loader, lang));
50
+ });
51
+ // TODO: revert ability to register modules
52
+ return {
53
+ storeName,
54
+ componentStore,
55
+ // hook (update when componentStore._updated changed)
56
+ withI18N: Component => withStore(storeName)(Component),
57
+ i18n: (key, props) => getTrans(key, props),
58
+ I18N: memo(withStore({
59
+ i18n: ['lang'],
60
+ [storeName]: true,
61
+ })(function I18N({ id, children, props }) {
62
+ const key = id ?? children;
63
+ return jsx(Fragment, { children: getTrans(key, props) });
64
+ })),
65
+ };
66
+ }
67
+
68
+ export { init, store };
@@ -0,0 +1,60 @@
1
+ function indexWhere(arr, val, fieldName) {
2
+ if (!fieldName) {
3
+ return arr.indexOf(val);
4
+ }
5
+ const isValObj = typeof val === 'object';
6
+ let index = -1;
7
+ arr.some((d, i) => {
8
+ const dVal = isValObj ? val?.[fieldName] : val;
9
+ if (d?.[fieldName] === dVal) {
10
+ index = i;
11
+ return true;
12
+ }
13
+ return false;
14
+ });
15
+ return index;
16
+ }
17
+ function sliceWhere([...arr], val, fieldName) {
18
+ spliceWhere(arr, val, fieldName);
19
+ return arr;
20
+ }
21
+ function spliceWhere(arr, val, fieldName) {
22
+ const index = indexWhere(arr, val, fieldName);
23
+ if (index > -1)
24
+ arr.splice(index, 1);
25
+ }
26
+ function _addUniq({ arr, val, fieldName }, action) {
27
+ if (Array.isArray(val)) {
28
+ val.forEach(v => addUniq(arr, v, fieldName));
29
+ return;
30
+ }
31
+ const index = indexWhere(arr, val, fieldName);
32
+ if (index === -1)
33
+ action(val);
34
+ }
35
+ function addUniq(arr, val, fieldName) {
36
+ _addUniq({ arr, val, fieldName }, value => arr.push(value));
37
+ }
38
+ function unshiftUniq(arr, val, fieldName) {
39
+ _addUniq({ arr, val, fieldName }, value => arr.unshift(value));
40
+ }
41
+ function insert(baseArr, targetArr, startIndex) {
42
+ return [
43
+ ...baseArr.slice(0, startIndex),
44
+ ...targetArr,
45
+ ...baseArr.slice(startIndex + targetArr.length),
46
+ ];
47
+ }
48
+ function getIndexCircular(arr, index) {
49
+ const l = arr.length;
50
+ return arr[((index % l) + l) % l];
51
+ }
52
+ function circularSlice(arr, startIndex, count) {
53
+ const newArr = [];
54
+ for (let i = 0; i < count; i++) {
55
+ newArr.push(getIndexCircular(arr, startIndex + i));
56
+ }
57
+ return newArr;
58
+ }
59
+
60
+ export { addUniq, circularSlice, getIndexCircular, indexWhere, insert, sliceWhere, spliceWhere, unshiftUniq };
@@ -0,0 +1,9 @@
1
+ const config = {
2
+ appRootId: 'app-root',
3
+ appOverlayId: 'app-modal',
4
+ configure(params) {
5
+ Object.assign(this, params);
6
+ },
7
+ };
8
+
9
+ export { config };
@@ -0,0 +1,11 @@
1
+ import Time from 'timen';
2
+
3
+ function debounce(fn, ms) {
4
+ let unsubscribeFn;
5
+ return function debounced(...args) {
6
+ unsubscribeFn?.();
7
+ unsubscribeFn = Time.after(ms, () => fn.apply(this, args));
8
+ };
9
+ }
10
+
11
+ export { debounce as default };
@@ -0,0 +1,46 @@
1
+ import { isBrowser } from './env.js';
2
+ import 'nanoid';
3
+ import 'timen';
4
+ import 'compareq';
5
+ import 'lodash.pick';
6
+ import './queryParams.js';
7
+
8
+ function getCoords(elem) {
9
+ const box = elem.getBoundingClientRect();
10
+ return {
11
+ top: box.top + window.pageYOffset,
12
+ left: box.left + window.pageXOffset,
13
+ };
14
+ }
15
+ function hasParent(elem, parentElem) {
16
+ const isEqual = elem === parentElem;
17
+ if (isEqual || elem.nodeName === 'HTML') {
18
+ return isEqual;
19
+ }
20
+ return hasParent(elem.parentNode, parentElem);
21
+ }
22
+ var INTERACTION_MODE;
23
+ (function (INTERACTION_MODE) {
24
+ INTERACTION_MODE["POINTER"] = "pointer";
25
+ INTERACTION_MODE["KEYBOARD"] = "keyboard";
26
+ })(INTERACTION_MODE || (INTERACTION_MODE = {}));
27
+ let interactionMode = INTERACTION_MODE.POINTER;
28
+ const getInteractionMode = () => interactionMode;
29
+ function watchControllerFlag() {
30
+ const classes = document.body.classList;
31
+ const onPointerMove = () => {
32
+ classes.remove(INTERACTION_MODE.KEYBOARD);
33
+ classes.add(INTERACTION_MODE.POINTER);
34
+ };
35
+ ['pointerdown', 'pointermove'].forEach(event => {
36
+ document.addEventListener(event, onPointerMove, true);
37
+ });
38
+ document.addEventListener('keydown', () => {
39
+ classes.remove(INTERACTION_MODE.POINTER);
40
+ classes.add(INTERACTION_MODE.KEYBOARD);
41
+ });
42
+ classes.add(interactionMode);
43
+ }
44
+ const isTouch = () => isBrowser && 'ontouchstart' in window;
45
+
46
+ export { INTERACTION_MODE, getCoords, getInteractionMode, hasParent, isTouch, watchControllerFlag };
@@ -0,0 +1,3 @@
1
+ const isBrowser = typeof window !== 'undefined';
2
+
3
+ export { isBrowser };
@@ -0,0 +1,11 @@
1
+ function toBase64(file) {
2
+ return new Promise(resolve => {
3
+ const reader = new FileReader();
4
+ reader.readAsDataURL(file);
5
+ reader.onload = () => resolve(reader.result);
6
+ // @ts-ignore
7
+ reader.onerror = error => resolve({ error });
8
+ });
9
+ }
10
+
11
+ export { toBase64 };
@@ -0,0 +1,31 @@
1
+ import { isBrowser } from './env.js';
2
+
3
+ const ls = isBrowser && window.localStorage;
4
+ var LS = isBrowser
5
+ ? {
6
+ get(key) {
7
+ let result = ls.getItem(key);
8
+ try {
9
+ result = JSON.parse(result);
10
+ }
11
+ catch (e) { }
12
+ return result;
13
+ },
14
+ set(key, val) {
15
+ if (!val) {
16
+ this.remove(key);
17
+ return;
18
+ }
19
+ const item = typeof val === 'object' ? JSON.stringify(val) : val;
20
+ ls.setItem(key, item);
21
+ },
22
+ remove(key) {
23
+ ls.removeItem(key);
24
+ },
25
+ clear() {
26
+ ls.clear();
27
+ },
28
+ }
29
+ : { get() { }, set() { }, remove() { }, clear() { } };
30
+
31
+ export { LS as default };
@@ -0,0 +1,27 @@
1
+ const LABEL = ['', 'k', 'M', 'B'];
2
+ function stringify(number) {
3
+ if (typeof number === 'string')
4
+ return number.match(/\d/g).join('');
5
+ return String(number);
6
+ }
7
+ const format = {
8
+ short(number, lv = 0) {
9
+ const numStr = stringify(number);
10
+ const level = Math.floor((numStr.length - 1) / 3);
11
+ if (level === 0)
12
+ return numStr;
13
+ const label = LABEL[level];
14
+ const num = numStr.slice(0, -level * 3);
15
+ return `${num}${label}`;
16
+ },
17
+ sections(number, splitter = ' ') {
18
+ const [whole, fractional] = stringify(number).split('.');
19
+ let result = whole.replace(/\B(?=(\d{3})+(?!\d))/g, splitter);
20
+ if (fractional !== undefined)
21
+ result = `${result}.${fractional}`;
22
+ return result;
23
+ },
24
+ };
25
+ const zero = num => num || 0;
26
+
27
+ export { format, zero };
@@ -0,0 +1,5 @@
1
+ function clone(obj) {
2
+ return JSON.parse(JSON.stringify(obj));
3
+ }
4
+
5
+ export { clone };
@@ -0,0 +1,20 @@
1
+ import { isBrowser } from './env.js';
2
+
3
+ const SSRQueryParams = {};
4
+ function parseQueryParams(qs) {
5
+ const queryString = qs || isBrowser ? location?.search : '';
6
+ if (!queryString)
7
+ return {};
8
+ return [...new URLSearchParams(queryString).entries()].reduce((acc, [key, value]) => {
9
+ acc[key] = value;
10
+ return acc;
11
+ }, {});
12
+ }
13
+ const setSSRQueryParams = (params) => {
14
+ Object.assign(SSRQueryParams, params);
15
+ };
16
+ const queryParams = isBrowser
17
+ ? parseQueryParams()
18
+ : SSRQueryParams;
19
+
20
+ export { parseQueryParams, queryParams, setSSRQueryParams };
@@ -0,0 +1,3 @@
1
+ var rangeMap = (value, x1, y1, x2, y2) => ((value - x1) * (y2 - x2)) / (y1 - x1) + x2;
2
+
3
+ export { rangeMap as default };
@@ -0,0 +1,64 @@
1
+ import Time from 'timen';
2
+ import compare from 'compareq';
3
+ import pick from 'lodash.pick';
4
+ import { addUniq, spliceWhere } from './array.js';
5
+ import { isBrowser } from './env.js';
6
+
7
+ const ITEMS = new Map();
8
+ const NATIVE_OBSERVERS = new Map();
9
+ const IS_NATIVE = isBrowser && 'ResizeObserver' in window;
10
+ const TIMEOUT = 500;
11
+ const SIZE_FIELDS = ['offsetWidth', 'offsetHeight'];
12
+ function check() {
13
+ ITEMS.forEach((item, elem) => {
14
+ const { sizes, listeners } = item;
15
+ const newSizes = pick(elem, SIZE_FIELDS);
16
+ if (!compare(newSizes, sizes)) {
17
+ item.sizes = newSizes;
18
+ listeners.forEach(cb => cb(newSizes, elem));
19
+ }
20
+ });
21
+ run();
22
+ }
23
+ function run() {
24
+ if (ITEMS.size > 0)
25
+ Time.after(TIMEOUT, check);
26
+ }
27
+ function observe(elem, cb) {
28
+ if (IS_NATIVE) {
29
+ const observer = new ResizeObserver(cb);
30
+ observer.observe(elem);
31
+ NATIVE_OBSERVERS.set(elem, observer);
32
+ return;
33
+ }
34
+ const data = ITEMS.get(elem);
35
+ if (data) {
36
+ addUniq(data.listeners, cb);
37
+ return;
38
+ }
39
+ ITEMS.set(elem, {
40
+ sizes: pick(elem, SIZE_FIELDS),
41
+ listeners: [cb],
42
+ });
43
+ if (ITEMS.size === 1)
44
+ run();
45
+ }
46
+ function unobserve(elem, cb) {
47
+ if (IS_NATIVE) {
48
+ const observer = NATIVE_OBSERVERS.get(elem);
49
+ if (!observer)
50
+ return;
51
+ observer.unobserve(elem);
52
+ NATIVE_OBSERVERS.delete(elem);
53
+ return;
54
+ }
55
+ const data = ITEMS.get(elem);
56
+ if (!cb || data?.listeners.indexOf(cb) === -1)
57
+ return;
58
+ if (data.listeners.length === 1)
59
+ ITEMS.delete(elem);
60
+ else
61
+ spliceWhere(data.listeners, cb);
62
+ }
63
+
64
+ export { observe, unobserve };
@@ -0,0 +1,41 @@
1
+ const METRICS_BY_AXIS = {
2
+ horizontal: {
3
+ size: 'offsetWidth',
4
+ scroll: 'scrollWidth',
5
+ },
6
+ vertical: {
7
+ size: 'offsetHeight',
8
+ scroll: 'scrollHeight',
9
+ },
10
+ };
11
+ function isScrollable(node, axis, threshold = 5) {
12
+ const m = METRICS_BY_AXIS[axis];
13
+ return node[m.scroll] - node[m.size] > threshold;
14
+ }
15
+ function getScrollParent(node, axis = 'vertical') {
16
+ if (node == null)
17
+ return null;
18
+ if (node.tagName === 'BODY' || isScrollable(node, axis))
19
+ return node;
20
+ return getScrollParent(node.parentNode, axis);
21
+ }
22
+ function scrollTo(elem, left, top) {
23
+ if ('scrollBehavior' in document.documentElement.style) {
24
+ elem.scrollTo({ left, top, behavior: 'smooth' });
25
+ return;
26
+ }
27
+ elem.scrollTo(left, top);
28
+ }
29
+ function scrollIntoView(elem, { horizontal } = { horizontal: false }) {
30
+ if (!elem)
31
+ return;
32
+ const scrollParent = getScrollParent(elem);
33
+ if (!scrollParent)
34
+ return;
35
+ const to = horizontal
36
+ ? elem.offsetLeft + elem.offsetWidth / 2 - scrollParent.clientWidth / 2
37
+ : elem.offsetTop + elem.offsetHeight / 2 - scrollParent.clientHeight / 2;
38
+ scrollTo(scrollParent, 0, Math.max(0, to));
39
+ }
40
+
41
+ export { getScrollParent, scrollIntoView, scrollTo };
@@ -0,0 +1,7 @@
1
+ function capitalize(str = '') {
2
+ if (typeof str !== 'string' || !str)
3
+ return str;
4
+ return `${str[0].toUpperCase()}${str.slice(1)}`;
5
+ }
6
+
7
+ export { capitalize };
@@ -0,0 +1,30 @@
1
+ import Time from 'timen';
2
+
3
+ function throttle(fn, ms, { trailing, skipFirst } = {}) {
4
+ let isCooldown = skipFirst;
5
+ let isCalledAtCooldown = false;
6
+ function runNext(...args) {
7
+ Time.after(ms, () => {
8
+ isCooldown = false;
9
+ if (trailing && isCalledAtCooldown) {
10
+ fn.apply(this, args);
11
+ isCalledAtCooldown = false;
12
+ }
13
+ });
14
+ }
15
+ return function throttled(...args) {
16
+ if (isCooldown) {
17
+ if (!isCalledAtCooldown && skipFirst && trailing)
18
+ runNext.apply(this, args);
19
+ isCalledAtCooldown = true;
20
+ }
21
+ else {
22
+ isCooldown = true;
23
+ isCalledAtCooldown = false;
24
+ fn.apply(this, args);
25
+ runNext.apply(this, args);
26
+ }
27
+ };
28
+ }
29
+
30
+ export { throttle as default };
@@ -0,0 +1,7 @@
1
+ import { nanoid } from 'nanoid';
2
+
3
+ function generateUID() {
4
+ return nanoid().replace(/^\d+/g, '').replace(/-/g, '_');
5
+ }
6
+
7
+ export { generateUID };
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as T from './AssistiveText.types';
3
+ export declare function AssistiveText(props: T.Props): JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { ReactNode, HTMLAttributes } from 'react';
2
+ export type Props = HTMLAttributes<HTMLDivElement> & {
3
+ className?: string;
4
+ size?: 's' | 'm' | 'l';
5
+ variant?: 'default' | 'danger';
6
+ children: ReactNode;
7
+ };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import * as T from './Button.types';
3
+ export type ButtonProps = T.Props;
4
+ export declare function Button(props: T.Props): JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function focusOnClick(buttonElem: HTMLButtonElement | null): void;
@@ -0,0 +1,14 @@
1
+ import { ButtonHTMLAttributes, ReactNode } from 'react';
2
+ import { Size } from 'uilib/types';
3
+ export type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
4
+ className?: string;
5
+ children: ReactNode;
6
+ variant?: 'clear' | 'default' | 'outlined' | 'primary';
7
+ size?: Size;
8
+ loading?: boolean;
9
+ checked?: boolean;
10
+ square?: boolean;
11
+ prefixElem?: ReactNode;
12
+ postfixElem?: ReactNode;
13
+ onRef?: (ref: HTMLButtonElement) => void;
14
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as T from './ButtonGroup.types';
3
+ export declare function ButtonGroup(props: T.Props): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export type Props = HTMLAttributes<HTMLDivElement> & {
3
+ children: React.ReactNode;
4
+ className?: string;
5
+ };
@@ -0,0 +1,18 @@
1
+ import { Component } from 'react';
2
+ import * as T from './Checkbox.types';
3
+ export declare class Checkbox extends Component<T.Props> {
4
+ id: any;
5
+ store: any;
6
+ static defaultProps: {
7
+ size: string;
8
+ variant: string;
9
+ label: string;
10
+ checked: boolean;
11
+ };
12
+ constructor(props: any);
13
+ onMouseDown: () => void;
14
+ onMouseUp: () => void;
15
+ onFocus: (e: any) => void;
16
+ onBlur: (e: any) => void;
17
+ render(): JSX.Element;
18
+ }
@@ -0,0 +1,10 @@
1
+ import { ReactNode, HTMLAttributes } from 'react';
2
+ import { Size, ComponentType } from '../../types';
3
+ export type Props = HTMLAttributes<HTMLInputElement> & ComponentType & {
4
+ label?: ReactNode;
5
+ checked?: boolean;
6
+ disabled?: boolean;
7
+ error?: string | boolean;
8
+ size?: Size;
9
+ variant?: 'default' | 'outlined';
10
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as T from './Container.types';
3
+ export declare function Container(props: T.Props): JSX.Element;
@@ -0,0 +1,13 @@
1
+ export type Props = {
2
+ className?: string;
3
+ size?: 's' | 'm' | 'l' | 'xl';
4
+ children: any;
5
+ alignItemsCenter?: boolean;
6
+ justifyContentCenter?: boolean;
7
+ vertical?: boolean;
8
+ fullHeight?: boolean | string;
9
+ fullWidth?: boolean | string;
10
+ scrolledX?: boolean;
11
+ scrolledY?: boolean;
12
+ style?: Partial<CSSStyleDeclaration>;
13
+ };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import * as T from './DateTime.types';
3
+ export declare function formatDate({ value, format, locale }: {
4
+ value: any;
5
+ format: any;
6
+ locale?: string;
7
+ }): any;
8
+ export declare function DateTime({ value, format, locale }: T.Props): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { Moment } from 'moment';
2
+ export type Props = {
3
+ value?: Date | Moment | string;
4
+ format?: string;
5
+ locale?: string;
6
+ };
@@ -0,0 +1,24 @@
1
+ import { Component } from 'react';
2
+ import * as T from './Draggable.types';
3
+ export declare class Draggable extends Component<T.Props> {
4
+ store: any;
5
+ startPos: any;
6
+ draggingElem: any;
7
+ draggingElemBounds: any;
8
+ dragStartFired: boolean;
9
+ timers: any;
10
+ constructor(props: any);
11
+ componentDidUpdate(prevProps: any): void;
12
+ componentWillUnmount(): void;
13
+ onPointerDown: (e: any) => void;
14
+ onPointerMove: (e: any) => void;
15
+ checkUnderElem: any;
16
+ onPointerOut: ({ target }: {
17
+ target: any;
18
+ }) => void;
19
+ onPointerUp: (e: any) => void;
20
+ selectInner: (elem: any) => any;
21
+ transformInner(elem: any, str?: any): void;
22
+ dropUnder(): void;
23
+ render(): JSX.Element;
24
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ export type Props = {
3
+ items: string[];
4
+ className?: string;
5
+ itemClassName?: string;
6
+ renderItem: (id: string, isActive: boolean) => ReactNode;
7
+ onDragStart?: (id: string) => void;
8
+ onDragEnd?: (id: string) => void;
9
+ onChange: (items: string[]) => void;
10
+ children?: ReactNode;
11
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as T from './Expand.types';
3
+ export declare function Expand(props: T.Props): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { Size } from 'uilib/types';
3
+ type ContentProps = HTMLAttributes<HTMLDivElement> & {
4
+ className?: string;
5
+ };
6
+ export type Props = {
7
+ className?: string;
8
+ size?: Size;
9
+ isOpen: boolean;
10
+ header: ReactNode;
11
+ headerClassName?: string;
12
+ content: (props: ContentProps) => ReactNode | ReactNode;
13
+ contentProps?: ContentProps;
14
+ onChange?: (isOpen: boolean) => void;
15
+ };
16
+ export {};