polpo 0.1.6 → 0.1.8

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 (366) hide show
  1. package/dist/components.cjs +31 -0
  2. package/dist/components.cjs.map +1 -0
  3. package/dist/components.d.cts +1866 -0
  4. package/dist/components.d.ts +1866 -0
  5. package/dist/components.js +31 -0
  6. package/dist/components.js.map +1 -0
  7. package/dist/{get-modal-position-drle0OjP.d.cts → get-modal-position-C5jQsaGx.d.cts} +1 -1
  8. package/dist/{get-modal-position-drle0OjP.d.ts → get-modal-position-C5jQsaGx.d.ts} +1 -1
  9. package/dist/helpers.cjs +1 -1
  10. package/dist/helpers.cjs.map +1 -1
  11. package/dist/helpers.d.cts +2 -2
  12. package/dist/helpers.d.ts +2 -2
  13. package/dist/helpers.js +1 -1
  14. package/dist/helpers.js.map +1 -1
  15. package/dist/hooks.cjs +1 -1
  16. package/dist/hooks.cjs.map +1 -1
  17. package/dist/hooks.d.cts +15 -13
  18. package/dist/hooks.d.ts +15 -13
  19. package/dist/hooks.js +1 -1
  20. package/dist/hooks.js.map +1 -1
  21. package/dist/layouts.cjs +4 -0
  22. package/dist/layouts.cjs.map +1 -0
  23. package/dist/{ui.d.cts → layouts.d.cts} +237 -2133
  24. package/dist/{ui.d.ts → layouts.d.ts} +237 -2133
  25. package/dist/layouts.js +4 -0
  26. package/dist/layouts.js.map +1 -0
  27. package/dist/types.cjs +3 -0
  28. package/dist/types.cjs.map +1 -0
  29. package/dist/types.d.cts +8 -0
  30. package/dist/types.d.ts +8 -0
  31. package/dist/types.js +2 -0
  32. package/dist/types.js.map +1 -0
  33. package/dist/use-modal-transition-C0lyjvkD.d.ts +29 -0
  34. package/dist/use-modal-transition-C7DzbnY5.d.cts +29 -0
  35. package/package.json +76 -76
  36. package/.eslintrc.cjs +0 -9
  37. package/.storybook/decorators.tsx +0 -61
  38. package/.storybook/main.ts +0 -47
  39. package/.storybook/manager-head.html +0 -2
  40. package/.storybook/manager.ts +0 -7
  41. package/.storybook/preview-head.html +0 -2
  42. package/.storybook/preview.ts +0 -38
  43. package/.storybook/theme.ts +0 -47
  44. package/.turbo/turbo-lint.log +0 -4
  45. package/README.md +0 -65
  46. package/dist/chunk-LJM5NQBY.js +0 -3
  47. package/dist/chunk-LJM5NQBY.js.map +0 -1
  48. package/dist/chunk-MAWW6AA7.js +0 -3
  49. package/dist/chunk-MAWW6AA7.js.map +0 -1
  50. package/dist/ui.cjs +0 -2197
  51. package/dist/ui.cjs.map +0 -1
  52. package/dist/ui.js +0 -2197
  53. package/dist/ui.js.map +0 -1
  54. package/dist/use-modal-transition-C6mR_NZh.d.cts +0 -32
  55. package/dist/use-modal-transition-DBAyFSqW.d.ts +0 -32
  56. package/src/components/accordion/accordion-item.stories.tsx +0 -128
  57. package/src/components/accordion/accordion-item.tsx +0 -119
  58. package/src/components/accordion/accordion.stories.tsx +0 -74
  59. package/src/components/accordion/accordion.style.ts +0 -42
  60. package/src/components/accordion/accordion.tsx +0 -56
  61. package/src/components/accordion/index.ts +0 -2
  62. package/src/components/buttons/button/button.stories.tsx +0 -103
  63. package/src/components/buttons/button/button.style.ts +0 -152
  64. package/src/components/buttons/button/button.tsx +0 -107
  65. package/src/components/buttons/button/index.ts +0 -1
  66. package/src/components/buttons/index.ts +0 -1
  67. package/src/components/cards/flip-card/flip-card.stories.tsx +0 -61
  68. package/src/components/cards/flip-card/flip-card.style.ts +0 -45
  69. package/src/components/cards/flip-card/flip-card.tsx +0 -55
  70. package/src/components/cards/flip-card/index.ts +0 -1
  71. package/src/components/cards/hover-card/hover-card.stories.tsx +0 -45
  72. package/src/components/cards/hover-card/hover-card.style.ts +0 -13
  73. package/src/components/cards/hover-card/hover-card.tsx +0 -71
  74. package/src/components/cards/hover-card/index.ts +0 -1
  75. package/src/components/cards/index.ts +0 -3
  76. package/src/components/cards/slide-card/index.ts +0 -1
  77. package/src/components/cards/slide-card/slide-card.stories.tsx +0 -47
  78. package/src/components/cards/slide-card/slide-card.tsx +0 -42
  79. package/src/components/cursor/cursor.stories.tsx +0 -36
  80. package/src/components/cursor/cursor.style.ts +0 -73
  81. package/src/components/cursor/cursor.tsx +0 -49
  82. package/src/components/cursor/index.ts +0 -1
  83. package/src/components/form/checkbox/checkbox.stories.tsx +0 -84
  84. package/src/components/form/checkbox/checkbox.style.ts +0 -109
  85. package/src/components/form/checkbox/checkbox.tsx +0 -110
  86. package/src/components/form/checkbox/index.ts +0 -1
  87. package/src/components/form/controller/controller.tsx +0 -42
  88. package/src/components/form/controller/index.ts +0 -1
  89. package/src/components/form/date-picker/date-picker.stories.tsx +0 -38
  90. package/src/components/form/date-picker/date-picker.tsx +0 -67
  91. package/src/components/form/date-picker/index.ts +0 -1
  92. package/src/components/form/field/field.stories.tsx +0 -52
  93. package/src/components/form/field/field.style.ts +0 -91
  94. package/src/components/form/field/field.tsx +0 -85
  95. package/src/components/form/field/field.types.ts +0 -34
  96. package/src/components/form/field/index.ts +0 -2
  97. package/src/components/form/form.stories.types.tsx +0 -50
  98. package/src/components/form/form.types.ts +0 -37
  99. package/src/components/form/index.ts +0 -14
  100. package/src/components/form/input/index.ts +0 -1
  101. package/src/components/form/input/input.stories.tsx +0 -41
  102. package/src/components/form/input/input.tsx +0 -73
  103. package/src/components/form/input-color/index.ts +0 -1
  104. package/src/components/form/input-color/input-color.stories.tsx +0 -46
  105. package/src/components/form/input-color/input-color.style.ts +0 -94
  106. package/src/components/form/input-color/input-color.tsx +0 -162
  107. package/src/components/form/input-file/index.ts +0 -1
  108. package/src/components/form/input-file/input-file.stories.tsx +0 -40
  109. package/src/components/form/input-file/input-file.style.ts +0 -143
  110. package/src/components/form/input-file/input-file.tsx +0 -214
  111. package/src/components/form/input-password/index.ts +0 -1
  112. package/src/components/form/input-password/input-password.stories.tsx +0 -37
  113. package/src/components/form/input-password/input-password.tsx +0 -83
  114. package/src/components/form/radio/index.ts +0 -1
  115. package/src/components/form/radio/radio.stories.tsx +0 -67
  116. package/src/components/form/radio/radio.style.ts +0 -79
  117. package/src/components/form/radio/radio.tsx +0 -95
  118. package/src/components/form/select/index.ts +0 -1
  119. package/src/components/form/select/options.tsx +0 -203
  120. package/src/components/form/select/select.stories.tsx +0 -150
  121. package/src/components/form/select/select.style.ts +0 -82
  122. package/src/components/form/select/select.tsx +0 -304
  123. package/src/components/form/select/select.types.ts +0 -76
  124. package/src/components/form/slider/index.ts +0 -1
  125. package/src/components/form/slider/slider.stories.tsx +0 -40
  126. package/src/components/form/slider/slider.style.ts +0 -92
  127. package/src/components/form/slider/slider.tsx +0 -108
  128. package/src/components/form/switch/index.ts +0 -1
  129. package/src/components/form/switch/switch.stories.tsx +0 -38
  130. package/src/components/form/switch/switch.style.ts +0 -120
  131. package/src/components/form/switch/switch.tsx +0 -111
  132. package/src/components/form/textarea/index.ts +0 -1
  133. package/src/components/form/textarea/textarea.stories.tsx +0 -43
  134. package/src/components/form/textarea/textarea.style.ts +0 -7
  135. package/src/components/form/textarea/textarea.tsx +0 -76
  136. package/src/components/icon/icon.stories.tsx +0 -63
  137. package/src/components/icon/icon.tsx +0 -64
  138. package/src/components/icon/icons/index.ts +0 -18
  139. package/src/components/icon/icons/object.tsx +0 -482
  140. package/src/components/icon/icons/social.tsx +0 -88
  141. package/src/components/icon/icons/symbol.tsx +0 -776
  142. package/src/components/icon/index.ts +0 -5
  143. package/src/components/image/image.stories.tsx +0 -25
  144. package/src/components/image/image.tsx +0 -7
  145. package/src/components/image/index.ts +0 -1
  146. package/src/components/index.ts +0 -17
  147. package/src/components/infinity-scroll/index.ts +0 -1
  148. package/src/components/infinity-scroll/infinity-scroll.stories.tsx +0 -75
  149. package/src/components/infinity-scroll/infinity-scroll.style.ts +0 -30
  150. package/src/components/infinity-scroll/infinity-scroll.tsx +0 -56
  151. package/src/components/line/index.ts +0 -1
  152. package/src/components/line/line.stories.tsx +0 -66
  153. package/src/components/line/line.style.ts +0 -57
  154. package/src/components/line/line.tsx +0 -76
  155. package/src/components/loaders/index.ts +0 -1
  156. package/src/components/loaders/simple-loader/index.ts +0 -1
  157. package/src/components/loaders/simple-loader/simple-loader.stories.tsx +0 -21
  158. package/src/components/loaders/simple-loader/simple-loader.style.ts +0 -13
  159. package/src/components/loaders/simple-loader/simple-loader.tsx +0 -15
  160. package/src/components/modals/action-modal/action-modal.stories.tsx +0 -157
  161. package/src/components/modals/action-modal/action-modal.style.ts +0 -117
  162. package/src/components/modals/action-modal/action-modal.tsx +0 -148
  163. package/src/components/modals/action-modal/index.ts +0 -1
  164. package/src/components/modals/aside-modal/aside-modal.stories.tsx +0 -81
  165. package/src/components/modals/aside-modal/aside-modal.style.ts +0 -88
  166. package/src/components/modals/aside-modal/aside-modal.tsx +0 -64
  167. package/src/components/modals/aside-modal/index.ts +0 -1
  168. package/src/components/modals/confirmation-modal/confirmation-modal.stories.tsx +0 -62
  169. package/src/components/modals/confirmation-modal/confirmation-modal.style.ts +0 -17
  170. package/src/components/modals/confirmation-modal/confirmation-modal.tsx +0 -43
  171. package/src/components/modals/confirmation-modal/index.ts +0 -1
  172. package/src/components/modals/index.ts +0 -6
  173. package/src/components/modals/menu/index.ts +0 -1
  174. package/src/components/modals/menu/menu.stories.tsx +0 -69
  175. package/src/components/modals/menu/menu.style.ts +0 -62
  176. package/src/components/modals/menu/menu.tsx +0 -144
  177. package/src/components/modals/modal/backdrop.tsx +0 -70
  178. package/src/components/modals/modal/index.ts +0 -2
  179. package/src/components/modals/modal/modal.stories.tsx +0 -328
  180. package/src/components/modals/modal/modal.style.ts +0 -70
  181. package/src/components/modals/modal/modal.tsx +0 -96
  182. package/src/components/modals/portal/index.ts +0 -1
  183. package/src/components/modals/portal/portal.tsx +0 -21
  184. package/src/components/ripple/index.ts +0 -1
  185. package/src/components/ripple/ripple.stories.tsx +0 -38
  186. package/src/components/ripple/ripple.style.ts +0 -33
  187. package/src/components/ripple/ripple.tsx +0 -63
  188. package/src/components/smart-table/index.ts +0 -1
  189. package/src/components/smart-table/smart-table.column.tsx +0 -63
  190. package/src/components/smart-table/smart-table.helpers.tsx +0 -59
  191. package/src/components/smart-table/smart-table.hooks.ts +0 -27
  192. package/src/components/smart-table/smart-table.row.tsx +0 -29
  193. package/src/components/smart-table/smart-table.stories.tsx +0 -301
  194. package/src/components/smart-table/smart-table.style.ts +0 -102
  195. package/src/components/smart-table/smart-table.tsx +0 -112
  196. package/src/components/smart-table/smart-table.types.ts +0 -41
  197. package/src/components/tabs/index.ts +0 -1
  198. package/src/components/tabs/tabs-container.stories.tsx +0 -159
  199. package/src/components/tabs/tabs-list.tsx +0 -134
  200. package/src/components/tabs/tabs.stories.tsx +0 -68
  201. package/src/components/tabs/tabs.style.ts +0 -137
  202. package/src/components/tabs/tabs.tsx +0 -117
  203. package/src/components/tag/index.ts +0 -1
  204. package/src/components/tag/tag.stories.tsx +0 -48
  205. package/src/components/tag/tag.style.ts +0 -29
  206. package/src/components/tag/tag.tsx +0 -34
  207. package/src/components/tooltips/click-to-copy/click-to-copy.stories.tsx +0 -39
  208. package/src/components/tooltips/click-to-copy/click-to-copy.tsx +0 -41
  209. package/src/components/tooltips/click-to-copy/index.ts +0 -1
  210. package/src/components/tooltips/index.ts +0 -2
  211. package/src/components/tooltips/tooltip/index.ts +0 -1
  212. package/src/components/tooltips/tooltip/tooltip.stories.tsx +0 -38
  213. package/src/components/tooltips/tooltip/tooltip.style.ts +0 -93
  214. package/src/components/tooltips/tooltip/tooltip.tsx +0 -59
  215. package/src/components/typography/index.ts +0 -2
  216. package/src/components/typography/typography.constants.ts +0 -43
  217. package/src/components/typography/typography.stories.tsx +0 -108
  218. package/src/components/typography/typography.style.ts +0 -76
  219. package/src/components/typography/typography.tsx +0 -100
  220. package/src/contexts/fetch-context/fetch-context.tsx +0 -114
  221. package/src/contexts/fetch-context/index.ts +0 -1
  222. package/src/contexts/form-context/form-context.tsx +0 -43
  223. package/src/contexts/form-context/index.ts +0 -1
  224. package/src/contexts/index.ts +0 -3
  225. package/src/contexts/theme-context/index.ts +0 -3
  226. package/src/contexts/theme-context/theme-context.tsx +0 -158
  227. package/src/contexts/theme-context/theme.animations.ts +0 -269
  228. package/src/contexts/theme-context/theme.defaults.ts +0 -205
  229. package/src/contexts/theme-context/theme.style.ts +0 -78
  230. package/src/contexts/theme-context/themes.ts +0 -96
  231. package/src/core/http-client.d.ts +0 -11
  232. package/src/core/http-client.d.ts.map +0 -1
  233. package/src/core/http-client.ts +0 -49
  234. package/src/core/index.d.ts +0 -2
  235. package/src/core/index.d.ts.map +0 -1
  236. package/src/core/index.ts +0 -1
  237. package/src/core/variants/color.ts +0 -9
  238. package/src/core/variants/index.ts +0 -3
  239. package/src/core/variants/radius.ts +0 -27
  240. package/src/core/variants/size.ts +0 -19
  241. package/src/helpers/format-bytes.ts +0 -11
  242. package/src/helpers/format-dates.ts +0 -11
  243. package/src/helpers/get-modal-position-relative-to-screen.ts +0 -86
  244. package/src/helpers/get-modal-position.ts +0 -211
  245. package/src/helpers/index.ts +0 -5
  246. package/src/helpers/text/index.ts +0 -1
  247. package/src/helpers/text/to-capitalize.ts +0 -17
  248. package/src/hooks/index.ts +0 -29
  249. package/src/hooks/use-async.ts +0 -88
  250. package/src/hooks/use-classnames.ts +0 -13
  251. package/src/hooks/use-click-outside.ts +0 -32
  252. package/src/hooks/use-constant.ts +0 -3
  253. package/src/hooks/use-cookie.ts +0 -124
  254. package/src/hooks/use-debounce.ts +0 -15
  255. package/src/hooks/use-dimensions.ts +0 -19
  256. package/src/hooks/use-dom-container.ts +0 -35
  257. package/src/hooks/use-event-listener.ts +0 -71
  258. package/src/hooks/use-file-reader.ts +0 -69
  259. package/src/hooks/use-geolocation.ts +0 -63
  260. package/src/hooks/use-hover.ts +0 -17
  261. package/src/hooks/use-in-view.ts +0 -18
  262. package/src/hooks/use-input-handlers.ts +0 -49
  263. package/src/hooks/use-intersection-observer.ts +0 -19
  264. package/src/hooks/use-media-query.ts +0 -25
  265. package/src/hooks/use-modal-in-container.ts +0 -96
  266. package/src/hooks/use-modal-transition.ts +0 -66
  267. package/src/hooks/use-modal.ts +0 -21
  268. package/src/hooks/use-mouse-position.ts +0 -64
  269. package/src/hooks/use-online-status.ts +0 -12
  270. package/src/hooks/use-render-count.ts +0 -11
  271. package/src/hooks/use-resize-observer.ts +0 -18
  272. package/src/hooks/use-safe-dispatch.ts +0 -22
  273. package/src/hooks/use-scroll.ts +0 -31
  274. package/src/hooks/use-state-history.ts +0 -22
  275. package/src/hooks/use-toggle-values.ts +0 -14
  276. package/src/hooks/use-toggle.ts +0 -11
  277. package/src/hooks/use-viewport.ts +0 -38
  278. package/src/index.ts +0 -5
  279. package/src/layouts/flex/flex.tsx +0 -75
  280. package/src/layouts/flex/index.ts +0 -1
  281. package/src/layouts/grid/grid.tsx +0 -86
  282. package/src/layouts/grid/index.ts +0 -1
  283. package/src/layouts/index.ts +0 -3
  284. package/src/layouts/section-layout/index.ts +0 -1
  285. package/src/layouts/section-layout/section-layout.stories.tsx +0 -55
  286. package/src/layouts/section-layout/section-layout.style.ts +0 -21
  287. package/src/layouts/section-layout/section-layout.tsx +0 -46
  288. package/src/stories/GettingStarted.mdx +0 -62
  289. package/src/types/generics.ts +0 -68
  290. package/src/types/index.ts +0 -1
  291. package/svg/Name=airplane, Category=object.svg +0 -3
  292. package/svg/Name=arrow-circle, Category=symbol.svg +0 -3
  293. package/svg/Name=arrow-down, Category=symbol.svg +0 -3
  294. package/svg/Name=arrow-left, Category=symbol.svg +0 -3
  295. package/svg/Name=arrow-right, Category=symbol.svg +0 -3
  296. package/svg/Name=arrow-up, Category=symbol.svg +0 -3
  297. package/svg/Name=bell, Category=object.svg +0 -3
  298. package/svg/Name=bicycle, Category=object.svg +0 -3
  299. package/svg/Name=book-open, Category=object.svg +0 -3
  300. package/svg/Name=book-solid, Category=object.svg +0 -6
  301. package/svg/Name=box-shadow, Category=symbol.svg +0 -5
  302. package/svg/Name=calendar, Category=object.svg +0 -3
  303. package/svg/Name=camera, Category=object.svg +0 -3
  304. package/svg/Name=caret-down, Category=symbol.svg +0 -3
  305. package/svg/Name=caret-left, Category=symbol.svg +0 -3
  306. package/svg/Name=caret-right, Category=symbol.svg +0 -3
  307. package/svg/Name=caret-up, Category=symbol.svg +0 -3
  308. package/svg/Name=checkmark, Category=symbol.svg +0 -3
  309. package/svg/Name=clean-computer, Category=object.svg +0 -10
  310. package/svg/Name=codepen, Category=social.svg +0 -3
  311. package/svg/Name=creative, Category=symbol.svg +0 -5
  312. package/svg/Name=cross, Category=symbol.svg +0 -4
  313. package/svg/Name=crossed-flags, Category=object.svg +0 -4
  314. package/svg/Name=cv, Category=symbol.svg +0 -5
  315. package/svg/Name=design-ui, Category=symbol.svg +0 -9
  316. package/svg/Name=document, Category=object.svg +0 -3
  317. package/svg/Name=door-closed, Category=object.svg +0 -3
  318. package/svg/Name=door-open, Category=object.svg +0 -3
  319. package/svg/Name=double-caret-down, Category=symbol.svg +0 -4
  320. package/svg/Name=double-caret-left, Category=symbol.svg +0 -4
  321. package/svg/Name=double-caret-righ, Category=symbol.svg +0 -4
  322. package/svg/Name=double-caret-up, Category=symbol.svg +0 -4
  323. package/svg/Name=download, Category=symbol.svg +0 -5
  324. package/svg/Name=dropper, Category=object.svg +0 -5
  325. package/svg/Name=envelope, Category=object.svg +0 -3
  326. package/svg/Name=exclamation-close, Category=symbol.svg +0 -4
  327. package/svg/Name=exclamation-open, Category=symbol.svg +0 -4
  328. package/svg/Name=external-link, Category=symbol.svg +0 -3
  329. package/svg/Name=eye, Category=object.svg +0 -4
  330. package/svg/Name=eye-hidden, Category=object.svg +0 -7
  331. package/svg/Name=facebook, Category=social.svg +0 -3
  332. package/svg/Name=form, Category=symbol.svg +0 -8
  333. package/svg/Name=game-control, Category=object.svg +0 -3
  334. package/svg/Name=gear, Category=object.svg +0 -3
  335. package/svg/Name=github, Category=social.svg +0 -3
  336. package/svg/Name=house, Category=object.svg +0 -3
  337. package/svg/Name=hyphen, Category=symbol.svg +0 -3
  338. package/svg/Name=info, Category=symbol.svg +0 -3
  339. package/svg/Name=instagram, Category=social.svg +0 -3
  340. package/svg/Name=link, Category=symbol.svg +0 -5
  341. package/svg/Name=linkedin, Category=social.svg +0 -3
  342. package/svg/Name=magnifying-glass, Category=object.svg +0 -3
  343. package/svg/Name=message, Category=symbol.svg +0 -4
  344. package/svg/Name=moon, Category=object.svg +0 -5
  345. package/svg/Name=npm, Category=social.svg +0 -3
  346. package/svg/Name=order-list, Category=symbol.svg +0 -7
  347. package/svg/Name=pencil, Category=object.svg +0 -3
  348. package/svg/Name=pin-location, Category=symbol.svg +0 -3
  349. package/svg/Name=question-mark-close, Category=symbol.svg +0 -3
  350. package/svg/Name=question-mark-open, Category=symbol.svg +0 -3
  351. package/svg/Name=share, Category=symbol.svg +0 -5
  352. package/svg/Name=spinner, Category=symbol.svg +0 -9
  353. package/svg/Name=star, Category=object.svg +0 -3
  354. package/svg/Name=star-empty, Category=object.svg +0 -3
  355. package/svg/Name=sun, Category=object.svg +0 -11
  356. package/svg/Name=text-shadow, Category=symbol.svg +0 -4
  357. package/svg/Name=thinking, Category=symbol.svg +0 -3
  358. package/svg/Name=trash-can, Category=object.svg +0 -4
  359. package/svg/Name=upload, Category=symbol.svg +0 -5
  360. package/svg/Name=user, Category=symbol.svg +0 -4
  361. package/svg/Name=warning, Category=symbol.svg +0 -5
  362. package/svg/Name=whatsapp, Category=social.svg +0 -3
  363. package/svgconfig.json +0 -4
  364. package/tsconfig.json +0 -14
  365. package/tsup.config.cjs +0 -21
  366. package/vite.config.ts +0 -14
