@sima-land/ui-nucleons 44.2.10 → 45.0.0-alpha.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 (378) hide show
  1. package/_internal/custom-scrollbar/index.d.ts +13 -7
  2. package/_internal/custom-scrollbar/index.js +29 -15
  3. package/_internal/dropdown-loading/index.d.ts +3 -3
  4. package/_internal/dropdown-loading/index.js +4 -2
  5. package/_internal/page-scroll-lock/adapters/body-scroll-lock.d.ts +39 -0
  6. package/_internal/page-scroll-lock/adapters/body-scroll-lock.js +62 -0
  7. package/_internal/page-scroll-lock/adapters/ui-nucleons.d.ts +25 -0
  8. package/_internal/page-scroll-lock/adapters/ui-nucleons.js +103 -0
  9. package/_internal/page-scroll-lock/context.d.ts +13 -0
  10. package/_internal/page-scroll-lock/context.js +54 -0
  11. package/_internal/page-scroll-lock/hook.d.ts +12 -0
  12. package/_internal/page-scroll-lock/hook.js +26 -0
  13. package/_internal/page-scroll-lock/index.d.ts +4 -0
  14. package/_internal/page-scroll-lock/index.js +9 -0
  15. package/_internal/page-scroll-lock/types.d.ts +22 -0
  16. package/_internal/readme.md +2 -0
  17. package/_internal/utils/dropdown.d.ts +1 -0
  18. package/_internal/utils/dropdown.js +1 -0
  19. package/alert/alert.module.scss +1 -24
  20. package/alert/index.d.ts +11 -17
  21. package/alert/index.js +33 -16
  22. package/arrow-button/arrow-button.module.scss +2 -0
  23. package/arrow-button/index.d.ts +2 -2
  24. package/autocomplete/autocomplete.d.ts +8 -0
  25. package/autocomplete/autocomplete.js +190 -0
  26. package/autocomplete/autocomplete.module.scss +2 -15
  27. package/autocomplete/index.d.ts +2 -27
  28. package/autocomplete/index.js +2 -126
  29. package/autocomplete/types.d.ts +19 -0
  30. package/autocomplete/types.js +2 -0
  31. package/autocomplete-deprecated/autocomplete.module.scss +20 -0
  32. package/autocomplete-deprecated/index.d.ts +28 -0
  33. package/autocomplete-deprecated/index.js +130 -0
  34. package/avatar/index.d.ts +2 -2
  35. package/avatar/user.d.ts +1 -1
  36. package/base-input/base-input.d.ts +11 -0
  37. package/base-input/base-input.js +96 -0
  38. package/base-input/base-input.module.scss +3 -3
  39. package/base-input/index.d.ts +2 -23
  40. package/base-input/index.js +2 -76
  41. package/base-input/types.d.ts +31 -0
  42. package/base-input/types.js +2 -0
  43. package/base-input/utils.d.ts +6 -0
  44. package/base-input/utils.js +14 -0
  45. package/base-input-deprecated/base-input.module.scss +66 -0
  46. package/base-input-deprecated/index.d.ts +24 -0
  47. package/base-input-deprecated/index.js +80 -0
  48. package/bordered-layout/index.d.ts +1 -0
  49. package/bordered-layout/index.js +1 -0
  50. package/bottom-bar/bottom-bar-util.scss +20 -0
  51. package/bottom-bar/bottom-bar.d.ts +12 -0
  52. package/bottom-bar/bottom-bar.js +47 -0
  53. package/bottom-bar/bottom-bar.module.scss +14 -0
  54. package/bottom-bar/index.d.ts +2 -21
  55. package/bottom-bar/index.js +5 -44
  56. package/bottom-bar/types.d.ts +10 -0
  57. package/bottom-bar/types.js +2 -0
  58. package/box/index.d.ts +1 -1
  59. package/breakpoints.scss +34 -3
  60. package/button/button.module.scss +70 -53
  61. package/button/index.d.ts +26 -41
  62. package/button/index.js +22 -46
  63. package/card/index.d.ts +2 -1
  64. package/card/index.js +23 -6
  65. package/card/slots.d.ts +17 -3
  66. package/card/slots.js +15 -13
  67. package/carousel/draggable.d.ts +7 -3
  68. package/carousel/draggable.js +10 -3
  69. package/carousel/helpers/draggable-event.d.ts +5 -2
  70. package/carousel/helpers/draggable-event.js +5 -0
  71. package/carousel/index.d.ts +1 -1
  72. package/carousel/index.js +24 -24
  73. package/checkbox/checkbox.module.scss +1 -0
  74. package/checkbox/index.d.ts +3 -3
  75. package/checkbox-field/index.d.ts +3 -0
  76. package/checkbox-field/index.js +3 -0
  77. package/clean-buttons/clean-buttons-util.scss +15 -0
  78. package/clean-buttons/clean-buttons.module.scss +5 -3
  79. package/clean-buttons/index.d.ts +16 -7
  80. package/clean-buttons/index.js +17 -14
  81. package/clean-buttons/types.d.ts +1 -1
  82. package/clean-buttons/utils.d.ts +5 -1
  83. package/clean-buttons/utils.js +4 -0
  84. package/{colors.d.ts → colors/index.d.ts} +2 -2
  85. package/{colors.js → colors/index.js} +2 -1
  86. package/colors.scss +2 -0
  87. package/dot-nav/index.d.ts +1 -1
  88. package/dropdown/index.d.ts +1 -0
  89. package/dropdown/utils.d.ts +19 -0
  90. package/dropdown/utils.js +47 -0
  91. package/dropdown-item/dropdown-item.module.scss +80 -15
  92. package/dropdown-item/index.d.ts +20 -9
  93. package/dropdown-item/index.js +12 -9
  94. package/dropdown-item/types.d.ts +3 -0
  95. package/dropdown-item/types.js +2 -0
  96. package/dropdown-item/utils.d.ts +45 -0
  97. package/dropdown-item/utils.js +89 -0
  98. package/expandable/utils.js +3 -3
  99. package/field-block/field-block.module.scss +155 -0
  100. package/field-block/index.d.ts +63 -0
  101. package/field-block/index.js +43 -0
  102. package/field-grid/index.d.ts +5 -4
  103. package/field-grid/index.js +1 -0
  104. package/helpers/bounds-of.d.ts +5 -1
  105. package/helpers/bounds-of.js +5 -0
  106. package/helpers/center-of.d.ts +4 -1
  107. package/helpers/center-of.js +8 -1
  108. package/helpers/create-container.d.ts +5 -2
  109. package/helpers/create-container.js +7 -2
  110. package/helpers/define-slots.d.ts +3 -3
  111. package/helpers/define-slots.js +5 -3
  112. package/helpers/events.d.ts +16 -8
  113. package/helpers/events.js +41 -15
  114. package/helpers/find-child-element.d.ts +12 -9
  115. package/helpers/find-child-element.js +9 -5
  116. package/helpers/find-offset-parent.d.ts +1 -2
  117. package/helpers/find-offset-parent.js +2 -2
  118. package/helpers/find-sibling-index.d.ts +11 -8
  119. package/helpers/find-sibling-index.js +8 -3
  120. package/helpers/fit-element-height.d.ts +5 -5
  121. package/helpers/fit-element-height.js +9 -7
  122. package/helpers/format-date.d.ts +11 -11
  123. package/helpers/format-date.js +15 -13
  124. package/helpers/format-number.d.ts +1 -1
  125. package/helpers/format-number.js +2 -2
  126. package/helpers/get-date-interval-data.d.ts +4 -1
  127. package/helpers/get-date-interval-data.js +7 -2
  128. package/helpers/get-declination.d.ts +5 -1
  129. package/helpers/get-declination.js +5 -0
  130. package/helpers/get-fraction-depth.d.ts +1 -1
  131. package/helpers/get-fraction-depth.js +2 -2
  132. package/helpers/get-no-index.d.ts +2 -2
  133. package/helpers/get-no-index.js +4 -3
  134. package/helpers/get-relative-pos.d.ts +4 -1
  135. package/helpers/get-relative-pos.js +7 -2
  136. package/helpers/get-scroll-parent.d.ts +1 -2
  137. package/helpers/get-scroll-parent.js +5 -5
  138. package/helpers/is-browser.d.ts +4 -1
  139. package/helpers/is-browser.js +8 -1
  140. package/helpers/is-fully-scrolled.d.ts +3 -3
  141. package/helpers/is-fully-scrolled.js +2 -2
  142. package/helpers/is-touch-device.d.ts +1 -1
  143. package/helpers/is-touch-device.js +4 -5
  144. package/helpers/layer.d.ts +1 -1
  145. package/helpers/layer.js +2 -2
  146. package/helpers/max-index-of.d.ts +4 -1
  147. package/helpers/max-index-of.js +7 -2
  148. package/helpers/media-query-list.d.ts +1 -1
  149. package/helpers/media-query-list.js +2 -2
  150. package/helpers/on.d.ts +4 -1
  151. package/helpers/on.js +7 -2
  152. package/helpers/point.d.ts +4 -1
  153. package/helpers/point.js +8 -1
  154. package/helpers/rename.d.ts +3 -1
  155. package/helpers/rename.js +1 -0
  156. package/helpers/scroll-to-child.d.ts +1 -1
  157. package/helpers/scroll-to-child.js +3 -2
  158. package/helpers/styles.d.ts +8 -2
  159. package/helpers/styles.js +18 -4
  160. package/helpers/with-prevent.d.ts +9 -6
  161. package/helpers/with-prevent.js +16 -9
  162. package/hint/hint-view.d.ts +26 -0
  163. package/hint/hint-view.js +43 -0
  164. package/hint/hint-view.module.scss +32 -0
  165. package/hint/hint.d.ts +14 -0
  166. package/hint/hint.js +41 -0
  167. package/hint/index.d.ts +5 -8
  168. package/hint/index.js +13 -48
  169. package/hint/utils.d.ts +61 -0
  170. package/hint/utils.js +161 -0
  171. package/hint-deprecated/index.d.ts +11 -0
  172. package/hint-deprecated/index.js +53 -0
  173. package/hooks/breakpoint/index.d.ts +7 -4
  174. package/hooks/breakpoint/index.js +21 -13
  175. package/hooks/breakpoint/types.d.ts +3 -4
  176. package/hooks/breakpoint/utils.d.ts +2 -1
  177. package/hooks/breakpoint/utils.js +2 -1
  178. package/hooks/index.d.ts +8 -8
  179. package/hooks/index.js +27 -19
  180. package/hooks/intersection/test-utils.d.ts +1 -1
  181. package/hooks/intersection/test-utils.js +2 -1
  182. package/hooks/styles.d.ts +6 -0
  183. package/hooks/styles.js +26 -0
  184. package/info-text/index.d.ts +23 -0
  185. package/info-text/index.js +60 -0
  186. package/info-text/info-text.module.scss +28 -0
  187. package/input/index.d.ts +32 -0
  188. package/input/index.js +96 -0
  189. package/input/input.module.scss +20 -0
  190. package/input/utils.d.ts +36 -0
  191. package/input/utils.js +71 -0
  192. package/layout/index.d.ts +6 -11
  193. package/layout/index.js +6 -60
  194. package/layout/layout.d.ts +10 -0
  195. package/layout/layout.js +32 -0
  196. package/layout/layout.module.scss +33 -26
  197. package/layout/legacy.d.ts +15 -0
  198. package/layout/legacy.js +68 -0
  199. package/layout/legacy.module.scss +49 -0
  200. package/layout/types.d.ts +6 -0
  201. package/layout/types.js +2 -0
  202. package/link/index.d.ts +4 -1
  203. package/link/index.js +2 -2
  204. package/link/link-util.scss +37 -0
  205. package/link/link.module.scss +19 -12
  206. package/loading-overlay/index.d.ts +1 -0
  207. package/loading-overlay/index.js +1 -0
  208. package/masked-field/index.d.ts +1 -0
  209. package/masked-field/index.js +1 -0
  210. package/masked-input/hook.d.ts +8 -0
  211. package/masked-input/hook.js +72 -0
  212. package/masked-input/index.d.ts +5 -0
  213. package/masked-input/index.js +7 -0
  214. package/masked-input/masked-input.d.ts +8 -0
  215. package/masked-input/masked-input.js +73 -0
  216. package/masked-input/types.d.ts +51 -0
  217. package/masked-input/types.js +2 -0
  218. package/masked-input/utils.d.ts +15 -0
  219. package/masked-input/utils.js +49 -0
  220. package/modal/index.d.ts +10 -12
  221. package/modal/index.js +27 -64
  222. package/modal/modal.module.scss +98 -55
  223. package/modal/slots.d.ts +13 -10
  224. package/modal/slots.js +30 -28
  225. package/modal/utils.d.ts +8 -10
  226. package/modal/utils.js +2 -26
  227. package/modal-overlay/index.d.ts +13 -0
  228. package/modal-overlay/index.js +60 -0
  229. package/modal-overlay/modal-overlay-util.scss +1 -0
  230. package/modal-overlay/modal-overlay.module.scss +14 -0
  231. package/modal-overlay/utils.d.ts +14 -0
  232. package/modal-overlay/utils.js +32 -0
  233. package/package.json +49 -41
  234. package/pagination/utils.d.ts +2 -2
  235. package/panel/index.d.ts +27 -13
  236. package/panel/index.js +43 -9
  237. package/panel/panel.module.scss +49 -8
  238. package/phone-input/index.d.ts +4 -28
  239. package/phone-input/index.js +2 -121
  240. package/phone-input/phone-input.d.ts +8 -0
  241. package/phone-input/phone-input.js +133 -0
  242. package/phone-input/phone-input.module.scss +8 -32
  243. package/phone-input/presets.d.ts +21 -22
  244. package/phone-input/presets.js +1 -2
  245. package/phone-input/types.d.ts +6 -0
  246. package/phone-input/types.js +2 -0
  247. package/phone-input/utils.d.ts +30 -1
  248. package/phone-input/utils.js +52 -3
  249. package/phone-input-deprecated/index.d.ts +29 -0
  250. package/phone-input-deprecated/index.js +124 -0
  251. package/phone-input-deprecated/phone-input.module.scss +41 -0
  252. package/plate/index.d.ts +3 -3
  253. package/plate/index.js +2 -2
  254. package/plate/plate.module.scss +3 -0
  255. package/popup/index.d.ts +5 -0
  256. package/popup/index.js +12 -0
  257. package/popup/popup-view.d.ts +14 -0
  258. package/popup/popup-view.js +35 -0
  259. package/popup/popup-view.module.scss +40 -0
  260. package/popup/popup.d.ts +17 -0
  261. package/popup/popup.js +73 -0
  262. package/popup/utils.d.ts +38 -0
  263. package/popup/utils.js +83 -0
  264. package/price/index.d.ts +1 -1
  265. package/price/index.js +3 -3
  266. package/price/utils.d.ts +5 -5
  267. package/price/utils.js +33 -23
  268. package/radio-button/index.d.ts +10 -0
  269. package/radio-button/index.js +33 -0
  270. package/radio-button/radio-button.module.scss +46 -0
  271. package/rating/index.d.ts +2 -1
  272. package/rating/types.d.ts +1 -1
  273. package/readme.md +56 -65
  274. package/screen/index.d.ts +4 -2
  275. package/screen/index.js +34 -3
  276. package/screen/screen.module.scss +0 -2
  277. package/screen/slots.d.ts +2 -8
  278. package/screen/slots.js +8 -9
  279. package/screen/utils.d.ts +2 -1
  280. package/select/index.d.ts +2 -33
  281. package/select/index.js +3 -109
  282. package/select/parts/block.d.ts +8 -0
  283. package/select/parts/block.js +70 -0
  284. package/select/parts/block.module.scss +7 -0
  285. package/select/parts/button.d.ts +8 -0
  286. package/select/parts/button.js +69 -0
  287. package/select/parts/menu.d.ts +8 -0
  288. package/select/parts/menu.js +105 -0
  289. package/select/parts/menu.module.scss +4 -0
  290. package/select/select.d.ts +14 -0
  291. package/select/select.js +145 -0
  292. package/select/types.d.ts +55 -0
  293. package/select/types.js +2 -0
  294. package/select/utils.d.ts +3 -0
  295. package/select/utils.js +13 -0
  296. package/select-deprecated/index.d.ts +34 -0
  297. package/select-deprecated/index.js +112 -0
  298. package/shadows.scss +18 -0
  299. package/side-page/index.d.ts +11 -26
  300. package/side-page/index.js +21 -26
  301. package/side-page/side-page.module.scss +35 -29
  302. package/side-page/slots.d.ts +12 -20
  303. package/side-page/slots.js +16 -28
  304. package/spinner/index.d.ts +18 -6
  305. package/spinner/index.js +25 -12
  306. package/spinner/spinner.module.scss +8 -0
  307. package/stepper/index.d.ts +18 -10
  308. package/stepper/index.js +17 -8
  309. package/stepper/stepper.module.scss +14 -15
  310. package/styling/fonts.d.ts +3 -3
  311. package/switcher-row/index.d.ts +42 -0
  312. package/switcher-row/index.js +59 -0
  313. package/switcher-row/switcher-row.module.scss +59 -0
  314. package/text/index.d.ts +1 -1
  315. package/text-button/index.d.ts +42 -0
  316. package/text-button/index.js +46 -0
  317. package/text-button/text-button.module.scss +96 -0
  318. package/text-field/index.d.ts +7 -6
  319. package/text-field/index.js +3 -2
  320. package/textarea/index.d.ts +21 -0
  321. package/textarea/index.js +85 -0
  322. package/textarea/textarea.module.scss +15 -0
  323. package/toggle/index.d.ts +3 -3
  324. package/toggle/toggle.module.scss +17 -8
  325. package/tooltip/index.d.ts +1 -0
  326. package/tooltip/index.js +1 -0
  327. package/top-bar/index.d.ts +3 -40
  328. package/top-bar/index.js +4 -60
  329. package/top-bar/top-bar-util.scss +29 -0
  330. package/top-bar/top-bar.d.ts +9 -0
  331. package/top-bar/top-bar.js +101 -0
  332. package/top-bar/top-bar.module.scss +129 -67
  333. package/top-bar/types.d.ts +31 -0
  334. package/top-bar/types.js +2 -0
  335. package/top-bar/utils.d.ts +14 -0
  336. package/top-bar/utils.js +56 -0
  337. package/touch-slider/index.d.ts +1 -0
  338. package/touch-slider/index.js +3 -2
  339. package/types.d.ts +18 -0
  340. package/types.js +2 -0
  341. package/unknown-content/index.d.ts +3 -3
  342. package/unknown-content/index.js +3 -3
  343. package/unknown-content/unknown-content.module.scss +16 -12
  344. package/upload-area/index.d.ts +2 -0
  345. package/upload-area/index.js +5 -0
  346. package/upload-area/types.d.ts +32 -0
  347. package/upload-area/types.js +2 -0
  348. package/upload-area/upload-area-util.scss +17 -0
  349. package/upload-area/upload-area.d.ts +8 -0
  350. package/upload-area/upload-area.js +105 -0
  351. package/upload-area/upload-area.module.scss +78 -0
  352. package/upload-area/utils.d.ts +17 -0
  353. package/upload-area/utils.js +48 -0
  354. package/utils.scss +74 -1
  355. package/with-hint/index.d.ts +3 -2
  356. package/with-hint/index.js +1 -0
  357. package/with-hint/positioning-hint.d.ts +1 -1
  358. package/with-hint/positioning-hint.js +2 -2
  359. package/with-tooltip/index.d.ts +2 -1
  360. package/with-tooltip/index.js +1 -0
  361. package/with-tooltip/utils.d.ts +2 -2
  362. package/_internal/body-scroll.d.ts +0 -23
  363. package/_internal/body-scroll.js +0 -41
  364. package/_internal/checkbox/index.d.ts +0 -5
  365. package/constants.d.ts +0 -6
  366. package/constants.js +0 -9
  367. package/nav-bar/index.d.ts +0 -46
  368. package/nav-bar/index.js +0 -76
  369. package/nav-bar/nav-bar.module.scss +0 -95
  370. package/upload/area.d.ts +0 -25
  371. package/upload/area.js +0 -65
  372. package/upload/area.module.scss +0 -44
  373. package/upload/utils.d.ts +0 -29
  374. package/upload/utils.js +0 -45
  375. /package/_internal/{checkbox/index.js → page-scroll-lock/types.js} +0 -0
  376. /package/{hint → hint-deprecated}/hint.module.scss +0 -0
  377. /package/{select → select-deprecated}/select.module.scss +0 -0
  378. /package/{upload → upload-area}/upload.svg +0 -0
