@liorian/sdk 0.28.0-alpha.56010ca

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 (362) hide show
  1. package/README.md +483 -0
  2. package/package.json +94 -0
  3. package/schemas/module.schema.json +818 -0
  4. package/src/application/index.ts +3 -0
  5. package/src/application/module-instance.ts +36 -0
  6. package/src/application/service/auth-api-service.ts +291 -0
  7. package/src/application/service/auth-user.service.ts +108 -0
  8. package/src/application/service/index.ts +12 -0
  9. package/src/application/service/module-activation-api.service.ts +105 -0
  10. package/src/application/service/notifications-api-service.ts +38 -0
  11. package/src/application/service/notifications-push.service.ts +299 -0
  12. package/src/application/service/notifications-socket-service.ts +76 -0
  13. package/src/application/service/organizations-api-service.ts +104 -0
  14. package/src/application/service/otp-api-service.ts +11 -0
  15. package/src/application/service/storage-api-service.ts +77 -0
  16. package/src/application/service/storefront-api.service.ts +72 -0
  17. package/src/application/service/user-preferences-api.service.ts +57 -0
  18. package/src/domain/config/app.config.ts +35 -0
  19. package/src/domain/config/auth.config.ts +30 -0
  20. package/src/domain/config/index.ts +4 -0
  21. package/src/domain/config/logo.config.ts +17 -0
  22. package/src/domain/entities/activities.interface.ts +18 -0
  23. package/src/domain/entities/catalog.interface.ts +96 -0
  24. package/src/domain/entities/index.ts +13 -0
  25. package/src/domain/entities/media.ts +22 -0
  26. package/src/domain/entities/module-activation.interface.ts +173 -0
  27. package/src/domain/entities/module.interface.ts +101 -0
  28. package/src/domain/entities/notification.interface.ts +23 -0
  29. package/src/domain/entities/objectable.type.ts +3 -0
  30. package/src/domain/entities/organization.interface.ts +81 -0
  31. package/src/domain/entities/user-auth.interface.ts +17 -0
  32. package/src/domain/entities/user-phone.interface.ts +11 -0
  33. package/src/domain/entities/user-profile.interface.ts +23 -0
  34. package/src/domain/entities/user.interface.ts +79 -0
  35. package/src/domain/enums/coloring.enum.ts +6 -0
  36. package/src/domain/enums/domains.enum.ts +282 -0
  37. package/src/domain/enums/index.ts +8 -0
  38. package/src/domain/enums/module-category.enum.ts +57 -0
  39. package/src/domain/enums/module.enum.ts +97 -0
  40. package/src/domain/enums/routine.enum.ts +12 -0
  41. package/src/domain/enums/user-profile.enum.ts +25 -0
  42. package/src/domain/enums/user-status.enum.ts +7 -0
  43. package/src/domain/index.ts +6 -0
  44. package/src/domain/typing/auth-caches.ts +12 -0
  45. package/src/domain/typing/auth-oauth.types.ts +172 -0
  46. package/src/domain/typing/devise.ts +2 -0
  47. package/src/domain/typing/index.ts +10 -0
  48. package/src/domain/typing/response.ts +30 -0
  49. package/src/domain/typing/routine.types.ts +113 -0
  50. package/src/domain/typing/session.interface.ts +28 -0
  51. package/src/domain/typing/statisticals.ts +11 -0
  52. package/src/domain/typing/user-media-upload.ts +9 -0
  53. package/src/domain/typing/values.ts +6 -0
  54. package/src/index.tsx +168 -0
  55. package/src/infrastructure/capabilities/cache-storage/capability.ts +129 -0
  56. package/src/infrastructure/capabilities/cache-storage/enum.ts +5 -0
  57. package/src/infrastructure/capabilities/cache-storage/index.ts +4 -0
  58. package/src/infrastructure/capabilities/cache-storage/types.ts +13 -0
  59. package/src/infrastructure/capabilities/index.ts +3 -0
  60. package/src/infrastructure/capabilities/stackable/capability.ts +55 -0
  61. package/src/infrastructure/capabilities/stackable/index.ts +3 -0
  62. package/src/infrastructure/capabilities/stackable/types.ts +24 -0
  63. package/src/infrastructure/common-classname.constant.ts +4 -0
  64. package/src/infrastructure/data/countries.ts +208 -0
  65. package/src/infrastructure/data/gender.ts +5 -0
  66. package/src/infrastructure/data/index.ts +3 -0
  67. package/src/infrastructure/dataset/index.ts +3 -0
  68. package/src/infrastructure/dataset/sign-in.dataset.ts +21 -0
  69. package/src/infrastructure/dataset/sign-up.dataset.ts +64 -0
  70. package/src/infrastructure/hooks/index.ts +10 -0
  71. package/src/infrastructure/hooks/use-activity-lock-draft.ts +69 -0
  72. package/src/infrastructure/hooks/use-auth.ts +24 -0
  73. package/src/infrastructure/hooks/use-elastic-interaction.ts +180 -0
  74. package/src/infrastructure/hooks/use-is-desktop.ts +25 -0
  75. package/src/infrastructure/hooks/use-is-tauri.ts +17 -0
  76. package/src/infrastructure/hooks/use-mobile.ts +19 -0
  77. package/src/infrastructure/hooks/use-notifications.ts +128 -0
  78. package/src/infrastructure/hooks/use-recent-colors.ts +113 -0
  79. package/src/infrastructure/hooks/use-recent-modules.ts +76 -0
  80. package/src/infrastructure/index.tsx +11 -0
  81. package/src/infrastructure/library/design-system.ts +95 -0
  82. package/src/infrastructure/library/index.tsx +5 -0
  83. package/src/infrastructure/library/motion-utils.ts +77 -0
  84. package/src/infrastructure/library/motion.tsx +31 -0
  85. package/src/infrastructure/library/scroll-progress.tsx +93 -0
  86. package/src/infrastructure/providers/auth-guard.provider.tsx +47 -0
  87. package/src/infrastructure/providers/auth.provider.tsx +168 -0
  88. package/src/infrastructure/providers/index.tsx +8 -0
  89. package/src/infrastructure/providers/module-usage.provider.tsx +95 -0
  90. package/src/infrastructure/providers/modules-guard.provider.tsx +64 -0
  91. package/src/infrastructure/providers/modules-routines.provider.tsx +33 -0
  92. package/src/infrastructure/providers/modules-switcher.provider.tsx +25 -0
  93. package/src/infrastructure/providers/query.provider.tsx +27 -0
  94. package/src/infrastructure/routines/__tests__/routine.test.ts +368 -0
  95. package/src/infrastructure/routines/index.tsx +3 -0
  96. package/src/infrastructure/routines/routine.hook.ts +121 -0
  97. package/src/infrastructure/routines/routine.ts +283 -0
  98. package/src/infrastructure/routines/routine.tsx +283 -0
  99. package/src/infrastructure/stores/activity-lock.store.ts +22 -0
  100. package/src/infrastructure/stores/auth-user-connected.store.ts +24 -0
  101. package/src/infrastructure/stores/dataset.store.ts +106 -0
  102. package/src/infrastructure/stores/index.ts +6 -0
  103. package/src/infrastructure/stores/module.store.ts +266 -0
  104. package/src/infrastructure/stores/upload.store.ts +198 -0
  105. package/src/infrastructure/utilities/access-label.util.ts +158 -0
  106. package/src/infrastructure/utilities/activities.util.tsx +54 -0
  107. package/src/infrastructure/utilities/activity-lock.service.ts +263 -0
  108. package/src/infrastructure/utilities/activity-tracker.service.ts +205 -0
  109. package/src/infrastructure/utilities/api-service.ts +237 -0
  110. package/src/infrastructure/utilities/auth-logout.util.ts +23 -0
  111. package/src/infrastructure/utilities/classname.util.ts +7 -0
  112. package/src/infrastructure/utilities/encryption.service.ts +125 -0
  113. package/src/infrastructure/utilities/form-snapshot.service.ts +304 -0
  114. package/src/infrastructure/utilities/format.util.ts +40 -0
  115. package/src/infrastructure/utilities/index.tsx +23 -0
  116. package/src/infrastructure/utilities/media-label.service.ts +47 -0
  117. package/src/infrastructure/utilities/modules.ts +11 -0
  118. package/src/infrastructure/utilities/permission.util.ts +22 -0
  119. package/src/infrastructure/utilities/push-permission.util.ts +43 -0
  120. package/src/infrastructure/utilities/route-access.ts +38 -0
  121. package/src/infrastructure/utilities/socket-service.ts +123 -0
  122. package/src/infrastructure/utilities/sso-auth.util.ts +188 -0
  123. package/src/infrastructure/utilities/stringable.util.ts +16 -0
  124. package/src/infrastructure/utilities/strings.util.ts +18 -0
  125. package/src/infrastructure/utilities/tauri.util.ts +15 -0
  126. package/src/infrastructure/utilities/utils.ts +6 -0
  127. package/src/infrastructure/utilities/values.ts +5 -0
  128. package/src/presentation/8starlabs-ui/button.tsx +94 -0
  129. package/src/presentation/8starlabs-ui/flip-clock.tsx +368 -0
  130. package/src/presentation/8starlabs-ui/heatmap.tsx +430 -0
  131. package/src/presentation/8starlabs-ui/hooks/index.tsx +2 -0
  132. package/src/presentation/8starlabs-ui/hooks/use-mobile.ts +21 -0
  133. package/src/presentation/8starlabs-ui/index.tsx +20 -0
  134. package/src/presentation/8starlabs-ui/json-viewer.tsx +972 -0
  135. package/src/presentation/8starlabs-ui/marquee.tsx +134 -0
  136. package/src/presentation/8starlabs-ui/partition-bar.tsx +198 -0
  137. package/src/presentation/8starlabs-ui/scroll-fade.tsx +158 -0
  138. package/src/presentation/8starlabs-ui/status-indicator.tsx +86 -0
  139. package/src/presentation/8starlabs-ui/system-banner.tsx +50 -0
  140. package/src/presentation/8starlabs-ui/timeline.tsx +576 -0
  141. package/src/presentation/8starlabs-ui/transport-badge.tsx +249 -0
  142. package/src/presentation/8starlabs-ui/ui/copy-button.tsx +60 -0
  143. package/src/presentation/8starlabs-ui/ui/index.tsx +2 -0
  144. package/src/presentation/analytics-section.tsx +85 -0
  145. package/src/presentation/app-sidebar.tsx +234 -0
  146. package/src/presentation/charts/area-widget.chart-skeleton.tsx +61 -0
  147. package/src/presentation/charts/area-widget.chart.tsx +128 -0
  148. package/src/presentation/charts/chart-widgets.types.ts +81 -0
  149. package/src/presentation/charts/index.tsx +16 -0
  150. package/src/presentation/charts/line-widget.chart-skeleton.tsx +64 -0
  151. package/src/presentation/charts/line-widget.chart.tsx +105 -0
  152. package/src/presentation/charts/pie-widget.chart-skeleton.tsx +56 -0
  153. package/src/presentation/charts/pie-widget.chart.tsx +168 -0
  154. package/src/presentation/charts/radar-widget.chart-skeleton.tsx +67 -0
  155. package/src/presentation/charts/radar-widget.chart.tsx +80 -0
  156. package/src/presentation/charts/radial-stacked-widget.chart-skeleton.tsx +66 -0
  157. package/src/presentation/charts/radial-stacked-widget.chart.tsx +120 -0
  158. package/src/presentation/charts/radial-widget.chart-skeleton.tsx +61 -0
  159. package/src/presentation/charts/radial-widget.chart.tsx +87 -0
  160. package/src/presentation/charts/tooltip-widget.chart-skeleton.tsx +64 -0
  161. package/src/presentation/charts/tooltip-widget.chart.tsx +89 -0
  162. package/src/presentation/components/activity-actions.tsx +20 -0
  163. package/src/presentation/components/activity-container.tsx +55 -0
  164. package/src/presentation/components/activity-content.tsx +20 -0
  165. package/src/presentation/components/activity-descriptor-parser.tsx +37 -0
  166. package/src/presentation/components/activity-header.tsx +20 -0
  167. package/src/presentation/components/activity-loader.tsx +19 -0
  168. package/src/presentation/components/activity-title.tsx +32 -0
  169. package/src/presentation/components/activity.tsx +22 -0
  170. package/src/presentation/components/auth/index.tsx +4 -0
  171. package/src/presentation/components/auth/sso-callback.view.tsx +44 -0
  172. package/src/presentation/components/auth/sso-disconnect.view.tsx +41 -0
  173. package/src/presentation/components/auth/sso-sign-in.view.tsx +29 -0
  174. package/src/presentation/components/auth-lock-screen.tsx +309 -0
  175. package/src/presentation/components/auth-session.view.tsx +17 -0
  176. package/src/presentation/components/data-table.tsx +814 -0
  177. package/src/presentation/components/dynamic-icon.tsx +16 -0
  178. package/src/presentation/components/floating-upload.tsx +291 -0
  179. package/src/presentation/components/index.tsx +40 -0
  180. package/src/presentation/components/local-time.tsx +170 -0
  181. package/src/presentation/components/markdown-parser.tsx +201 -0
  182. package/src/presentation/components/message-scroller.tsx +131 -0
  183. package/src/presentation/components/module-first-access-config.view.tsx +181 -0
  184. package/src/presentation/components/module-first-access-pending.view.tsx +38 -0
  185. package/src/presentation/components/module-guard.tsx +34 -0
  186. package/src/presentation/components/modules-first-access.guard.tsx +88 -0
  187. package/src/presentation/components/modules-guard-forbidden.tsx +46 -0
  188. package/src/presentation/components/notification-details.modal.tsx +145 -0
  189. package/src/presentation/components/notification-item.tsx +127 -0
  190. package/src/presentation/components/notifications-popover.tsx +128 -0
  191. package/src/presentation/components/push-notifications.provider.tsx +65 -0
  192. package/src/presentation/components/upload-progress-dialog.tsx +140 -0
  193. package/src/presentation/components/waiting-bar.tsx +22 -0
  194. package/src/presentation/components/waiting-section.tsx +15 -0
  195. package/src/presentation/components/waiting.tsx +14 -0
  196. package/src/presentation/data-grid/data-grid-empty.tsx +24 -0
  197. package/src/presentation/data-grid/data-grid-search-engine.tsx +32 -0
  198. package/src/presentation/data-grid/data-grid.tsx +892 -0
  199. package/src/presentation/data-grid/index.tsx +4 -0
  200. package/src/presentation/form-screen.tsx +95 -0
  201. package/src/presentation/icons/custom.tsx +20 -0
  202. package/src/presentation/icons/glyphIcons.tsx +53 -0
  203. package/src/presentation/icons/icons.enum.ts +4 -0
  204. package/src/presentation/icons/icons.util.ts +6 -0
  205. package/src/presentation/icons/index.tsx +8 -0
  206. package/src/presentation/icons/lucide.tsx +17 -0
  207. package/src/presentation/icons/remix.tsx +33 -0
  208. package/src/presentation/icons/types.ts +27 -0
  209. package/src/presentation/index.tsx +45 -0
  210. package/src/presentation/modals/components/ModalBox.tsx +74 -0
  211. package/src/presentation/modals/components/ModalPortal.tsx +31 -0
  212. package/src/presentation/modals/components/ModalStepper.tsx +319 -0
  213. package/src/presentation/modals/components/ModalWrapper.tsx +65 -0
  214. package/src/presentation/modals/components/index.tsx +5 -0
  215. package/src/presentation/modals/hooks/index.ts +2 -0
  216. package/src/presentation/modals/hooks/useModal.ts +38 -0
  217. package/src/presentation/modals/index.tsx +5 -0
  218. package/src/presentation/modals/stores/index.ts +2 -0
  219. package/src/presentation/modals/stores/useModalStore.ts +90 -0
  220. package/src/presentation/modals/types/index.ts +2 -0
  221. package/src/presentation/modals/types/modal.type.ts +33 -0
  222. package/src/presentation/module-menubar.tsx +300 -0
  223. package/src/presentation/module-widget.tsx +233 -0
  224. package/src/presentation/nav-documents.tsx +89 -0
  225. package/src/presentation/nav-main.tsx +62 -0
  226. package/src/presentation/nav-secondary.tsx +41 -0
  227. package/src/presentation/nav-user.tsx +109 -0
  228. package/src/presentation/permission-action-badge.tsx +35 -0
  229. package/src/presentation/reui/index.tsx +3 -0
  230. package/src/presentation/reui/stepper.tsx +508 -0
  231. package/src/presentation/reui/timeline.tsx +226 -0
  232. package/src/presentation/sheets/index.tsx +2 -0
  233. package/src/presentation/sheets/legacy-sheet-header.tsx +0 -0
  234. package/src/presentation/sheets/legacy-sheet.tsx +37 -0
  235. package/src/presentation/size.enum.ts +19 -0
  236. package/src/presentation/system/index.tsx +3 -0
  237. package/src/presentation/system/logo.theme.tsx +21 -0
  238. package/src/presentation/system/types.ts +10 -0
  239. package/src/presentation/theme/index.tsx +6 -0
  240. package/src/presentation/theme/prefer-color-scheme.tsx +50 -0
  241. package/src/presentation/theme/switch-color-scheme.tsx +16 -0
  242. package/src/presentation/theme/theme-switcher-button.tsx +20 -0
  243. package/src/presentation/theme/theme.enum.ts +4 -0
  244. package/src/presentation/theme/theme.store.ts +87 -0
  245. package/src/presentation/themes/index.tsx +2 -0
  246. package/src/presentation/themes/katon/dashboard-layout.tsx +1080 -0
  247. package/src/presentation/themes/katon/edge-section.tsx +19 -0
  248. package/src/presentation/themes/katon/header-menubar.tsx +270 -0
  249. package/src/presentation/themes/katon/header-modules-available.tsx +44 -0
  250. package/src/presentation/themes/katon/header-modules-recents.tsx +52 -0
  251. package/src/presentation/themes/katon/header-modules-store.tsx +25 -0
  252. package/src/presentation/themes/katon/header-options.tsx +13 -0
  253. package/src/presentation/themes/katon/header-organization-select.tsx +146 -0
  254. package/src/presentation/themes/katon/header-routines.tsx +74 -0
  255. package/src/presentation/themes/katon/header-tasks-connected-user.tsx +150 -0
  256. package/src/presentation/themes/katon/index.tsx +16 -0
  257. package/src/presentation/themes/katon/main-wrapper.tsx +34 -0
  258. package/src/presentation/themes/katon/module-item-link.tsx +32 -0
  259. package/src/presentation/themes/katon/view-frame.tsx +25 -0
  260. package/src/presentation/themes/katon/view-helmet.tsx +53 -0
  261. package/src/presentation/themes/katon/view-status.tsx +32 -0
  262. package/src/presentation/themes/katon/view-wrapper.tsx +15 -0
  263. package/src/presentation/themes/katon/view.tsx +42 -0
  264. package/src/presentation/ui/accordion-multiselect.tsx +206 -0
  265. package/src/presentation/ui/accordion.tsx +81 -0
  266. package/src/presentation/ui/alert-dialog.tsx +199 -0
  267. package/src/presentation/ui/alert.tsx +76 -0
  268. package/src/presentation/ui/aspect-ratio.tsx +11 -0
  269. package/src/presentation/ui/attachment.tsx +204 -0
  270. package/src/presentation/ui/avatar.tsx +112 -0
  271. package/src/presentation/ui/badge.tsx +49 -0
  272. package/src/presentation/ui/breadcrumb.tsx +122 -0
  273. package/src/presentation/ui/bubble.tsx +125 -0
  274. package/src/presentation/ui/button-group.tsx +83 -0
  275. package/src/presentation/ui/button.tsx +87 -0
  276. package/src/presentation/ui/calendar.tsx +222 -0
  277. package/src/presentation/ui/card.tsx +106 -0
  278. package/src/presentation/ui/carousel.tsx +242 -0
  279. package/src/presentation/ui/chart.tsx +373 -0
  280. package/src/presentation/ui/checkbox.tsx +33 -0
  281. package/src/presentation/ui/clickable.tsx +58 -0
  282. package/src/presentation/ui/collapsible.tsx +33 -0
  283. package/src/presentation/ui/color-swatch-selector.tsx +81 -0
  284. package/src/presentation/ui/combobox.tsx +299 -0
  285. package/src/presentation/ui/command.tsx +195 -0
  286. package/src/presentation/ui/context-menu.tsx +263 -0
  287. package/src/presentation/ui/dialog.tsx +168 -0
  288. package/src/presentation/ui/direction.tsx +22 -0
  289. package/src/presentation/ui/drawer.tsx +134 -0
  290. package/src/presentation/ui/dropdown-menu.tsx +269 -0
  291. package/src/presentation/ui/empty.tsx +104 -0
  292. package/src/presentation/ui/field.tsx +238 -0
  293. package/src/presentation/ui/granularity-selector.tsx +58 -0
  294. package/src/presentation/ui/hover-card.tsx +44 -0
  295. package/src/presentation/ui/index.tsx +74 -0
  296. package/src/presentation/ui/input-group.tsx +156 -0
  297. package/src/presentation/ui/input-otp.tsx +87 -0
  298. package/src/presentation/ui/input.tsx +19 -0
  299. package/src/presentation/ui/item.tsx +196 -0
  300. package/src/presentation/ui/kpi-card.tsx +203 -0
  301. package/src/presentation/ui/label-selector.tsx +100 -0
  302. package/src/presentation/ui/label.tsx +24 -0
  303. package/src/presentation/ui/legacy-birth-date-input.tsx +43 -0
  304. package/src/presentation/ui/legacy-color-picker/index.tsx +42 -0
  305. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.content.tsx +37 -0
  306. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.context.tsx +42 -0
  307. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.hex-input.tsx +97 -0
  308. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.picker.tsx +266 -0
  309. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.presets.ts +22 -0
  310. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.quick-list.tsx +49 -0
  311. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.recent.tsx +43 -0
  312. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.swatches.tsx +111 -0
  313. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.trigger.tsx +128 -0
  314. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.tsx +110 -0
  315. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.types.ts +1 -0
  316. package/src/presentation/ui/legacy-color-picker/legacy-color-picker.utils.ts +114 -0
  317. package/src/presentation/ui/legacy-country-input.tsx +171 -0
  318. package/src/presentation/ui/legacy-gender-input.tsx +22 -0
  319. package/src/presentation/ui/legacy-input.tsx +106 -0
  320. package/src/presentation/ui/legacy-phone-input.tsx +213 -0
  321. package/src/presentation/ui/legacy-select-input.tsx +114 -0
  322. package/src/presentation/ui/legacy-text-area.tsx +111 -0
  323. package/src/presentation/ui/list-items.tsx +59 -0
  324. package/src/presentation/ui/marker.tsx +69 -0
  325. package/src/presentation/ui/media-player/index.tsx +12 -0
  326. package/src/presentation/ui/media-player/media-player.context.tsx +36 -0
  327. package/src/presentation/ui/media-player/media-player.tsx +167 -0
  328. package/src/presentation/ui/media-player/player-controls.tsx +207 -0
  329. package/src/presentation/ui/media-player/players/audio-player.tsx +78 -0
  330. package/src/presentation/ui/media-player/players/index.tsx +4 -0
  331. package/src/presentation/ui/media-player/players/video-player.tsx +193 -0
  332. package/src/presentation/ui/media-player/players/voice-note-player.tsx +108 -0
  333. package/src/presentation/ui/media-player/use-media-player.hook.ts +263 -0
  334. package/src/presentation/ui/menubar.tsx +281 -0
  335. package/src/presentation/ui/message.tsx +92 -0
  336. package/src/presentation/ui/navigation-menu.tsx +172 -0
  337. package/src/presentation/ui/pagination.tsx +129 -0
  338. package/src/presentation/ui/popover.tsx +89 -0
  339. package/src/presentation/ui/progress.tsx +31 -0
  340. package/src/presentation/ui/resizable.tsx +50 -0
  341. package/src/presentation/ui/select.tsx +192 -0
  342. package/src/presentation/ui/separator.tsx +28 -0
  343. package/src/presentation/ui/sheet.tsx +147 -0
  344. package/src/presentation/ui/sidebar.tsx +702 -0
  345. package/src/presentation/ui/skeleton.tsx +13 -0
  346. package/src/presentation/ui/slide-to-confirm.tsx +129 -0
  347. package/src/presentation/ui/slider.tsx +59 -0
  348. package/src/presentation/ui/sonner.tsx +58 -0
  349. package/src/presentation/ui/switch.tsx +33 -0
  350. package/src/presentation/ui/table.tsx +116 -0
  351. package/src/presentation/ui/tabs.tsx +90 -0
  352. package/src/presentation/ui/text-gradient.tsx +84 -0
  353. package/src/presentation/ui/textarea.tsx +18 -0
  354. package/src/presentation/ui/timeline-steps.tsx +235 -0
  355. package/src/presentation/ui/toggle-group.tsx +89 -0
  356. package/src/presentation/ui/toggle.tsx +47 -0
  357. package/src/presentation/ui/tooltip.tsx +57 -0
  358. package/src/presentation/uploading/index.tsx +3 -0
  359. package/src/presentation/uploading/media-upload-field.tsx +152 -0
  360. package/src/presentation/uploading/storage-media.tsx +210 -0
  361. package/src/styles.css +403 -0
  362. package/src/themes.css +1038 -0
