@sima-land/ui-nucleons 44.2.10 → 45.0.0-alpha.0

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 (376) 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/{checkbox/index.js → page-scroll-lock/types.js} +0 -0
  17. package/_internal/readme.md +2 -0
  18. package/_internal/utils/dropdown.d.ts +1 -0
  19. package/_internal/utils/dropdown.js +1 -0
  20. package/alert/alert.module.scss +1 -24
  21. package/alert/index.d.ts +11 -17
  22. package/alert/index.js +33 -16
  23. package/arrow-button/arrow-button.module.scss +2 -0
  24. package/arrow-button/index.d.ts +2 -2
  25. package/autocomplete/autocomplete.d.ts +8 -0
  26. package/autocomplete/autocomplete.js +190 -0
  27. package/autocomplete/autocomplete.module.scss +2 -15
  28. package/autocomplete/index.d.ts +2 -27
  29. package/autocomplete/index.js +2 -126
  30. package/autocomplete/types.d.ts +19 -0
  31. package/autocomplete/types.js +2 -0
  32. package/autocomplete-deprecated/autocomplete.module.scss +20 -0
  33. package/autocomplete-deprecated/index.d.ts +28 -0
  34. package/autocomplete-deprecated/index.js +130 -0
  35. package/avatar/index.d.ts +2 -2
  36. package/avatar/user.d.ts +1 -1
  37. package/base-input/base-input.d.ts +11 -0
  38. package/base-input/base-input.js +96 -0
  39. package/base-input/base-input.module.scss +3 -3
  40. package/base-input/index.d.ts +2 -23
  41. package/base-input/index.js +2 -76
  42. package/base-input/types.d.ts +31 -0
  43. package/base-input/types.js +2 -0
  44. package/base-input/utils.d.ts +6 -0
  45. package/base-input/utils.js +14 -0
  46. package/base-input-deprecated/base-input.module.scss +66 -0
  47. package/base-input-deprecated/index.d.ts +24 -0
  48. package/base-input-deprecated/index.js +80 -0
  49. package/bordered-layout/index.d.ts +1 -0
  50. package/bordered-layout/index.js +1 -0
  51. package/bottom-bar/bottom-bar-util.scss +20 -0
  52. package/bottom-bar/bottom-bar.d.ts +12 -0
  53. package/bottom-bar/bottom-bar.js +47 -0
  54. package/bottom-bar/bottom-bar.module.scss +14 -0
  55. package/bottom-bar/index.d.ts +2 -21
  56. package/bottom-bar/index.js +5 -44
  57. package/bottom-bar/types.d.ts +10 -0
  58. package/bottom-bar/types.js +2 -0
  59. package/box/index.d.ts +1 -1
  60. package/breakpoints.scss +1 -1
  61. package/button/button.module.scss +70 -53
  62. package/button/index.d.ts +26 -41
  63. package/button/index.js +22 -46
  64. package/card/index.d.ts +2 -1
  65. package/card/index.js +23 -6
  66. package/card/slots.d.ts +17 -3
  67. package/card/slots.js +15 -13
  68. package/carousel/draggable.d.ts +7 -3
  69. package/carousel/draggable.js +10 -3
  70. package/carousel/helpers/draggable-event.d.ts +5 -2
  71. package/carousel/helpers/draggable-event.js +5 -0
  72. package/carousel/index.d.ts +1 -1
  73. package/carousel/index.js +24 -24
  74. package/checkbox/checkbox.module.scss +1 -0
  75. package/checkbox/index.d.ts +3 -3
  76. package/checkbox-field/index.d.ts +3 -0
  77. package/checkbox-field/index.js +3 -0
  78. package/clean-buttons/clean-buttons-util.scss +15 -0
  79. package/clean-buttons/clean-buttons.module.scss +5 -3
  80. package/clean-buttons/index.d.ts +16 -7
  81. package/clean-buttons/index.js +17 -14
  82. package/clean-buttons/types.d.ts +1 -1
  83. package/clean-buttons/utils.d.ts +5 -1
  84. package/clean-buttons/utils.js +4 -0
  85. package/{colors.d.ts → colors/index.d.ts} +1 -1
  86. package/{colors.js → colors/index.js} +0 -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 +45 -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 +31 -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 → hint-deprecated}/hint.module.scss +0 -0
  172. package/hint-deprecated/index.d.ts +11 -0
  173. package/hint-deprecated/index.js +53 -0
  174. package/hooks/breakpoint/index.d.ts +7 -4
  175. package/hooks/breakpoint/index.js +21 -13
  176. package/hooks/breakpoint/types.d.ts +3 -4
  177. package/hooks/breakpoint/utils.d.ts +2 -1
  178. package/hooks/breakpoint/utils.js +2 -1
  179. package/hooks/index.d.ts +8 -8
  180. package/hooks/index.js +27 -19
  181. package/hooks/intersection/test-utils.d.ts +1 -1
  182. package/hooks/intersection/test-utils.js +2 -1
  183. package/hooks/styles.d.ts +6 -0
  184. package/hooks/styles.js +26 -0
  185. package/info-text/index.d.ts +23 -0
  186. package/info-text/index.js +60 -0
  187. package/info-text/info-text.module.scss +28 -0
  188. package/input/index.d.ts +32 -0
  189. package/input/index.js +96 -0
  190. package/input/input.module.scss +20 -0
  191. package/input/utils.d.ts +36 -0
  192. package/input/utils.js +71 -0
  193. package/layout/index.d.ts +6 -11
  194. package/layout/index.js +6 -60
  195. package/layout/layout.d.ts +10 -0
  196. package/layout/layout.js +32 -0
  197. package/layout/layout.module.scss +33 -26
  198. package/layout/legacy.d.ts +15 -0
  199. package/layout/legacy.js +68 -0
  200. package/layout/legacy.module.scss +49 -0
  201. package/layout/types.d.ts +6 -0
  202. package/layout/types.js +2 -0
  203. package/link/index.d.ts +4 -1
  204. package/link/index.js +2 -2
  205. package/link/link.module.scss +10 -0
  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 +34 -41
  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 +3 -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/{select → select-deprecated}/select.module.scss +0 -0
  299. package/shadows.scss +18 -0
  300. package/side-page/index.d.ts +11 -26
  301. package/side-page/index.js +21 -26
  302. package/side-page/side-page.module.scss +35 -29
  303. package/side-page/slots.d.ts +12 -20
  304. package/side-page/slots.js +16 -28
  305. package/spinner/index.d.ts +18 -6
  306. package/spinner/index.js +25 -12
  307. package/spinner/spinner.module.scss +8 -0
  308. package/stepper/index.d.ts +18 -10
  309. package/stepper/index.js +17 -8
  310. package/stepper/stepper.module.scss +14 -15
  311. package/styling/fonts.d.ts +3 -3
  312. package/switcher-row/index.d.ts +42 -0
  313. package/switcher-row/index.js +59 -0
  314. package/switcher-row/switcher-row.module.scss +55 -0
  315. package/text/index.d.ts +1 -1
  316. package/text-button/index.d.ts +42 -0
  317. package/text-button/index.js +46 -0
  318. package/text-button/text-button.module.scss +99 -0
  319. package/text-field/index.d.ts +7 -6
  320. package/text-field/index.js +3 -2
  321. package/textarea/index.d.ts +21 -0
  322. package/textarea/index.js +85 -0
  323. package/textarea/textarea.module.scss +15 -0
  324. package/toggle/index.d.ts +3 -3
  325. package/toggle/toggle.module.scss +17 -8
  326. package/tooltip/index.d.ts +1 -0
  327. package/tooltip/index.js +1 -0
  328. package/top-bar/index.d.ts +3 -40
  329. package/top-bar/index.js +4 -60
  330. package/top-bar/top-bar-util.scss +29 -0
  331. package/top-bar/top-bar.d.ts +9 -0
  332. package/top-bar/top-bar.js +101 -0
  333. package/top-bar/top-bar.module.scss +129 -67
  334. package/top-bar/types.d.ts +31 -0
  335. package/top-bar/types.js +2 -0
  336. package/top-bar/utils.d.ts +14 -0
  337. package/top-bar/utils.js +56 -0
  338. package/touch-slider/index.d.ts +1 -0
  339. package/touch-slider/index.js +3 -2
  340. package/types.d.ts +18 -0
  341. package/types.js +2 -0
  342. package/unknown-content/index.d.ts +3 -3
  343. package/unknown-content/index.js +3 -3
  344. package/unknown-content/unknown-content.module.scss +16 -12
  345. package/upload-area/index.d.ts +2 -0
  346. package/upload-area/index.js +5 -0
  347. package/upload-area/types.d.ts +32 -0
  348. package/upload-area/types.js +2 -0
  349. package/upload-area/upload-area-util.scss +17 -0
  350. package/upload-area/upload-area.d.ts +8 -0
  351. package/upload-area/upload-area.js +105 -0
  352. package/upload-area/upload-area.module.scss +78 -0
  353. package/{upload → upload-area}/upload.svg +0 -0
  354. package/upload-area/utils.d.ts +17 -0
  355. package/upload-area/utils.js +48 -0
  356. package/utils.scss +74 -1
  357. package/with-hint/index.d.ts +3 -2
  358. package/with-hint/index.js +1 -0
  359. package/with-hint/positioning-hint.d.ts +1 -1
  360. package/with-hint/positioning-hint.js +2 -2
  361. package/with-tooltip/index.d.ts +2 -1
  362. package/with-tooltip/index.js +1 -0
  363. package/with-tooltip/utils.d.ts +2 -2
  364. package/_internal/body-scroll.d.ts +0 -23
  365. package/_internal/body-scroll.js +0 -41
  366. package/_internal/checkbox/index.d.ts +0 -5
  367. package/constants.d.ts +0 -6
  368. package/constants.js +0 -9
  369. package/nav-bar/index.d.ts +0 -46
  370. package/nav-bar/index.js +0 -76
  371. package/nav-bar/nav-bar.module.scss +0 -95
  372. package/upload/area.d.ts +0 -25
  373. package/upload/area.js +0 -65
  374. package/upload/area.module.scss +0 -44
  375. package/upload/utils.d.ts +0 -29
  376. package/upload/utils.js +0 -45