package/modal/slots.d.ts CHANGED
@@ -1,35 +1,38 @@
1
- import React from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { TopBarProps } from '../top-bar';
3
3
  import { BottomBarProps } from '../bottom-bar';
4
- export interface ModalHeaderProps extends TopBarProps {
4
+ export interface ModalHeaderProps extends Omit<TopBarProps, 'size'> {
5
5
  onBack?: () => void;
6
6
  onClose?: () => void;
7
7
  }
8
+ export type ModalFooterProps = Omit<BottomBarProps, 'size'>;
8
9
  /**
9
10
  * Шапка окна.
10
11
  * @param props Свойства.
11
12
  * @return Элемент.
12
13
  */
13
- export declare const ModalHeader: ({ onBack, onClose, ...topBarProps }: ModalHeaderProps) => JSX.Element;
14
+ export declare function ModalHeader({ className, onBack, onClose, buttons, ...rest }: ModalHeaderProps): JSX.Element;
14
15
  /**
15
16
  * Основной контент окна.
16
17
  * @param props Свойства.
17
18
  * @return Элемент.
18
19
  */
19
- export declare const ModalBody: ({ children, onFullScroll, fullScrollThreshold, }: {
20
- children?: React.ReactNode;
21
- fullScrollThreshold?: number | undefined;
22
- onFullScroll?: (() => void) | undefined;
23
- }) => JSX.Element;
20
+ export declare function ModalBody({ children, onFullScroll, fullScrollThreshold, }: {
21
+ children?: ReactNode;
22
+ fullScrollThreshold?: number;
23
+ onFullScroll?: () => void;
24
+ }): JSX.Element;
24
25
  /**
25
26
  * Футер окна.
26
27
  * @param props Свойства.
27
28
  * @return Элемент.
28
29
  */
29
- export declare const ModalFooter: (props: BottomBarProps) => JSX.Element;
30
+ export declare function ModalFooter({ className, ...rest }: ModalFooterProps): JSX.Element;
30
31
  /**
31
32
  * Контент который будет выводится поверх окна с абсолютным позиционированием.
32
33
  * @param props Свойства.
33
34
  * @return Элемент.
34
35
  */
35
- export declare const ModalOverlap: React.FC;
36
+ export declare function ModalOverlap({ children }: {
37
+ children?: ReactNode;
38
+ }): JSX.Element;
package/modal/slots.js CHANGED
@@ -40,58 +40,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.ModalOverlap = exports.ModalFooter = exports.ModalBody = exports.ModalHeader = void 0;
41
41
  const react_1 = __importStar(require("react"));
42
42
  const top_bar_1 = require("../top-bar");
43
- const cross_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/cross"));
44
- const arrow_left_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/arrow-left"));
43
+ const utils_1 = require("../top-bar/utils");
45
44
  const bottom_bar_1 = require("../bottom-bar");
46
45
  const custom_scrollbar_1 = require("../_internal/custom-scrollbar");
47
- const modal_module_scss_1 = __importDefault(require("./modal.module.scss"));
48
46
  const viewport_1 = require("../context/viewport");
49
- const constants_1 = require("../constants");
47
+ const utils_2 = require("./utils");
48
+ const page_scroll_lock_1 = require("../_internal/page-scroll-lock");
49
+ const bind_1 = __importDefault(require("classnames/bind"));
50
+ const modal_module_scss_1 = __importDefault(require("./modal.module.scss"));
51
+ const cx = bind_1.default.bind(modal_module_scss_1.default);
50
52
  /**
51
53
  * Шапка окна.
52
54
  * @param props Свойства.
53
55
  * @return Элемент.
54
56
  */
55
- const ModalHeader = (_a) => {
56
- var { onBack, onClose } = _a, topBarProps = __rest(_a, ["onBack", "onClose"]);
57
- return (react_1.default.createElement(top_bar_1.TopBar, Object.assign({}, topBarProps, { buttonsProps: Object.assign(Object.assign(Object.assign({}, topBarProps.buttonsProps), (onBack && {
58
- start: {
59
- 'data-testid': 'modal:back',
60
- onClick: onBack,
61
- icon: react_1.default.createElement(arrow_left_1.default, null),
62
- },
63
- })), (onClose && {
64
- end: {
65
- 'data-testid': 'modal:close',
66
- onClick: onClose,
67
- icon: react_1.default.createElement(cross_1.default, null),
68
- },
69
- })), className: modal_module_scss_1.default.header })));
70
- };
57
+ function ModalHeader(_a) {
58
+ var { className, onBack, onClose, buttons } = _a, rest = __rest(_a, ["className", "onBack", "onClose", "buttons"]);
59
+ const { topBarSize } = (0, react_1.useContext)(utils_2.ModalContext);
60
+ return (react_1.default.createElement(top_bar_1.TopBar, Object.assign({}, rest, { size: topBarSize, buttons: (0, utils_1.navigationButtons)({ buttons, onBack, onClose }), className: cx('header', className) })));
61
+ }
71
62
  exports.ModalHeader = ModalHeader;
72
63
  /**
73
64
  * Основной контент окна.
74
65
  * @param props Свойства.
75
66
  * @return Элемент.
76
67
  */
77
- const ModalBody = ({ children, onFullScroll, fullScrollThreshold, }) => {
78
- const ref = (0, react_1.useRef)(null);
79
- return (react_1.default.createElement(custom_scrollbar_1.CustomScrollbar, { inFlexBox: true, className: modal_module_scss_1.default.body, overflow: { x: 'h', y: 's' }, onFullScroll: onFullScroll, fullScrollThreshold: fullScrollThreshold },
80
- react_1.default.createElement(viewport_1.ViewportContext.Provider, { value: ref },
81
- react_1.default.createElement("div", Object.assign({ className: modal_module_scss_1.default.main, ref: ref }, { [constants_1.BSL_IGNORE_ATTR]: true }), children))));
82
- };
68
+ function ModalBody({ children, onFullScroll, fullScrollThreshold, }) {
69
+ const viewportRef = (0, react_1.useRef)(null);
70
+ const scrollableRef = (0, react_1.useRef)(null);
71
+ const osComponentRef = (0, react_1.useRef)(null);
72
+ const { withScrollDisable, scrollDisableOptions } = (0, react_1.useContext)(utils_2.ModalContext);
73
+ (0, react_1.useImperativeHandle)(scrollableRef, () => (0, custom_scrollbar_1.getViewport)(osComponentRef.current));
74
+ (0, react_1.useImperativeHandle)(viewportRef, () => (0, custom_scrollbar_1.getViewport)(osComponentRef.current));
75
+ (0, page_scroll_lock_1.usePageScrollLock)(scrollableRef, Object.assign({ lockEnabled: withScrollDisable }, scrollDisableOptions));
76
+ return (react_1.default.createElement(viewport_1.ViewportContext.Provider, { value: viewportRef },
77
+ react_1.default.createElement(custom_scrollbar_1.CustomScrollbar, { inFlexBox: true, osComponentRef: osComponentRef, className: modal_module_scss_1.default.body, overflow: { x: 'hidden', y: 'scroll' }, onFullScroll: onFullScroll, fullScrollThreshold: fullScrollThreshold }, children)));
78
+ }
83
79
  exports.ModalBody = ModalBody;
84
80
  /**
85
81
  * Футер окна.
86
82
  * @param props Свойства.
87
83
  * @return Элемент.
88
84
  */
89
- const ModalFooter = (props) => react_1.default.createElement(bottom_bar_1.BottomBar, Object.assign({}, props));
85
+ function ModalFooter(_a) {
86
+ var { className } = _a, rest = __rest(_a, ["className"]);
87
+ const { bottomBarSize } = (0, react_1.useContext)(utils_2.ModalContext);
88
+ return react_1.default.createElement(bottom_bar_1.BottomBar, Object.assign({}, rest, { size: bottomBarSize, className: cx('footer', className) }));
89
+ }
90
90
  exports.ModalFooter = ModalFooter;
91
91
  /**
92
92
  * Контент который будет выводится поверх окна с абсолютным позиционированием.
93
93
  * @param props Свойства.
94
94
  * @return Элемент.
95
95
  */
96
- const ModalOverlap = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children);
96
+ function ModalOverlap({ children }) {
97
+ return react_1.default.createElement(react_1.default.Fragment, null, children);
98
+ }
97
99
  exports.ModalOverlap = ModalOverlap;
