@expcat/tigercat-core 0.4.0 → 0.4.2

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
@@ -1110,6 +1110,106 @@ function parseInputValue(target, type) {
1110
1110
  return target.value;
1111
1111
  }
1112
1112
 
1113
+ // src/utils/input-number-utils.ts
1114
+ function getInputNumberWrapperClasses(disabled) {
1115
+ return classNames(
1116
+ "inline-flex items-center relative w-full",
1117
+ "border rounded-md shadow-sm",
1118
+ "bg-[var(--tiger-surface,#ffffff)]",
1119
+ "transition-colors",
1120
+ disabled ? "bg-[var(--tiger-surface-muted,#f3f4f6)] cursor-not-allowed opacity-60" : "hover:border-[var(--tiger-primary,#2563eb)]"
1121
+ );
1122
+ }
1123
+ var WRAPPER_STATUS_CLASSES = {
1124
+ default: "border-[var(--tiger-border,#e5e7eb)]",
1125
+ error: "border-red-500",
1126
+ success: "border-green-500",
1127
+ warning: "border-yellow-500"
1128
+ };
1129
+ var WRAPPER_FOCUS_STATUS_CLASSES = {
1130
+ default: "ring-[var(--tiger-primary,#2563eb)]",
1131
+ error: "ring-red-500",
1132
+ success: "ring-green-500",
1133
+ warning: "ring-yellow-500"
1134
+ };
1135
+ function getInputNumberStatusClasses(status = "default") {
1136
+ return WRAPPER_STATUS_CLASSES[status];
1137
+ }
1138
+ function getInputNumberFocusRingColor(status = "default") {
1139
+ return WRAPPER_FOCUS_STATUS_CLASSES[status];
1140
+ }
1141
+ var WRAPPER_SIZE_CLASSES = {
1142
+ sm: "h-8",
1143
+ md: "h-10",
1144
+ lg: "h-12"
1145
+ };
1146
+ function getInputNumberSizeClasses(size = "md") {
1147
+ return WRAPPER_SIZE_CLASSES[size];
1148
+ }
1149
+ var INPUT_SIZE_CLASSES2 = {
1150
+ sm: "text-sm px-2",
1151
+ md: "text-base px-3",
1152
+ lg: "text-lg px-4"
1153
+ };
1154
+ function getInputNumberInputClasses(size = "md", hasControlsRight, hasControlsBoth) {
1155
+ return classNames(
1156
+ "w-full h-full bg-transparent border-0 outline-none",
1157
+ "text-[var(--tiger-text,#111827)]",
1158
+ "placeholder:text-[var(--tiger-text-muted,#6b7280)]",
1159
+ "disabled:text-[var(--tiger-text-muted,#6b7280)] disabled:cursor-not-allowed",
1160
+ "[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
1161
+ INPUT_SIZE_CLASSES2[size],
1162
+ hasControlsRight && "pr-8",
1163
+ hasControlsBoth && "px-8 text-center"
1164
+ );
1165
+ }
1166
+ function getInputNumberStepButtonClasses(position, disabled) {
1167
+ return classNames(
1168
+ "flex items-center justify-center",
1169
+ "w-7 h-1/2",
1170
+ "border-l border-[var(--tiger-border,#e5e7eb)]",
1171
+ "text-[var(--tiger-text-muted,#6b7280)]",
1172
+ "transition-colors cursor-pointer select-none",
1173
+ position === "up" ? "border-b border-b-[var(--tiger-border,#e5e7eb)]" : "",
1174
+ disabled ? "opacity-40 cursor-not-allowed" : "hover:text-[var(--tiger-primary,#2563eb)] hover:bg-[var(--tiger-surface-muted,#f9fafb)]"
1175
+ );
1176
+ }
1177
+ function getInputNumberSideButtonClasses(position, disabled) {
1178
+ return classNames(
1179
+ "flex items-center justify-center",
1180
+ "w-8 h-full",
1181
+ "text-[var(--tiger-text-muted,#6b7280)]",
1182
+ "transition-colors cursor-pointer select-none",
1183
+ position === "left" ? "border-r border-r-[var(--tiger-border,#e5e7eb)] rounded-l-md" : "border-l border-l-[var(--tiger-border,#e5e7eb)] rounded-r-md",
1184
+ disabled ? "opacity-40 cursor-not-allowed" : "hover:text-[var(--tiger-primary,#2563eb)] hover:bg-[var(--tiger-surface-muted,#f9fafb)]"
1185
+ );
1186
+ }
1187
+ var inputNumberControlsRightClasses = "absolute right-0 top-0 h-full flex flex-col";
1188
+ var inputNumberUpIconPathD = "M7 10l5-5 5 5H7z";
1189
+ var inputNumberDownIconPathD = "M7 7l5 5 5-5H7z";
1190
+ var inputNumberMinusIconPathD = "M5 12h14";
1191
+ var inputNumberPlusIconPathD = "M12 5v14M5 12h14";
1192
+ function clampValue(value, min = -Infinity, max = Infinity) {
1193
+ return Math.min(Math.max(value, min), max);
1194
+ }
1195
+ function stepValue(current, step, direction, min = -Infinity, max = Infinity, precision) {
1196
+ const base = current ?? 0;
1197
+ const raw = direction === "up" ? base + step : base - step;
1198
+ const clamped = clampValue(raw, min, max);
1199
+ return precision !== void 0 ? formatPrecision(clamped, precision) : clamped;
1200
+ }
1201
+ function formatPrecision(value, precision) {
1202
+ return Number(value.toFixed(precision));
1203
+ }
1204
+ function isAtMin(value, min = -Infinity) {
1205
+ if (value === null || value === void 0) return false;
1206
+ return value <= min;
1207
+ }
1208
+ function isAtMax(value, max = Infinity) {
1209
+ if (value === null || value === void 0) return false;
1210
+ return value >= max;
1211
+ }
1212
+
1113
1213
  // src/utils/form-item-styles.ts
