@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.esm.js CHANGED
@@ -3709,8 +3709,10 @@ function useDatePicker() {
3709
3709
  // This is a simplified implementation that would need improvement
3710
3710
  const parts = e.target.value.split('-');
3711
3711
  if (parts.length === 2) {
3712
- const startPart = parts[0].trim();
3713
- const endPart = parts[1].trim();
3712
+ var _parts$, _parts$2;
3713
+ const startPart = (_parts$ = parts[0]) === null || _parts$ === void 0 ? void 0 : _parts$.trim();
3714
+ const endPart = (_parts$2 = parts[1]) === null || _parts$2 === void 0 ? void 0 : _parts$2.trim();
3715
+ if (!startPart || !endPart) return;
3714
3716
  const parsedStart = new Date(startPart);
3715
3717
  if (!isNaN(parsedStart.getTime())) {
3716
3718
  setViewDate(parsedStart);
@@ -4384,6 +4386,7 @@ const Dropdown = _ref4 => {
4384
4386
  }, [isOpen, closeOnEscape, close]);
4385
4387
  // Keyboard navigation
4386
4388
  const handleKeyDown = useCallback(e => {
4389
+ var _focusableItems$2, _focusableItems4;
4387
4390
  if (!menuRef.current) return;
4388
4391
  const focusableItems = menuRef.current.querySelectorAll('[role="menuitem"]:not([disabled])');
4389
4392
  if (!focusableItems.length) return;
@@ -4392,26 +4395,30 @@ const Dropdown = _ref4 => {
4392
4395
  case 'ArrowDown':
4393
4396
  e.preventDefault();
4394
4397
  if (currentIndex < focusableItems.length - 1) {
4395
- focusableItems[currentIndex + 1].focus();
4398
+ var _focusableItems;
4399
+ (_focusableItems = focusableItems[currentIndex + 1]) === null || _focusableItems === void 0 || _focusableItems.focus();
4396
4400
  } else {
4397
- focusableItems[0].focus();
4401
+ var _focusableItems$;
4402
+ (_focusableItems$ = focusableItems[0]) === null || _focusableItems$ === void 0 || _focusableItems$.focus();
4398
4403
  }
4399
4404
  break;
4400
4405
  case 'ArrowUp':
4401
4406
  e.preventDefault();
4402
4407
  if (currentIndex > 0) {
4403
- focusableItems[currentIndex - 1].focus();
4408
+ var _focusableItems2;
4409
+ (_focusableItems2 = focusableItems[currentIndex - 1]) === null || _focusableItems2 === void 0 || _focusableItems2.focus();
4404
4410
  } else {
4405
- focusableItems[focusableItems.length - 1].focus();
4411
+ var _focusableItems3;
4412
+ (_focusableItems3 = focusableItems[focusableItems.length - 1]) === null || _focusableItems3 === void 0 || _focusableItems3.focus();
4406
4413
  }
4407
4414
  break;
4408
4415
  case 'Home':
4409
4416
  e.preventDefault();
4410
- focusableItems[0].focus();
4417
+ (_focusableItems$2 = focusableItems[0]) === null || _focusableItems$2 === void 0 || _focusableItems$2.focus();
4411
4418
  break;
4412
4419
  case 'End':
4413
4420
  e.preventDefault();
4414
- focusableItems[focusableItems.length - 1].focus();
4421
+ (_focusableItems4 = focusableItems[focusableItems.length - 1]) === null || _focusableItems4 === void 0 || _focusableItems4.focus();
4415
4422
  break;
4416
4423
  }
4417
4424
  }, []);
@@ -6788,18 +6795,25 @@ const usePhotoViewer = _ref => {
6788
6795
  }};
6789
6796
  if (touches.length === 1 && currentState.zoomLevel > 1) {
6790
6797
  setIsDragging(true);
6791
- setStartDragPosition({
6792
- x: touches[0].clientX - currentState.position.x,
6793
- y: touches[0].clientY - currentState.position.y
6794
- });
6798
+ const touch = touches[0];
6799
+ if (touch) {
6800
+ setStartDragPosition({
6801
+ x: touch.clientX - currentState.position.x,
6802
+ y: touch.clientY - currentState.position.y
6803
+ });
6804
+ }
6795
6805
  } else if (touches.length === 2) {
6796
- const dx = touches[0].clientX - touches[1].clientX;
6797
- const dy = touches[0].clientY - touches[1].clientY;
6798
- lastDistanceRef.current = Math.sqrt(dx * dx + dy * dy);
6799
- lastMidpointRef.current = {
6800
- x: (touches[0].clientX + touches[1].clientX) / 2,
6801
- y: (touches[0].clientY + touches[1].clientY) / 2
6802
- };
6806
+ const touch1 = touches[0];
6807
+ const touch2 = touches[1];
6808
+ if (touch1 && touch2) {
6809
+ const dx = touch1.clientX - touch2.clientX;
6810
+ const dy = touch1.clientY - touch2.clientY;
6811
+ lastDistanceRef.current = Math.sqrt(dx * dx + dy * dy);
6812
+ lastMidpointRef.current = {
6813
+ x: (touch1.clientX + touch2.clientX) / 2,
6814
+ y: (touch1.clientY + touch2.clientY) / 2
6815
+ };
6816
+ }
6803
6817
  }
6804
6818
  return prev;
6805
6819
  });
@@ -6832,63 +6846,77 @@ const usePhotoViewer = _ref => {
6832
6846
  if (currentState.zoomLevel > 1 && touches.length === 1) {
6833
6847
  event.preventDefault();
6834
6848
  }
6849
+ let newPosition = null;
6850
+ let zoomDelta = 0;
6851
+ let currentMidpoint = null;
6835
6852
  if (touches.length === 1 && isDragging && currentState.zoomLevel > 1) {
6836
- const newPosition = {
6837
- x: touches[0].clientX - startDragPosition.x,
6838
- y: touches[0].clientY - startDragPosition.y
6839
- };
6840
- const constrainedPosition = constrainPosition(newPosition, currentState.bounds);
6841
- return {
6842
- ...prev,
6843
- [currentIndex]: {
6844
- ...currentState,
6845
- position: constrainedPosition
6846
- }
6847
- };
6848
- } else if (touches.length === 2 && lastDistanceRef.current !== null) {
6849
- const dx = touches[0].clientX - touches[1].clientX;
6850
- const dy = touches[0].clientY - touches[1].clientY;
6851
- const distance = Math.sqrt(dx * dx + dy * dy);
6852
- const zoomDelta = (distance - lastDistanceRef.current) * 0.005;
6853
- lastDistanceRef.current = distance;
6854
- const currentMidpoint = {
6855
- x: (touches[0].clientX + touches[1].clientX) / 2,
6856
- y: (touches[0].clientY + touches[1].clientY) / 2
6857
- };
6858
- const oldZoom = currentState.zoomLevel;
6859
- const newZoom = Math.max(0.1, Math.min(5, oldZoom + zoomDelta));
6860
- if (newZoom !== oldZoom && lastMidpointRef.current) {
6861
- let rect;
6862
- try {
6863
- rect = event.currentTarget.getBoundingClientRect();
6864
- } catch (error) {
6865
- console.warn('PhotoViewer: Error getting bounding rect in touch move', error);
6866
- return prev;
6867
- }
6868
- if (!rect || rect.width === 0 || rect.height === 0) return prev;
6869
- const centerX = rect.width / 2;
6870
- const centerY = rect.height / 2;
6871
- const midpointX = currentMidpoint.x - rect.left - centerX;
6872
- const midpointY = currentMidpoint.y - rect.top - centerY;
6873
- const zoomFactor = newZoom / oldZoom;
6874
- const newBounds = calculateBounds(newZoom, currentState.rotation);
6875
- const newPosition = {
6876
- x: currentState.position.x + midpointX * (1 - zoomFactor) * 0.5,
6877
- y: currentState.position.y + midpointY * (1 - zoomFactor) * 0.5
6853
+ const touch = touches[0];
6854
+ if (touch) {
6855
+ newPosition = {
6856
+ x: touch.clientX - startDragPosition.x,
6857
+ y: touch.clientY - startDragPosition.y
6878
6858
  };
6879
- const constrainedPosition = constrainPosition(newPosition, newBounds);
6880
- lastMidpointRef.current = currentMidpoint;
6859
+ }
6860
+ if (newPosition) {
6861
+ const constrainedPosition = constrainPosition(newPosition, currentState.bounds);
6881
6862
  return {
6882
6863
  ...prev,
6883
6864
  [currentIndex]: {
6884
6865
  ...currentState,
6885
- zoomLevel: newZoom,
6886
- bounds: newBounds,
6887
6866
  position: constrainedPosition
6888
6867
  }
6889
6868
  };
6890
6869
  }
6891
- lastMidpointRef.current = currentMidpoint;
6870
+ } else if (touches.length === 2 && lastDistanceRef.current !== null) {
6871
+ const touch1 = touches[0];
6872
+ const touch2 = touches[1];
6873
+ if (touch1 && touch2) {
6874
+ const dx = touch1.clientX - touch2.clientX;
6875
+ const dy = touch1.clientY - touch2.clientY;
6876
+ const distance = Math.sqrt(dx * dx + dy * dy);
6877
+ zoomDelta = (distance - lastDistanceRef.current) * 0.005;
6878
+ lastDistanceRef.current = distance;
6879
+ currentMidpoint = {
6880
+ x: (touch1.clientX + touch2.clientX) / 2,
6881
+ y: (touch1.clientY + touch2.clientY) / 2
6882
+ };
6883
+ const oldZoom = currentState.zoomLevel;
6884
+ const newZoom = Math.max(0.1, Math.min(5, oldZoom + zoomDelta));
6885
+ if (newZoom !== oldZoom && lastMidpointRef.current && currentMidpoint) {
6886
+ let rect;
6887
+ try {
6888
+ rect = event.currentTarget.getBoundingClientRect();
6889
+ } catch (error) {
6890
+ console.warn('PhotoViewer: Error getting bounding rect in touch move', error);
6891
+ return prev;
6892
+ }
6893
+ if (!rect || rect.width === 0 || rect.height === 0) return prev;
6894
+ const centerX = rect.width / 2;
6895
+ const centerY = rect.height / 2;
6896
+ const midpointX = currentMidpoint.x - rect.left - centerX;
6897
+ const midpointY = currentMidpoint.y - rect.top - centerY;
6898
+ const zoomFactor = newZoom / oldZoom;
6899
+ const newBounds = calculateBounds(newZoom, currentState.rotation);
6900
+ const newPosition = {
6901
+ x: currentState.position.x + midpointX * (1 - zoomFactor) * 0.5,
6902
+ y: currentState.position.y + midpointY * (1 - zoomFactor) * 0.5
6903
+ };
6904
+ const constrainedPosition = constrainPosition(newPosition, newBounds);
6905
+ lastMidpointRef.current = currentMidpoint;
6906
+ return {
6907
+ ...prev,
6908
+ [currentIndex]: {
6909
+ ...currentState,
6910
+ zoomLevel: newZoom,
6911
+ bounds: newBounds,
6912
+ position: constrainedPosition
6913
+ }
6914
+ };
6915
+ }
6916
+ if (currentMidpoint) {
6917
+ lastMidpointRef.current = currentMidpoint;
6918
+ }
6919
+ }
6892
6920
  }
6893
6921
  return prev;
6894
6922
  });
@@ -7695,6 +7723,7 @@ const usePopover = _ref => {
7695
7723
  let bestPosition = position === 'auto' ? 'top' : position;
7696
7724
  // If specified position is 'auto', find the position with most space
7697
7725
  if (position === 'auto') {
7726
+ var _spaces$;
7698
7727
  const spaces = [{
7699
7728
  position: 'top',
7700
7729
  space: spaceTop
@@ -7711,7 +7740,7 @@ const usePopover = _ref => {
7711
7740
  // Sort by available space (descending)
7712
7741
  spaces.sort((a, b) => b.space - a.space);
7713
7742
  // Select position with most space
7714
- bestPosition = spaces[0].position;
7743
+ bestPosition = (_spaces$ = spaces[0]) === null || _spaces$ === void 0 ? void 0 : _spaces$.position;
7715
7744
  } else {
7716
7745
  // Check if the preferred position has enough space
7717
7746
  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;
@@ -10716,7 +10745,7 @@ const Upload$1 = _ref => {
10716
10745
  // If multiple is not allowed, take only the first file
10717
10746
  const filesToProcess = multiple ? files : [files[0]];
10718
10747
  // Validate files
10719
- const validFiles = filesToProcess.filter(file => validateFile(file));
10748
+ const validFiles = filesToProcess.filter(file => file !== undefined && validateFile(file));
10720
10749
  // Notify about file selection
10721
10750
  if (validFiles.length && onFileSelect) {
10722
10751
  onFileSelect(validFiles);
@@ -11387,7 +11416,7 @@ const MasonryGrid$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
11387
11416
  // Find the shortest column
11388
11417
  const shortestCol = columnHeights.current.indexOf(Math.min(...columnHeights.current));
11389
11418
  const left = shortestCol * (colWidth + gap);
11390
- const top = columnHeights.current[shortestCol];
11419
+ const top = columnHeights.current[shortestCol] ?? 0;
11391
11420
  const height = item.ref.current.offsetHeight;
11392
11421
  columnHeights.current[shortestCol] = top + height + gap;
11393
11422
  newPositions[index] = {
@@ -12262,15 +12291,18 @@ class Upload {
12262
12291
  // If multiple is not allowed, take only the first file
12263
12292
  const filesToProcess = this.options.multiple ? files : [files[0]];
12264
12293
  // Validate files
12265
- const validFiles = filesToProcess.filter(file => this._validateFile(file));
12294
+ const validFiles = filesToProcess.filter(file => file !== undefined && this._validateFile(file));
12266
12295
  // Notify about file selection
12267
12296
  if (validFiles.length && this.options.onFileSelect) {
12268
12297
  this.options.onFileSelect(validFiles);
12269
12298
  }
12270
12299
  // Process the first valid file
12271
12300
  if (validFiles.length) {
12272
- this.setFile(validFiles[0]);
12273
- this._simulateUpload(validFiles[0]);
12301
+ const firstFile = validFiles[0];
12302
+ if (firstFile) {
12303
+ this.setFile(firstFile);
12304
+ this._simulateUpload(firstFile);
12305
+ }
12274
12306
  }
12275
12307
  }
12276
12308
  /**