package/modal/utils.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- import React from 'react';
2
- /**
3
- * Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
4
- * @param callback Сработает при клике.
5
- * @return Свойства для целевого элемента.
6
- */
7
- export declare const useCloseHandler: (callback?: (() => void) | undefined) => {
8
- onMouseUp: ({ target, currentTarget, button }: React.MouseEvent) => void;
9
- onMouseDown: ({ button, target }: React.MouseEvent) => void;
10
- };
1
+ /// <reference types="react" />
2
+ import { BottomBarProps } from '../bottom-bar';
3
+ import { TopBarProps } from '../top-bar';
4
+ import { WithPageScrollLock } from '../_internal/page-scroll-lock';
5
+ export declare const ModalContext: import("react").Context<WithPageScrollLock & {
6
+ topBarSize?: TopBarProps['size'];
7
+ bottomBarSize?: BottomBarProps['size'];
8
+ }>;
package/modal/utils.js CHANGED
@@ -1,29 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCloseHandler = void 0;
3
+ exports.ModalContext = void 0;
4
4
  const react_1 = require("react");
5
- const identity_1 = require("../hooks/identity");
6
- /**
7
- * Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
8
- * @param callback Сработает при клике.
9
- * @return Свойства для целевого элемента.
10
- */
11
- const useCloseHandler = (callback) => {
12
- const callbackRef = (0, identity_1.useIdentityRef)(callback);
13
- const mouseDownTarget = (0, react_1.useRef)();
14
- const onMouseDown = (0, react_1.useCallback)(({ button, target }) => {
15
- if (button === 0) {
16
- mouseDownTarget.current = target;
17
- }
18
- }, []);
19
- const onMouseUp = (0, react_1.useCallback)(({ target, currentTarget, button }) => {
20
- const fn = callbackRef.current;
21
- fn &&
22
- button === 0 &&
23
- target === currentTarget &&
24
- currentTarget === mouseDownTarget.current &&
25
- fn();
26
- }, []);
27
- return { onMouseUp, onMouseDown };
28
- };
29
- exports.useCloseHandler = useCloseHandler;
5
+ exports.ModalContext = (0, react_1.createContext)({});
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes, Ref } from 'react';
2
+ export interface ModalOverlayProps extends HTMLAttributes<HTMLDivElement> {
3
+ /** Реф корневого элемента. */
4
+ rootRef?: Ref<HTMLDivElement>;
5
+ /** Идентификатор для систем автоматизированного тестирования. */
6
+ 'data-testid'?: string;
7
+ }
8
+ /**
9
+ * Полноэкранное затемнение для модальных компонентов (Alert, Modal, SidePage...).
10
+ * @param props Свойства.
11
+ * @return Элемент.
12
+ */
13
+ export declare function ModalOverlay({ rootRef, children, className, style, 'data-testid': testId, ...restProps }: ModalOverlayProps): JSX.Element;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ModalOverlay = void 0;
41
+ const react_1 = __importStar(require("react"));
42
+ const styles_1 = require("../hooks/styles");
43
+ const layer_1 = require("../helpers/layer");
44
+ const classnames_1 = __importDefault(require("classnames"));
45
+ const modal_overlay_module_scss_1 = __importDefault(require("./modal-overlay.module.scss"));
46
+ /**
47
+ * Полноэкранное затемнение для модальных компонентов (Alert, Modal, SidePage...).
48
+ * @param props Свойства.
49
+ * @return Элемент.
50
+ */
51
+ function ModalOverlay(_a) {
52
+ var { rootRef, children, className, style, 'data-testid': testId = 'modal-overlay' } = _a, restProps = __rest(_a, ["rootRef", "children", "className", "style", 'data-testid']);
53
+ const layer = (0, layer_1.useLayer)() + 100;
54
+ const ref = (0, react_1.useRef)(null);
55
+ (0, react_1.useImperativeHandle)(rootRef, () => ref.current);
56
+ (0, styles_1.useViewportHeightUnit)(ref);
57
+ return (react_1.default.createElement(layer_1.LayerProvider, { value: layer },
58
+ react_1.default.createElement("div", Object.assign({}, restProps, { ref: ref, className: (0, classnames_1.default)(modal_overlay_module_scss_1.default.root, className), "data-testid": testId, style: Object.assign(Object.assign({}, style), { zIndex: layer }) }), children)));
59
+ }
60
+ exports.ModalOverlay = ModalOverlay;
@@ -0,0 +1 @@
1
+ $overlay-color: rgba(0, 0, 0, 0.24);
@@ -0,0 +1,14 @@
1
+ @use '../utils';
2
+ @use './modal-overlay-util';
3
+
4
+ .root {
5
+ position: fixed;
6
+ top: 0;
7
+ left: 0;
8
+ display: flex;
9
+ width: 100vw;
10
+ height: calc(var(--vh, 1vh) * 100);
11
+ background: modal-overlay-util.$overlay-color;
12
+ overflow: auto;
13
+ @include utils.hidden-scrollbars;
14
+ }
@@ -0,0 +1,14 @@
1
+ import { MouseEventHandler } from 'react';
2
+ /**
3
+ * Вызывает callback только если клик был начат и закончен на одном и том же элементе.
4
+ * @param onExactClick Сработает при клике.
5
+ * @param options Опции.
6
+ * @return Свойства для целевого элемента.
7
+ */
8
+ export declare function useExactClick(onExactClick: VoidFunction | undefined, { onMouseDown, onMouseUp, }?: {
9
+ onMouseDown?: MouseEventHandler;
10
+ onMouseUp?: MouseEventHandler;
11
+ }): {
12
+ onMouseUp: MouseEventHandler<Element>;
13
+ onMouseDown: MouseEventHandler<Element>;
14
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useExactClick = void 0;
4
+ const react_1 = require("react");
5
+ const identity_1 = require("../hooks/identity");
6
+ /**
7
+ * Вызывает callback только если клик был начат и закончен на одном и том же элементе.
8
+ * @param onExactClick Сработает при клике.
9
+ * @param options Опции.
10
+ * @return Свойства для целевого элемента.
11
+ */
12
+ function useExactClick(onExactClick, { onMouseDown, onMouseUp, } = {}) {
13
+ const callbackRef = (0, identity_1.useIdentityRef)(onExactClick);
14
+ const mouseDownTarget = (0, react_1.useRef)(null);
15
+ const handleMouseDown = (0, react_1.useCallback)(event => {
16
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
17
+ if (event.button === 0) {
18
+ mouseDownTarget.current = event.target;
19
+ }
20
+ }, []);
21
+ const handleMouseUp = (0, react_1.useCallback)(event => {
22
+ const fn = callbackRef.current;
23
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
24
+ fn &&
25
+ event.button === 0 &&
26
+ event.target === event.currentTarget &&
27
+ event.currentTarget === mouseDownTarget.current &&
28
+ fn();
29
+ }, []);
30
+ return { onMouseUp: handleMouseUp, onMouseDown: handleMouseDown };
31
+ }
32
+ exports.useExactClick = useExactClick;
package/package.json CHANGED
@@ -1,68 +1,92 @@
1
1
  {
2
2
  "name": "@sima-land/ui-nucleons",
3
- "version": "44.2.10",
3
+ "version": "45.0.0-alpha.1",
4
4
  "repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
5
5
  "author": "www.sima-land.ru team",
6
6
  "license": "Apache-2.0",
7
7
  "private": false,
8
8
  "engines": {
9
- "node": ">=14.15.5"
9
+ "node": ">=16.15.1"
10
+ },
11
+ "scripts": {
12
+ "export:colors": "node .template/build.mjs",
13
+ "build:before": "rimraf build",
14
+ "build:main": "tsc --project tsconfig.build.json",
15
+ "build:after": "node dist.mjs",
16
+ "build": "npm run build:before && npm run build:main && npm run build:after",
17
+ "test": "BROWSERSLIST_ENV=\"test\" npx jest",
18
+ "coverage": "jest --clearCache && BROWSERSLIST_ENV=\"test\" npx jest --coverage",
19
+ "type-check": "tsc -p . --noEmit",
20
+ "lint": "npm run lint:scripts && npm run lint:styles",
21
+ "lint:scripts": "eslint --cache src/ --ext .js,.jsx,.ts,.tsx",
22
+ "lint:styles": "stylelint 'src/**/*.{css,scss}'",
23
+ "storybook": "BROWSERSLIST_ENV=\"storybook\" npx start-storybook -p 9009 -c .storybook",
24
+ "storybook:build": "BROWSERSLIST_ENV=\"storybook\" npx build-storybook --quiet --loglevel error -o build-storybook",
25
+ "prettier": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,css,scss}\"",
26
+ "prettier:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,css,scss}\""
10
27
  },
11
28
  "dependencies": {
12
- "@krutoo/input-mask": "^0.0.8",
13
- "@sima-land/ui-quarks": "^3.0.0",
29
+ "@floating-ui/react": "^0.17.0",
30
+ "@krutoo/input-mask": "^0.0.9",
31
+ "@sima-land/ui-quarks": "^3.6.0",
14
32
  "body-scroll-lock": "3.1.5",
15
33
  "classnames": "^2.3.1",
16
34
  "date-fns": "^2.28.0",
17
- "intersection-observer": "^0.12.0",
35
+ "focus-trap": "^7.2.0",
18
36
  "lodash": "^4.17.21",
19
- "overlayscrollbars": "^1.13.1",
20
- "overlayscrollbars-react": "^0.2.3",
21
- "react-transition-group": "^4.4.2"
37
+ "overlayscrollbars": "^1.13.3",
38
+ "overlayscrollbars-react": "^0.3.0",
39
+ "react-transition-group": "^4.4.2",
40
+ "redux": "^4.2.0"
22
41
  },
23
42
  "devDependencies": {
24
43
  "@babel/core": "^7.17.7",
25
44
  "@babel/preset-env": "^7.16.11",
26
45
  "@babel/preset-react": "^7.16.7",
27
46
  "@babel/preset-typescript": "^7.16.7",
47
+ "@playwright/test": "^1.27.1",
28
48
  "@rushstack/eslint-patch": "^1.1.1",
29
49
  "@sima-land/linters": "^2.1.2",
30
- "@storybook/addon-actions": "^6.4.19",
31
- "@storybook/addon-backgrounds": "^6.4.19",
32
- "@storybook/addon-docs": "^6.4.19",
33
- "@storybook/addon-storysource": "^6.4.19",
34
- "@storybook/addons": "^6.4.19",
35
- "@storybook/builder-webpack5": "^6.4.19",
36
- "@storybook/manager-webpack5": "^6.4.19",
37
- "@storybook/react": "^6.4.19",
38
- "@storybook/theming": "^6.4.19",
50
+ "@storybook/addon-actions": "^6.5.14",
51
+ "@storybook/addon-backgrounds": "^6.5.14",
52
+ "@storybook/addon-docs": "^6.5.14",
53
+ "@storybook/addon-storysource": "^6.5.14",
54
+ "@storybook/addons": "^6.5.14",
55
+ "@storybook/builder-webpack5": "^6.5.14",
56
+ "@storybook/manager-webpack5": "^6.5.14",
57
+ "@storybook/react": "^6.5.14",
58
+ "@storybook/theming": "^6.5.14",
39
59
  "@svgr/core": "^6.2.1",
40
60
  "@svgr/plugin-jsx": "^6.2.1",
41
61
  "@svgr/plugin-svgo": "^6.2.0",
42
62
  "@svgr/webpack": "^6.2.1",
43
63
  "@testing-library/react": "^12.1.4",
64
+ "@testing-library/user-event": "^14.4.3",
44
65
  "@types/body-scroll-lock": "^3.1.0",
45
66
  "@types/enzyme": "^3.10.11",
46
67
  "@types/jest": "^27.4.1",
47
68
  "@types/lodash": "^4.14.180",
69
+ "@types/overlayscrollbars": "^1.12.1",
48
70
  "@types/react": "^17.0.40",
49
71
  "@types/react-dom": "^17.0.13",
50
72
  "@types/react-transition-group": "^4.4.4",
51
73
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
52
74
  "babel-jest": "^27.5.1",
53
- "babel-loader": "^8.2.3",
54
- "babel-preset-jest": "^27.5.1",
75
+ "clipboard": "^2.0.11",
55
76
  "copyfiles": "^2.4.1",
56
77
  "css-loader": "^6.7.1",
57
78
  "enzyme": "^3.9.0",
58
79
  "enzyme-to-json": "^3.6.2",
59
80
  "eslint": "^8.11.0",
81
+ "eslint-plugin-storybook": "^0.6.4",
60
82
  "file-loader": "^6.2.0",
61
83
  "handlebars": "^4.7.7",
62
84
  "husky": "^7.0.4",
63
- "jest": "^27.5.1",
64
- "jest-css-modules-transform": "^4.3.0",
85
+ "jest": "^29.3.1",
86
+ "jest-css-modules-transform": "^4.4.2",
87
+ "jest-environment-jsdom": "^29.3.1",
65
88
  "lint-staged": "^12.3.5",
89
+ "lorem-ipsum": "^2.0.8",
66
90
  "postcss": "^8.4.11",
67
91
  "prettier": "^2.5.1",
68
92
  "react": "^17.0.2",
@@ -73,29 +97,13 @@
73
97
  "sass-loader": "^12.6.0",
74
98
  "style-loader": "^3.3.1",
75
99
  "stylelint": "^14.5.3",
76
- "typescript": "^4.6.2",
77
- "typescript-plugin-css-modules": "^3.4.0",
78
- "webpack": "^5.70.0"
100
+ "ts-node": "^10.9.1",
101
+ "typescript": "^4.9.4",
102
+ "typescript-plugin-css-modules": "^4.1.1",
103
+ "webpack": "^5.75.0"
79
104
  },
80
105
  "peerDependencies": {
81
106
  "react": ">=17",
82
107
  "react-dom": ">=17"
83
- },
84
- "scripts": {
85
- "prepare": "",
86
- "export:colors": "node .template/build.mjs",
87
- "build:before": "rimraf build",
88
- "build:main": "tsc --project tsconfig.build.json",
89
- "build:after": "node dist.js",
90
- "build": "npm run build:before && npm run build:main && npm run build:after",
91
- "test": "BROWSERSLIST_ENV=\"test\" npx jest",
92
- "coverage": "jest --clearCache && BROWSERSLIST_ENV=\"test\" npx jest --coverage",
93
- "type-check": "tsc -p . --noEmit",
94
- "lint:scripts": "eslint --cache src/ --ext .js,.jsx,.ts,.tsx",
95
- "lint:styles": "stylelint 'src/**/*.{css,scss}'",
96
- "storybook": "BROWSERSLIST_ENV=\"storybook\" npx start-storybook -p 9009 -c .storybook",
97
- "storybook:build": "BROWSERSLIST_ENV=\"storybook\" npx build-storybook --quiet --loglevel error -o build-storybook",
98
- "prettier": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error",
99
- "prettier:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error"
100
108
  }
101
109
  }
