@addev-be/ui 0.1.18

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 (98) hide show
  1. package/assets/fonts/montserrat-200.woff2 +0 -0
  2. package/assets/fonts/montserrat-400.woff2 +0 -0
  3. package/assets/fonts/montserrat-500.woff2 +0 -0
  4. package/assets/fonts/montserrat-700.woff2 +0 -0
  5. package/assets/icons/arrow-down-a-z.svg +1 -0
  6. package/assets/icons/arrow-up-z-a.svg +1 -0
  7. package/assets/icons/arrows-rotate.svg +1 -0
  8. package/assets/icons/arrows-up-down.svg +1 -0
  9. package/assets/icons/check.svg +1 -0
  10. package/assets/icons/copy.svg +1 -0
  11. package/assets/icons/down.svg +1 -0
  12. package/assets/icons/filter-full.svg +1 -0
  13. package/assets/icons/filter-slash.svg +1 -0
  14. package/assets/icons/filter.svg +1 -0
  15. package/assets/icons/hashtag.svg +1 -0
  16. package/assets/icons/image-slash.svg +1 -0
  17. package/assets/icons/left.svg +1 -0
  18. package/assets/icons/magnifier.svg +1 -0
  19. package/assets/icons/phone.svg +1 -0
  20. package/assets/icons/plus.svg +1 -0
  21. package/assets/icons/right.svg +1 -0
  22. package/assets/icons/spinner-third.svg +1 -0
  23. package/assets/icons/table-columns.svg +1 -0
  24. package/assets/icons/up.svg +1 -0
  25. package/assets/icons/user-tie.svg +1 -0
  26. package/eslint.config.js +28 -0
  27. package/package.json +49 -0
  28. package/src/Icons.tsx +80 -0
  29. package/src/components/data/DataGrid/AdvancedRequestDataGrid.tsx +236 -0
  30. package/src/components/data/DataGrid/DataGridCell.tsx +78 -0
  31. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -0
  32. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +58 -0
  33. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -0
  34. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -0
  35. package/src/components/data/DataGrid/DataGridEditableCell.tsx +54 -0
  36. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +75 -0
  37. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +190 -0
  38. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +100 -0
  39. package/src/components/data/DataGrid/DataGridFooter.tsx +64 -0
  40. package/src/components/data/DataGrid/DataGridHeader.tsx +129 -0
  41. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +166 -0
  42. package/src/components/data/DataGrid/FilterModalContent/index.tsx +125 -0
  43. package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -0
  44. package/src/components/data/DataGrid/FilterValuesScroller.tsx +131 -0
  45. package/src/components/data/DataGrid/VirtualScroller.tsx +51 -0
  46. package/src/components/data/DataGrid/helpers/advancedRequests.tsx +61 -0
  47. package/src/components/data/DataGrid/helpers/columns.tsx +259 -0
  48. package/src/components/data/DataGrid/helpers/filters.ts +219 -0
  49. package/src/components/data/DataGrid/helpers/index.ts +3 -0
  50. package/src/components/data/DataGrid/hooks/index.ts +30 -0
  51. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +225 -0
  52. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +166 -0
  53. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +49 -0
  54. package/src/components/data/DataGrid/index.tsx +145 -0
  55. package/src/components/data/DataGrid/styles.ts +284 -0
  56. package/src/components/data/DataGrid/types.ts +232 -0
  57. package/src/components/data/index.ts +3 -0
  58. package/src/components/forms/Button.tsx +99 -0
  59. package/src/components/forms/IconButton.tsx +57 -0
  60. package/src/components/forms/IndeterminateCheckbox.tsx +46 -0
  61. package/src/components/forms/Select.tsx +40 -0
  62. package/src/components/forms/index.ts +5 -0
  63. package/src/components/forms/styles.ts +20 -0
  64. package/src/components/index.ts +3 -0
  65. package/src/components/layout/Dropdown/index.tsx +79 -0
  66. package/src/components/layout/Dropdown/styles.ts +44 -0
  67. package/src/components/layout/Loading/index.tsx +28 -0
  68. package/src/components/layout/Loading/styles.ts +29 -0
  69. package/src/components/layout/Modal/index.tsx +51 -0
  70. package/src/components/layout/Modal/styles.ts +110 -0
  71. package/src/components/layout/index.ts +3 -0
  72. package/src/config/index.ts +14 -0
  73. package/src/helpers/getScrollbarSize.ts +14 -0
  74. package/src/helpers/numbers.ts +20 -0
  75. package/src/hooks/index.ts +2 -0
  76. package/src/hooks/useElementSize.ts +24 -0
  77. package/src/hooks/useWindowSize.ts +20 -0
  78. package/src/index.ts +7 -0
  79. package/src/providers/PortalsProvider/index.tsx +54 -0
  80. package/src/providers/PortalsProvider/styles.ts +27 -0
  81. package/src/providers/SettingsProvider/index.tsx +70 -0
  82. package/src/providers/ThemeProvider/ThemeProvider.ts +55 -0
  83. package/src/providers/ThemeProvider/defaultTheme.ts +444 -0
  84. package/src/providers/ThemeProvider/index.ts +3 -0
  85. package/src/providers/ThemeProvider/types.ts +123 -0
  86. package/src/providers/UiProviders/index.tsx +65 -0
  87. package/src/providers/UiProviders/styles.ts +10 -0
  88. package/src/providers/hooks.ts +8 -0
  89. package/src/providers/index.ts +5 -0
  90. package/src/services/WebSocketService.ts +147 -0
  91. package/src/services/advancedRequests.ts +100 -0
  92. package/src/services/base.ts +31 -0
  93. package/src/services/hooks.ts +13 -0
  94. package/src/services/index.ts +2 -0
  95. package/src/styles/animations.scss +30 -0
  96. package/src/styles/index.scss +42 -0
  97. package/src/typings.d.ts +6 -0
  98. package/tsconfig.json +18 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M47 377l96 96c9.4 9.4 24.6 9.4 33.9 0l96-96c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-55 55V56c0-13.3-10.7-24-24-24s-24 10.7-24 24V398.1L81 343c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9zm305-89c-13.3 0-24 10.7-24 24s10.7 24 24 24h74.6L334.1 440.1c-6.3 7.1-7.8 17.2-4 25.8S342.6 480 352 480H480c13.3 0 24-10.7 24-24s-10.7-24-24-24H405.4l92.5-104.1c6.3-7.1 7.8-17.2 4-25.8S489.4 288 480 288H352zM416 32c-9.1 0-17.4 5.1-21.5 13.3l-80 160c-5.9 11.9-1.1 26.3 10.7 32.2s26.3 1.1 32.2-10.7L370.8 200H456c1.7 0 3.3-.2 4.9-.5l13.6 27.2c5.9 11.9 20.3 16.7 32.2 10.7s16.7-20.3 10.7-32.2l-80-160C433.4 37.1 425.1 32 416 32zM394.8 152L416 109.7 437.2 152H394.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M352 32H480c9.4 0 18 5.5 21.9 14.2s2.3 18.7-4 25.8L405.4 176H480c13.3 0 24 10.7 24 24s-10.7 24-24 24H352c-9.4 0-18-5.5-21.9-14.2s-2.3-18.7 4-25.8L426.6 80H352c-13.3 0-24-10.7-24-24s10.7-24 24-24zM143 39c9.4-9.4 24.6-9.4 33.9 0l96 96c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-55-55V456c0 13.3-10.7 24-24 24s-24-10.7-24-24V113.9L81 169c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l96-96zM416 272c9.1 0 17.4 5.1 21.5 13.3l80 160c5.9 11.9 1.1 26.3-10.7 32.2s-26.3 1.1-32.2-10.7l-13.6-27.2c-1.6 .3-3.2 .5-4.9 .5H370.8l-13.4 26.7c-5.9 11.9-20.3 16.7-32.2 10.7s-16.7-20.3-10.7-32.2l80-160c4.1-8.1 12.4-13.3 21.5-13.3zM394.8 392h42.3L416 349.7 394.8 392z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M496 200c0 13.3-10.7 24-24 24h0H360 328c-13.3 0-24-10.7-24-24s10.7-24 24-24h32 54.1l-52.1-52.1C333.8 95.8 295.7 80 256 80c-72.7 0-135.2 44.1-162 107.1c-5.2 12.2-19.3 17.9-31.5 12.7s-17.9-19.3-12.7-31.5C83.9 88.2 163.4 32 256 32c52.5 0 102.8 20.8 139.9 57.9L448 142.1V88l0-.4V56c0-13.3 10.7-24 24-24s24 10.7 24 24V200zM40 288H152c13.3 0 24 10.7 24 24s-10.7 24-24 24H97.9l52.1 52.1C178.2 416.2 216.3 432 256 432c72.6 0 135-43.9 161.9-106.8c5.2-12.2 19.3-17.8 31.5-12.6s17.8 19.3 12.6 31.5C427.8 424 348.5 480 256 480c-52.5 0-102.8-20.8-139.9-57.9L64 369.9V424c0 13.3-10.7 24-24 24s-24-10.7-24-24V312c0-13.3 10.7-24 24-24z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M177 7c-9.4-9.4-24.6-9.4-33.9 0L47 103c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l55-55V430.1L81 375c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l96 96c9.4 9.4 24.6 9.4 33.9 0l96-96c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-55 55V81.9l55 55c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9L177 7z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M214.6 470.6c-12.5 12.5-32.8 12.5-45.3 0l-160-160c-9.2-9.2-11.9-22.9-6.9-34.9s16.6-19.8 29.6-19.8l96 0 0-184c0-22.1 17.9-40 40-40l48 0c22.1 0 40 17.9 40 40l0 184 96 0c12.9 0 24.6 7.8 29.6 19.8s2.2 25.7-6.9 34.9l-160 160z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M3.9 54.9C10.5 40.9 24.5 32 40 32H472c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9V448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6V320.9L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L408.1 294.6 566.6 100c6.1-7.4 9.4-16.7 9.4-26.3c0-23-18.7-41.7-41.7-41.7h-429c-8.6 0-16.5 2.6-23.1 7.1L38.8 5.1zM134.4 80H521L370.3 265 134.4 80zM288 364.4V322.9l-48-37.8v83.2c0 12.2 5.6 23.7 15.1 31.3L347.6 473c5.7 4.5 12.8 7 20.1 7c17.8 0 32.3-14.5 32.3-32.3V411.2l-48-37.8v41.9l-64-50.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M0 73.7C0 50.7 18.7 32 41.7 32H470.3c23 0 41.7 18.7 41.7 41.7c0 9.6-3.3 18.9-9.4 26.3L336 304.5V447.7c0 17.8-14.5 32.3-32.3 32.3c-7.3 0-14.4-2.5-20.1-7l-92.5-73.4c-9.6-7.6-15.1-19.1-15.1-31.3V304.5L9.4 100C3.3 92.6 0 83.3 0 73.7zM55 80L218.6 280.8c3.5 4.3 5.4 9.6 5.4 15.2v68.4l64 50.8V296c0-5.5 1.9-10.9 5.4-15.2L457 80H55z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M181.3 32.4c17.4 2.9 29.2 19.4 26.3 36.8L197.8 128l95.1 0 11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3s29.2 19.4 26.3 36.8L357.8 128l58.2 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-68.9 0L325.8 320l58.2 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-68.9 0-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8l9.8-58.7-95.1 0-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8L90.2 384 32 384c-17.7 0-32-14.3-32-32s14.3-32 32-32l68.9 0 21.3-128L64 192c-17.7 0-32-14.3-32-32s14.3-32 32-32l68.9 0 11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3zM187.1 192L165.8 320l95.1 0 21.3-128-95.1 0z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Pro 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-55.5-43.5c.5-3.1 .7-6.3 .7-9.6l0-320c0-35.3-28.7-64-64-64L128 32c-14.4 0-27.8 4.8-38.5 12.9L38.8 5.1zM134.4 80L512 80c8.8 0 16 7.2 16 16l0 292.5-53.4-41.9L387 233.3c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3l-7.2 9.3L256 175.3c-.4-26.2-21.7-47.3-48-47.3c-3.7 0-7.4 .4-10.8 1.2L134.4 80zm353 400L282.9 318.9 266 340.7l-30.5-42.7C231 291.7 223.8 288 216 288s-15 3.7-19.5 10.1l-80 112-4.5 6.3 0-.3 0-231.8L64 146.4 64 416c0 35.3 28.7 64 64 64l359.4 0z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M9.4 278.6c-12.5-12.5-12.5-32.8 0-45.3l160-160c9.2-9.2 22.9-11.9 34.9-6.9s19.8 16.6 19.8 29.6l0 96 184 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-184 0 0 96c0 12.9-7.8 24.6-19.8 29.6s-25.7 2.2-34.9-6.9l-160-160z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M368 208A160 160 0 1 0 48 208a160 160 0 1 0 320 0zM337.1 371.1C301.7 399.2 256.8 416 208 416C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208c0 48.8-16.8 93.7-44.9 129.1L505 471c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L337.1 371.1z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M164.9 24.6c-7.7-18.6-28-28.5-47.4-23.2l-88 24C12.1 30.2 0 46 0 64C0 311.4 200.6 512 448 512c18 0 33.8-12.1 38.6-29.5l24-88c5.3-19.4-4.6-39.7-23.2-47.4l-96-40c-16.3-6.8-35.2-2.1-46.3 11.6L304.7 368C234.3 334.7 177.3 277.7 144 207.3L193.3 167c13.7-11.2 18.4-30 11.6-46.3l-40-96z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M248 72c0-13.3-10.7-24-24-24s-24 10.7-24 24V232H40c-13.3 0-24 10.7-24 24s10.7 24 24 24H200V440c0 13.3 10.7 24 24 24s24-10.7 24-24V280H408c13.3 0 24-10.7 24-24s-10.7-24-24-24H248V72z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M438.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-9.2 9.2-22.9 11.9-34.9 6.9s-19.8-16.6-19.8-29.6l0-96L40 320c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40l184 0 0-96c0-12.9 7.8-24.6 19.8-29.6s25.7-2.2 34.9 6.9l160 160z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path opacity="1" d="M457 372c11.5 6.6 26.3 2.7 31.8-9.3C503.7 330.2 512 294.1 512 256C512 122.7 410.1 13.2 280 1.1C266.8-.1 256 10.7 256 24s10.8 23.9 24 25.4C383.5 61.2 464 149.2 464 256c0 29.3-6.1 57.3-17 82.6c-5.3 12.2-1.5 26.8 10 33.5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M48 416V160H232V432H64c-8.8 0-16-7.2-16-16zm232 16V160H464V416c0 8.8-7.2 16-16 16H280zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M169.4 41.4c12.5-12.5 32.8-12.5 45.3 0l160 160c9.2 9.2 11.9 22.9 6.9 34.9s-16.6 19.8-29.6 19.8H256V440c0 22.1-17.9 40-40 40H168c-22.1 0-40-17.9-40-40V256H32c-12.9 0-24.6-7.8-29.6-19.8s-2.2-25.7 6.9-34.9l160-160z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M96 128a128 128 0 1 0 256 0A128 128 0 1 0 96 128zm94.5 200.2l18.6 31L175.8 483.1l-36-146.9c-2-8.1-9.8-13.4-17.9-11.3C51.9 342.4 0 405.8 0 481.3c0 17 13.8 30.7 30.7 30.7l131.7 0c0 0 0 0 .1 0l5.5 0 112 0 5.5 0c0 0 0 0 .1 0l131.7 0c17 0 30.7-13.8 30.7-30.7c0-75.5-51.9-138.9-121.9-156.4c-8.1-2-15.9 3.3-17.9 11.3l-36 146.9L238.9 359.2l18.6-31c6.4-10.7-1.3-24.2-13.7-24.2L224 304l-19.7 0c-12.4 0-20.1 13.6-13.7 24.2z"/></svg>
