@expcat/tigercat-core 0.3.69 → 0.3.70

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
@@ -5150,6 +5150,203 @@ function getTextClasses(props) {
5150
5150
  );
5151
5151
  }
5152
5152
 
5153
+ // src/utils/image-utils.ts
5154
+ var imageBaseClasses = "relative inline-block overflow-hidden";
5155
+ function getImageImgClasses(fit) {
5156
+ const fitMap = {
5157
+ contain: "object-contain",
5158
+ cover: "object-cover",
5159
+ fill: "object-fill",
5160
+ none: "object-none",
5161
+ "scale-down": "object-scale-down"
5162
+ };
5163
+ return classNames("block w-full h-full", fitMap[fit]);
5164
+ }
5165
+ var imageErrorClasses = "flex items-center justify-center w-full h-full bg-[var(--tiger-image-error-bg,#f3f4f6)] text-[var(--tiger-image-error-text,#9ca3af)]";
5166
+ var imageLoadingClasses = "flex items-center justify-center w-full h-full bg-[var(--tiger-image-error-bg,#f3f4f6)] text-[var(--tiger-image-error-text,#9ca3af)] animate-pulse";
5167
+ var imagePreviewCursorClass = "cursor-pointer";
5168
+ var imageErrorIconPath = "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z";
5169
+ var zoomInIconPath = "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v6m3-3H7";
5170
+ var zoomOutIconPath = "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM13 10H7";
5171
+ var resetIconPath = "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15";
5172
+ var prevIconPath = "M15 19l-7-7 7-7";
5173
+ var nextIconPath = "M9 5l7 7-7 7";
5174
+ var previewCloseIconPath = "M6 18L18 6M6 6l12 12";
5175
+ var imagePreviewMaskClasses = "fixed inset-0 bg-[var(--tiger-image-mask,rgba(0,0,0,0.85))] transition-opacity";
5176
+ var imagePreviewWrapperClasses = "fixed inset-0 flex items-center justify-center select-none";
5177
+ var imagePreviewImgClasses = "max-w-none transition-transform duration-150 ease-out cursor-grab active:cursor-grabbing";
5178
+ var imagePreviewToolbarClasses = "absolute bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 rounded-full bg-[var(--tiger-image-toolbar-bg,rgba(0,0,0,0.6))] text-white";
5179
+ var imagePreviewToolbarBtnClasses = "flex items-center justify-center w-8 h-8 rounded-full hover:bg-white/20 transition-colors focus:outline-none focus:ring-2 focus:ring-white/50 disabled:opacity-40 disabled:cursor-not-allowed";
5180
+ var imagePreviewNavBtnClasses = "absolute top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-[var(--tiger-image-toolbar-bg,rgba(0,0,0,0.6))] text-white hover:bg-white/20 transition-colors focus:outline-none focus:ring-2 focus:ring-white/50 disabled:opacity-40 disabled:cursor-not-allowed";
5181
+ var imagePreviewCloseBtnClasses = "absolute top-4 right-4 flex items-center justify-center w-10 h-10 rounded-full bg-[var(--tiger-image-toolbar-bg,rgba(0,0,0,0.6))] text-white hover:bg-white/20 transition-colors focus:outline-none focus:ring-2 focus:ring-white/50";
5182
+ var imagePreviewCounterClasses = "text-sm text-white/80 mx-2 tabular-nums";
5183
+ var imageCropperContainerClasses = "relative overflow-hidden bg-[var(--tiger-image-cropper-bg,#1a1a2e)] select-none touch-none";
5184
+ var imageCropperImgClasses = "absolute top-0 left-0 max-w-none pointer-events-none";
5185
+ var imageCropperMaskClasses = "absolute inset-0 pointer-events-none";
5186
+ var imageCropperSelectionClasses = "absolute border-2 border-[var(--tiger-image-cropper-border,#ffffff)] pointer-events-none";
5187
+ var imageCropperGuideClasses = "absolute border-[var(--tiger-image-cropper-border,rgba(255,255,255,0.4))] pointer-events-none";
5188
+ var imageCropperDragAreaClasses = "absolute cursor-move";
5189
+ function getCropperHandleClasses(handle) {
5190
+ const base = "absolute w-3 h-3 bg-[var(--tiger-image-cropper-border,#ffffff)] border border-[var(--tiger-image-cropper-handle-border,rgba(0,0,0,0.3))]";
5191
+ const positionMap = {
5192
+ nw: "-top-1.5 -left-1.5 cursor-nw-resize",
5193
+ n: "-top-1.5 left-1/2 -translate-x-1/2 cursor-n-resize",
5194
+ ne: "-top-1.5 -right-1.5 cursor-ne-resize",
5195
+ e: "top-1/2 -right-1.5 -translate-y-1/2 cursor-e-resize",
5196
+ se: "-bottom-1.5 -right-1.5 cursor-se-resize",
5197
+ s: "-bottom-1.5 left-1/2 -translate-x-1/2 cursor-s-resize",
5198
+ sw: "-bottom-1.5 -left-1.5 cursor-sw-resize",
5199
+ w: "top-1/2 -left-1.5 -translate-y-1/2 cursor-w-resize"
5200
+ };
5201
+ return classNames(base, positionMap[handle]);
5202
+ }
5203
+ var CROP_HANDLES = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
5204
+ var cropUploadTriggerClasses = "inline-flex items-center justify-center gap-2 px-4 py-2 border-2 border-dashed border-[var(--tiger-border,#d1d5db)] rounded-lg text-[var(--tiger-text-muted,#6b7280)] hover:border-[var(--tiger-primary,#2563eb)] hover:text-[var(--tiger-primary,#2563eb)] transition-colors cursor-pointer focus:outline-none focus:ring-2 focus:ring-[var(--tiger-primary,#2563eb)] focus:ring-offset-2";
5205
+ var cropUploadTriggerDisabledClasses = "inline-flex items-center justify-center gap-2 px-4 py-2 border-2 border-dashed border-[var(--tiger-border,#d1d5db)] rounded-lg text-[var(--tiger-text-muted,#9ca3af)] cursor-not-allowed opacity-50";
5206
+ var uploadPlusIconPath = "M12 4v16m8-8H4";
5207
+ function clampScale(scale, min, max) {
5208
+ return Math.min(Math.max(scale, min), max);
5209
+ }
5210
+ function calculateTransform(scale, offsetX, offsetY) {
5211
+ return `translate(${offsetX}px, ${offsetY}px) scale(${scale})`;
5212
+ }
5213
+ function getPreviewNavState(currentIndex, total) {
5214
+ return {
5215
+ hasPrev: currentIndex > 0,
5216
+ hasNext: currentIndex < total - 1,
5217
+ counter: total > 1 ? `${currentIndex + 1} / ${total}` : ""
5218
+ };
5219
+ }
5220
+ function constrainCropRect(rect, imageWidth, imageHeight, aspectRatio) {
5221
+ let { x, y, width, height } = rect;
5222
+ if (aspectRatio && aspectRatio > 0) {
5223
+ const currentRatio = width / height;
5224
+ if (currentRatio > aspectRatio) {
5225
+ width = height * aspectRatio;
5226
+ } else {
5227
+ height = width / aspectRatio;
5228
+ }
5229
+ }
5230
+ width = Math.min(width, imageWidth);
5231
+ height = Math.min(height, imageHeight);
5232
+ x = Math.max(0, Math.min(x, imageWidth - width));
5233
+ y = Math.max(0, Math.min(y, imageHeight - height));
5234
+ return { x, y, width, height };
5235
+ }
5236
+ function resizeCropRect(rect, handle, dx, dy, imageWidth, imageHeight, aspectRatio, minW = 20, minH = 20) {
5237
+ let { x, y, width, height } = rect;
5238
+ switch (handle) {
5239
+ case "nw":
5240
+ x += dx;
5241
+ y += dy;
5242
+ width -= dx;
5243
+ height -= dy;
5244
+ break;
5245
+ case "n":
5246
+ y += dy;
5247
+ height -= dy;
5248
+ break;
5249
+ case "ne":
5250
+ width += dx;
5251
+ y += dy;
5252
+ height -= dy;
5253
+ break;
5254
+ case "e":
5255
+ width += dx;
5256
+ break;
5257
+ case "se":
5258
+ width += dx;
5259
+ height += dy;
5260
+ break;
5261
+ case "s":
5262
+ height += dy;
5263
+ break;
5264
+ case "sw":
5265
+ x += dx;
5266
+ width -= dx;
5267
+ height += dy;
5268
+ break;
5269
+ case "w":
5270
+ x += dx;
5271
+ width -= dx;
5272
+ break;
5273
+ }
5274
+ if (width < minW) {
5275
+ if (handle.includes("w")) {
5276
+ x = rect.x + rect.width - minW;
5277
+ }
5278
+ width = minW;
5279
+ }
5280
+ if (height < minH) {
5281
+ if (handle.includes("n")) {
5282
+ y = rect.y + rect.height - minH;
5283
+ }
5284
+ height = minH;
5285
+ }
5286
+ if (aspectRatio && aspectRatio > 0) {
5287
+ const newRatio = width / height;
5288
+ if (handle === "n" || handle === "s" || handle === "nw" || handle === "sw" || handle === "ne" || handle === "se") {
5289
+ width = height * aspectRatio;
5290
+ }
5291
+ if (handle === "e" || handle === "w") {
5292
+ height = width / aspectRatio;
5293
+ }
5294
+ if (newRatio !== aspectRatio && (handle === "nw" || handle === "ne" || handle === "sw" || handle === "se")) {
5295
+ width = height * aspectRatio;
5296
+ }
5297
+ }
5298
+ return constrainCropRect({ x, y, width, height }, imageWidth, imageHeight, aspectRatio);
5299
+ }
5300
+ function moveCropRect(rect, dx, dy, boundW, boundH) {
5301
+ const x = Math.max(0, Math.min(rect.x + dx, boundW - rect.width));
5302
+ const y = Math.max(0, Math.min(rect.y + dy, boundH - rect.height));
5303
+ return { x, y, width: rect.width, height: rect.height };
5304
+ }
5305
+ function getInitialCropRect(imageWidth, imageHeight, aspectRatio) {
5306
+ const padding = 0.1;
5307
+ let cropW = imageWidth * (1 - padding * 2);
5308
+ let cropH = imageHeight * (1 - padding * 2);
5309
+ if (aspectRatio && aspectRatio > 0) {
5310
+ if (cropW / cropH > aspectRatio) {
5311
+ cropW = cropH * aspectRatio;
5312
+ } else {
5313
+ cropH = cropW / aspectRatio;
5314
+ }
5315
+ }
5316
+ return {
5317
+ x: (imageWidth - cropW) / 2,
5318
+ y: (imageHeight - cropH) / 2,
5319
+ width: cropW,
5320
+ height: cropH
5321
+ };
5322
+ }
5323
+ function cropCanvas(image, cropRect, displayWidth, displayHeight, outputType = "image/png", quality = 0.92) {
5324
+ const scaleX = image.naturalWidth / displayWidth;
5325
+ const scaleY = image.naturalHeight / displayHeight;
5326
+ const sx = cropRect.x * scaleX;
5327
+ const sy = cropRect.y * scaleY;
5328
+ const sw = cropRect.width * scaleX;
5329
+ const sh = cropRect.height * scaleY;
5330
+ const canvas = document.createElement("canvas");
5331
+ canvas.width = Math.round(sw);
5332
+ canvas.height = Math.round(sh);
5333
+ const ctx = canvas.getContext("2d");
5334
+ if (ctx) {
5335
+ ctx.drawImage(image, sx, sy, sw, sh, 0, 0, canvas.width, canvas.height);
5336
+ }
5337
+ const dataUrl = canvas.toDataURL(outputType, quality);
5338
+ return { canvas, dataUrl };
5339
+ }
5340
+ function getTouchDistance(touch1, touch2) {
5341
+ const dx = touch1.clientX - touch2.clientX;
5342
+ const dy = touch1.clientY - touch2.clientY;
5343
+ return Math.sqrt(dx * dx + dy * dy);
5344
+ }
5345
+ function toCSSSize(value) {
5346
+ if (value === void 0) return void 0;
5347
+ return typeof value === "number" ? `${value}px` : value;
5348
+ }
5349
+
5153
5350
  // src/utils/carousel-utils.ts