package/readme.md CHANGED
@@ -5,6 +5,7 @@
5
5
  ## Использование
6
6
 
7
7
  Установка
8
+
8
9
  ```bash
9
10
  # npm
10
11
  npm i -S @sima-land/ui-nucleons
@@ -14,21 +15,26 @@ yarn add @sima-land/ui-nucleons
14
15
  ```
15
16
 
16
17
  ### Настройка сборки и запуска тестов
18
+
17
19
  Компоненты библиотеки используют:
20
+
18
21
  - импорты стилей
19
22
  - импорты стилей как css-модулей (каждый такой файл промаркирован в виде `%filename%.module.scss`)
20
23
  - импорты svg-файлов как react-компоненты
21
24
 
22
25
  #### Для работы с Webpack необходимо (как вариант):
26
+
23
27
  - добавить необходимые пакеты `@svgr/*`
24
28
  - сконфигурировать обработку svg, css, scss файлов
25
29
 
26
30
  ##### Добавление пакетов `@svgr/*`:
31
+
27
32
  ```bash
28
33
  npm install --save-dev @svgr/core @svgr/plugin-svgo @svgr/webpack
29
34
  ```
30
35
 
31
36
  ##### Конфигурация webpack
37
+
32
38
  ```js
33
39
  // webpack.config.js
34
40
  const svgrOptions = require('../../svgr.config'); // опции SVGR (скопировать из данного проекта)
@@ -51,10 +57,7 @@ module.exports = {
51
57
  {
52
58
  test: /\.(css|scss)$/,
53
59
  exclude: /\.module\.(css|scss)$/,
54
- use: [
55
- 'css-loader',
56
- 'postcss-loader',
57
- ],
60
+ use: ['css-loader', 'sass-loader'],
58
61
  },
59
62
 
60
63
  // обработка css-модулей
@@ -70,7 +73,6 @@ module.exports = {
70
73
  },
71
74
  },
72
75
  },
73
- 'postcss-loader',
74
76
  'sass-loader',
75
77
  ],
76
78
  },
@@ -84,28 +86,28 @@ module.exports = {
84
86
  ##### Добавить обработку SVG
85
87
 
86
88
  - добавить файл "трансформера" вида:
89
+
87
90
  ```js
88
- const babel = require('@babel/core');
89
- const babelJestPreset = require('babel-preset-jest');
90
- const svgr = require('@svgr/core').default;
91
- const svgrOptions = require('../../svgr.config'); // опции SVGR
91
+ const swc = require('@swc/core');
92
+ const svgr = require('@svgr/core');
93
+ const svgrConfig = require('../../svgr.config');
92
94
 
93
95
  module.exports = {
94
- process: (src, filename) => {
95
- const code = svgr.sync(src, svgrOptions, { filePath: filename });
96
+ process(sourceText, sourcePath) {
97
+ const code = svgr.transform.sync(sourceText, svgrConfig, { filePath: sourcePath });
98
+ const result = swc.transformSync(code);
96
99
 
97
- return babel.transformSync(code, {
98
- filename,
99
- presets: [babelJestPreset],
100
- }).code;
100
+ return result;
101
101
  },
102
102
  };
103
103
  ```
104
+
104
105
  - задействовать его в конфигурации Jest
105
106
 
106
107
  ##### Добавить поддержку стилей
107
108
 
108
109
  В конфигурации Jest:
110
+
109
111
  ```js
110
112
  module.exports = {
111
113
  transform: {
@@ -154,39 +156,30 @@ declare module '*.svg' {
154
156
 
155
157
  ### Принципы библиотеки
156
158
 
157
- - в библиотеке не должно быть HOC (компонентов высшего порядка - функций возвращающих компонент)
159
+ - в библиотеке не должно быть HOC (компонентов высшего порядка - функций, возвращающих компонент)
158
160
  - компонент интерфейса не должен иметь внешних отступов по умолчанию
159
161
 
160
- ### Консольные команды, необходимые в процессе разработки
161
- * ```npm run build``` - сборка компонентов в `./build` для публикации
162
- * ```npm run test``` - запуск тестов *Jest*
163
- * ```npm run lint:scripts``` - запуск линтера *ESLint*
164
- * ```npm run lint:styles``` - запуск линтера *styleLint*
165
- * ```npm run type-check``` - Проверка типов TS
166
- * ```npm run storybook``` - запуск *storybook*
167
-
168
162
  ### Структура библиотеки
169
163
 
170
164
  `src/` - директория со всеми компонентами библиотеки
171
- * `something/` - директория с компонентом
172
- * `__stories__/`
173
- * `index.stories.tsx` - описание компонента для storybook
174
- * `__test__/`
175
- * `index.test.tsx` - unit-тесты
176
- * `index.tsx` - файл, с именованными экспортами компонента и интерфейса
177
- * `helpers/` - общие вспомогательные функции (для использования вне библиотеки)
178
- * `hooks/` - общие react-хуки (для использования вне библиотеки)
179
- * `_internal/` - внутренние скрипты для использования только в рамках данной библиотеки
180
165
 
181
- ## Работа компонентов, использующих информацию о viewport
166
+ - `something/` - директория с компонентом
167
+ - `__stories__/`
168
+ - `index.stories.tsx` - описание компонента для storybook
169
+ - `__test__/`
170
+ - `index.test.tsx` - unit-тесты
171
+ - `index.tsx` - файл, с именованными экспортами компонента и интерфейса
172
+ - `helpers/` - общие вспомогательные функции (для использования вне библиотеки)
173
+ - `hooks/` - общие react-хуки (для использования вне библиотеки)
174
+ - `_internal/` - внутренние скрипты для использования только в рамках данной библиотеки
182
175
 
183
- Компоненты вроде `Screen` и `Alert` используют следующие css-переменные:
176
+ ### Тестирование
184
177
 
185
- - `--vh`: используется как сотая доля высоты экрана (аналог `1vh`), может учитывать визуальный viewport
186
- - `--offsetTop`: используется как позиция верхней границы визуального viewport'а
178
+ Локально E2E-тесты должны запускаться через docker, пример:
187
179
 
188
- При использовании таких компонентов в проектах, для корректной работы на мобильных устройствах (например при показе/скрытии виртуальных клавиатур и других изменениях viewport), необходимо предоставить эти переменные (например установив их на `<body />`)
189
-
190
- При работе над подобными компонентами необходимо учитывать отсутствие этих переменных и не забывать устанавливать запасное значение при использовании `var()`
180
+ ```bash
181
+ docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.29.2-focal /bin/bash
182
+ npx playwright test
183
+ ```
191
184
 
192
- Установка не выполняется компонентами самостоятельно в целях производительности.
185
+ В противном случае скриншотные тесты не будут совпадать из-за разницы окружения запуска.
package/screen/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ScreenInnerProps } from './utils';
3
- export interface ScreenProps extends ScreenInnerProps {
3
+ import { WithPageScrollLock } from '../_internal/page-scroll-lock';
4
+ export interface ScreenProps extends ScreenInnerProps, WithPageScrollLock {
4
5
  /** Содержимое. */
5
6
  children?: React.ReactNode;
6
7
  /** Определяет область отображаемую как загружающуюся. */
@@ -10,11 +11,12 @@ export interface ScreenProps extends ScreenInnerProps {
10
11
  }
11
12
  /**
12
13
  * Экран.
14
+ * @deprecated На адаптивных страницах стоит использовать Modal.
13
15
  * @param props Свойства.
14
16
  * @return Элемент.
15
17
  */
16
18
  export declare const Screen: {
17
- ({ children, loading, loadingArea, loadingOverlayProps, onFullScroll, fullScrollThreshold, "data-testid": testId, }: ScreenProps): JSX.Element;
19
+ ({ children, loading, loadingArea, loadingOverlayProps, onFullScroll, fullScrollThreshold, withScrollDisable, scrollDisableOptions, "data-testid": testId, }: ScreenProps): JSX.Element;
18
20
  Header: ({ divided, title, subtitle, buttons, onBack, onClose, ...restProps }: import("./slots").HeaderSlotProps) => JSX.Element;
19
21
  Body: React.ForwardRefExoticComponent<{
20
22
  children?: React.ReactNode;
package/screen/index.js CHANGED
@@ -1,21 +1,46 @@
1
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
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.Screen = void 0;
7
- const react_1 = __importDefault(require("react"));
30
+ const react_1 = __importStar(require("react"));
8
31
  const slots_1 = require("./slots");
9
32
  const layer_1 = require("../helpers/layer");
10
33
  const define_slots_1 = require("../helpers/define-slots");
11
34
  const utils_1 = require("./utils");
12
35
  const screen_module_scss_1 = __importDefault(require("./screen.module.scss"));
36
+ const styles_1 = require("../hooks/styles");
13
37
  /**
14
38
  * Экран.
39
+ * @deprecated На адаптивных страницах стоит использовать Modal.
15
40
  * @param props Свойства.
16
41
  * @return Элемент.
17
42
  */
18
- const Screen = ({ children, loading, loadingArea = 'full', loadingOverlayProps, onFullScroll, fullScrollThreshold = 320, 'data-testid': testId = 'screen', }) => {
43
+ const Screen = ({ children, loading, loadingArea = 'full', loadingOverlayProps, onFullScroll, fullScrollThreshold = 320, withScrollDisable, scrollDisableOptions, 'data-testid': testId = 'screen', }) => {
19
44
  const fullLoading = loading && loadingArea === 'full';
20
45
  const layer = (0, layer_1.useLayer)() + 300; // 300 из-за монолита
21
46
  const { header, body, footer } = (0, define_slots_1.defineSlots)(children, {
@@ -23,10 +48,14 @@ const Screen = ({ children, loading, loadingArea = 'full', loadingOverlayProps,
23
48
  body: slots_1.BodySlot,
24
49
  footer: slots_1.FooterSlot,
25
50
  });
51
+ const rootRef = (0, react_1.useRef)(null);
52
+ (0, styles_1.useViewportHeightUnit)(rootRef);
26
53
  if (!body) {
27
54
  throw Error('Looks like you are trying to render <Screen /> without <Screen.Body /> slot, but it is required');
28
55
  }
29
- return (react_1.default.createElement("div", { className: screen_module_scss_1.default.root, style: { zIndex: layer }, "data-testid": testId },
56
+ return (react_1.default.createElement("div", { ref: rootRef, className: screen_module_scss_1.default.root, style: {
57
+ zIndex: layer, // z-index именно здесь из-за position: fixed
58
+ }, "data-testid": testId },
30
59
  react_1.default.createElement(layer_1.LayerProvider, { value: layer },
31
60
  !fullLoading && header,
32
61
  react_1.default.createElement(utils_1.ScreenContext.Provider, { value: {
@@ -34,6 +63,8 @@ const Screen = ({ children, loading, loadingArea = 'full', loadingOverlayProps,
34
63
  loadingOverlayProps,
35
64
  onFullScroll,
36
65
  fullScrollThreshold,
66
+ withScrollDisable,
67
+ scrollDisableOptions,
37
68
  } }, body),
38
69
  !fullLoading && footer && (react_1.default.createElement("div", { className: screen_module_scss_1.default.footer, "data-testid": 'screen:footer' }, footer)))));
39
70
  };
@@ -6,8 +6,6 @@
6
6
  left: 0;
7
7
  display: flex;
8
8
  flex-direction: column;
9
-
10
- // для корректного отображения с динамическим viewport переменная --vh должна быть доступна
11
9
  height: calc(var(--vh, 1vh) * 100);
12
10
  width: 100%;
13
11
  box-sizing: border-box;
package/screen/slots.d.ts CHANGED
@@ -1,12 +1,6 @@
1
1
  import React from 'react';
2
- import { NavBarProps } from '../nav-bar';
3
- export interface HeaderSlotProps extends NavBarProps {
4
- /** Нужна ли разделительная полоса внизу шапки экрана. */
5
- divided?: boolean;
6
- /** Заголовок. */
7
- title?: string;
8
- /** Подзаголовок. */
9
- subtitle?: string;
2
+ import { TopBarProps } from '../top-bar';
3
+ export interface HeaderSlotProps extends TopBarProps {
10
4
  /** Будет вызвана при нажатии на кнопку-стрелку. */
11
5
  onBack?: () => void;
12
6
  /** Будет вызвана при нажатии на кнопку-крести. */
package/screen/slots.js CHANGED
@@ -39,16 +39,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.FooterSlot = exports.BodySlot = exports.HeaderSlot = void 0;
41
41
  const react_1 = __importStar(require("react"));
42
- const nav_bar_1 = require("../nav-bar");
43
42
  const lodash_1 = require("lodash");
44
43
  const arrow_left_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/arrow-left"));
45
44
  const cross_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/cross"));
46
- const body_scroll_1 = require("../_internal/body-scroll");
45
+ const page_scroll_lock_1 = require("../_internal/page-scroll-lock");
47
46
  const hooks_1 = require("../hooks");
48
47
  const loading_overlay_1 = require("../loading-overlay");
49
48
  const utils_1 = require("./utils");
50
49
  const screen_module_scss_1 = __importDefault(require("./screen.module.scss"));
51
- const constants_1 = require("../constants");
50
+ const top_bar_1 = require("../top-bar");
52
51
  /**
53
52
  * Слот шапки экрана.
54
53
  * @param props Свойства.
@@ -56,11 +55,11 @@ const constants_1 = require("../constants");
56
55
  */
57
56
  const HeaderSlot = (_a) => {
58
57
  var { divided, title, subtitle, buttons, onBack, onClose } = _a, restProps = __rest(_a, ["divided", "title", "subtitle", "buttons", "onBack", "onClose"]);
59
- return (react_1.default.createElement(nav_bar_1.NavBar, Object.assign({}, restProps, { title: title, subtitle: subtitle, bottomBordered: divided, buttons: Object.assign(Object.assign({}, buttons), { start: onBack
58
+ return (react_1.default.createElement(top_bar_1.TopBar, Object.assign({}, restProps, { size: 's', title: title, subtitle: subtitle, divided: divided, buttons: Object.assign(Object.assign({}, buttons), { start: onBack
60
59
  ? {
61
60
  // ВАЖНО: не подмешиваем свойства из buttons.start
62
61
  // чтобы не распылять конфигурацию одной и той же кнопки по нескольким местам
63
- icon: arrow_left_1.default,
62
+ icon: react_1.default.createElement(arrow_left_1.default, null),
64
63
  onClick: onBack,
65
64
  'aria-label': 'Вернуться назад',
66
65
  'data-testid': 'screen:back',
@@ -69,7 +68,7 @@ const HeaderSlot = (_a) => {
69
68
  ? {
70
69
  // ВАЖНО: не подмешиваем свойства из buttons.end
71
70
  // чтобы не распылять конфигурацию одной и той же кнопки по нескольким местам
72
- icon: cross_1.default,
71
+ icon: react_1.default.createElement(cross_1.default, null),
73
72
  onClick: onClose,
74
73
  'aria-label': `Закрыть ${title || ''}`.trim(),
75
74
  'data-testid': 'screen:close',
@@ -81,17 +80,17 @@ exports.HeaderSlot = HeaderSlot;
81
80
  * Слот основного контента экрана.
82
81
  */
83
82
  exports.BodySlot = (0, react_1.forwardRef)(function BodySlot({ children }, outerRef) {
84
- const { loading, loadingOverlayProps, onFullScroll, fullScrollThreshold } = (0, react_1.useContext)(utils_1.ScreenContext);
83
+ const { loading, loadingOverlayProps, onFullScroll, fullScrollThreshold, withScrollDisable, scrollDisableOptions, } = (0, react_1.useContext)(utils_1.ScreenContext);
85
84
  // при блокировке прокрутки нужно передавать элемент, которому нужно сохранить возможность прокрутки
86
85
  // https://github.com/willmcpo/body-scroll-lock/blame/79c4cf2c956eb7d5cf8d54a03d12751bc6ac8aa3/README.md#L52
87
86
  // поэтому используем внутренний ref и useImperativeHandle
88
87
  const ref = (0, react_1.useRef)(null);
89
88
  (0, react_1.useImperativeHandle)(outerRef, () => ref.current);
90
- (0, body_scroll_1.useBodyScrollLock)(ref, true, { allowTouchMove: body_scroll_1.allowTouchMove });
89
+ (0, page_scroll_lock_1.usePageScrollLock)(ref, Object.assign({ lockEnabled: withScrollDisable }, scrollDisableOptions));
91
90
  (0, hooks_1.useInfiniteScroll)(ref, { onFullScroll, threshold: fullScrollThreshold });
92
91
  return (
93
92
  // ВАЖНО: элемент с ref должен выводиться всегда (без условий), т.к. он нужен для блокировки прокрутки
94
- react_1.default.createElement("div", Object.assign({ ref: ref, className: screen_module_scss_1.default.body, "data-testid": 'screen:body' }, { [constants_1.BSL_IGNORE_ATTR]: true }), loading ? (react_1.default.createElement(loading_overlay_1.LoadingOverlay, Object.assign({}, loadingOverlayProps, { fill: false, style: { height: '100%' } }))) : (children)));
93
+ react_1.default.createElement("div", { ref: ref, className: screen_module_scss_1.default.body, "data-testid": 'screen:body' }, loading ? (react_1.default.createElement(loading_overlay_1.LoadingOverlay, Object.assign({}, loadingOverlayProps, { fill: false, style: { height: '100%' } }))) : (children)));
95
94
  });
96
95
  /**
97
96
  * Слот футера экрана.
package/screen/utils.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { LoadingOverlayProps } from '../loading-overlay';
3
- export interface ScreenInnerProps {
3
+ import { WithPageScrollLock } from '../_internal/page-scroll-lock';
4
+ export interface ScreenInnerProps extends WithPageScrollLock {
4
5
  /** Нужно ли выводить вместо содержимого состояние загрузки. */
5
6
  loading?: boolean;
6
7
  /** Свойства компонента LoadingOverlay. */
package/select/index.d.ts CHANGED
@@ -1,33 +1,2 @@
1
- import React from 'react';
2
- import { TextFieldProps } from '../text-field';
3
- declare type Size = 's' | 'm' | 'l' | 'xl';
4
- export interface SelectProps extends Omit<TextFieldProps, 'style' | 'endAdornment'> {
5
- /** Нужно ли выводить состояние загрузки списка. */
6
- loading?: boolean;
7
- /** Сработает при открытии/закрытии меню. */
8
- onMenuToggle?: (opened: boolean) => void;
9
- /** Сработает при выборе. */
10
- onSelect?: (option: any) => void;
11
- /** Список опций. */
12
- options: any[];
13
- /** Размер для DropdownItem. */
14
- optionSize?: Size;
15
- /** Вернет содержимое опции. */
16
- renderOption?: (option: any) => React.ReactNode;
17
- /** Стили. */
18
- style?: React.CSSProperties;
19
- endAdornment?: TextFieldProps['endAdornment'] | ((opened: boolean) => React.ReactNode);
20
- }
21
- /**
22
- * Выводит иконку стрелки для поля Select по умолчанию.
23
- * @param opened Открыт ли список опций.
24
- * @return Элемент.
25
- */
26
- export declare const renderDefaultArrow: (opened: boolean) => JSX.Element;
27
- /**
28
- * Поле выбора из списка.
29
- * @param props Свойства.
30
- * @return Элемент.
31
- */
32
- export declare const Select: ({ options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption, "data-testid": dataTestId, size, endAdornment, ...restProps }: SelectProps) => JSX.Element;
33
- export {};
1
+ export type { SelectProps, SelectStyle } from './types';
2
+ export { Select } from './select';
package/select/index.js CHANGED
@@ -1,111 +1,5 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.Select = exports.renderDefaultArrow = void 0;
41
- const react_1 = __importStar(require("react"));
42
- const dropdown_1 = require("../dropdown");
43
- const dropdown_item_1 = require("../dropdown-item");
44
- const text_field_1 = require("../text-field");
45
- const dropdown_2 = require("../_internal/utils/dropdown");
46
- const bind_1 = __importDefault(require("classnames/bind"));
47
- const down_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/down"));
48
- const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/up"));
49
- const select_module_scss_1 = __importDefault(require("./select.module.scss"));
50
- const colors_1 = require("../colors");
51
- const dropdown_loading_1 = require("../_internal/dropdown-loading");
52
- const hooks_1 = require("../hooks");
53
- const cx = bind_1.default.bind(select_module_scss_1.default);
54
- /**
55
- * Выводит иконку стрелки для поля Select по умолчанию.
56
- * @param opened Открыт ли список опций.
57
- * @return Элемент.
58
- */
59
- const renderDefaultArrow = (opened) => {
60
- const ArrowSVG = opened ? up_1.default : down_1.default;
61
- return react_1.default.createElement(ArrowSVG, { fill: colors_1.COLORS.get('basic-gray38') });
62
- };
63
- exports.renderDefaultArrow = renderDefaultArrow;
64
- /**
65
- * Поле выбора из списка.
66
- * @param props Свойства.
67
- * @return Элемент.
68
- */
69
- const Select = (_a) => {
70
- var { options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption = String, 'data-testid': dataTestId, size, endAdornment = exports.renderDefaultArrow } = _a, restProps = __rest(_a, ["options", "optionSize", "onSelect", "style", "className", "label", "onClick", "value", "loading", "onMenuToggle", "renderOption", 'data-testid', "size", "endAdornment"]);
71
- const rootRef = (0, react_1.useRef)(null);
72
- const fieldRef = (0, react_1.useRef)(null);
73
- const menuRef = (0, react_1.useRef)(null);
74
- const [opened, toggleMenu] = (0, react_1.useState)(false);
75
- (0, react_1.useEffect)(() => {
76
- opened && menuRef.current && menuRef.current.focus();
77
- onMenuToggle && onMenuToggle(opened);
78
- }, [opened]);
79
- (0, hooks_1.useOutsideClick)(rootRef, toggleMenu.bind(null, false));
80
- return (react_1.default.createElement("div", { ref: rootRef, style: style, className: cx('root', className), "data-testid": dataTestId },
81
- react_1.default.createElement(text_field_1.TextField, Object.assign({}, restProps, { size: size, blockProps: {
82
- ref: fieldRef,
83
- tabIndex: 0,
84
- onMouseDown: () => {
85
- toggleMenu(a => !a);
86
- },
87
- onKeyDown: e => {
88
- e.key === 'Enter' && toggleMenu(true);
89
- },
90
- }, onClick: e => {
91
- e.preventDefault();
92
- onClick && onClick(e);
93
- }, className: select_module_scss_1.default.field, "data-testid": 'select:field', label: label, focused: opened, baseInputProps: {
94
- // чтобы не ловить фокус на поле
95
- style: { pointerEvents: 'none' },
96
- tabIndex: -1,
97
- }, value: value, multiline: false, variant: 'desktop', readOnly: true, endAdornment: typeof endAdornment === 'function' ? endAdornment(opened) : endAdornment })),
98
- opened && (loading || options.length > 0) && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({}, (0, dropdown_2.placeDropdown)(size), { ref: menuRef, "data-testid": 'select:menu', role: 'menu', tabIndex: -1, className: cx('menu'), onKeyDown: event => {
99
- if (event.key === 'Enter') {
100
- toggleMenu(false);
101
- fieldRef.current && fieldRef.current.focus();
102
- }
103
- }, onBlur: () => {
104
- toggleMenu(false);
105
- fieldRef.current && fieldRef.current.focus();
106
- } }), loading ? (react_1.default.createElement(dropdown_loading_1.DropdownLoading, { "data-testid": 'select:loading-area' })) : (options.map((option, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: optionSize, key: index, role: 'menuitem', onClick: () => {
107
- toggleMenu(false);
108
- onSelect && onSelect(option);
109
- } }, renderOption(option)))))))));
110
- };
111
- exports.Select = Select;
3
+ exports.Select = void 0;
4
+ var select_1 = require("./select");
5
+ Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return select_1.Select; } });
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { FieldBlockProps } from '../../field-block';
3
+ /**
4
+ * Компонент открывашки в виде поля.
5
+ * @param props Свойства.
6
+ * @return Элемент.
7
+ */
8
+ export declare function SelectFieldBlock(props: FieldBlockProps): JSX.Element;
@@ -0,0 +1,70 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.SelectFieldBlock = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const utils_1 = require("../utils");
32
+ const field_block_1 = require("../../field-block");
33
+ const colors_1 = require("../../colors");
34
+ const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/up"));
35
+ const down_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/down"));
36
+ const block_module_scss_1 = __importDefault(require("./block.module.scss"));
37
+ const classnames_1 = __importDefault(require("classnames"));
38
+ /**
39
+ * Компонент открывашки в виде поля.
40
+ * @param props Свойства.
41
+ * @return Элемент.
42
+ */
43
+ function SelectFieldBlock(props) {
44
+ var _a;
45
+ const binding = (0, react_1.useContext)(utils_1.SelectContext);
46
+ const [focused, setFocused] = (0, react_1.useState)(false);
47
+ const ArrowSVG = binding.opened ? up_1.default : down_1.default;
48
+ // @todo прокидывать ref в props.blockRef при необходимости
49
+ const ref = (0, react_1.useRef)(null);
50
+ (0, react_1.useImperativeHandle)(binding.anchorRef, () => ref.current);
51
+ (0, react_1.useImperativeHandle)(binding.openerRef, () => ref.current);
52
+ return (react_1.default.createElement(field_block_1.FieldBlock, Object.assign({ label: binding.label, adornmentEnd: react_1.default.createElement(ArrowSVG, { fill: colors_1.COLORS.get('basic-gray24') }) }, props, { failed: binding.failed, disabled: binding.disabled, fixedHeight: true, blockRef: ref, blockProps: Object.assign(Object.assign({}, props === null || props === void 0 ? void 0 : props.blockProps), { onFocus: event => {
53
+ var _a, _b;
54
+ setFocused(true);
55
+ (_b = (_a = props.blockProps) === null || _a === void 0 ? void 0 : _a.onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, event);
56
+ }, onBlur: event => {
57
+ var _a, _b;
58
+ setFocused(false);
59
+ (_b = (_a = props.blockProps) === null || _a === void 0 ? void 0 : _a.onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, event);
60
+ }, onKeyDown: event => {
61
+ var _a, _b, _c;
62
+ (_a = binding.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(binding, event);
63
+ (_c = (_b = props.blockProps) === null || _b === void 0 ? void 0 : _b.onKeyDown) === null || _c === void 0 ? void 0 : _c.call(_b, event);
64
+ }, onMouseDown: event => {
65
+ var _a, _b, _c;
66
+ (_a = binding.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(binding, event);
67
+ (_c = (_b = props.blockProps) === null || _b === void 0 ? void 0 : _b.onMouseDown) === null || _c === void 0 ? void 0 : _c.call(_b, event);
68
+ }, role: 'combobox', tabIndex: binding.disabled ? undefined : 0, className: (0, classnames_1.default)(block_module_scss_1.default.block, (_a = props.blockProps) === null || _a === void 0 ? void 0 : _a.className) }), focused: focused || binding.opened, labelAsPlaceholder: !binding.value, main: binding.value })));
69
+ }
70
+ exports.SelectFieldBlock = SelectFieldBlock;
@@ -0,0 +1,3 @@
1
+ .block {
2
+ cursor: pointer;
3
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { TextButtonAsButtonProps } from '../../text-button';
3
+ /**
4
+ * Компонент открывашки в виде текстовой кнопки.
5
+ * @param props Свойства.
6
+ * @return Элемент.
7
+ */
8
+ export declare function SelectTextButton({ buttonRef: buttonRefProp, children, onKeyDown, onMouseDown, ...props }: TextButtonAsButtonProps): JSX.Element;