@gamecp/ui 0.1.29 → 0.1.32

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.mjs CHANGED
@@ -805,7 +805,7 @@ function SmartDropdown({
805
805
  trigger,
806
806
  children,
807
807
  className = "",
808
- width = 384,
808
+ width = 300,
809
809
  maxHeight = 450,
810
810
  offset = 8,
811
811
  margin = 16,
@@ -853,7 +853,7 @@ function SmartDropdown({
853
853
  const availableLeftSpace = triggerRect.left - margin;
854
854
  const dynamicOffset = Math.max(20, availableLeftSpace * 0.2);
855
855
  right = viewportWidth - triggerRect.left + dynamicOffset;
856
- left = 0;
856
+ left = void 0;
857
857
  calculatedWidth = Math.min(
858
858
  calculatedWidth,
859
859
  triggerRect.left - dynamicOffset - margin
@@ -905,13 +905,13 @@ function SmartDropdown({
905
905
  finalMaxHeight = Math.min(maxHeight, spaceBelow);
906
906
  } else if (position === "top-left-aligned") {
907
907
  right = viewportWidth - triggerRect.right;
908
- left = 0;
908
+ left = void 0;
909
909
  top = triggerRect.top - offset;
910
910
  isAbove = true;
911
911
  finalMaxHeight = Math.min(maxHeight, spaceAbove);
912
912
  } else if (position === "bottom-left-aligned") {
913
913
  right = viewportWidth - triggerRect.right;
914
- left = 0;
914
+ left = void 0;
915
915
  top = triggerRect.bottom + offset;
916
916
  isAbove = false;
917
917
  finalMaxHeight = Math.min(maxHeight, spaceBelow);
@@ -1010,20 +1010,13 @@ function SmartDropdown({
1010
1010
  top: dropdownPosition.top,
1011
1011
  ...dropdownPosition.left !== void 0 ? { left: dropdownPosition.left } : {},
1012
1012
  ...dropdownPosition.right !== void 0 ? { right: dropdownPosition.right } : {},
1013
- width: width === "fit-content" ? "auto" : dropdownPosition.width,
1013
+ width: width ?? dropdownPosition.width,
1014
1014
  maxHeight: dropdownPosition.maxHeight
1015
1015
  },
1016
1016
  onClick: (e) => {
1017
1017
  e.stopPropagation();
1018
1018
  },
1019
- children: /* @__PURE__ */ jsx(
1020
- "div",
1021
- {
1022
- className: className ? className : "overflow-y-auto",
1023
- style: { maxHeight: dropdownPosition.maxHeight },
1024
- children: typeof children === "function" ? children({ isAbove: dropdownPosition.isAbove }) : children
1025
- }
1026
- )
1019
+ children: /* @__PURE__ */ jsx("div", { className: className ? className : "overflow-y-auto h-full", children: typeof children === "function" ? children({ isAbove: dropdownPosition.isAbove }) : children })
1027
1020
  }
1028
1021
  ),
1029
1022
  document.body
@@ -1043,6 +1036,8 @@ function SmartSelect({
1043
1036
  searchable = false,
1044
1037
  keepOpen = false,
1045
1038
  clearable = true,
1039
+ variant = "default",
1040
+ renderSelected,
1046
1041
  // API integration props
1047
1042
  onOpen,
1048
1043
  onClose,
@@ -1063,7 +1058,7 @@ function SmartSelect({
1063
1058
  );
1064
1059
  const hasSelection = multiple ? selectedValues.length > 0 : value && value !== "";
1065
1060
  const filteredOptions = searchable && searchTerm.trim() ? options.filter(
1066
- (option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()) || option.value.toLowerCase().includes(searchTerm.toLowerCase()) || option.description?.toLowerCase().includes(searchTerm.toLowerCase())
1061
+ (option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()) || option.value.toLowerCase().includes(searchTerm.toLowerCase()) || typeof option.description === "string" && option.description.toLowerCase().includes(searchTerm.toLowerCase())
1067
1062
  ) : options;
1068
1063
  const { focusedIndex, handleKeyDown, resetFocus } = useKeyboardNavigation({
1069
1064
  isOpen,
@@ -1172,10 +1167,10 @@ function SmartSelect({
1172
1167
  "aria-controls": "dropdown-listbox",
1173
1168
  "aria-autocomplete": "list",
1174
1169
  "aria-activedescendant": focusedIndex >= 0 ? `option-${focusedIndex}` : void 0,
1175
- className: `form-input truncate ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "opacity-50 cursor-not-allowed" : ""} ${className}`
1170
+ className: `form-input truncate ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "cursor-not-allowed" : ""} ${className}`
1176
1171
  }
1177
1172
  ),
1178
- hasSelection && clearable && /* @__PURE__ */ jsx(
1173
+ hasSelection && clearable && !disabled && /* @__PURE__ */ jsx(
1179
1174
  "button",
1180
1175
  {
1181
1176
  type: "button",
@@ -1231,7 +1226,7 @@ function SmartSelect({
1231
1226
  "aria-controls": "dropdown-listbox",
1232
1227
  "aria-label": placeholder,
1233
1228
  "aria-activedescendant": focusedIndex >= 0 ? `option-${focusedIndex}` : void 0,
1234
- className: `form-input flex items-center justify-between text-left ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "opacity-60 cursor-not-allowed" : ""} ${className}`,
1229
+ className: `${variant === "compact" ? "bg-background border border-border rounded-lg px-2 py-1 text-xs h-auto min-h-0 hover:bg-muted/50" : "form-input"} flex items-center justify-between text-left ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "cursor-not-allowed" : ""} ${className}`,
1235
1230
  children: /* @__PURE__ */ jsx(
1236
1231
  "span",
1237
1232
  {
@@ -1242,7 +1237,7 @@ function SmartSelect({
1242
1237
  selectedOptions[0].icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: selectedOptions[0].icon }),
1243
1238
  /* @__PURE__ */ jsx("span", { className: "truncate", children: displayText })
1244
1239
  ] });
1245
- })() : /* @__PURE__ */ jsx("span", { className: "truncate", children: placeholder }) : selectedOptions[0] ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 min-w-0 flex-1", children: [
1240
+ })() : /* @__PURE__ */ jsx("span", { className: "truncate", children: placeholder }) : selectedOptions[0] ? renderSelected ? renderSelected(selectedOptions[0]) : /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 min-w-0 flex-1", children: [
1246
1241
  selectedOptions[0].icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: selectedOptions[0].icon }),
1247
1242
  /* @__PURE__ */ jsx("span", { className: "truncate", children: selectedOptions[0].label })
1248
1243
  ] }) : /* @__PURE__ */ jsx("span", { className: "truncate", children: placeholder })
@@ -1250,7 +1245,7 @@ function SmartSelect({
1250
1245
  )
1251
1246
  }
1252
1247
  ),
1253
- hasSelection && clearable && /* @__PURE__ */ jsx(
1248
+ hasSelection && clearable && !disabled && /* @__PURE__ */ jsx(
1254
1249
  "button",
1255
1250
  {
1256
1251
  type: "button",
@@ -1301,18 +1296,42 @@ function SmartSelect({
1301
1296
  e.stopPropagation();
1302
1297
  handleSelect(option.value);
1303
1298
  },
1304
- className: `w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between min-h-[40px] transition-colors ${selectedValues.includes(option.value) ? "bg-accent border-l-2 border-l-ring" : index === focusedIndex ? "bg-muted text-muted-foreground ring-2 ring-ring" : ""}`,
1299
+ className: `w-full ${variant === "compact" ? "px-2 py-1.5 text-xs" : "px-3 py-1.5 text-sm"} text-left hover:bg-muted/50 flex items-center justify-between transition-colors ${selectedValues.includes(option.value) ? "bg-primary" : index === focusedIndex ? "bg-muted/50" : ""}`,
1305
1300
  children: [
1306
1301
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0 flex-1", children: [
1307
- option.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: option.icon }),
1302
+ option.icon && /* @__PURE__ */ jsx(
1303
+ "span",
1304
+ {
1305
+ className: `flex-shrink-0 ${selectedValues.includes(option.value) ? "text-primary-foreground" : ""}`,
1306
+ children: option.icon
1307
+ }
1308
+ ),
1308
1309
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
1309
1310
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1310
- /* @__PURE__ */ jsx("div", { className: "font-medium text-foreground truncate", children: option.label }),
1311
+ /* @__PURE__ */ jsx(
1312
+ "div",
1313
+ {
1314
+ className: `font-medium truncate ${selectedValues.includes(option.value) ? "text-primary-foreground" : "text-foreground"}`,
1315
+ children: option.label
1316
+ }
1317
+ ),
1311
1318
  option.metadata?.isDefault && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium success-badge flex-shrink-0", children: "Default" })
1312
1319
  ] }),
1313
- option.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground truncate", children: option.description }),
1314
- option.metadata?.args && option.metadata.args.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
1315
- /* @__PURE__ */ jsx("div", { className: "text-xs text-secondary-foreground mb-1", children: "Arguments:" }),
1320
+ option.description && /* @__PURE__ */ jsx(
1321
+ "div",
1322
+ {
1323
+ className: `text-xs truncate ${selectedValues.includes(option.value) ? "text-primary-foreground/80" : "text-muted-foreground"}`,
1324
+ children: option.description
1325
+ }
1326
+ ),
1327
+ option.metadata?.args && option.metadata.args.length > 0 && (!option.metadata.commandType || option.metadata.commandType === "command") && /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
1328
+ /* @__PURE__ */ jsx(
1329
+ "div",
1330
+ {
1331
+ className: `text-xs mb-1 ${selectedValues.includes(option.value) ? "text-primary-foreground/80" : "text-muted-foreground"}`,
1332
+ children: "Arguments:"
1333
+ }
1334
+ ),
1316
1335
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
1317
1336
  option.metadata.args.slice(0, 3).map((arg, argIndex) => /* @__PURE__ */ jsx(
1318
1337
  "span",
@@ -1322,11 +1341,17 @@ function SmartSelect({
1322
1341
  },
1323
1342
  argIndex
1324
1343
  )),
1325
- option.metadata.args.length > 3 && /* @__PURE__ */ jsxs("span", { className: "text-xs text-secondary-foreground", children: [
1326
- "+",
1327
- option.metadata.args.length - 3,
1328
- " more"
1329
- ] })
1344
+ option.metadata.args.length > 3 && /* @__PURE__ */ jsxs(
1345
+ "span",
1346
+ {
1347
+ className: `text-xs ${selectedValues.includes(option.value) ? "text-primary-foreground/80" : "text-muted-foreground"}`,
1348
+ children: [
1349
+ "+",
1350
+ option.metadata.args.length - 3,
1351
+ " more"
1352
+ ]
1353
+ }
1354
+ )
1330
1355
  ] })
1331
1356
  ] })