@@ -2,12 +2,12 @@ interface IPageButton {
2
2
  value: number;
3
3
  content: string | number;
4
4
  }
5
- declare type State = {
5
+ type State = {
6
6
  current: number;
7
7
  range: number;
8
8
  total: number;
9
9
  };
10
- export declare const cx: (...args: import("classnames").Argument[]) => string;
10
+ export declare const cx: (...args: import("classnames").ArgumentArray) => string;
11
11
  /**
12
12
  * Фабрика объектов с данными о кнопке страницы.
13
13
  * @param value Номер целевой страницы.
package/panel/index.d.ts CHANGED
@@ -1,24 +1,38 @@
1
- import React from 'react';
2
- import { Token } from '../colors';
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import type { LinkProps } from '../link';
3
+ export type PanelType = 'info' | 'error' | 'success' | 'warning';
3
4
  export interface PanelProps {
4
- /** Наименование цвета панели. */
5
- color?: Token;
6
- /** Наименование цвета содержимого. */
7
- contentColor?: Token;
8
- /** Нужно ли стилизовать как inline-элемент. */
9
- inline?: boolean;
10
- /** Компонент иконки. */
11
- icon?: React.ComponentType<React.SVGAttributes<SVGSVGElement>>;
5
+ /** Тип панели. Влияет на отображение. */
6
+ type?: PanelType;
7
+ /** Иконка перед основным контентом. */
8
+ adornmentStart?: ReactNode;
9
+ /** Иконка после основного контента. */
10
+ adornmentEnd?: ReactNode;
12
11
  /** CSS-класс корневого элемента. */
13
12
  className?: string;
14
- /** Содержимое в виде строки с html-версткой. */
15
- html?: string;
13
+ /** Стили корневого элемента панели. */
14
+ style?: CSSProperties;
15
+ /** Содержимое. */
16
+ children?: ReactNode;
16
17
  /** Идентификатор для систем автоматизированного тестирования. */
17
18
  'data-testid'?: string;
18
19
  }
