@app-studio/web 0.8.81 → 0.8.82

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.
@@ -27,50 +27,51 @@ export declare const DefaultColorStops: Record<GradientType, ColorStop[]>;
27
27
  */
28
28
  export declare const generateGradientString: (type: GradientType, colors: ColorStop[], direction?: string | undefined, shape?: "circle" | "ellipse" | undefined, position?: string | undefined) => string;
29
29
  /**
30
- * Animation keyframes for animated gradients
30
+ * Animation styles for animated gradients using app-studio's animation system
31
31
  */
32
32
  export declare const GradientAnimations: {
33
33
  linear: {
34
- '@keyframes gradient-animation': {
35
- '0%': {
34
+ backgroundSize: string;
35
+ transition: string;
36
+ animate: {
37
+ from: {
36
38
  backgroundPosition: string;
37
39
  };
38
40
  '50%': {
39
41
  backgroundPosition: string;
40
42
  };
41
- '100%': {
43
+ to: {
42
44
  backgroundPosition: string;
43
45
  };
44
46
  };
45
- animation: string;
46
- backgroundSize: string;
47
47
  };
48
48
  radial: {
49
- '@keyframes gradient-animation': {
50
- '0%': {
49
+ backgroundSize: string;
50
+ transition: string;
51
+ animate: {
52
+ from: {
51
53
  backgroundPosition: string;
54
+ backgroundSize: string;
52
55
  };
53
56
  '50%': {
54
57
  backgroundSize: string;
55
58
  };
56
- '100%': {
59
+ to: {
57
60
  backgroundPosition: string;
58
61
  backgroundSize: string;
59
62
  };
60
63
  };
61
- animation: string;
62
- backgroundSize: string;
63
64
  };
64
65
  conic: {
65
- '@keyframes gradient-animation': {
66
- '0%': {
66
+ transition: string;
67
+ animate: {
68
+ from: {
67
69
  transform: string;
68
70
  };
69
- '100%': {
71
+ to: {
70
72
  transform: string;
71
73
  };
72
74
  };
73
- animation: string;
74
75
  };
75
76
  };
76
77
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { InputProps, Shadow, ViewProps } from 'app-studio';
2
3
  import { Elevation } from '../../../utils/elevation';
3
4
  import { Shape, Size, Variant } from '../../Input/Input.type';
@@ -67,6 +68,8 @@ export interface OTPInputProps extends Omit<InputProps, 'size'> {
67
68
  * Callback when an input field loses focus
68
69
  */
69
70
  onBlur?: (value: any) => void;
71
+ onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
72
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
70
73
  /**
71
74
  * Callback when an input field is clicked
72
75
  */
@@ -1,6 +1,6 @@
1
1
  import { ClipboardEvent, KeyboardEvent, ChangeEvent } from 'react';
2
2
  import { OTPInputProps } from './OTPInput.props';
3
- export declare const useOTPInputState: ({ value: controlledValue, defaultValue, length, onChange, onChangeText, onComplete, pattern, stepValues, pasteTransformer, }: OTPInputProps) => {
3
+ export declare const useOTPInputState: ({ value: controlledValue, defaultValue, length, onChange, onChangeText, onComplete, onKeyDown, onKeyPress, onBlur, onFocus, isReadOnly, isDisabled, pattern, stepValues, pasteTransformer, }: OTPInputProps) => {
4
4
  value: string;
5
5
  setValue: (newValue: string) => void;
6
6
  isFocused: boolean;
@@ -18,5 +18,6 @@ export declare const useOTPInputState: ({ value: controlledValue, defaultValue,
18
18
  handleFocus: () => void;
19
19
  handleBlur: () => void;
20
20
  handleKeyDown: (_: KeyboardEvent<HTMLInputElement>) => void;
21
+ handleKeyPress: (e: KeyboardEvent<HTMLInputElement>) => void;
21
22
  handlePaste: (e: ClipboardEvent<HTMLInputElement>) => void;
22
23
  };
@@ -24,5 +24,6 @@ declare const OTPInputView: React.FC<OTPInputViewProps & {
24
24
  handleBlur: () => void;
25
25
  handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
26
26
  stepValues?: number[];
27
+ handleKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => void;
27
28
  }>;
28
29
  export default OTPInputView;
@@ -17,5 +17,5 @@ interface SideBarNavItemProps {
17
17
  ariaLabel?: string;
18
18
  badge?: number;
19
19
  }
20
- export declare const SideBarNavItem: ({ icon, label, isActive, badge, views, ...props }: SideBarNavItemProps & any) => React.JSX.Element;
20
+ export declare const SideBarNavItem: ({ icon, label, isActive, badge, views, ariaLabel, ...props }: SideBarNavItemProps & any) => React.JSX.Element;
21
21
  export {};
@@ -34,6 +34,7 @@ require('core-js/modules/es.string.match.js');
34
34
  require('core-js/modules/es.string.search.js');
35
35
  require('core-js/modules/es.array.flat-map.js');
36
36
  require('core-js/modules/es.array.unscopables.flat-map.js');
37
+ require('core-js/modules/es.string.trim.js');
37
38
 
38
39
  function _objectWithoutPropertiesLoose(r, e) {
39
40
  if (null == r) return {};
@@ -3764,7 +3765,9 @@ var ButtonView = _ref => {
3764
3765
  var hovering = isHovered && effect === 'hover';
3765
3766
  var reverse = isHovered && effect === 'reverse';
3766
3767
  // Determine if the button color is light or dark for proper contrast
3767
- var isLight = contrast(getColor(buttonColor, elementMode ? elementMode : themeMode)) == 'light';
3768
+ var buttonMode = elementMode ? elementMode : themeMode;
3769
+ var reverseMode = reverse && buttonMode == 'light' ? 'dark' : "light"; // Slightly darker
3770
+ var isLight = contrast(getColor(buttonColor, buttonMode)) == 'light';
3768
3771
  // Define button variants with effect support
3769
3772
  var ButtonVariants = {
3770
3773
  filled: {
@@ -3774,12 +3777,12 @@ var ButtonView = _ref => {
3774
3777
  borderStyle: 'solid',
3775
3778
  borderColor: reverse ? buttonColor : 'transparent',
3776
3779
  _hover: {
3777
- backgroundColor: reverse ? buttonColor + "10" : "" + buttonColor,
3778
- transform: 'translateY(-2px)',
3780
+ themeMode: reverse && buttonMode == 'light' ? 'light' : "dark",
3781
+ transform: 'translateY(-1px)',
3779
3782
  boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)'
3780
3783
  },
3781
3784
  _active: {
3782
- backgroundColor: reverse ? buttonColor + "20" : "" + buttonColor,
3785
+ themeMode: reverse && buttonMode == 'light' ? 'light' : "dark",
3783
3786
  transform: 'translateY(0)',
3784
3787
  boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)'
3785
3788
  }
@@ -3791,12 +3794,12 @@ var ButtonView = _ref => {
3791
3794
  borderColor: reverse ? buttonColor : colorScheme,
3792
3795
  color: reverse ? 'white' : buttonColor,
3793
3796
  _hover: {
3794
- backgroundColor: reverse ? "" + buttonColor : buttonColor + "10",
3795
- transform: 'translateY(-2px)',
3797
+ themeMode: reverse ? reverseMode : buttonMode,
3798
+ transform: 'translateY(-1px)',
3796
3799
  boxShadow: '0 4px 8px rgba(0, 0, 0, 0.05)'
3797
3800
  },
3798
3801
  _active: {
3799
- backgroundColor: reverse ? buttonColor + "b0" : buttonColor + "20",
3802
+ themeMode: reverse ? reverseMode : buttonMode,
3800
3803
  transform: 'translateY(0)',
3801
3804
  boxShadow: '0 2px 4px rgba(0, 0, 0, 0.05)'
3802
3805
  }
@@ -3824,11 +3827,11 @@ var ButtonView = _ref => {
3824
3827
  borderStyle: 'none',
3825
3828
  borderColor: 'transparent',
3826
3829
  _hover: {
3827
- backgroundColor: reverse ? "" + buttonColor : buttonColor + "10",
3828
- transform: 'translateY(-2px)'
3830
+ themeMode: reverse ? reverseMode : buttonMode,
3831
+ transform: 'translateY(-1px)'
3829
3832
  },
3830
3833
  _active: {
3831
- backgroundColor: reverse ? buttonColor + "b0" : buttonColor + "20",
3834
+ themeMode: reverse ? reverseMode : buttonMode,
3832
3835
  transform: 'translateY(0)'
3833
3836
  }
3834
3837
  }
@@ -4439,7 +4442,7 @@ var _excluded$c = ["children", "isActive", "views"],
4439
4442
  _excluded3$5 = ["views", "children"],
4440
4443
  _excluded4$4 = ["children", "views"],
4441
4444
  _excluded5$1 = ["children", "views", "style"],
4442
- _excluded6$1 = ["children", "defaultActiveIndex", "activeIndex", "onChange", "showNavigation", "navigationPosition", "prevButton", "nextButton", "showIndicators", "indicatorPosition", "indicatorVariant", "autoPlay", "autoPlayInterval", "pauseOnHover", "infinite", "direction", "transitionDuration", "views", "themeMode"];
4445
+ _excluded6$1 = ["children", "defaultActiveIndex", "activeIndex", "onChange", "showNavigation", "navigationPosition", "prevButton", "nextButton", "showIndicators", "indicatorPosition", "indicatorVariant", "autoPlay", "autoPlayInterval", "pauseOnHover", "infinite", "direction", "transitionDuration", "views", "stepIndices", "themeMode"];
4443
4446
  var CarouselSlide = _ref => {
4444
4447
  var {
4445
4448
  children,
@@ -6332,17 +6335,6 @@ var InputVariants = {
6332
6335
  _focus: {
6333
6336
  borderColor: 'theme.primary',
6334
6337
  boxShadow: '0 0 0 1px rgba(66, 153, 225, 0.2)'
6335
- },
6336
- '@media (prefers-color-scheme: dark)': {
6337
- backgroundColor: 'color.gray.800',
6338
- borderColor: 'color.gray.700',
6339
- _hover: {
6340
- borderColor: 'color.gray.600'
6341
- },
6342
- _focus: {
6343
- borderColor: 'theme.primary',
6344
- boxShadow: '0 0 0 1px rgba(66, 153, 225, 0.4)'
6345
- }
6346
6338
  }
6347
6339
  },
6348
6340
  default: {
@@ -6358,16 +6350,6 @@ var InputVariants = {
6358
6350
  },
6359
6351
  _focus: {
6360
6352
  borderBottomColor: 'theme.primary'
6361
- },
6362
- '@media (prefers-color-scheme: dark)': {
6363
- backgroundColor: 'color.gray.800',
6364
- borderBottomColor: 'color.gray.700',
6365
- _hover: {
6366
- borderBottomColor: 'color.gray.600'
6367
- },
6368
- _focus: {
6369
- borderBottomColor: 'theme.primary'
6370
- }
6371
6353
  }
6372
6354
  },
6373
6355
  none: {
@@ -6499,7 +6481,7 @@ var HeadingSizes$1 = {
6499
6481
  }
6500
6482
  };
6501
6483
 
6502
- var _excluded$l = ["children", "heading", "isItalic", "isUnderlined", "isStriked", "weight", "size"];
6484
+ var _excluded$l = ["children", "heading", "isItalic", "isUnderlined", "isStriked", "weight", "size", "dropDown"];
6503
6485
  var LabelView = _ref => {
6504
6486
  var {
6505
6487
  children,
@@ -6709,11 +6691,7 @@ var SelectBox = _ref2 => {
6709
6691
  // State properties
6710
6692
  cursor: isDisabled ? 'not-allowed' : 'pointer',
6711
6693
  // Animation
6712
- transition: 'all 0.2s ease',
6713
- // Dark mode support
6714
- '@media (prefers-color-scheme: dark)': {
6715
- color: isDisabled ? 'color.gray.600' : 'color.gray.100'
6716
- }
6694
+ transition: 'all 0.2s ease'
6717
6695
  }, views['field'], views['text']);
6718
6696
  var option = options.length > 0 && options.find(option => option.value === value);
6719
6697
  return /*#__PURE__*/React__default.createElement(Text, Object.assign({}, fieldStyles), (value === '' || Array.isArray(value) && value.length === 0) && !!placeholder ? placeholder : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, typeof value === 'string' ? (_ref3 = option && option.label) != null ? _ref3 : value :
@@ -6772,9 +6750,7 @@ var HiddenSelect = _ref4 => {
6772
6750
  var DropDown = _ref5 => {
6773
6751
  var {
6774
6752
  size,
6775
- views = {
6776
- dropDown: {}
6777
- },
6753
+ views = {},
6778
6754
  options,
6779
6755
  callback = () => {},
6780
6756
  highlightedIndex,
@@ -6824,7 +6800,7 @@ var DropDown = _ref5 => {
6824
6800
  borderRadius: '4px'
6825
6801
  }
6826
6802
  }
6827
- }, shadow, views['dropDown']), options.length > 0 && options.map((option, index) => (/*#__PURE__*/React__default.createElement(Item, Object.assign({
6803
+ }, shadow, views == null ? void 0 : views.dropDown), options.length > 0 && options.map((option, index) => (/*#__PURE__*/React__default.createElement(Item, Object.assign({
6828
6804
  key: option.value,
6829
6805
  size: size,
6830
6806
  style: views['text'],
@@ -7134,7 +7110,7 @@ var ColorSchemes = {
7134
7110
  }
7135
7111
  };
7136
7112
 
7137
- var _excluded$p = ["id", "name", "label", "inActiveChild", "activeChild", "labelPosition", "shadow", "size", "value", "isHovered", "isDisabled", "isReadOnly", "on", "setOn", "onChange", "setValue", "setIsHovered", "helperText", "views"];
7113
+ var _excluded$p = ["id", "name", "label", "inActiveChild", "isChecked", "activeChild", "labelPosition", "shadow", "size", "value", "isHovered", "isDisabled", "isReadOnly", "on", "setOn", "onChange", "setValue", "setIsHovered", "helperText", "views"];
7138
7114
  var SwitchContent = props => /*#__PURE__*/React__default.createElement(appStudio.Input, Object.assign({
7139
7115
  type: "checkbox"
7140
7116
  }, props));
@@ -7541,11 +7517,7 @@ var TextFieldView = _ref => {
7541
7517
  // State properties
7542
7518
  cursor: isDisabled ? 'not-allowed' : 'text',
7543
7519
  // Animation
7544
- transition: 'all 0.2s ease',
7545
- // Dark mode support
7546
- '@media (prefers-color-scheme: dark)': {
7547
- color: isDisabled ? 'color.gray.600' : 'color.gray.100'
7548
- }
7520
+ transition: 'all 0.2s ease'
7549
7521
  }, views['field']);
7550
7522
  var handleFocus = () => {
7551
7523
  setIsFocused(true);
@@ -9526,8 +9498,8 @@ var CountryPickerView = _ref5 => {
9526
9498
  var showLabel = !!(label && (isFocused || value));
9527
9499
  var fieldStyles = Object.assign({
9528
9500
  margin: 0,
9529
- paddingVerical: 8,
9530
- paddingHorizonatl: 0,
9501
+ paddingVertical: 8,
9502
+ paddingHorizontal: 0,
9531
9503
  width: '100%',
9532
9504
  heigth: '100%',
9533
9505
  border: 'none',
@@ -9991,6 +9963,12 @@ var useOTPInputState = _ref => {
9991
9963
  onChange,
9992
9964
  onChangeText,
9993
9965
  onComplete,
9966
+ onKeyDown,
9967
+ onKeyPress,
9968
+ onBlur,
9969
+ onFocus,
9970
+ isReadOnly,
9971
+ isDisabled,
9994
9972
  pattern,
9995
9973
  stepValues,
9996
9974
  pasteTransformer
@@ -10104,6 +10082,16 @@ var useOTPInputState = _ref => {
10104
10082
  var handleKeyDown = React.useCallback(_ => {
10105
10083
  // Handle special keys like backspace, arrows, etc.
10106
10084
  // This is handled by the browser for the single input
10085
+ if (onKeyDown) {
10086
+ onKeyDown(_);
10087
+ }
10088
+ }, []);
10089
+ var handleKeyPress = React.useCallback(e => {
10090
+ // Handle key press events
10091
+ // This is handled by the browser for the single input
10092
+ if (onKeyPress) {
10093
+ onKeyPress(e);
10094
+ }
10107
10095
  }, []);
10108
10096
  var handlePaste = React.useCallback(e => {
10109
10097
  var input = inputRef.current;
@@ -10260,11 +10248,12 @@ var useOTPInputState = _ref => {
10260
10248
  handleFocus,
10261
10249
  handleBlur,
10262
10250
  handleKeyDown,
10251
+ handleKeyPress,
10263
10252
  handlePaste
10264
10253
  };
10265
10254
  };
10266
10255
 
10267
- var _excluded$y = ["id", "name", "label", "value", "length", "onChange", "onChangeText", "onComplete", "helperText", "placeholder", "shadow", "views", "size", "shape", "variant", "gap", "type", "error", "isFocused", "isHovered", "isDisabled", "isReadOnly", "isAutoFocus", "setValue", "setIsFocused", "setIsHovered", "inputRef", "containerRef", "mirrorSelectionStart", "mirrorSelectionEnd", "setMirrorSelectionStart", "setMirrorSelectionEnd", "handlePaste", "handleChange", "handleFocus", "handleBlur", "handleKeyDown", "stepValues", "setInputRef", "onBlur", "onClick", "onFocus"];
10256
+ var _excluded$y = ["id", "name", "label", "value", "length", "onChange", "onChangeText", "onComplete", "helperText", "placeholder", "shadow", "views", "size", "shape", "variant", "gap", "type", "error", "isFocused", "isHovered", "isDisabled", "isReadOnly", "isAutoFocus", "setValue", "setIsFocused", "setIsHovered", "inputRef", "containerRef", "mirrorSelectionStart", "mirrorSelectionEnd", "setMirrorSelectionStart", "setMirrorSelectionEnd", "handlePaste", "handleChange", "handleFocus", "handleBlur", "handleKeyDown", "handleKeyPress", "secureTextEntry", "isFirstColumn", "stepValues", "setInputRef", "onBlur", "onClick", "onFocus"];
10268
10257
  // Create a context for OTP input slots
10269
10258
  var OTPInputContext = /*#__PURE__*/React.createContext({
10270
10259
  slots: [],
@@ -10272,7 +10261,7 @@ var OTPInputContext = /*#__PURE__*/React.createContext({
10272
10261
  isHovering: false
10273
10262
  });
10274
10263
  // CSS for noscript fallback
10275
- var NOSCRIPT_CSS_FALLBACK = "\n@keyframes blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0; }\n}\n\n[data-input-otp] {\n --nojs-bg: white !important;\n --nojs-fg: black !important;\n\n background-color: var(--nojs-bg) !important;\n color: var(--nojs-fg) !important;\n caret-color: var(--nojs-fg) !important;\n letter-spacing: .25em !important;\n text-align: center !important;\n border: 1px solid var(--nojs-fg) !important;\n border-radius: 4px !important;\n width: 100% !important;\n}\n@media (prefers-color-scheme: dark) {\n [data-input-otp] {\n --nojs-bg: black !important;\n --nojs-fg: white !important;\n }\n}";
10264
+ var NOSCRIPT_CSS_FALLBACK = "\n@keyframes blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0; }\n}\n\n[data-input-otp] {\n --nojs-bg: white !important;\n --nojs-fg: black !important;\n\n background-color: var(--nojs-bg) !important;\n color: var(--nojs-fg) !important;\n caret-color: var(--nojs-fg) !important;\n letter-spacing: .25em !important;\n text-align: center !important;\n border: 1px solid var(--nojs-fg) !important;\n border-radius: 4px !important;\n width: 100% !important;\n}\n";
10276
10265
  // Helper function to safely insert CSS rules
10277
10266
  function safeInsertRule(sheet, rule) {
10278
10267
  try {
@@ -10520,7 +10509,8 @@ var OTPInputComponent = props => {
10520
10509
  handleFocus,
10521
10510
  handleBlur,
10522
10511
  handleKeyDown,
10523
- handlePaste
10512
+ handlePaste,
10513
+ handleKeyPress
10524
10514
  } = useOTPInputState(props);
10525
10515
  // Use the controlled value if it exists, otherwise use the internal state value
10526
10516
  var displayValue = controlledValue !== undefined ? controlledValue : value;
@@ -10542,6 +10532,7 @@ var OTPInputComponent = props => {
10542
10532
  handleFocus: handleFocus,
10543
10533
  handleBlur: handleBlur,
10544
10534
  handleKeyDown: handleKeyDown,
10535
+ handleKeyPress: handleKeyPress,
10545
10536
  handlePaste: handlePaste,
10546
10537
  stepValues: props.stepValues
10547
10538
  }));
@@ -11959,12 +11950,12 @@ var UploadView = _ref => {
11959
11950
  } = _ref;
11960
11951
  var finalPreviewUrl = externalPreviewUrl || previewUrl;
11961
11952
  // Debug log to help troubleshoot
11962
- console.log('Uploader state:', {
11963
- fileType,
11964
- finalPreviewUrl,
11965
- selectedFile: selectedFile == null ? void 0 : selectedFile.name,
11966
- progress
11967
- });
11953
+ // console.log('Uploader state:', {
11954
+ // fileType,
11955
+ // finalPreviewUrl,
11956
+ // selectedFile: selectedFile?.name,
11957
+ // progress,
11958
+ // });
11968
11959
  return /*#__PURE__*/React__default.createElement(appStudio.Center, Object.assign({
11969
11960
  onClick: handleClick,
11970
11961
  cursor: "pointer",
@@ -12215,7 +12206,7 @@ var ModalTypography = {
12215
12206
  };
12216
12207
 
12217
12208
  var _excluded$H = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position", "views"],
12218
- _excluded2$c = ["children", "shadow", "isFullScreen", "shape", "views"],
12209
+ _excluded2$c = ["children", "shadow", "isFullScreen", "shape", "views", "isOpen"],
12219
12210
  _excluded3$9 = ["children", "buttonColor", "iconSize", "buttonPosition", "views"],
12220
12211
  _excluded4$7 = ["children", "views"],
12221
12212
  _excluded5$3 = ["children", "views"];
@@ -13101,7 +13092,9 @@ var useTabsState = (propTabs, initialTabValue) => {
13101
13092
  return foundTab;
13102
13093
  }
13103
13094
  // Warn if initialTabValue is provided but not found
13104
- console.warn("Tabs: initialTabValue \"" + initialTabValue + "\" not found in tabs. Defaulting to the first tab.");
13095
+ // console.warn(
13096
+ // `Tabs: initialTabValue "${initialTabValue}" not found in tabs. Defaulting to the first tab.`
13097
+ // );
13105
13098
  }
13106
13099
  return propTabs[0]; // Default to the first tab
13107
13100
  };
@@ -16009,7 +16002,7 @@ var HandleIconStyles = {
16009
16002
 
16010
16003
  var _excluded$X = ["children", "id", "defaultSize", "minSize", "maxSize", "collapsible", "defaultCollapsed", "onCollapseChange", "views"],
16011
16004
  _excluded2$g = ["id", "position", "disabled", "withVisualIndicator", "withCollapseButton", "collapseTarget", "views"],
16012
- _excluded3$c = ["children", "orientation", "size", "variant", "defaultSizes", "minSize", "maxSize", "collapsible", "containerRef", "views"];
16005
+ _excluded3$c = ["children", "orientation", "size", "variant", "defaultSizes", "minSize", "maxSize", "collapsible", "containerRef", "autoSaveId", "views"];
16013
16006
  // Create context for the Resizable component
16014
16007
  var ResizableContext = /*#__PURE__*/React.createContext({
16015
16008
  orientation: 'horizontal',
@@ -16805,6 +16798,16 @@ var Toast = /*#__PURE__*/Object.assign(ToastComponent, {
16805
16798
  // Export the hook for component usage
16806
16799
  var useToast$1 = useToast;
16807
16800
 
16801
+ // Default filter function defined outside the hook to avoid recreating it on each render
16802
+ var defaultFilterFn = (value, item) => {
16803
+ var _item$description, _item$keywords;
16804
+ if (!value) return true;
16805
+ var searchValue = value.toLowerCase();
16806
+ var matchesName = item.name.toLowerCase().includes(searchValue);
16807
+ var matchesDescription = ((_item$description = item.description) == null ? void 0 : _item$description.toLowerCase().includes(searchValue)) || false;
16808
+ var matchesKeywords = ((_item$keywords = item.keywords) == null ? void 0 : _item$keywords.some(keyword => keyword.toLowerCase().includes(searchValue))) || false;
16809
+ return matchesName || matchesDescription || matchesKeywords;
16810
+ };
16808
16811
  var useCommandState = _ref => {
16809
16812
  var {
16810
16813
  open,
@@ -16813,46 +16816,36 @@ var useCommandState = _ref => {
16813
16816
  commands = [],
16814
16817
  filter
16815
16818
  } = _ref;
16816
- // Combine commands from groups and flat list
16817
- var allCommands = React.useCallback(() => {
16818
- var groupCommands = groups.flatMap(group => group.commands);
16819
- return [...groupCommands, ...commands];
16820
- }, [groups, commands]);
16821
16819
  // State for search input
16822
16820
  var [search, setSearch] = React.useState('');
16823
16821
  // State for selected item index
16824
16822
  var [selectedIndex, setSelectedIndex] = React.useState(0);
16825
16823
  // Ref for the command list element
16826
16824
  var listRef = React.useRef(null);
16827
- // Default filter function
16828
- var defaultFilter = (value, item) => {
16829
- var _item$description, _item$keywords;
16830
- if (!value) return true;
16831
- var searchValue = value.toLowerCase();
16832
- var matchesName = item.name.toLowerCase().includes(searchValue);
16833
- var matchesDescription = ((_item$description = item.description) == null ? void 0 : _item$description.toLowerCase().includes(searchValue)) || false;
16834
- var matchesKeywords = ((_item$keywords = item.keywords) == null ? void 0 : _item$keywords.some(keyword => keyword.toLowerCase().includes(searchValue))) || false;
16835
- return matchesName || matchesDescription || matchesKeywords;
16836
- };
16837
- // Filter commands based on search
16838
- var filterCommands = React.useCallback(searchValue => {
16839
- var filterFn = filter || defaultFilter;
16840
- return allCommands().filter(item => filterFn(searchValue, item));
16841
- }, [allCommands, filter, defaultFilter]);
16842
- // Filtered commands based on search
16843
- var [filteredCommands, setFilteredCommands] = React.useState(allCommands());
16844
- // Filtered groups based on search
16845
- var filteredGroups = React.useCallback(() => {
16825
+ // Use the provided filter or fall back to the default
16826
+ var filterFn = React.useMemo(() => filter || defaultFilterFn, [filter]);
16827
+ // Combine and memoize all commands from groups and flat list
16828
+ var allCommands = React.useMemo(() => {
16829
+ var groupCommands = groups.flatMap(group => group.commands);
16830
+ return [...groupCommands, ...commands];
16831
+ }, [groups, commands]);
16832
+ // Filter and memoize commands based on search
16833
+ var filteredCommands = React.useMemo(() => {
16834
+ if (!search.trim()) return allCommands;
16835
+ return allCommands.filter(item => filterFn(search, item));
16836
+ }, [allCommands, search, filterFn]);
16837
+ // Filter and memoize groups based on search
16838
+ var filteredGroups = React.useMemo(() => {
16846
16839
  if (!search) return groups;
16847
- return groups.map(group => Object.assign({}, group, {
16848
- commands: group.commands.filter(command => (filter || defaultFilter)(search, command))
16849
- })).filter(group => group.commands.length > 0);
16850
- }, [groups, search, filter, defaultFilter]);
16851
- // Update filtered commands when search changes
16840
+ var filterFn = filter || defaultFilterFn;
16841
+ return groups.map(g => Object.assign({}, g, {
16842
+ commands: g.commands.filter(c => filterFn(search, c))
16843
+ })).filter(g => g.commands.length);
16844
+ }, [groups, search, filter]);
16845
+ // Reset selected index when filtered commands change
16852
16846
  React.useEffect(() => {
16853
- setFilteredCommands(filterCommands(search));
16854
16847
  setSelectedIndex(0);
16855
- }, [search, filterCommands]);
16848
+ }, [filteredCommands.length]);
16856
16849
  // Handle keyboard navigation
16857
16850
  var handleKeyDown = React.useCallback(e => {
16858
16851
  if (!open) return;
@@ -16902,6 +16895,9 @@ var useCommandState = _ref => {
16902
16895
  React.useEffect(() => {
16903
16896
  if (open) {
16904
16897
  setSelectedIndex(0);
16898
+ } else {
16899
+ // Clear search when closed
16900
+ setSearch('');
16905
16901
  }
16906
16902
  }, [open]);
16907
16903
  return {
@@ -16910,7 +16906,7 @@ var useCommandState = _ref => {
16910
16906
  selectedIndex,
16911
16907
  setSelectedIndex,
16912
16908
  filteredCommands,
16913
- filteredGroups: filteredGroups(),
16909
+ filteredGroups,
16914
16910
  listRef
16915
16911
  };
16916
16912
  };
@@ -17179,26 +17175,21 @@ var CommandView = _ref7 => {
17179
17175
  } = _ref7,
17180
17176
  props = _objectWithoutPropertiesLoose(_ref7, _excluded6$3);
17181
17177
  if (!open) return null;
17182
- var handleItemSelect = item => {
17183
- if (!item.disabled) {
17184
- item.onSelect();
17185
- onOpenChange(false);
17186
- setSearch('');
17187
- }
17188
- };
17189
- var handleBackdropClick = e => {
17190
- if (e.target === e.currentTarget) {
17191
- onOpenChange(false);
17192
- }
17193
- };
17194
- var contextValue = {
17178
+ var handleItemSelect = React__default.useCallback(item => {
17179
+ if (item.disabled) return;
17180
+ item.onSelect();
17181
+ onOpenChange(false);
17182
+ setSearch('');
17183
+ }, [onOpenChange, setSearch]);
17184
+ var handleBackdropClick = React__default.useCallback(e => e.target === e.currentTarget && onOpenChange(false), [onOpenChange]);
17185
+ var contextValue = React__default.useMemo(() => ({
17195
17186
  search,
17196
17187
  setSearch,
17197
17188
  selectedIndex,
17198
17189
  setSelectedIndex,
17199
17190
  filteredCommands,
17200
17191
  onSelect: handleItemSelect
17201
- };
17192
+ }), [search, selectedIndex, filteredCommands, handleItemSelect, setSearch, setSelectedIndex]);
17202
17193
  var hasGroups = groups.length > 0;
17203
17194
  // const hasCommands = commands.length > 0;
17204
17195
  var isEmpty = filteredCommands.length === 0;