@shohojdhara/atomix 0.1.28 → 0.1.30

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/dist/index.js CHANGED
@@ -3732,8 +3732,10 @@ function useDatePicker() {
3732
3732
  // This is a simplified implementation that would need improvement
3733
3733
  const parts = e.target.value.split('-');
3734
3734
  if (parts.length === 2) {
3735
- const startPart = parts[0].trim();
3736
- const endPart = parts[1].trim();
3735
+ var _parts$, _parts$2;
3736
+ const startPart = (_parts$ = parts[0]) === null || _parts$ === void 0 ? void 0 : _parts$.trim();
3737
+ const endPart = (_parts$2 = parts[1]) === null || _parts$2 === void 0 ? void 0 : _parts$2.trim();
3738
+ if (!startPart || !endPart) return;
3737
3739
  const parsedStart = new Date(startPart);
3738
3740
  if (!isNaN(parsedStart.getTime())) {
3739
3741
  setViewDate(parsedStart);
@@ -4407,6 +4409,7 @@ const Dropdown = _ref4 => {
4407
4409
  }, [isOpen, closeOnEscape, close]);
4408
4410
  // Keyboard navigation
4409
4411
  const handleKeyDown = React.useCallback(e => {
4412
+ var _focusableItems$2, _focusableItems4;
4410
4413
  if (!menuRef.current) return;
4411
4414
  const focusableItems = menuRef.current.querySelectorAll('[role="menuitem"]:not([disabled])');
4412
4415
  if (!focusableItems.length) return;
@@ -4415,26 +4418,30 @@ const Dropdown = _ref4 => {
4415
4418
  case 'ArrowDown':
4416
4419
  e.preventDefault();
4417
4420
  if (currentIndex < focusableItems.length - 1) {
4418
- focusableItems[currentIndex + 1].focus();
4421
+ var _focusableItems;
4422
+ (_focusableItems = focusableItems[currentIndex + 1]) === null || _focusableItems === void 0 || _focusableItems.focus();
4419
4423
  } else {
4420
- focusableItems[0].focus();
4424
+ var _focusableItems$;
4425
+ (_focusableItems$ = focusableItems[0]) === null || _focusableItems$ === void 0 || _focusableItems$.focus();
4421
4426
  }
4422
4427
  break;
4423
4428
  case 'ArrowUp':
4424
4429
  e.preventDefault();
4425
4430
  if (currentIndex > 0) {
4426
- focusableItems[currentIndex - 1].focus();
4431
+ var _focusableItems2;
4432
+ (_focusableItems2 = focusableItems[currentIndex - 1]) === null || _focusableItems2 === void 0 || _focusableItems2.focus();
4427
4433
  } else {
4428
- focusableItems[focusableItems.length - 1].focus();
4434
+ var _focusableItems3;
4435
+ (_focusableItems3 = focusableItems[focusableItems.length - 1]) === null || _focusableItems3 === void 0 || _focusableItems3.focus();
4429
4436
  }
4430
4437
  break;
4431
4438
  case 'Home':
4432
4439
  e.preventDefault();
4433
- focusableItems[0].focus();
4440
+ (_focusableItems$2 = focusableItems[0]) === null || _focusableItems$2 === void 0 || _focusableItems$2.focus();
4434
4441
  break;
4435
4442
  case 'End':
4436
4443
  e.preventDefault();
4437
- focusableItems[focusableItems.length - 1].focus();
4444
+ (_focusableItems4 = focusableItems[focusableItems.length - 1]) === null || _focusableItems4 === void 0 || _focusableItems4.focus();
4438
4445
  break;
4439
4446
  }
4440
4447
  }, []);
@@ -6811,18 +6818,25 @@ const usePhotoViewer = _ref => {
6811
6818
  }};
6812
6819
  if (touches.length === 1 && currentState.zoomLevel > 1) {
6813
6820
  setIsDragging(true);
6814
- setStartDragPosition({
6815
- x: touches[0].clientX - currentState.position.x,
6816
- y: touches[0].clientY - currentState.position.y
6817
- });
6821
+ const touch = touches[0];
6822
+ if (touch) {
6823
+ setStartDragPosition({
6824
+ x: touch.clientX - currentState.position.x,
6825
+ y: touch.clientY - currentState.position.y
6826
+ });
6827
+ }
6818
6828
  } else if (touches.length === 2) {
6819
- const dx = touches[0].clientX - touches[1].clientX;
6820
- const dy = touches[0].clientY - touches[1].clientY;
6821
- lastDistanceRef.current = Math.sqrt(dx * dx + dy * dy);
6822
- lastMidpointRef.current = {
6823
- x: (touches[0].clientX + touches[1].clientX) / 2,
6824
- y: (touches[0].clientY + touches[1].clientY) / 2
6825
- };
6829
+ const touch1 = touches[0];
6830
+ const touch2 = touches[1];
6831
+ if (touch1 && touch2) {
6832
+ const dx = touch1.clientX - touch2.clientX;
6833
+ const dy = touch1.clientY - touch2.clientY;
6834
+ lastDistanceRef.current = Math.sqrt(dx * dx + dy * dy);
6835
+ lastMidpointRef.current = {
6836
+ x: (touch1.clientX + touch2.clientX) / 2,
6837
+ y: (touch1.clientY + touch2.clientY) / 2
6838
+ };
6839
+ }
6826
6840
  }
6827
6841
  return prev;
6828
6842
  });