1332
1357
  ] })
@@ -1340,11 +1365,11 @@ function SmartSelect({
1340
1365
  },
1341
1366
  className: "w-4 h-4 text-primary bg-muted border-border rounded focus:ring-primary focus:ring-2"
1342
1367
  }
1343
- ) : selectedValues.includes(option.value) && /* @__PURE__ */ jsx(RiCheckLine, { className: "w-4 h-4 text-primary flex-shrink-0" })
1368
+ ) : selectedValues.includes(option.value) && /* @__PURE__ */ jsx(RiCheckLine, { className: "w-4 h-4 text-primary-foreground flex-shrink-0" })
1344
1369
  ]
1345
1370
  },
1346
1371
  option.value
1347
- )) : /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-secondary-foreground flex items-center gap-2", children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
1372
+ )) : /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground flex items-center gap-2", children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
1348
1373
  /* @__PURE__ */ jsx(RiLoader4Line, { className: "w-4 h-4 animate-spin" }),
1349
1374
  /* @__PURE__ */ jsx("span", { children: "Loading..." })
1350
1375
  ] }) : searchTerm.trim() ? /* @__PURE__ */ jsx("span", { children: "No results found" }) : /* @__PURE__ */ jsx("span", { children: "No options available" }) }) })
@@ -2489,7 +2514,7 @@ function FormInput({
2489
2514
  }
2490
2515
  )