5154
5351
  var carouselBaseClasses = "relative overflow-hidden w-full";
5155
5352
  var carouselTrackScrollClasses = "flex transition-transform ease-in-out";
@@ -6453,6 +6650,7 @@ export {
6453
6650
  ANIMATION_DURATION_FAST_MS,
6454
6651
  ANIMATION_DURATION_MS,
6455
6652
  ANIMATION_DURATION_SLOW_MS,
6653
+ CROP_HANDLES,
6456
6654
  CalendarIconPath,
6457
6655
  ChevronLeftIconPath,
6458
6656
  ChevronRightIconPath,
@@ -6557,6 +6755,7 @@ export {
6557
6755
  calculateCirclePath,
6558
6756
  calculatePagination,
6559
6757
  calculateStepStatus,
6758
+ calculateTransform,
6560
6759
  calendarSolidIcon20PathD,
6561
6760
  captureActiveElement,
6562
6761
  cardActionsClasses,
@@ -6598,6 +6797,7 @@ export {
6598
6797
  chevronRightSolidIcon20PathD,
6599
6798
  clampBarWidth,
6600
6799
  clampPercentage,
6800
+ clampScale,
6601
6801
  clampSlideIndex,
6602
6802
  classNames,
6603
6803
  clearFieldErrors,
@@ -6631,6 +6831,7 @@ export {
6631
6831
  computeFloatingPosition,
6632
6832
  computePieHoverOffset,
6633
6833
  computePieLabelLine,
6834
+ constrainCropRect,
6634
6835
  containerBaseClasses,
6635
6836
  containerCenteredClasses,
6636
6837
  containerMaxWidthClasses,
@@ -6646,6 +6847,9 @@ export {
6646
6847
  createPieArcPath,
6647
6848
  createPointScale,
6648
6849
  createPolygonPath,
6850
+ cropCanvas,
6851
+ cropUploadTriggerClasses,
6852
+ cropUploadTriggerDisabledClasses,
6649
6853
  datePickerBaseClasses,
6650
6854
  datePickerCalendarClasses,
6651
6855
  datePickerCalendarGridClasses,
@@ -6776,6 +6980,7 @@ export {
6776
6980
  getContainerClasses,
6777
6981
  getContainerHeight,
6778
6982
  getContainerScrollTop,
6983
+ getCropperHandleClasses,
6779
6984
  getCurrentTime,
6780
6985
  getDatePickerDayCellClasses,
6781
6986
  getDatePickerIconButtonClasses,
@@ -6823,6 +7028,8 @@ export {
6823
7028
  getFormWizardLabels,
6824
7029
  getGridColumnClasses,
6825
7030
  getGutterStyles,
7031
+ getImageImgClasses,
7032
+ getInitialCropRect,
6826
7033
  getInitials,
6827
7034
  getInputAffixClasses,
6828
7035
  getInputClasses,
@@ -6894,6 +7101,7 @@ export {
6894
7101
  getPopoverTitleClasses,
6895
7102
  getPopoverTriggerClasses,
6896
7103
  getPrevSlideIndex,
7104
+ getPreviewNavState,
6897
7105
  getProgressTextColorClasses,
6898
7106
  getProgressVariantClasses,
6899
7107
  getQuickJumperInputClasses,
@@ -6982,6 +7190,7 @@ export {
6982
7190
  getTooltipTriggerClasses,
6983
7191
  getTotalPages,
6984
7192
  getTotalTextClasses,
7193
+ getTouchDistance,
6985
7194
  getTransformOrigin,
6986
7195
  getTreeNodeClasses,
6987
7196
  getTreeNodeExpandIconClasses,
@@ -7005,6 +7214,25 @@ export {
7005
7214
  iconSvgDefaultStrokeLinejoin,
7006
7215
  iconSvgDefaultStrokeWidth,
7007
7216
  iconWrapperClasses,
7217
+ imageBaseClasses,
7218
+ imageCropperContainerClasses,
7219
+ imageCropperDragAreaClasses,
7220
+ imageCropperGuideClasses,
7221
+ imageCropperImgClasses,
7222
+ imageCropperMaskClasses,
7223
+ imageCropperSelectionClasses,
7224
+ imageErrorClasses,
7225
+ imageErrorIconPath,
7226
+ imageLoadingClasses,
7227
+ imagePreviewCloseBtnClasses,
7228
+ imagePreviewCounterClasses,
7229
+ imagePreviewCursorClass,
7230
+ imagePreviewImgClasses,
7231
+ imagePreviewMaskClasses,
7232
+ imagePreviewNavBtnClasses,
7233
+ imagePreviewToolbarBtnClasses,
7234
+ imagePreviewToolbarClasses,
7235
+ imagePreviewWrapperClasses,
7008
7236
  initRovingTabIndex,
7009
7237
  injectDropdownStyles,
7010
7238
  injectLoadingAnimationStyles,
@@ -7109,7 +7337,9 @@ export {
7109
7337
  modalSizeClasses,
7110
7338
  modalTitleClasses,
7111
7339
  modalWrapperClasses,
7340
+ moveCropRect,
7112
7341
  moveFocusInMenu,
7342
+ nextIconPath,
7113
7343
  normalizeActiveKeys,
7114
7344
  normalizeChartPadding,
7115
7345
  normalizeDate,
@@ -7142,6 +7372,8 @@ export {
7142
7372
  popconfirmSuccessIconPath,
7143
7373
  popconfirmWarningIconPath,
7144
7374
  prepareUploadFiles,
7375
+ prevIconPath,
7376
+ previewCloseIconPath,
7145
7377
  progressCircleBaseClasses,
7146
7378
  progressCircleSizeClasses,
7147
7379
  progressCircleTextClasses,
@@ -7166,8 +7398,10 @@ export {
7166
7398
  replaceKeys,
7167
7399
  resetAreaGradientCounter,
7168
7400
  resetBarGradientCounter,
7401
+ resetIconPath,
7169
7402
  resetLineGradientCounter,
7170
7403
  resetScatterGradientCounter,
7404
+ resizeCropRect,
7171
7405
  resolveChartPalette,
7172
7406
  resolveChartTooltipContent,
7173
7407
  resolveLocaleText,
@@ -7289,6 +7523,7 @@ export {
7289
7523
  to12HourFormat,
7290
7524
  to24HourFormat,
7291
7525
  toActivityTimelineItems,
7526
+ toCSSSize,
7292
7527
  toggleKey,
7293
7528
  togglePanelKey,
7294
7529
  treeBaseClasses,
@@ -7307,6 +7542,7 @@ export {
7307
7542
  treeNodeLabelClasses,
7308
7543
  treeNodeSelectedClasses,
7309
7544
  treeNodeWrapperClasses,
7545
+ uploadPlusIconPath,
7310
7546
  uploadStatusIconColorClasses,
7311
7547
  uploadStatusIconSizeClasses,
7312
7548
  validateCurrentPage,
@@ -7315,5 +7551,7 @@ export {
7315
7551
  validateFileType,
7316
7552
  validateForm,
7317
7553
  validateRule,
7318
- version
7554
+ version,
7555
+ zoomInIconPath,
7556
+ zoomOutIconPath
7319
7557
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expcat/tigercat-core",
3
- "version": "0.3.69",
3
+ "version": "0.3.70",
4
4
  "type": "module",
5
5
  "description": "Core utilities for Tigercat UI library",
6
6
  "license": "MIT",