@gamecp/ui 0.1.30 → 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.d.mts CHANGED
@@ -302,11 +302,12 @@ declare function SmartDropdown({ isOpen, onClose, trigger, children, className,
302
302
  interface Option {
303
303
  value: string;
304
304
  label: string;
305
- description?: string;
305
+ description?: React.ReactNode;
306
306
  icon?: React.ReactNode;
307
307
  metadata?: {
308
308
  isDefault?: boolean;
309
309
  args?: string[];
310
+ commandType?: 'command' | 'bash' | 'sh' | 'powershell';
310
311
  };
311
312
  }
312
313
  interface SmartSelectProps {
@@ -315,19 +316,21 @@ interface SmartSelectProps {
315
316
  onChange: (value: string | string[]) => void;
316
317
  placeholder?: string;
317
318
  className?: string;
318
- description?: string;
319
+ description?: React.ReactNode;
319
320
  disabled?: boolean;
320
321
  multiple?: boolean;
321
- width?: number;
322
+ width?: number | 'auto' | 'fit-content';
322
323
  searchable?: boolean;
323
324
  keepOpen?: boolean;
324
325
  clearable?: boolean;
326
+ variant?: 'default' | 'compact';
327
+ renderSelected?: (option: Option) => React.ReactNode;
325
328
  onOpen?: () => void;
326
329
  onClose?: () => void;
327
330
  onSearch?: (search: string) => void;
328
331
  isLoading?: boolean;
329
332
  }
330
- declare function SmartSelect({ options, value, onChange, placeholder, className, description, disabled, multiple, width, searchable, keepOpen, clearable, onOpen, onClose, onSearch, isLoading, }: SmartSelectProps): react_jsx_runtime.JSX.Element;
333
+ declare function SmartSelect({ options, value, onChange, placeholder, className, description, disabled, multiple, width, searchable, keepOpen, clearable, variant, renderSelected, onOpen, onClose, onSearch, isLoading, }: SmartSelectProps): react_jsx_runtime.JSX.Element;
331
334
 
332
335
  interface SkeletonProps {
333
336
  className?: string;
package/dist/index.d.ts CHANGED
@@ -302,11 +302,12 @@ declare function SmartDropdown({ isOpen, onClose, trigger, children, className,
302
302
  interface Option {
303
303
  value: string;
304
304
  label: string;
305
- description?: string;
305
+ description?: React.ReactNode;
306
306
  icon?: React.ReactNode;
307
307
  metadata?: {
308
308
  isDefault?: boolean;
309
309
  args?: string[];
310
+ commandType?: 'command' | 'bash' | 'sh' | 'powershell';
310
311
  };
311
312
  }
312
313
  interface SmartSelectProps {
@@ -315,19 +316,21 @@ interface SmartSelectProps {
315
316
  onChange: (value: string | string[]) => void;
316
317
  placeholder?: string;
317
318
  className?: string;
318
- description?: string;
319
+ description?: React.ReactNode;
319
320
  disabled?: boolean;
320
321
  multiple?: boolean;
321
- width?: number;
322
+ width?: number | 'auto' | 'fit-content';
322
323
  searchable?: boolean;
323
324
  keepOpen?: boolean;
324
325
  clearable?: boolean;
326
+ variant?: 'default' | 'compact';
327
+ renderSelected?: (option: Option) => React.ReactNode;
325
328
  onOpen?: () => void;
326
329
  onClose?: () => void;
327
330
  onSearch?: (search: string) => void;
328
331
  isLoading?: boolean;
329
332
  }
330
- declare function SmartSelect({ options, value, onChange, placeholder, className, description, disabled, multiple, width, searchable, keepOpen, clearable, onOpen, onClose, onSearch, isLoading, }: SmartSelectProps): react_jsx_runtime.JSX.Element;
333
+ declare function SmartSelect({ options, value, onChange, placeholder, className, description, disabled, multiple, width, searchable, keepOpen, clearable, variant, renderSelected, onOpen, onClose, onSearch, isLoading, }: SmartSelectProps): react_jsx_runtime.JSX.Element;
331
334
 
332
335
  interface SkeletonProps {
333
336
  className?: string;
package/dist/index.js CHANGED
@@ -812,7 +812,7 @@ function SmartDropdown({
812
812
  trigger,
813
813
  children,
814
814
  className = "",
815
- width = 384,
815
+ width = 300,
816
816
  maxHeight = 450,
817
817
  offset = 8,
818
818
  margin = 16,
@@ -860,7 +860,7 @@ function SmartDropdown({
860
860
  const availableLeftSpace = triggerRect.left - margin;
861
861
  const dynamicOffset = Math.max(20, availableLeftSpace * 0.2);
862
862
  right = viewportWidth - triggerRect.left + dynamicOffset;
863
- left = 0;
863
+ left = void 0;
864
864
  calculatedWidth = Math.min(
865
865
  calculatedWidth,
866
866
  triggerRect.left - dynamicOffset - margin
@@ -912,13 +912,13 @@ function SmartDropdown({
912
912
  finalMaxHeight = Math.min(maxHeight, spaceBelow);
913
913
  } else if (position === "top-left-aligned") {
914
914
  right = viewportWidth - triggerRect.right;
915
- left = 0;
915
+ left = void 0;
916
916
  top = triggerRect.top - offset;
917
917
  isAbove = true;
918
918
  finalMaxHeight = Math.min(maxHeight, spaceAbove);
919
919
  } else if (position === "bottom-left-aligned") {
920
920
  right = viewportWidth - triggerRect.right;
921
- left = 0;
921
+ left = void 0;
922
922
  top = triggerRect.bottom + offset;
923
923
  isAbove = false;
924
924
  finalMaxHeight = Math.min(maxHeight, spaceBelow);
@@ -1017,20 +1017,13 @@ function SmartDropdown({
1017
1017
  top: dropdownPosition.top,
1018
1018
  ...dropdownPosition.left !== void 0 ? { left: dropdownPosition.left } : {},
1019
1019
  ...dropdownPosition.right !== void 0 ? { right: dropdownPosition.right } : {},
1020
- width: width === "fit-content" ? "auto" : dropdownPosition.width,
1020
+ width: width ?? dropdownPosition.width,
1021
1021
  maxHeight: dropdownPosition.maxHeight
1022
1022
  },
1023
1023
  onClick: (e) => {
1024
1024
  e.stopPropagation();
1025
1025
  },
1026
- children: /* @__PURE__ */ jsxRuntime.jsx(
1027
- "div",
1028
- {
1029
- className: className ? className : "overflow-y-auto",
1030
- style: { maxHeight: dropdownPosition.maxHeight },
1031
- children: typeof children === "function" ? children({ isAbove: dropdownPosition.isAbove }) : children
1032
- }
1033
- )
1026
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: className ? className : "overflow-y-auto h-full", children: typeof children === "function" ? children({ isAbove: dropdownPosition.isAbove }) : children })
1034
1027
  }
1035
1028
  ),
1036
1029
  document.body
@@ -1050,6 +1043,8 @@ function SmartSelect({
1050
1043
  searchable = false,
1051
1044
  keepOpen = false,
1052
1045
  clearable = true,
1046
+ variant = "default",
1047
+ renderSelected,
1053
1048
  // API integration props
1054
1049
  onOpen,
1055
1050
  onClose,
@@ -1070,7 +1065,7 @@ function SmartSelect({
1070
1065
  );
1071
1066
  const hasSelection = multiple ? selectedValues.length > 0 : value && value !== "";
1072
1067
  const filteredOptions = searchable && searchTerm.trim() ? options.filter(
1073
- (option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()) || option.value.toLowerCase().includes(searchTerm.toLowerCase()) || option.description?.toLowerCase().includes(searchTerm.toLowerCase())
1068
+ (option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()) || option.value.toLowerCase().includes(searchTerm.toLowerCase()) || typeof option.description === "string" && option.description.toLowerCase().includes(searchTerm.toLowerCase())
1074
1069
  ) : options;
1075
1070
  const { focusedIndex, handleKeyDown, resetFocus } = useKeyboardNavigation({
1076
1071
  isOpen,
@@ -1179,10 +1174,10 @@ function SmartSelect({
1179
1174
  "aria-controls": "dropdown-listbox",
1180
1175
  "aria-autocomplete": "list",
1181
1176
  "aria-activedescendant": focusedIndex >= 0 ? `option-${focusedIndex}` : void 0,
1182
- className: `form-input truncate ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "opacity-50 cursor-not-allowed" : ""} ${className}`
1177
+ className: `form-input truncate ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "cursor-not-allowed" : ""} ${className}`
1183
1178
  }
1184
1179
  ),
1185
- hasSelection && clearable && /* @__PURE__ */ jsxRuntime.jsx(
1180
+ hasSelection && clearable && !disabled && /* @__PURE__ */ jsxRuntime.jsx(
1186
1181
  "button",
1187
1182
  {
1188
1183
  type: "button",
@@ -1238,7 +1233,7 @@ function SmartSelect({
1238
1233
  "aria-controls": "dropdown-listbox",
1239
1234
  "aria-label": placeholder,
1240
1235
  "aria-activedescendant": focusedIndex >= 0 ? `option-${focusedIndex}` : void 0,
1241
- className: `form-input flex items-center justify-between text-left ${hasSelection ? "pr-12" : "pr-8"} ${disabled ? "opacity-60 cursor-not-allowed" : ""} ${className}`,
1236
+ 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}`,
1242
1237
  children: /* @__PURE__ */ jsxRuntime.jsx(
1243
1238
  "span",
1244
1239
  {
@@ -1249,7 +1244,7 @@ function SmartSelect({
1249
1244
  selectedOptions[0].icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: selectedOptions[0].icon }),
1250
1245
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: displayText })
1251
1246
  ] });
1252
- })() : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: placeholder }) : selectedOptions[0] ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1 min-w-0 flex-1", children: [
1247
+ })() : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: placeholder }) : selectedOptions[0] ? renderSelected ? renderSelected(selectedOptions[0]) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1 min-w-0 flex-1", children: [
1253
1248
  selectedOptions[0].icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: selectedOptions[0].icon }),
1254
1249
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: selectedOptions[0].label })
1255
1250
  ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: placeholder })
@@ -1257,7 +1252,7 @@ function SmartSelect({
1257
1252
  )
1258
1253
  }
1259
1254
  ),
1260
- hasSelection && clearable && /* @__PURE__ */ jsxRuntime.jsx(
1255
+ hasSelection && clearable && !disabled && /* @__PURE__ */ jsxRuntime.jsx(
1261
1256
  "button",
1262
1257
  {
1263
1258
  type: "button",
@@ -1308,18 +1303,42 @@ function SmartSelect({
1308
1303
  e.stopPropagation();
1309
1304
  handleSelect(option.value);
1310
1305
  },
1311
- 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" : ""}`,
1306
+ 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" : ""}`,
1312
1307
  children: [
1313
1308
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 min-w-0 flex-1", children: [
1314
- option.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: option.icon }),
1309
+ option.icon && /* @__PURE__ */ jsxRuntime.jsx(
1310
+ "span",
1311
+ {
1312
+ className: `flex-shrink-0 ${selectedValues.includes(option.value) ? "text-primary-foreground" : ""}`,
1313
+ children: option.icon
1314
+ }
1315
+ ),
1315
1316
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
1316
1317
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1317
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-foreground truncate", children: option.label }),
1318
+ /* @__PURE__ */ jsxRuntime.jsx(
1319
+ "div",
1320
+ {
1321
+ className: `font-medium truncate ${selectedValues.includes(option.value) ? "text-primary-foreground" : "text-foreground"}`,
1322
+ children: option.label
1323
+ }
1324
+ ),
1318
1325
  option.metadata?.isDefault && /* @__PURE__ */ jsxRuntime.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" })
1319
1326
  ] }),
1320
- option.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground truncate", children: option.description }),
1321
- option.metadata?.args && option.metadata.args.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1", children: [
1322
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-secondary-foreground mb-1", children: "Arguments:" }),
1327
+ option.description && /* @__PURE__ */ jsxRuntime.jsx(
1328
+ "div",
1329
+ {
1330
+ className: `text-xs truncate ${selectedValues.includes(option.value) ? "text-primary-foreground/80" : "text-muted-foreground"}`,
1331
+ children: option.description
1332
+ }
1333
+ ),
1334
+ option.metadata?.args && option.metadata.args.length > 0 && (!option.metadata.commandType || option.metadata.commandType === "command") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1", children: [
1335
+ /* @__PURE__ */ jsxRuntime.jsx(
1336
+ "div",
1337
+ {
1338
+ className: `text-xs mb-1 ${selectedValues.includes(option.value) ? "text-primary-foreground/80" : "text-muted-foreground"}`,
1339
+ children: "Arguments:"
1340
+ }
1341
+ ),
1323
1342
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-1", children: [
1324
1343
  option.metadata.args.slice(0, 3).map((arg, argIndex) => /* @__PURE__ */ jsxRuntime.jsx(
1325
1344
  "span",
@@ -1329,11 +1348,17 @@ function SmartSelect({
1329
1348
  },
1330
1349
  argIndex
1331
1350
  )),
1332
- option.metadata.args.length > 3 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-secondary-foreground", children: [
1333
- "+",
1334
- option.metadata.args.length - 3,
1335
- " more"
1336
- ] })
1351
+ option.metadata.args.length > 3 && /* @__PURE__ */ jsxRuntime.jsxs(
1352
+ "span",
1353
+ {
1354
+ className: `text-xs ${selectedValues.includes(option.value) ? "text-primary-foreground/80" : "text-muted-foreground"}`,
1355
+ children: [
1356
+ "+",
1357
+ option.metadata.args.length - 3,
1358
+ " more"
1359
+ ]
1360
+ }
1361
+ )
1337
1362
  ] })
1338
1363
  ] })
1339
1364
  ] })
@@ -1347,11 +1372,11 @@ function SmartSelect({
1347
1372
  },
1348
1373
  className: "w-4 h-4 text-primary bg-muted border-border rounded focus:ring-primary focus:ring-2"
1349
1374
  }
1350
- ) : selectedValues.includes(option.value) && /* @__PURE__ */ jsxRuntime.jsx(ri.RiCheckLine, { className: "w-4 h-4 text-primary flex-shrink-0" })
1375
+ ) : selectedValues.includes(option.value) && /* @__PURE__ */ jsxRuntime.jsx(ri.RiCheckLine, { className: "w-4 h-4 text-primary-foreground flex-shrink-0" })
1351
1376
  ]
1352
1377
  },
1353
1378
  option.value
1354
- )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-sm text-secondary-foreground flex items-center gap-2", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1379
+ )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground flex items-center gap-2", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1355
1380
  /* @__PURE__ */ jsxRuntime.jsx(ri.RiLoader4Line, { className: "w-4 h-4 animate-spin" }),