@@ -1,301 +0,0 @@
1
- import { Icon } from '../icon';
2
-
3
- import { SmartTable } from './smart-table';
4
-
5
- import type { Meta, StoryObj } from '@storybook/react';
6
-
7
- const users = [
8
- {
9
- age: '25',
10
- gender: 'male',
11
- occupation: 'Software engineer',
12
- hobbies: ['Reading', 'Hiking'],
13
- email: 'john@example.com',
14
- phone: '123-456-7890',
15
- username: 'johnny25',
16
- name: 'John Doe',
17
- country: 'USA',
18
- id: '1',
19
- },
20
- {
21
- age: '30',
22
- gender: 'female',
23
- occupation: 'Graphic designer',
24
- hobbies: ['Painting', 'Yoga'],
25
- email: 'jane@example.com',
26
- phone: '987-654-3210',
27
- username: 'janeD30',
28
- name: 'Jane Smith',
29
- country: 'Canada',
30
- id: '2',
31
- },
32
- {
33
- age: '28',
34
- gender: 'male',
35
- occupation: 'Data analyst',
36
- hobbies: ['Gaming', 'Cycling'],
37
- email: 'mike@example.com',
38
- phone: '555-123-4567',
39
- username: 'mikeA28',
40
- name: 'Mike Johnson',
41
- country: 'UK',
42
- id: '3',
43
- },
44
- {
45
- age: '35',
46
- gender: 'female',
47
- occupation: 'Marketing manager',
48
- hobbies: ['Traveling', 'Cooking'],
49
- email: 'sara@example.com',
50
- phone: '444-987-6543',
51
- username: 'saraM35',
52
- name: 'Sara Wilson',
53
- country: 'Australia',
54
- id: '4',
55
- },
56
- {
57
- age: '22',
58
- gender: 'male',
59
- occupation: 'Web developer',
60
- hobbies: ['Programming', 'Photography'],
61
- email: 'alex@example.com',
62
- phone: '333-555-1234',
63
- username: 'alexD22',
64
- name: 'Alex Brown',
65
- country: 'Germany',
66
- id: '5',
67
- },
68
- {
69
- age: '27',
70
- gender: 'female',
71
- occupation: 'HR specialist',
72
- hobbies: ['Dancing', 'Reading'],
73
- email: 'lisa@example.com',
74
- phone: '222-444-9876',
75
- username: 'lisaS27',
76
- name: 'Lisa Davis',
77
- country: 'France',
78
- id: '6',
79
- },
80
- {
81
- age: '31',
82
- gender: 'male',
83
- occupation: 'Financial analyst',
84
- hobbies: ['Investing', 'Golfing'],
85
- email: 'tom@example.com',
86
- phone: '111-333-5555',
87
- username: 'tomA31',
88
- name: 'Tom Miller',
89
- country: 'Japan',
90
- id: '7',
91
- },
92
- {
93
- age: '29',
94
- gender: 'female',
95
- occupation: 'Sales executive',
96
- hobbies: ['Shopping', 'Running'],
97
- email: 'anna@example.com',
98
- phone: '666-222-4444',
99
- username: 'annaE29',
100
- name: 'Anna Taylor',
101
- country: 'Brazil',
102
- id: '8',
103
- },
104
- {
105
- age: '26',
106
- gender: 'male',
107
- occupation: 'IT support',
108
- hobbies: ['Gaming', 'Watching movies'],
109
- email: 'jake@example.com',
110
- phone: '777-111-3333',
111
- username: 'jakeS26',
112
- name: 'Jake Anderson',
113
- country: 'India',
114
- id: '9',
115
- },
116
- {
117
- age: '33',
118
- gender: 'female',
119
- occupation: 'Nurse',
120
- hobbies: ['Cooking', 'Painting'],
121
- email: 'kate@example.com',
122
- phone: '888-666-2222',
123
- username: 'kateN33',
124
- name: 'Kate Thomas',
125
- country: 'Italy',
126
- id: '10',
127
- },
128
- {
129
- age: '24',
130
- gender: 'male',
131
- occupation: 'Teacher',
132
- hobbies: ['Reading', 'Traveling'],
133
- email: 'ryan@example.com',
134
- phone: '999-777-1111',
135
- username: 'ryanT24',
136
- name: 'Ryan Jackson',
137
- country: 'Mexico',
138
- id: '11',
139
- },
140
- {
141
- age: '32',
142
- gender: 'female',
143
- occupation: 'Lawyer',
144
- hobbies: ['Running', 'Yoga'],
145
- email: 'lily@example.com',
146
- phone: '000-888-6666',
147
- username: 'lilyL32',
148
- name: 'Lily White',
149
- country: 'South Africa',
150
- id: '12',
151
- },
152
- {
153
- age: '23',
154
- gender: 'male',
155
- occupation: 'Mechanic',
156
- hobbies: ['Fixing cars', 'Fishing'],
157
- email: 'matt@example.com',
158
- phone: '111-999-7777',
159
- username: 'mattM23',
160
- name: 'Matt Harris',
161
- country: 'Russia',
162
- id: '13',
163
- },
164
- {
165
- age: '34',
166
- gender: 'female',
167
- occupation: 'Architect',
168
- hobbies: ['Designing', 'Hiking'],
169
- email: 'sophia@example.com',
170
- phone: '222-000-8888',
171
- username: 'sophiaA34',
172
- name: 'Sophia Clark',
173
- country: 'Spain',
174
- id: '14',
175
- },
176
- {
177
- age: '21',
178
- gender: 'male',
179
- occupation: 'Intern',
180
- hobbies: ['Learning', 'Reading'],
181
- email: 'chris@example.com',
182
- phone: '333-111-9999',
183
- username: 'chrisI21',
184
- name: 'Chris Lewis',
185
- country: 'Netherlands',
186
- id: '15',
187
- },
188
- {
189
- age: '36',
190
- gender: 'female',
191
- occupation: 'CEO',
192
- hobbies: ['Gambling', 'Traveling'],
193
- email: 'emily@example.com',
194
- phone: '444-222-0000',
195
- username: 'emilyC36',
196
- name: 'Emily Robinson',
197
- country: 'Sweden',
198
- id: '16',
199
- },
200
- {
201
- age: '37',
202
- gender: 'male',
203
- occupation: 'Doctor',
204
- hobbies: ['Helping others', 'Running'],
205
- email: 'david@example.com',
206
- phone: '555-333-1111',
207
- username: 'davidD37',
208
- name: 'David Hall',
209
- country: 'Norway',
210
- id: '17',
211
- },
212
- {
213
- age: '38',
214
- gender: 'female',
215
- occupation: 'Accountant',
216
- hobbies: ['Calculating', 'Reading'],
217
- email: 'olivia@example.com',
218
- phone: '666-444-2222',
219
- username: 'oliviaA38',
220
- name: 'Olivia Young',
221
- country: 'Finland',
222
- id: '18',
223
- },
224
- {
225
- age: '39',
226
- gender: 'male',
227
- occupation: 'Plumber',
228
- hobbies: ['Fixing pipes', 'Fishing'],
229
- email: 'noah@example.com',
230
- phone: '777-555-3333',
231
- username: 'noahP39',
232
- name: 'Noah King',
233
- country: 'Denmark',
234
- id: '19',
235
- },
236
- {
237
- age: '40',
238
- gender: 'female',
239
- occupation: 'Teacher',
240
- hobbies: ['Teaching', 'Traveling'],
241
- email: 'ava@example.com',
242
- phone: '888-666-4444',
243
- username: 'avaT40',
244
- name: 'Ava Scott',
245
- country: 'Belgium',
246
- id: '20',
247
- },
248
- ];
249
-
250
- const meta: Meta<typeof SmartTable> = {
251
- title: 'Smart Table',
252
- component: SmartTable,
253
- argTypes: {
254
- columns: { control: false },
255
- data: { control: false },
256
- width: { control: 'inline-radio', options: ['scroll', 'content'] },
257
- selectable: { control: 'boolean' },
258
- rowId: { control: false },
259
- },
260
- args: {},
261
- decorators: [
262
- Story => (
263
- <div style={{ width: '100%', maxHeight: '500px', overflow: 'auto' }}>
264
- <Story />
265
- </div>
266
- ),
267
- ],
268
- };
269
-
270
- export default meta;
271
- type Story = StoryObj<typeof SmartTable>;
272
-
273
- export const Users: Story = {
274
- args: {
275
- // @ts-expect-error Storybook doesn't recognize the rowId prop
276
- rowId: 'id',
277
- data: users,
278
- columns: [
279
- // @ts-expect-error Storybook doesn't recognize props
280
- { header: 'Name', field: 'name' },
281
- // @ts-expect-error Storybook doesn't recognize props
282
- { header: 'Age', field: 'age' },
283
- // @ts-expect-error Storybook doesn't recognize props
284
- { header: 'Email', field: 'email' },
285
- // @ts-expect-error Storybook doesn't recognize props
286
- { header: 'Username', field: 'username' },
287
- // @ts-expect-error Storybook doesn't recognize props
288
- { header: 'Phone', field: 'phone' },
289
- {
290
- header: 'Gender',
291
- render: data => <Icon name={data.gender === 'male' ? 'user' : 'camera'} />,
292
- // @ts-expect-error Storybook doesn't recognize props
293
- sortBy: 'gender',
294
- },
295
- // @ts-expect-error Storybook doesn't recognize props
296
- { header: 'Country', field: 'country' },
297
- // @ts-expect-error Storybook doesn't recognize props
298
- { header: 'Occupation', field: 'occupation' },
299
- ],
300
- },
301
- };
@@ -1,102 +0,0 @@
1
- import { styled } from 'styled-components';
2
-
3
- export const SmartTableContainerStyle = styled.section`
4
- border: 1px solid ${props => props.theme.colors.primary.main};
5
- border-radius: 10px;
6
- overflow: auto;
7
- height: 100%;
8
- width: 100%;
9
- margin: auto;
10
- `;
11
-
12
- export const SmartTableStyle = styled.table`
13
- border-collapse: collapse;
14
- position: relative;
15
-
16
- &.layout-fixed {
17
- table-layout: fixed;
18
- }
19
-
20
- &.layout-scrollable {
21
- table-layout: auto;
22
- }
23
- `;
24
-
25
- export const SmartHeaderStyle = styled.thead`
26
- position: sticky;
27
- z-index: 10;
28
- top: 0;
29
- box-shadow:
30
- 0 3px 5px 0 rgba(0, 0, 0, 0.2),
31
- 0 1px 10px 0 rgba(0, 0, 0, 0.12);
32
- `;
33
-
34
- export const SmartBodyStyle = styled.tbody``;
35
-
36
- export const SmartColumnStyle = styled.th`
37
- padding: 0.8em 1.2em;
38
- user-select: none;
39
-
40
- &.sort-on-click {
41
- cursor: pointer;
42
- }
43
-
44
- .sort-icon {
45
- width: 1em;
46
- display: block;
47
- }
48
-
49
- svg {
50
- animation: fadeIn 300ms ease;
51
- }
52
-
53
- path {
54
- transition: all 300ms ease;
55
- }
56
-
57
- &:first-child {
58
- padding-left: 2em;
59
- }
60
-
61
- &:last-child {
62
- padding-right: 2em;
63
- }
64
- `;
65
-
66
- export const SmartHeaderRowStyle = styled.tr`
67
- background: ${props => props.theme.colors.primary.main};
68
- color: ${props => props.theme.colors.primary.contrast};
69
- transition: all 300ms ease;
70
- `;
71
-
72
- export const SmartRowStyle = styled.tr`
73
- background: ${props => props.theme.colors.background.main};
74
- box-shadow: inset 0 0 0 0 ${props => props.theme.colors.primary.main};
75
- transition: box-shadow 300ms ease;
76
-
77
- &.row-selected,
78
- &:hover {
79
- background: ${props => props.theme.colors.background.paper};
80
- }
81
-
82
- &.row-selected {
83
- box-shadow: inset 10px 0 0 -5px ${props => props.theme.colors.primary.main};
84
- }
85
-
86
- &:not(:last-child) {
87
- border-bottom: 1px solid ${props => props.theme.colors.border.main};
88
- }
89
- `;
90
-
91
- export const SmartCellStyle = styled.td`
92
- transition: all 300ms ease;
93
- padding: 0.6em 1em;
94
-
95
- &:first-child {
96
- padding-left: 2em;
97
- }
98
-
99
- &:last-child {
100
- padding-right: 2em;
101
- }
102
- `;
@@ -1,112 +0,0 @@
1
- import { useMemo, useState } from 'react';
2
-
3
- import { KeyValuesOf } from '../../types';
4
- import { Checkbox } from '../form';
5
-
6
- import { SmartTableColumn } from './smart-table.column';
7
- import { sortData } from './smart-table.helpers';
8
- import { useSort } from './smart-table.hooks';
9
- import { SmartTableRow } from './smart-table.row';
10
- import {
11
- SmartBodyStyle,
12
- SmartHeaderStyle,
13
- SmartTableStyle,
14
- SmartHeaderRowStyle,
15
- SmartTableContainerStyle,
16
- } from './smart-table.style';
17
- import { ColumnData, RowDataObject } from './smart-table.types';
18
-
19
- import { useClassNames } from '@polpo/hooks';
20
-
21
- type SmartTableProps<RowData extends RowDataObject> = {
22
- columns: Array<ColumnData<RowData>>;
23
- data: Array<RowData>;
24
- width?: 'scroll' | 'content';
25
- selectable?: boolean;
26
- rowId: KeyValuesOf<RowData, React.Key>;
27
- };
28
-
29
- export const SmartTable = <RowData extends RowDataObject>({
30
- columns: initialColumns,
31
- data,
32
- width,
33
- selectable = false,
34
- rowId,
35
- }: SmartTableProps<RowData>) => {
36
- const [selected, setSelected] = useState<{ [key: string]: RowData }>({});
37
-
38
- const tableClassName = useClassNames({
39
- 'layout-fixed': width === 'content',
40
- 'layout-scrollable': width === 'scroll',
41
- });
42
-
43
- const { sortBy, order, toggleSortField } = useSort<RowData>();
44
-
45
- const columns = useMemo(() => {
46
- let finalColumns = [...initialColumns];
47
-
48
- if (selectable) {
49
- finalColumns = [
50
- {
51
- header: `${Object.values(selected).length}`,
52
- render: (data, rowKey) => (
53
- <Checkbox
54
- name={`selected-${rowKey}`}
55
- value={`${rowKey}` in selected}
56
- setValue={isSelected => {
57
- setSelected(prev => {
58
- const copy = { ...prev };
59
-
60
- if (isSelected) {
61
- copy[`${rowKey}`] = data;
62
- } else {
63
- delete copy[`${rowKey}`];
64
- }
65
-
66
- return copy;
67
- });
68
- }}
69
- />
70
- ),
71
- },
72
- ...finalColumns,
73
- ];
74
- }
75
-
76
- return finalColumns;
77
- }, [initialColumns, selectable, selected]);
78
-
79
- const rows = useMemo(() => sortData<RowData>(data, sortBy, order), [data, sortBy, order]);
80
-
81
- return (
82
- <SmartTableContainerStyle>
83
- <SmartTableStyle className={tableClassName}>
84
- <SmartHeaderStyle>
85
- <SmartHeaderRowStyle>
86
- {columns.map((column, key) => (
87
- <SmartTableColumn
88
- key={key}
89
- toggleSortField={toggleSortField}
90
- sortField={sortBy}
91
- orderField={order}
92
- {...column}
93
- />
94
- ))}
95
- </SmartHeaderRowStyle>
96
- </SmartHeaderStyle>
97
- <SmartBodyStyle>
98
- {rows.map(row => (
99
- <SmartTableRow
100
- key={row[rowId] as React.Key}
101
- rowKey={row[rowId] as React.Key}
102
- data={row}
103
- columns={columns}
104
- isSelected={`${row[rowId] as React.Key}` in selected}
105
- selectable={selectable}
106
- />
107
- ))}
108
- </SmartBodyStyle>
109
- </SmartTableStyle>
110
- </SmartTableContainerStyle>
111
- );
112
- };
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
-
3
- import { KeyValuesOf } from '../../types';
4
- import { IconNameT } from '../icon';
5
-
6
- export type Primitive = string | number | boolean;
7
-
8
- export type RowDataObject = { [key: string]: Primitive | object };
9
-
10
- export type Order = 'asc' | 'desc';
11
-
12
- type ColumnDataCommon<RowData extends RowDataObject> = {
13
- header: React.ReactNode;
14
- sortBy?: KeyValuesOf<RowData, Primitive>;
15
- icon?: IconNameT;
16
- width?: `${number}px` | `${number}em` | `${number}%`;
17
- };
18
-
19
- type ColumnDataField<RowData extends RowDataObject> = ColumnDataCommon<RowData> & {
20
- field: KeyValuesOf<RowData, Primitive>;
21
- sortBy?: never;
22
- render?: never;
23
- Component?: never;
24
- };
25
-
26
- type ColumnDataRender<RowData extends RowDataObject> = ColumnDataCommon<RowData> & {
27
- field?: never;
28
- render: (row: RowData, rowKey: React.Key) => React.ReactNode;
29
- Component?: never;
30
- };
31
-
32
- type ColumnDataComponent<RowData extends RowDataObject> = ColumnDataCommon<RowData> & {
33
- field?: never;
34
- render?: never;
35
- Component: React.FC<{ data: RowData; rowKey: React.Key }>;
36
- };
37
-
38
- export type ColumnData<RowData extends RowDataObject> =
39
- | ColumnDataField<RowData>
40
- | ColumnDataRender<RowData>
41
- | ColumnDataComponent<RowData>;
@@ -1 +0,0 @@
1
- export * from './tabs';