@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,292 @@
1
+ import { Component, createRef, createElement } from 'react';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { createStore } from 'justorm/react';
4
+ import cn from 'classnames';
5
+ import pick from 'lodash.pick';
6
+ import compare from 'compareq';
7
+ import Time from 'timen';
8
+ import { Label } from '../Label/Label.js';
9
+ import { Icon } from '../Icon/Icon.js';
10
+ import { Scroll } from '../Scroll/Scroll.js';
11
+ import { toBase64 } from '../../tools/file.js';
12
+ import { spliceWhere } from '../../tools/array.js';
13
+ import S from './InputFile.styl.js';
14
+ import Item from './Item/Item.js';
15
+ import '../AssistiveText/AssistiveText.styl.js';
16
+ import '../Spinner/Spinner.styl.js';
17
+ import '../Button/Button.styl.js';
18
+ import '../ButtonGroup/ButtonGroup.styl.js';
19
+ import 'nanoid';
20
+ import '../Checkbox/Checkbox.styl.js';
21
+ import '../Container/Container.styl.js';
22
+ import 'moment';
23
+ import { Draggable } from '../Draggable/Draggable.js';
24
+ import '../Expand/Expand.styl.js';
25
+ import 'lodash.omit';
26
+ import '../RequiredStar/RequiredStar.styl.js';
27
+ import '../Input/Input.styl.js';
28
+ import '../Form/Form.styl.js';
29
+ import '../Form/Validator.js';
30
+ import '../Form/SubmitButtons/SubmitButtons.styl.js';
31
+ import '../Gallery/Gallery.styl.js';
32
+ import '../Heading/Heading.js';
33
+ import '../Portal/Portal.js';
34
+ import '../Paranja/Paranja.styl.js';
35
+ import '../LightBox/LightBox.styl.js';
36
+ import '../Notifications/Notifications.js';
37
+ import '../../tools/dom.js';
38
+ import '../Popup/Popup.styl.js';
39
+ import '../../tools/queryParams.js';
40
+ import '../PopupMenu/PopupMenu.styl.js';
41
+ import '../Router/Router.js';
42
+ import '../Select/Select.styl.js';
43
+ import '../Table/Table.styl.js';
44
+ import '../Tabs/Tabs.styl.js';
45
+ import '../Text/Text.js';
46
+ import '../Virtualized/Virtualized.styl.js';
47
+ import '../Virtualized/List/List.styl.js';
48
+ import '../Virtualized/List/ListScroll.styl.js';
49
+ import '../../services/i18n.js';
50
+
51
+ const SCROLL_OFFSET = {
52
+ s: 10,
53
+ m: 12,
54
+ l: 16,
55
+ };
56
+ const defaultFileState = {
57
+ total: 1,
58
+ loaded: 0,
59
+ error: null,
60
+ base64: '',
61
+ };
62
+ const buildDefaultState = (src, index, loaded) => ({
63
+ ...defaultFileState,
64
+ loaded,
65
+ index,
66
+ src,
67
+ });
68
+ class InputFile extends Component {
69
+ store;
70
+ filesToUpload = []; // [File,...]
71
+ previewRequests = {}; // [index]: Promise
72
+ inputRef = createRef();
73
+ _mounted = false;
74
+ constructor(props) {
75
+ super(props);
76
+ this.store = createStore(this, {
77
+ items: this.getStateFromProps(),
78
+ labelClipPath: '',
79
+ pickingIndex: null,
80
+ isDragging: false,
81
+ });
82
+ }
83
+ static defaultProps = {
84
+ size: 'm',
85
+ variant: 'default',
86
+ maxCount: 1,
87
+ };
88
+ componentDidMount() {
89
+ this._mounted = true;
90
+ this.props.uploadOnDemand?.(this.demandedUploader);
91
+ }
92
+ componentWillUnmount() {
93
+ this._mounted = false;
94
+ this.store.items.forEach(({ xhr }) => xhr?.abort());
95
+ }
96
+ componentDidUpdate(prevProps) {
97
+ const { value, maxCount } = this.props;
98
+ if (!compare(prevProps.value, value) || prevProps.maxCount !== maxCount) {
99
+ this.store.items = this.getStateFromProps();
100
+ }
101
+ }
102
+ isMultiple = () => this.props.maxCount > 1;
103
+ getStateFromProps() {
104
+ const { value, maxCount, upload } = this.props;
105
+ const loaded = upload ? 1 : 0;
106
+ if (this.isMultiple()) {
107
+ if (maxCount === 1)
108
+ return [buildDefaultState(value, 0, loaded)];
109
+ return value
110
+ .slice(0, maxCount)
111
+ .map((src, index) => buildDefaultState(src, index, loaded));
112
+ }
113
+ const val = Array.isArray(value) ? value[0] : value;
114
+ return val ? [buildDefaultState(val, 0, loaded)] : [];
115
+ }
116
+ getValFromState = () => {
117
+ const { items } = this.store;
118
+ if (this.isMultiple())
119
+ return items.map(({ src, base64 }) => src || base64);
120
+ if (!items[0])
121
+ return null;
122
+ return items[0].src || items[0].base64;
123
+ };
124
+ getLastIndex = () => {
125
+ const { value } = this.props;
126
+ return Array.isArray(value) ? value.length : 0;
127
+ };
128
+ filterAllowedFiles(files, index) {
129
+ const { maxCount, limit } = this.props;
130
+ const allowedFiles = [];
131
+ [...files].every(file => {
132
+ if (index >= maxCount)
133
+ return false;
134
+ if (limit) {
135
+ const sizeMb = file.size / 1024 / 1024;
136
+ if (sizeMb > limit) {
137
+ console.error(`Max file size - ${limit}Mb`, file);
138
+ return false;
139
+ }
140
+ }
141
+ allowedFiles.push(file);
142
+ index++;
143
+ return true;
144
+ }, []);
145
+ return allowedFiles;
146
+ }
147
+ onPlusButtonClick = () => this.inputRef.current.click();
148
+ onItemClick(index) {
149
+ this.store.pickingIndex = index;
150
+ Time.after(50, () => this.inputRef.current.click());
151
+ }
152
+ onDragStart = () => (this.store.isDragging = true);
153
+ onDragEnd = () => (this.store.isDragging = false);
154
+ onChange = async (e) => {
155
+ const { files } = e.target;
156
+ const { items, pickingIndex } = this.store;
157
+ const { onSelect, uploadOnDemand, upload } = this.props;
158
+ let index = pickingIndex ?? this.getLastIndex();
159
+ const allowedFiles = this.filterAllowedFiles(files, index);
160
+ allowedFiles.forEach(file => {
161
+ items[index] = { ...defaultFileState, index };
162
+ this.filesToUpload[index] = file;
163
+ this.previewRequests[index] = this.generatePreview(file, index);
164
+ index++;
165
+ });
166
+ onSelect?.(allowedFiles);
167
+ if (upload)
168
+ this.processUploadOnChange(allowedFiles);
169
+ if (uploadOnDemand)
170
+ this.processUploadOnDemand();
171
+ if (typeof pickingIndex === 'number')
172
+ this.store.pickingIndex = null;
173
+ };
174
+ onReorder = ids => {
175
+ const { items } = this.store;
176
+ const { onChange } = this.props;
177
+ this.store.items = ids.map(id => items[id]);
178
+ onChange(null, this.getValFromState());
179
+ };
180
+ onProgress = state => e => {
181
+ Object.assign(state, pick(e, ['total', 'loaded']));
182
+ };
183
+ async generatePreview(file, index) {
184
+ const state = this.store.items[index];
185
+ Object.assign(state, defaultFileState);
186
+ state.base64 = await toBase64(file);
187
+ delete this.previewRequests[index];
188
+ }
189
+ async processUploadOnDemand() {
190
+ await Promise.all(Object.values(this.previewRequests));
191
+ if (!this._mounted)
192
+ return;
193
+ const { onChange } = this.props;
194
+ onChange(null, this.getValFromState());
195
+ }
196
+ async processUploadOnChange(files) {
197
+ const { onChange } = this.props;
198
+ const { pickingIndex } = this.store;
199
+ const lastIndex = pickingIndex ?? this.getLastIndex();
200
+ const reqs = files.map((file, i) => this.upload(file, lastIndex + i));
201
+ await Promise.all(reqs);
202
+ onChange(null, this.getValFromState());
203
+ }
204
+ async upload(file, index) {
205
+ const { upload } = this.props;
206
+ const { items } = this.store;
207
+ const state = items[index];
208
+ const src = await upload({
209
+ file,
210
+ onProgress: this.onProgress(state),
211
+ getXHR: xhr => (state.xhr = xhr),
212
+ });
213
+ delete this.filesToUpload[index];
214
+ if (!this._mounted)
215
+ return;
216
+ Object.assign(state, {
217
+ src,
218
+ loaded: state.total,
219
+ xhr: null,
220
+ });
221
+ }
222
+ demandedUploader = async (upload) => {
223
+ const { value } = this.props;
224
+ const { items } = this.store;
225
+ let newVal;
226
+ if (this.isMultiple()) {
227
+ const requests = [];
228
+ newVal = [...value];
229
+ value.forEach((val, i) => {
230
+ const file = this.filesToUpload[i];
231
+ if (file) {
232
+ const params = { file, onProgress: this.onProgress(items[i]) };
233
+ requests.push(upload(params).then(url => (newVal[i] = url)));
234
+ }
235
+ });
236
+ await Promise.all(requests);
237
+ }
238
+ else {
239
+ newVal = await upload(this.filesToUpload[0], this.onProgress(items[0]));
240
+ }
241
+ this.filesToUpload = [];
242
+ return newVal;
243
+ };
244
+ remove = async (e, value) => {
245
+ e.stopPropagation();
246
+ const { remove, onChange } = this.props;
247
+ if (remove) {
248
+ const res = await remove(value);
249
+ if (!res)
250
+ return;
251
+ }
252
+ const { items } = this.store;
253
+ spliceWhere(items, value, 'src');
254
+ onChange(null, this.getValFromState());
255
+ };
256
+ renderPlusButton() {
257
+ const { size } = this.props;
258
+ return (jsx("label", { className: cn(S.item, S.addButton), onClick: this.onPlusButtonClick, children: jsx(Icon, { type: "plus", size: size }) }, "add-button"));
259
+ }
260
+ renderItem = (i, props = {}) => {
261
+ const { size } = this.props;
262
+ const { base64, src, loaded, total } = this.store.items[i];
263
+ const url = base64 || src;
264
+ return (createElement(Item, { ...props, size: size, key: String(url) + i, img: url, total: total, loaded: loaded, waitingForUpload: !!this.filesToUpload[i], onRemove: e => this.remove(e, url), onClick: () => this.onItemClick(i) }));
265
+ };
266
+ renderItems() {
267
+ const { draggable, maxCount } = this.props;
268
+ const { items, isDragging } = this.store;
269
+ if (items.length === 0)
270
+ return this.renderPlusButton();
271
+ const needAddButton = this.isMultiple() && items.length < maxCount;
272
+ if (draggable) {
273
+ const ids = Array.from({ length: items.length }, (_, i) => String(i));
274
+ return (jsx(Draggable, { className: S.draggable, itemClassName: S.item, items: ids, onDragStart: this.onDragStart, onDragEnd: this.onDragEnd, onChange: this.onReorder, renderItem: id => this.renderItem(parseInt(id, 10), { isDragging }), children: needAddButton && this.renderPlusButton() }));
275
+ }
276
+ const elems = items.map((_, i) => this.renderItem(i, { className: S.item }));
277
+ if (needAddButton)
278
+ elems.push(this.renderPlusButton());
279
+ return elems;
280
+ }
281
+ render() {
282
+ // @ts-ignore
283
+ const { className, size, variant, draggable, label, maxCount, accept, value, } = this.props;
284
+ const { labelClipPath, pickingIndex } = this.store;
285
+ const isEmpty = !value?.length;
286
+ const classes = cn(S.root, className, isEmpty && S.empty, S[`size-${size}`], S[`variant-${variant}`], draggable && S.draggable);
287
+ const scrollOffset = SCROLL_OFFSET[size];
288
+ return (jsxs("div", { className: classes, children: [jsx("div", { className: S.border, suppressHydrationWarning: true, style: { clipPath: labelClipPath } }), jsx("input", { ref: this.inputRef, className: S.input, type: "file", multiple: maxCount > 1 && typeof pickingIndex !== 'number', accept: accept, onChange: this.onChange }), jsx(Label, { isOnTop: true, size: size, className: S.label, onClipPathChange: clipPath => (this.store.labelClipPath = clipPath), children: label }), jsx(Scroll, { y: true, size: "s", className: S.inner, innerClassName: S.items, fadeSize: size, offset: { y: { before: scrollOffset, after: scrollOffset } }, style: { clipPath: labelClipPath }, children: this.renderItems() })] }));
289
+ }
290
+ }
291
+
292
+ export { InputFile };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".InputFile_root__pY3JG{position:relative}.InputFile_border__whRyD{border-radius:inherit;height:100%;left:0;pointer-events:none;position:absolute;top:0;transition:background-color .2s ease-out;width:100%}.InputFile_variant-outlined__f5hnA .InputFile_border__whRyD{background-color:transparent;box-shadow:inset 0 0 0 2px var(--accent-color)}.InputFile_variant-default__Jqzal .InputFile_border__whRyD{background-color:var(--accent-color-alpha-100)}.InputFile_variant-default__Jqzal .InputFile_border__whRyD:hover{background-color:var(--active-color-alpha-300)}.InputFile_empty__7j1BK:hover .InputFile_border__whRyD{background-color:var(--active-color-alpha-500)}.InputFile_label__bAEz-{align-items:center;display:flex;height:100%;position:absolute}.InputFile_inner__BQFX7{max-height:inherit}.InputFile_items__ND1YG{align-items:center;display:flex;flex-wrap:wrap;font-size:0;margin:-4px;width:calc(100% + 8px)}.InputFile_item__qg5I6{display:inline-flex;margin:4px;position:relative}.InputFile_item__qg5I6:first-child:last-child{width:100%}.InputFile_addButton__rW719{align-items:center;cursor:pointer;justify-content:center;position:relative;transition:background-color .2s ease-out}.InputFile_root__pY3JG:not(.InputFile_empty__7j1BK) .InputFile_addButton__rW719:hover{background-color:var(--active-color-alpha-500)}.InputFile_input__7FR5r{bottom:0;left:0;opacity:0;pointer-events:none;position:absolute;right:0;top:0}.InputFile_size-s__hsWTE{font-size:12px}.InputFile_size-s__hsWTE .InputFile_border__whRyD,.InputFile_size-s__hsWTE .InputFile_item__qg5I6{border-radius:4px}.InputFile_size-s__hsWTE .InputFile_items__ND1YG{padding:10px}.InputFile_size-s__hsWTE .InputFile_item__qg5I6{height:50px;width:50px}.InputFile_size-m__unA0n{font-size:16px}.InputFile_size-m__unA0n .InputFile_border__whRyD,.InputFile_size-m__unA0n .InputFile_item__qg5I6{border-radius:6px}.InputFile_size-m__unA0n .InputFile_items__ND1YG{padding:12px}.InputFile_size-m__unA0n .InputFile_item__qg5I6{height:70px;width:70px}.InputFile_size-l__wpOVo{font-size:20px}.InputFile_size-l__wpOVo .InputFile_border__whRyD,.InputFile_size-l__wpOVo .InputFile_item__qg5I6{border-radius:8px}.InputFile_size-l__wpOVo .InputFile_items__ND1YG{padding:14px}.InputFile_size-l__wpOVo .InputFile_item__qg5I6{height:100px;width:100px}.InputFile_draggable__M7-3v{position:relative;width:100%}.InputFile_draggable__M7-3v .InputFile_item__qg5I6:not(.InputFile_addButton__rW719){cursor:move}";
4
+ var S = {"root":"InputFile_root__pY3JG","border":"InputFile_border__whRyD","variant-outlined":"InputFile_variant-outlined__f5hnA","variant-default":"InputFile_variant-default__Jqzal","empty":"InputFile_empty__7j1BK","label":"InputFile_label__bAEz-","inner":"InputFile_inner__BQFX7","items":"InputFile_items__ND1YG","item":"InputFile_item__qg5I6","addButton":"InputFile_addButton__rW719","input":"InputFile_input__7FR5r","size-s":"InputFile_size-s__hsWTE","size-m":"InputFile_size-m__unA0n","size-l":"InputFile_size-l__wpOVo","draggable":"InputFile_draggable__M7-3v"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import cn from 'classnames';
3
+ import { Button } from '../../Button/Button.js';
4
+ import { Icon } from '../../Icon/Icon.js';
5
+ import S from './Item.styl.js';
6
+
7
+ function Item(props) {
8
+ const { className, size, img, total, loaded, waitingForUpload, children, onRemove, isDragging, ...rest } = props;
9
+ const style = {};
10
+ const isComplete = loaded === total;
11
+ const isLoading = !isComplete && loaded > 0;
12
+ const classes = cn(S.root, S[`size-${size}`], waitingForUpload && S.waitingForUpload, isLoading && S.loading, isDragging && S.dragging, className);
13
+ if (img)
14
+ style.backgroundImage = `url(${img})`;
15
+ return (jsxs("div", { ...rest, className: classes, style: style, children: [children, jsx(Button, { className: S.removeButton, size: "s", variant: "clear", square: true, onClick: onRemove, children: jsx(Icon, { type: "delete" }) }), jsx("div", { className: cn(S.progress, isComplete && S.complete), style: { left: `${(loaded / total) * 100 - 100}%` } }), jsx("div", { className: S.overlay })] }));
16
+ }
17
+
18
+ export { Item as default };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".Item_root__uFQw8{background-position:50%;background-size:cover;height:100%;overflow:hidden;position:relative}.Item_root__uFQw8.Item_loading__hN0tA{pointer-events:none}.Item_root__uFQw8>.Item_overlay__lE8hl,.Item_root__uFQw8>img{border-radius:inherit}.Item_size-s__6FWi7{border-radius:4px}.Item_size-m__ICwh8{border-radius:6px}.Item_size-l__zv6Xj{border-radius:8px}.Item_overlay__lE8hl{bottom:0;left:0;pointer-events:none;position:absolute;right:0;top:0;transition:background-color .1s ease-out;z-index:1}.Item_waitingForUpload__JFsoN .Item_overlay__lE8hl{background-color:var(--accent-color-alpha-200);border:2px dashed var(--accent-color-alpha-500)}.Item_root__uFQw8:hover .Item_overlay__lE8hl{background-color:var(--active-color-alpha-500)}.Item_root__uFQw8:hover .Item_removeButton__EgOub{transform:translateX(0)}.Item_removeButton__EgOub{border-radius:0;border-top-left-radius:inherit;bottom:0;position:absolute;right:0;transform:translateX(100%);transition:transform .2s ease-out;z-index:2}.Item_removeButton__EgOub,.Item_removeButton__EgOub:hover{background-color:var(--decent-color-alpha-900)}.Item_removeButton__EgOub:hover{color:var(--danger-color)}.Item_progress__bpcNP{background-color:var(--active-color-alpha-800);height:100%;left:-100%;pointer-events:none;position:absolute;top:0;transition:all .2s ease-out;width:100%;z-index:1}.Item_progress__bpcNP.Item_complete__lEfmV{opacity:0}.Item_dragging__HPzfu{overflow:visible}.Item_dragging__HPzfu .Item_overlay__lE8hl,.Item_dragging__HPzfu .Item_progress__bpcNP,.Item_dragging__HPzfu .Item_removeButton__EgOub{display:none}";
4
+ var S = {"root":"Item_root__uFQw8","loading":"Item_loading__hN0tA","overlay":"Item_overlay__lE8hl","size-s":"Item_size-s__6FWi7","size-m":"Item_size-m__ICwh8","size-l":"Item_size-l__zv6Xj","waitingForUpload":"Item_waitingForUpload__JFsoN","removeButton":"Item_removeButton__EgOub","progress":"Item_progress__bpcNP","complete":"Item_complete__lEfmV","dragging":"Item_dragging__HPzfu"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -0,0 +1,8 @@
1
+ var LABEL_MULTIPLIER = 0.7;
2
+ var LABEL_PADDING = 5;
3
+ var C = {
4
+ LABEL_MULTIPLIER: LABEL_MULTIPLIER,
5
+ LABEL_PADDING: LABEL_PADDING
6
+ };
7
+
8
+ export { LABEL_MULTIPLIER, LABEL_PADDING, C as default };
@@ -0,0 +1,35 @@
1
+ import C from './Label.constants.json.js';
2
+
3
+ function getBottomOffset(size = 's') {
4
+ if (size === 'l')
5
+ return 4;
6
+ if (size === 'm')
7
+ return 2;
8
+ return 0;
9
+ }
10
+ function getLabelClipPath(left, width, size = 's') {
11
+ const offset = 10;
12
+ const A = left - C.LABEL_PADDING;
13
+ // @ts-ignore
14
+ const B = width === 0 ? 0 : left + width * C.LABEL_MULTIPLIER + C.LABEL_PADDING;
15
+ const cutWidth = 5 + getBottomOffset(size);
16
+ const min = `-${offset}px`;
17
+ const max = `calc(100% + ${offset}px)`;
18
+ const points = [
19
+ [min, min],
20
+ [min, max],
21
+ [max, max],
22
+ [max, min],
23
+ [`${B}px`, min],
24
+ [`${B}px`, `${cutWidth - 1}px`],
25
+ [`${B - 1}px`, `${cutWidth}px`],
26
+ [`${A + 1}px`, `${cutWidth}px`],
27
+ [`${A}px`, `${cutWidth - 1}px`],
28
+ [`${A}px`, min],
29
+ ]
30
+ .map(coords => coords.join(' '))
31
+ .join(', \n');
32
+ return `polygon(${points})`;
33
+ }
34
+
35
+ export { getLabelClipPath };
@@ -0,0 +1,58 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Component, createRef } from 'react';
3
+ import cn from 'classnames';
4
+ import Time from 'timen';
5
+ import S from './Label.styl.js';
6
+ import { getLabelClipPath } from './Label.helpers.js';
7
+
8
+ class Label extends Component {
9
+ gapWrapRef = createRef();
10
+ gapRef = createRef();
11
+ timers;
12
+ state = { clipPath: '' };
13
+ labelWidth = 0;
14
+ static defaultProps = {
15
+ size: 'm',
16
+ };
17
+ constructor(props) {
18
+ super(props);
19
+ this.timers = Time.create();
20
+ }
21
+ componentDidMount() {
22
+ this.updateClipPath();
23
+ }
24
+ componentDidUpdate(prevProps) {
25
+ const { children, isOnTop, size, onClipPathChange } = this.props;
26
+ const needUpadte = onClipPathChange &&
27
+ (children !== prevProps.children ||
28
+ isOnTop !== prevProps.isOnTop ||
29
+ size !== prevProps.size);
30
+ if (needUpadte)
31
+ this.updateClipPath();
32
+ }
33
+ updateClipPath = () => {
34
+ const { isOnTop, onClipPathChange, size } = this.props;
35
+ const gapWrapElem = this.gapWrapRef?.current;
36
+ const gapElem = this.gapRef?.current;
37
+ if (!onClipPathChange || !gapWrapElem || !gapElem)
38
+ return;
39
+ // @ts-ignore
40
+ const { offsetLeft } = gapWrapElem;
41
+ const { offsetWidth } = gapElem;
42
+ const labelWidth = isOnTop ? offsetWidth : 0;
43
+ if (this.labelWidth === labelWidth)
44
+ return;
45
+ this.labelWidth = labelWidth;
46
+ const clipPath = getLabelClipPath(offsetLeft, labelWidth, size);
47
+ onClipPathChange(clipPath);
48
+ };
49
+ render() {
50
+ const { className, size, isOnTop, isError, children } = this.props;
51
+ const classes = cn(S.root, S[`size-${size}`], isOnTop && S.onTop, isError && S.isError, className);
52
+ if (!children)
53
+ return null;
54
+ return (jsxs("div", { className: classes, children: [jsx("div", { className: S.view, children: jsx("div", { children: children }) }), jsx("div", { className: S.gapWrap, ref: this.gapWrapRef, children: jsx("div", { className: S.gap, ref: this.gapRef, children: children }) })] }));
55
+ }
56
+ }
57
+
58
+ export { Label };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".Label_size-s__CL8do{font-size:12px;padding:0 10px}.Label_size-m__X81DA{font-size:16px;padding:0 12px}.Label_size-l__-2YIE{font-size:20px;padding:0 14px}.Label_size-xl__aeykV{padding-right:10px}.Label_root__TewVm{align-items:center;color:var(--accent-color-alpha-500);display:flex;left:0;padding-bottom:0;padding-top:0;pointer-events:none;position:absolute;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:1}.Label_root__TewVm,.Label_root__TewVm>div{height:100%;max-width:100%}.Label_gap__zlRrx,.Label_view__Lz9Eu>div{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Label_view__Lz9Eu{align-items:center;-webkit-backface-visibility:hidden;backface-visibility:hidden;display:flex;height:100%;max-width:100%;transform:translateZ(0);transform-origin:top left;transition:transform .15s ease-out}.Label_onTop__7Ntzk .Label_view__Lz9Eu{color:var(--accent-color);transform:scale(.7) translate3d(0,-50%,0)}.Label_isError__YqI0d .Label_view__Lz9Eu{color:var(--danger-color)}.Label_gapWrap__lDGBB{max-width:100%;opacity:0;padding:inherit;pointer-events:none;position:absolute}.Label_gapWrap__lDGBB:before{border-radius:4px;content:\"\";height:1.4em;left:-6px;position:absolute;right:-6px;z-index:-1}";
4
+ var S = {"size-s":"Label_size-s__CL8do","size-m":"Label_size-m__X81DA","size-l":"Label_size-l__-2YIE","size-xl":"Label_size-xl__aeykV","root":"Label_root__TewVm","view":"Label_view__Lz9Eu","gap":"Label_gap__zlRrx","onTop":"Label_onTop__7Ntzk","isError":"Label_isError__YqI0d","gapWrap":"Label_gapWrap__lDGBB"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -0,0 +1,65 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Component } from 'react';
3
+ import Time from 'timen';
4
+ import { createStore } from 'justorm/react';
5
+ import { Container } from '../Container/Container.js';
6
+ import { Spinner } from '../Spinner/Spinner.js';
7
+
8
+ function compare(cb1, cb2) {
9
+ return cb1?.toString() === cb2?.toString();
10
+ }
11
+ const loaded = new Map();
12
+ class Lazy extends Component {
13
+ store;
14
+ Node;
15
+ hasNode = false;
16
+ clearSpinnerTimeout;
17
+ static defaultProps = {
18
+ size: 'm',
19
+ };
20
+ constructor(props) {
21
+ super(props);
22
+ this.Node = loaded.get(this.props.loader);
23
+ this.hasNode = Boolean(this.Node);
24
+ this.store = createStore(this, {
25
+ loading: !this.hasNode,
26
+ spinnerTimeout: this.hasNode,
27
+ });
28
+ }
29
+ componentDidMount() {
30
+ if (!this.hasNode)
31
+ this.update();
32
+ }
33
+ componentDidUpdate({ loader }) {
34
+ if (!compare(this.props.loader, loader)) {
35
+ // @ts-ignore
36
+ this.clearSpinnerTimeout?.();
37
+ this.update();
38
+ }
39
+ }
40
+ update() {
41
+ const { loader } = this.props;
42
+ this.clearSpinnerTimeout = Time.after(500, () => this.setState({ spinnerTimeout: false }));
43
+ this.store.loading = true;
44
+ loader().then(({ default: Node }) => {
45
+ if (!compare(this.props.loader, loader))
46
+ return;
47
+ this.Node = Node;
48
+ loaded.set(loader, Node);
49
+ this.store.loading = false;
50
+ });
51
+ }
52
+ render() {
53
+ const { Node } = this;
54
+ const { progressElem, loader, hideSpinner, ...props } = this.props;
55
+ const { loading, spinnerTimeout } = this.store;
56
+ if (Node)
57
+ return jsx(Node, { ...props });
58
+ if (!spinnerTimeout && loading && !hideSpinner) {
59
+ return (progressElem ?? (jsx(Container, { fullHeight: true, fullWidth: true, children: jsx(Spinner, { size: props.size }) })));
60
+ }
61
+ return null;
62
+ }
63
+ }
64
+
65
+ export { Lazy };
@@ -0,0 +1,28 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState, useCallback, useEffect } from 'react';
3
+ import cn from 'classnames';
4
+ import { Paranja } from '../Paranja/Paranja.js';
5
+ import { Button } from '../Button/Button.js';
6
+ import { Icon } from '../Icon/Icon.js';
7
+ import S from './LightBox.styl.js';
8
+
9
+ function LightBox({ children, onClose, blur, ...props }) {
10
+ const [isOpen, setOpen] = useState(false);
11
+ const onKeyDown = useCallback(e => {
12
+ if (isOpen && e.key === 'Escape') {
13
+ e.stopPropagation();
14
+ setOpen(false);
15
+ onClose?.();
16
+ }
17
+ }, [isOpen, onClose]);
18
+ useEffect(() => {
19
+ setOpen(props.isOpen);
20
+ }, [props.isOpen]);
21
+ useEffect(() => {
22
+ document.addEventListener('keydown', onKeyDown, true);
23
+ return () => document.removeEventListener('keydown', onKeyDown, true);
24
+ }, [isOpen]);
25
+ return (jsxs(Paranja, { className: cn(S.root, isOpen && S.open), blur: blur, children: [children, jsx(Button, { className: S.close, onClick: onClose, variant: "clear", children: jsx(Icon, { type: "close", size: "l" }) })] }));
26
+ }
27
+
28
+ export { LightBox };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".LightBox_root__R-JhJ{align-items:center;display:flex;justify-content:center;opacity:0;pointer-events:none;transition:opacity .2s ease-out}.LightBox_open__a-qrU{opacity:1;pointer-events:all}.LightBox_close__ts4k1{border-radius:0;color:var(--accent-color);height:60px;min-height:60px;position:absolute;right:0;top:0;width:60px;z-index:1}.LightBox_close__ts4k1:hover{background-color:var(--decent-color-alpha-200);color:var(--active-color)}@media (min-width:700px){.LightBox_close__ts4k1{height:100px;min-height:100px;width:100px}}";
4
+ var S = {"root":"LightBox_root__R-JhJ","open":"LightBox_open__a-qrU","close":"LightBox_close__ts4k1"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -0,0 +1,6 @@
1
+ var ANIMATION_DURATION = 300;
2
+ var C = {
3
+ ANIMATION_DURATION: ANIMATION_DURATION
4
+ };
5
+
6
+ export { ANIMATION_DURATION, C as default };
@@ -0,0 +1,67 @@
1
+ import { createElement, Component } from 'react';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import cn from 'classnames';
4
+ import { withStore } from 'justorm/react';
5
+ import { Icon } from '../Icon/Icon.js';
6
+ import { Button } from '../Button/Button.js';
7
+ import { Scroll } from '../Scroll/Scroll.js';
8
+ import STORE from './store.js';
9
+ import S from './Notifications.styl.js';
10
+
11
+ function getTouchPos(e) {
12
+ const { clientX: x, clientY: y } = e.targetTouches[0];
13
+ return { x, y };
14
+ }
15
+ function getDeltaPos(p1, p2) {
16
+ return {
17
+ x: Math.abs(p2.x - p1.x),
18
+ y: Math.abs(p2.y - p1.y),
19
+ };
20
+ }
21
+ const TOUCH_MOVE_TRESHOLD = 50;
22
+ class Item extends Component {
23
+ startPos = null;
24
+ onTouchStart = e => {
25
+ this.startPos = getTouchPos(e);
26
+ };
27
+ onTouchMove = e => {
28
+ const { unpause } = this.props;
29
+ if (!this.startPos)
30
+ return;
31
+ // e.preventDefault();
32
+ e.stopPropagation();
33
+ const pos = getTouchPos(e);
34
+ const delta = getDeltaPos(this.startPos, pos);
35
+ if (delta.x > delta.y && delta.x > TOUCH_MOVE_TRESHOLD) {
36
+ unpause();
37
+ this.closeMe();
38
+ }
39
+ };
40
+ onTouchEnd = () => {
41
+ const { unpause } = this.props;
42
+ unpause();
43
+ this.startPos = null;
44
+ };
45
+ onTouchCancel = () => (this.startPos = null);
46
+ closeMe = () => {
47
+ const { id, close } = this.props;
48
+ close(id);
49
+ };
50
+ render() {
51
+ const { type = 'default', title, content, visible, pause, unpause, } = this.props;
52
+ const classes = cn(S.item, S[`type-${type}`], visible && S.visible);
53
+ return (jsx("div", { className: classes, onMouseOver: pause, onFocus: pause, onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove, onMouseOut: unpause, onBlur: unpause, onTouchEnd: this.onTouchEnd, onTouchCancel: this.onTouchCancel, children: jsxs("div", { className: S.itemInner, children: [(title || content) && (jsxs("div", { className: S.text, children: [title && jsx("div", { className: S.title, children: title }), content && jsx("div", { className: S.content, children: content })] })), jsx(Button, { className: S.close, variant: "clear", square: true, onClick: this.closeMe, children: jsx(Icon, { type: "close", size: "s" }) })] }) }));
54
+ }
55
+ }
56
+ const NotificationsStore = STORE;
57
+ const Notifications = withStore({
58
+ notifications: ['items', 'data'],
59
+ })(function Notifications({ store, ...rest }) {
60
+ const { notifications } = store;
61
+ const { items, data, pause, unpause, close } = notifications;
62
+ const api = { pause, unpause, close };
63
+ const classes = cn(S.root, items.length === 0 && S.empty);
64
+ return (jsx(Scroll, { ...rest, y: true, size: "s", className: classes, innerClassName: S.inner, offset: { y: { before: 22, after: 22 } }, children: items.map(id => (createElement(Item, { ...data[id], ...api, id: id, key: id }))) }));
65
+ });
66
+
67
+ export { Notifications, NotificationsStore };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".Notifications_root__S3ujN{max-height:calc(var(--vh)*100);overflow:hidden;position:fixed;right:0;top:0;transform:translateZ(0);transition:right .3s ease-out;width:320px;z-index:20}.Notifications_inner__6v9e3{padding:var(--indent-m)}.Notifications_empty__zCpOA{pointer-events:none}.Notifications_itemInner__nEYAl,.Notifications_item__I3Up4{border-radius:var(--border-radius-l)}.Notifications_item__I3Up4{-webkit-backface-visibility:hidden;backface-visibility:hidden;left:100%;max-height:0;max-width:100%;opacity:0;position:relative;transition:all .3s ease-out;width:300px}.Notifications_item__I3Up4+.Notifications_item__I3Up4{padding-top:10px}.Notifications_item__I3Up4:hover{transform:translateX(-2px)}.Notifications_visible__ln4-n{left:0;max-height:500px;opacity:1}.Notifications_itemInner__nEYAl{align-items:center;-webkit-backdrop-filter:blur(30px);backdrop-filter:blur(30px);background-color:var(--decent-color-alpha-500);box-shadow:inset 0 0 1px var(--accent-color-alpha-300),0 0 20px var(--decent-color);box-sizing:border-box;display:flex;padding:16px 32px 16px 20px;position:relative;transition:.3s ease-out;transition-property:transform}.Notifications_type-warning__Nxg6C .Notifications_itemInner__nEYAl{background-color:var(--warning-color-alpha-300)}.Notifications_type-danger__zeIMt .Notifications_itemInner__nEYAl{background-color:var(--danger-color-alpha-300)}.Notifications_icon__nKs-X{background:no-repeat 50%;height:24px;margin-right:10px;min-width:24px;width:24px}.Notifications_type-loading__N4EE5 .Notifications_icon__nKs-X{transform:translateY(-20px)}.Notifications_text__7QZL6{display:flex;flex-direction:column;flex-grow:1;z-index:1}.Notifications_title__Gu9bs{font-size:16px;font-weight:700}.Notifications_content__Zrvw2{font-size:12px;margin-top:calc(var(--indent-s)/2)}.Notifications_content__Zrvw2:first-child{margin-top:0}.Notifications_close__-IUH3{background-color:transparent;border-radius:50%;cursor:pointer;height:40px!important;max-height:40px!important;max-width:40px!important;opacity:0;position:absolute;right:-5px;top:-5px;transform:scale(.8);transition:.1s ease-out;transition-property:opacity,transform;width:40px!important}.Notifications_item__I3Up4:hover .Notifications_close__-IUH3{opacity:.8}.Notifications_close__-IUH3:hover{background-color:transparent;background-color:initial;opacity:1;transform:scale(1)}@media (max-width:700px){.Notifications_item__I3Up4,.Notifications_root__S3ujN{width:100%}.Notifications_title__Gu9bs{font-size:20px}.Notifications_content__Zrvw2{font-size:16px}.Notifications_close__-IUH3{transform:scale(1.2)}}";
4
+ var S = {"root":"Notifications_root__S3ujN","inner":"Notifications_inner__6v9e3","empty":"Notifications_empty__zCpOA","item":"Notifications_item__I3Up4","itemInner":"Notifications_itemInner__nEYAl","visible":"Notifications_visible__ln4-n","type-warning":"Notifications_type-warning__Nxg6C","type-danger":"Notifications_type-danger__zeIMt","icon":"Notifications_icon__nKs-X","type-loading":"Notifications_type-loading__N4EE5","text":"Notifications_text__7QZL6","title":"Notifications_title__Gu9bs","content":"Notifications_content__Zrvw2","close":"Notifications_close__-IUH3"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };