@cloud-ru/ds-toolbar 1.0.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 (261) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +301 -0
  4. package/dist/cjs/components/Toolbar/Toolbar.d.ts +3 -0
  5. package/dist/cjs/components/Toolbar/Toolbar.js +51 -0
  6. package/dist/cjs/components/Toolbar/helpers.d.ts +12 -0
  7. package/dist/cjs/components/Toolbar/helpers.js +27 -0
  8. package/dist/cjs/components/Toolbar/hooks/index.d.ts +2 -0
  9. package/dist/cjs/components/Toolbar/hooks/index.js +18 -0
  10. package/dist/cjs/components/Toolbar/hooks/useFilters.d.ts +12 -0
  11. package/dist/cjs/components/Toolbar/hooks/useFilters.js +55 -0
  12. package/dist/cjs/components/Toolbar/hooks/usePersistState/index.d.ts +1 -0
  13. package/dist/cjs/components/Toolbar/hooks/usePersistState/index.js +17 -0
  14. package/dist/cjs/components/Toolbar/hooks/usePersistState/usePersistState.d.ts +9 -0
  15. package/dist/cjs/components/Toolbar/hooks/usePersistState/usePersistState.js +72 -0
  16. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/index.d.ts +3 -0
  17. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/index.js +19 -0
  18. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/isDateString.d.ts +9 -0
  19. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/isDateString.js +45 -0
  20. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/parser.d.ts +4 -0
  21. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/parser.js +46 -0
  22. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/serializer.d.ts +11 -0
  23. package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/serializer.js +41 -0
  24. package/dist/cjs/components/Toolbar/index.d.ts +3 -0
  25. package/dist/cjs/components/Toolbar/index.js +19 -0
  26. package/dist/cjs/components/Toolbar/styles.module.css +297 -0
  27. package/dist/cjs/components/Toolbar/types.d.ts +80 -0
  28. package/dist/cjs/components/Toolbar/types.js +2 -0
  29. package/dist/cjs/components/Toolbar/typesUtils.d.ts +12 -0
  30. package/dist/cjs/components/Toolbar/typesUtils.js +2 -0
  31. package/dist/cjs/components/Toolbar/utils/buildMobileOverflowActions.d.ts +10 -0
  32. package/dist/cjs/components/Toolbar/utils/buildMobileOverflowActions.js +84 -0
  33. package/dist/cjs/components/Toolbar/utils/toolbarAfterOverflow.d.ts +2 -0
  34. package/dist/cjs/components/Toolbar/utils/toolbarAfterOverflow.js +5 -0
  35. package/dist/cjs/components/index.d.ts +4 -0
  36. package/dist/cjs/components/index.js +23 -0
  37. package/dist/cjs/helperComponents/BulkActions/BulkActions.d.ts +2 -0
  38. package/dist/cjs/helperComponents/BulkActions/BulkActions.js +20 -0
  39. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.d.ts +8 -0
  40. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.js +20 -0
  41. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/index.d.ts +1 -0
  42. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/index.js +17 -0
  43. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/styles.module.css +3 -0
  44. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.d.ts +17 -0
  45. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.js +39 -0
  46. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/index.d.ts +1 -0
  47. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/index.js +17 -0
  48. package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/styles.module.css +39 -0
  49. package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.d.ts +14 -0
  50. package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.js +27 -0
  51. package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.d.ts +1 -0
  52. package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.js +17 -0
  53. package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.d.ts +9 -0
  54. package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.js +21 -0
  55. package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/index.d.ts +1 -0
  56. package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/index.js +17 -0
  57. package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/styles.module.css +40 -0
  58. package/dist/cjs/helperComponents/BulkActions/components/index.d.ts +4 -0
  59. package/dist/cjs/helperComponents/BulkActions/components/index.js +20 -0
  60. package/dist/cjs/helperComponents/BulkActions/index.d.ts +2 -0
  61. package/dist/cjs/helperComponents/BulkActions/index.js +18 -0
  62. package/dist/cjs/helperComponents/BulkActions/styles.module.css +9 -0
  63. package/dist/cjs/helperComponents/BulkActions/types.d.ts +31 -0
  64. package/dist/cjs/helperComponents/BulkActions/types.js +2 -0
  65. package/dist/cjs/helperComponents/BulkActions/utils.d.ts +15 -0
  66. package/dist/cjs/helperComponents/BulkActions/utils.js +26 -0
  67. package/dist/cjs/helperComponents/DataView/DataView.d.ts +2 -0
  68. package/dist/cjs/helperComponents/DataView/DataView.js +9 -0
  69. package/dist/cjs/helperComponents/DataView/constants.d.ts +9 -0
  70. package/dist/cjs/helperComponents/DataView/constants.js +13 -0
  71. package/dist/cjs/helperComponents/DataView/index.d.ts +3 -0
  72. package/dist/cjs/helperComponents/DataView/index.js +19 -0
  73. package/dist/cjs/helperComponents/DataView/types.d.ts +12 -0
  74. package/dist/cjs/helperComponents/DataView/types.js +2 -0
  75. package/dist/cjs/helperComponents/FilterButton/FilterButton.d.ts +12 -0
  76. package/dist/cjs/helperComponents/FilterButton/FilterButton.js +17 -0
  77. package/dist/cjs/helperComponents/FilterButton/index.d.ts +1 -0
  78. package/dist/cjs/helperComponents/FilterButton/index.js +17 -0
  79. package/dist/cjs/helperComponents/FilterButton/styles.module.css +5 -0
  80. package/dist/cjs/helperComponents/MoreActions/MoreActions.d.ts +13 -0
  81. package/dist/cjs/helperComponents/MoreActions/MoreActions.js +35 -0
  82. package/dist/cjs/helperComponents/MoreActions/index.d.ts +1 -0
  83. package/dist/cjs/helperComponents/MoreActions/index.js +17 -0
  84. package/dist/cjs/helperComponents/MoreActions/styles.module.css +5 -0
  85. package/dist/cjs/helperComponents/Search/ToolbarSearch.d.ts +9 -0
  86. package/dist/cjs/helperComponents/Search/ToolbarSearch.js +19 -0
  87. package/dist/cjs/helperComponents/Search/index.d.ts +1 -0
  88. package/dist/cjs/helperComponents/Search/index.js +17 -0
  89. package/dist/cjs/helperComponents/Search/styles.module.css +25 -0
  90. package/dist/cjs/helperComponents/Separator/Separator.d.ts +1 -0
  91. package/dist/cjs/helperComponents/Separator/Separator.js +11 -0
  92. package/dist/cjs/helperComponents/Separator/index.d.ts +1 -0
  93. package/dist/cjs/helperComponents/Separator/index.js +17 -0
  94. package/dist/cjs/helperComponents/Separator/styles.module.css +14 -0
  95. package/dist/cjs/helperComponents/index.d.ts +6 -0
  96. package/dist/cjs/helperComponents/index.js +22 -0
  97. package/dist/cjs/index.d.ts +5 -0
  98. package/dist/cjs/index.js +24 -0
  99. package/dist/cjs/locale/index.d.ts +55 -0
  100. package/dist/cjs/locale/index.js +32 -0
  101. package/dist/cjs/package.json +3 -0
  102. package/dist/cjs/style.css +437 -0
  103. package/dist/cjs/testIds.d.ts +24 -0
  104. package/dist/cjs/testIds.js +27 -0
  105. package/dist/esm/components/Toolbar/Toolbar.d.ts +3 -0
  106. package/dist/esm/components/Toolbar/Toolbar.js +45 -0
  107. package/dist/esm/components/Toolbar/helpers.d.ts +12 -0
  108. package/dist/esm/components/Toolbar/helpers.js +23 -0
  109. package/dist/esm/components/Toolbar/hooks/index.d.ts +2 -0
  110. package/dist/esm/components/Toolbar/hooks/index.js +2 -0
  111. package/dist/esm/components/Toolbar/hooks/useFilters.d.ts +12 -0
  112. package/dist/esm/components/Toolbar/hooks/useFilters.js +49 -0
  113. package/dist/esm/components/Toolbar/hooks/usePersistState/index.d.ts +1 -0
  114. package/dist/esm/components/Toolbar/hooks/usePersistState/index.js +1 -0
  115. package/dist/esm/components/Toolbar/hooks/usePersistState/usePersistState.d.ts +9 -0
  116. package/dist/esm/components/Toolbar/hooks/usePersistState/usePersistState.js +69 -0
  117. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/index.d.ts +3 -0
  118. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/index.js +3 -0
  119. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/isDateString.d.ts +9 -0
  120. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/isDateString.js +42 -0
  121. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/parser.d.ts +4 -0
  122. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/parser.js +42 -0
  123. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/serializer.d.ts +11 -0
  124. package/dist/esm/components/Toolbar/hooks/usePersistState/utils/serializer.js +37 -0
  125. package/dist/esm/components/Toolbar/index.d.ts +3 -0
  126. package/dist/esm/components/Toolbar/index.js +3 -0
  127. package/dist/esm/components/Toolbar/styles.module.css +297 -0
  128. package/dist/esm/components/Toolbar/types.d.ts +80 -0
  129. package/dist/esm/components/Toolbar/types.js +1 -0
  130. package/dist/esm/components/Toolbar/typesUtils.d.ts +12 -0
  131. package/dist/esm/components/Toolbar/typesUtils.js +1 -0
  132. package/dist/esm/components/Toolbar/utils/buildMobileOverflowActions.d.ts +10 -0
  133. package/dist/esm/components/Toolbar/utils/buildMobileOverflowActions.js +81 -0
  134. package/dist/esm/components/Toolbar/utils/toolbarAfterOverflow.d.ts +2 -0
  135. package/dist/esm/components/Toolbar/utils/toolbarAfterOverflow.js +2 -0
  136. package/dist/esm/components/index.d.ts +4 -0
  137. package/dist/esm/components/index.js +3 -0
  138. package/dist/esm/helperComponents/BulkActions/BulkActions.d.ts +2 -0
  139. package/dist/esm/helperComponents/BulkActions/BulkActions.js +14 -0
  140. package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.d.ts +8 -0
  141. package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.js +14 -0
  142. package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/index.d.ts +1 -0
  143. package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/index.js +1 -0
  144. package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/styles.module.css +3 -0
  145. package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.d.ts +17 -0
  146. package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.js +33 -0
  147. package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/index.d.ts +1 -0
  148. package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/index.js +1 -0
  149. package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/styles.module.css +39 -0
  150. package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.d.ts +14 -0
  151. package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.js +24 -0
  152. package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.d.ts +1 -0
  153. package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.js +1 -0
  154. package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.d.ts +9 -0
  155. package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.js +15 -0
  156. package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/index.d.ts +1 -0
  157. package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/index.js +1 -0
  158. package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/styles.module.css +40 -0
  159. package/dist/esm/helperComponents/BulkActions/components/index.d.ts +4 -0
  160. package/dist/esm/helperComponents/BulkActions/components/index.js +4 -0
  161. package/dist/esm/helperComponents/BulkActions/index.d.ts +2 -0
  162. package/dist/esm/helperComponents/BulkActions/index.js +2 -0
  163. package/dist/esm/helperComponents/BulkActions/styles.module.css +9 -0
  164. package/dist/esm/helperComponents/BulkActions/types.d.ts +31 -0
  165. package/dist/esm/helperComponents/BulkActions/types.js +1 -0
  166. package/dist/esm/helperComponents/BulkActions/utils.d.ts +15 -0
  167. package/dist/esm/helperComponents/BulkActions/utils.js +21 -0
  168. package/dist/esm/helperComponents/DataView/DataView.d.ts +2 -0
  169. package/dist/esm/helperComponents/DataView/DataView.js +6 -0
  170. package/dist/esm/helperComponents/DataView/constants.d.ts +9 -0
  171. package/dist/esm/helperComponents/DataView/constants.js +10 -0
  172. package/dist/esm/helperComponents/DataView/index.d.ts +3 -0
  173. package/dist/esm/helperComponents/DataView/index.js +3 -0
  174. package/dist/esm/helperComponents/DataView/types.d.ts +12 -0
  175. package/dist/esm/helperComponents/DataView/types.js +1 -0
  176. package/dist/esm/helperComponents/FilterButton/FilterButton.d.ts +12 -0
  177. package/dist/esm/helperComponents/FilterButton/FilterButton.js +11 -0
  178. package/dist/esm/helperComponents/FilterButton/index.d.ts +1 -0
  179. package/dist/esm/helperComponents/FilterButton/index.js +1 -0
  180. package/dist/esm/helperComponents/FilterButton/styles.module.css +5 -0
  181. package/dist/esm/helperComponents/MoreActions/MoreActions.d.ts +13 -0
  182. package/dist/esm/helperComponents/MoreActions/MoreActions.js +29 -0
  183. package/dist/esm/helperComponents/MoreActions/index.d.ts +1 -0
  184. package/dist/esm/helperComponents/MoreActions/index.js +1 -0
  185. package/dist/esm/helperComponents/MoreActions/styles.module.css +5 -0
  186. package/dist/esm/helperComponents/Search/ToolbarSearch.d.ts +9 -0
  187. package/dist/esm/helperComponents/Search/ToolbarSearch.js +13 -0
  188. package/dist/esm/helperComponents/Search/index.d.ts +1 -0
  189. package/dist/esm/helperComponents/Search/index.js +1 -0
  190. package/dist/esm/helperComponents/Search/styles.module.css +25 -0
  191. package/dist/esm/helperComponents/Separator/Separator.d.ts +1 -0
  192. package/dist/esm/helperComponents/Separator/Separator.js +5 -0
  193. package/dist/esm/helperComponents/Separator/index.d.ts +1 -0
  194. package/dist/esm/helperComponents/Separator/index.js +1 -0
  195. package/dist/esm/helperComponents/Separator/styles.module.css +14 -0
  196. package/dist/esm/helperComponents/index.d.ts +6 -0
  197. package/dist/esm/helperComponents/index.js +6 -0
  198. package/dist/esm/index.d.ts +5 -0
  199. package/dist/esm/index.js +5 -0
  200. package/dist/esm/locale/index.d.ts +55 -0
  201. package/dist/esm/locale/index.js +29 -0
  202. package/dist/esm/style.css +437 -0
  203. package/dist/esm/testIds.d.ts +24 -0
  204. package/dist/esm/testIds.js +24 -0
  205. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  206. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  207. package/package.json +65 -0
  208. package/src/components/Toolbar/Toolbar.tsx +145 -0
  209. package/src/components/Toolbar/helpers.ts +39 -0
  210. package/src/components/Toolbar/hooks/index.ts +2 -0
  211. package/src/components/Toolbar/hooks/useFilters.ts +87 -0
  212. package/src/components/Toolbar/hooks/usePersistState/index.ts +1 -0
  213. package/src/components/Toolbar/hooks/usePersistState/usePersistState.ts +107 -0
  214. package/src/components/Toolbar/hooks/usePersistState/utils/index.ts +3 -0
  215. package/src/components/Toolbar/hooks/usePersistState/utils/isDateString.ts +49 -0
  216. package/src/components/Toolbar/hooks/usePersistState/utils/parser.ts +62 -0
  217. package/src/components/Toolbar/hooks/usePersistState/utils/serializer.ts +51 -0
  218. package/src/components/Toolbar/index.ts +3 -0
  219. package/src/components/Toolbar/styles.module.scss +116 -0
  220. package/src/components/Toolbar/types.ts +99 -0
  221. package/src/components/Toolbar/typesUtils.ts +17 -0
  222. package/src/components/Toolbar/utils/buildMobileOverflowActions.tsx +142 -0
  223. package/src/components/Toolbar/utils/toolbarAfterOverflow.ts +2 -0
  224. package/src/components/index.ts +4 -0
  225. package/src/helperComponents/BulkActions/BulkActions.tsx +54 -0
  226. package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.tsx +35 -0
  227. package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/index.ts +1 -0
  228. package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/styles.module.scss +3 -0
  229. package/src/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.tsx +135 -0
  230. package/src/helperComponents/BulkActions/components/BulkActionsControls/index.ts +1 -0
  231. package/src/helperComponents/BulkActions/components/BulkActionsControls/styles.module.scss +49 -0
  232. package/src/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.tsx +88 -0
  233. package/src/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.ts +1 -0
  234. package/src/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.tsx +40 -0
  235. package/src/helperComponents/BulkActions/components/SelectionLabel/index.ts +1 -0
  236. package/src/helperComponents/BulkActions/components/SelectionLabel/styles.module.scss +38 -0
  237. package/src/helperComponents/BulkActions/components/index.ts +4 -0
  238. package/src/helperComponents/BulkActions/index.ts +2 -0
  239. package/src/helperComponents/BulkActions/styles.module.scss +13 -0
  240. package/src/helperComponents/BulkActions/types.ts +32 -0
  241. package/src/helperComponents/BulkActions/utils.tsx +32 -0
  242. package/src/helperComponents/DataView/DataView.tsx +22 -0
  243. package/src/helperComponents/DataView/constants.tsx +15 -0
  244. package/src/helperComponents/DataView/index.ts +3 -0
  245. package/src/helperComponents/DataView/types.ts +15 -0
  246. package/src/helperComponents/FilterButton/FilterButton.tsx +40 -0
  247. package/src/helperComponents/FilterButton/index.ts +1 -0
  248. package/src/helperComponents/FilterButton/styles.module.scss +5 -0
  249. package/src/helperComponents/MoreActions/MoreActions.tsx +69 -0
  250. package/src/helperComponents/MoreActions/index.ts +1 -0
  251. package/src/helperComponents/MoreActions/styles.module.scss +5 -0
  252. package/src/helperComponents/Search/ToolbarSearch.tsx +48 -0
  253. package/src/helperComponents/Search/index.ts +1 -0
  254. package/src/helperComponents/Search/styles.module.scss +35 -0
  255. package/src/helperComponents/Separator/Separator.tsx +9 -0
  256. package/src/helperComponents/Separator/index.ts +1 -0
  257. package/src/helperComponents/Separator/styles.module.scss +18 -0
  258. package/src/helperComponents/index.ts +6 -0
  259. package/src/index.ts +5 -0
  260. package/src/locale/index.ts +33 -0
  261. package/src/testIds.ts +24 -0
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@cloud-ru/ds-toolbar",
3
+ "version": "1.0.0",
4
+ "description": "Панель инструментов списков и таблиц — поиск, фильтры, массовые действия, меню «Ещё».",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/cloud-ru-tech/snack-v2.git",
8
+ "directory": "packages/toolbar"
9
+ },
10
+ "homepage": "https://github.com/cloud-ru-tech/snack-v2/tree/master/packages/toolbar",
11
+ "license": "Apache-2.0",
12
+ "author": "Anna Kozlova <apkozlova@cloud.ru>",
13
+ "type": "module",
14
+ "main": "./dist/cjs/index.js",
15
+ "module": "./dist/esm/index.js",
16
+ "types": "./dist/esm/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "source": "./src/index.ts",
20
+ "types": "./dist/esm/index.d.ts",
21
+ "import": "./dist/esm/index.js",
22
+ "require": "./dist/cjs/index.js"
23
+ },
24
+ "./locale": {
25
+ "source": "./src/locale/index.ts",
26
+ "types": "./dist/esm/locale/index.d.ts",
27
+ "import": "./dist/esm/locale/index.js",
28
+ "require": "./dist/cjs/locale/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "src",
34
+ "./CHANGELOG.md",
35
+ "./LICENSE"
36
+ ],
37
+ "sideEffects": [
38
+ "*.css",
39
+ "**/*.css"
40
+ ],
41
+ "dependencies": {
42
+ "@cloud-ru/ft-request-payload-transform": "^0.3.0",
43
+ "classnames": "^2.5.1",
44
+ "@cloud-ru/ds-button": "^1.0.0",
45
+ "@cloud-ru/ds-bottom-sheet": "^1.0.0",
46
+ "@cloud-ru/ds-adaptive": "^1.0.0",
47
+ "@cloud-ru/ds-locale": "^1.0.0",
48
+ "@cloud-ru/ds-icons": "^1.0.0",
49
+ "@cloud-ru/ds-list": "^1.0.0",
50
+ "@cloud-ru/ds-materials": "^1.0.0",
51
+ "@cloud-ru/ds-portal-context": "^1.0.0",
52
+ "@cloud-ru/ds-scroll": "^1.0.0",
53
+ "@cloud-ru/ds-chips": "^1.0.0",
54
+ "@cloud-ru/ds-theme": "^1.0.0",
55
+ "@cloud-ru/ds-search": "^1.0.0",
56
+ "@cloud-ru/ds-segment-control": "^1.0.0",
57
+ "@cloud-ru/ds-tag": "^1.0.0",
58
+ "@cloud-ru/ds-toggles": "^1.0.0",
59
+ "@cloud-ru/ds-tooltip": "^1.0.0",
60
+ "@cloud-ru/ds-utils": "^1.0.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }
@@ -0,0 +1,145 @@
1
+ import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
2
+ import { Button } from '@cloud-ru/ds-button';
3
+ import { ChipChoiceRow, FiltersState } from '@cloud-ru/ds-chips';
4
+ import { UpdateSVG } from '@cloud-ru/ds-icons/interface/system';
5
+ import { useThemeClassnames } from '@cloud-ru/ds-theme';
6
+ import { extractSupportProps } from '@cloud-ru/ds-utils';
7
+ import cn from 'classnames';
8
+ import { useMemo, useRef } from 'react';
9
+
10
+ import { BulkActions, DataView, FilterButton, MoreActions, Search, Separator } from '../../helperComponents';
11
+ import { toolbarLocale } from '../../locale';
12
+ import { TEST_IDS } from '../../testIds';
13
+ import { extractBulkActionsProps, isBulkActionsProps } from './helpers';
14
+ import { useFilters, usePersistState } from './hooks';
15
+ import styles from './styles.module.scss';
16
+ import { ToolbarProps } from './types';
17
+ import { buildMobileOverflowActions } from './utils/buildMobileOverflowActions';
18
+
19
+ export function Toolbar<TState extends FiltersState = Record<string, unknown>>({
20
+ className,
21
+ after,
22
+ dataView,
23
+ outline = true,
24
+ moreActions,
25
+ onRefresh,
26
+ search,
27
+ filterRow: filterRowProps,
28
+ persist,
29
+ ...rest
30
+ }: ToolbarProps<TState>) {
31
+ const { layoutType } = useAdaptiveLayout();
32
+ const { t } = toolbarLocale.useTranslations();
33
+ const supportProps = extractSupportProps(rest);
34
+ const needsBulkActions = isBulkActionsProps(rest);
35
+ const isMobile = isMobileLayout(layoutType);
36
+ const containerWrapperRef = useRef<HTMLDivElement>(null);
37
+
38
+ const { filterButton, filterRow } = useFilters<TState>({ filterRow: filterRowProps });
39
+
40
+ usePersistState({ persist, filter: filterRow?.value, search: search?.value });
41
+
42
+ const mobileOverflowActions = useMemo(
43
+ () =>
44
+ isMobile
45
+ ? buildMobileOverflowActions({
46
+ onRefresh,
47
+ after,
48
+ moreActions,
49
+ refreshLabel: t('refresh'),
50
+ })
51
+ : undefined,
52
+ [isMobile, onRefresh, after, moreActions, t],
53
+ );
54
+
55
+ const effectiveMoreActions = isMobile ? mobileOverflowActions : moreActions;
56
+ const showMoreActionsMenu = Boolean(effectiveMoreActions?.length);
57
+ const showRefreshButton = Boolean(onRefresh) && !isMobile;
58
+ const showAfterSlot = Boolean(after) && !isMobile;
59
+ const hasLeftSideElements = showRefreshButton;
60
+ const showDataView = Boolean(dataView?.show);
61
+ const hasRightSideElements = Boolean(showAfterSlot || showDataView || showMoreActionsMenu || filterRowProps);
62
+
63
+ const showSeparatorAfterExtra = Boolean(showAfterSlot && (showDataView || filterButton || showMoreActionsMenu));
64
+
65
+ // Фиксируем density, остальные оси (colorScheme/brand/…) наследуем из контекста темы.
66
+ const themeClassName = useThemeClassnames({ density: isMobile ? 'comfort' : 'compact' });
67
+
68
+ return (
69
+ <div
70
+ className={cn(themeClassName, styles.containerWrapper)}
71
+ ref={containerWrapperRef}
72
+ {...supportProps}
73
+ data-test-id={supportProps['data-test-id'] ?? TEST_IDS.main}
74
+ >
75
+ <div className={cn(styles.container, className)} data-acrylic-appearance='neutral' data-acrylic-level='1Level'>
76
+ <div className={styles.acrylic} aria-hidden />
77
+
78
+ {outline && <div className={styles.border} aria-hidden />}
79
+
80
+ <div className={styles.content}>
81
+ {hasLeftSideElements && (
82
+ <div className={styles.beforeSearch}>
83
+ <Button
84
+ view='function'
85
+ appearance='neutral'
86
+ icon={<UpdateSVG />}
87
+ size='m'
88
+ className={styles.updateButton}
89
+ onClick={onRefresh}
90
+ data-test-id={TEST_IDS.refreshButton}
91
+ />
92
+ </div>
93
+ )}
94
+
95
+ {hasLeftSideElements && <Separator />}
96
+
97
+ <div className={styles.searchWrapper}>{search && <Search {...search} />}</div>
98
+
99
+ {hasRightSideElements && (
100
+ <>
101
+ <Separator />
102
+
103
+ {showAfterSlot && (
104
+ <div data-test-id={TEST_IDS.after} className={styles.slot}>
105
+ {after}
106
+ </div>
107
+ )}
108
+
109
+ {showSeparatorAfterExtra && <Separator />}
110
+
111
+ {showDataView && dataView && (
112
+ <div data-test-id={TEST_IDS.dataView} className={styles.slot}>
113
+ <DataView
114
+ value={dataView.value}
115
+ defaultValue={dataView.defaultValue}
116
+ onChange={dataView.onChange}
117
+ items={dataView.items}
118
+ />
119
+ </div>
120
+ )}
121
+
122
+ {filterButton && (
123
+ <div className={styles.slot}>
124
+ <FilterButton {...filterButton} />
125
+ </div>
126
+ )}
127
+
128
+ {showMoreActionsMenu && effectiveMoreActions && (
129
+ <div className={styles.slot}>
130
+ <MoreActions moreActions={effectiveMoreActions} />
131
+ </div>
132
+ )}
133
+ </>
134
+ )}
135
+ </div>
136
+ </div>
137
+
138
+ {filterRow && <ChipChoiceRow<TState> {...filterRow} size='s' data-test-id={TEST_IDS.filterRow} />}
139
+
140
+ {needsBulkActions && (
141
+ <BulkActions {...extractBulkActionsProps(rest)} resizingContainerRef={containerWrapperRef} />
142
+ )}
143
+ </div>
144
+ );
145
+ }
@@ -0,0 +1,39 @@
1
+ import { FiltersState } from '@cloud-ru/ds-chips';
2
+
3
+ import { ToolbarBulkActionProps, ToolbarProps } from './types';
4
+
5
+ export function extractBulkActionsProps({
6
+ onCheck,
7
+ checked,
8
+ indeterminate,
9
+ bulkActions = [],
10
+ selectedCount,
11
+ totalCount,
12
+ showBulkCheckbox,
13
+ }: ToolbarBulkActionProps) {
14
+ return {
15
+ onCheck,
16
+ checked,
17
+ indeterminate,
18
+ actions: bulkActions,
19
+ selectedCount,
20
+ totalCount,
21
+ showBulkCheckbox,
22
+ };
23
+ }
24
+
25
+ const BULK_TOOLBAR_PROP_KEYS = [
26
+ 'bulkActions',
27
+ 'onCheck',
28
+ 'checked',
29
+ 'indeterminate',
30
+ 'selectedCount',
31
+ 'totalCount',
32
+ 'showBulkCheckbox',
33
+ ] as const satisfies readonly (keyof ToolbarBulkActionProps)[];
34
+
35
+ export function isBulkActionsProps<TState extends FiltersState>(
36
+ props: Partial<ToolbarProps<TState>>,
37
+ ): props is ToolbarBulkActionProps {
38
+ return BULK_TOOLBAR_PROP_KEYS.some(key => props[key] !== undefined);
39
+ }
@@ -0,0 +1,2 @@
1
+ export * from './usePersistState';
2
+ export * from './useFilters';
@@ -0,0 +1,87 @@
1
+ import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
2
+ import { FiltersState, hasFilterBeenApplied } from '@cloud-ru/ds-chips';
3
+ import { useUncontrolledProp } from '@cloud-ru/ds-utils';
4
+ import cn from 'classnames';
5
+ import { useMemo } from 'react';
6
+
7
+ import { FilterButtonProps } from '../../../helperComponents';
8
+ import styles from '../styles.module.scss';
9
+ import { FilterRow } from '../types';
10
+
11
+ type UseFiltersProps<TState extends FiltersState> = {
12
+ filterRow?: FilterRow<TState>;
13
+ };
14
+
15
+ type UseFiltersReturnType<TState extends FiltersState> = {
16
+ filterButton?: FilterButtonProps;
17
+ filterRow?: FilterRow<TState>;
18
+ };
19
+
20
+ export function useFilters<TState extends FiltersState>({
21
+ filterRow,
22
+ }: UseFiltersProps<TState>): UseFiltersReturnType<TState> {
23
+ const { layoutType } = useAdaptiveLayout();
24
+ const isMobile = isMobileLayout(layoutType);
25
+ const defaultOpen = isMobile ? (filterRow?.initialOpen ?? false) : false;
26
+
27
+ const [filtersOpen, setFiltersOpen] = useUncontrolledProp<boolean>(filterRow?.open, defaultOpen, newValue => {
28
+ const result = typeof newValue === 'function' ? newValue(filtersOpen) : newValue;
29
+ filterRow?.onOpenChange?.(result);
30
+ });
31
+
32
+ const [value, setValue] = useUncontrolledProp<TState>(
33
+ filterRow?.value,
34
+ (filterRow?.defaultValue ?? {}) as TState,
35
+ newValue => {
36
+ const result = typeof newValue === 'function' ? newValue(value) : newValue;
37
+ filterRow?.onChange?.(result);
38
+ },
39
+ );
40
+
41
+ const [visibleFilters, setVisibleFilters] = useUncontrolledProp<string[]>(
42
+ filterRow?.visibleFilters,
43
+ Object.keys(value),
44
+ newState => {
45
+ const result = typeof newState === 'function' ? newState(visibleFilters) : newState;
46
+ filterRow?.onVisibleFiltersChange?.(result);
47
+ },
48
+ );
49
+
50
+ const patchedFilters = useMemo(
51
+ () =>
52
+ (filterRow?.filters ?? []).map(filter => {
53
+ if (!isMobile && ['single', 'multiple'].includes(filter.type)) {
54
+ return {
55
+ ...filter,
56
+ dropDownClassName: cn(filter.dropDownClassName, styles.list),
57
+ };
58
+ }
59
+
60
+ return filter;
61
+ }),
62
+ [filterRow?.filters, isMobile],
63
+ );
64
+
65
+ const numberOfFilters = useMemo(
66
+ () => Object.keys(value).reduce((result, filterKey) => result + Number(hasFilterBeenApplied(value[filterKey])), 0),
67
+ [value],
68
+ );
69
+
70
+ return {
71
+ filterButton: filterRow ? { open: filtersOpen, onOpenChange: setFiltersOpen, numberOfFilters } : undefined,
72
+ filterRow:
73
+ filtersOpen && filterRow
74
+ ? {
75
+ ...filterRow,
76
+ open: undefined,
77
+ onOpenChange: undefined,
78
+ initialOpen: undefined,
79
+ filters: patchedFilters,
80
+ value,
81
+ onChange: setValue,
82
+ visibleFilters,
83
+ onVisibleFiltersChange: setVisibleFilters,
84
+ }
85
+ : undefined,
86
+ };
87
+ }
@@ -0,0 +1 @@
1
+ export * from './usePersistState';
@@ -0,0 +1,107 @@
1
+ import { FiltersState } from '@cloud-ru/ds-chips';
2
+ import { DataPersistOptions, useDataPersist } from '@cloud-ru/ds-utils';
3
+ import { MutableRefObject, useEffect, useMemo, useRef } from 'react';
4
+
5
+ import { PersistedFilterState, ToolbarPersistConfig } from '../../types';
6
+ import { defaultParser, defaultSerializer, prepareDataForFilter } from './utils';
7
+
8
+ type UsePersistStateProps<TState extends FiltersState = Record<string, unknown>> = {
9
+ persist?: ToolbarPersistConfig<TState>;
10
+ filter?: TState;
11
+ search?: string;
12
+ };
13
+
14
+ type RunPersistStateHydrationOnceParams<TState extends FiltersState> = {
15
+ hasHydratedRef: MutableRefObject<boolean>;
16
+ defaultState: PersistedFilterState<TState> | undefined;
17
+ onLoad?: ToolbarPersistConfig<TState>['onLoad'];
18
+ };
19
+
20
+ function runPersistStateHydrationOnce<TState extends FiltersState>({
21
+ hasHydratedRef,
22
+ defaultState,
23
+ onLoad,
24
+ }: RunPersistStateHydrationOnceParams<TState>) {
25
+ if (hasHydratedRef.current) {
26
+ return;
27
+ }
28
+
29
+ if (defaultState) {
30
+ onLoad?.({
31
+ ...defaultState,
32
+ filter: prepareDataForFilter(defaultState.filter ?? {}),
33
+ });
34
+ }
35
+
36
+ hasHydratedRef.current = true;
37
+ }
38
+
39
+ export function usePersistState<TState extends FiltersState = Record<string, unknown>>({
40
+ persist,
41
+ filter,
42
+ search,
43
+ }: UsePersistStateProps<TState>) {
44
+ const hasHydratedRef = useRef(false);
45
+ const skipInitialPersistRef = useRef(true);
46
+ const onLoadRef = useRef(persist?.onLoad);
47
+
48
+ onLoadRef.current = persist?.onLoad;
49
+
50
+ const dataPersistOptions = useMemo<DataPersistOptions<PersistedFilterState<TState>> | undefined>(() => {
51
+ if (!persist?.filterQueryKey || !persist?.id) return undefined;
52
+
53
+ const defaultValidate = (value: PersistedFilterState<TState>): boolean => {
54
+ const filterOk = value?.filter === undefined || (typeof value.filter === 'object' && value.filter !== null);
55
+ const searchOk = value?.search === undefined || typeof value.search === 'string';
56
+ return Boolean(filterOk && searchOk);
57
+ };
58
+
59
+ const combinedValidate = (value: PersistedFilterState<TState>): boolean => {
60
+ const baseValid = defaultValidate(value);
61
+ return persist?.validateData ? baseValid && persist.validateData(value) : baseValid;
62
+ };
63
+
64
+ return {
65
+ queryKey: persist.filterQueryKey,
66
+ localStorageKey: `${persist.id}_filter`,
67
+ validateData: combinedValidate as unknown as (value: unknown) => value is PersistedFilterState<TState>,
68
+ };
69
+ }, [persist]);
70
+
71
+ const { getDefaultData, setDataToStorages } = useDataPersist<PersistedFilterState<TState>>({
72
+ options: dataPersistOptions,
73
+ serializer: value => (persist?.serializer ? persist.serializer(value) : defaultSerializer<TState>(value)),
74
+ parser: (value: string) => (persist?.parser ? persist.parser(value) : defaultParser<TState>(value)),
75
+ });
76
+
77
+ const defaultState = useMemo(getDefaultData, [getDefaultData]);
78
+
79
+ useEffect(() => {
80
+ runPersistStateHydrationOnce({
81
+ hasHydratedRef,
82
+ defaultState,
83
+ onLoad: onLoadRef.current,
84
+ });
85
+ }, [defaultState]);
86
+
87
+ useEffect(() => {
88
+ if (!persist?.id || !persist?.filterQueryKey || !hasHydratedRef.current) {
89
+ return;
90
+ }
91
+
92
+ if (skipInitialPersistRef.current) {
93
+ skipInitialPersistRef.current = false;
94
+ return;
95
+ }
96
+
97
+ const snapshot: PersistedFilterState<TState> = {
98
+ ...(persist.state ?? getDefaultData() ?? {}),
99
+ ...(filter ? { filter } : {}),
100
+ ...(search !== undefined ? { search } : {}),
101
+ };
102
+
103
+ if (Object.keys(snapshot).length === 0) return;
104
+
105
+ setDataToStorages(snapshot);
106
+ }, [persist?.id, persist?.filterQueryKey, persist?.state, filter, search, setDataToStorages, getDefaultData]);
107
+ }
@@ -0,0 +1,3 @@
1
+ export * from './parser';
2
+ export * from './serializer';
3
+ export * from './isDateString';
@@ -0,0 +1,49 @@
1
+ const DATE_SYMBOLS_REGEXP = /[\d\-:.TZ+\s]/g;
2
+
3
+ /** Утилита для проверки значения на соответствие дате.
4
+ * Поддерживает:
5
+ * - ISO форматы: '2021-01-01T00:00:00Z', '2021-01-01T15:55:42.000Z'
6
+ * - Форматы с точками: '12.03.2025', '12.03.2025 12:00'
7
+ * - Частичные даты: '2026', '2026-01'
8
+ * - Timestamps: '1768492519666', '-62167219200000'
9
+ * - Временные зоны: '+03:00', '-05:00'
10
+ */
11
+ export function isDateString(value: unknown): value is string {
12
+ if (typeof value !== 'string') return false;
13
+
14
+ const trimmed = value.trim();
15
+ if (trimmed.length === 0) return false;
16
+
17
+ const nonDateSymbols = trimmed.replaceAll(DATE_SYMBOLS_REGEXP, '');
18
+ if (nonDateSymbols.length > 0) return false;
19
+
20
+ if (/^-?\d+$/.test(trimmed)) {
21
+ if (trimmed.length <= 2) return false;
22
+
23
+ const num = Number(trimmed);
24
+ const date = new Date(num);
25
+
26
+ if (isNaN(date.getTime())) return false;
27
+
28
+ return date.getTime() === num;
29
+ }
30
+
31
+ if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(trimmed)) {
32
+ return false;
33
+ }
34
+
35
+ const date = new Date(trimmed);
36
+ if (isNaN(date.getTime())) return false;
37
+
38
+ const hasDateLikeStructure =
39
+ /^\d{4}/.test(trimmed) ||
40
+ /^\d{1,2}[.-]\d{1,2}[.-]\d{4}/.test(trimmed) ||
41
+ /^\d{4}[.-]\d{1,2}[.-]\d{1,2}/.test(trimmed) ||
42
+ /T/.test(trimmed);
43
+
44
+ if (!hasDateLikeStructure && !trimmed.includes(':')) {
45
+ return false;
46
+ }
47
+
48
+ return date.toString() !== 'Invalid Date';
49
+ }
@@ -0,0 +1,62 @@
1
+ import { FiltersState } from '@cloud-ru/ds-chips';
2
+
3
+ import { parseQueryParamsString, RequestPayloadParams } from '@cloud-ru/ft-request-payload-transform';
4
+
5
+ import { PersistedFilterState } from '../../../types';
6
+ import { isDateString } from './isDateString';
7
+
8
+ function parseValue(value: unknown) {
9
+ if (isDateString(value)) {
10
+ return new Date(value);
11
+ }
12
+
13
+ if (typeof value === 'boolean') {
14
+ return String(value);
15
+ }
16
+
17
+ return value;
18
+ }
19
+
20
+ function mapFilterFromPayload<TFilters extends FiltersState = Record<string, unknown>>(
21
+ value?: RequestPayloadParams['filter'],
22
+ ): TFilters | undefined {
23
+ if (!value) {
24
+ return undefined;
25
+ }
26
+
27
+ return Object.fromEntries(
28
+ value.map(filter => {
29
+ if (Array.isArray(filter.value)) {
30
+ return [filter.field, filter.value.map(parseValue)];
31
+ }
32
+
33
+ return [filter.field, parseValue(filter.value)];
34
+ }),
35
+ ) as TFilters;
36
+ }
37
+
38
+ export function defaultParser<T extends FiltersState>(value: string): PersistedFilterState<T> {
39
+ const parsed = parseQueryParamsString(value);
40
+
41
+ return {
42
+ pagination: parsed?.pagination,
43
+ ordering: parsed?.ordering,
44
+ search: parsed?.search?.toString() || '',
45
+ filter: mapFilterFromPayload<T>(parsed?.filter) ?? ({} as T),
46
+ };
47
+ }
48
+
49
+ export function prepareDataForFilter<T>(filter: Record<string, unknown>): T {
50
+ return Object.entries(filter).reduce(
51
+ (acc, [key, value]) => {
52
+ if (Array.isArray(value)) {
53
+ acc[key] = value.map(parseValue);
54
+ } else {
55
+ acc[key] = parseValue(value);
56
+ }
57
+
58
+ return acc;
59
+ },
60
+ { ...filter },
61
+ ) as T;
62
+ }
@@ -0,0 +1,51 @@
1
+ import { FiltersState } from '@cloud-ru/ds-chips';
2
+
3
+ import { createRequestPayload, RequestPayloadParams } from '@cloud-ru/ft-request-payload-transform';
4
+
5
+ import { PersistedFilterState } from '../../../types';
6
+
7
+ type FilterValue = string | null | number | boolean | Date;
8
+
9
+ function mapValueToString(filter: FilterValue): string | null | number | boolean {
10
+ if (filter instanceof Date) {
11
+ return filter.toISOString();
12
+ }
13
+
14
+ return filter;
15
+ }
16
+
17
+ function mapFilterToPayload(value?: FiltersState): RequestPayloadParams['filter'] {
18
+ if (!value) {
19
+ return undefined;
20
+ }
21
+
22
+ return Object.entries(value)
23
+ .filter(([, v]) => v !== undefined)
24
+ .map(([key, v]) =>
25
+ Array.isArray(v)
26
+ ? {
27
+ value: (v as FilterValue[]).map(mapValueToString),
28
+ condition: 'in',
29
+ field: key,
30
+ }
31
+ : {
32
+ value: mapValueToString(v as FilterValue),
33
+ condition: 'eq',
34
+ field: key,
35
+ },
36
+ );
37
+ }
38
+
39
+ /** Вспомогательная функция для преобразования состояния тулбара к формату RequestPayloadParams */
40
+ export function formatFilterStateToRequestPayload<T extends FiltersState>(value?: PersistedFilterState<T> | null) {
41
+ return createRequestPayload({
42
+ pagination: value?.pagination,
43
+ search: value?.search ?? '',
44
+ ordering: value?.ordering,
45
+ filter: mapFilterToPayload(value?.filter),
46
+ });
47
+ }
48
+
49
+ export function defaultSerializer<T extends FiltersState>(value: PersistedFilterState<T>) {
50
+ return formatFilterStateToRequestPayload(value).toString();
51
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Toolbar';
2
+ export * from './types';
3
+ export * from './hooks';