20
+ export declare const LINK_COLOR_BY_TYPE: Record<PanelType, LinkProps['color']>;
19
21
  /**
20
22
  * Компонент панели с информацией.
21
23
  * @param props Свойства.
22
24
  * @return Элемент.
23
25
  */
24
- export declare const Panel: React.FC<PanelProps>;
26
+ export declare function Panel({ type, adornmentStart, adornmentEnd, className, style, children, 'data-testid': testId, }: PanelProps): JSX.Element;
27
+ export declare namespace Panel {
28
+ var UnknownContent: typeof PanelUnknownContent;
29
+ }
30
+ /**
31
+ * Компонент для вывода неизвестной html-верстки, стилизованной по гайдам Panel.
32
+ * @param props Свойства.
33
+ * @return Элемент.
34
+ */
35
+ declare function PanelUnknownContent({ markup }: {
36
+ markup: string;
37
+ }): JSX.Element;
38
+ export {};
package/panel/index.js CHANGED
@@ -3,22 +3,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Panel = void 0;
6
+ exports.Panel = exports.LINK_COLOR_BY_TYPE = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
- const bind_1 = __importDefault(require("classnames/bind"));
9
8
  const colors_1 = require("../styling/colors");
10
- const colors_2 = require("../colors");
9
+ const bind_1 = __importDefault(require("classnames/bind"));
11
10
  const panel_module_scss_1 = __importDefault(require("./panel.module.scss"));