@@ -0,0 +1,235 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "../../infrastructure/utilities/utils"
5
+
6
+ /* -----------------------------------------------------------------------------
7
+ * Timeline (root container)
8
+ * -------------------------------------------------------------------------- */
9
+
10
+ const timelineStepsVariants = cva("flex", {
11
+ variants: {
12
+ orientation: {
13
+ vertical: "flex-col",
14
+ horizontal: "flex-row overflow-x-auto",
15
+ },
16
+ position: {
17
+ left: "",
18
+ right: "",
19
+ alternate: "",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ orientation: "vertical",
24
+ position: "left",
25
+ },
26
+ })
27
+
28
+ interface TimelineStepsProps extends React.ComponentProps<"div">, VariantProps<typeof timelineStepsVariants> {}
29
+
30
+ function TimelineSteps({ className, orientation, position, ...props }: TimelineStepsProps) {
31
+ return (
32
+ <div
33
+ data-slot="timeline-steps"
34
+ data-orientation={orientation}
35
+ data-position={position}
36
+ className={cn(timelineStepsVariants({ orientation, position }), className)}
37
+ {...props}
38
+ />
39
+ )
40
+ }
41
+
42
+ /* -----------------------------------------------------------------------------
43
+ * TimelineItem
44
+ * -------------------------------------------------------------------------- */
45
+
46
+ const timelineStepsItemVariants = cva("relative flex flex-col", {
47
+ variants: {
48
+ orientation: {
49
+ vertical: "pb-8 last:pb-0",
50
+ horizontal: "flex-1 items-center",
51
+ },
52
+ status: {
53
+ default: "",
54
+ completed: "",
55
+ current: "",
56
+ upcoming: "opacity-60",
57
+ },
58
+ },
59
+ defaultVariants: {
60
+ orientation: "vertical",
61
+ status: "default",
62
+ },
63
+ })
64
+
65
+ interface TimelineStepsItemProps extends React.ComponentProps<"div">, VariantProps<typeof timelineStepsItemVariants> {}
66
+
67
+ function TimelineStepsItem({ className, orientation, status, ...props }: TimelineStepsItemProps) {
68
+ return (
69
+ <div
70
+ data-slot="timeline-steps-item"
71
+ data-status={status}
72
+ className={cn(timelineStepsItemVariants({ orientation, status }), className)}
73
+ {...props}
74
+ />
75
+ )
76
+ }
77
+
78
+ /* -----------------------------------------------------------------------------
79
+ * TimelineConnector (the line connecting items)
80
+ * -------------------------------------------------------------------------- */
81
+
82
+ const timelineStepsConnectorVariants = cva("", {
83
+ variants: {
84
+ orientation: {
85
+ vertical:
86
+ "absolute left-[calc(var(--timeline-steps-icon-size,2.5rem)/2)] top-[var(--timeline-steps-icon-size,2.5rem)] h-[calc(100%-var(--timeline-steps-icon-size,2.5rem))] w-px -translate-x-1/2",
87
+ horizontal: "absolute top-3 left-[calc(50%+0.75rem)] h-px w-[calc(100%-1.5rem)]",
88
+ },
89
+ variant: {
90
+ default: "bg-border",
91
+ dashed: "border-l border-dashed border-border bg-transparent",
92
+ dotted: "border-l border-dotted border-border bg-transparent",
93
+ },
94
+ status: {
95
+ default: "",
96
+ completed: "bg-primary",
97
+ current: "bg-gradient-to-b from-primary to-border",
98
+ upcoming: "bg-muted",
99
+ },
100
+ },
101
+ defaultVariants: {
102
+ orientation: "vertical",
103
+ variant: "default",
104
+ status: "default",
105
+ },
106
+ })
107
+
108
+ interface TimelineStepsConnectorProps
109
+ extends React.ComponentProps<"div">,
110
+ VariantProps<typeof timelineStepsConnectorVariants> {}
111
+
112
+ function TimelineStepsConnector({ className, orientation, variant, status, ...props }: TimelineStepsConnectorProps) {
113
+ return (
114
+ <div
115
+ data-slot="timeline-steps-connector"
116
+ aria-hidden="true"
117
+ className={cn(timelineStepsConnectorVariants({ orientation, variant, status }), className)}
118
+ {...props}
119
+ />
120
+ )
121
+ }
122
+
123
+ /* -----------------------------------------------------------------------------
124
+ * TimelineHeader (contains icon and title row)
125
+ * -------------------------------------------------------------------------- */
126
+
127
+ function TimelineStepsHeader({ className, ...props }: React.ComponentProps<"div">) {
128
+ return <div data-slot="timeline-steps-header" className={cn("flex items-center gap-3", className)} {...props} />
129
+ }
130
+
131
+ /* -----------------------------------------------------------------------------
132
+ * TimelineStepsIcon (the dot/icon indicator)
133
+ * -------------------------------------------------------------------------- */
134
+
135
+ const timelineStepsIconVariants = cva(
136
+ "relative z-10 flex shrink-0 items-center justify-center rounded-full border bg-background [--timeline-steps-icon-size:2.5rem]",
137
+ {
138
+ variants: {
139
+ size: {
140
+ sm: "size-6 [--timeline-steps-icon-size:1.5rem] [&>svg]:size-3",
141
+ default: "size-10 [--timeline-steps-icon-size:2.5rem] [&>svg]:size-4",
142
+ lg: "size-12 [--timeline-steps-icon-size:3rem] [&>svg]:size-5",
143
+ },
144
+ variant: {
145
+ default: "border-border text-muted-foreground",
146
+ primary: "border-primary bg-primary text-primary-foreground",
147
+ secondary: "border-secondary bg-secondary text-secondary-foreground",
148
+ destructive: "border-destructive bg-destructive text-destructive-foreground",
149
+ outline: "border-border bg-background text-foreground",
150
+ },
151
+ },
152
+ defaultVariants: {
153
+ size: "default",
154
+ variant: "default",
155
+ },
156
+ },
157
+ )
158
+
159
+ interface TimelineStepsIconProps extends React.ComponentProps<"div">, VariantProps<typeof timelineStepsIconVariants> {}
160
+
161
+ function TimelineStepsIcon({ className, size, variant, ...props }: TimelineStepsIconProps) {
162
+ return (
163
+ <div
164
+ data-slot="timeline-steps-icon"
165
+ className={cn(timelineStepsIconVariants({ size, variant }), className)}
166
+ {...props}
167
+ />
168
+ )
169
+ }
170
+
171
+ /* -----------------------------------------------------------------------------
172
+ * TimelineStepsContent (container for description, time, etc.)
173
+ * -------------------------------------------------------------------------- */
174
+
175
+ function TimelineStepsContent({ className, ...props }: React.ComponentProps<"div">) {
176
+ return (
177
+ <div
178
+ data-slot="timeline-steps-content"
179
+ className={cn("ms-[3.25rem] flex flex-col gap-1 pt-0.5 pb-2", className)}
180
+ {...props}
181
+ />
182
+ )
183
+ }
184
+
185
+ /* -----------------------------------------------------------------------------
186
+ * TimelineStepsTitle
187
+ * -------------------------------------------------------------------------- */
188
+
189
+ function TimelineStepsTitle({ className, ...props }: React.ComponentProps<"div">) {
190
+ return (
191
+ <div
192
+ data-slot="timeline-steps-title"
193
+ className={cn("text-foreground leading-none font-medium tracking-tight", className)}
194
+ {...props}
195
+ />
196
+ )
197
+ }
198
+
199
+ /* -----------------------------------------------------------------------------
200
+ * TimelineDescription
201
+ * -------------------------------------------------------------------------- */
202
+
203
+ function TimelineStepsDescription({ className, ...props }: React.ComponentProps<"div">) {
204
+ return (
205
+ <div data-slot="timeline-steps-description" className={cn("text-muted-foreground text-sm", className)} {...props} />
206
+ )
207
+ }
208
+
209
+ /* -----------------------------------------------------------------------------
210
+ * TimelineStepsTime (timestamp display)
211
+ * -------------------------------------------------------------------------- */
212
+
213
+ function TimelineStepsTime({ className, ...props }: React.ComponentProps<"time">) {
214
+ return <time data-slot="timeline-steps-time" className={cn("text-muted-foreground text-xs", className)} {...props} />
215
+ }
216
+
217
+ /* -----------------------------------------------------------------------------
218
+ * Exports
219
+ * -------------------------------------------------------------------------- */
220
+
221
+ export {
222
+ TimelineSteps,
223
+ TimelineStepsItem,
224
+ TimelineStepsConnector,
225
+ TimelineStepsHeader,
226
+ TimelineStepsIcon,
227
+ TimelineStepsContent,
228
+ TimelineStepsTitle,
229
+ TimelineStepsDescription,
230
+ TimelineStepsTime,
231
+ timelineStepsVariants,
232
+ timelineStepsItemVariants,
233
+ timelineStepsConnectorVariants,
234
+ timelineStepsIconVariants,
235
+ }
@@ -0,0 +1,89 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { type VariantProps } from "class-variance-authority"
5
+ import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
6
+
7
+ import { cn } from "../../infrastructure/utilities/utils"
8
+ import { toggleVariants } from "./toggle"
9
+
10
+ const ToggleGroupContext = React.createContext<
11
+ VariantProps<typeof toggleVariants> & {
12
+ spacing?: number
13
+ orientation?: "horizontal" | "vertical"
14
+ }
15
+ >({
16
+ size: "default",
17
+ variant: "default",
18
+ spacing: 2,
19
+ orientation: "horizontal",
20
+ })
21
+
22
+ function ToggleGroup({
23
+ className,
24
+ variant,
25
+ size,
26
+ spacing = 2,
27
+ orientation = "horizontal",
28
+ children,
29
+ ...props
30
+ }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
31
+ VariantProps<typeof toggleVariants> & {
32
+ spacing?: number
33
+ orientation?: "horizontal" | "vertical"
34
+ }) {
35
+ return (
36
+ <ToggleGroupPrimitive.Root
37
+ data-slot="toggle-group"
38
+ data-variant={variant}
39
+ data-size={size}
40
+ data-spacing={spacing}
41
+ data-orientation={orientation}
42
+ style={{ "--gap": spacing } as React.CSSProperties}
43
+ className={cn(
44
+ "group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
45
+ className
46
+ )}
47
+ {...props}
48
+ >
49
+ <ToggleGroupContext.Provider
50
+ value={{ variant, size, spacing, orientation }}
51
+ >
52
+ {children}
53
+ </ToggleGroupContext.Provider>
54
+ </ToggleGroupPrimitive.Root>
55
+ )
56
+ }
57
+
58
+ function ToggleGroupItem({
59
+ className,
60
+ children,
61
+ variant = "default",
62
+ size = "default",
63
+ ...props
64
+ }: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
65
+ VariantProps<typeof toggleVariants>) {
66
+ const context = React.useContext(ToggleGroupContext)
67
+
68
+ return (
69
+ <ToggleGroupPrimitive.Item
70
+ data-slot="toggle-group-item"
71
+ data-variant={context.variant || variant}
72
+ data-size={context.size || size}
73
+ data-spacing={context.spacing}
74
+ className={cn(
75
+ "shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
76
+ toggleVariants({
77
+ variant: context.variant || variant,
78
+ size: context.size || size,
79
+ }),
80
+ className
81
+ )}
82
+ {...props}
83
+ >
84
+ {children}
85
+ </ToggleGroupPrimitive.Item>
86
+ )
87
+ }
88
+
89
+ export { ToggleGroup, ToggleGroupItem }
@@ -0,0 +1,47 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+ import { Toggle as TogglePrimitive } from "radix-ui"
6
+
7
+ import { cn } from "../../infrastructure/utilities/utils"
8
+
9
+ const toggleVariants = cva(
10
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ default: "bg-transparent",
15
+ outline: "border border-input bg-transparent hover:bg-muted",
16
+ },
17
+ size: {
18
+ default:
19
+ "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
20
+ sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
21
+ lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
22
+ },
23
+ },
24
+ defaultVariants: {
25
+ variant: "default",
26
+ size: "default",
27
+ },
28
+ }
29
+ )
30
+
31
+ function Toggle({
32
+ className,
33
+ variant = "default",
34
+ size = "default",
35
+ ...props
36
+ }: React.ComponentProps<typeof TogglePrimitive.Root> &
37
+ VariantProps<typeof toggleVariants>) {
38
+ return (
39
+ <TogglePrimitive.Root
40
+ data-slot="toggle"
41
+ className={cn(toggleVariants({ variant, size, className }))}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ export { Toggle, toggleVariants }
@@ -0,0 +1,57 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Tooltip as TooltipPrimitive } from "radix-ui"
5
+
6
+ import { cn } from "../../infrastructure/utilities/utils"
7
+
8
+ function TooltipProvider({
9
+ delayDuration = 0,
10
+ ...props
11
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
12
+ return (
13
+ <TooltipPrimitive.Provider
14
+ data-slot="tooltip-provider"
15
+ delayDuration={delayDuration}
16
+ {...props}
17
+ />
18
+ )
19
+ }
20
+
21
+ function Tooltip({
22
+ ...props
23
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
24
+ return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
25
+ }
26
+
27
+ function TooltipTrigger({
28
+ ...props
29
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
30
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
31
+ }
32
+
33
+ function TooltipContent({
34
+ className,
35
+ sideOffset = 0,
36
+ children,
37
+ ...props
38
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
39
+ return (
40
+ <TooltipPrimitive.Portal>
41
+ <TooltipPrimitive.Content
42
+ data-slot="tooltip-content"
43
+ sideOffset={sideOffset}
44
+ className={cn(
45
+ "z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
46
+ className
47
+ )}
48
+ {...props}
49
+ >
50
+ {children}
51
+ <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
52
+ </TooltipPrimitive.Content>
53
+ </TooltipPrimitive.Portal>
54
+ )
55
+ }
56
+
57
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
@@ -0,0 +1,3 @@
1
+ // @liorian/sdk/presentation/uploading — media upload widgets.
2
+ export * from "./media-upload-field";
3
+ export * from "./storage-media";
@@ -0,0 +1,152 @@
1
+ import {UserMediaFieldConfig} from "../../domain/typing/user-media-upload";
2
+ import {MediaStorageInterface, MediaUploadOptions} from "../../domain/entities/media";
3
+ import {useEffect, useRef, useState} from "react";
4
+ import {useUploadStore} from "../../infrastructure/stores/upload.store";
5
+ import {CheckCircle2, FileText, ImageIcon, Trash2, Upload, X} from "lucide-react";
6
+ import {formatFileSize} from "../../infrastructure/utilities/format.util";
7
+ import {MediaLabelService} from "../../infrastructure/utilities/media-label.service";
8
+ import {StorageMedia} from "./storage-media";
9
+ import {Button} from "../ui/button";
10
+ import {Progress} from "../ui/progress";
11
+ import {Activity} from "../components/activity";
12
+
13
+
14
+ export interface MediaUploadFieldProps {
15
+ moduleKey: string;
16
+ field: UserMediaFieldConfig;
17
+ value?: MediaStorageInterface;
18
+ onChange: (media?: MediaStorageInterface) => void;
19
+ }
20
+
21
+ export function MediaUploadField({field, value, onChange, moduleKey}: MediaUploadFieldProps) {
22
+ const inputRef = useRef<HTMLInputElement>(null);
23
+ const uploadFile = useUploadStore((state) => state.uploadFile);
24
+ const [isUploading, setIsUploading] = useState(false);
25
+ const [progress, setProgress] = useState(0);
26
+ const [error, setError] = useState<string>();
27
+ const [localPreviewUrl, setLocalPreviewUrl] = useState<string>();
28
+
29
+ useEffect(() => {
30
+ return () => {
31
+ if (localPreviewUrl) URL.revokeObjectURL(localPreviewUrl);
32
+ };
33
+ }, [localPreviewUrl]);
34
+
35
+ const isStoredImage = value?.id
36
+ ? MediaLabelService.sectionFor({mime: value.type, extension: value.filename?.split(".").pop() ?? ""}) === "image"
37
+ : false;
38
+
39
+ const handleSelect = async (file?: File | null) => {
40
+ if (!file) return;
41
+ if (localPreviewUrl) URL.revokeObjectURL(localPreviewUrl);
42
+ setLocalPreviewUrl(URL.createObjectURL(file));
43
+ setError(undefined);
44
+ setIsUploading(true);
45
+ setProgress(0);
46
+
47
+ const options: MediaUploadOptions = {module: moduleKey, type: field.type};
48
+ try {
49
+ const media = await uploadFile(file, options, (event) => {
50
+ setProgress(event.total ? (event.loaded / event.total) * 100 : 0);
51
+ }) as MediaStorageInterface | undefined;
52
+ if (!media) throw new Error('Réponse invalide du serveur');
53
+ setLocalPreviewUrl(undefined);
54
+ onChange(media);
55
+ } catch (e: any) {
56
+ setError(e?.response?.data?.message || e?.message || 'Une erreur est survenue lors du téléversement');
57
+ } finally {
58
+ setIsUploading(false);
59
+ }
60
+ };
61
+
62
+ return (
63
+ <div data-slot="media-upload-field" className="rounded-lg border border-border/60 bg-muted/30 p-4">
64
+ <div className="flex items-center gap-4">
65
+ <div className="flex size-16 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-background ring-1 ring-foreground/10">
66
+ {localPreviewUrl ? (
67
+ // eslint-disable-next-line @next/next/no-img-element
68
+ <img src={localPreviewUrl} alt={field.label} className="size-full object-cover"/>
69
+ ) : isStoredImage ? (
70
+ <StorageMedia id={value!.id!} className="size-full"/>
71
+ ) : value ? (
72
+ <FileText className="size-6 text-muted-foreground"/>
73
+ ) : (
74
+ <ImageIcon className="size-6 text-muted-foreground"/>
75
+ )}
76
+ </div>
77
+
78
+ <div className="min-w-0 flex-1">
79
+ <p className="text-sm font-medium">{field.label}</p>
80
+ <p className="text-xs text-muted-foreground">{field.description}</p>
81
+ {value?.filename && !isUploading && (
82
+ <p className="mt-0.5 truncate text-xs text-muted-foreground">
83
+ {value.filename} · {formatFileSize(value.metadata?.size ?? 0)}
84
+ </p>
85
+ )}
86
+ </div>
87
+
88
+ <div className="flex shrink-0 items-center gap-1">
89
+ {value && !isUploading && (
90
+ <Button
91
+ variant="ghost"
92
+ size="icon-sm"
93
+ onClick={() => onChange(undefined)}
94
+ aria-label={`Retirer ${field.label.toLowerCase()}`}
95
+ className="text-muted-foreground hover:text-destructive"
96
+ >
97
+ <Trash2 className="size-4"/>
98
+ </Button>
99
+ )}
100
+ <input
101
+ ref={inputRef}
102
+ type="file"
103
+ accept="image/*"
104
+ className="hidden"
105
+ onChange={(e) => {
106
+ handleSelect(e.target.files?.[0]);
107
+ e.target.value = "";
108
+ }}
109
+ />
110
+ <Button variant="outline" size="sm" onClick={() => inputRef.current?.click()} disabled={isUploading}>
111
+ {value && !isUploading ? (
112
+ <>
113
+ <Upload className="size-3.5"/>
114
+ Remplacer
115
+ </>
116
+ ) : (
117
+ <>
118
+ <Upload className="size-3.5"/>
119
+ Téléverser
120
+ </>
121
+ )}
122
+ </Button>
123
+ </div>
124
+ </div>
125
+
126
+ {isUploading && (
127
+ <div className="mt-3 flex items-center gap-2">
128
+ <Progress value={progress} className="h-1.5 flex-1"/>
129
+ <span className="w-11 text-right text-xs tabular-nums text-muted-foreground">
130
+ {Math.round(progress)}%
131
+ </span>
132
+ </div>
133
+ )}
134
+ {error ? (
135
+ <p className="mt-2 flex items-center gap-1 text-xs text-destructive">
136
+ <X className="size-3"/>
137
+ {error}
138
+ </p>
139
+ ) : value && !isUploading ? (
140
+ <p className="mt-2 flex items-center gap-1 text-xs text-emerald-500">
141
+ <CheckCircle2 className="size-3"/>
142
+ Fichier téléversé avec succès
143
+ </p>
144
+ ) : isUploading ? (
145
+ <p className="mt-2 flex items-center gap-1 text-xs text-muted-foreground">
146
+ <Activity.Loader size={12}/>
147
+ Téléversement en cours…
148
+ </p>
149
+ ) : null}
150
+ </div>
151
+ );
152
+ }