@yogiswara/honcho-editor-ui 2.5.10 → 2.6.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.
Files changed (50) hide show
  1. package/dist/components/editor/HBulkPreset.js +12 -2
  2. package/dist/hooks/demo/HonchoEditorBulkDemo.d.ts +3 -0
  3. package/dist/hooks/demo/HonchoEditorBulkDemo.js +228 -0
  4. package/dist/hooks/demo/HonchoEditorSingleCleanDemo.d.ts +3 -0
  5. package/dist/hooks/demo/HonchoEditorSingleCleanDemo.js +354 -0
  6. package/dist/hooks/demo/index.d.ts +2 -0
  7. package/dist/hooks/demo/index.js +2 -0
  8. package/dist/hooks/editor/type.d.ts +71 -0
  9. package/dist/hooks/editor/useHonchoEditorBulk.d.ts +10 -12
  10. package/dist/hooks/editor/useHonchoEditorBulk.js +126 -10
  11. package/dist/hooks/editor/useHonchoEditorSingle.d.ts +43 -0
  12. package/dist/hooks/editor/useHonchoEditorSingle.js +158 -0
  13. package/dist/hooks/useAdjustmentHistory.d.ts +9 -5
  14. package/dist/hooks/useAdjustmentHistory.js +187 -31
  15. package/dist/hooks/useAdjustmentHistoryBatch.d.ts +18 -1
  16. package/dist/hooks/useAdjustmentHistoryBatch.js +627 -201
  17. package/dist/hooks/useGallerySwipe.d.ts +1 -1
  18. package/dist/hooks/usePaging.d.ts +1 -1
  19. package/dist/hooks/usePaging.js +1 -1
  20. package/dist/hooks/usePreset.d.ts +1 -1
  21. package/dist/hooks/usePreset.js +35 -35
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +1 -1
  24. package/dist/lib/context/EditorContext.d.ts +10 -0
  25. package/dist/lib/context/EditorContext.js +4 -2
  26. package/dist/lib/hooks/useEditorHeadless.d.ts +18 -2
  27. package/dist/lib/hooks/useEditorHeadless.js +142 -63
  28. package/dist/utils/adjustment.d.ts +2 -1
  29. package/dist/utils/adjustment.js +16 -0
  30. package/dist/utils/imageLoader.d.ts +11 -0
  31. package/dist/utils/imageLoader.js +53 -0
  32. package/package.json +1 -1
  33. package/dist/components/editor/GalleryAlbum/SimplifiedAlbumGallery.d.ts +0 -17
  34. package/dist/components/editor/GalleryAlbum/SimplifiedAlbumGallery.js +0 -14
  35. package/dist/components/editor/GalleryAlbum/SimplifiedImageItem.d.ts +0 -8
  36. package/dist/components/editor/GalleryAlbum/SimplifiedImageItem.js +0 -30
  37. package/dist/components/editor/HImageEditorPage.d.ts +0 -1
  38. package/dist/components/editor/HImageEditorPage.js +0 -187
  39. package/dist/hooks/__tests__/useGallerySwipe.test.d.ts +0 -0
  40. package/dist/hooks/__tests__/useGallerySwipe.test.js +0 -619
  41. package/dist/hooks/editor/useHonchoEditor.d.ts +0 -203
  42. package/dist/hooks/editor/useHonchoEditor.js +0 -716
  43. package/dist/hooks/useAdjustmentHistory.demo.d.ts +0 -8
  44. package/dist/hooks/useAdjustmentHistory.demo.js +0 -106
  45. package/dist/hooks/useAdjustmentHistory.example.d.ts +0 -38
  46. package/dist/hooks/useAdjustmentHistory.example.js +0 -182
  47. package/dist/hooks/useAdjustmentHistory.syncDemo.d.ts +0 -8
  48. package/dist/hooks/useAdjustmentHistory.syncDemo.js +0 -180
  49. package/dist/hooks/useGallerySwipe.example.d.ts +0 -24
  50. package/dist/hooks/useGallerySwipe.example.js +0 -184
