ikoncomponents 1.5.7 → 1.5.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.
- package/README.md +36 -36
- package/bin.js +2 -0
- package/dist/commands/init.js +63 -0
- package/dist/index.js +14 -116
- package/dist/utlis/copyDir.js +7 -0
- package/package.json +17 -91
- package/templates/default/hooks/use-mobile.ts +19 -0
- package/templates/default/ikonS/accordion.tsx +66 -0
- package/templates/default/ikonS/alert-dialog.tsx +179 -0
- package/templates/default/ikonS/alert.tsx +66 -0
- package/templates/default/ikonS/aspect-ratio.tsx +11 -0
- package/templates/default/ikonS/avatar.tsx +53 -0
- package/templates/default/ikonS/badge.tsx +49 -0
- package/templates/default/ikonS/breadcrumb.tsx +109 -0
- package/templates/default/ikonS/button.tsx +64 -0
- package/templates/default/ikonS/calendar.tsx +227 -0
- package/templates/default/ikonS/card.tsx +92 -0
- package/templates/default/ikonS/checkbox.tsx +33 -0
- package/templates/default/ikonS/collapsible.tsx +33 -0
- package/templates/default/ikonS/command.tsx +184 -0
- package/templates/default/ikonS/date-input.tsx +259 -0
- package/templates/default/ikonS/date-range-picker.tsx +103 -0
- package/templates/default/ikonS/dialog.tsx +143 -0
- package/templates/default/ikonS/drawer.tsx +134 -0
- package/templates/default/ikonS/dropdown-menu.tsx +259 -0
- package/templates/default/ikonS/form.tsx +166 -0
- package/templates/default/ikonS/hover-card.tsx +44 -0
- package/templates/default/ikonS/input-otp.tsx +71 -0
- package/templates/default/ikonS/input.tsx +22 -0
- package/templates/default/ikonS/label.tsx +24 -0
- package/templates/default/ikonS/navigation-menu.tsx +195 -0
- package/templates/default/ikonS/popover.tsx +48 -0
- package/templates/default/ikonS/progress.tsx +40 -0
- package/templates/default/ikonS/radio-group.tsx +45 -0
- package/templates/default/ikonS/scroll-area.tsx +58 -0
- package/templates/default/ikonS/select.tsx +184 -0
- package/templates/default/ikonS/separator.tsx +28 -0
- package/templates/default/ikonS/sheet.tsx +139 -0
- package/templates/default/ikonS/sidebar.tsx +726 -0
- package/templates/default/ikonS/skeleton.tsx +15 -0
- package/templates/default/ikonS/slider.tsx +64 -0
- package/templates/default/ikonS/sonner.tsx +25 -0
- package/templates/default/ikonS/switch.tsx +31 -0
- package/templates/default/ikonS/table.tsx +116 -0
- package/templates/default/ikonS/tabs.tsx +67 -0
- package/templates/default/ikonS/textarea.tsx +18 -0
- package/templates/default/ikonS/toggle-group.tsx +83 -0
- package/templates/default/ikonS/toggle.tsx +47 -0
- package/templates/default/ikonS/tooltip.tsx +65 -0
- package/templates/default/ikonS/workflow.tsx +119 -0
- package/templates/default/ikoncomponents/action-menu/index.tsx +108 -0
- package/templates/default/ikoncomponents/action-menu/type.ts +18 -0
- package/templates/default/ikoncomponents/activity-sheet/index.tsx +63 -0
- package/templates/default/ikoncomponents/alert-dialog/dialog-context.tsx +65 -0
- package/templates/default/ikoncomponents/alert-dialog/index.tsx +80 -0
- package/templates/default/ikoncomponents/app-breadcrumb/BreadcrumbProvider.tsx +68 -0
- package/templates/default/ikoncomponents/app-breadcrumb/index.tsx +222 -0
- package/templates/default/ikoncomponents/big-calendar/big-calender-event/index.tsx +38 -0
- package/templates/default/ikoncomponents/big-calendar/big-calender-toolbar/index.tsx +81 -0
- package/templates/default/ikoncomponents/big-calendar/index.css +879 -0
- package/templates/default/ikoncomponents/big-calendar/index.tsx +59 -0
- package/templates/default/ikoncomponents/big-calendar/type.ts +37 -0
- package/templates/default/ikoncomponents/buttons/index.tsx +127 -0
- package/templates/default/ikoncomponents/combobox-input/index.tsx +75 -0
- package/templates/default/ikoncomponents/combobox-input/type.ts +14 -0
- package/templates/default/ikoncomponents/custom-combo-dropdown/index.tsx +242 -0
- package/templates/default/ikoncomponents/data-table/datatable-column-filter/index.tsx +80 -0
- package/templates/default/ikoncomponents/data-table/datatable-faceted-filter/index.tsx +149 -0
- package/templates/default/ikoncomponents/data-table/datatable-filter-menu/index.tsx +98 -0
- package/templates/default/ikoncomponents/data-table/datatable-pagination/index.tsx +119 -0
- package/templates/default/ikoncomponents/data-table/datatable-toolbar/index.tsx +45 -0
- package/templates/default/ikoncomponents/data-table/function.ts +7 -0
- package/templates/default/ikoncomponents/data-table/index.tsx +549 -0
- package/templates/default/ikoncomponents/data-table/type.ts +75 -0
- package/templates/default/ikoncomponents/e-chart/index.tsx +183 -0
- package/templates/default/ikoncomponents/file-input/index.tsx +27 -0
- package/templates/default/ikoncomponents/fileUpload/index.tsx +121 -0
- package/templates/default/ikoncomponents/form-fields/combobox-input/index.tsx +111 -0
- package/templates/default/ikoncomponents/form-fields/combobox-input-value/index.tsx +121 -0
- package/templates/default/ikoncomponents/form-fields/date-input/index.tsx +80 -0
- package/templates/default/ikoncomponents/form-fields/file-input/index.tsx +9 -0
- package/templates/default/ikoncomponents/form-fields/input/index.tsx +27 -0
- package/{dist/ikoncomponents/form-fields/multi-combobox-input/index.js → templates/default/ikoncomponents/form-fields/multi-combobox-input/index.tsx} +574 -381
- package/templates/default/ikoncomponents/form-fields/otp-input/index.tsx +39 -0
- package/templates/default/ikoncomponents/form-fields/password-input/index.tsx +52 -0
- package/templates/default/ikoncomponents/form-fields/phone-input/index.tsx +7 -0
- package/templates/default/ikoncomponents/form-fields/textarea/index.tsx +28 -0
- package/templates/default/ikoncomponents/form-fields/types/index.ts +46 -0
- package/templates/default/ikoncomponents/glowing-effect/index.tsx +171 -0
- package/templates/default/ikoncomponents/icon/index.tsx +22 -0
- package/templates/default/ikoncomponents/image-cropper-upload/components/cropperImg.css +19 -0
- package/{dist/ikoncomponents/image-cropper-upload/components/newCropper.js → templates/default/ikoncomponents/image-cropper-upload/components/newCropper.tsx} +117 -85
- package/templates/default/ikoncomponents/image-cropper-upload/components/newImageUploadForm.tsx +352 -0
- package/templates/default/ikoncomponents/image-cropper-upload/cropper-form/index.tsx +250 -0
- package/templates/default/ikoncomponents/image-cropper-upload/cropper-form-with-modal/index.tsx +32 -0
- package/{dist/ikoncomponents/image-cropper-upload/image-cropper/index.js → templates/default/ikoncomponents/image-cropper-upload/image-cropper/index.tsx} +119 -87
- package/templates/default/ikoncomponents/image-cropper-upload/index.tsx +95 -0
- package/templates/default/ikoncomponents/image-cropper-upload/utils/index.ts +117 -0
- package/templates/default/ikoncomponents/loading-spinner/index.tsx +43 -0
- package/templates/default/ikoncomponents/main-layout/RefreshContext.tsx +30 -0
- package/templates/default/ikoncomponents/main-layout/SidebarNavContext.tsx +103 -0
- package/templates/default/ikoncomponents/main-layout/app-sidebar.tsx +36 -0
- package/templates/default/ikoncomponents/main-layout/footer.tsx +21 -0
- package/templates/default/ikoncomponents/main-layout/header.tsx +53 -0
- package/templates/default/ikoncomponents/main-layout/index.tsx +38 -0
- package/templates/default/ikoncomponents/main-layout/main-sidebar.tsx +389 -0
- package/templates/default/ikoncomponents/main-layout/nav-main.tsx +103 -0
- package/templates/default/ikoncomponents/multi-combobox/index.tsx +345 -0
- package/templates/default/ikoncomponents/no-data/index.tsx +11 -0
- package/templates/default/ikoncomponents/page-wrapper/index.tsx +30 -0
- package/templates/default/ikoncomponents/password-strength-meter/index.tsx +49 -0
- package/templates/default/ikoncomponents/phone-input/index.tsx +72 -0
- package/templates/default/ikoncomponents/provider-wrapper/index.tsx +32 -0
- package/templates/default/ikoncomponents/search-input/index.tsx +18 -0
- package/templates/default/ikoncomponents/sheet/index.tsx +34 -0
- package/templates/default/ikoncomponents/simple-widget/index.tsx +54 -0
- package/templates/default/ikoncomponents/skeleton-loader/skeleton-table.tsx +34 -0
- package/templates/default/ikoncomponents/skeleton-loader/skeleton-widget.tsx +13 -0
- package/templates/default/ikoncomponents/tabs/index.tsx +139 -0
- package/{dist/ikoncomponents/tabs/type.d.ts → templates/default/ikoncomponents/tabs/type.ts} +20 -19
- package/{dist/ikoncomponents/theme-toggle-btn/index.js → templates/default/ikoncomponents/theme-toggle-btn/index.tsx} +189 -118
- package/templates/default/ikoncomponents/title-progress/index.tsx +41 -0
- package/templates/default/ikoncomponents/tooltip/index.tsx +17 -0
- package/templates/default/ikoncomponents/twolevel-dropdown/convertToDropdownNodes.tsx +33 -0
- package/templates/default/ikoncomponents/twolevel-dropdown/index.tsx +279 -0
- package/templates/default/ikoncomponents/upload-tab/index.tsx +237 -0
- package/templates/default/ikoncomponents/widgets/index.tsx +81 -0
- package/templates/default/ikoncomponents/widgets/type.ts +11 -0
- package/templates/default/ikoncomponents/work-in-progress/index.tsx +16 -0
- package/templates/default/styles.css +1159 -0
- package/templates/default/utils/actions/account/index.ts +33 -0
- package/templates/default/utils/actions/account/type.ts +4 -0
- package/{dist/utils/actions/auth/index.js → templates/default/utils/actions/auth/index.ts} +69 -58
- package/templates/default/utils/actions/common/revalidate.ts +18 -0
- package/templates/default/utils/actions/common/type.ts +4 -0
- package/{dist/utils/actions/common/utils.js → templates/default/utils/actions/common/utils.ts} +28 -25
- package/templates/default/utils/actions/software/index.ts +106 -0
- package/templates/default/utils/api/accountService/index.ts +103 -0
- package/templates/default/utils/api/accountService/type.ts +4 -0
- package/templates/default/utils/api/file-upload/index.ts +103 -0
- package/templates/default/utils/api/file-upload/type.ts +8 -0
- package/{dist/utils/api/ikonBaseApi.js → templates/default/utils/api/ikonBaseApi.ts} +132 -104
- package/templates/default/utils/api/loginService/index.ts +106 -0
- package/{dist/utils/api/loginService/type.d.ts → templates/default/utils/api/loginService/type.ts} +35 -31
- package/templates/default/utils/api/softwareService/index.ts +356 -0
- package/templates/default/utils/api/softwareService/type.ts +62 -0
- package/{dist/utils/border-radius-provider.js → templates/default/utils/border-radius-provider.tsx} +59 -35
- package/templates/default/utils/cn.ts +6 -0
- package/{dist/utils/font-provider.js → templates/default/utils/font-provider.tsx} +61 -37
- package/templates/default/utils/session/cookieSession.ts +49 -0
- package/templates/default/utils/theme-provider/index.tsx +11 -0
- package/templates/default/utils/token-management/index.ts +115 -0
- package/templates/default/utils/token-management/types.ts +6 -0
- package/dist/hooks/use-mobile.d.ts +0 -1
- package/dist/hooks/use-mobile.js +0 -15
- package/dist/ikoncomponents/action-menu/index.d.ts +0 -5
- package/dist/ikoncomponents/action-menu/index.js +0 -42
- package/dist/ikoncomponents/action-menu/type.d.ts +0 -14
- package/dist/ikoncomponents/action-menu/type.js +0 -1
- package/dist/ikoncomponents/activity-sheet/index.d.ts +0 -11
- package/dist/ikoncomponents/activity-sheet/index.js +0 -23
- package/dist/ikoncomponents/alert-dialog/dialog-context.d.ts +0 -21
- package/dist/ikoncomponents/alert-dialog/dialog-context.js +0 -30
- package/dist/ikoncomponents/alert-dialog/index.d.ts +0 -14
- package/dist/ikoncomponents/alert-dialog/index.js +0 -20
- package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.d.ts +0 -18
- package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.js +0 -43
- package/dist/ikoncomponents/app-breadcrumb/index.d.ts +0 -5
- package/dist/ikoncomponents/app-breadcrumb/index.js +0 -57
- package/dist/ikoncomponents/big-calendar/big-calender-event/index.d.ts +0 -5
- package/dist/ikoncomponents/big-calendar/big-calender-event/index.js +0 -16
- package/dist/ikoncomponents/big-calendar/big-calender-toolbar/index.d.ts +0 -2
- package/dist/ikoncomponents/big-calendar/big-calender-toolbar/index.js +0 -39
- package/dist/ikoncomponents/big-calendar/index.d.ts +0 -3
- package/dist/ikoncomponents/big-calendar/index.js +0 -35
- package/dist/ikoncomponents/big-calendar/type.d.ts +0 -31
- package/dist/ikoncomponents/big-calendar/type.js +0 -1
- package/dist/ikoncomponents/buttons/index.d.ts +0 -18
- package/dist/ikoncomponents/buttons/index.js +0 -38
- package/dist/ikoncomponents/combobox-input/index.d.ts +0 -2
- package/dist/ikoncomponents/combobox-input/index.js +0 -18
- package/dist/ikoncomponents/combobox-input/type.d.ts +0 -13
- package/dist/ikoncomponents/combobox-input/type.js +0 -1
- package/dist/ikoncomponents/custom-combo-dropdown/index.d.ts +0 -21
- package/dist/ikoncomponents/custom-combo-dropdown/index.js +0 -85
- package/dist/ikoncomponents/data-table/datatable-column-filter/index.d.ts +0 -2
- package/dist/ikoncomponents/data-table/datatable-column-filter/index.js +0 -22
- package/dist/ikoncomponents/data-table/datatable-faceted-filter/index.d.ts +0 -2
- package/dist/ikoncomponents/data-table/datatable-faceted-filter/index.js +0 -35
- package/dist/ikoncomponents/data-table/datatable-filter-menu/index.d.ts +0 -2
- package/dist/ikoncomponents/data-table/datatable-filter-menu/index.js +0 -38
- package/dist/ikoncomponents/data-table/datatable-pagination/index.d.ts +0 -2
- package/dist/ikoncomponents/data-table/datatable-pagination/index.js +0 -13
- package/dist/ikoncomponents/data-table/datatable-toolbar/index.d.ts +0 -2
- package/dist/ikoncomponents/data-table/datatable-toolbar/index.js +0 -18
- package/dist/ikoncomponents/data-table/function.d.ts +0 -1
- package/dist/ikoncomponents/data-table/function.js +0 -6
- package/dist/ikoncomponents/data-table/index.d.ts +0 -2
- package/dist/ikoncomponents/data-table/index.js +0 -223
- package/dist/ikoncomponents/data-table/type.d.ts +0 -60
- package/dist/ikoncomponents/data-table/type.js +0 -1
- package/dist/ikoncomponents/e-chart/index.d.ts +0 -15
- package/dist/ikoncomponents/e-chart/index.js +0 -115
- package/dist/ikoncomponents/file-input/index.d.ts +0 -1
- package/dist/ikoncomponents/file-input/index.js +0 -21
- package/dist/ikoncomponents/fileUpload/index.d.ts +0 -15
- package/dist/ikoncomponents/fileUpload/index.js +0 -69
- package/dist/ikoncomponents/form-fields/combobox-input/index.d.ts +0 -2
- package/dist/ikoncomponents/form-fields/combobox-input/index.js +0 -21
- package/dist/ikoncomponents/form-fields/combobox-input-value/index.d.ts +0 -18
- package/dist/ikoncomponents/form-fields/combobox-input-value/index.js +0 -26
- package/dist/ikoncomponents/form-fields/date-input/index.d.ts +0 -2
- package/dist/ikoncomponents/form-fields/date-input/index.js +0 -15
- package/dist/ikoncomponents/form-fields/file-input/index.d.ts +0 -1
- package/dist/ikoncomponents/form-fields/file-input/index.js +0 -4
- package/dist/ikoncomponents/form-fields/input/index.d.ts +0 -2
- package/dist/ikoncomponents/form-fields/input/index.js +0 -18
- package/dist/ikoncomponents/form-fields/multi-combobox-input/index.d.ts +0 -6
- package/dist/ikoncomponents/form-fields/otp-input/index.d.ts +0 -2
- package/dist/ikoncomponents/form-fields/otp-input/index.js +0 -18
- package/dist/ikoncomponents/form-fields/phone-input/index.d.ts +0 -1
- package/dist/ikoncomponents/form-fields/phone-input/index.js +0 -4
- package/dist/ikoncomponents/form-fields/textarea/index.d.ts +0 -2
- package/dist/ikoncomponents/form-fields/textarea/index.js +0 -18
- package/dist/ikoncomponents/form-fields/types/index.d.ts +0 -36
- package/dist/ikoncomponents/form-fields/types/index.js +0 -1
- package/dist/ikoncomponents/glowing-effect/index.d.ts +0 -14
- package/dist/ikoncomponents/glowing-effect/index.js +0 -84
- package/dist/ikoncomponents/icon/index.d.ts +0 -8
- package/dist/ikoncomponents/icon/index.js +0 -23
- package/dist/ikoncomponents/image-cropper-upload/components/newCropper.d.ts +0 -15
- package/dist/ikoncomponents/image-cropper-upload/components/newImageUploadForm.d.ts +0 -7
- package/dist/ikoncomponents/image-cropper-upload/components/newImageUploadForm.js +0 -145
- package/dist/ikoncomponents/image-cropper-upload/cropper-form/index.d.ts +0 -6
- package/dist/ikoncomponents/image-cropper-upload/cropper-form/index.js +0 -92
- package/dist/ikoncomponents/image-cropper-upload/cropper-form-with-modal/index.d.ts +0 -6
- package/dist/ikoncomponents/image-cropper-upload/cropper-form-with-modal/index.js +0 -14
- package/dist/ikoncomponents/image-cropper-upload/image-cropper/index.d.ts +0 -14
- package/dist/ikoncomponents/image-cropper-upload/index.d.ts +0 -27
- package/dist/ikoncomponents/image-cropper-upload/index.js +0 -49
- package/dist/ikoncomponents/image-cropper-upload/utils/index.d.ts +0 -16
- package/dist/ikoncomponents/image-cropper-upload/utils/index.js +0 -73
- package/dist/ikoncomponents/loading-spinner/index.d.ts +0 -9
- package/dist/ikoncomponents/loading-spinner/index.js +0 -19
- package/dist/ikoncomponents/main-layout/RefreshContext.d.ts +0 -10
- package/dist/ikoncomponents/main-layout/RefreshContext.js +0 -17
- package/dist/ikoncomponents/main-layout/SidebarNavContext.d.ts +0 -33
- package/dist/ikoncomponents/main-layout/SidebarNavContext.js +0 -52
- package/dist/ikoncomponents/main-layout/app-sidebar.d.ts +0 -3
- package/dist/ikoncomponents/main-layout/app-sidebar.js +0 -24
- package/dist/ikoncomponents/main-layout/footer.d.ts +0 -1
- package/dist/ikoncomponents/main-layout/footer.js +0 -5
- package/dist/ikoncomponents/main-layout/header.d.ts +0 -3
- package/dist/ikoncomponents/main-layout/header.js +0 -15
- package/dist/ikoncomponents/main-layout/index.d.ts +0 -6
- package/dist/ikoncomponents/main-layout/index.js +0 -11
- package/dist/ikoncomponents/main-layout/main-sidebar.d.ts +0 -60
- package/dist/ikoncomponents/main-layout/main-sidebar.js +0 -119
- package/dist/ikoncomponents/main-layout/nav-main.d.ts +0 -11
- package/dist/ikoncomponents/main-layout/nav-main.js +0 -33
- package/dist/ikoncomponents/multi-combobox/index.d.ts +0 -13
- package/dist/ikoncomponents/multi-combobox/index.js +0 -202
- package/dist/ikoncomponents/no-data/index.d.ts +0 -3
- package/dist/ikoncomponents/no-data/index.js +0 -5
- package/dist/ikoncomponents/page-wrapper/index.d.ts +0 -9
- package/dist/ikoncomponents/page-wrapper/index.js +0 -7
- package/dist/ikoncomponents/password-strength-meter/index.d.ts +0 -3
- package/dist/ikoncomponents/password-strength-meter/index.js +0 -40
- package/dist/ikoncomponents/phone-input/index.d.ts +0 -1
- package/dist/ikoncomponents/phone-input/index.js +0 -41
- package/dist/ikoncomponents/provider-wrapper/index.d.ts +0 -6
- package/dist/ikoncomponents/provider-wrapper/index.js +0 -11
- package/dist/ikoncomponents/search-input/index.d.ts +0 -1
- package/dist/ikoncomponents/search-input/index.js +0 -19
- package/dist/ikoncomponents/sheet/index.d.ts +0 -10
- package/dist/ikoncomponents/sheet/index.js +0 -6
- package/dist/ikoncomponents/simple-widget/index.d.ts +0 -14
- package/dist/ikoncomponents/simple-widget/index.js +0 -14
- package/dist/ikoncomponents/skeleton-loader/skeleton-table.d.ts +0 -5
- package/dist/ikoncomponents/skeleton-loader/skeleton-table.js +0 -6
- package/dist/ikoncomponents/skeleton-loader/skeleton-widget.d.ts +0 -3
- package/dist/ikoncomponents/skeleton-loader/skeleton-widget.js +0 -5
- package/dist/ikoncomponents/tabs/index.d.ts +0 -2
- package/dist/ikoncomponents/tabs/index.js +0 -50
- package/dist/ikoncomponents/tabs/type.js +0 -2
- package/dist/ikoncomponents/theme-toggle-btn/index.d.ts +0 -1
- package/dist/ikoncomponents/title-progress/index.d.ts +0 -12
- package/dist/ikoncomponents/title-progress/index.js +0 -10
- package/dist/ikoncomponents/tooltip/index.d.ts +0 -5
- package/dist/ikoncomponents/tooltip/index.js +0 -5
- package/dist/ikoncomponents/twolevel-dropdown/index.d.ts +0 -31
- package/dist/ikoncomponents/twolevel-dropdown/index.js +0 -143
- package/dist/ikoncomponents/upload-tab/index.d.ts +0 -1
- package/dist/ikoncomponents/upload-tab/index.js +0 -92
- package/dist/ikoncomponents/widgets/index.d.ts +0 -2
- package/dist/ikoncomponents/widgets/index.js +0 -14
- package/dist/ikoncomponents/widgets/type.d.ts +0 -10
- package/dist/ikoncomponents/widgets/type.js +0 -2
- package/dist/ikoncomponents/work-in-progress/index.d.ts +0 -1
- package/dist/ikoncomponents/work-in-progress/index.js +0 -4
- package/dist/index.d.ts +0 -138
- package/dist/shadcn/accordion.d.ts +0 -7
- package/dist/shadcn/accordion.js +0 -33
- package/dist/shadcn/alert-dialog.d.ts +0 -20
- package/dist/shadcn/alert-dialog.js +0 -83
- package/dist/shadcn/alert.d.ts +0 -9
- package/dist/shadcn/alert.js +0 -38
- package/dist/shadcn/aspect-ratio.d.ts +0 -3
- package/dist/shadcn/aspect-ratio.js +0 -19
- package/dist/shadcn/avatar.d.ts +0 -6
- package/dist/shadcn/avatar.js +0 -28
- package/dist/shadcn/badge.d.ts +0 -9
- package/dist/shadcn/badge.js +0 -35
- package/dist/shadcn/breadcrumb.d.ts +0 -11
- package/dist/shadcn/breadcrumb.js +0 -45
- package/dist/shadcn/button.d.ts +0 -10
- package/dist/shadcn/button.js +0 -47
- package/dist/shadcn/calendar.d.ts +0 -8
- package/dist/shadcn/calendar.js +0 -61
- package/dist/shadcn/card.d.ts +0 -9
- package/dist/shadcn/card.js +0 -42
- package/dist/shadcn/checkbox.d.ts +0 -4
- package/dist/shadcn/checkbox.js +0 -21
- package/dist/shadcn/collapsible.d.ts +0 -5
- package/dist/shadcn/collapsible.js +0 -27
- package/dist/shadcn/command.d.ts +0 -18
- package/dist/shadcn/command.js +0 -54
- package/dist/shadcn/date-input.d.ts +0 -7
- package/dist/shadcn/date-input.js +0 -179
- package/dist/shadcn/date-range-picker.d.ts +0 -24
- package/dist/shadcn/date-range-picker.js +0 -45
- package/dist/shadcn/dialog.d.ts +0 -15
- package/dist/shadcn/dialog.js +0 -57
- package/dist/shadcn/drawer.d.ts +0 -13
- package/dist/shadcn/drawer.js +0 -56
- package/dist/shadcn/dropdown-menu.d.ts +0 -25
- package/dist/shadcn/dropdown-menu.js +0 -77
- package/dist/shadcn/form.d.ts +0 -24
- package/dist/shadcn/form.js +0 -70
- package/dist/shadcn/hover-card.d.ts +0 -6
- package/dist/shadcn/hover-card.js +0 -28
- package/dist/shadcn/input-otp.d.ts +0 -34
- package/dist/shadcn/input-otp.js +0 -40
- package/dist/shadcn/input.d.ts +0 -3
- package/dist/shadcn/input.js +0 -18
- package/dist/shadcn/label.d.ts +0 -4
- package/dist/shadcn/label.js +0 -20
- package/dist/shadcn/navigation-menu.d.ts +0 -16
- package/dist/shadcn/navigation-menu.js +0 -74
- package/dist/shadcn/popover.d.ts +0 -7
- package/dist/shadcn/popover.js +0 -32
- package/dist/shadcn/progress.d.ts +0 -8
- package/dist/shadcn/progress.js +0 -23
- package/dist/shadcn/radio-group.d.ts +0 -5
- package/dist/shadcn/radio-group.js +0 -25
- package/dist/shadcn/scroll-area.d.ts +0 -5
- package/dist/shadcn/scroll-area.js +0 -26
- package/dist/shadcn/select.d.ts +0 -15
- package/dist/shadcn/select.js +0 -59
- package/dist/shadcn/separator.d.ts +0 -4
- package/dist/shadcn/separator.js +0 -20
- package/dist/shadcn/sheet.d.ts +0 -13
- package/dist/shadcn/sheet.js +0 -61
- package/dist/shadcn/sidebar.d.ts +0 -69
- package/dist/shadcn/sidebar.js +0 -242
- package/dist/shadcn/skeleton.d.ts +0 -3
- package/dist/shadcn/skeleton.js +0 -18
- package/dist/shadcn/slider.d.ts +0 -4
- package/dist/shadcn/slider.js +0 -26
- package/dist/shadcn/sonner.d.ts +0 -3
- package/dist/shadcn/sonner.js +0 -25
- package/dist/shadcn/switch.d.ts +0 -4
- package/dist/shadcn/switch.js +0 -20
- package/dist/shadcn/table.d.ts +0 -10
- package/dist/shadcn/table.js +0 -47
- package/dist/shadcn/tabs.d.ts +0 -7
- package/dist/shadcn/tabs.js +0 -32
- package/dist/shadcn/textarea.d.ts +0 -3
- package/dist/shadcn/textarea.js +0 -18
- package/dist/shadcn/toggle-group.d.ts +0 -9
- package/dist/shadcn/toggle-group.js +0 -35
- package/dist/shadcn/toggle.d.ts +0 -9
- package/dist/shadcn/toggle.js +0 -38
- package/dist/shadcn/tooltip.d.ts +0 -7
- package/dist/shadcn/tooltip.js +0 -32
- package/dist/shadcn/workflow.d.ts +0 -20
- package/dist/shadcn/workflow.js +0 -20
- package/dist/styles.css +0 -6163
- package/dist/utils/actions/account/index.d.ts +0 -5
- package/dist/utils/actions/account/index.js +0 -28
- package/dist/utils/actions/account/type.d.ts +0 -4
- package/dist/utils/actions/account/type.js +0 -1
- package/dist/utils/actions/auth/index.d.ts +0 -7
- package/dist/utils/actions/common/utils.d.ts +0 -5
- package/dist/utils/actions/software/index.d.ts +0 -11
- package/dist/utils/actions/software/index.js +0 -75
- package/dist/utils/api/accountService/index.d.ts +0 -23
- package/dist/utils/api/accountService/index.js +0 -64
- package/dist/utils/api/accountService/type.d.ts +0 -4
- package/dist/utils/api/accountService/type.js +0 -1
- package/dist/utils/api/file-upload/index.d.ts +0 -5
- package/dist/utils/api/file-upload/index.js +0 -80
- package/dist/utils/api/file-upload/type.d.ts +0 -6
- package/dist/utils/api/file-upload/type.js +0 -1
- package/dist/utils/api/ikonBaseApi.d.ts +0 -12
- package/dist/utils/api/loginService/index.d.ts +0 -12
- package/dist/utils/api/loginService/index.js +0 -72
- package/dist/utils/api/loginService/type.js +0 -1
- package/dist/utils/api/softwareService/index.d.ts +0 -64
- package/dist/utils/api/softwareService/index.js +0 -212
- package/dist/utils/api/softwareService/type.d.ts +0 -54
- package/dist/utils/api/softwareService/type.js +0 -1
- package/dist/utils/border-radius-provider.d.ts +0 -11
- package/dist/utils/cn.d.ts +0 -2
- package/dist/utils/cn.js +0 -5
- package/dist/utils/font-provider.d.ts +0 -11
- package/dist/utils/session/cookieSession.d.ts +0 -8
- package/dist/utils/session/cookieSession.js +0 -33
- package/dist/utils/theme-provider/index.d.ts +0 -3
- package/dist/utils/theme-provider/index.js +0 -18
- package/dist/utils/token-management/index.d.ts +0 -10
- package/dist/utils/token-management/index.js +0 -69
- package/dist/utils/token-management/types.d.ts +0 -6
- package/dist/utils/token-management/types.js +0 -1
package/templates/default/ikoncomponents/image-cropper-upload/components/newImageUploadForm.tsx
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import React, { useState, useEffect, memo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ZoomIn,
|
|
4
|
+
ZoomOut,
|
|
5
|
+
RotateCw,
|
|
6
|
+
RotateCcw,
|
|
7
|
+
ArrowUp,
|
|
8
|
+
ArrowDown,
|
|
9
|
+
ArrowLeft,
|
|
10
|
+
ArrowRight,
|
|
11
|
+
ImageIcon,
|
|
12
|
+
FileImage,
|
|
13
|
+
Square,
|
|
14
|
+
Upload,
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
import { Label } from "../../../shadcn/label";
|
|
17
|
+
import { Input } from "../../../shadcn/input";
|
|
18
|
+
import { Button } from "../../../shadcn/button";
|
|
19
|
+
import { NewCropperImg } from "./newCropper";
|
|
20
|
+
import Image from "next/image";
|
|
21
|
+
|
|
22
|
+
type ActiveState = "first" | "second" | "third";
|
|
23
|
+
|
|
24
|
+
export interface ImageFormProps {
|
|
25
|
+
open: boolean;
|
|
26
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
27
|
+
onImageSubmit: (data: string | null) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const NewImageFormComponent: React.FC<ImageFormProps> = ({
|
|
31
|
+
open,
|
|
32
|
+
setOpen,
|
|
33
|
+
onImageSubmit,
|
|
34
|
+
}) => {
|
|
35
|
+
const [imageSrc, setImageSrc] = useState<string | null>(null);
|
|
36
|
+
const [croppedImage, setCroppedImage] = useState<string | null>(null);
|
|
37
|
+
const [prevImages, setPrevImages] = useState<
|
|
38
|
+
Record<ActiveState, string | null>
|
|
39
|
+
>({
|
|
40
|
+
first: null,
|
|
41
|
+
second: null,
|
|
42
|
+
third: null,
|
|
43
|
+
});
|
|
44
|
+
const [aspectRatio, setAspectRatio] = useState<number>(4 / 3);
|
|
45
|
+
const [activeState, setActiveState] = useState<ActiveState>("first");
|
|
46
|
+
const [rotationAngle, setRotationAngle] = useState(0);
|
|
47
|
+
const [scale, setScale] = useState(1);
|
|
48
|
+
const [moveDirection, setMoveDirection] = useState<{ x: number; y: number }>({
|
|
49
|
+
x: 0,
|
|
50
|
+
y: 0,
|
|
51
|
+
});
|
|
52
|
+
const [fileName, setFileName] = useState<string | undefined>("");
|
|
53
|
+
|
|
54
|
+
const handleImageSubmit = () => {
|
|
55
|
+
console.log("Image Submit Button is pressed");
|
|
56
|
+
console.log(prevImages);
|
|
57
|
+
onImageSubmit(prevImages.third);
|
|
58
|
+
setOpen(false);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const rotateImage = (angle: number) => {
|
|
62
|
+
setRotationAngle((prevAngle) => prevAngle + angle);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleMoveUp = () => {
|
|
66
|
+
setMoveDirection({ x: 0, y: -5 });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleMoveDown = () => {
|
|
70
|
+
setMoveDirection({ x: 0, y: 5 });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleMoveLeft = () => {
|
|
74
|
+
setMoveDirection({ x: -5, y: 0 });
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleMoveRight = () => {
|
|
78
|
+
setMoveDirection({ x: 5, y: 0 });
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Handle zoom in
|
|
82
|
+
const zoomIn = () => {
|
|
83
|
+
setScale((prevScale) => {
|
|
84
|
+
const newScale = prevScale + 0.2;
|
|
85
|
+
if (newScale <= 2) {
|
|
86
|
+
// Ensure scale does not exceed the max value
|
|
87
|
+
return newScale;
|
|
88
|
+
}
|
|
89
|
+
return prevScale;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Handle zoom out
|
|
94
|
+
const zoomOut = () => {
|
|
95
|
+
setScale((prevScale) => {
|
|
96
|
+
const newScale = prevScale - 0.2;
|
|
97
|
+
if (newScale >= 0.2) {
|
|
98
|
+
// Ensure scale does not go below the min value
|
|
99
|
+
return newScale;
|
|
100
|
+
}
|
|
101
|
+
return prevScale;
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const handleAspectRatioChange = (ratio: number, stateName: ActiveState) => {
|
|
106
|
+
setAspectRatio(ratio);
|
|
107
|
+
setActiveState(stateName);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const handleFileChange = (file: File) => {
|
|
111
|
+
if (file.type.startsWith("image/")) {
|
|
112
|
+
const reader = new FileReader();
|
|
113
|
+
reader.onloadend = () => {
|
|
114
|
+
setImageSrc(reader.result as string);
|
|
115
|
+
setFileName((prev) => prev || file.name);
|
|
116
|
+
};
|
|
117
|
+
reader.readAsDataURL(file);
|
|
118
|
+
} else {
|
|
119
|
+
alert("Please drop a valid image file.");
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const handleDrop = (event: React.DragEvent) => {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
handleFileChange(event.dataTransfer.files[0]);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const getImagePreview = (state: ActiveState) => {
|
|
129
|
+
const imgSource =
|
|
130
|
+
croppedImage && activeState === state ? croppedImage : prevImages[state];
|
|
131
|
+
// const imgSource = prevImages[state];
|
|
132
|
+
return imgSource ? (
|
|
133
|
+
<div
|
|
134
|
+
className={`
|
|
135
|
+
${state === "first"
|
|
136
|
+
? "relative w-3/5 h-[200px] bg-slate-400"
|
|
137
|
+
: state === "second"
|
|
138
|
+
? "relative w-1/2 h-[220px] bg-slate-400"
|
|
139
|
+
: "relative w-1/3 h-[120px] bg-slate-400"
|
|
140
|
+
}`}
|
|
141
|
+
>
|
|
142
|
+
<Image
|
|
143
|
+
src={imgSource || ""}
|
|
144
|
+
alt={`Preview ${state}`}
|
|
145
|
+
layout="fill"
|
|
146
|
+
objectFit="70vh"
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
) : (
|
|
150
|
+
<div
|
|
151
|
+
className={`
|
|
152
|
+
${state === "first"
|
|
153
|
+
? "relative w-3/5 h-[200px] bg-slate-400"
|
|
154
|
+
: state === "second"
|
|
155
|
+
? "relative w-1/2 h-[220px] bg-slate-400"
|
|
156
|
+
: "relative w-1/3 h-[120px] bg-slate-400"
|
|
157
|
+
}`}
|
|
158
|
+
></div>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (croppedImage) {
|
|
164
|
+
if (
|
|
165
|
+
prevImages.first === null ||
|
|
166
|
+
prevImages.second === null ||
|
|
167
|
+
prevImages.third === null
|
|
168
|
+
) {
|
|
169
|
+
setPrevImages({
|
|
170
|
+
first: croppedImage,
|
|
171
|
+
second: croppedImage,
|
|
172
|
+
third: croppedImage,
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
setPrevImages((prev) => ({ ...prev, [activeState]: croppedImage }));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, [croppedImage]);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<>
|
|
182
|
+
{/* Form UI */}
|
|
183
|
+
<div className="flex flex-row gap-2">
|
|
184
|
+
<div className="flex-1">
|
|
185
|
+
<Label htmlFor="imageName">Image Name</Label>
|
|
186
|
+
<Input
|
|
187
|
+
id="imageName"
|
|
188
|
+
placeholder="Enter image name"
|
|
189
|
+
value={fileName}
|
|
190
|
+
onChange={(e) => setFileName(e.target.value)}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
<div className="self-end">
|
|
194
|
+
<Button
|
|
195
|
+
variant="outline"
|
|
196
|
+
onClick={() => document.getElementById("inputImage1")?.click()}
|
|
197
|
+
>
|
|
198
|
+
<Upload />
|
|
199
|
+
</Button>
|
|
200
|
+
<Input
|
|
201
|
+
id="inputImage1"
|
|
202
|
+
type="file"
|
|
203
|
+
accept="image/png, image/jpeg"
|
|
204
|
+
className="hidden"
|
|
205
|
+
onChange={(e) => {
|
|
206
|
+
const file = e.target.files?.[0];
|
|
207
|
+
if (file && file.type.startsWith("image/")) {
|
|
208
|
+
const reader = new FileReader();
|
|
209
|
+
reader.onloadend = () => {
|
|
210
|
+
setImageSrc(reader.result as string);
|
|
211
|
+
setFileName((prevFileName) => prevFileName || file.name);
|
|
212
|
+
};
|
|
213
|
+
reader.readAsDataURL(file);
|
|
214
|
+
setPrevImages({
|
|
215
|
+
first: null,
|
|
216
|
+
second: null,
|
|
217
|
+
third: null,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
</div>
|
|
223
|
+
<div className="flex-1">
|
|
224
|
+
<Label htmlFor="imageDesc">Image Description</Label>
|
|
225
|
+
<Input id="imageDesc" placeholder="Describe your image" />
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
{/* Image Upload */}
|
|
230
|
+
<div className="flex flex-row gap-2">
|
|
231
|
+
<div
|
|
232
|
+
className="w-3/5 flex justify-center items-center border-2 border-dashed border-gray-400 bg-gray-100"
|
|
233
|
+
style={{ height: "70vh" }}
|
|
234
|
+
onDrop={handleDrop}
|
|
235
|
+
onDragOver={(e) => e.preventDefault()}
|
|
236
|
+
>
|
|
237
|
+
{imageSrc ? (
|
|
238
|
+
<NewCropperImg
|
|
239
|
+
imageSrc={imageSrc}
|
|
240
|
+
onCroppedImage={setCroppedImage}
|
|
241
|
+
aspectRatio={aspectRatio}
|
|
242
|
+
rotationAngle={rotationAngle}
|
|
243
|
+
zoomLevel={scale}
|
|
244
|
+
moveDirection={moveDirection}
|
|
245
|
+
currentState={activeState}
|
|
246
|
+
/>
|
|
247
|
+
) : (
|
|
248
|
+
<div className="text-center">
|
|
249
|
+
<Label htmlFor="inputImage">Drag and drop an image here</Label>
|
|
250
|
+
<div className="mt-4">
|
|
251
|
+
<Button
|
|
252
|
+
variant="outline"
|
|
253
|
+
onClick={() => document.getElementById("inputImage")?.click()}
|
|
254
|
+
>
|
|
255
|
+
Upload Image
|
|
256
|
+
</Button>
|
|
257
|
+
<Input
|
|
258
|
+
id="inputImage"
|
|
259
|
+
type="file"
|
|
260
|
+
accept="image/png, image/jpeg"
|
|
261
|
+
className="hidden"
|
|
262
|
+
onChange={(e) => {
|
|
263
|
+
const file = e.target.files?.[0];
|
|
264
|
+
if (file) {
|
|
265
|
+
handleFileChange(file);
|
|
266
|
+
}
|
|
267
|
+
}}
|
|
268
|
+
/>
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
{/* Image Previews */}
|
|
275
|
+
<div className="w-2/5 flex flex-col gap-2">
|
|
276
|
+
<h3>Landscape</h3>
|
|
277
|
+
{getImagePreview("first")}
|
|
278
|
+
<h3>Potrait</h3>
|
|
279
|
+
{getImagePreview("second")}
|
|
280
|
+
<h3>Icon</h3>
|
|
281
|
+
{getImagePreview("third")}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
{/* Controls */}
|
|
286
|
+
|
|
287
|
+
<div className="flex flex-row gap-1">
|
|
288
|
+
<div className="w-3/5 flex flex-row justify-between">
|
|
289
|
+
<div>
|
|
290
|
+
<Button
|
|
291
|
+
variant="outline"
|
|
292
|
+
onClick={() => handleAspectRatioChange(4 / 3, "first")}
|
|
293
|
+
>
|
|
294
|
+
<ImageIcon />
|
|
295
|
+
</Button>
|
|
296
|
+
<Button
|
|
297
|
+
variant="outline"
|
|
298
|
+
onClick={() => handleAspectRatioChange(3 / 4, "second")}
|
|
299
|
+
>
|
|
300
|
+
<FileImage />
|
|
301
|
+
</Button>
|
|
302
|
+
<Button
|
|
303
|
+
variant="outline"
|
|
304
|
+
onClick={() => handleAspectRatioChange(1 / 1, "third")}
|
|
305
|
+
>
|
|
306
|
+
<Square />
|
|
307
|
+
</Button>
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
<div>
|
|
311
|
+
<Button onClick={() => rotateImage(90)} variant="outline">
|
|
312
|
+
{<RotateCw />}
|
|
313
|
+
</Button>
|
|
314
|
+
|
|
315
|
+
<Button onClick={() => rotateImage(-90)} variant="outline">
|
|
316
|
+
{<RotateCcw />}
|
|
317
|
+
</Button>
|
|
318
|
+
</div>
|
|
319
|
+
|
|
320
|
+
<div>
|
|
321
|
+
<Button onClick={() => zoomIn()} variant="outline">
|
|
322
|
+
{<ZoomIn />}
|
|
323
|
+
</Button>
|
|
324
|
+
<Button onClick={() => zoomOut()} variant="outline">
|
|
325
|
+
{<ZoomOut />}
|
|
326
|
+
</Button>
|
|
327
|
+
</div>
|
|
328
|
+
<div>
|
|
329
|
+
<Button onClick={handleMoveUp} variant="outline">
|
|
330
|
+
{<ArrowUp />}
|
|
331
|
+
</Button>
|
|
332
|
+
<Button onClick={handleMoveDown} variant="outline">
|
|
333
|
+
{<ArrowDown />}
|
|
334
|
+
</Button>
|
|
335
|
+
<Button onClick={handleMoveLeft} variant="outline">
|
|
336
|
+
{<ArrowLeft />}
|
|
337
|
+
</Button>
|
|
338
|
+
<Button onClick={handleMoveRight} variant="outline">
|
|
339
|
+
{<ArrowRight />}
|
|
340
|
+
</Button>
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<div className="w-2/5 flex flex-row-reverse">
|
|
345
|
+
<Button onClick={handleImageSubmit}>Save</Button>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
348
|
+
</>
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
export const NewImageForm = memo(NewImageFormComponent);
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { Input } from '../../../shadcn/input'
|
|
2
|
+
import { Label } from '../../../shadcn/label'
|
|
3
|
+
import { ToggleGroup, ToggleGroupItem } from '../../../shadcn/toggle-group'
|
|
4
|
+
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, FileImage, ImageIcon, RotateCcw, RotateCw, Square, Upload, ZoomIn, ZoomOut } from 'lucide-react'
|
|
5
|
+
import { ChangeEvent, memo, useEffect, useState } from 'react'
|
|
6
|
+
import { ImageCropper } from '../image-cropper'
|
|
7
|
+
import Image from 'next/image'
|
|
8
|
+
import { AspectRatio } from '../../../shadcn/aspect-ratio'
|
|
9
|
+
import { TextButton } from '../../buttons'
|
|
10
|
+
import { toast } from 'sonner'
|
|
11
|
+
import { FileInput } from '../../file-input'
|
|
12
|
+
import { OriginalImageProps, useImageCropper } from '..'
|
|
13
|
+
import { set } from 'date-fns'
|
|
14
|
+
|
|
15
|
+
type ActiveState = "landscape" | "potrait" | "icon";
|
|
16
|
+
|
|
17
|
+
const stateWiseAspectRatio = {
|
|
18
|
+
landscape: 4 / 3,
|
|
19
|
+
potrait: 3 / 4,
|
|
20
|
+
icon: 1 / 1
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Props {
|
|
24
|
+
onNewFileUpload?: (...args: any) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function CropperFormComponent({ onNewFileUpload }: Props) {
|
|
28
|
+
|
|
29
|
+
const { originalImage, setOriginalImage, aspectRatioWiseImages, setAspectRatioWiseImages } = useImageCropper();
|
|
30
|
+
const [croppedImage, setCroppedImage] = useState<string | null>(null);
|
|
31
|
+
const [activeState, setActiveState] = useState<ActiveState | undefined>();
|
|
32
|
+
const [rotationAngle, setRotationAngle] = useState(0);
|
|
33
|
+
const [scale, setScale] = useState(1);
|
|
34
|
+
const [moveDirection, setMoveDirection] = useState<{ x: number; y: number }>({
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const [imageSrc, setImageSrc] = useState<string | null>(null);
|
|
40
|
+
const handleDrop = (event: React.DragEvent) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
handleFileChange(event.dataTransfer.files[0]);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const handleFileChange = (file: File | string) => {
|
|
46
|
+
if (typeof file === "string") {
|
|
47
|
+
setImageSrc(file);
|
|
48
|
+
} else {
|
|
49
|
+
if (file?.type?.startsWith("image/")) {
|
|
50
|
+
onNewFileUpload?.();
|
|
51
|
+
|
|
52
|
+
const reader = new FileReader();
|
|
53
|
+
reader.onloadend = () => {
|
|
54
|
+
setImageSrc(reader.result as string);
|
|
55
|
+
setActiveState(undefined);
|
|
56
|
+
};
|
|
57
|
+
reader.readAsDataURL(file);
|
|
58
|
+
setOriginalImage({ ...originalImage, image: file, name: file.name });
|
|
59
|
+
} else {
|
|
60
|
+
toast.error("Please select a valid image file.");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (originalImage.image) {
|
|
67
|
+
handleFileChange(originalImage.image)
|
|
68
|
+
}
|
|
69
|
+
}, [originalImage.image]);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const getImagePreview = (state: ActiveState) => {
|
|
73
|
+
const imgSource = croppedImage && activeState === state ? croppedImage : aspectRatioWiseImages[state];
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<h3 className='mb-3'>{state}</h3>
|
|
77
|
+
<AspectRatio ratio={stateWiseAspectRatio[state]} className='bg-muted'>
|
|
78
|
+
{imgSource &&
|
|
79
|
+
<Image
|
|
80
|
+
src={imgSource || ""}
|
|
81
|
+
alt={`Preview ${state}`}
|
|
82
|
+
fill
|
|
83
|
+
/>
|
|
84
|
+
}
|
|
85
|
+
</AspectRatio>
|
|
86
|
+
</>
|
|
87
|
+
)
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (croppedImage) {
|
|
94
|
+
if (activeState) {
|
|
95
|
+
setAspectRatioWiseImages({ ...aspectRatioWiseImages, [activeState]: croppedImage });
|
|
96
|
+
} else {
|
|
97
|
+
setAspectRatioWiseImages({
|
|
98
|
+
landscape: croppedImage,
|
|
99
|
+
potrait: croppedImage,
|
|
100
|
+
icon: croppedImage
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}, [croppedImage]);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<>
|
|
109
|
+
<div className='flex flex-col gap-3 h-full overflow-auto'>
|
|
110
|
+
<div className='flex flex-col lg:flex-row gap-3 justify-between'>
|
|
111
|
+
<div className='w-full flex flex-col gap-4'>
|
|
112
|
+
<Label htmlFor="imageName">
|
|
113
|
+
Image Name
|
|
114
|
+
</Label>
|
|
115
|
+
<FileInput
|
|
116
|
+
id="inputImage"
|
|
117
|
+
accept="image/*"
|
|
118
|
+
fileNamePlaceholder="Enter image name"
|
|
119
|
+
fileName={originalImage?.name || ""}
|
|
120
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
121
|
+
const file = e.target.files?.[0];
|
|
122
|
+
if (file) {
|
|
123
|
+
handleFileChange(file);
|
|
124
|
+
}
|
|
125
|
+
}}
|
|
126
|
+
onFileNameChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
127
|
+
setOriginalImage({ ...originalImage, name: e.target.value })
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
</div>
|
|
132
|
+
<div className='w-full flex flex-col gap-4'>
|
|
133
|
+
<Label htmlFor="imageDescription">
|
|
134
|
+
Image Description
|
|
135
|
+
</Label>
|
|
136
|
+
<Input
|
|
137
|
+
id="imageDescription"
|
|
138
|
+
placeholder="Enter image Description"
|
|
139
|
+
value={originalImage?.description || ""}
|
|
140
|
+
onChange={(e) => setOriginalImage({ ...originalImage, description: e.target.value })}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
<div className='flex flex-col lg:flex-row gap-3'>
|
|
145
|
+
<div className='flex-grow flex flex-col gap-3'>
|
|
146
|
+
<div>
|
|
147
|
+
<h3 className='mb-3'>Original Image</h3>
|
|
148
|
+
<AspectRatio
|
|
149
|
+
ratio={4 / 3}
|
|
150
|
+
className='flex justify-center items-center bg-muted text-muted-foreground'
|
|
151
|
+
onDrop={handleDrop}
|
|
152
|
+
onDragOver={(e) => e.preventDefault()}
|
|
153
|
+
>
|
|
154
|
+
{imageSrc ?
|
|
155
|
+
<ImageCropper
|
|
156
|
+
src={imageSrc}
|
|
157
|
+
onCroppedImage={setCroppedImage}
|
|
158
|
+
aspectRatio={stateWiseAspectRatio[activeState || "icon"]}
|
|
159
|
+
rotationAngle={rotationAngle}
|
|
160
|
+
zoomLevel={scale}
|
|
161
|
+
moveDirection={moveDirection}
|
|
162
|
+
/>
|
|
163
|
+
:
|
|
164
|
+
<div className="text-center">
|
|
165
|
+
<Label htmlFor="inputImage">Drag and drop an image here</Label>
|
|
166
|
+
<div className="mt-3">
|
|
167
|
+
<TextButton
|
|
168
|
+
variant="outline"
|
|
169
|
+
onClick={() => document.getElementById("inputImage")?.click()}
|
|
170
|
+
>
|
|
171
|
+
Browse Image
|
|
172
|
+
</TextButton>
|
|
173
|
+
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
}
|
|
177
|
+
</AspectRatio>
|
|
178
|
+
|
|
179
|
+
</div>
|
|
180
|
+
<div className="flex flex-col lg:flex-row gap-3 justify-between">
|
|
181
|
+
<div>
|
|
182
|
+
<ToggleGroup type="single" variant='outline' value={activeState} onValueChange={(value) => setActiveState(value as ActiveState)}>
|
|
183
|
+
<ToggleGroupItem className="rounded-e-none" value="landscape">
|
|
184
|
+
<ImageIcon />
|
|
185
|
+
</ToggleGroupItem>
|
|
186
|
+
<ToggleGroupItem className="rounded-none border-x-0" value="potrait">
|
|
187
|
+
<FileImage />
|
|
188
|
+
</ToggleGroupItem>
|
|
189
|
+
<ToggleGroupItem className='rounded-s-none' value="icon">
|
|
190
|
+
<Square />
|
|
191
|
+
</ToggleGroupItem>
|
|
192
|
+
</ToggleGroup>
|
|
193
|
+
</div>
|
|
194
|
+
<div className='flex flex-col lg:flex-row gap-3 justify-between'>
|
|
195
|
+
<ToggleGroup type="single" variant='outline' value="" onValueChange={(value) => setRotationAngle(parseInt(value))}>
|
|
196
|
+
<ToggleGroupItem className="rounded-e-none" value="90">
|
|
197
|
+
<RotateCw />
|
|
198
|
+
</ToggleGroupItem>
|
|
199
|
+
<ToggleGroupItem className='rounded-s-none border-s-0' value="-90">
|
|
200
|
+
<RotateCcw />
|
|
201
|
+
</ToggleGroupItem>
|
|
202
|
+
</ToggleGroup>
|
|
203
|
+
<ToggleGroup type="single" variant='outline' value=''>
|
|
204
|
+
<ToggleGroupItem className="rounded-e-none" value="up" onClick={() => setMoveDirection({ x: 0, y: -5 })}>
|
|
205
|
+
<ArrowUp />
|
|
206
|
+
</ToggleGroupItem>
|
|
207
|
+
<ToggleGroupItem className="rounded-none border-x-0" value="down" onClick={() => setMoveDirection({ x: 0, y: 5 })}>
|
|
208
|
+
<ArrowDown />
|
|
209
|
+
</ToggleGroupItem>
|
|
210
|
+
<ToggleGroupItem className='rounded-none border-e-0' value="left" onClick={() => setMoveDirection({ x: -5, y: 0 })}>
|
|
211
|
+
<ArrowLeft />
|
|
212
|
+
</ToggleGroupItem>
|
|
213
|
+
<ToggleGroupItem className='rounded-s-none' value="right" onClick={() => setMoveDirection({ x: 5, y: 0 })}>
|
|
214
|
+
<ArrowRight />
|
|
215
|
+
</ToggleGroupItem>
|
|
216
|
+
</ToggleGroup>
|
|
217
|
+
<ToggleGroup type="single" variant='outline' value="" onValueChange={(value) => setScale(pre => pre + parseFloat(value))} >
|
|
218
|
+
<ToggleGroupItem className="rounded-e-none" value="0.1">
|
|
219
|
+
<ZoomIn />
|
|
220
|
+
</ToggleGroupItem>
|
|
221
|
+
<ToggleGroupItem className='rounded-s-none border-s-0' value="-0.1">
|
|
222
|
+
<ZoomOut />
|
|
223
|
+
</ToggleGroupItem>
|
|
224
|
+
</ToggleGroup>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
</div>
|
|
229
|
+
{/* Image Previews */}
|
|
230
|
+
<div className="flex flex-row lg:flex-col gap-3 w-full lg:w-48">
|
|
231
|
+
<div className='w-5/5'>
|
|
232
|
+
{getImagePreview("landscape")}
|
|
233
|
+
</div>
|
|
234
|
+
<div className='w-4/5'>
|
|
235
|
+
{getImagePreview("potrait")}
|
|
236
|
+
</div>
|
|
237
|
+
<div className='w-3/5'>
|
|
238
|
+
{getImagePreview("icon")}
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
</div >
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
</>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export const CropperForm = memo(CropperFormComponent)
|
package/templates/default/ikoncomponents/image-cropper-upload/cropper-form-with-modal/index.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '../../../shadcn/dialog'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { CropperForm } from '../cropper-form'
|
|
4
|
+
import { TextButton } from '../../buttons'
|
|
5
|
+
import { AspectRatioWiseImagesProps, OriginalImageProps, useImageCropper } from '..'
|
|
6
|
+
|
|
7
|
+
export function CropperFormWithModal
|
|
8
|
+
({ open, onOpenChange, onCropperChange }:
|
|
9
|
+
Readonly<{ open: boolean, onOpenChange: (open: boolean) => void, onCropperChange: (originalImage: OriginalImageProps, aspectRatioWiseImages: AspectRatioWiseImagesProps) => void }>) {
|
|
10
|
+
const { originalImage, aspectRatioWiseImages } = useImageCropper();
|
|
11
|
+
return (
|
|
12
|
+
<Dialog modal open={open} onOpenChange={(isOpen) => {
|
|
13
|
+
onOpenChange(isOpen)
|
|
14
|
+
}}>
|
|
15
|
+
<DialogContent className="max-w-full lg:max-w-5xl max-h-full overflow-auto">
|
|
16
|
+
<DialogHeader>
|
|
17
|
+
<DialogTitle>Image to upload</DialogTitle>
|
|
18
|
+
</DialogHeader>
|
|
19
|
+
<CropperForm />
|
|
20
|
+
<DialogFooter>
|
|
21
|
+
<TextButton onClick={() => {
|
|
22
|
+
onCropperChange(originalImage, aspectRatioWiseImages)
|
|
23
|
+
onOpenChange(false);
|
|
24
|
+
}}>
|
|
25
|
+
Save Changes
|
|
26
|
+
</TextButton>
|
|
27
|
+
</DialogFooter>
|
|
28
|
+
</DialogContent>
|
|
29
|
+
</Dialog>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|