2491
2516
  ] }),
2492
- footerDescription && /* @__PURE__ */ jsx("p", { className: "text-xs mt-1", children: footerDescription }),
2517
+ footerDescription && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: footerDescription }),
2493
2518
  error && /* @__PURE__ */ jsx("div", { id: `${name}-error`, className: "form-error", role: "alert", children: typeof error === "string" ? /* @__PURE__ */ jsx("p", { children: error }) : error })
2494
2519
  ] }) });
2495
2520
  }
@@ -2701,17 +2726,48 @@ function PageHeader({
2701
2726
  title,
2702
2727
  subtitle,
2703
2728
  rightContent,
2704
- className = ""
2729
+ className = "",
2730
+ size = "lg"
2705
2731
  }) {
2706
- return /* @__PURE__ */ jsx("div", { className: `mb-6 lg:mb-8 ${className}`, children: /* @__PURE__ */ jsxs("div", { className: "header-layout", children: [
2732
+ const sizeClasses5 = {
2733
+ sm: {
2734
+ container: "mb-6",
2735
+ icon: "w-5 h-5 lg:w-6 lg:h-6",
2736
+ title: "text-lg lg:text-xl",
2737
+ subtitle: "text-sm",
2738
+ spacing: "space-x-2 lg:space-x-3"
2739
+ },
2740
+ md: {
2741
+ container: "mb-6 lg:mb-8",
2742
+ icon: "w-6 h-6 lg:w-7 lg:h-7",
2743
+ title: "text-xl lg:text-2xl",
2744
+ subtitle: "text-sm",
2745
+ spacing: "space-x-2 lg:space-x-3"
2746
+ },
2747
+ lg: {
2748
+ container: "mb-6 lg:mb-8",
2749
+ icon: "w-6 h-6 lg:w-8 lg:h-8",
2750
+ title: "text-xl lg:text-3xl",
2751
+ subtitle: "text-sm",
2752
+ spacing: "space-x-2 lg:space-x-3"
2753
+ }
2754
+ };
2755
+ const currentSize = sizeClasses5[size];
2756
+ return /* @__PURE__ */ jsx("div", { className: `${currentSize.container} ${className}`, children: /* @__PURE__ */ jsxs("div", { className: "header-layout", children: [
2707
2757
  /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3", children: [
2708
- Icon && /* @__PURE__ */ jsx(Icon, { className: "w-6 h-6 lg:w-8 lg:h-8 flex-shrink-0" }),
2758
+ Icon && /* @__PURE__ */ jsx(Icon, { className: `${currentSize.icon} flex-shrink-0` }),
2709
2759
  /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
2710
- /* @__PURE__ */ jsx("h1", { className: "text-xl lg:text-3xl font-bold text-foreground truncate", children: title }),
2711
- subtitle && /* @__PURE__ */ jsx("p", { className: "text-sm lg:text-base text-muted-foreground", children: subtitle })
2760
+ /* @__PURE__ */ jsx("h1", { className: `${currentSize.title} font-bold truncate`, children: title }),
2761
+ subtitle && /* @__PURE__ */ jsx("p", { className: `${currentSize.subtitle} text-muted-foreground`, children: subtitle })
2712
2762
  ] })
2713
2763
  ] }),
2714
- rightContent && /* @__PURE__ */ jsx("div", { className: "flex items-center space-x-2 lg:space-x-3 flex-shrink-0", children: rightContent })
2764
+ rightContent && /* @__PURE__ */ jsx(
2765
+ "div",
2766
+ {
2767
+ className: `flex items-center ${currentSize.spacing} flex-shrink-0`,
2768
+ children: rightContent
2769
+ }
2770
+ )
2715
2771
  ] }) });