12
11
  const cx = bind_1.default.bind(panel_module_scss_1.default);
12
+ const PANEL_COLORS_BY_TYPE = {
13
+ info: {
14
+ textColor: 'basic-gray87',
15
+ panelColor: 'basic-gray4',
16
+ },
17
+ error: {
18
+ textColor: 'basic-white',
19
+ panelColor: 'additional-deep-red',
20
+ },
21
+ success: {
22
+ textColor: 'basic-white',
23
+ panelColor: 'additional-teal',
24
+ },
25
+ warning: {
26
+ textColor: 'basic-gray87',
27
+ panelColor: 'additional-yellow',
28
+ },
29
+ };
30
+ exports.LINK_COLOR_BY_TYPE = {
31
+ info: 'basic-blue',
32
+ error: 'basic-white',
33
+ success: 'basic-white',
34
+ warning: 'basic-gray87',
35
+ };
13
36
  /**
14
37
  * Компонент панели с информацией.
15
38
  * @param props Свойства.
16
39
  * @return Элемент.
17
40
  */
18
- const Panel = ({ color: panelColor = 'basic-gray4', contentColor = 'basic-gray87', inline = false, icon: Icon, className, children, html, 'data-testid': testId = 'panel', }) => {
19
- const contentProps = html ? { dangerouslySetInnerHTML: { __html: html } } : { children };
20
- return (react_1.default.createElement("div", { className: cx('panel', inline && 'inline', (0, colors_1.bgColor)(panelColor), className), "data-testid": testId },
21
- Icon && (react_1.default.createElement(Icon, { fill: colors_2.COLORS.get(contentColor), width: 16, height: 20, className: cx('icon'), "aria-hidden": 'true' })),
22
- react_1.default.createElement("div", Object.assign({}, contentProps, { className: cx('content', (0, colors_1.color)(contentColor)) }))));
23
- };
41
+ function Panel({ type = 'info', adornmentStart, adornmentEnd, className, style, children, 'data-testid': testId = 'panel', }) {
42
+ const textColor = PANEL_COLORS_BY_TYPE[type].textColor;
43
+ const panelColor = PANEL_COLORS_BY_TYPE[type].panelColor;
44
+ return (react_1.default.createElement("div", { className: cx('root', `type-${type}`, (0, colors_1.bgColor)(panelColor), (0, colors_1.color)(textColor), className), "data-testid": testId, style: style },
45
+ adornmentStart && react_1.default.createElement("div", { className: cx('adornment') }, adornmentStart),
46
+ react_1.default.createElement("div", { className: cx('main') }, children),
47
+ adornmentEnd && react_1.default.createElement("div", { className: cx('adornment') }, adornmentEnd)));
48
+ }
24
49
  exports.Panel = Panel;
50
+ /**
51
+ * Компонент для вывода неизвестной html-верстки, стилизованной по гайдам Panel.
52
+ * @param props Свойства.
53
+ * @return Элемент.
54
+ */
55
+ function PanelUnknownContent({ markup }) {
56
+ return react_1.default.createElement("div", { className: cx('unknown-content'), dangerouslySetInnerHTML: { __html: markup } });
57
+ }
58
+ Panel.UnknownContent = PanelUnknownContent;