@@ -1,184 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { useGallerySwipe } from './useGallerySwipe';
3
- import { useState, useEffect } from 'react';
4
- /**
5
- * Example usage of the useGallerySwipe hook
6
- * This shows various integration patterns and use cases
7
- */
8
- /**
9
- * Basic example: Simple image gallery with navigation buttons
10
- */
11
- export function BasicGalleryExample() {
12
- const [firebaseUid, setFirebaseUid] = useState('user123');
13
- const [currentImageId, setCurrentImageId] = useState('image_001');
14
- const [controller, setController] = useState(null);
15
- // Initialize controller (replace with your actual controller initialization)
16
- useEffect(() => {
17
- // Your controller initialization logic here
18
- const initController = async () => {
19
- // const controllerInstance = new YourController();
20
- // setController(controllerInstance);
21
- };
22
- initController();
23
- }, []);
24
- const { currentImageData, isNextAvailable, isPrevAvailable, onSwipeNext, onSwipePrev, isLoading, error } = useGallerySwipe(firebaseUid, currentImageId, controller);
25
- return (_jsxs("div", { className: "gallery-container", children: [error && (_jsxs("div", { className: "error-message", style: { color: 'red' }, children: ["Error: ", error] })), isLoading && (_jsx("div", { className: "loading-indicator", children: "Loading..." })), currentImageData && (_jsxs("div", { className: "image-display", children: [_jsx("img", { src: currentImageData.download?.path || currentImageData.raw_edited?.path, alt: `Image ${currentImageData.id}`, style: { maxWidth: '100%', height: 'auto' } }), _jsxs("p", { children: ["Image ID: ", currentImageData.id] }), _jsxs("p", { children: ["Event ID: ", currentImageData.event_id] })] })), _jsxs("div", { className: "navigation-controls", children: [_jsx("button", { onClick: onSwipePrev, disabled: !isPrevAvailable || isLoading, className: "nav-button prev", children: "\u2190 Previous" }), _jsx("button", { onClick: onSwipeNext, disabled: !isNextAvailable || isLoading, className: "nav-button next", children: "Next \u2192" })] })] }));
26
- }
27
- /**
28
- * Advanced example: Gallery with keyboard navigation and swipe gestures
29
- */
30
- export function AdvancedGalleryExample() {
31
- const [firebaseUid] = useState('user456');
32
- const [selectedImageId, setSelectedImageId] = useState('initial_image_id');
33
- const [controller] = useState(null); // Replace with actual controller
34
- const gallerySwipe = useGallerySwipe(firebaseUid, selectedImageId, controller);
35
- // Keyboard navigation
36
- useEffect(() => {
37
- const handleKeyPress = async (event) => {
38
- if (gallerySwipe.isLoading)
39
- return;
40
- switch (event.key) {
41
- case 'ArrowLeft':
42
- event.preventDefault();
43
- if (gallerySwipe.isPrevAvailable) {
44
- await gallerySwipe.onSwipePrev();
45
- }
46
- break;
47
- case 'ArrowRight':
48
- event.preventDefault();
49
- if (gallerySwipe.isNextAvailable) {
50
- await gallerySwipe.onSwipeNext();
51
- }
52
- break;
53
- }
54
- };
55
- window.addEventListener('keydown', handleKeyPress);
56
- return () => window.removeEventListener('keydown', handleKeyPress);
57
- }, [gallerySwipe]);
58
- // Touch/swipe gesture handlers (basic implementation)
59
- const [touchStart, setTouchStart] = useState(null);
60
- const [touchEnd, setTouchEnd] = useState(null);
61
- const handleTouchStart = (e) => {
62
- setTouchEnd(null);
63
- setTouchStart(e.targetTouches[0].clientX);
64
- };
65
- const handleTouchMove = (e) => {
66
- setTouchEnd(e.targetTouches[0].clientX);
67
- };
68
- const handleTouchEnd = async () => {
69
- if (!touchStart || !touchEnd)
70
- return;
71
- const distance = touchStart - touchEnd;
72
- const isLeftSwipe = distance > 50;
73
- const isRightSwipe = distance < -50;
74
- if (isLeftSwipe && gallerySwipe.isNextAvailable) {
75
- await gallerySwipe.onSwipeNext();
76
- }
77
- if (isRightSwipe && gallerySwipe.isPrevAvailable) {
78
- await gallerySwipe.onSwipePrev();
79
- }
80
- };
81
- return (_jsxs("div", { className: "advanced-gallery", children: [_jsxs("div", { className: "gallery-header", children: [_jsx("h2", { children: "Advanced Gallery Navigation" }), _jsxs("div", { className: "status-indicators", children: [_jsx("span", { className: `status ${gallerySwipe.isLoading ? 'loading' : 'ready'}`, children: gallerySwipe.isLoading ? 'Loading...' : 'Ready' }), _jsxs("span", { className: "navigation-status", children: ["Prev: ", gallerySwipe.isPrevAvailable ? '✓' : '✗', " | Next: ", gallerySwipe.isNextAvailable ? '✓' : '✗'] })] })] }), _jsxs("div", { className: "image-container", onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, style: {
82
- touchAction: 'pan-x',
83
- userSelect: 'none',
84
- position: 'relative'
85
- }, children: [gallerySwipe.currentImageData ? (_jsxs("div", { className: "image-wrapper", children: [_jsx("img", { src: gallerySwipe.currentImageData.raw_edited?.path ||
86
- gallerySwipe.currentImageData.download?.path, alt: `Gallery image ${gallerySwipe.currentImageData.id}`, style: {
87
- width: '100%',
88
- height: 'auto',
89
- display: 'block'
90
- } }), _jsxs("div", { className: "image-info", children: [_jsxs("p", { children: ["ID: ", gallerySwipe.currentImageData.id] }), _jsxs("p", { children: ["Event: ", gallerySwipe.currentImageData.event_id] })] })] })) : (_jsx("div", { className: "no-image", children: "No image loaded" })), gallerySwipe.error && (_jsx("div", { className: "error-overlay", children: gallerySwipe.error }))] }), _jsx("div", { className: "instructions", children: _jsx("p", { children: "Use arrow keys, navigation buttons, or swipe to navigate" }) })] }));
91
- }
92
- /**
93
- * Integration example: Using with existing useHonchoEditor
94
- */
95
- export function EditorIntegrationExample() {
96
- const [firebaseUid] = useState('editor_user');
97
- const [currentImageId, setCurrentImageId] = useState('editor_image_001');
98
- const [controller] = useState(null);
99
- // Gallery navigation hook
100
- const { currentImageData, isNextAvailable, isPrevAvailable, onSwipeNext, onSwipePrev, isLoading: galleryLoading, error: galleryError } = useGallerySwipe(firebaseUid, currentImageId, controller);
101
- // Update current image ID when gallery navigation changes
102
- useEffect(() => {
103
- if (currentImageData?.id && currentImageData.id !== currentImageId) {
104
- setCurrentImageId(currentImageData.id);
105
- // Trigger any editor updates here
106
- // e.g., loadImageFromId(firebaseUid, currentImageData.id);
107
- }
108
- }, [currentImageData, currentImageId, firebaseUid]);
109
- // Example: Integrate with your existing editor handlers
110
- const handleImageChange = async (direction) => {
111
- try {
112
- if (direction === 'next' && isNextAvailable) {
113
- await onSwipeNext();
114
- }
115
- else if (direction === 'prev' && isPrevAvailable) {
116
- await onSwipePrev();
117
- }
118
- }
119
- catch (error) {
120
- console.error('Navigation error:', error);
121
- }
122
- };
123
- return (_jsxs("div", { className: "editor-integration", children: [_jsxs("div", { className: "editor-header", children: [_jsx("button", { onClick: () => handleImageChange('prev'), disabled: !isPrevAvailable || galleryLoading, className: "nav-btn", children: "\u27E8 Prev Image" }), _jsx("span", { className: "current-image-info", children: currentImageData ? `Image: ${currentImageData.id}` : 'No image' }), _jsx("button", { onClick: () => handleImageChange('next'), disabled: !isNextAvailable || galleryLoading, className: "nav-btn", children: "Next Image \u27E9" })] }), galleryError && (_jsxs("div", { className: "error-banner", children: ["Gallery Error: ", galleryError] })), _jsx("div", { className: "editor-content", children: currentImageData && (_jsxs("div", { className: "editor-canvas", children: [_jsxs("p", { children: ["Editing: ", currentImageData.id] }), _jsxs("p", { children: ["Event: ", currentImageData.event_id] })] })) }), galleryLoading && (_jsx("div", { className: "loading-overlay", children: "Loading next image..." }))] }));
124
- }
125
- /**
126
- * Mobile-optimized example with touch gestures
127
- */
128
- export function MobileGalleryExample() {
129
- const [firebaseUid] = useState('mobile_user');
130
- const [imageId] = useState('mobile_image_001');
131
- const [controller] = useState(null);
132
- const gallery = useGallerySwipe(firebaseUid, imageId, controller);
133
- // Mobile-specific gesture handling
134
- const [swipeThreshold] = useState(75); // Minimum distance for swipe
135
- const [touchStartX, setTouchStartX] = useState(0);
136
- const [touchStartY, setTouchStartY] = useState(0);
137
- const handleTouchStart = (e) => {
138
- setTouchStartX(e.touches[0].clientX);
139
- setTouchStartY(e.touches[0].clientY);
140
- };
141
- const handleTouchEnd = async (e) => {
142
- const touchEndX = e.changedTouches[0].clientX;
143
- const touchEndY = e.changedTouches[0].clientY;
144
- const deltaX = touchStartX - touchEndX;
145
- const deltaY = Math.abs(touchStartY - touchEndY);
146
- // Only process horizontal swipes (ignore vertical)
147
- if (deltaY < 100 && Math.abs(deltaX) > swipeThreshold) {
148
- if (deltaX > 0 && gallery.isNextAvailable) {
149
- // Swipe left - next image
150
- await gallery.onSwipeNext();
151
- }
152
- else if (deltaX < 0 && gallery.isPrevAvailable) {
153
- // Swipe right - previous image
154
- await gallery.onSwipePrev();
155
- }
156
- }
157
- };
158
- return (_jsxs("div", { className: "mobile-gallery", style: { touchAction: 'pan-y' }, children: [_jsx("div", { className: "mobile-header", children: _jsxs("div", { className: "navigation-dots", children: [_jsx("span", { className: `dot ${gallery.isPrevAvailable ? 'active' : 'inactive'}`, children: "\u25CF" }), _jsx("span", { className: "current-dot", children: "\u25CF" }), _jsx("span", { className: `dot ${gallery.isNextAvailable ? 'active' : 'inactive'}`, children: "\u25CF" })] }) }), _jsxs("div", { className: "swipe-area", onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, style: {
159
- width: '100%',
160
- height: '70vh',
161
- position: 'relative',
162
- overflow: 'hidden'
163
- }, children: [gallery.currentImageData && (_jsx("img", { src: gallery.currentImageData.download?.path, alt: "Gallery image", style: {
164
- width: '100%',
165
- height: '100%',
166
- objectFit: 'contain',
167
- userSelect: 'none',
168
- pointerEvents: 'none'
169
- } })), gallery.isLoading && (_jsxs("div", { className: "mobile-loading", children: [_jsx("div", { className: "spinner", children: "\u25D0" }), _jsx("p", { children: "Loading..." })] })), gallery.error && (_jsx("div", { className: "mobile-error", children: _jsxs("p", { children: ["\u26A0\uFE0F ", gallery.error] }) }))] }), _jsx("div", { className: "mobile-footer", children: _jsxs("p", { className: "swipe-hint", children: ["Swipe left/right to navigate \u2022 ", gallery.currentImageData?.id || 'No image'] }) })] }));
170
- }
171
- /**
172
- * Error handling and loading states example
173
- */
174
- export function ErrorHandlingExample() {
175
- const [firebaseUid] = useState('test_user');
176
- const [imageId] = useState('test_image');
177
- const [controller] = useState(null);
178
- const { currentImageData, isNextAvailable, isPrevAvailable, onSwipeNext, onSwipePrev, isLoading, error } = useGallerySwipe(firebaseUid, imageId, controller);
179
- const handleRetry = () => {
180
- // Force re-initialization by changing a key prop or calling a refresh function
181
- window.location.reload(); // Simple retry approach
182
- };
183
- return (_jsxs("div", { className: "error-handling-example", children: [_jsxs("div", { className: "status-panel", children: [_jsx("h3", { children: "Gallery Status" }), _jsxs("div", { className: "status-grid", children: [_jsxs("div", { className: "status-item", children: [_jsx("label", { children: "Loading:" }), _jsx("span", { className: isLoading ? 'status-active' : 'status-inactive', children: isLoading ? 'Yes' : 'No' })] }), _jsxs("div", { className: "status-item", children: [_jsx("label", { children: "Error:" }), _jsx("span", { className: error ? 'status-error' : 'status-ok', children: error || 'None' })] }), _jsxs("div", { className: "status-item", children: [_jsx("label", { children: "Current Image:" }), _jsx("span", { children: currentImageData?.id || 'None' })] }), _jsxs("div", { className: "status-item", children: [_jsx("label", { children: "Navigation:" }), _jsxs("span", { children: ["Prev: ", isPrevAvailable ? '✓' : '✗', " | Next: ", isNextAvailable ? '✓' : '✗'] })] })] }), error && (_jsx("div", { className: "error-actions", children: _jsx("button", { onClick: handleRetry, className: "retry-button", children: "Retry" }) }))] }), _jsx("div", { className: "gallery-content", children: currentImageData ? (_jsx("div", { className: "image-preview", children: _jsx("img", { src: currentImageData.download?.path, alt: "Current", style: { maxWidth: '300px', maxHeight: '200px' } }) })) : (_jsx("div", { className: "no-content", children: isLoading ? 'Loading gallery...' : 'No image available' })) }), _jsxs("div", { className: "navigation-test", children: [_jsx("button", { onClick: onSwipePrev, disabled: !isPrevAvailable || isLoading, children: "Test Previous" }), _jsx("button", { onClick: onSwipeNext, disabled: !isNextAvailable || isLoading, children: "Test Next" })] })] }));
184
- }