@@ -0,0 +1,28 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ 'react-refresh': reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ },
28
+ )
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@addev-be/ui",
3
+ "version": "0.1.18",
4
+ "type": "module",
5
+ "scripts": {
6
+ "watch": "tsc -b --watch",
7
+ "build": "tsc -b",
8
+ "lint": "eslint ."
9
+ },
10
+ "types": "src/index.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./src/index.ts"
14
+ }
15
+ },
16
+ "devDependencies": {
17
+ "@eslint/js": "^8.57.0",
18
+ "@types/lodash": "^4",
19
+ "@types/react": "^18.3.3",
20
+ "@types/react-dom": "^18.3.0",
21
+ "@types/uuid": "^10",
22
+ "@typescript-eslint/eslint-plugin": "^8.6.0",
23
+ "@vitejs/plugin-react-swc": "^3.5.0",
24
+ "eslint": "^8.57.0",
25
+ "eslint-plugin-import": "^2.30.0",
26
+ "eslint-plugin-jest": "^28.8.3",
27
+ "eslint-plugin-n": "^17.10.2",
28
+ "eslint-plugin-promise": "^7.1.0",
29
+ "eslint-plugin-react": "^7.36.1",
30
+ "eslint-plugin-react-hooks": "^5.1.0-rc.0",
31
+ "eslint-plugin-react-refresh": "^0.4.9",
32
+ "globals": "^15.9.0",
33
+ "typescript": "^5.5.3",
34
+ "typescript-eslint": "^8.6.0"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "^18.3.1",
38
+ "react-dom": "^18.3.1",
39
+ "styled-components": "^6.1.13",
40
+ "vite-plugin-svgr": "^4.2.0"
41
+ },
42
+ "dependencies": {
43
+ "fp-ts": "^2.16.9",
44
+ "io-ts": "^2.2.21",
45
+ "lodash": "^4.17.21",
46
+ "moment": "^2.30.1",
47
+ "uuid": "^10.0.0"
48
+ }
49
+ }
package/src/Icons.tsx ADDED
@@ -0,0 +1,80 @@
1
+ import { FC, SVGProps, useEffect, useState } from 'react';
2
+
3
+ import ArrowDownAZIcon from '../assets/icons/arrow-down-a-z.svg?react';
4
+ import ArrowUpZAIcon from '../assets/icons/arrow-up-z-a.svg?react';
5
+ import ArrowsRotateIcon from '../assets/icons/arrows-rotate.svg?react';
6
+ import ArrowsUpDownIcon from '../assets/icons/arrows-up-down.svg?react';
7
+ import CheckIcon from '../assets/icons/check.svg?react';
8
+ import CopyIcon from '../assets/icons/copy.svg?react';
9
+ import DownIcon from '../assets/icons/down.svg?react';
10
+ import FilterFullIcon from '../assets/icons/filter-full.svg?react';
11
+ import FilterIcon from '../assets/icons/filter.svg?react';
12
+ import FilterSlashIcon from '../assets/icons/filter-slash.svg?react';
13
+ import HashtagIcon from '../assets/icons/hashtag.svg?react';
14
+ import ImageSlashIcon from '../assets/icons/image-slash.svg?react';
15
+ import LeftIcon from '../assets/icons/left.svg?react';
16
+ import MagnifierIcon from '../assets/icons/magnifier.svg?react';
17
+ import PhoneIcon from '../assets/icons/phone.svg?react';
18
+ import PlusIcon from '../assets/icons/plus.svg?react';
19
+ import RightIcon from '../assets/icons/right.svg?react';
20
+ import SpinnerIcon from '../assets/icons/spinner-third.svg?react';
21
+ import TableColumnsIcon from '../assets/icons/table-columns.svg?react';
22
+ import UpIcon from '../assets/icons/up.svg?react';
23
+ import UserTieIcon from '../assets/icons/user-tie.svg?react';
24
+
25
+ type IconFCProps = SVGProps<SVGSVGElement>;
26
+ export type IconFC = FC<IconFCProps>;
27
+
28
+ type AnimatedIconProps = {
29
+ icons: FC[];
30
+ speed?: number;
31
+ };
32
+
33
+ export const AnimatedIcon: FC<AnimatedIconProps & IconFCProps> = ({
34
+ icons,
35
+ speed = 150,
36
+ ...props
37
+ }) => {
38
+ const [currentIcon, setCurrentIcon] = useState(0);
39
+
40
+ useEffect(() => {
41
+ const interval = setInterval(() => {
42
+ setCurrentIcon((currentIcon) => (currentIcon + 1) % icons.length);
43
+ }, speed);
44
+
45
+ return () => {
46
+ clearInterval(interval);
47
+ };
48
+ }, [icons.length, speed]);
49
+
50
+ const Icon = icons[currentIcon];
51
+ return <Icon {...props} />;
52
+ };
53
+
54
+ export const LoadingIcon: FC<IconFCProps> = ({ className, ...props }) => (
55
+ <SpinnerIcon className={`animate-spin ${className}`} {...props} />
56
+ );
57
+
58
+ export {
59
+ ArrowDownAZIcon,
60
+ ArrowUpZAIcon,
61
+ ArrowsRotateIcon,
62
+ ArrowsUpDownIcon,
63
+ CheckIcon,
64
+ CopyIcon,
65
+ DownIcon,
66
+ FilterFullIcon,
67
+ FilterIcon,
68
+ FilterSlashIcon,
69
+ HashtagIcon,
70
+ ImageSlashIcon,
71
+ LeftIcon,
72
+ MagnifierIcon,
73
+ PhoneIcon,
74
+ PlusIcon,
75
+ RightIcon,
76
+ SpinnerIcon,
77
+ TableColumnsIcon,
78
+ UpIcon,
79
+ UserTieIcon,
80
+ };
@@ -0,0 +1,236 @@
1
+ import {
2
+ AdvancedRequestRow,
3
+ ConditionDTO,
4
+ FieldDTO,
5
+ OrderByDTO,
6
+ useAdvancedRequestHandler,
7
+ } from '../../../services/advancedRequests';
8
+ import {
9
+ DataGridColumns,
10
+ DataGridFilters,
11
+ DataGridProps,
12
+ DataGridSort,
13
+ } from './types';
14
+ import { convertFiltersToConditions, getAdvancedRequestDto } from './helpers';
15
+ import { useCallback, useEffect, useRef, useState } from 'react';
16
+
17
+ import { DataGrid } from '.';
18
+ import { debounce } from 'lodash';
19
+
20
+ export type AdvancedRequestDataGridProps<R> = Omit<DataGridProps<R>, 'rows'> & {
21
+ type: string;
22
+ orderBy?: OrderByDTO[];
23
+ conditions?: ConditionDTO[];
24
+ addIdColumn?: boolean;
25
+ parser?: (row: AdvancedRequestRow<R>) => R;
26
+ };
27
+
28
+ const getColumnField = <R,>(
29
+ columns: DataGridColumns<R>,
30
+ columnKey: string
31
+ ): FieldDTO => {
32
+ return columns[columnKey].field
33
+ ? {
34
+ fieldName: columns[columnKey].field?.fieldName ?? columnKey,
35
+ fieldAlias: columnKey,
36
+ }
37
+ : {
38
+ fieldName: columnKey,
39
+ fieldAlias: columnKey,
40
+ };
41
+ };
42
+ const getFirstColumnField = <R,>(columns: DataGridColumns<R>): FieldDTO => {
43
+ return getColumnField(columns, Object.keys(columns)[0]);
44
+ };
45
+
46
+ export const AdvancedRequestDataGrid = <R,>(
47
+ props: AdvancedRequestDataGridProps<R>
48
+ ) => {
49
+ const currentRows = useRef<R[]>([]);
50
+ const [rows, setRows] = useState<R[]>([]);
51
+ const [start, setStart] = useState(0);
52
+ const [length, setLength] = useState(50);
53
+ const [total, setTotal] = useState(-1);
54
+ const advancedRequest = useAdvancedRequestHandler<R>();
55
+
56
+ const [conditions, setConditions] = useState<ConditionDTO[]>([]);
57
+ const [orderBy, setOrderBy] = useState<OrderByDTO[]>(
58
+ props.orderBy ?? [
59
+ {
60
+ field: getFirstColumnField(props.columns),
61
+ direction: 'ASC',
62
+ },
63
+ ]
64
+ );
65
+
66
+ const refresh = useCallback(() => {
67
+ setRows([]);
68
+ setStart(0);
69
+ setLength(50);
70
+ setTotal(-1);
71
+ }, []);
72
+
73
+ const onFiltersChanged = useCallback((filters: DataGridFilters<R>) => {
74
+ console.log('filters changed', filters);
75
+ const newConditions = convertFiltersToConditions(filters);
76
+ console.log('new conditions:', newConditions);
77
+ setTotal(-1);
78
+ setConditions(newConditions);
79
+ }, []);
80
+
81
+ const onSortsChanged = useCallback(
82
+ (sorts: Record<string, DataGridSort>) => {
83
+ console.log('sorts changed', sorts);
84
+ refresh();
85
+ setOrderBy(
86
+ Object.entries(sorts).map(
87
+ ([columnKey, direction]) =>
88
+ ({
89
+ field: getColumnField(props.columns, columnKey),
90
+ direction: direction.toUpperCase(),
91
+ } as OrderByDTO)
92
+ )
93
+ );
94
+ },
95
+ [props.columns, refresh]
96
+ );
97
+
98
+ const loadRows = useRef(
99
+ debounce(
100
+ (
101
+ columns: DataGridColumns<R>,
102
+ conditions: ConditionDTO[],
103
+ orderBy: OrderByDTO[],
104
+ start: number,
105
+ length: number,
106
+ getTotal = false
107
+ ) => {
108
+ advancedRequest(
109
+ getAdvancedRequestDto({
110
+ type: props.type,
111
+ columns,
112
+ conditions,
113
+ orderBy,
114
+ start,
115
+ length,
116
+ getTotal,
117
+ })
118
+ ).then((response) => {
119
+ if (getTotal) {
120
+ currentRows.current = Array(response.total).fill(null);
121
+ if (getTotal) setTotal(response.total ?? 0);
122
+ }
123
+ const parsedRows = response.data.map(
124
+ props.parser ?? ((row) => row as R)
125
+ );
126
+ currentRows.current.splice(start, length, ...parsedRows);
127
+ setRows([...currentRows.current]);
128
+ });
129
+ },
130
+ 100
131
+ )
132
+ );
133
+
134
+ const loadFilterValues = useCallback(
135
+ (columnKey: string) => {
136
+ return advancedRequest({
137
+ fields: [
138
+ {
139
+ fieldName: columnKey,
140
+ },
141
+ ],
142
+ conditions: [
143
+ ...(props.conditions ?? []),
144
+ ...conditions,
145
+ {
146
+ field: {
147
+ fieldName: 'DeletedAt',
148
+ },
149
+ operator: 'isNull' as const,
150
+ },
151
+ ].filter(
152
+ (condition) =>
153
+ (condition.field.fieldAlias ?? condition.field.fieldName) !==
154
+ columnKey
155
+ ),
156
+ orderBy: [
157
+ {
158
+ field: { fieldName: columnKey },
159
+ direction: 'ASC',
160
+ },
161
+ ],
162
+ type: props.type,
163
+ getTotal: false,
164
+ unique: true,
165
+ }).then((response) => {
166
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
167
+ return response.data.map((row: any) => row[columnKey]);
168
+ });
169
+ },
170
+ [advancedRequest, conditions, props.conditions, props.type]
171
+ );
172
+
173
+ useEffect(
174
+ () =>
175
+ loadRows.current(
176
+ props.columns,
177
+ [...(props.conditions ?? []), ...(conditions ?? [])],
178
+ orderBy,
179
+ start,
180
+ length,
181
+ total < 0
182
+ ),
183
+ [props.columns, conditions, orderBy, start, length, total, props.conditions]
184
+ );
185
+
186
+ const loadCopyRows = useCallback(
187
+ () =>
188
+ advancedRequest(
189
+ getAdvancedRequestDto({
190
+ type: props.type,
191
+ columns: props.columns,
192
+ conditions: [...(props.conditions ?? []), ...(conditions ?? [])],
193
+ orderBy,
194
+ start: 0,
195
+ length: total,
196
+ })
197
+ ).then((response) =>
198
+ response.data.map(props.parser ?? ((row) => row as R))
199
+ ),
200
+ [
201
+ advancedRequest,
202
+ conditions,
203
+ orderBy,
204
+ props.columns,
205
+ props.conditions,
206
+ props.parser,
207
+ props.type,
208
+ total,
209
+ ]
210
+ );
211
+
212
+ const onVisibleRowsChanged = useCallback(
213
+ (newStart: number, newLength: number) => {
214
+ if (newStart !== start || newLength !== length) {
215
+ setStart(newStart);
216
+ setLength(newLength);
217
+ }
218
+ },
219
+ [length, start]
220
+ );
221
+
222
+ return (
223
+ <DataGrid
224
+ onVisibleRowsChange={onVisibleRowsChanged}
225
+ filter={false}
226
+ sort={false}
227
+ onFiltersChanged={onFiltersChanged}
228
+ onSortsChanged={onSortsChanged}
229
+ filterValuesLoader={loadFilterValues}
230
+ rows={rows}
231
+ loadCopyRows={loadCopyRows}
232
+ refresh={refresh}
233
+ {...props}
234
+ />
235
+ );
236
+ };
@@ -0,0 +1,78 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
3
+
4
+ import * as styles from './styles';
5
+
6
+ import { DataGridCellProps, DataGridColumn, DataGridFilterType } from './types';
7
+ import { MouseEvent, useCallback } from 'react';
8
+
9
+ import { DataGridEditableCell } from './DataGridEditableCell';
10
+ import { join } from 'lodash';
11
+ import { useDataGridContext } from './hooks';
12
+
13
+ const defaultRender = <R,>(
14
+ col: DataGridColumn<R, DataGridFilterType | undefined>,
15
+ row: R
16
+ ) => {
17
+ const value = col.propertyName ? row[col.propertyName] : '';
18
+ return !value ? '' : String(value);
19
+ };
20
+
21
+ export const DataGridCell = <R,>({
22
+ row,
23
+ rowIndex,
24
+ columnKey,
25
+ columnIndex,
26
+ column,
27
+ context,
28
+ className,
29
+ style,
30
+ }: DataGridCellProps<R>) => {
31
+ const {
32
+ name,
33
+ editable,
34
+ editingCell = [-1, -1],
35
+ setEditingCell,
36
+ onRowDoubleClick,
37
+ } = useDataGridContext(context);
38
+ const isEditable =
39
+ !!editable && !!column.editable && column.type && column.getter;
40
+ const isEditing =
41
+ isEditable && editingCell[0] === rowIndex && editingCell[1] === columnIndex;
42
+
43
+ const onDoubleClick = useCallback(
44
+ (e: MouseEvent) => {
45
+ e.stopPropagation();
46
+ e.preventDefault();
47
+ if (isEditable) {
48
+ setEditingCell([rowIndex, columnIndex]);
49
+ } else onRowDoubleClick?.(row, e);
50
+ },
51
+ [columnIndex, isEditable, onRowDoubleClick, row, rowIndex, setEditingCell]
52
+ );
53
+
54
+ if (isEditing) {
55
+ return (
56
+ <DataGridEditableCell
57
+ key={`${name}-${rowIndex}-${columnIndex}`}
58
+ row={row}
59
+ rowIndex={rowIndex}
60
+ columnKey={columnKey}
61
+ columnIndex={columnIndex}
62
+ column={column}
63
+ context={context}
64
+ />
65
+ );
66
+ }
67
+
68
+ return (
69
+ <styles.DataGridCell
70
+ key={`${name}-${rowIndex}-${columnIndex}`}
71
+ className={join([className, column.className, column.bodyClassName], ' ')}
72
+ onDoubleClick={onDoubleClick}
73
+ style={style}
74
+ >
75
+ {(column.render ?? defaultRender)(column, row)}
76
+ </styles.DataGridCell>
77
+ );
78
+ };
@@ -0,0 +1,14 @@
1
+ import { DataGridColumnKeyValuePair, DataGridColumns } from '../types';
2
+
3
+ export const normalizeColumnsOrders = <R>(
4
+ columns: DataGridColumns<R> | DataGridColumnKeyValuePair<R>[]
5
+ ) =>
6
+ (Array.isArray(columns) ? columns : Object.entries(columns)).map<
7
+ DataGridColumnKeyValuePair<R>
8
+ >(([key, column], index) => [
9
+ key,
10
+ {
11
+ ...column,
12
+ order: index,
13
+ },
14
+ ]);
@@ -0,0 +1,58 @@
1
+ import { useCallback, useContext, useMemo, useState } from 'react';
2
+
3
+ import { Button } from '../../../forms';
4
+ import { DataGridColumnsEditor } from '.';
5
+ import { DataGridContext } from '../types';
6
+ import { Modal } from '../../../layout/Modal';
7
+ import { mapValues } from 'lodash';
8
+
9
+ export const useDataGridColumnsModal = <R,>(context: DataGridContext<R>) => {
10
+ const [isVisible, setIsVisible] = useState(false);
11
+ const { columns, setSettings, saveSettings } = useContext(context);
12
+ const [currentColumns, setCurrentColumns] = useState(columns);
13
+
14
+ const openModal = useCallback(() => {
15
+ setIsVisible(true);
16
+ }, []);
17
+ const closeModal = useCallback(() => {
18
+ setIsVisible(false);
19
+ }, []);
20
+
21
+ const onApplyClicked = useCallback(() => {
22
+ const newSettings = mapValues(currentColumns, (col) => ({
23
+ order: col.order ?? 0,
24
+ width: col.width ?? 150,
25
+ }));
26
+ setSettings(() => newSettings);
27
+ saveSettings(newSettings);
28
+ closeModal();
29
+ }, [currentColumns, closeModal, saveSettings, setSettings]);
30
+
31
+ const modal = useMemo(
32
+ () =>
33
+ isVisible ? (
34
+ <Modal $width={600} $height={400}>
35
+ <Modal.Header>Paramètres des colonnes</Modal.Header>
36
+ <Modal.Content>
37
+ <DataGridColumnsEditor
38
+ columns={currentColumns}
39
+ onColumnsChanged={setCurrentColumns}
40
+ />
41
+ </Modal.Content>
42
+ <Modal.Footer>
43
+ <Button onClick={closeModal}>Annuler</Button>
44
+ <Button
45
+ color="primary"
46
+ style={{ marginLeft: 'auto' }}
47
+ onClick={onApplyClicked}
48
+ >
49
+ Appliquer
50
+ </Button>
51
+ </Modal.Footer>
52
+ </Modal>
53
+ ) : null,
54
+ [closeModal, currentColumns, isVisible, onApplyClicked]
55
+ );
56
+
57
+ return { openModal, closeModal, modal };
58
+ };