@zenify-omni/chat-ui-react-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/assets/asset-url.js +6 -0
- package/assets/icons/chatter_agent.js +27 -0
- package/assets/icons/chatter_chatbot.js +43 -0
- package/assets/icons/chatter_contact.js +36 -0
- package/assets/icons/email_icon.png +0 -0
- package/assets/icons/emoji/angry.svg +56 -0
- package/assets/icons/emoji/haha.svg +20 -0
- package/assets/icons/emoji/like.svg +10 -0
- package/assets/icons/emoji/like_out_line.png +0 -0
- package/assets/icons/emoji/love.svg +10 -0
- package/assets/icons/emoji/sad.svg +46 -0
- package/assets/icons/emoji/wow.svg +51 -0
- package/assets/icons/instagram.js +29 -0
- package/assets/icons/not_found.png +0 -0
- package/assets/icons/not_found_template.svg +9 -0
- package/assets/icons/phone_icon.png +0 -0
- package/assets/icons/shopee.js +17 -0
- package/assets/icons/sms_icon.png +0 -0
- package/assets/icons/tiktok.js +17 -0
- package/assets/icons/whatsapp.js +28 -0
- package/assets/icons/zalo.js +17 -0
- package/assets/icons/zalo_icon.png +0 -0
- package/assets/icons/zns_icon.png +0 -0
- package/assets/images/emoji.webp +0 -0
- package/assets/images/error.png +0 -0
- package/assets/images/menu.png +0 -0
- package/assets/images/money.png +0 -0
- package/assets/images/success.png +0 -0
- package/assets/public-urls.js +78 -0
- package/components/campaign-detail-route/select/group.js +38 -0
- package/components/campaign-detail-route/select/multi-groups.js +43 -0
- package/components/chat-route/chat-box/ads-context-card.js +143 -0
- package/components/chat-route/chat-box/chat-drop-file.js +18 -0
- package/components/chat-route/chat-box/chat-feedback/chat-insight.js +214 -0
- package/components/chat-route/chat-box/chat-feedback/index.js +127 -0
- package/components/chat-route/chat-box/chat-header-actions-inline.js +1055 -0
- package/components/chat-route/chat-box/chat-header.js +465 -0
- package/components/chat-route/chat-box/chat-input.js +1164 -0
- package/components/chat-route/chat-box/chat-message-action.js +399 -0
- package/components/chat-route/chat-box/chat-message-list.js +995 -0
- package/components/chat-route/chat-box/chat-message.js +2099 -0
- package/components/chat-route/chat-box/chat-reply-preview.js +317 -0
- package/components/chat-route/chat-box/common-groups-modal.js +430 -0
- package/components/chat-route/chat-box/constants.js +29 -0
- package/components/chat-route/chat-box/contact-card/index.js +87 -0
- package/components/chat-route/chat-box/edit-customer-alias-dialog.js +197 -0
- package/components/chat-route/chat-box/emoji-picker-combined.js +91 -0
- package/components/chat-route/chat-box/emoji-sprite.js +45 -0
- package/components/chat-route/chat-box/emojiMap.js +92 -0
- package/components/chat-route/chat-box/facebook-reconnect-notice.js +49 -0
- package/components/chat-route/chat-box/forward-message-modal.js +659 -0
- package/components/chat-route/chat-box/index.js +165 -0
- package/components/chat-route/chat-box/message-time.js +44 -0
- package/components/chat-route/chat-box/message-viewers.js +114 -0
- package/components/chat-route/chat-box/pasted-file-preview.js +138 -0
- package/components/chat-route/chat-box/pinned-messages.js +255 -0
- package/components/chat-route/chat-box/react-message/react-preview.js +83 -0
- package/components/chat-route/chat-box/react-message/reaction-button.js +200 -0
- package/components/chat-route/chat-box/right-side/chat-history.js +142 -0
- package/components/chat-route/chat-box/right-side/chat-tag-selector.js +232 -0
- package/components/chat-route/chat-box/right-side/create-personal-tag-modal.js +458 -0
- package/components/chat-route/chat-box/right-side/customer/customer-info-item.js +60 -0
- package/components/chat-route/chat-box/right-side/in-room-dialog.js +225 -0
- package/components/chat-route/chat-box/right-side/zalo-group/add-friend-dialog.js +154 -0
- package/components/chat-route/chat-box/right-side/zalo-group/send-message-dialog.js +165 -0
- package/components/chat-route/chat-box/send-contact-card-modal.js +102 -0
- package/components/chat-route/chat-box/send-contact-card.js +80 -0
- package/components/chat-route/chat-box/text-content.js +400 -0
- package/components/chat-route/chat-box/use-facebook-page-invalid.js +22 -0
- package/components/chat-route/chat-box/zalo-emoji-decoration.js +98 -0
- package/components/chat-route/chat-box/zalo-emoji-picker.js +74 -0
- package/components/chat-route/chat-box/zalo-personal-editor.js +590 -0
- package/components/chat-route/chat-box/zalo-reminder/create-zalo-reminder.js +868 -0
- package/components/chat-route/chat-box/zalo-reminder/use-send-zalo-reminder.js +98 -0
- package/components/chat-route/chat-box/zalo-reminder/zalo-reminder-content.js +294 -0
- package/components/chat-route/chat-box/zalo-rtf-utils.js +422 -0
- package/components/chat-route/chat-list/action-chat-item.js +116 -0
- package/components/chat-route/chat-list/assign-agent-dialog.js +170 -0
- package/components/chat-route/chat-list/assign-tag-dialog.js +242 -0
- package/components/chat-route/chat-list/chat-item-tags.js +105 -0
- package/components/chat-route/chat-list/chat-item.js +749 -0
- package/components/chat-route/chat-list/chat-list-item.js +370 -0
- package/components/chat-route/chat-list/chat-list-selection-bar.js +426 -0
- package/components/chat-route/chat-list/chat-search-preview.js +48 -0
- package/components/chat-route/chat-list/chat-sort-menu.js +89 -0
- package/components/chat-route/chat-list/edit-filter-modal.js +468 -0
- package/components/chat-route/chat-list/filter-chat-sources.js +222 -0
- package/components/chat-route/chat-list/filter-chat.js +501 -0
- package/components/chat-route/chat-list/filter-criteria-rows.js +845 -0
- package/components/chat-route/chat-list/filter-group-select.js +66 -0
- package/components/chat-route/chat-list/filter-pin-menu.js +165 -0
- package/components/chat-route/chat-list/friend-request/list-friend-request.js +287 -0
- package/components/chat-route/chat-list/index.js +243 -0
- package/components/chat-route/chat-list/inline-search-results.js +178 -0
- package/components/chat-route/chat-list/post-ids-field.js +104 -0
- package/components/chat-route/chat-list/quick-filter-bar.js +391 -0
- package/components/chat-route/chat-list/save-filter-popover.js +258 -0
- package/components/chat-route/chat-list/search-messages/index.js +225 -0
- package/components/chat-route/chat-list/search-result-header.js +51 -0
- package/components/chat-route/chat-list/util.js +604 -0
- package/components/chat-route/chat-toolbar.js +108 -0
- package/components/chat-route/hooks/use-reassign.js +111 -0
- package/components/chat-route/shared/close-conversation-dialog.js +111 -0
- package/components/chat-route/shared/force-transfer-dialog.js +109 -0
- package/components/chat-route/shared/in-queue-confirm-dialog.js +40 -0
- package/components/chat-route/util.js +146 -0
- package/components/chat-route/zalo/modal-action-zalo.js +76 -0
- package/components/chat-route/zalo/modal-add-friend-zalo.js +277 -0
- package/components/custom/SafeHTML.js +45 -0
- package/components/custom/audio-player.js +81 -0
- package/components/custom/avatar.js +95 -0
- package/components/custom/between-date-picker/index.js +86 -0
- package/components/custom/button-close.js +28 -0
- package/components/custom/button.js +80 -0
- package/components/custom/color-picker.js +81 -0
- package/components/custom/combobox.js +168 -0
- package/components/custom/custom-dialog.js +44 -0
- package/components/custom/custom-select.js +256 -0
- package/components/custom/cycle-value-helpers.js +11 -0
- package/components/custom/cycle-value.js +93 -0
- package/components/custom/date-time-picker/components/date-time-group.js +44 -0
- package/components/custom/date-time-picker/components/date-time-input.js +383 -0
- package/components/custom/date-time-picker/components/date-time-unit-input.js +138 -0
- package/components/custom/date-time-picker/components/month-year-picker.js +232 -0
- package/components/custom/date-time-picker/hooks/use-merge-refs.js +18 -0
- package/components/custom/date-time-picker/hooks/use-scroll-to-center.js +18 -0
- package/components/custom/date-time-picker/index.js +348 -0
- package/components/custom/field-file-upload/files-upload.js +87 -0
- package/components/custom/field-file-upload/image-upload.js +115 -0
- package/components/custom/field-file-upload/preview-images-modal.js +284 -0
- package/components/custom/field-file-upload/preview-list-file.js +134 -0
- package/components/custom/field-file-upload/preview-list-image.js +108 -0
- package/components/custom/field-file-upload/upload-custom.js +222 -0
- package/components/custom/field-generator.js +639 -0
- package/components/custom/field-layout-popover.js +304 -0
- package/components/custom/file-preview-modal.js +351 -0
- package/components/custom/html-edtior.js +100 -0
- package/components/custom/icon.js +49 -0
- package/components/custom/infinite-scroll-combobox.js +253 -0
- package/components/custom/inline-edit-popover.js +90 -0
- package/components/custom/inputs/calendar-input.js +0 -0
- package/components/custom/inputs/chip-input.js +136 -0
- package/components/custom/inputs/file-input.js +71 -0
- package/components/custom/inputs/mask-data/mask-data-input.js +80 -0
- package/components/custom/inputs/mask-data/mask-data-select.js +78 -0
- package/components/custom/inputs/mask-data/mask-data-textarea.js +75 -0
- package/components/custom/inputs/mask-data/reconcile-masked-edit.js +20 -0
- package/components/custom/jxl-decode.js +34 -0
- package/components/custom/jxl-image.js +68 -0
- package/components/custom/jxl-worker.js +12 -0
- package/components/custom/label.js +55 -0
- package/components/custom/layout.js +30 -0
- package/components/custom/multi-select-search-cc.js +179 -0
- package/components/custom/multiple-select-setting-tags.js +404 -0
- package/components/custom/multiple-selector.js +821 -0
- package/components/custom/pagination.js +95 -0
- package/components/custom/popup-confirm.js +120 -0
- package/components/custom/previews/facebook/facebook-appointment-booking-preview.js +83 -0
- package/components/custom/previews/facebook/facebook-audio-preview.js +130 -0
- package/components/custom/previews/facebook/facebook-event-preview.js +72 -0
- package/components/custom/previews/facebook/facebook-file-preview.js +95 -0
- package/components/custom/previews/facebook/facebook-group-preview.js +103 -0
- package/components/custom/previews/facebook/facebook-image-preview.js +81 -0
- package/components/custom/previews/facebook/facebook-page-preview.js +85 -0
- package/components/custom/previews/facebook/facebook-post-preview.js +77 -0
- package/components/custom/previews/facebook/facebook-reel-preview.js +83 -0
- package/components/custom/previews/facebook/facebook-sticker-preview.js +23 -0
- package/components/custom/previews/facebook/facebook-video-preview.js +114 -0
- package/components/custom/previews/facebook/index.js +24 -0
- package/components/custom/previews/file-preview.js +747 -0
- package/components/custom/previews/image-preview.js +288 -0
- package/components/custom/previews/instagram/index.js +4 -0
- package/components/custom/previews/instagram/instagram-share-post-preview.js +77 -0
- package/components/custom/previews/link-preview.js +166 -0
- package/components/custom/previews/product-preview.js +334 -0
- package/components/custom/previews/tiktok-order-preview.js +278 -0
- package/components/custom/previews/tiktok-product-preview.js +321 -0
- package/components/custom/previews/tiktok-voucher-preview.js +151 -0
- package/components/custom/previews/whatsapp/index.js +10 -0
- package/components/custom/previews/whatsapp/whatsapp-contact-card-preview.js +150 -0
- package/components/custom/previews/whatsapp/whatsapp-order-preview.js +38 -0
- package/components/custom/previews/whatsapp/whatsapp-poll-preview.js +29 -0
- package/components/custom/previews/whatsapp/whatsapp-product-preview.js +29 -0
- package/components/custom/retry-image.js +44 -0
- package/components/custom/search-input.js +26 -0
- package/components/custom/separator-with-text.js +14 -0
- package/components/custom/showToast.js +21 -0
- package/components/custom/sortable-header.js +62 -0
- package/components/custom/table-resize-line.js +92 -0
- package/components/custom/time-picker/index.js +73 -0
- package/components/custom/time-picker/time-picker-input.js +159 -0
- package/components/custom/time-picker/time-picker-utils.js +152 -0
- package/components/custom/viewers/audio-player.js +192 -0
- package/components/custom/viewers/code-viewer.js +140 -0
- package/components/custom/viewers/csv-viewer.js +174 -0
- package/components/custom/viewers/docx-viewer.js +145 -0
- package/components/custom/viewers/image-viewer.js +104 -0
- package/components/custom/viewers/markdown-viewer.js +124 -0
- package/components/custom/viewers/pdf-viewer.js +333 -0
- package/components/custom/viewers/spreadsheet-viewer.js +232 -0
- package/components/custom/viewers/unsupported-viewer.js +85 -0
- package/components/custom/viewers/video-player.js +241 -0
- package/components/customers-route/change-owner-modal.js +430 -0
- package/components/customers-route/contact-note-button.js +212 -0
- package/components/customers-route/customer-source.js +37 -0
- package/components/customers-route/table/columns.js +675 -0
- package/components/customers-route/table/edit-fields.js +125 -0
- package/components/customers-route/table/editable-cell.js +218 -0
- package/components/customers-route/table/note-cell.js +77 -0
- package/components/dialogs/invite-agent.js +677 -0
- package/components/error-boundary.js +53 -0
- package/components/leads-route/duplicate-phone-warning-toast.js +96 -0
- package/components/leads-route/table/columns.js +523 -0
- package/components/leads-route/table/contact-cell-name.js +82 -0
- package/components/leads-route/table/edit-fields.js +142 -0
- package/components/leads-route/table/editable-cell.js +228 -0
- package/components/org-tree/group-name-display.js +36 -0
- package/components/org-tree/group-tree-multi-select.js +208 -0
- package/components/org-tree/group-tree-select.js +220 -0
- package/components/posts-route/dialog-select-posts.js +284 -0
- package/components/reports-route/agents/multi-select-agents.js +55 -0
- package/components/reports-route/agents/multi-select-search-agents.js +43 -0
- package/components/settings-route/chat-layout/detail/constants.js +353 -0
- package/components/settings-route/chat-layout/detail/form.js +43 -0
- package/components/settings-route/chat-timeout/channel-multi-select.js +119 -0
- package/components/settings-route/multi-channel/facebook/hooks/use-facebook-sdk.js +3 -0
- package/components/settings-route/object-rule/util.js +79 -0
- package/components/settings-route/routing/settings-dialog.js +561 -0
- package/components/settings-route/switchboard/queue-new/constant.js +9 -0
- package/components/shared/linked-customer-fields/LinkedCustomerFields.js +91 -0
- package/components/shared/linked-customer-fields/use-linked-customer-fields.js +123 -0
- package/components/smartqc-route/qc-form/controls/multi-select-search-agents.js +50 -0
- package/components/ui/alert-dialog.js +112 -0
- package/components/ui/avatar.js +44 -0
- package/components/ui/badge.js +54 -0
- package/components/ui/button.js +48 -0
- package/components/ui/calendar.js +70 -0
- package/components/ui/card.js +58 -0
- package/components/ui/carousel.js +238 -0
- package/components/ui/checkbox.js +27 -0
- package/components/ui/command.js +111 -0
- package/components/ui/context-menu.js +154 -0
- package/components/ui/dialog.js +104 -0
- package/components/ui/dropdown-menu.js +169 -0
- package/components/ui/form.js +104 -0
- package/components/ui/input.js +115 -0
- package/components/ui/label.js +20 -0
- package/components/ui/popover.js +29 -0
- package/components/ui/radio-group.js +53 -0
- package/components/ui/scroll-area.js +38 -0
- package/components/ui/select.js +147 -0
- package/components/ui/separator.js +24 -0
- package/components/ui/sheet.js +113 -0
- package/components/ui/skeleton.js +17 -0
- package/components/ui/slider.js +26 -0
- package/components/ui/sonner.js +76 -0
- package/components/ui/switch.js +54 -0
- package/components/ui/table-v2.js +269 -0
- package/components/ui/table.js +245 -0
- package/components/ui/tabs.js +89 -0
- package/components/ui/textarea.js +33 -0
- package/components/ui/tooltip.js +40 -0
- package/components/workflow-editor/nodes/ticket/picker-field.js +233 -0
- package/components/zalo-login-qr.js +237 -0
- package/components/zalo-login-status-modal.js +45 -0
- package/config/env.js +27 -0
- package/config/hmr.js +8 -0
- package/config/navigation.js +54 -0
- package/config/runtime.js +46 -0
- package/config/theme.js +274 -0
- package/constants/brand-colors.js +32 -0
- package/constants/chat-icon.js +34 -0
- package/dist/chat.css +1 -0
- package/exceptions/throw-exception.js +15 -0
- package/hooks/use-chat-attachments.js +106 -0
- package/hooks/use-chat-configs.js +62 -0
- package/hooks/use-chat-customer.js +33 -0
- package/hooks/use-chat-display-config-sync.js +72 -0
- package/hooks/use-chat-permission.js +68 -0
- package/hooks/use-chat-room-detail.js +44 -0
- package/hooks/use-chat-selection.js +26 -0
- package/hooks/use-chat-sort.js +69 -0
- package/hooks/use-chat-surface.js +8 -0
- package/hooks/use-common-filter-options.js +70 -0
- package/hooks/use-crm-organization-filter-options.js +0 -0
- package/hooks/use-crm-organizations-data.js +23 -0
- package/hooks/use-debounce.js +14 -0
- package/hooks/use-dynamic-fields.js +7 -0
- package/hooks/use-facebook-notice.js +24 -0
- package/hooks/use-feature-flags.js +6 -0
- package/hooks/use-field-layout-override.js +46 -0
- package/hooks/use-file-upload.js +119 -0
- package/hooks/use-file-viewer.js +93 -0
- package/hooks/use-frozen-columns.js +29 -0
- package/hooks/use-horizontal-scroll.js +41 -0
- package/hooks/use-image-preview-queue.js +101 -0
- package/hooks/use-inline-editable-cell.js +97 -0
- package/hooks/use-intersection-observer.js +24 -0
- package/hooks/use-interval.js +20 -0
- package/hooks/use-latest-message-id.js +13 -0
- package/hooks/use-lead-filter-options.js +0 -0
- package/hooks/use-logout-listener.js +43 -0
- package/hooks/use-org-tree.js +43 -0
- package/hooks/use-permission.js +33 -0
- package/hooks/use-quick-filters.js +175 -0
- package/hooks/use-resizable-table.js +0 -0
- package/hooks/use-setting-common.js +389 -0
- package/hooks/use-settings.js +41 -0
- package/hooks/use-sort-bindings.js +24 -0
- package/hooks/use-table-display-config.js +0 -0
- package/hooks/use-tenant-config.js +99 -0
- package/hooks/use-update-user-config.js +150 -0
- package/hooks/use-zalo-connection.js +57 -0
- package/hooks/use-zalo-mention-list.js +31 -0
- package/index.css +624 -0
- package/index.js +100 -0
- package/lib/deal-name.js +27 -0
- package/lib/i18n/react.js +7 -0
- package/lib/i18n/use-language.js +0 -0
- package/lib/query-client.js +34 -0
- package/lib/utils.js +25 -0
- package/package.json +108 -0
- package/provider/chat-context.js +9 -0
- package/provider/chat-provider.js +177 -0
- package/provider/chat-room-context.js +9 -0
- package/provider/chat-room-hooks.js +8 -0
- package/provider/chat-room-provider.js +84 -0
- package/provider/hooks.js +22 -0
- package/provider/index.js +42 -0
- package/public/contact-card-user.svg +25 -0
- package/public/images/icons/facebook.svg +1 -0
- package/public/images/icons/instagram.svg +1 -0
- package/public/images/icons/shopee.svg +1 -0
- package/public/images/icons/whatsapp.svg +1 -0
- package/public/images/icons/zalo.png +0 -0
- package/public/images/images.jpg +0 -0
- package/public/images/ticket_sources/api.png +0 -0
- package/public/images/ticket_sources/email.png +0 -0
- package/public/images/ticket_sources/facebook.png +0 -0
- package/public/images/ticket_sources/hand.png +0 -0
- package/public/images/ticket_sources/instagram.png +0 -0
- package/public/images/ticket_sources/livechat.png +0 -0
- package/public/images/ticket_sources/shopee.svg +1 -0
- package/public/images/ticket_sources/sms.png +0 -0
- package/public/images/ticket_sources/telephone-call-in.png +0 -0
- package/public/images/ticket_sources/telephone-call-out.png +0 -0
- package/public/images/ticket_sources/tiktok.png +0 -0
- package/public/images/ticket_sources/tiktok_shop.png +0 -0
- package/public/images/ticket_sources/whatsapp.png +0 -0
- package/public/images/ticket_sources/whatsapp.svg +1 -0
- package/public/images/ticket_sources/zalo.png +0 -0
- package/public/placeholder.svg +13 -0
- package/store/app-status-store.js +17 -0
- package/store/chat-display-config-store.js +182 -0
- package/store/chat-display-config.resolvers.js +88 -0
- package/store/chat-store-helpers.js +62 -0
- package/store/chat-store.js +931 -0
- package/store/crm-organization-list-filter-store.js +126 -0
- package/store/customer-list-filter-store.js +139 -0
- package/store/devtools.js +9 -0
- package/store/duplicate-phone-warning-store.js +18 -0
- package/store/entity-extract-store.js +72 -0
- package/store/file-preview-store.js +27 -0
- package/store/filter-store.js +289 -0
- package/store/index.js +22 -0
- package/store/knowledge-crawl-store.js +53 -0
- package/store/lead-list-filter-store.js +142 -0
- package/store/list-pagination-state.js +44 -0
- package/store/lumi-learn-from-chat-store.js +69 -0
- package/store/merge-suggestion-store.js +27 -0
- package/store/notification-store.js +63 -0
- package/store/preview-image-store.js +22 -0
- package/store/settings-store/multi-channel/email-list-store.js +20 -0
- package/store/settings-store/multi-channel/facebook-list-store.js +22 -0
- package/store/settings-store/multi-channel/google-list-store.js +20 -0
- package/store/settings-store/multi-channel/instagram-list-store.js +20 -0
- package/store/settings-store/multi-channel/misa-list-store.js +20 -0
- package/store/settings-store/multi-channel/nhanhvn-list-store.js +20 -0
- package/store/settings-store/multi-channel/shopee-list-store.js +20 -0
- package/store/settings-store/multi-channel/shopee-order-list-store.js +20 -0
- package/store/settings-store/multi-channel/sms-list-store.js +20 -0
- package/store/settings-store/multi-channel/tiktok-business-list-store.js +20 -0
- package/store/settings-store/multi-channel/tiktok-list-store.js +20 -0
- package/store/settings-store/multi-channel/zalo-list-store.js +22 -0
- package/store/settings-store/multi-channel/zalo-user-list-store.js +25 -0
- package/store/smart-qc-store/smart-qc-list-filter-store.js +70 -0
- package/store/tenant-config-store.js +21 -0
- package/store/user-detail-store.js +17 -0
- package/store/user-status-store.js +33 -0
- package/store/workflow-store.js +24 -0
- package/store/workspace-store.js +32 -0
- package/tailwind-preset.js +129 -0
- package/utils/chat-actions.js +414 -0
- package/utils/chat_socket.js +1225 -0
- package/utils/extra-columns.js +108 -0
- package/utils/file.js +316 -0
- package/utils/html-to-plain-text.js +12 -0
- package/utils/notification.js +71 -0
- package/utils/replaceZaloSprite.js +64 -0
- package/utils/show-be-error.js +17 -0
- package/utils/typing_socket.js +101 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Label } from "../../ui/label.js";
|
|
4
|
+
import UploadCustom from "./upload-custom.js";
|
|
5
|
+
import PreviewListFiles from "./preview-list-file.js";
|
|
6
|
+
import { cn } from "../../../lib/utils.js";
|
|
7
|
+
import {
|
|
8
|
+
EXTRAFIELD_FILE_UPLOAD_MAXSIZE,
|
|
9
|
+
EXTRAFIELD_FILE_UPLOAD_MAXCOUNT
|
|
10
|
+
} from "@zenify-omni/chat-js/constants/file-upload.js";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
12
|
+
function FilesUpload({
|
|
13
|
+
multiple = true,
|
|
14
|
+
maxSize = EXTRAFIELD_FILE_UPLOAD_MAXSIZE,
|
|
15
|
+
onFilesChange,
|
|
16
|
+
value,
|
|
17
|
+
isMiniSize,
|
|
18
|
+
showImageName,
|
|
19
|
+
classNameItem,
|
|
20
|
+
maxCount = EXTRAFIELD_FILE_UPLOAD_MAXCOUNT,
|
|
21
|
+
isChange = true,
|
|
22
|
+
disabled
|
|
23
|
+
}) {
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const [files, setFiles] = useState([]);
|
|
26
|
+
const removeFile = (updated) => {
|
|
27
|
+
setFiles(updated);
|
|
28
|
+
onFilesChange?.(updated.map((img) => img));
|
|
29
|
+
};
|
|
30
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(isMiniSize && "px-3"), children: [
|
|
31
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsx(
|
|
32
|
+
UploadCustom,
|
|
33
|
+
{
|
|
34
|
+
isChange,
|
|
35
|
+
isMiniSize,
|
|
36
|
+
onChange: onFilesChange,
|
|
37
|
+
setFiles,
|
|
38
|
+
disabled,
|
|
39
|
+
value,
|
|
40
|
+
maxSize,
|
|
41
|
+
maxCount,
|
|
42
|
+
multiple,
|
|
43
|
+
inputAccept: ".pdf,.doc,.docx,.xls,.xlsx,.txt",
|
|
44
|
+
allowedType: [
|
|
45
|
+
"application/pdf",
|
|
46
|
+
// pdf
|
|
47
|
+
"application/msword",
|
|
48
|
+
// doc
|
|
49
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
50
|
+
// docx
|
|
51
|
+
"application/vnd.ms-excel",
|
|
52
|
+
// xls
|
|
53
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
54
|
+
// xlsx
|
|
55
|
+
"text/plain"
|
|
56
|
+
// txt
|
|
57
|
+
],
|
|
58
|
+
title: t("common:message.orDragDropFileHere", {
|
|
59
|
+
defaultValue: "ho\u1EB7c k\xE9o th\u1EA3 file v\xE0o \u0111\xE2y"
|
|
60
|
+
}),
|
|
61
|
+
desc: t("common:message.fileUploadHint", {
|
|
62
|
+
maxSize,
|
|
63
|
+
defaultValue: "PDF, DOC, DOCX, XLS, XLSX, TXT t\u1ED1i \u0111a {maxSize}MB"
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
) }),
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-3", children: [
|
|
68
|
+
files.length > 0 && !isMiniSize && /* @__PURE__ */ jsx(Label, { className: "flex items-center justify-between text-xs font-medium text-foreground", children: /* @__PURE__ */ jsx("span", { children: t("common:label.selectedFilesCount", {
|
|
69
|
+
length: files.length,
|
|
70
|
+
defaultValue: "File \u0111\xE3 ch\u1ECDn ({length})"
|
|
71
|
+
}) }) }),
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
PreviewListFiles,
|
|
74
|
+
{
|
|
75
|
+
isRemoveFiles: isChange && !disabled,
|
|
76
|
+
classNameItem,
|
|
77
|
+
removeFile,
|
|
78
|
+
showImageName,
|
|
79
|
+
datas: files
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
] })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
FilesUpload
|
|
87
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { ChevronDown } from "lucide-react";
|
|
4
|
+
import { Label } from "../../ui/label.js";
|
|
5
|
+
import PreviewListImage from "./preview-list-image.js";
|
|
6
|
+
import UploadCustom from "./upload-custom.js";
|
|
7
|
+
import { cn } from "../../../lib/utils.js";
|
|
8
|
+
import {
|
|
9
|
+
EXTRAFIELD_IMAGE_UPLOAD_MAXSIZE,
|
|
10
|
+
EXTRAFIELD_IMAGE_UPLOAD_MAXCOUNT
|
|
11
|
+
} from "@zenify-omni/chat-js/constants/file-upload.js";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
13
|
+
const formatLinkToPreviewImage = (value) => {
|
|
14
|
+
if (!Array.isArray(value)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const data = value.filter((e) => e).map((e) => {
|
|
18
|
+
let formatValue = {};
|
|
19
|
+
if (typeof e === "string" || !e.file?.name) {
|
|
20
|
+
formatValue.file = {};
|
|
21
|
+
const previewUrl = typeof e === "string" ? e : e.preview || "";
|
|
22
|
+
formatValue.preview = previewUrl;
|
|
23
|
+
formatValue.file.name = previewUrl ? previewUrl.split("/").pop() : "image";
|
|
24
|
+
} else {
|
|
25
|
+
formatValue = e;
|
|
26
|
+
}
|
|
27
|
+
return formatValue;
|
|
28
|
+
});
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
function ImageUpload({
|
|
32
|
+
multiple = true,
|
|
33
|
+
maxSize = EXTRAFIELD_IMAGE_UPLOAD_MAXSIZE,
|
|
34
|
+
onImagesChange,
|
|
35
|
+
value,
|
|
36
|
+
isMiniSize,
|
|
37
|
+
showImageName,
|
|
38
|
+
maxImageShowing = 4,
|
|
39
|
+
maxCount = EXTRAFIELD_IMAGE_UPLOAD_MAXCOUNT,
|
|
40
|
+
disabled = false,
|
|
41
|
+
isChange = true
|
|
42
|
+
}) {
|
|
43
|
+
const { t } = useTranslation();
|
|
44
|
+
const [images, setImages] = useState([]);
|
|
45
|
+
const [isShowAll, setIsShowAll] = useState(false);
|
|
46
|
+
const removeImage = (updated) => {
|
|
47
|
+
setImages(updated);
|
|
48
|
+
onImagesChange?.(updated.map((img) => img));
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(isMiniSize && "px-3"), children: [
|
|
51
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsx(
|
|
52
|
+
UploadCustom,
|
|
53
|
+
{
|
|
54
|
+
isImage: true,
|
|
55
|
+
isChange,
|
|
56
|
+
disabled,
|
|
57
|
+
maxImageShowing,
|
|
58
|
+
isOptionShowAll: true,
|
|
59
|
+
isShowAll,
|
|
60
|
+
setIsShowAll,
|
|
61
|
+
isMiniSize,
|
|
62
|
+
onChange: onImagesChange,
|
|
63
|
+
setFiles: setImages,
|
|
64
|
+
value,
|
|
65
|
+
maxSize,
|
|
66
|
+
maxCount,
|
|
67
|
+
multiple,
|
|
68
|
+
allowedType: ["image/jpeg", "image/png", "image/jpg"],
|
|
69
|
+
inputAccept: "image/*",
|
|
70
|
+
title: t("common:message.orDragDropImage", {
|
|
71
|
+
defaultValue: "ho\u1EB7c k\xE9o th\u1EA3 \u1EA3nh v\xE0o \u0111\xE2y"
|
|
72
|
+
}),
|
|
73
|
+
desc: t("common:message.supportedImageTypesJpgPng", {
|
|
74
|
+
maxSize,
|
|
75
|
+
defaultValue: "JPG, JPEG, PNG t\u1ED1i \u0111a {maxSize}MB"
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
) }),
|
|
79
|
+
/* @__PURE__ */ jsx("div", { className: "my-2 space-y-3", children: images.length > 0 && !isMiniSize && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
80
|
+
/* @__PURE__ */ jsx(Label, { className: "flex items-center justify-between text-xs font-medium text-foreground", children: /* @__PURE__ */ jsx("span", { children: t("common:label.selectedImagesCount", {
|
|
81
|
+
length: images.length,
|
|
82
|
+
defaultValue: "\u1EA2nh \u0111\xE3 ch\u1ECDn ({length})"
|
|
83
|
+
}) }) }),
|
|
84
|
+
images.length > maxImageShowing && /* @__PURE__ */ jsx(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: "cursor-pointer p-1 text-foreground transition-transform duration-200 ease-in-out",
|
|
88
|
+
onClick: () => setIsShowAll(!isShowAll),
|
|
89
|
+
children: /* @__PURE__ */ jsx(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: `transition-transform duration-300 ease-in-out ${isShowAll ? "rotate-0" : "rotate-90"}`,
|
|
93
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { size: 16 })
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] }) }),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
PreviewListImage,
|
|
101
|
+
{
|
|
102
|
+
isRemoveImages: isChange,
|
|
103
|
+
disabled,
|
|
104
|
+
maxImageShowing: isShowAll ? images.length : maxImageShowing,
|
|
105
|
+
removeImages: removeImage,
|
|
106
|
+
showImageName,
|
|
107
|
+
images
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
] });
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
ImageUpload,
|
|
114
|
+
formatLinkToPreviewImage
|
|
115
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { placeholderSvg } from "../../../assets/public-urls.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
X,
|
|
6
|
+
ChevronLeft,
|
|
7
|
+
ChevronRight,
|
|
8
|
+
Download,
|
|
9
|
+
ZoomIn,
|
|
10
|
+
ZoomOut,
|
|
11
|
+
RotateCw,
|
|
12
|
+
RotateCcw,
|
|
13
|
+
RefreshCw
|
|
14
|
+
} from "lucide-react";
|
|
15
|
+
import { Button } from "../../ui/button.js";
|
|
16
|
+
import usePreviewImageStore from "../../../store/preview-image-store.js";
|
|
17
|
+
import { useShallow } from "zustand/react/shallow";
|
|
18
|
+
import { createPortal } from "react-dom";
|
|
19
|
+
import { saveAs } from "file-saver";
|
|
20
|
+
import { Dialog, DialogContent } from "../../ui/dialog.js";
|
|
21
|
+
const MIN_SCALE = 0.5;
|
|
22
|
+
const MAX_SCALE = 3;
|
|
23
|
+
const DEFAULT_SCALE = 1.8;
|
|
24
|
+
const ZOOM_STEP = 0.2;
|
|
25
|
+
function GlobalPreviewImage() {
|
|
26
|
+
const [scale, setScale] = useState(DEFAULT_SCALE);
|
|
27
|
+
const [rotation, setRotation] = useState(0);
|
|
28
|
+
const [modalImages, previewModal, setPreviewModal] = usePreviewImageStore(
|
|
29
|
+
useShallow((state) => [
|
|
30
|
+
state.modalImages,
|
|
31
|
+
state.previewModal,
|
|
32
|
+
state.setPreviewModal
|
|
33
|
+
])
|
|
34
|
+
);
|
|
35
|
+
const currentIndex = previewModal.currentIndex;
|
|
36
|
+
const isOpen = previewModal.isOpen;
|
|
37
|
+
const images = modalImages;
|
|
38
|
+
const resetTransform = () => {
|
|
39
|
+
setScale(DEFAULT_SCALE);
|
|
40
|
+
setRotation(0);
|
|
41
|
+
};
|
|
42
|
+
const changeImage = (data) => {
|
|
43
|
+
resetTransform();
|
|
44
|
+
setPreviewModal(data);
|
|
45
|
+
};
|
|
46
|
+
const clampScale = (value) => Math.max(MIN_SCALE, Math.min(value, MAX_SCALE));
|
|
47
|
+
const onZoomIn = () => setScale((prev) => clampScale(prev + ZOOM_STEP));
|
|
48
|
+
const onZoomOut = () => setScale((prev) => clampScale(prev - ZOOM_STEP));
|
|
49
|
+
const onRotateLeft = () => setRotation((prev) => prev - 90);
|
|
50
|
+
const onRotateRight = () => setRotation((prev) => prev + 90);
|
|
51
|
+
const onClose = () => {
|
|
52
|
+
changeImage({ isOpen: false, currentIndex: 0 });
|
|
53
|
+
};
|
|
54
|
+
const onNext = () => {
|
|
55
|
+
changeImage({
|
|
56
|
+
...previewModal,
|
|
57
|
+
currentIndex: (currentIndex + 1) % images.length
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const onPrev = () => {
|
|
61
|
+
changeImage({
|
|
62
|
+
...previewModal,
|
|
63
|
+
currentIndex: currentIndex === 0 ? images.length - 1 : currentIndex - 1
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const onSelectImage = (index) => {
|
|
67
|
+
changeImage({
|
|
68
|
+
...previewModal,
|
|
69
|
+
currentIndex: index
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const handleKeyDown = (e) => {
|
|
74
|
+
if (!isOpen) return;
|
|
75
|
+
switch (e.key) {
|
|
76
|
+
case "Escape":
|
|
77
|
+
onClose();
|
|
78
|
+
break;
|
|
79
|
+
case "ArrowLeft":
|
|
80
|
+
onPrev();
|
|
81
|
+
break;
|
|
82
|
+
case "ArrowRight":
|
|
83
|
+
onNext();
|
|
84
|
+
break;
|
|
85
|
+
case "+":
|
|
86
|
+
case "=":
|
|
87
|
+
onZoomIn();
|
|
88
|
+
break;
|
|
89
|
+
case "-":
|
|
90
|
+
case "_":
|
|
91
|
+
onZoomOut();
|
|
92
|
+
break;
|
|
93
|
+
case "r":
|
|
94
|
+
case "R":
|
|
95
|
+
onRotateRight();
|
|
96
|
+
break;
|
|
97
|
+
case "0":
|
|
98
|
+
resetTransform();
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
103
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
104
|
+
}, [isOpen, onClose, onNext, onPrev]);
|
|
105
|
+
if (!isOpen || !images[currentIndex]) return null;
|
|
106
|
+
const currentImage = images[currentIndex];
|
|
107
|
+
const hasMultipleImages = images.length > 1;
|
|
108
|
+
const handleBackdropClick = (e) => {
|
|
109
|
+
if (e.target === e.currentTarget) {
|
|
110
|
+
onClose();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const handleDownload = () => {
|
|
114
|
+
let cleanedUrl = currentImage.url;
|
|
115
|
+
if (cleanedUrl.includes("\n")) {
|
|
116
|
+
cleanedUrl = cleanedUrl.split("\n")[0].trim();
|
|
117
|
+
}
|
|
118
|
+
const filename = images[currentIndex].file?.name?.trim() || images[currentIndex].name?.trim() || "download";
|
|
119
|
+
saveAs(cleanedUrl, filename);
|
|
120
|
+
};
|
|
121
|
+
const handleWheel = (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
const newScale = clampScale(scale - e.deltaY * 1e-3);
|
|
124
|
+
setScale(newScale);
|
|
125
|
+
};
|
|
126
|
+
return createPortal(
|
|
127
|
+
/* @__PURE__ */ jsx(Dialog, { open: isOpen, children: /* @__PURE__ */ jsx(DialogContent, { className: "fixed inset-0 z-50 m-0 h-screen w-screen max-w-none translate-x-0 translate-y-0 !animate-none rounded-none border-none bg-transparent p-0 shadow-none !transition-none !duration-0", children: /* @__PURE__ */ jsxs(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: "relative z-10 flex h-full w-full flex-col items-center justify-center",
|
|
131
|
+
onClick: handleBackdropClick,
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ jsx("div", { className: "absolute left-0 right-0 top-0 z-20 bg-gradient-to-b from-black/50 to-transparent p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
134
|
+
/* @__PURE__ */ jsxs("div", { className: "text-white", children: [
|
|
135
|
+
/* @__PURE__ */ jsx("h3", { className: "max-w-md truncate text-lg font-semibold", children: currentImage.name }),
|
|
136
|
+
hasMultipleImages && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
137
|
+
currentIndex + 1,
|
|
138
|
+
" of ",
|
|
139
|
+
images.length
|
|
140
|
+
] })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
Button,
|
|
145
|
+
{
|
|
146
|
+
variant: "ghost",
|
|
147
|
+
size: "sm",
|
|
148
|
+
title: "Zoom out (-)",
|
|
149
|
+
disabled: scale <= MIN_SCALE,
|
|
150
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50 disabled:opacity-40",
|
|
151
|
+
onClick: onZoomOut,
|
|
152
|
+
children: /* @__PURE__ */ jsx(ZoomOut, { className: "h-5 w-5" })
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsx(
|
|
156
|
+
Button,
|
|
157
|
+
{
|
|
158
|
+
variant: "ghost",
|
|
159
|
+
size: "sm",
|
|
160
|
+
title: "Zoom in (+)",
|
|
161
|
+
disabled: scale >= MAX_SCALE,
|
|
162
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50 disabled:opacity-40",
|
|
163
|
+
onClick: onZoomIn,
|
|
164
|
+
children: /* @__PURE__ */ jsx(ZoomIn, { className: "h-5 w-5" })
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ jsx(
|
|
168
|
+
Button,
|
|
169
|
+
{
|
|
170
|
+
variant: "ghost",
|
|
171
|
+
size: "sm",
|
|
172
|
+
title: "Rotate left",
|
|
173
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
174
|
+
onClick: onRotateLeft,
|
|
175
|
+
children: /* @__PURE__ */ jsx(RotateCcw, { className: "h-5 w-5" })
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
Button,
|
|
180
|
+
{
|
|
181
|
+
variant: "ghost",
|
|
182
|
+
size: "sm",
|
|
183
|
+
title: "Rotate right (R)",
|
|
184
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
185
|
+
onClick: onRotateRight,
|
|
186
|
+
children: /* @__PURE__ */ jsx(RotateCw, { className: "h-5 w-5" })
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
Button,
|
|
191
|
+
{
|
|
192
|
+
variant: "ghost",
|
|
193
|
+
size: "sm",
|
|
194
|
+
title: "Reset (0)",
|
|
195
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
196
|
+
onClick: resetTransform,
|
|
197
|
+
children: /* @__PURE__ */ jsx(RefreshCw, { className: "h-5 w-5" })
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
Button,
|
|
202
|
+
{
|
|
203
|
+
variant: "ghost",
|
|
204
|
+
size: "sm",
|
|
205
|
+
title: "Download",
|
|
206
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
207
|
+
onClick: handleDownload,
|
|
208
|
+
children: /* @__PURE__ */ jsx(Download, { className: "h-5 w-5" })
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
/* @__PURE__ */ jsx(
|
|
212
|
+
Button,
|
|
213
|
+
{
|
|
214
|
+
variant: "ghost",
|
|
215
|
+
size: "sm",
|
|
216
|
+
title: "Close (Esc)",
|
|
217
|
+
className: "h-10 w-10 rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
218
|
+
onClick: onClose,
|
|
219
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" })
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] })
|
|
223
|
+
] }) }),
|
|
224
|
+
hasMultipleImages && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
Button,
|
|
227
|
+
{
|
|
228
|
+
variant: "ghost",
|
|
229
|
+
size: "sm",
|
|
230
|
+
className: "absolute left-4 top-1/2 z-20 h-12 w-12 -translate-y-1/2 transform rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
231
|
+
onClick: onPrev,
|
|
232
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-6 w-6" })
|
|
233
|
+
}
|
|
234
|
+
),
|
|
235
|
+
/* @__PURE__ */ jsx(
|
|
236
|
+
Button,
|
|
237
|
+
{
|
|
238
|
+
variant: "ghost",
|
|
239
|
+
size: "sm",
|
|
240
|
+
className: "absolute right-4 top-1/2 z-20 h-12 w-12 -translate-y-1/2 transform rounded-full bg-black/30 p-0 !text-white hover:bg-gray-500/50",
|
|
241
|
+
onClick: onNext,
|
|
242
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-6 w-6" })
|
|
243
|
+
}
|
|
244
|
+
)
|
|
245
|
+
] }),
|
|
246
|
+
currentImage.loading ? /* @__PURE__ */ jsx("div", { className: "z-10 flex h-[35vh] w-[35vw] items-center justify-center rounded-lg bg-black/20", children: /* @__PURE__ */ jsx("div", { className: "h-10 w-10 animate-spin rounded-full border-4 border-white/30 border-t-card" }) }) : /* @__PURE__ */ jsx(
|
|
247
|
+
"img",
|
|
248
|
+
{
|
|
249
|
+
style: { transform: `scale(${scale}) rotate(${rotation}deg)` },
|
|
250
|
+
onWheel: handleWheel,
|
|
251
|
+
src: currentImage.url || placeholderSvg,
|
|
252
|
+
alt: currentImage.name,
|
|
253
|
+
onClick: (e) => e.stopPropagation(),
|
|
254
|
+
className: "z-10 max-h-[35vh] max-w-[35vw] rounded-lg object-contain shadow-2xl transition-transform duration-300"
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
hasMultipleImages && /* @__PURE__ */ jsx("div", { className: "absolute bottom-0 left-0 right-0 z-20 bg-gradient-to-t from-black/50 to-transparent p-4", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "flex max-w-full space-x-2 overflow-x-auto p-3", children: images.map((image, index) => /* @__PURE__ */ jsxs(
|
|
258
|
+
"button",
|
|
259
|
+
{
|
|
260
|
+
className: `relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-lg border-2 transition-all duration-200 ${index === currentIndex ? "scale-110 border-card shadow-lg" : "border-transparent opacity-70 hover:border-border hover:opacity-100"}`,
|
|
261
|
+
onClick: () => onSelectImage(index),
|
|
262
|
+
children: [
|
|
263
|
+
image.loading ? /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center justify-center bg-black/20", children: /* @__PURE__ */ jsx("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-white/30 border-t-card" }) }) : /* @__PURE__ */ jsx(
|
|
264
|
+
"img",
|
|
265
|
+
{
|
|
266
|
+
src: image.url || placeholderSvg,
|
|
267
|
+
alt: image.name,
|
|
268
|
+
className: "h-full w-full object-cover"
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
index === currentIndex && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-white/20", children: /* @__PURE__ */ jsx("div", { className: "h-2 w-2 rounded-full bg-card" }) })
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
index
|
|
275
|
+
)) }) }) })
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
) }) }),
|
|
279
|
+
document.body
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
export {
|
|
283
|
+
GlobalPreviewImage as default
|
|
284
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Download, X } from "lucide-react";
|
|
4
|
+
import { cn } from "../../../lib/utils.js";
|
|
5
|
+
import {
|
|
6
|
+
getIconForContentType,
|
|
7
|
+
mimeTypes,
|
|
8
|
+
getMimeType,
|
|
9
|
+
checkMimeType,
|
|
10
|
+
getColor
|
|
11
|
+
} from "../previews/file-preview.js";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
13
|
+
const PreviewListFiles = ({
|
|
14
|
+
datas,
|
|
15
|
+
removeFile,
|
|
16
|
+
maxFileShowing,
|
|
17
|
+
isRemoveFiles = true,
|
|
18
|
+
isDownloadFiles = true,
|
|
19
|
+
classNameItem,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const [fileResults, setFileResults] = useState([]);
|
|
24
|
+
const removeFiles = (index) => {
|
|
25
|
+
URL.revokeObjectURL(datas[index].preview);
|
|
26
|
+
const updated = datas.filter((_, i) => i !== index);
|
|
27
|
+
setFileResults(updated);
|
|
28
|
+
removeFile(updated);
|
|
29
|
+
};
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const processFiles = async () => {
|
|
32
|
+
let results = datas;
|
|
33
|
+
if (maxFileShowing) {
|
|
34
|
+
results = datas.slice(0, maxFileShowing);
|
|
35
|
+
}
|
|
36
|
+
const processed = await Promise.all(
|
|
37
|
+
results.map(async (value) => {
|
|
38
|
+
const mimeType = await genMimeType(value.file.name, value.preview);
|
|
39
|
+
return { ...value, mimeType };
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
setFileResults(processed);
|
|
43
|
+
};
|
|
44
|
+
if (datas?.length > 0) {
|
|
45
|
+
processFiles();
|
|
46
|
+
} else {
|
|
47
|
+
setFileResults([]);
|
|
48
|
+
}
|
|
49
|
+
}, [datas, maxFileShowing]);
|
|
50
|
+
const genMimeType = async (fileName, preview) => {
|
|
51
|
+
const extension = fileName.split(".").pop().toLowerCase();
|
|
52
|
+
if (mimeTypes[extension]) {
|
|
53
|
+
return getMimeType(extension);
|
|
54
|
+
}
|
|
55
|
+
return await checkMimeType(preview);
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ jsx("div", { className: "!mt-1", children: fileResults.length > 0 && /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", maxFileShowing && "flex items-center"), children: [
|
|
58
|
+
fileResults.map((it, index) => /* @__PURE__ */ jsxs(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
className: cn(
|
|
62
|
+
"flex min-w-0 items-center justify-between rounded-md border bg-card p-2",
|
|
63
|
+
it.error ? "border-destructive" : "border-border-subtle",
|
|
64
|
+
classNameItem
|
|
65
|
+
),
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-grow items-center gap-2 overflow-hidden", children: [
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
className: cn(
|
|
72
|
+
"flex h-6 w-6 shrink-0 items-center justify-center rounded-full",
|
|
73
|
+
getColor(it.mimeType, it.file.name)
|
|
74
|
+
),
|
|
75
|
+
children: getIconForContentType(it.mimeType, "h-4 w-4")
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
"span",
|
|
80
|
+
{
|
|
81
|
+
className: cn(
|
|
82
|
+
"overflow-hidden truncate text-xs text-foreground",
|
|
83
|
+
props.classNameTitle
|
|
84
|
+
),
|
|
85
|
+
title: it.file.name,
|
|
86
|
+
children: decodeURIComponent(it.file.name)
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsxs("div", { className: "ml-1 flex shrink-0 items-center gap-2", children: [
|
|
91
|
+
isDownloadFiles && /* @__PURE__ */ jsx(
|
|
92
|
+
"a",
|
|
93
|
+
{
|
|
94
|
+
href: it.preview,
|
|
95
|
+
download: it.file.name,
|
|
96
|
+
className: "inline-flex items-center gap-1 text-xs text-primary transition-colors hover:text-primary",
|
|
97
|
+
"aria-label": t("common:action.downloadNamed", {
|
|
98
|
+
name: it.file.name,
|
|
99
|
+
defaultValue: "T\u1EA3i v\u1EC1 {name}"
|
|
100
|
+
}),
|
|
101
|
+
target: "_blank",
|
|
102
|
+
rel: "noopener noreferrer",
|
|
103
|
+
children: /* @__PURE__ */ jsx(Download, { className: "h-3 w-3" })
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
isRemoveFiles && /* @__PURE__ */ jsx(
|
|
107
|
+
"button",
|
|
108
|
+
{
|
|
109
|
+
type: "button",
|
|
110
|
+
onClick: () => removeFiles(index),
|
|
111
|
+
className: "text-destructive transition-colors hover:text-destructive",
|
|
112
|
+
"aria-label": t("common:action.deleteNamed", {
|
|
113
|
+
name: it.file.name,
|
|
114
|
+
defaultValue: "X\xF3a {name}"
|
|
115
|
+
}),
|
|
116
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }),
|
|
120
|
+
it.error && /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-destructive", children: it.error })
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
(it.id || "_map_file") + index
|
|
124
|
+
)),
|
|
125
|
+
maxFileShowing && maxFileShowing > 0 && datas.length > maxFileShowing && /* @__PURE__ */ jsxs("span", { className: "!m-0 ml-3 whitespace-nowrap font-medium text-muted-foreground", children: [
|
|
126
|
+
"+",
|
|
127
|
+
datas.length - maxFileShowing
|
|
128
|
+
] })
|
|
129
|
+
] }) });
|
|
130
|
+
};
|
|
131
|
+
var preview_list_file_default = PreviewListFiles;
|
|
132
|
+
export {
|
|
133
|
+
preview_list_file_default as default
|
|
134
|
+
};
|