1114
1214
  var FORM_ITEM_SPACING = {
1115
1215
  sm: "mb-3 last:mb-0",
@@ -1885,7 +1985,7 @@ function isValidTimeValue(value, min, max) {
1885
1985
  function validateStep(step) {
1886
1986
  return Math.max(1, Math.floor(step));
1887
1987
  }
1888
- function clampValue(value, min, max) {
1988
+ function clampValue2(value, min, max) {
1889
1989
  return Math.max(min, Math.min(max, value));
1890
1990
  }
1891
1991
  function parseTime(timeString) {
@@ -1901,9 +2001,9 @@ function parseTime(timeString) {
1901
2001
  return { hours, minutes, seconds };
1902
2002
  }
1903
2003
  function formatTime(hours, minutes, seconds = 0, showSeconds = false) {
1904
- const h = clampValue(hours, 0, 23).toString().padStart(2, "0");
1905
- const m = clampValue(minutes, 0, 59).toString().padStart(2, "0");
1906
- const s = clampValue(seconds, 0, 59).toString().padStart(2, "0");
2004
+ const h = clampValue2(hours, 0, 23).toString().padStart(2, "0");
2005
+ const m = clampValue2(minutes, 0, 59).toString().padStart(2, "0");
2006
+ const s = clampValue2(seconds, 0, 59).toString().padStart(2, "0");
1907
2007
  return showSeconds ? `${h}:${m}:${s}` : `${h}:${m}`;
1908
2008
  }
1909
2009
  function to12HourFormat(hours) {
@@ -1948,8 +2048,8 @@ function formatTimeDisplayWithLocale(hours, minutes, seconds = 0, format = "24",
1948
2048
  }
1949
2049
  const { hours: hours12, period } = to12HourFormat(hours);
1950
2050
  const h = hours12.toString().padStart(2, "0");
1951
- const m = clampValue(minutes, 0, 59).toString().padStart(2, "0");
1952
- const s = clampValue(seconds, 0, 59).toString().padStart(2, "0");
2051
+ const m = clampValue2(minutes, 0, 59).toString().padStart(2, "0");
2052
+ const s = clampValue2(seconds, 0, 59).toString().padStart(2, "0");
1953
2053
  const timeStr = showSeconds ? `${h}:${m}:${s}` : `${h}:${m}`;
1954
2054
  const labels = getTimePeriodLabels(locale);
1955
2055
  const suffix = period === "AM" ? labels.am : labels.pm;
@@ -2443,6 +2543,11 @@ function getDividerStyle(orientation, color, thickness) {
2443
2543
  var layoutRootClasses = "tiger-layout flex flex-col min-h-screen";
2444
2544
  var layoutHeaderClasses = "tiger-header bg-[var(--tiger-surface,#ffffff)] border-b border-[var(--tiger-border,#e5e7eb)]";
2445
2545
  var layoutSidebarClasses = "tiger-sidebar bg-[var(--tiger-surface,#ffffff)] border-r border-[var(--tiger-border,#e5e7eb)] overflow-hidden transition-all duration-300";
2546
+ var layoutSidebarCollapsedClasses = "tiger-sidebar-collapsed";
2547
+ function getSidebarStyle(collapsed, width = "256px", collapsedWidth = "64px") {
2548
+ const w = collapsed ? collapsedWidth : width;
2549
+ return { width: w, minWidth: w };
2550
+ }
2446
2551
  var layoutContentClasses = "tiger-content flex-1 bg-[var(--tiger-layout-content-bg,#f9fafb)] p-6";
2447
2552
  var layoutFooterClasses = "tiger-footer bg-[var(--tiger-surface,#ffffff)] border-t border-[var(--tiger-border,#e5e7eb)] p-4";
2448
2553
 
@@ -2616,6 +2721,14 @@ function getCheckboxCellClasses(size) {
2616
2721
  };
2617
2722
  return classNames("text-center", widthClasses[size]);
2618
2723
  }
2724
+ function getExpandCellClasses(size) {
2725
+ return getCheckboxCellClasses(size);
2726
+ }
2727
+ var expandIconButtonClasses = "inline-flex items-center justify-center w-5 h-5 rounded cursor-pointer border-0 bg-transparent transition-transform duration-200 text-[var(--tiger-text-muted,#6b7280)] hover:text-[var(--tiger-text,#111827)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--tiger-focus-ring,var(--tiger-primary,#2563eb))]";
2728
+ function getExpandIconRotationClasses(expanded) {
2729
+ return expanded ? "rotate-90" : "rotate-0";
2730
+ }
2731
+ var expandedRowContentClasses = "bg-[var(--tiger-surface-muted,#f9fafb)] border-b border-[var(--tiger-border,#e5e7eb)]";
2619
2732
  function defaultSortFn(a, b) {
2620
2733
  if (a === null || a === void 0) return 1;
2621
2734
  if (b === null || b === void 0) return -1;
@@ -3530,12 +3643,16 @@ var submenuTitleClasses = "flex w-full items-center justify-between px-4 py-2 te
3530
3643
  var submenuExpandIconClasses = "ml-2 transition-transform duration-200";
3531
3644
  var submenuExpandIconExpandedClasses = "transform rotate-180";
3532
3645
  var submenuContentHorizontalClasses = "absolute left-0 top-full mt-0 min-w-[160px] bg-[var(--tiger-surface,#ffffff)] text-[var(--tiger-text,#111827)] border border-[var(--tiger-border,#e5e7eb)] rounded shadow-lg z-50";
3646
+ var submenuContentHorizontalNestedClasses = "absolute left-full top-0 ml-0 min-w-[160px] bg-[var(--tiger-surface,#ffffff)] text-[var(--tiger-text,#111827)] border border-[var(--tiger-border,#e5e7eb)] rounded shadow-lg z-50";
3533
3647
  var submenuContentPopupClasses = "absolute left-full top-0 ml-1 min-w-[180px] bg-[var(--tiger-surface,#ffffff)] text-[var(--tiger-text,#111827)] border border-[var(--tiger-border,#e5e7eb)] rounded shadow-lg z-50";
3534
3648
  var submenuContentVerticalClasses = "overflow-hidden pl-2";
3535
3649
  var submenuContentInlineClasses = "overflow-hidden";
3536
3650
  var menuItemGroupTitleClasses = "px-4 py-2 text-xs font-semibold text-[var(--tiger-text-muted,#6b7280)] uppercase tracking-wider";
3537
3651
  var menuCollapsedClasses = "min-w-[64px]";
3538
3652
  var menuCollapsedItemClasses = "justify-center px-2";
3653
+ function getSubmenuPopupZIndex(level) {
3654
+ return { zIndex: 50 + level * 10 };
3655
+ }
3539
3656
  function getMenuClasses(mode, theme, collapsed) {
3540
3657
  const classes = [menuBaseClasses, menuModeClasses[mode]];
3541
3658
  if (theme === "dark") {
@@ -3607,7 +3724,11 @@ function replaceKeys(key, keys) {
3607
3724
  function getMenuButtons(container) {
3608
3725
  return Array.from(
3609
3726
  container.querySelectorAll('button[data-tiger-menuitem="true"]')
3610
- ).filter((el) => !el.disabled && !el.closest('[data-tiger-menu-hidden="true"]'));
3727
+ ).filter((el) => {
3728
+ if (el.disabled || el.closest('[data-tiger-menu-hidden="true"]')) return false;
3729
+ const nearest = el.closest('ul[role="menu"]');
3730
+ return nearest === container;
3731
+ });
3611
3732
  }
3612
3733
  function moveFocusInMenu(current, delta) {
3613
3734
  const menuEl = current.closest('ul[role="menu"]');
@@ -6983,6 +7104,7 @@ export {
6983
7104
  clampPercentage,
6984
7105
  clampScale,
6985
7106
  clampSlideIndex,
7107
+ clampValue,
6986
7108
  classNames,
6987
7109
  clearFieldErrors,
6988
7110
  clipCommentTreeDepth,
@@ -7085,6 +7207,8 @@ export {
7085
7207
  dotsVariantConfig,
7086
7208
  ensureBarMinHeight,
7087
7209
  errorCircleSolidIcon20PathD,
7210
+ expandIconButtonClasses,
7211
+ expandedRowContentClasses,
7088
7212
  fileToUploadFile,
7089
7213
  filterData,
7090
7214
  filterOptions,
@@ -7108,6 +7232,7 @@ export {
7108
7232
  formatMonthYear,
7109
7233
  formatPageAriaLabel,
7110
7234
  formatPaginationTotal,
7235
+ formatPrecision,
7111
7236
  formatProgressText,
7112
7237
  formatTime,
7113
7238
  formatTimeDisplay,
@@ -7202,6 +7327,8 @@ export {
7202
7327
  getDropdownTriggerClasses,
7203
7328
  getElementOffsetTop,
7204
7329
  getErrorFields,
7330
+ getExpandCellClasses,
7331
+ getExpandIconRotationClasses,
7205
7332
  getFieldError,
7206
7333
  getFileListItemClasses,
7207
7334
  getFirstDayOfMonth,
@@ -7224,6 +7351,13 @@ export {
7224
7351
  getInputAffixClasses,
7225
7352
  getInputClasses,
7226
7353
  getInputErrorClasses,
7354
+ getInputNumberFocusRingColor,
7355
+ getInputNumberInputClasses,
7356
+ getInputNumberSideButtonClasses,
7357
+ getInputNumberSizeClasses,
7358
+ getInputNumberStatusClasses,
7359
+ getInputNumberStepButtonClasses,
7360
+ getInputNumberWrapperClasses,
7227
7361
  getInputWrapperClasses,
7228
7362
  getJustifyClasses,
7229
7363
  getLeafKeys,
@@ -7317,6 +7451,7 @@ export {
7317
7451
  getSeparatorContent,
7318
7452
  getShortDayNames,
7319
7453
  getShortMonthNames,
7454
+ getSidebarStyle,
7320
7455
  getSimplePaginationButtonClasses,
7321
7456
  getSimplePaginationButtonsWrapperClasses,
7322
7457
  getSimplePaginationContainerClasses,
@@ -7345,6 +7480,7 @@ export {
7345
7480
  getStepsContainerClasses,
7346
7481
  getSubMenuExpandIconClasses,
7347
7482
  getSubMenuTitleClasses,
7483
+ getSubmenuPopupZIndex,
7348
7484
  getSvgDefaultAttrs,
7349
7485
  getSwitchClasses,
7350
7486
  getSwitchThumbClasses,
@@ -7430,9 +7566,16 @@ export {
7430
7566
  injectShakeStyle,
7431
7567
  injectSvgAnimationStyles,
7432
7568
  inputFocusClasses,
7569
+ inputNumberControlsRightClasses,
7570
+ inputNumberDownIconPathD,
7571
+ inputNumberMinusIconPathD,
7572
+ inputNumberPlusIconPathD,
7573
+ inputNumberUpIconPathD,
7433
7574
  interactiveClasses,
7434
7575
  interpolateUploadLabel,
7435
7576
  isActivationKey,
7577
+ isAtMax,
7578
+ isAtMin,
7436
7579
  isBrowser,
7437
7580
  isDateInRange,
7438
7581
  isEnterKey,
@@ -7457,6 +7600,7 @@ export {
7457
7600
  layoutHeaderClasses,
7458
7601
  layoutRootClasses,
7459
7602
  layoutSidebarClasses,
7603
+ layoutSidebarCollapsedClasses,
7460
7604
  linePointTransitionClasses,
7461
7605
  linkBaseClasses,
7462
7606
  linkDisabledClasses,
@@ -7645,7 +7789,9 @@ export {
7645
7789
  statusSuccessIconPath,
7646
7790
  statusWarningIconPath,
7647
7791
  stepFinishChar,
7792
+ stepValue,
7648
7793
  submenuContentHorizontalClasses,
7794
+ submenuContentHorizontalNestedClasses,
7649
7795
  submenuContentInlineClasses,
7650
7796
  submenuContentPopupClasses,
7651
7797
  submenuContentVerticalClasses,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expcat/tigercat-core",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "Core utilities for Tigercat UI library",
6
6
  "license": "MIT",