@@ -6855,63 +6869,77 @@ const usePhotoViewer = _ref => {
6855
6869
  if (currentState.zoomLevel > 1 && touches.length === 1) {
6856
6870
  event.preventDefault();
6857
6871
  }
6872
+ let newPosition = null;
6873
+ let zoomDelta = 0;
6874
+ let currentMidpoint = null;
6858
6875
  if (touches.length === 1 && isDragging && currentState.zoomLevel > 1) {
6859
- const newPosition = {
6860
- x: touches[0].clientX - startDragPosition.x,
6861
- y: touches[0].clientY - startDragPosition.y
6862
- };
6863
- const constrainedPosition = constrainPosition(newPosition, currentState.bounds);
6864
- return {
6865
- ...prev,
6866
- [currentIndex]: {
6867
- ...currentState,
6868
- position: constrainedPosition
6869
- }
6870
- };
6871
- } else if (touches.length === 2 && lastDistanceRef.current !== null) {
6872
- const dx = touches[0].clientX - touches[1].clientX;
6873
- const dy = touches[0].clientY - touches[1].clientY;
6874
- const distance = Math.sqrt(dx * dx + dy * dy);
6875
- const zoomDelta = (distance - lastDistanceRef.current) * 0.005;
6876
- lastDistanceRef.current = distance;
6877
- const currentMidpoint = {
6878
- x: (touches[0].clientX + touches[1].clientX) / 2,
6879
- y: (touches[0].clientY + touches[1].clientY) / 2
6880
- };
6881
- const oldZoom = currentState.zoomLevel;
6882
- const newZoom = Math.max(0.1, Math.min(5, oldZoom + zoomDelta));
6883
- if (newZoom !== oldZoom && lastMidpointRef.current) {
6884
- let rect;
6885
- try {
6886
- rect = event.currentTarget.getBoundingClientRect();
6887
- } catch (error) {
6888
- console.warn('PhotoViewer: Error getting bounding rect in touch move', error);
6889
- return prev;
6890
- }
6891
- if (!rect || rect.width === 0 || rect.height === 0) return prev;
6892
- const centerX = rect.width / 2;
6893
- const centerY = rect.height / 2;
6894
- const midpointX = currentMidpoint.x - rect.left - centerX;
6895
- const midpointY = currentMidpoint.y - rect.top - centerY;
6896
- const zoomFactor = newZoom / oldZoom;
6897
- const newBounds = calculateBounds(newZoom, currentState.rotation);
6898
- const newPosition = {
6899
- x: currentState.position.x + midpointX * (1 - zoomFactor) * 0.5,
6900
- y: currentState.position.y + midpointY * (1 - zoomFactor) * 0.5
6876
+ const touch = touches[0];
6877
+ if (touch) {
6878
+ newPosition = {
6879
+ x: touch.clientX - startDragPosition.x,
6880
+ y: touch.clientY - startDragPosition.y
6901
6881
  };
6902
- const constrainedPosition = constrainPosition(newPosition, newBounds);
6903
- lastMidpointRef.current = currentMidpoint;
6882
+ }
6883
+ if (newPosition) {
6884
+ const constrainedPosition = constrainPosition(newPosition, currentState.bounds);
6904
6885
  return {
6905
6886
  ...prev,
6906
6887
  [currentIndex]: {
6907
6888
  ...currentState,
6908
- zoomLevel: newZoom,
6909
- bounds: newBounds,
6910
6889
  position: constrainedPosition
6911
6890
  }
6912
6891
  };
6913
6892
  }
6914
- lastMidpointRef.current = currentMidpoint;
6893
+ } else if (touches.length === 2 && lastDistanceRef.current !== null) {
6894
+ const touch1 = touches[0];
6895
+ const touch2 = touches[1];
6896
+ if (touch1 && touch2) {
6897
+ const dx = touch1.clientX - touch2.clientX;
6898
+ const dy = touch1.clientY - touch2.clientY;
6899
+ const distance = Math.sqrt(dx * dx + dy * dy);
6900
+ zoomDelta = (distance - lastDistanceRef.current) * 0.005;
6901
+ lastDistanceRef.current = distance;
6902
+ currentMidpoint = {
6903
+ x: (touch1.clientX + touch2.clientX) / 2,
6904
+ y: (touch1.clientY + touch2.clientY) / 2
6905
+ };
6906
+ const oldZoom = currentState.zoomLevel;
6907
+ const newZoom = Math.max(0.1, Math.min(5, oldZoom + zoomDelta));
6908
+ if (newZoom !== oldZoom && lastMidpointRef.current && currentMidpoint) {
6909
+ let rect;
6910
+ try {
6911
+ rect = event.currentTarget.getBoundingClientRect();
6912
+ } catch (error) {
6913
+ console.warn('PhotoViewer: Error getting bounding rect in touch move', error);
6914
+ return prev;
6915
+ }
6916
+ if (!rect || rect.width === 0 || rect.height === 0) return prev;
6917
+ const centerX = rect.width / 2;
6918
+ const centerY = rect.height / 2;
6919
+ const midpointX = currentMidpoint.x - rect.left - centerX;
6920
+ const midpointY = currentMidpoint.y - rect.top - centerY;
6921
+ const zoomFactor = newZoom / oldZoom;
6922
+ const newBounds = calculateBounds(newZoom, currentState.rotation);
6923
+ const newPosition = {
6924
+ x: currentState.position.x + midpointX * (1 - zoomFactor) * 0.5,
6925
+ y: currentState.position.y + midpointY * (1 - zoomFactor) * 0.5
6926
+ };
6927
+ const constrainedPosition = constrainPosition(newPosition, newBounds);
6928
+ lastMidpointRef.current = currentMidpoint;
6929
+ return {
6930
+ ...prev,
6931
+ [currentIndex]: {
6932
+ ...currentState,
6933
+ zoomLevel: newZoom,
6934
+ bounds: newBounds,
6935
+ position: constrainedPosition
6936
+ }
6937
+ };
6938
+ }
6939
+ if (currentMidpoint) {
6940
+ lastMidpointRef.current = currentMidpoint;
6941
+ }
6942
+ }
6915
6943
  }
6916
6944
  return prev;
6917
6945
  });
@@ -7718,6 +7746,7 @@ const usePopover = _ref => {
7718
7746
  let bestPosition = position === 'auto' ? 'top' : position;
7719
7747
  // If specified position is 'auto', find the position with most space
7720
7748
  if (position === 'auto') {
7749
+ var _spaces$;
7721
7750
  const spaces = [{
7722
7751
  position: 'top',
7723
7752
  space: spaceTop
@@ -7734,7 +7763,7 @@ const usePopover = _ref => {
7734
7763
  // Sort by available space (descending)
7735
7764
  spaces.sort((a, b) => b.space - a.space);
7736
7765
  // Select position with most space
7737
- bestPosition = spaces[0].position;
7766
+ bestPosition = (_spaces$ = spaces[0]) === null || _spaces$ === void 0 ? void 0 : _spaces$.position;
7738
7767
  } else {
7739
7768
  // Check if the preferred position has enough space
7740
7769
  const needsFlip = position === 'top' && spaceTop < popoverRect.height + offset && spaceBottom >= popoverRect.height + offset || position === 'bottom' && spaceBottom < popoverRect.height + offset && spaceTop >= popoverRect.height + offset || position === 'left' && spaceLeft < popoverRect.width + offset && spaceRight >= popoverRect.width + offset || position === 'right' && spaceRight < popoverRect.width + offset && spaceLeft >= popoverRect.width + offset;
@@ -10739,7 +10768,7 @@ const Upload$1 = _ref => {
10739
10768
  // If multiple is not allowed, take only the first file
10740
10769
  const filesToProcess = multiple ? files : [files[0]];
10741
10770
  // Validate files
10742
- const validFiles = filesToProcess.filter(file => validateFile(file));
10771
+ const validFiles = filesToProcess.filter(file => file !== undefined && validateFile(file));
10743
10772
  // Notify about file selection
10744
10773
  if (validFiles.length && onFileSelect) {
10745
10774
  onFileSelect(validFiles);
@@ -11410,7 +11439,7 @@ const MasonryGrid$1 = /*#__PURE__*/React.forwardRef((_ref, ref) => {
11410
11439
  // Find the shortest column
11411
11440
  const shortestCol = columnHeights.current.indexOf(Math.min(...columnHeights.current));
11412
11441
  const left = shortestCol * (colWidth + gap);
11413
- const top = columnHeights.current[shortestCol];
11442
+ const top = columnHeights.current[shortestCol] ?? 0;
11414
11443
  const height = item.ref.current.offsetHeight;
11415
11444
  columnHeights.current[shortestCol] = top + height + gap;
11416
11445
  newPositions[index] = {
@@ -12285,15 +12314,18 @@ class Upload {
12285
12314
  // If multiple is not allowed, take only the first file
12286
12315
  const filesToProcess = this.options.multiple ? files : [files[0]];
12287
12316
  // Validate files
12288
- const validFiles = filesToProcess.filter(file => this._validateFile(file));
12317
+ const validFiles = filesToProcess.filter(file => file !== undefined && this._validateFile(file));
12289
12318
  // Notify about file selection
12290
12319
  if (validFiles.length && this.options.onFileSelect) {
12291
12320
  this.options.onFileSelect(validFiles);
12292
12321
  }
12293
12322
  // Process the first valid file
12294
12323
  if (validFiles.length) {
12295
- this.setFile(validFiles[0]);
12296
- this._simulateUpload(validFiles[0]);
12324
+ const firstFile = validFiles[0];
12325
+ if (firstFile) {
12326
+ this.setFile(firstFile);
12327
+ this._simulateUpload(firstFile);
12328
+ }
12297
12329
  }
12298
12330
  }
12299
12331
  /**