@yogiswara/honcho-editor-ui 3.6.10 → 3.8.1

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.
@@ -159,7 +159,7 @@ export interface Preset {
159
159
  }
160
160
  export interface Controller {
161
161
  onGetImage(firebaseUid: string, imageID: string): Promise<Gallery>;
162
- getImageList(firebaseUid: string, eventId: string, page: number): Promise<ResponseGalleryPaging>;
162
+ getImageList(firebaseUid: string, eventId: string, page: number, limit: number, sortBy?: string, sortDirection?: string): Promise<ResponseGalleryPaging>;
163
163
  syncConfig(firebaseUid: string): Promise<void>;
164
164
  handleBack(firebaseUid: string, imageID: string): void;
165
165
  getPresets(firebaseUid: string): Promise<Preset[]>;
@@ -12,6 +12,14 @@ export interface PhotoData {
12
12
  isSelected: boolean;
13
13
  adjustments?: Partial<AdjustmentValues>;
14
14
  }
15
+ export interface GalleryDataProps {
16
+ photos: any[];
17
+ isLoading: boolean;
18
+ isLoadingMore: boolean;
19
+ hasMore: boolean;
20
+ loadMore: () => void;
21
+ reloadGallery: () => void;
22
+ }
15
23
  export interface CopyCheckboxes {
16
24
  color: {
17
25
  temperature: boolean;
@@ -155,4 +163,4 @@ export interface UseHonchoEditorBulkReturn {
155
163
  * - Automatic backend synchronization for all state changes
156
164
  * - Comprehensive logging of multi-image operations
157
165
  */
158
- export declare function useHonchoEditorBulk(controller: Controller, eventID: string, firebaseUid: string): UseHonchoEditorBulkReturn;
166
+ export declare function useHonchoEditorBulk(controller: Controller, eventID: string, firebaseUid: string, galleryHookData: GalleryDataProps): UseHonchoEditorBulkReturn;
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
  import { useState, useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { useAdjustmentHistoryBatch } from '../useAdjustmentHistoryBatch';
4
- import { usePaging } from "../usePaging";
5
4
  import { usePreset } from "../usePreset";
6
5
  import { mapAdjustmentStateToAdjustmentEditor } from "../../utils/adjustment";
7
6
  import { log } from '../../utils/logger';
@@ -142,13 +141,16 @@ const getCurrentAdjustmentsForCopy = (selectedIds, currentBatch) => {
142
141
  * - Automatic backend synchronization for all state changes
143
142
  * - Comprehensive logging of multi-image operations
144
143
  */
145
- export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
144
+ export function useHonchoEditorBulk(controller, eventID, firebaseUid, galleryHookData) {
146
145
  const { state, actions: batchActions } = useAdjustmentHistoryBatch(controller, firebaseUid, eventID);
147
146
  const { currentBatch, selectedIds } = state;
148
- const { images, info, actions } = usePaging(controller, firebaseUid, eventID, {
149
- autoLoad: true,
150
- autoReset: false, // Prevent auto-reset to avoid loops
151
- });
147
+ // const { images, info, actions } = usePaging(controller, firebaseUid, eventID, {
148
+ // autoLoad: true,
149
+ // autoReset: false, // Prevent auto-reset to avoid loops
150
+ // });
151
+ const images = useMemo(() => {
152
+ return galleryHookData.photos.map(p => p.value || p);
153
+ }, [galleryHookData.photos]);
152
154
  // Preset management
153
155
  const { presets, info: presetInfo, actions: presetActions } = usePreset(controller, firebaseUid, {
154
156
  autoLoad: true,
@@ -178,12 +180,12 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
178
180
  };
179
181
  const readyState = useMemo(() => {
180
182
  const paging = {
181
- isReady: info.isReady ?? (info.isInitialized && !info.isLoading && info.error === null),
182
- isLoading: info.isLoading,
183
+ isReady: !galleryHookData.isLoading, // Simplified ready check
184
+ isLoading: galleryHookData.isLoading,
183
185
  };
184
186
  log.debug("[useHonchoEditorBulk] 📊 Paging state");
185
187
  const history = {
186
- isReady: state.isReady ?? true, // History sync happens on-demand, not blocking
188
+ isReady: state.isReady ?? true,
187
189
  isLoading: state.isLoading ?? false
188
190
  };
189
191
  log.debug("[useHonchoEditorBulk] 📊 History state");
@@ -191,26 +193,15 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
191
193
  isReady: presetInfo.isReady ?? (presetInfo.isInitialized && !presetInfo.isLoading),
192
194
  isLoading: presetInfo.isLoading
193
195
  };
194
- log.debug("[useHonchoEditorBulk] 📊 Preset state");
195
196
  const allReady = paging.isReady && history.isReady && presets.isReady;
196
197
  const anyLoading = paging.isLoading || history.isLoading || presets.isLoading;
197
- log.debug({
198
- paging: { isReady: paging.isReady, isLoading: paging.isLoading },
199
- history: { isReady: history.isReady, isLoading: history.isLoading },
200
- presets: { isReady: presets.isReady, isLoading: presets.isLoading },
201
- allReady,
202
- anyLoading
203
- }, '[useHonchoEditorBulk] 📊 Ready state computed');
204
198
  return {
205
199
  isReady: allReady,
206
200
  isLoading: anyLoading,
207
201
  operations: { paging, history, presets }
208
202
  };
209
203
  }, [
210
- info.isReady,
211
- info.isInitialized,
212
- info.isLoading,
213
- info.error,
204
+ galleryHookData.isLoading, // Updated dependency
214
205
  state.isReady,
215
206
  state.isLoading,
216
207
  presetInfo.isReady,
@@ -296,9 +287,9 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
296
287
  }, '[useHonchoEditorBulk] 🎨 Preset selection updated');
297
288
  }, [activePreset]);
298
289
  // Use loading states from usePaging instead of local state
299
- const isLoading = info.isLoading;
300
- const error = info.error;
301
- const hasMore = info.hasMore;
290
+ const isLoading = galleryHookData.isLoading;
291
+ const error = null;
292
+ const hasMore = galleryHookData.hasMore;
302
293
  const imageData = useMemo(() => {
303
294
  const res = images.map(item => {
304
295
  const basePhoto = mapGalleryToPhotoData(item, selectedIds);
@@ -536,7 +527,7 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
536
527
  return {
537
528
  imageData,
538
529
  isLoading,
539
- isLoadingMore: info.isLoadingMore,
530
+ isLoadingMore: galleryHookData.isLoadingMore,
540
531
  error,
541
532
  selectedIds,
542
533
  hasMore,
@@ -554,8 +545,8 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
554
545
  // Preset creation handlers
555
546
  presetActions, // Expose preset actions for create/rename/delete
556
547
  handleToggleImageSelection: batchActions.toggleSelection,
557
- handleLoadMore: actions.loadMore,
558
- handleRefresh: actions.refresh,
548
+ handleLoadMore: async () => { galleryHookData.loadMore(); },
549
+ handleRefresh: async () => { galleryHookData.reloadGallery(); },
559
550
  // Adjustment
560
551
  handleBulkTempDecreaseMax,
561
552
  handleBulkTempDecrease,
@@ -53,7 +53,7 @@ export function useGallerySwipe(firebaseUid, initImageId, controller) {
53
53
  // Search through pages until we find the target image or reach safety limit
54
54
  while (!isFound && page <= 100) { // Safety limit to prevent infinite loop
55
55
  try {
56
- const response = await controller.getImageList(firebaseUid, eventId, page);
56
+ const response = await controller.getImageList(firebaseUid, eventId, page, 20);
57
57
  if (response.gallery && response.gallery.length > 0) {
58
58
  // Accumulate all images from previous pages
59
59
  allImages = [...allImages, ...response.gallery];
@@ -96,7 +96,7 @@ export function useGallerySwipe(firebaseUid, initImageId, controller) {
96
96
  }
97
97
  try {
98
98
  const nextPageNum = currentPage + 1;
99
- const response = await controller.getImageList(firebaseUid, currentEventId, nextPageNum);
99
+ const response = await controller.getImageList(firebaseUid, currentEventId, nextPageNum, 20);
100
100
  if (response.gallery && response.gallery.length > 0) {
101
101
  // Update pagination state with new page information
102
102
  setCurrentPage(nextPageNum);
@@ -93,7 +93,7 @@ export function usePaging(controller, firebaseUid, eventId, options = {}) {
93
93
  setError(null);
94
94
  try {
95
95
  debugLog(`Loading page ${pageNum}...`, { isLoadMore });
96
- const response = await controllerRef.current.getImageList(firebaseUidRef.current, eventIdRef.current, pageNum);
96
+ const response = await controllerRef.current.getImageList(firebaseUidRef.current, eventIdRef.current, pageNum, 20);
97
97
  debugLog('Page loaded successfully', {
98
98
  page: response.current_page,
99
99
  imageCount: response.gallery.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "3.6.10",
3
+ "version": "3.8.1",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -11,9 +11,12 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build": "tsc",
14
- "test": "jest",
14
+ "test": "jest --passWithNoTests",
15
15
  "test:watch": "jest --watch",
16
- "test:coverage": "jest --coverage"
16
+ "test:coverage": "jest --coverage",
17
+ "preversion": "npm test",
18
+ "prepublishOnly": "npm run build",
19
+ "postversion": "git push origin main && git push --tags"
17
20
  },
18
21
  "peerDependencies": {
19
22
  "@emotion/react": "^11.11.1",