1356
1381
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading..." })
1357
1382
  ] }) : searchTerm.trim() ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: "No results found" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: "No options available" }) }) })
@@ -2496,7 +2521,7 @@ function FormInput({
2496
2521
  }
2497
2522
  )
2498
2523
  ] }),
2499
- footerDescription && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs mt-1", children: footerDescription }),
2524
+ footerDescription && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: footerDescription }),
2500
2525
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { id: `${name}-error`, className: "form-error", role: "alert", children: typeof error === "string" ? /* @__PURE__ */ jsxRuntime.jsx("p", { children: error }) : error })
2501
2526
  ] }) });
2502
2527
  }
@@ -2776,32 +2801,32 @@ function Switch({
2776
2801
  const variants = {
2777
2802
  default: {
2778
2803
  checked: "bg-primary",
2779
- unchecked: "bg-input",
2804
+ unchecked: "bg-muted-foreground/40",
2780
2805
  ring: "focus:ring-primary"
2781
2806
  },
2782
2807
  success: {
2783
2808
  checked: "bg-success",
2784
- unchecked: "bg-input",
2809
+ unchecked: "bg-muted-foreground/40",
2785
2810
  ring: "focus:ring-success"
2786
2811
  },
2787
2812
  danger: {
2788
2813
  checked: "bg-destructive",
2789
- unchecked: "bg-input",
2814
+ unchecked: "bg-muted-foreground/40",
2790
2815
  ring: "focus:ring-destructive"
2791
2816
  },
2792
2817
  warning: {
2793
2818
  checked: "bg-warning",
2794
- unchecked: "bg-input",
2819
+ unchecked: "bg-muted-foreground/40",
2795
2820
  ring: "focus:ring-warning"
2796
2821
  },
2797
2822
  info: {
2798
2823
  checked: "bg-info",
2799
- unchecked: "bg-input",
2824
+ unchecked: "bg-muted-foreground/40",
2800
2825
  ring: "focus:ring-info"
2801
2826
  },
2802
2827
  embedded: {
2803
2828
  checked: "bg-success",
2804
- unchecked: "bg-input",
2829
+ unchecked: "bg-muted-foreground/40",
2805
2830
  ring: "focus:ring-success"
2806
2831
  }
2807
2832
  };
@@ -2822,9 +2847,9 @@ function Switch({
2822
2847
  disabled,
2823
2848
  onClick: toggle,
2824
2849
  className: `
2825
- relative inline-flex flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent
2850
+ relative inline-flex flex-shrink-0 cursor-pointer rounded-full border-2
2826
2851
  transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 ${currentVariant.ring} focus:ring-offset-2
2827
- ${checked ? currentVariant.checked : currentVariant.unchecked}
2852
+ ${checked ? `${currentVariant.checked} border-transparent` : `${currentVariant.unchecked} border-muted-foreground/30`}
2828
2853
  ${disabled ? "opacity-50 cursor-not-allowed" : ""}
2829
2854
  ${currentSize.track}
2830
2855
  `,