2716
2772
  }
2717
2773
  function Switch({
@@ -2738,32 +2794,32 @@ function Switch({
2738
2794
  const variants = {
2739
2795
  default: {
2740
2796
  checked: "bg-primary",
2741
- unchecked: "bg-input",
2797
+ unchecked: "bg-muted-foreground/40",
2742
2798
  ring: "focus:ring-primary"
2743
2799
  },
2744
2800
  success: {
2745
2801
  checked: "bg-success",
2746
- unchecked: "bg-input",
2802
+ unchecked: "bg-muted-foreground/40",
2747
2803
  ring: "focus:ring-success"
2748
2804
  },
2749
2805
  danger: {
2750
2806
  checked: "bg-destructive",
2751
- unchecked: "bg-input",
2807
+ unchecked: "bg-muted-foreground/40",
2752
2808
  ring: "focus:ring-destructive"
2753
2809
  },
2754
2810
  warning: {
2755
2811
  checked: "bg-warning",
2756
- unchecked: "bg-input",
2812
+ unchecked: "bg-muted-foreground/40",
2757
2813
  ring: "focus:ring-warning"
2758
2814
  },
2759
2815
  info: {
2760
2816
  checked: "bg-info",
2761
- unchecked: "bg-input",
2817
+ unchecked: "bg-muted-foreground/40",
2762
2818
  ring: "focus:ring-info"
2763
2819
  },
2764
2820
  embedded: {
2765
2821
  checked: "bg-success",
2766
- unchecked: "bg-input",
2822
+ unchecked: "bg-muted-foreground/40",
2767
2823
  ring: "focus:ring-success"
2768
2824
  }
2769
2825
  };
@@ -2784,9 +2840,9 @@ function Switch({
2784
2840
  disabled,
2785
2841
  onClick: toggle,
2786
2842
  className: `
2787
- relative inline-flex flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent
2843
+ relative inline-flex flex-shrink-0 cursor-pointer rounded-full border-2
2788
2844
  transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 ${currentVariant.ring} focus:ring-offset-2
2789
- ${checked ? currentVariant.checked : currentVariant.unchecked}
2845
+ ${checked ? `${currentVariant.checked} border-transparent` : `${currentVariant.unchecked} border-muted-foreground/30`}
2790
2846
  ${disabled ? "opacity-50 cursor-not-allowed" : ""}
2791
2847
  ${currentSize.track}
2792
2848
  `,