@app-studio/web 0.9.7 → 0.9.8

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.
Files changed (35) hide show
  1. package/dist/components/ChatInput/ChatInput/ChatInput.props.d.ts +24 -0
  2. package/dist/components/ChatInput/ChatInput/ChatInput.type.d.ts +1 -1
  3. package/dist/components/ChatInput/EditableInput.d.ts +24 -1
  4. package/dist/components/ChatInput/examples/EnhancedEditableInput.d.ts +2 -0
  5. package/dist/components/ChatInput/examples/MentionEditableInput.d.ts +2 -0
  6. package/dist/components/ContextMenu/ContextMenu/ContextMenu.style.d.ts +1 -5
  7. package/dist/components/DropdownMenu/DropdownMenu/DropdownMenu.type.d.ts +1 -0
  8. package/dist/components/Form/TagInput/TagInput/TagInput.props.d.ts +190 -0
  9. package/dist/components/Form/TagInput/TagInput/TagInput.state.d.ts +26 -0
  10. package/dist/components/Form/TagInput/TagInput/TagInput.type.d.ts +79 -0
  11. package/dist/components/Form/TagInput/TagInput/TagInput.view.d.ts +13 -0
  12. package/dist/components/Form/TagInput/TagInput/index.d.ts +4 -0
  13. package/dist/components/Form/TagInput/TagInput.d.ts +3 -0
  14. package/dist/components/Form/TagInput/examples/Default.d.ts +25 -0
  15. package/dist/components/Form/TagInput/examples/index.d.ts +1 -0
  16. package/dist/components/Form/TagInput/index.d.ts +2 -0
  17. package/dist/components/Formik/Formik.TagInput.d.ts +7 -0
  18. package/dist/components/Formik/examples/FormikTagInput.d.ts +9 -0
  19. package/dist/components/Formik/examples/index.d.ts +1 -0
  20. package/dist/components/Input/FieldContainer/FieldContainer.d.ts +1 -1
  21. package/dist/components/Menubar/Menubar/Menubar.type.d.ts +1 -0
  22. package/dist/components/index.d.ts +1 -0
  23. package/dist/pages/positioning-test.page.d.ts +3 -0
  24. package/dist/pages/tags.page.d.ts +3 -0
  25. package/dist/web.cjs.development.js +1655 -600
  26. package/dist/web.cjs.development.js.map +1 -1
  27. package/dist/web.cjs.production.min.js +1 -1
  28. package/dist/web.cjs.production.min.js.map +1 -1
  29. package/dist/web.esm.js +1657 -603
  30. package/dist/web.esm.js.map +1 -1
  31. package/dist/web.umd.development.js +1544 -489
  32. package/dist/web.umd.development.js.map +1 -1
  33. package/dist/web.umd.production.min.js +1 -1
  34. package/dist/web.umd.production.min.js.map +1 -1
  35. package/package.json +2 -2
package/dist/web.esm.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import 'core-js/modules/es.object.assign.js';
2
- import React, { useState, useMemo, useEffect, useCallback, isValidElement, Children, cloneElement, useContext, createContext, useRef, Fragment, useLayoutEffect, forwardRef } from 'react';
2
+ import React, { useState, useMemo, useEffect, useCallback, isValidElement, Children, cloneElement, useContext, createContext, useRef, Fragment, forwardRef } from 'react';
3
3
  import 'core-js/modules/es.array.includes.js';
4
4
  import 'core-js/modules/es.array.iterator.js';
5
5
  import 'core-js/modules/es.string.includes.js';
6
6
  import 'core-js/modules/web.dom-collections.iterator.js';
7
7
  import 'core-js/modules/es.regexp.to-string.js';
8
- import { View, Horizontal, Vertical, Element, Text as Text$1, Center, useTheme, Image, useHover, Typography, Input, Form, useInView } from 'app-studio';
8
+ import { View, Horizontal, Vertical, Element, Text as Text$1, Center, useTheme, Image, useHover, useElementPosition, Typography, Input, Form, useInView } from 'app-studio';
9
9
  import 'core-js/modules/es.symbol.description.js';
10
10
  import 'core-js/modules/es.parse-float.js';
11
11
  import 'core-js/modules/es.string.trim-end.js';
@@ -18,6 +18,7 @@ import 'core-js/modules/es.array.reduce.js';
18
18
  import 'core-js/modules/es.number.to-fixed.js';
19
19
  import 'core-js/modules/es.string.starts-with.js';
20
20
  import format from 'date-fns/format';
21
+ import 'core-js/modules/es.string.trim.js';
21
22
  import 'core-js/modules/es.regexp.constructor.js';
22
23
  import 'core-js/modules/es.regexp.exec.js';
23
24
  import { useFormikContext, getIn } from 'formik';
@@ -30,7 +31,6 @@ import 'core-js/modules/es.string.match.js';
30
31
  import 'core-js/modules/es.string.search.js';
31
32
  import 'core-js/modules/es.array.flat-map.js';
32
33
  import 'core-js/modules/es.array.unscopables.flat-map.js';
33
- import 'core-js/modules/es.string.trim.js';
34
34
 
35
35
  function _objectWithoutPropertiesLoose(r, e) {
36
36
  if (null == r) return {};
@@ -6410,60 +6410,8 @@ var ContextMenuItemStates = {
6410
6410
  cursor: 'not-allowed'
6411
6411
  }
6412
6412
  };
6413
- // Helper function to calculate position based on available space
6414
- var calculateMenuPosition = function calculateMenuPosition(x, y, menuWidth, menuHeight, windowWidth, windowHeight, side, align) {
6415
- if (side === void 0) {
6416
- side = 'right';
6417
- }
6418
- if (align === void 0) {
6419
- align = 'start';
6420
- }
6421
- var posX = x;
6422
- var posY = y;
6423
- // Adjust horizontal position based on side
6424
- if (side === 'left') {
6425
- posX = x - menuWidth;
6426
- } else if (side === 'right') {
6427
- posX = x;
6428
- } else if (side === 'top' || side === 'bottom') {
6429
- // Adjust horizontal position based on alignment for top/bottom
6430
- if (align === 'center') {
6431
- posX = x - menuWidth / 2;
6432
- } else if (align === 'end') {
6433
- posX = x - menuWidth;
6434
- }
6435
- }
6436
- // Adjust vertical position based on side
6437
- if (side === 'top') {
6438
- posY = y - menuHeight;
6439
- } else if (side === 'bottom') {
6440
- posY = y;
6441
- } else if (side === 'left' || side === 'right') {
6442
- // Adjust vertical position based on alignment for left/right
6443
- if (align === 'center') {
6444
- posY = y - menuHeight / 2;
6445
- } else if (align === 'end') {
6446
- posY = y - menuHeight;
6447
- }
6448
- }
6449
- // Ensure menu stays within window bounds
6450
- if (posX + menuWidth > windowWidth) {
6451
- posX = windowWidth - menuWidth;
6452
- }
6453
- if (posX < 0) {
6454
- posX = 0;
6455
- }
6456
- if (posY + menuHeight > windowHeight) {
6457
- posY = windowHeight - menuHeight;
6458
- }
6459
- if (posY < 0) {
6460
- posY = 0;
6461
- }
6462
- return {
6463
- x: posX,
6464
- y: posY
6465
- };
6466
- };
6413
+ // Note: Manual positioning logic has been replaced with intelligent positioning
6414
+ // using viewport-aware algorithms in the ContextMenu component
6467
6415
 
6468
6416
  var _excluded$f = ["children", "disableNativeContextMenu", "asChild", "isDisabled", "views"],
6469
6417
  _excluded2$6 = ["items", "children", "position", "side", "align", "views", "style"],
@@ -6584,28 +6532,72 @@ var ContextMenuContent = _ref3 => {
6584
6532
  variant
6585
6533
  } = useContextMenuContext();
6586
6534
  var menuRef = useRef(null);
6535
+ // Use contentRef if provided, otherwise use local menuRef
6536
+ var ref = contentRef || menuRef;
6537
+ // Use useElementPosition for intelligent positioning
6538
+ var {
6539
+ ref: positionRef,
6540
+ relation
6541
+ } = useElementPosition({
6542
+ // trackChanges: true,
6543
+ // trackOnHover: false,
6544
+ // trackOnScroll: true,
6545
+ // trackOnResize: true,
6546
+ // throttleMs: 50,
6547
+ });
6587
6548
  var [menuPosition, setMenuPosition] = useState({
6588
6549
  x: 0,
6589
6550
  y: 0
6590
6551
  });
6591
- // Use contentRef if provided, otherwise use local menuRef
6592
- var ref = contentRef || menuRef;
6593
- // Calculate the position of the menu
6552
+ // Calculate the position of the menu using useElementPosition
6594
6553
  useEffect(() => {
6595
6554
  if (isOpen && ref.current) {
6555
+ var pos = position || contextPosition;
6596
6556
  var menuWidth = ref.current.offsetWidth;
6597
6557
  var menuHeight = ref.current.offsetHeight;
6598
- var windowWidth = window.innerWidth;
6599
- var windowHeight = window.innerHeight;
6600
- var pos = position || contextPosition;
6601
- var calculatedPosition = calculateMenuPosition(pos.x, pos.y, menuWidth, menuHeight, windowWidth, windowHeight, side, align);
6602
- setMenuPosition(calculatedPosition);
6558
+ // Get viewport dimensions for boundary checking
6559
+ var viewportWidth = window.innerWidth;
6560
+ var viewportHeight = window.innerHeight;
6561
+ // Calculate optimal position based on available space
6562
+ var finalX = pos.x;
6563
+ var finalY = pos.y;
6564
+ // Use relation data if available for smarter positioning
6565
+ if (relation) {
6566
+ // Position based on where there's more space
6567
+ if (relation.space.horizontal === 'left') {
6568
+ finalX = pos.x - menuWidth;
6569
+ } else {
6570
+ finalX = pos.x;
6571
+ }
6572
+ if (relation.space.vertical === 'top') {
6573
+ finalY = pos.y - menuHeight;
6574
+ } else {
6575
+ finalY = pos.y;
6576
+ }
6577
+ }
6578
+ // Ensure the menu stays within viewport bounds
6579
+ if (finalX + menuWidth > viewportWidth) {
6580
+ finalX = viewportWidth - menuWidth - 8; // 8px margin
6581
+ }
6582
+ if (finalX < 8) {
6583
+ finalX = 8; // 8px margin
6584
+ }
6585
+ if (finalY + menuHeight > viewportHeight) {
6586
+ finalY = viewportHeight - menuHeight - 8; // 8px margin
6587
+ }
6588
+ if (finalY < 8) {
6589
+ finalY = 8; // 8px margin
6590
+ }
6591
+ setMenuPosition({
6592
+ x: finalX,
6593
+ y: finalY
6594
+ });
6603
6595
  }
6604
- }, [isOpen, contextPosition, position, side, align, ref]);
6596
+ }, [isOpen, contextPosition, position, side, align, ref, relation]);
6605
6597
  if (!isOpen) {
6606
6598
  return null;
6607
6599
  }
6608
- // Basic positioning - place top-left corner at calculated position
6600
+ // Intelligent positioning - place at calculated optimal position
6609
6601
  var positionStyles = {
6610
6602
  position: 'fixed',
6611
6603
  top: menuPosition.y + "px",
@@ -6658,7 +6650,6 @@ var ContextMenuItem = _ref4 => {
6658
6650
  var [isHovered, setIsHovered] = useState(false);
6659
6651
  var hasSubmenu = item.items && item.items.length > 0;
6660
6652
  var isSubmenuActive = activeSubmenuId === item.id;
6661
- var itemRef = useRef(null);
6662
6653
  var [submenuPosition, setSubmenuPosition] = useState({
6663
6654
  x: 0,
6664
6655
  y: 0
@@ -6683,16 +6674,40 @@ var ContextMenuItem = _ref4 => {
6683
6674
  if (closeMenu) closeMenu();
6684
6675
  }
6685
6676
  };
6686
- // Calculate the position of the submenu
6677
+ // Use useElementPosition for submenu positioning
6678
+ var {
6679
+ ref: itemRef,
6680
+ relation: submenuRelation
6681
+ } = useElementPosition({
6682
+ // trackChanges: true,
6683
+ // trackOnHover: false,
6684
+ // trackOnScroll: true,
6685
+ // trackOnResize: true,
6686
+ // throttleMs: 50,
6687
+ });
6688
+ // Calculate the position of the submenu with intelligent positioning
6687
6689
  useEffect(() => {
6688
6690
  if (isSubmenuActive && itemRef.current) {
6689
6691
  var rect = itemRef.current.getBoundingClientRect();
6692
+ var viewportWidth = window.innerWidth;
6693
+ // Estimate submenu dimensions (will be refined when submenu renders)
6694
+ var estimatedSubmenuWidth = 200; // Default submenu width
6695
+ // Use relation data for smarter positioning if available
6696
+ var useLeftSide = false;
6697
+ if (submenuRelation) {
6698
+ useLeftSide = submenuRelation.space.horizontal === 'left';
6699
+ } else {
6700
+ // Fallback to manual calculation
6701
+ var rightSpace = viewportWidth - rect.right;
6702
+ var leftSpace = rect.left;
6703
+ useLeftSide = rightSpace < estimatedSubmenuWidth && leftSpace > rightSpace;
6704
+ }
6690
6705
  setSubmenuPosition({
6691
- x: rect.right,
6706
+ x: useLeftSide ? rect.left - estimatedSubmenuWidth : rect.right,
6692
6707
  y: rect.top
6693
6708
  });
6694
6709
  }
6695
- }, [isSubmenuActive]);
6710
+ }, [isSubmenuActive, item.items, submenuRelation]);
6696
6711
  return /*#__PURE__*/React.createElement(View, Object.assign({
6697
6712
  ref: itemRef,
6698
6713
  role: "menuitem",
@@ -6986,7 +7001,7 @@ var HelperText = _ref => {
6986
7001
  };
6987
7002
 
6988
7003
  var _excluded$j = ["children", "helperText", "error", "views"];
6989
- var FieldContainer = _ref => {
7004
+ var FieldContainer = /*#__PURE__*/React.forwardRef((_ref, ref) => {
6990
7005
  var {
6991
7006
  children,
6992
7007
  helperText,
@@ -6994,9 +7009,8 @@ var FieldContainer = _ref => {
6994
7009
  views
6995
7010
  } = _ref,
6996
7011
  props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
6997
- return /*#__PURE__*/React.createElement(Vertical
6998
- // Layout properties
6999
- , Object.assign({
7012
+ return /*#__PURE__*/React.createElement(Vertical, Object.assign({
7013
+ ref: ref,
7000
7014
  // Layout properties
7001
7015
  gap: 8,
7002
7016
  position: "relative",
@@ -7012,7 +7026,8 @@ var FieldContainer = _ref => {
7012
7026
  color: "color.red.500",
7013
7027
  transition: "all 0.2s ease"
7014
7028
  }, views == null ? void 0 : views.error), error)));
7015
- };
7029
+ });
7030
+ FieldContainer.displayName = 'FieldContainer';
7016
7031
 
7017
7032
  /**
7018
7033
  * Input Styles
@@ -7603,6 +7618,47 @@ var SelectView = _ref7 => {
7603
7618
  highlightedIndex
7604
7619
  } = _ref7,
7605
7620
  props = _objectWithoutPropertiesLoose(_ref7, _excluded4$6);
7621
+ var {
7622
+ ref: triggerRef,
7623
+ relation,
7624
+ updateRelation
7625
+ } = useElementPosition({
7626
+ trackChanges: true,
7627
+ throttleMs: 100
7628
+ });
7629
+ var dropdownRef = useRef(null);
7630
+ // Get optimal positioning style based on available space
7631
+ var getDropdownStyle = () => {
7632
+ if (!relation) {
7633
+ // Default positioning when relation is not available
7634
+ return {
7635
+ position: 'absolute',
7636
+ top: '100%',
7637
+ marginTop: '8px',
7638
+ left: 0,
7639
+ right: 0,
7640
+ zIndex: 10000
7641
+ };
7642
+ }
7643
+ var baseStyle = {
7644
+ position: 'absolute',
7645
+ left: 0,
7646
+ right: 0,
7647
+ zIndex: 10000
7648
+ };
7649
+ // Place dropdown where there's more space vertically
7650
+ if (relation.space.vertical === 'top') {
7651
+ return Object.assign({}, baseStyle, {
7652
+ bottom: '100%',
7653
+ marginBottom: '8px'
7654
+ });
7655
+ } else {
7656
+ return Object.assign({}, baseStyle, {
7657
+ top: '100%',
7658
+ marginTop: '8px'
7659
+ });
7660
+ }
7661
+ };
7606
7662
  // close when *any* other select opens
7607
7663
  React.useEffect(() => {
7608
7664
  var handleCloseAll = () => setHide(true);
@@ -7661,11 +7717,10 @@ var SelectView = _ref7 => {
7661
7717
  }
7662
7718
  };
7663
7719
  return /*#__PURE__*/React.createElement(FieldContainer, {
7664
- style: {
7665
- position: 'relative',
7666
- width: '100%',
7667
- display: 'inline-block'
7668
- },
7720
+ ref: triggerRef,
7721
+ position: "relative",
7722
+ width: "100%",
7723
+ display: "inline-block",
7669
7724
  id: id,
7670
7725
  role: "SelectBox",
7671
7726
  helperText: helperText,
@@ -7695,7 +7750,8 @@ var SelectView = _ref7 => {
7695
7750
  isFocused: isFocused,
7696
7751
  showLabel: showLabel,
7697
7752
  onMouseEnter: handleHover,
7698
- onMouseLeave: handleHover
7753
+ onMouseLeave: handleHover,
7754
+ position: "relative"
7699
7755
  }, /*#__PURE__*/React.createElement(FieldWrapper, null, showLabel && (/*#__PURE__*/React.createElement(FieldLabel, Object.assign({
7700
7756
  htmlFor: id,
7701
7757
  color: 'theme.primary',
@@ -7728,15 +7784,10 @@ var SelectView = _ref7 => {
7728
7784
  orientation: "up",
7729
7785
  widthHeight: IconSizes$2[size],
7730
7786
  style: views.icon
7731
- })))))), !hide && options.length > 0 && (/*#__PURE__*/React.createElement(Element, {
7787
+ }))))), !hide && options.length > 0 && (/*#__PURE__*/React.createElement(Element, {
7788
+ ref: dropdownRef,
7732
7789
  onClick: e => e.stopPropagation(),
7733
- style: {
7734
- position: 'absolute',
7735
- top: 'calc(100% + 4px)',
7736
- left: 0,
7737
- right: 0,
7738
- zIndex: 1000
7739
- }
7790
+ style: getDropdownStyle()
7740
7791
  }, /*#__PURE__*/React.createElement(DropDown, {
7741
7792
  size: size,
7742
7793
  views: Object.assign({}, views, {
@@ -7753,7 +7804,7 @@ var SelectView = _ref7 => {
7753
7804
  callback: handleCallback,
7754
7805
  highlightedIndex: highlightedIndex,
7755
7806
  setHighlightedIndex: setHighlightedIndex
7756
- }))));
7807
+ })))));
7757
7808
  };
7758
7809
 
7759
7810
  // Defines a functional component named 'SelectComponent', which is expected to receive 'SelectProps' as properties.
@@ -11178,6 +11229,45 @@ var ComboBoxView = _ref => {
11178
11229
  // Collects all further props not destructured explicitly.
11179
11230
  } = _ref,
11180
11231
  props = _objectWithoutPropertiesLoose(_ref, _excluded$y);
11232
+ var {
11233
+ ref: triggerRef,
11234
+ relation
11235
+ } = useElementPosition();
11236
+ var dropdownRef = useRef(null);
11237
+ // Get optimal positioning style based on available space
11238
+ var getDropdownStyle = () => {
11239
+ if (!relation) {
11240
+ // Default positioning when relation is not available
11241
+ return {
11242
+ position: 'absolute',
11243
+ top: '100%',
11244
+ marginTop: '8px',
11245
+ left: 0,
11246
+ right: 0,
11247
+ zIndex: 10000,
11248
+ maxHeight: '240px'
11249
+ };
11250
+ }
11251
+ var baseStyle = {
11252
+ position: 'absolute',
11253
+ left: 0,
11254
+ right: 0,
11255
+ zIndex: 10000,
11256
+ maxHeight: '240px'
11257
+ };
11258
+ // Place dropdown where there's more space vertically
11259
+ if (relation.space.vertical === 'top') {
11260
+ return Object.assign({}, baseStyle, {
11261
+ bottom: '100%',
11262
+ marginBottom: '8px'
11263
+ });
11264
+ } else {
11265
+ return Object.assign({}, baseStyle, {
11266
+ top: '100%',
11267
+ marginTop: '8px'
11268
+ });
11269
+ }
11270
+ };
11181
11271
  // Sets up an effect to handle clicking outside the dropdown to close it.
11182
11272
  useEffect(() => {
11183
11273
  var handleClickOutside = event => {
@@ -11220,6 +11310,7 @@ var ComboBoxView = _ref => {
11220
11310
  }, label)), /*#__PURE__*/React.createElement(View, {
11221
11311
  position: "relative"
11222
11312
  }, /*#__PURE__*/React.createElement(Horizontal, Object.assign({
11313
+ ref: triggerRef,
11223
11314
  cursor: "pointer",
11224
11315
  backgroundColor: "color.white",
11225
11316
  boxShadow: "rgba(0, 0, 0, 0.16) 0px 1px 4px",
@@ -11240,19 +11331,14 @@ var ComboBoxView = _ref => {
11240
11331
  weight: "medium",
11241
11332
  flexGrow: 1,
11242
11333
  color: "color.gray.800"
11243
- }, views == null ? void 0 : views.label), selectedItem.label)), right, isDropdownVisible && (/*#__PURE__*/React.createElement(View, Object.assign({
11334
+ }, views == null ? void 0 : views.label), selectedItem.label)), right), isDropdownVisible && (/*#__PURE__*/React.createElement(View, Object.assign({
11335
+ ref: dropdownRef,
11244
11336
  id: "combobox-dropdown",
11245
- position: "absolute",
11246
11337
  backgroundColor: "color.white",
11247
- boxShadow: "rgba(0, 0 ,0 ,0.16) 0px 1px 4px",
11248
- width: "100%",
11338
+ boxShadow: "rgba(0, 0, 0, 0.16) 0px 1px 4px",
11249
11339
  overflowY: "auto",
11250
- zIndex: 10000,
11251
- bottom: -8,
11252
- left: 0,
11253
- transform: "translateY(100%)",
11254
- marginTop: "4px",
11255
- borderRadius: "4px"
11340
+ borderRadius: "4px",
11341
+ style: getDropdownStyle()
11256
11342
  }, views == null ? void 0 : views.dropdown), searchEnabled && (/*#__PURE__*/React.createElement(TextFieldView, {
11257
11343
  id: props.id,
11258
11344
  name: props.name,
@@ -11286,7 +11372,7 @@ var ComboBoxView = _ref => {
11286
11372
  onClick: () => handleSelect(item)
11287
11373
  }, views == null ? void 0 : views.item), /*#__PURE__*/React.createElement(Text, null, item.label), /*#__PURE__*/React.createElement(React.Fragment, null, item.icon && item.icon, item.value === selectedItem.value && showTick && !item.icon && /*#__PURE__*/React.createElement(TickIcon, {
11288
11374
  widthHeight: 20
11289
- }))))))))))));
11375
+ })))))))))));
11290
11376
  };
11291
11377
 
11292
11378
  var _excluded$z = ["id", "name", "items", "placeholder", "searchPlaceholder"];
@@ -11321,136 +11407,547 @@ var ComboBoxComponent = _ref => {
11321
11407
  // Exports the ComboBoxComponent as ComboBox
11322
11408
  var ComboBox = ComboBoxComponent;
11323
11409
 
11324
- function syncTimeouts(cb) {
11325
- var t1 = setTimeout(cb, 0); // For faster machines
11326
- var t2 = setTimeout(cb, 10);
11327
- var t3 = setTimeout(cb, 50);
11328
- return [t1, t2, t3];
11329
- }
11330
-
11331
- var useOTPInputState = _ref => {
11332
- var _window;
11333
- var {
11334
- value: controlledValue,
11335
- defaultValue = '',
11336
- length = 6,
11337
- onChange,
11338
- onChangeText,
11339
- onComplete,
11340
- onKeyDown,
11341
- onKeyPress,
11342
- onBlur,
11343
- onFocus,
11344
- isReadOnly,
11345
- isDisabled,
11346
- pattern,
11347
- stepValues,
11348
- pasteTransformer
11349
- } = _ref;
11350
- // Determine if component is controlled
11351
- var isControlled = controlledValue !== undefined;
11352
- var initialValue = isControlled ? controlledValue : defaultValue;
11353
- // State for the OTP value
11354
- var [value, setInternalValue] = useState((initialValue == null ? void 0 : initialValue.slice(0, length)) || '');
11410
+ /**
11411
+ * Custom hook for managing TagInput state
11412
+ */
11413
+ var useTagInputState = props => {
11414
+ var {
11415
+ tags: controlledTags,
11416
+ defaultTags = [],
11417
+ onTagsChange,
11418
+ onTagAdd,
11419
+ onTagRemove,
11420
+ maxTags,
11421
+ minTagLength = 1,
11422
+ maxTagLength = 50,
11423
+ allowDuplicates = false,
11424
+ separators = ['enter', 'comma'],
11425
+ isDisabled = false,
11426
+ isReadOnly = false
11427
+ } = props;
11428
+ // State for input value
11429
+ var [inputValue, setInputValue] = useState('');
11430
+ // State for tags (controlled vs uncontrolled)
11431
+ var [internalTags, setInternalTags] = useState(() => {
11432
+ var initialValue = controlledTags || defaultTags || [];
11433
+ return initialValue.map((tag, index) => ({
11434
+ id: "tag-" + index + "-" + Date.now(),
11435
+ value: tag
11436
+ }));
11437
+ });
11355
11438
  // State for focus and hover
11356
11439
  var [isFocused, setIsFocused] = useState(false);
11357
11440
  var [isHovered, setIsHovered] = useState(false);
11358
- // State for selection tracking
11359
- var [mirrorSelectionStart, setMirrorSelectionStart] = useState(null);
11360
- var [mirrorSelectionEnd, setMirrorSelectionEnd] = useState(null);
11361
- // Refs
11362
- var inputRef = useRef(null);
11363
- var containerRef = useRef(null);
11364
- var initialLoadRef = useRef({
11365
- value,
11366
- onChange: onChange || (() => {}),
11367
- isIOS: typeof window !== 'undefined' && ((_window = window) == null || (_window = _window.CSS) == null || _window.supports == null ? void 0 : _window.supports('-webkit-touch-callout', 'none'))
11368
- });
11369
- var inputMetadataRef = useRef({
11370
- prev: [null, null, 'none']
11371
- });
11372
- // Create regexp for validation
11373
- var regexp = pattern ? typeof pattern === 'string' ? new RegExp(pattern) : pattern : null;
11374
- // Sync with controlled value
11441
+ // Use controlled value if provided, otherwise use internal state
11442
+ var tags = controlledTags && Array.isArray(controlledTags) ? controlledTags.map((tag, index) => ({
11443
+ id: "tag-" + index + "-" + Date.now(),
11444
+ value: tag
11445
+ })) : internalTags;
11446
+ // Update internal tags when controlled value changes
11375
11447
  useEffect(() => {
11376
- if (isControlled && controlledValue !== value) {
11377
- setInternalValue((controlledValue == null ? void 0 : controlledValue.slice(0, length)) || '');
11448
+ if (controlledTags && Array.isArray(controlledTags)) {
11449
+ setInternalTags(controlledTags.map((tag, index) => ({
11450
+ id: "tag-" + index + "-" + Date.now(),
11451
+ value: tag
11452
+ })));
11378
11453
  }
11379
- }, [isControlled, controlledValue, length, value]);
11380
- // Handle value changes with completion check
11381
- var setValue = useCallback(newValue => {
11382
- // If step values are provided, find the closest step
11383
- var valueToSet = newValue;
11384
- if (stepValues && stepValues.length > 0 && newValue) {
11385
- // Convert to number for comparison
11386
- var numValue = parseInt(newValue, 10);
11387
- if (!isNaN(numValue)) {
11388
- // Find the closest step value
11389
- var closest = stepValues[0];
11390
- var minDiff = Math.abs(numValue - closest);
11391
- for (var i = 1; i < stepValues.length; i++) {
11392
- var diff = Math.abs(numValue - stepValues[i]);
11393
- if (diff < minDiff) {
11394
- minDiff = diff;
11395
- closest = stepValues[i];
11396
- }
11397
- }
11398
- // Convert back to string
11399
- valueToSet = closest.toString();
11454
+ }, [controlledTags]);
11455
+ /**
11456
+ * Validates a tag before adding
11457
+ */
11458
+ var validateTag = useCallback(tag => {
11459
+ var trimmed = tag.trim();
11460
+ // Check length constraints
11461
+ if (trimmed.length < minTagLength || trimmed.length > maxTagLength) {
11462
+ return false;
11463
+ }
11464
+ // Check for duplicates if not allowed
11465
+ if (!allowDuplicates) {
11466
+ var tagValues = tags.map(t => t.value.toLowerCase());
11467
+ if (tagValues.includes(trimmed.toLowerCase())) {
11468
+ return false;
11400
11469
  }
11401
11470
  }
11402
- // Always update internal state for both controlled and uncontrolled components
11403
- setInternalValue(valueToSet);
11404
- // Call onChange if provided
11405
- if (onChange) {
11406
- onChange(valueToSet);
11471
+ // Check maximum tags limit
11472
+ if (maxTags && tags.length >= maxTags) {
11473
+ return false;
11407
11474
  }
11408
- // Call onChangeText if provided
11409
- if (onChangeText) {
11410
- onChangeText(valueToSet);
11475
+ return true;
11476
+ }, [tags, minTagLength, maxTagLength, allowDuplicates, maxTags]);
11477
+ /**
11478
+ * Adds a new tag
11479
+ */
11480
+ var addTag = useCallback(tag => {
11481
+ if (isDisabled || isReadOnly) return;
11482
+ var trimmed = tag.trim();
11483
+ if (!trimmed || !validateTag(trimmed)) return;
11484
+ var newTag = {
11485
+ id: "tag-" + Date.now() + "-" + Math.random(),
11486
+ value: trimmed
11487
+ };
11488
+ var newTags = [...tags, newTag];
11489
+ var tagValues = newTags.map(t => t.value);
11490
+ if (!controlledTags) {
11491
+ setInternalTags(newTags);
11492
+ }
11493
+ onTagsChange == null || onTagsChange(tagValues);
11494
+ onTagAdd == null || onTagAdd(trimmed);
11495
+ setInputValue('');
11496
+ }, [tags, validateTag, onTagsChange, onTagAdd, isDisabled, isReadOnly, controlledTags]);
11497
+ /**
11498
+ * Removes a tag by index
11499
+ */
11500
+ var removeTag = useCallback(index => {
11501
+ if (isDisabled || isReadOnly) return;
11502
+ var tagToRemove = tags[index];
11503
+ if (!tagToRemove) return;
11504
+ var newTags = tags.filter((_, i) => i !== index);
11505
+ var tagValues = newTags.map(t => t.value);
11506
+ if (!controlledTags) {
11507
+ setInternalTags(newTags);
11508
+ }
11509
+ onTagsChange == null || onTagsChange(tagValues);
11510
+ onTagRemove == null || onTagRemove(tagToRemove.value, index);
11511
+ }, [tags, onTagsChange, onTagRemove, isDisabled, isReadOnly, controlledTags]);
11512
+ /**
11513
+ * Handles input change
11514
+ */
11515
+ var handleInputChange = useCallback(event => {
11516
+ if (isDisabled || isReadOnly) return;
11517
+ var newValue = event.target.value;
11518
+ // Check for comma separator
11519
+ if (separators.includes('comma') && newValue.includes(',')) {
11520
+ var parts = newValue.split(',');
11521
+ var tagToAdd = parts[0];
11522
+ var remaining = parts.slice(1).join(',');
11523
+ if (tagToAdd.trim()) {
11524
+ addTag(tagToAdd);
11525
+ }
11526
+ setInputValue(remaining);
11527
+ return;
11411
11528
  }
11412
- // Check if the OTP is complete and call onComplete if provided
11413
- if (onComplete && valueToSet.length === length) {
11414
- onComplete(valueToSet);
11529
+ setInputValue(newValue);
11530
+ }, [addTag, separators, isDisabled, isReadOnly]);
11531
+ /**
11532
+ * Handles key down events
11533
+ */
11534
+ var handleKeyDown = useCallback(event => {
11535
+ if (isDisabled || isReadOnly) return;
11536
+ var {
11537
+ key
11538
+ } = event;
11539
+ // Handle Enter key
11540
+ if (separators.includes('enter') && key === 'Enter') {
11541
+ event.preventDefault();
11542
+ if (inputValue.trim()) {
11543
+ addTag(inputValue);
11544
+ }
11545
+ return;
11415
11546
  }
11416
- }, [onChange, onChangeText, onComplete, length, stepValues]);
11417
- // Set up input ref
11418
- var setInputRef = useCallback(ref => {
11419
- // We can't directly assign to inputRef.current, so we use this workaround
11420
- if (ref && inputRef.current !== ref) {
11421
- // Store the reference without directly assigning
11422
- Object.defineProperty(inputRef, 'current', {
11423
- value: ref,
11424
- writable: true
11425
- });
11547
+ // Handle Tab key
11548
+ if (separators.includes('tab') && key === 'Tab' && inputValue.trim()) {
11549
+ event.preventDefault();
11550
+ addTag(inputValue);
11551
+ return;
11426
11552
  }
11427
- }, []);
11428
- // Event handlers
11429
- var handleChange = useCallback(e => {
11430
- var newValue = e.currentTarget.value.slice(0, length);
11431
- if (newValue.length > 0 && regexp && !regexp.test(newValue)) {
11432
- e.preventDefault();
11553
+ // Handle Space key
11554
+ if (separators.includes('space') && key === ' ' && inputValue.trim()) {
11555
+ event.preventDefault();
11556
+ addTag(inputValue);
11433
11557
  return;
11434
11558
  }
11435
- // Always update the value
11436
- setValue(newValue);
11437
- // Update the input field value directly to ensure it's always in sync
11438
- if (inputRef.current) {
11439
- inputRef.current.value = newValue;
11559
+ // Handle Backspace to remove last tag
11560
+ if (key === 'Backspace' && !inputValue && tags.length > 0) {
11561
+ event.preventDefault();
11562
+ removeTag(tags.length - 1);
11563
+ return;
11440
11564
  }
11441
- }, [length, regexp, setValue, inputRef]);
11565
+ }, [addTag, removeTag, inputValue, tags, separators, isDisabled, isReadOnly]);
11566
+ /**
11567
+ * Handles input focus
11568
+ */
11442
11569
  var handleFocus = useCallback(() => {
11443
- if (inputRef.current) {
11444
- var _inputRef$current;
11445
- var start = Math.min(inputRef.current.value.length, length - 1);
11446
- var end = inputRef.current.value.length;
11447
- (_inputRef$current = inputRef.current) == null || _inputRef$current.setSelectionRange(start, end);
11448
- setMirrorSelectionStart(start);
11449
- setMirrorSelectionEnd(end);
11450
- }
11451
11570
  setIsFocused(true);
11452
- }, [length]);
11453
- var handleBlur = useCallback(() => {
11571
+ props.onFocus == null || props.onFocus();
11572
+ }, [props.onFocus]);
11573
+ /**
11574
+ * Handles input blur
11575
+ */
11576
+ var handleBlur = useCallback(() => {
11577
+ setIsFocused(false);
11578
+ // Add current input value as tag on blur if it exists
11579
+ if (inputValue.trim()) {
11580
+ addTag(inputValue);
11581
+ }
11582
+ props.onBlur == null || props.onBlur();
11583
+ }, [addTag, inputValue, props.onBlur]);
11584
+ return {
11585
+ inputValue,
11586
+ setInputValue,
11587
+ tags,
11588
+ setTags: setInternalTags,
11589
+ isFocused,
11590
+ setIsFocused,
11591
+ isHovered,
11592
+ setIsHovered,
11593
+ addTag,
11594
+ removeTag,
11595
+ handleInputChange,
11596
+ handleKeyDown,
11597
+ handleFocus,
11598
+ handleBlur,
11599
+ validateTag
11600
+ };
11601
+ };
11602
+
11603
+ var _excluded$A = ["id", "name", "label", "placeholder", "helperText", "error", "inputValue", "tags", "left", "right", "shadow", "views", "size", "shape", "variant", "isDisabled", "isReadOnly", "isAutoFocus", "isRemovable", "isFocused", "isHovered", "maxTags", "handleInputChange", "handleKeyDown", "handleFocus", "handleBlur", "removeTag", "setIsHovered", "onClick"];
11604
+ /**
11605
+ * Individual tag chip component
11606
+ */
11607
+ var TagChip = _ref => {
11608
+ var {
11609
+ tag,
11610
+ onRemove,
11611
+ isRemovable,
11612
+ size,
11613
+ views,
11614
+ isDisabled,
11615
+ isReadOnly
11616
+ } = _ref;
11617
+ var {
11618
+ getColor
11619
+ } = useTheme();
11620
+ var chipSize = {
11621
+ xs: {
11622
+ padding: '2px 6px',
11623
+ fontSize: '10px',
11624
+ iconSize: 10
11625
+ },
11626
+ sm: {
11627
+ padding: '4px 8px',
11628
+ fontSize: '12px',
11629
+ iconSize: 12
11630
+ },
11631
+ md: {
11632
+ padding: '6px 10px',
11633
+ fontSize: '14px',
11634
+ iconSize: 14
11635
+ },
11636
+ lg: {
11637
+ padding: '8px 12px',
11638
+ fontSize: '16px',
11639
+ iconSize: 16
11640
+ },
11641
+ xl: {
11642
+ padding: '10px 14px',
11643
+ fontSize: '18px',
11644
+ iconSize: 18
11645
+ }
11646
+ }[size] || {
11647
+ padding: '6px 10px',
11648
+ fontSize: '14px',
11649
+ iconSize: 14
11650
+ };
11651
+ return /*#__PURE__*/React.createElement(Horizontal, Object.assign({
11652
+ alignItems: "center",
11653
+ gap: 4,
11654
+ padding: chipSize.padding,
11655
+ backgroundColor: "color.gray.100",
11656
+ borderRadius: "16px",
11657
+ border: "1px solid",
11658
+ borderColor: "color.gray.200",
11659
+ transition: "all 0.2s ease",
11660
+ opacity: isDisabled ? 0.6 : 1,
11661
+ _hover: !isDisabled && !isReadOnly ? {
11662
+ backgroundColor: 'color.gray.200',
11663
+ borderColor: 'color.gray.300'
11664
+ } : {}
11665
+ }, views == null ? void 0 : views.tag), /*#__PURE__*/React.createElement(Text$1, Object.assign({
11666
+ fontSize: chipSize.fontSize,
11667
+ color: isDisabled ? 'color.gray.400' : 'color.gray.700',
11668
+ fontWeight: "500",
11669
+ whiteSpace: "nowrap"
11670
+ }, views == null ? void 0 : views.tagText), tag), isRemovable && !isDisabled && !isReadOnly && (/*#__PURE__*/React.createElement(View, Object.assign({
11671
+ cursor: "pointer",
11672
+ padding: "2px",
11673
+ borderRadius: "50%",
11674
+ transition: "all 0.2s ease",
11675
+ _hover: {
11676
+ backgroundColor: 'color.gray.300'
11677
+ },
11678
+ onClick: onRemove
11679
+ }, views == null ? void 0 : views.tagRemove), /*#__PURE__*/React.createElement(CloseIcon, {
11680
+ widthHeight: chipSize.iconSize,
11681
+ color: "color.gray.500"
11682
+ }))));
11683
+ };
11684
+ /**
11685
+ * Main TagInput view component
11686
+ */
11687
+ var TagInputView = _ref2 => {
11688
+ var {
11689
+ id,
11690
+ name,
11691
+ label,
11692
+ placeholder = 'Type and press Enter to add tags...',
11693
+ helperText,
11694
+ error = false,
11695
+ inputValue = '',
11696
+ tags = [],
11697
+ left,
11698
+ right,
11699
+ shadow = {},
11700
+ views = {},
11701
+ size = 'md',
11702
+ shape = 'default',
11703
+ variant = 'default',
11704
+ isDisabled = false,
11705
+ isReadOnly = false,
11706
+ isAutoFocus = false,
11707
+ isRemovable = true,
11708
+ isFocused = false,
11709
+ isHovered = false,
11710
+ maxTags,
11711
+ handleInputChange,
11712
+ handleKeyDown,
11713
+ handleFocus,
11714
+ handleBlur,
11715
+ removeTag,
11716
+ setIsHovered,
11717
+ onClick
11718
+ } = _ref2,
11719
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$A);
11720
+ var {
11721
+ getColor,
11722
+ themeMode
11723
+ } = useTheme();
11724
+ // Determine if we should show the label
11725
+ var showLabel = Boolean(label && (isFocused || tags.length > 0 || inputValue));
11726
+ // Calculate if max tags reached
11727
+ var isMaxReached = maxTags && tags.length >= maxTags;
11728
+ // Container styles
11729
+ var containerStyles = Object.assign({}, Shapes[shape], InputVariants[variant], views == null ? void 0 : views.inputContainer);
11730
+ // Input styles
11731
+ var inputStyles = Object.assign({
11732
+ border: 'none',
11733
+ outline: 'none',
11734
+ backgroundColor: 'transparent',
11735
+ fontSize: Typography.fontSizes[size],
11736
+ color: isDisabled ? 'color.gray.400' : 'color.gray.900',
11737
+ flex: 1,
11738
+ minWidth: '120px'
11739
+ }, views == null ? void 0 : views.input);
11740
+ return /*#__PURE__*/React.createElement(FieldContainer, Object.assign({
11741
+ error: !!error,
11742
+ helperText: typeof error === 'string' ? error : helperText,
11743
+ views: views
11744
+ }, props), /*#__PURE__*/React.createElement(FieldContent, Object.assign({
11745
+ label: label,
11746
+ shadow: shadow,
11747
+ value: tags.length > 0 || inputValue ? 'has-content' : '',
11748
+ size: size,
11749
+ shape: shape,
11750
+ variant: variant,
11751
+ error: !!error,
11752
+ showLabel: showLabel,
11753
+ isFocused: isFocused,
11754
+ isHovered: isHovered,
11755
+ isDisabled: isDisabled,
11756
+ isReadOnly: isReadOnly,
11757
+ views: views,
11758
+ onClick: onClick,
11759
+ onMouseEnter: () => setIsHovered == null ? void 0 : setIsHovered(true),
11760
+ onMouseLeave: () => setIsHovered == null ? void 0 : setIsHovered(false)
11761
+ }, containerStyles), left, /*#__PURE__*/React.createElement(FieldWrapper, null, label && (/*#__PURE__*/React.createElement(FieldLabel, {
11762
+ size: size,
11763
+ error: !!error,
11764
+ views: views
11765
+ }, label)), /*#__PURE__*/React.createElement(Horizontal, Object.assign({
11766
+ alignItems: "center",
11767
+ gap: 4,
11768
+ flexWrap: "wrap",
11769
+ width: "100%",
11770
+ minHeight: Typography.fontSizes[size],
11771
+ padding: "8px 0"
11772
+ }, views == null ? void 0 : views.tagsContainer), tags.map((tag, index) => (/*#__PURE__*/React.createElement(TagChip, {
11773
+ key: tag.id,
11774
+ tag: tag.value,
11775
+ onRemove: () => removeTag == null ? void 0 : removeTag(index),
11776
+ isRemovable: isRemovable,
11777
+ size: size,
11778
+ views: views,
11779
+ isDisabled: isDisabled,
11780
+ isReadOnly: isReadOnly
11781
+ }))), !isMaxReached && (/*#__PURE__*/React.createElement(Input, Object.assign({
11782
+ id: id,
11783
+ name: name,
11784
+ type: "text",
11785
+ value: inputValue,
11786
+ placeholder: tags.length === 0 ? placeholder : '',
11787
+ disabled: isDisabled,
11788
+ readOnly: isReadOnly,
11789
+ autoFocus: isAutoFocus,
11790
+ onChange: handleInputChange,
11791
+ onKeyDown: handleKeyDown,
11792
+ onFocus: handleFocus,
11793
+ onBlur: handleBlur,
11794
+ autoComplete: "off"
11795
+ }, inputStyles))), isMaxReached && (/*#__PURE__*/React.createElement(Text$1, Object.assign({
11796
+ fontSize: Typography.fontSizes[size],
11797
+ color: "color.gray.500",
11798
+ fontStyle: "italic"
11799
+ }, views == null ? void 0 : views.placeholder), "Maximum ", maxTags, " tags reached")))), right));
11800
+ };
11801
+
11802
+ var _excluded$B = ["tags"];
11803
+ /**
11804
+ * TagInput Component
11805
+ *
11806
+ * A form input component for managing a list of tags.
11807
+ * Users can add tags by typing and pressing Enter or comma,
11808
+ * and remove them by clicking the X button or using backspace.
11809
+ */
11810
+ var TagInputComponent = props => {
11811
+ // Initialize state management with the custom hook
11812
+ var tagInputState = useTagInputState(props);
11813
+ // Separate the tags prop to avoid type conflicts
11814
+ var restProps = _objectWithoutPropertiesLoose(props, _excluded$B);
11815
+ // Render the view component with combined props and state
11816
+ return /*#__PURE__*/React.createElement(TagInputView, Object.assign({}, tagInputState, restProps));
11817
+ };
11818
+ // Export the component
11819
+ var TagInput = TagInputComponent;
11820
+
11821
+ function syncTimeouts(cb) {
11822
+ var t1 = setTimeout(cb, 0); // For faster machines
11823
+ var t2 = setTimeout(cb, 10);
11824
+ var t3 = setTimeout(cb, 50);
11825
+ return [t1, t2, t3];
11826
+ }
11827
+
11828
+ var useOTPInputState = _ref => {
11829
+ var _window;
11830
+ var {
11831
+ value: controlledValue,
11832
+ defaultValue = '',
11833
+ length = 6,
11834
+ onChange,
11835
+ onChangeText,
11836
+ onComplete,
11837
+ onKeyDown,
11838
+ onKeyPress,
11839
+ onBlur,
11840
+ onFocus,
11841
+ isReadOnly,
11842
+ isDisabled,
11843
+ pattern,
11844
+ stepValues,
11845
+ pasteTransformer
11846
+ } = _ref;
11847
+ // Determine if component is controlled
11848
+ var isControlled = controlledValue !== undefined;
11849
+ var initialValue = isControlled ? controlledValue : defaultValue;
11850
+ // State for the OTP value
11851
+ var [value, setInternalValue] = useState((initialValue == null ? void 0 : initialValue.slice(0, length)) || '');
11852
+ // State for focus and hover
11853
+ var [isFocused, setIsFocused] = useState(false);
11854
+ var [isHovered, setIsHovered] = useState(false);
11855
+ // State for selection tracking
11856
+ var [mirrorSelectionStart, setMirrorSelectionStart] = useState(null);
11857
+ var [mirrorSelectionEnd, setMirrorSelectionEnd] = useState(null);
11858
+ // Refs
11859
+ var inputRef = useRef(null);
11860
+ var containerRef = useRef(null);
11861
+ var initialLoadRef = useRef({
11862
+ value,
11863
+ onChange: onChange || (() => {}),
11864
+ isIOS: typeof window !== 'undefined' && ((_window = window) == null || (_window = _window.CSS) == null || _window.supports == null ? void 0 : _window.supports('-webkit-touch-callout', 'none'))
11865
+ });
11866
+ var inputMetadataRef = useRef({
11867
+ prev: [null, null, 'none']
11868
+ });
11869
+ // Create regexp for validation
11870
+ var regexp = pattern ? typeof pattern === 'string' ? new RegExp(pattern) : pattern : null;
11871
+ // Sync with controlled value
11872
+ useEffect(() => {
11873
+ if (isControlled && controlledValue !== value) {
11874
+ setInternalValue((controlledValue == null ? void 0 : controlledValue.slice(0, length)) || '');
11875
+ }
11876
+ }, [isControlled, controlledValue, length, value]);
11877
+ // Handle value changes with completion check
11878
+ var setValue = useCallback(newValue => {
11879
+ // If step values are provided, find the closest step
11880
+ var valueToSet = newValue;
11881
+ if (stepValues && stepValues.length > 0 && newValue) {
11882
+ // Convert to number for comparison
11883
+ var numValue = parseInt(newValue, 10);
11884
+ if (!isNaN(numValue)) {
11885
+ // Find the closest step value
11886
+ var closest = stepValues[0];
11887
+ var minDiff = Math.abs(numValue - closest);
11888
+ for (var i = 1; i < stepValues.length; i++) {
11889
+ var diff = Math.abs(numValue - stepValues[i]);
11890
+ if (diff < minDiff) {
11891
+ minDiff = diff;
11892
+ closest = stepValues[i];
11893
+ }
11894
+ }
11895
+ // Convert back to string
11896
+ valueToSet = closest.toString();
11897
+ }
11898
+ }
11899
+ // Always update internal state for both controlled and uncontrolled components
11900
+ setInternalValue(valueToSet);
11901
+ // Call onChange if provided
11902
+ if (onChange) {
11903
+ onChange(valueToSet);
11904
+ }
11905
+ // Call onChangeText if provided
11906
+ if (onChangeText) {
11907
+ onChangeText(valueToSet);
11908
+ }
11909
+ // Check if the OTP is complete and call onComplete if provided
11910
+ if (onComplete && valueToSet.length === length) {
11911
+ onComplete(valueToSet);
11912
+ }
11913
+ }, [onChange, onChangeText, onComplete, length, stepValues]);
11914
+ // Set up input ref
11915
+ var setInputRef = useCallback(ref => {
11916
+ // We can't directly assign to inputRef.current, so we use this workaround
11917
+ if (ref && inputRef.current !== ref) {
11918
+ // Store the reference without directly assigning
11919
+ Object.defineProperty(inputRef, 'current', {
11920
+ value: ref,
11921
+ writable: true
11922
+ });
11923
+ }
11924
+ }, []);
11925
+ // Event handlers
11926
+ var handleChange = useCallback(e => {
11927
+ var newValue = e.currentTarget.value.slice(0, length);
11928
+ if (newValue.length > 0 && regexp && !regexp.test(newValue)) {
11929
+ e.preventDefault();
11930
+ return;
11931
+ }
11932
+ // Always update the value
11933
+ setValue(newValue);
11934
+ // Update the input field value directly to ensure it's always in sync
11935
+ if (inputRef.current) {
11936
+ inputRef.current.value = newValue;
11937
+ }
11938
+ }, [length, regexp, setValue, inputRef]);
11939
+ var handleFocus = useCallback(() => {
11940
+ if (inputRef.current) {
11941
+ var _inputRef$current;
11942
+ var start = Math.min(inputRef.current.value.length, length - 1);
11943
+ var end = inputRef.current.value.length;
11944
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.setSelectionRange(start, end);
11945
+ setMirrorSelectionStart(start);
11946
+ setMirrorSelectionEnd(end);
11947
+ }
11948
+ setIsFocused(true);
11949
+ }, [length]);
11950
+ var handleBlur = useCallback(() => {
11454
11951
  setIsFocused(false);
11455
11952
  }, []);
11456
11953
  var handleKeyDown = useCallback(_ => {
@@ -11627,7 +12124,7 @@ var useOTPInputState = _ref => {
11627
12124
  };
11628
12125
  };
11629
12126
 
11630
- var _excluded$A = ["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"];
12127
+ var _excluded$C = ["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"];
11631
12128
  // Create a context for OTP input slots
11632
12129
  var OTPInputContext = /*#__PURE__*/createContext({
11633
12130
  slots: [],
@@ -11681,7 +12178,7 @@ var OTPInputView = _ref => {
11681
12178
  onFocus = () => {}
11682
12179
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11683
12180
  } = _ref,
11684
- props = _objectWithoutPropertiesLoose(_ref, _excluded$A);
12181
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$C);
11685
12182
  useTheme(); // Initialize theme context
11686
12183
  var showLabel = !!label;
11687
12184
  // Create context value for slots
@@ -11913,7 +12410,7 @@ var OTPInputComponent = props => {
11913
12410
  };
11914
12411
  var OTPInput = OTPInputComponent;
11915
12412
 
11916
- var _excluded$B = ["children", "autoFocus", "initFocus", "onChange"];
12413
+ var _excluded$D = ["children", "autoFocus", "initFocus", "onChange"];
11917
12414
  var FocusContext = /*#__PURE__*/createContext({
11918
12415
  active: false,
11919
12416
  focusNextInput: () => {},
@@ -11929,7 +12426,7 @@ var FormikForm = _ref => {
11929
12426
  initFocus,
11930
12427
  onChange = () => {}
11931
12428
  } = _ref,
11932
- props = _objectWithoutPropertiesLoose(_ref, _excluded$B);
12429
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$D);
11933
12430
  var formik = useFormikContext();
11934
12431
  useEffect(() => {
11935
12432
  onChange(formik.values);
@@ -11977,7 +12474,7 @@ var FormikForm = _ref => {
11977
12474
  }, /*#__PURE__*/React.createElement(Form, Object.assign({}, props), children));
11978
12475
  };
11979
12476
 
11980
- var _excluded$C = ["name", "type"];
12477
+ var _excluded$E = ["name", "type"];
11981
12478
  var getInputTypeProps = type => {
11982
12479
  switch (type) {
11983
12480
  case 'email':
@@ -12016,7 +12513,7 @@ var useFormikInput = _ref => {
12016
12513
  name,
12017
12514
  type
12018
12515
  } = _ref,
12019
- props = _objectWithoutPropertiesLoose(_ref, _excluded$C);
12516
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$E);
12020
12517
  var focus = useFormFocus();
12021
12518
  var {
12022
12519
  touched,
@@ -12060,13 +12557,13 @@ var useFormikInput = _ref => {
12060
12557
  } : {});
12061
12558
  };
12062
12559
 
12063
- var _excluded$D = ["value"];
12560
+ var _excluded$F = ["value"];
12064
12561
  var CheckboxComponent$1 = props => {
12065
12562
  var _useFormikInput = useFormikInput(props),
12066
12563
  {
12067
12564
  value
12068
12565
  } = _useFormikInput,
12069
- formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$D);
12566
+ formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$F);
12070
12567
  formProps.isChecked = value;
12071
12568
  var checkboxStates = useCheckboxState(props);
12072
12569
  return /*#__PURE__*/React.createElement(CheckboxView, Object.assign({}, checkboxStates, formProps));
@@ -12134,11 +12631,11 @@ var TextAreaComponent$1 = props => {
12134
12631
  */
12135
12632
  var FormikTextArea = TextAreaComponent$1;
12136
12633
 
12137
- var _excluded$E = ["value"];
12634
+ var _excluded$G = ["value"];
12138
12635
  var TextFieldComponent$1 = props => {
12139
12636
  var formProps = useFormikInput(props);
12140
12637
  var _useTextFieldState = useTextFieldState(props),
12141
- textFieldStates = _objectWithoutPropertiesLoose(_useTextFieldState, _excluded$E);
12638
+ textFieldStates = _objectWithoutPropertiesLoose(_useTextFieldState, _excluded$G);
12142
12639
  return /*#__PURE__*/React.createElement(TextFieldView, Object.assign({}, textFieldStates, formProps));
12143
12640
  };
12144
12641
  /**
@@ -12146,7 +12643,7 @@ var TextFieldComponent$1 = props => {
12146
12643
  */
12147
12644
  var FormikTextField = TextFieldComponent$1;
12148
12645
 
12149
- var _excluded$F = ["visibleIcon", "hiddenIcon"],
12646
+ var _excluded$H = ["visibleIcon", "hiddenIcon"],
12150
12647
  _excluded2$b = ["isVisible", "setIsVisible"];
12151
12648
  var PasswordComponent$1 = _ref => {
12152
12649
  var {
@@ -12157,7 +12654,7 @@ var PasswordComponent$1 = _ref => {
12157
12654
  widthHeight: 14
12158
12655
  })
12159
12656
  } = _ref,
12160
- props = _objectWithoutPropertiesLoose(_ref, _excluded$F);
12657
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$H);
12161
12658
  var formProps = useFormikInput(props);
12162
12659
  var _usePasswordState = usePasswordState(formProps),
12163
12660
  {
@@ -12182,14 +12679,14 @@ var PasswordComponent$1 = _ref => {
12182
12679
  */
12183
12680
  var FormikPassword = PasswordComponent$1;
12184
12681
 
12185
- var _excluded$G = ["items", "placeholder", "searchPlaceholder"];
12682
+ var _excluded$I = ["items", "placeholder", "searchPlaceholder"];
12186
12683
  var ComboBoxComponent$1 = _ref => {
12187
12684
  var {
12188
12685
  items,
12189
12686
  placeholder,
12190
12687
  searchPlaceholder
12191
12688
  } = _ref,
12192
- props = _objectWithoutPropertiesLoose(_ref, _excluded$G);
12689
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$I);
12193
12690
  var formProps = useFormikInput(props);
12194
12691
  var ComboBoxStates = useComboBoxState(items, placeholder, searchPlaceholder);
12195
12692
  // Ensure the onChange function from formProps is being called when an item is selected
@@ -12470,7 +12967,7 @@ var OrientationStyles = {
12470
12967
  }
12471
12968
  };
12472
12969
 
12473
- var _excluded$H = ["min", "max", "step", "currentValue", "stepValues", "shape", "size", "variant", "orientation", "isDisabled", "showValue", "showTooltip", "backgroundColor", "label", "helperText", "themeMode", "shadow", "isDragging", "isHovered", "setIsHovered", "trackRef", "thumbRef", "handleThumbMouseDown", "handleTrackMouseDown", "handleKeyDown", "thumbPositionPercent", "ariaLabel", "views"];
12970
+ var _excluded$J = ["min", "max", "step", "currentValue", "stepValues", "shape", "size", "variant", "orientation", "isDisabled", "showValue", "showTooltip", "backgroundColor", "label", "helperText", "themeMode", "shadow", "isDragging", "isHovered", "setIsHovered", "trackRef", "thumbRef", "handleThumbMouseDown", "handleTrackMouseDown", "handleKeyDown", "thumbPositionPercent", "ariaLabel", "views"];
12474
12971
  var SliderView = _ref => {
12475
12972
  var _views$tooltip, _views$tooltip2;
12476
12973
  var {
@@ -12513,7 +13010,7 @@ var SliderView = _ref => {
12513
13010
  tooltip: {}
12514
13011
  }
12515
13012
  } = _ref,
12516
- props = _objectWithoutPropertiesLoose(_ref, _excluded$H);
13013
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$J);
12517
13014
  var {
12518
13015
  getColor,
12519
13016
  themeMode
@@ -13426,7 +13923,7 @@ var UploadView = _ref => {
13426
13923
  }, views == null ? void 0 : views.view)));
13427
13924
  };
13428
13925
 
13429
- var _excluded$I = ["accept", "icon", "text", "maxSize", "onFileSelect", "onMultipleFileSelect", "validateFile", "isLoading", "progress", "fileType", "multiple"];
13926
+ var _excluded$K = ["accept", "icon", "text", "maxSize", "onFileSelect", "onMultipleFileSelect", "validateFile", "isLoading", "progress", "fileType", "multiple"];
13430
13927
  var Uploader = _ref => {
13431
13928
  var {
13432
13929
  accept = '*/*',
@@ -13441,7 +13938,7 @@ var Uploader = _ref => {
13441
13938
  fileType,
13442
13939
  multiple = false
13443
13940
  } = _ref,
13444
- props = _objectWithoutPropertiesLoose(_ref, _excluded$I);
13941
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$K);
13445
13942
  var {
13446
13943
  previewUrl,
13447
13944
  thumbnailUrl,
@@ -13637,7 +14134,7 @@ var ModalTypography = {
13637
14134
  }
13638
14135
  };
13639
14136
 
13640
- var _excluded$J = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position", "views"],
14137
+ var _excluded$L = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position", "views"],
13641
14138
  _excluded2$c = ["children", "shadow", "isFullScreen", "shape", "views", "isOpen"],
13642
14139
  _excluded3$8 = ["children", "buttonColor", "iconSize", "buttonPosition", "views"],
13643
14140
  _excluded4$7 = ["children", "views"],
@@ -13652,7 +14149,7 @@ var ModalOverlay = _ref => {
13652
14149
  position = 'center',
13653
14150
  views
13654
14151
  } = _ref,
13655
- props = _objectWithoutPropertiesLoose(_ref, _excluded$J);
14152
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$L);
13656
14153
  var handleClick = () => {
13657
14154
  if (!isClosePrevented) onClose();
13658
14155
  };
@@ -13948,7 +14445,7 @@ var NavigationMenuItemStates = {
13948
14445
  }
13949
14446
  };
13950
14447
 
13951
- var _excluded$K = ["href", "children", "views"];
14448
+ var _excluded$M = ["href", "children", "views"];
13952
14449
  // Create context for the NavigationMenu
13953
14450
  var NavigationMenuContext = /*#__PURE__*/createContext({
13954
14451
  activeItemId: null,
@@ -14179,7 +14676,7 @@ var NavigationMenuLink = _ref6 => {
14179
14676
  children,
14180
14677
  views
14181
14678
  } = _ref6,
14182
- props = _objectWithoutPropertiesLoose(_ref6, _excluded$K);
14679
+ props = _objectWithoutPropertiesLoose(_ref6, _excluded$M);
14183
14680
  var {
14184
14681
  itemValue,
14185
14682
  isDisabled
@@ -14246,7 +14743,7 @@ var NavigationMenuView = _ref7 => {
14246
14743
  })))));
14247
14744
  };
14248
14745
 
14249
- var _excluded$L = ["items", "children", "orientation", "size", "variant", "defaultActiveItemId", "defaultExpandedItemIds", "onItemActivate", "views"];
14746
+ var _excluded$N = ["items", "children", "orientation", "size", "variant", "defaultActiveItemId", "defaultExpandedItemIds", "onItemActivate", "views"];
14250
14747
  /**
14251
14748
  * NavigationMenu component for creating navigation menus with optional nested items.
14252
14749
  * Supports both data-driven approach (with items prop) and compound component pattern.
@@ -14263,7 +14760,7 @@ var NavigationMenuComponent = _ref => {
14263
14760
  onItemActivate,
14264
14761
  views
14265
14762
  } = _ref,
14266
- props = _objectWithoutPropertiesLoose(_ref, _excluded$L);
14763
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$N);
14267
14764
  var {
14268
14765
  activeItemId,
14269
14766
  setActiveItemId,
@@ -14786,20 +15283,20 @@ var useTitleState = props => {
14786
15283
  * Font sizes for different title sizes
14787
15284
  */
14788
15285
  var TitleSizes = {
14789
- xs: 16,
14790
- sm: 20,
14791
- md: 32,
14792
- lg: 48,
15286
+ xs: 24,
15287
+ sm: 36,
15288
+ md: 48,
15289
+ lg: 64,
14793
15290
  xl: 72
14794
15291
  };
14795
15292
  /**
14796
15293
  * Line heights for different title sizes
14797
15294
  */
14798
15295
  var LineHeights$1 = {
14799
- xs: 24,
14800
- sm: 28,
14801
- md: 40,
14802
- lg: 56,
15296
+ xs: 32,
15297
+ sm: 40,
15298
+ md: 56,
15299
+ lg: 72,
14803
15300
  xl: 80
14804
15301
  };
14805
15302
  /**
@@ -14839,7 +15336,7 @@ var HighlightStyles = {
14839
15336
  })
14840
15337
  };
14841
15338
 
14842
- var _excluded$M = ["text", "typingSpeed", "pauseTime", "onComplete", "showCursor", "cursorColor", "textStyle", "as"];
15339
+ var _excluded$O = ["text", "typingSpeed", "pauseTime", "onComplete", "showCursor", "cursorColor", "textStyle", "as"];
14843
15340
  /**
14844
15341
  * A component that creates a typewriter effect for text
14845
15342
  */
@@ -14853,7 +15350,7 @@ var TypewriterEffect = _ref => {
14853
15350
  cursorColor = 'currentColor',
14854
15351
  textStyle
14855
15352
  } = _ref,
14856
- props = _objectWithoutPropertiesLoose(_ref, _excluded$M);
15353
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$O);
14857
15354
  // Convert text to array if it's a string
14858
15355
  var textArray = Array.isArray(text) ? text : [text];
14859
15356
  // State for the currently displayed text
@@ -14920,7 +15417,7 @@ var TypewriterEffect = _ref => {
14920
15417
  }))))));
14921
15418
  };
14922
15419
 
14923
- var _excluded$N = ["children", "highlightText", "highlightStyle", "highlightColor", "highlightSecondaryColor", "size", "centered", "views", "highlightAnimate", "animate", "highlightTypewriter", "highlightTypewriterDuration"];
15420
+ var _excluded$P = ["children", "highlightText", "highlightStyle", "highlightColor", "highlightSecondaryColor", "size", "centered", "views", "highlightAnimate", "animate", "highlightTypewriter", "highlightTypewriterDuration"];
14924
15421
  function escapeRegExp(string) {
14925
15422
  return string.replace(/[.*+?^${}()|[\\]\\/g, '\\$&');
14926
15423
  }
@@ -14939,7 +15436,7 @@ var TitleView = _ref => {
14939
15436
  highlightTypewriter: propHighlightTypewriter = false,
14940
15437
  highlightTypewriterDuration = 3000
14941
15438
  } = _ref,
14942
- props = _objectWithoutPropertiesLoose(_ref, _excluded$N);
15439
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$P);
14943
15440
  var {
14944
15441
  ref,
14945
15442
  inView
@@ -15110,7 +15607,7 @@ var useToggleState = defaultToggled => {
15110
15607
  };
15111
15608
  };
15112
15609
 
15113
- var _excluded$O = ["children", "shape", "variant", "isHovered", "setIsHovered", "isDisabled", "isToggle", "setIsToggled", "onToggle", "views"];
15610
+ var _excluded$Q = ["children", "shape", "variant", "isHovered", "setIsHovered", "isDisabled", "isToggle", "setIsToggled", "onToggle", "views"];
15114
15611
  var ToggleView = _ref => {
15115
15612
  var {
15116
15613
  children,
@@ -15124,7 +15621,7 @@ var ToggleView = _ref => {
15124
15621
  onToggle,
15125
15622
  views
15126
15623
  } = _ref,
15127
- props = _objectWithoutPropertiesLoose(_ref, _excluded$O);
15624
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$Q);
15128
15625
  var toggleColor = !isDisabled ? 'color.trueGray.400' : 'theme.disabled';
15129
15626
  var isActive = !!(isToggle || isHovered);
15130
15627
  var toggleVariants = {
@@ -15167,7 +15664,7 @@ var ToggleView = _ref => {
15167
15664
  }, toggleVariants[variant], props, views == null ? void 0 : views.container), children);
15168
15665
  };
15169
15666
 
15170
- var _excluded$P = ["children", "shape", "variant", "isDisabled", "isToggled", "onToggle"];
15667
+ var _excluded$R = ["children", "shape", "variant", "isDisabled", "isToggled", "onToggle"];
15171
15668
  // Destructuring properties from ToggleProps to be used within the ToggleComponent.
15172
15669
  var ToggleComponent = _ref => {
15173
15670
  var {
@@ -15179,7 +15676,7 @@ var ToggleComponent = _ref => {
15179
15676
  isToggled = false,
15180
15677
  onToggle
15181
15678
  } = _ref,
15182
- props = _objectWithoutPropertiesLoose(_ref, _excluded$P);
15679
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$R);
15183
15680
  // Initializing toggle state and set state functions using the custom hook useToggleState.
15184
15681
  var {
15185
15682
  isHovered,
@@ -15513,64 +16010,8 @@ var DropdownMenuItemStates = {
15513
16010
  cursor: 'not-allowed'
15514
16011
  }
15515
16012
  };
15516
- // Helper function to calculate position based on side and alignment
15517
- var getDropdownPosition = function getDropdownPosition(side, align) {
15518
- if (side === void 0) {
15519
- side = 'bottom';
15520
- }
15521
- if (align === void 0) {
15522
- align = 'start';
15523
- }
15524
- var positions = {
15525
- top: Object.assign({
15526
- bottom: '100%',
15527
- marginBottom: '8px'
15528
- }, align === 'start' && {
15529
- left: 0
15530
- }, align === 'center' && {
15531
- left: '50%',
15532
- transform: 'translateX(-50%)'
15533
- }, align === 'end' && {
15534
- right: 0
15535
- }),
15536
- right: Object.assign({
15537
- left: '100%',
15538
- marginLeft: '8px'
15539
- }, align === 'start' && {
15540
- top: 0
15541
- }, align === 'center' && {
15542
- top: '50%',
15543
- transform: 'translateY(-50%)'
15544
- }, align === 'end' && {
15545
- bottom: 0
15546
- }),
15547
- bottom: Object.assign({
15548
- top: '100%',
15549
- marginTop: '8px'
15550
- }, align === 'start' && {
15551
- left: 0
15552
- }, align === 'center' && {
15553
- left: '50%',
15554
- transform: 'translateX(-50%)'
15555
- }, align === 'end' && {
15556
- right: 0
15557
- }),
15558
- left: Object.assign({
15559
- right: '100%',
15560
- marginRight: '8px'
15561
- }, align === 'start' && {
15562
- top: 0
15563
- }, align === 'center' && {
15564
- top: '50%',
15565
- transform: 'translateY(-50%)'
15566
- }, align === 'end' && {
15567
- bottom: 0
15568
- })
15569
- };
15570
- return positions[side];
15571
- };
15572
16013
 
15573
- var _excluded$Q = ["children", "views"],
16014
+ var _excluded$S = ["children", "views"],
15574
16015
  _excluded2$d = ["items", "side", "align", "views"],
15575
16016
  _excluded3$9 = ["item", "views"],
15576
16017
  _excluded4$8 = ["views"],
@@ -15582,7 +16023,10 @@ var DropdownMenuContext = /*#__PURE__*/createContext({
15582
16023
  activeSubmenuId: null,
15583
16024
  setActiveSubmenuId: () => {},
15584
16025
  size: 'md',
15585
- variant: 'default'
16026
+ variant: 'default',
16027
+ triggerRef: {
16028
+ current: null
16029
+ }
15586
16030
  });
15587
16031
  // Provider component for the DropdownMenu context
15588
16032
  var DropdownMenuProvider = _ref => {
@@ -15608,16 +16052,18 @@ var DropdownMenuTrigger = _ref2 => {
15608
16052
  children,
15609
16053
  views
15610
16054
  } = _ref2,
15611
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$Q);
16055
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$S);
15612
16056
  var {
15613
16057
  isOpen,
15614
- setIsOpen
16058
+ setIsOpen,
16059
+ triggerRef
15615
16060
  } = useDropdownMenuContext();
15616
16061
  var handleClick = e => {
15617
16062
  e.stopPropagation();
15618
16063
  setIsOpen(!isOpen);
15619
16064
  };
15620
16065
  return /*#__PURE__*/React.createElement(View, Object.assign({
16066
+ ref: triggerRef,
15621
16067
  id: "dropdown-trigger",
15622
16068
  onClick: handleClick,
15623
16069
  cursor: "pointer",
@@ -15636,20 +16082,121 @@ var DropdownMenuContent = _ref3 => {
15636
16082
  props = _objectWithoutPropertiesLoose(_ref3, _excluded2$d);
15637
16083
  var {
15638
16084
  isOpen,
15639
- //activeSubmenuId, setActiveSubmenuId, size,
15640
- variant
16085
+ variant,
16086
+ triggerRef
15641
16087
  } = useDropdownMenuContext();
16088
+ var contentRef = useRef(null);
16089
+ var [optimalPosition, setOptimalPosition] = useState({
16090
+ x: 0,
16091
+ y: 0,
16092
+ placement: side
16093
+ });
16094
+ // Calculate optimal position when the dropdown opens
16095
+ useEffect(() => {
16096
+ if (isOpen && contentRef.current && triggerRef.current) {
16097
+ var contentRect = contentRef.current.getBoundingClientRect();
16098
+ var triggerRect = triggerRef.current.getBoundingClientRect();
16099
+ // Get content dimensions
16100
+ var contentWidth = Math.max(contentRect.width || 180, 180);
16101
+ var contentHeight = Math.max(contentRect.height || 100, 100);
16102
+ // Get viewport dimensions
16103
+ var viewportWidth = window.innerWidth;
16104
+ var viewportHeight = window.innerHeight;
16105
+ // Calculate available space on all sides from the trigger
16106
+ var availableSpace = {
16107
+ top: triggerRect.top,
16108
+ right: viewportWidth - triggerRect.right,
16109
+ bottom: viewportHeight - triggerRect.bottom,
16110
+ left: triggerRect.left
16111
+ };
16112
+ // Determine optimal placement based on available space and preferred side
16113
+ var placements = [{
16114
+ placement: 'bottom',
16115
+ space: availableSpace.bottom,
16116
+ fits: availableSpace.bottom >= contentHeight + 8,
16117
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
16118
+ y: triggerRect.bottom + 8
16119
+ }, {
16120
+ placement: 'top',
16121
+ space: availableSpace.top,
16122
+ fits: availableSpace.top >= contentHeight + 8,
16123
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
16124
+ y: triggerRect.top - contentHeight - 8
16125
+ }, {
16126
+ placement: 'right',
16127
+ space: availableSpace.right,
16128
+ fits: availableSpace.right >= contentWidth + 8,
16129
+ x: triggerRect.right + 8,
16130
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
16131
+ }, {
16132
+ placement: 'left',
16133
+ space: availableSpace.left,
16134
+ fits: availableSpace.left >= contentWidth + 8,
16135
+ x: triggerRect.left - contentWidth - 8,
16136
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
16137
+ }];
16138
+ // First try the preferred side if it fits
16139
+ var preferredPlacement = placements.find(p => p.placement === side && p.fits);
16140
+ if (preferredPlacement) {
16141
+ setOptimalPosition({
16142
+ x: preferredPlacement.x,
16143
+ y: preferredPlacement.y,
16144
+ placement: preferredPlacement.placement
16145
+ });
16146
+ return;
16147
+ }
16148
+ // Otherwise, find the best fitting placement
16149
+ var fittingPlacement = placements.find(p => p.fits);
16150
+ if (fittingPlacement) {
16151
+ setOptimalPosition({
16152
+ x: fittingPlacement.x,
16153
+ y: fittingPlacement.y,
16154
+ placement: fittingPlacement.placement
16155
+ });
16156
+ return;
16157
+ }
16158
+ // If nothing fits, choose the placement with the most space
16159
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
16160
+ // Ensure the content stays within viewport bounds
16161
+ var finalX = bestPlacement.x;
16162
+ var finalY = bestPlacement.y;
16163
+ if (finalX + contentWidth > viewportWidth) {
16164
+ finalX = viewportWidth - contentWidth - 8;
16165
+ }
16166
+ if (finalX < 8) {
16167
+ finalX = 8;
16168
+ }
16169
+ if (finalY + contentHeight > viewportHeight) {
16170
+ finalY = viewportHeight - contentHeight - 8;
16171
+ }
16172
+ if (finalY < 8) {
16173
+ finalY = 8;
16174
+ }
16175
+ setOptimalPosition({
16176
+ x: finalX,
16177
+ y: finalY,
16178
+ placement: bestPlacement.placement
16179
+ });
16180
+ }
16181
+ }, [isOpen, side, align, triggerRef]);
15642
16182
  if (!isOpen) {
15643
16183
  return null;
15644
16184
  }
16185
+ // Create intelligent positioning styles
16186
+ var positionStyles = {
16187
+ position: 'fixed',
16188
+ left: optimalPosition.x,
16189
+ top: optimalPosition.y,
16190
+ zIndex: 1000
16191
+ };
15645
16192
  return /*#__PURE__*/React.createElement(View, Object.assign({
16193
+ ref: contentRef,
15646
16194
  id: "dropdown-menu",
15647
- position: "absolute",
15648
- zIndex: 1000,
15649
16195
  borderRadius: 4,
15650
16196
  boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)",
15651
- overflow: "hidden"
15652
- }, getDropdownPosition(side, align), DropdownMenuVariants[variant], views == null ? void 0 : views.menu, props), items.map((item, index) => {
16197
+ overflow: "hidden",
16198
+ style: positionStyles
16199
+ }, DropdownMenuVariants[variant], views == null ? void 0 : views.menu, props), items.map((item, index) => {
15653
16200
  if (item.divider) {
15654
16201
  return /*#__PURE__*/React.createElement(DropdownMenuDivider, {
15655
16202
  key: "divider-" + index,
@@ -15661,7 +16208,13 @@ var DropdownMenuContent = _ref3 => {
15661
16208
  item: item,
15662
16209
  views: views
15663
16210
  });
15664
- }));
16211
+ }), process.env.NODE_ENV === 'development' && (/*#__PURE__*/React.createElement("div", {
16212
+ style: {
16213
+ fontSize: '10px',
16214
+ opacity: 0.7,
16215
+ padding: '4px'
16216
+ }
16217
+ }, "Placement: ", optimalPosition.placement)));
15665
16218
  };
15666
16219
  // DropdownMenu Item component
15667
16220
  var DropdownMenuItem = _ref4 => {
@@ -15764,7 +16317,7 @@ var DropdownMenuView = _ref6 => {
15764
16317
  }));
15765
16318
  };
15766
16319
 
15767
- var _excluded$R = ["trigger", "items", "size", "variant", "side", "align", "defaultOpen", "views"];
16320
+ var _excluded$T = ["trigger", "items", "size", "variant", "side", "align", "defaultOpen", "views"];
15768
16321
  /**
15769
16322
  * DropdownMenu component for displaying a menu when clicking on a trigger element.
15770
16323
  */
@@ -15779,13 +16332,14 @@ var DropdownMenuComponent = _ref => {
15779
16332
  defaultOpen = false,
15780
16333
  views
15781
16334
  } = _ref,
15782
- props = _objectWithoutPropertiesLoose(_ref, _excluded$R);
16335
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$T);
15783
16336
  var {
15784
16337
  isOpen,
15785
16338
  setIsOpen,
15786
16339
  activeSubmenuId,
15787
16340
  setActiveSubmenuId
15788
16341
  } = useDropdownMenuState(defaultOpen);
16342
+ var triggerRef = useRef(null);
15789
16343
  return /*#__PURE__*/React.createElement(DropdownMenuProvider, {
15790
16344
  value: {
15791
16345
  isOpen,
@@ -15793,7 +16347,8 @@ var DropdownMenuComponent = _ref => {
15793
16347
  activeSubmenuId,
15794
16348
  setActiveSubmenuId,
15795
16349
  size,
15796
- variant
16350
+ variant,
16351
+ triggerRef
15797
16352
  }
15798
16353
  }, /*#__PURE__*/React.createElement(DropdownMenuView, Object.assign({
15799
16354
  trigger: trigger,
@@ -16191,7 +16746,7 @@ var DefaultColorPalette$1 = [
16191
16746
  category: 'neutral'
16192
16747
  }];
16193
16748
 
16194
- var _excluded$S = ["id", "name", "label", "placeholder", "helperText", "views", "size", "shape", "variant", "error", "isDisabled", "isReadOnly", "predefinedColors", "showCustomInput", "showRecentColors", "isOpen", "selectedColor", "recentColors", "customColor", "handleToggle", "handleColorSelect", "handleCustomColorChange", "handleCustomColorSubmit", "triggerRef", "dropdownRef"];
16749
+ var _excluded$U = ["id", "name", "label", "placeholder", "helperText", "views", "size", "shape", "variant", "error", "isDisabled", "isReadOnly", "predefinedColors", "showCustomInput", "showRecentColors", "isOpen", "selectedColor", "recentColors", "customColor", "handleToggle", "handleColorSelect", "handleCustomColorChange", "handleCustomColorSubmit", "triggerRef", "dropdownRef"];
16195
16750
  var ColorPickerView = _ref => {
16196
16751
  var {
16197
16752
  // Basic props
@@ -16226,7 +16781,7 @@ var ColorPickerView = _ref => {
16226
16781
  dropdownRef
16227
16782
  // Other props
16228
16783
  } = _ref,
16229
- props = _objectWithoutPropertiesLoose(_ref, _excluded$S);
16784
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$U);
16230
16785
  var {
16231
16786
  getColor
16232
16787
  } = useTheme();
@@ -18556,7 +19111,7 @@ var useEmojiPickerState = props => {
18556
19111
  };
18557
19112
  };
18558
19113
 
18559
- var _excluded$T = ["id", "name", "label", "placeholder", "helperText", "views", "size", "shape", "variant", "error", "isDisabled", "isReadOnly", "showSearch", "showCategories", "showRecentEmojis", "enabledCategories", "isOpen", "selectedEmoji", "recentEmojis", "searchQuery", "activeCategory", "filteredEmojis", "handleToggle", "handleEmojiSelect", "handleSearchChange", "handleCategoryChange", "triggerRef", "dropdownRef"];
19114
+ var _excluded$V = ["id", "name", "label", "placeholder", "helperText", "views", "size", "shape", "variant", "error", "isDisabled", "isReadOnly", "showSearch", "showCategories", "showRecentEmojis", "enabledCategories", "isOpen", "selectedEmoji", "recentEmojis", "searchQuery", "activeCategory", "filteredEmojis", "handleToggle", "handleEmojiSelect", "handleSearchChange", "handleCategoryChange", "triggerRef", "dropdownRef"];
18560
19115
  var EmojiPickerView = _ref => {
18561
19116
  var {
18562
19117
  // Basic props
@@ -18594,7 +19149,7 @@ var EmojiPickerView = _ref => {
18594
19149
  dropdownRef
18595
19150
  // Other props
18596
19151
  } = _ref,
18597
- props = _objectWithoutPropertiesLoose(_ref, _excluded$T);
19152
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$V);
18598
19153
  var {
18599
19154
  getColor
18600
19155
  } = useTheme();
@@ -18746,109 +19301,7 @@ var useHoverCardState = function useHoverCardState(_temp) {
18746
19301
  };
18747
19302
  };
18748
19303
 
18749
- // More advanced positioning using element measurements
18750
- var getContentPositionStyles = function getContentPositionStyles(triggerRect, side, align, sideOffset) {
18751
- if (side === void 0) {
18752
- side = 'bottom';
18753
- }
18754
- if (align === void 0) {
18755
- align = 'center';
18756
- }
18757
- if (sideOffset === void 0) {
18758
- sideOffset = 8;
18759
- }
18760
- if (!triggerRect) {
18761
- return {
18762
- position: 'absolute',
18763
- opacity: 0,
18764
- pointerEvents: 'none'
18765
- }; // Hide if trigger isn't measured
18766
- }
18767
- var styles = {
18768
- position: 'absolute',
18769
- zIndex: 1000
18770
- };
18771
- // Calculate position based on side and alignment
18772
- switch (side) {
18773
- case 'top':
18774
- styles.bottom = '100%';
18775
- styles.marginBottom = sideOffset;
18776
- if (align === 'start') {
18777
- styles.left = 0;
18778
- } else if (align === 'center') {
18779
- styles.left = '50%';
18780
- styles.transform = 'translateX(-50%)';
18781
- } else if (align === 'end') {
18782
- styles.right = 0;
18783
- }
18784
- break;
18785
- case 'right':
18786
- styles.left = '100%';
18787
- styles.marginLeft = sideOffset;
18788
- if (align === 'start') {
18789
- styles.top = 0;
18790
- } else if (align === 'center') {
18791
- styles.top = '50%';
18792
- styles.transform = 'translateY(-50%)';
18793
- } else if (align === 'end') {
18794
- styles.bottom = 0;
18795
- }
18796
- break;
18797
- case 'bottom':
18798
- styles.top = '100%';
18799
- styles.marginTop = sideOffset;
18800
- if (align === 'start') {
18801
- styles.left = 0;
18802
- } else if (align === 'center') {
18803
- styles.left = '50%';
18804
- styles.transform = 'translateX(-50%)';
18805
- } else if (align === 'end') {
18806
- styles.right = 0;
18807
- }
18808
- break;
18809
- case 'left':
18810
- styles.right = '100%';
18811
- styles.marginRight = sideOffset;
18812
- if (align === 'start') {
18813
- styles.top = 0;
18814
- } else if (align === 'center') {
18815
- styles.top = '50%';
18816
- styles.transform = 'translateY(-50%)';
18817
- } else if (align === 'end') {
18818
- styles.bottom = 0;
18819
- }
18820
- break;
18821
- }
18822
- return styles;
18823
- };
18824
-
18825
- /**
18826
- * A hook that returns the DOMRect of an element.
18827
- * @param ref React ref object for the element to measure
18828
- * @returns DOMRect of the element or null if the element is not available
18829
- */
18830
- var useRect = ref => {
18831
- var [rect, setRect] = useState(null);
18832
- var updateRect = useCallback(() => {
18833
- if (ref.current) {
18834
- setRect(ref.current.getBoundingClientRect());
18835
- }
18836
- }, [ref]);
18837
- useLayoutEffect(() => {
18838
- if (!ref.current) return;
18839
- updateRect();
18840
- // Update on resize and scroll
18841
- window.addEventListener('resize', updateRect);
18842
- window.addEventListener('scroll', updateRect);
18843
- return () => {
18844
- window.removeEventListener('resize', updateRect);
18845
- window.removeEventListener('scroll', updateRect);
18846
- };
18847
- }, [ref, updateRect]);
18848
- return rect;
18849
- };
18850
-
18851
- var _excluded$U = ["children", "views", "asChild"],
19304
+ var _excluded$W = ["children", "views", "asChild"],
18852
19305
  _excluded2$e = ["children", "views", "side", "align", "sideOffset", "style", "backgroundColor", "borderRadius", "boxShadow", "padding", "minWidth", "maxWidth"];
18853
19306
  // Create context for the HoverCard
18854
19307
  var HoverCardContext = /*#__PURE__*/createContext({
@@ -18887,7 +19340,7 @@ var HoverCardTrigger = _ref2 => {
18887
19340
  views,
18888
19341
  asChild = false
18889
19342
  } = _ref2,
18890
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$U);
19343
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$W);
18891
19344
  var {
18892
19345
  openCard,
18893
19346
  closeCard,
@@ -18945,15 +19398,111 @@ var HoverCardContent = _ref3 => {
18945
19398
  contentId,
18946
19399
  triggerId
18947
19400
  } = useHoverCardContext();
18948
- // Use hook to measure trigger for positioning
18949
- var triggerRect = useRect(triggerRef);
18950
- // Calculate position based on trigger dimensions and side prop
18951
- var positionStyles = getContentPositionStyles(triggerRect, side, align, sideOffset);
19401
+ var [optimalPosition, setOptimalPosition] = useState({
19402
+ x: 0,
19403
+ y: 0,
19404
+ placement: side
19405
+ });
19406
+ // Calculate optimal position when the card opens or content dimensions change
19407
+ useEffect(() => {
19408
+ if (isOpen && contentRef != null && contentRef.current && triggerRef != null && triggerRef.current) {
19409
+ var contentRect = contentRef.current.getBoundingClientRect();
19410
+ var triggerRect = triggerRef.current.getBoundingClientRect();
19411
+ // Get content dimensions
19412
+ var contentWidth = Math.max(contentRect.width || 200, 200);
19413
+ var contentHeight = Math.max(contentRect.height || 100, 100);
19414
+ // Get viewport dimensions
19415
+ var viewportWidth = window.innerWidth;
19416
+ var viewportHeight = window.innerHeight;
19417
+ // Calculate available space on all sides from the trigger
19418
+ var availableSpace = {
19419
+ top: triggerRect.top,
19420
+ right: viewportWidth - triggerRect.right,
19421
+ bottom: viewportHeight - triggerRect.bottom,
19422
+ left: triggerRect.left
19423
+ };
19424
+ // Determine optimal placement based on available space and preferred side
19425
+ var placements = [{
19426
+ placement: 'bottom',
19427
+ space: availableSpace.bottom,
19428
+ fits: availableSpace.bottom >= contentHeight + sideOffset,
19429
+ x: triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
19430
+ y: triggerRect.bottom + sideOffset
19431
+ }, {
19432
+ placement: 'top',
19433
+ space: availableSpace.top,
19434
+ fits: availableSpace.top >= contentHeight + sideOffset,
19435
+ x: triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
19436
+ y: triggerRect.top - contentHeight - sideOffset
19437
+ }, {
19438
+ placement: 'right',
19439
+ space: availableSpace.right,
19440
+ fits: availableSpace.right >= contentWidth + sideOffset,
19441
+ x: triggerRect.right + sideOffset,
19442
+ y: triggerRect.top + triggerRect.height / 2 - contentHeight / 2
19443
+ }, {
19444
+ placement: 'left',
19445
+ space: availableSpace.left,
19446
+ fits: availableSpace.left >= contentWidth + sideOffset,
19447
+ x: triggerRect.left - contentWidth - sideOffset,
19448
+ y: triggerRect.top + triggerRect.height / 2 - contentHeight / 2
19449
+ }];
19450
+ // First try the preferred side if it fits
19451
+ var preferredPlacement = placements.find(p => p.placement === side && p.fits);
19452
+ if (preferredPlacement) {
19453
+ setOptimalPosition({
19454
+ x: preferredPlacement.x,
19455
+ y: preferredPlacement.y,
19456
+ placement: preferredPlacement.placement
19457
+ });
19458
+ return;
19459
+ }
19460
+ // Otherwise, find the best fitting placement
19461
+ var fittingPlacement = placements.find(p => p.fits);
19462
+ if (fittingPlacement) {
19463
+ setOptimalPosition({
19464
+ x: fittingPlacement.x,
19465
+ y: fittingPlacement.y,
19466
+ placement: fittingPlacement.placement
19467
+ });
19468
+ return;
19469
+ }
19470
+ // If nothing fits, choose the placement with the most space
19471
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
19472
+ // Ensure the content stays within viewport bounds
19473
+ var finalX = bestPlacement.x;
19474
+ var finalY = bestPlacement.y;
19475
+ if (finalX + contentWidth > viewportWidth) {
19476
+ finalX = viewportWidth - contentWidth - 8;
19477
+ }
19478
+ if (finalX < 8) {
19479
+ finalX = 8;
19480
+ }
19481
+ if (finalY + contentHeight > viewportHeight) {
19482
+ finalY = viewportHeight - contentHeight - 8;
19483
+ }
19484
+ if (finalY < 8) {
19485
+ finalY = 8;
19486
+ }
19487
+ setOptimalPosition({
19488
+ x: finalX,
19489
+ y: finalY,
19490
+ placement: bestPlacement.placement
19491
+ });
19492
+ }
19493
+ }, [isOpen, side, sideOffset, contentRef, triggerRef]);
18952
19494
  var handleMouseEnter = () => cancelCloseTimer(); // Keep card open if mouse enters content
18953
19495
  var handleMouseLeave = () => closeCard();
18954
19496
  if (!isOpen) {
18955
19497
  return null; // Don't render content if not open
18956
19498
  }
19499
+ // Create intelligent positioning styles
19500
+ var positionStyles = {
19501
+ position: 'fixed',
19502
+ left: optimalPosition.x,
19503
+ top: optimalPosition.y,
19504
+ zIndex: 1000
19505
+ };
18957
19506
  return /*#__PURE__*/React.createElement(View, Object.assign({
18958
19507
  ref: contentRef,
18959
19508
  id: contentId,
@@ -18968,13 +19517,18 @@ var HoverCardContent = _ref3 => {
18968
19517
  padding: padding,
18969
19518
  minWidth: minWidth,
18970
19519
  maxWidth: maxWidth,
18971
- zIndex: 1000,
18972
- // Combine calculated position styles with user styles
19520
+ // Combine intelligent position styles with user styles
18973
19521
  style: Object.assign({}, positionStyles, userStyle)
18974
- }, views == null ? void 0 : views.container, props), children);
19522
+ }, views == null ? void 0 : views.container, props), children, process.env.NODE_ENV === 'development' && (/*#__PURE__*/React.createElement("div", {
19523
+ style: {
19524
+ fontSize: '10px',
19525
+ opacity: 0.7,
19526
+ marginTop: '4px'
19527
+ }
19528
+ }, "Placement: ", optimalPosition.placement)));
18975
19529
  };
18976
19530
 
18977
- var _excluded$V = ["children", "views", "openDelay", "closeDelay"];
19531
+ var _excluded$X = ["children", "views", "openDelay", "closeDelay"];
18978
19532
  /**
18979
19533
  * HoverCard component displays floating content when hovering over a trigger element.
18980
19534
  * Supports configurable open and close delays for a smoother user experience.
@@ -18986,7 +19540,7 @@ var HoverCardComponent = _ref => {
18986
19540
  openDelay,
18987
19541
  closeDelay
18988
19542
  } = _ref,
18989
- props = _objectWithoutPropertiesLoose(_ref, _excluded$V);
19543
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$X);
18990
19544
  var hoverCardState = useHoverCardState({
18991
19545
  openDelay,
18992
19546
  closeDelay
@@ -19103,20 +19657,8 @@ var MenubarItemStates = {
19103
19657
  cursor: 'not-allowed'
19104
19658
  }
19105
19659
  };
19106
- var getMenubarContentPosition = orientation => {
19107
- if (orientation === 'horizontal') {
19108
- return {
19109
- top: '100%',
19110
- left: 0
19111
- };
19112
- }
19113
- return {
19114
- top: 0,
19115
- left: '100%'
19116
- };
19117
- };
19118
19660
 
19119
- var _excluded$W = ["children", "orientation", "size", "variant", "views"];
19661
+ var _excluded$Y = ["children", "orientation", "size", "variant", "views"];
19120
19662
  // Create context for the Menubar
19121
19663
  var MenubarContext = /*#__PURE__*/createContext({
19122
19664
  activeMenuId: null,
@@ -19127,7 +19669,10 @@ var MenubarContext = /*#__PURE__*/createContext({
19127
19669
  toggleMenu: () => {},
19128
19670
  orientation: 'horizontal',
19129
19671
  size: 'md',
19130
- variant: 'default'
19672
+ variant: 'default',
19673
+ triggerRefs: {
19674
+ current: {}
19675
+ }
19131
19676
  });
19132
19677
  // Hook to use the Menubar context
19133
19678
  var useMenubarContext = () => useContext(MenubarContext);
@@ -19150,7 +19695,7 @@ var MenubarRoot = _ref2 => {
19150
19695
  variant = 'default',
19151
19696
  views
19152
19697
  } = _ref2,
19153
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$W);
19698
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$Y);
19154
19699
  var Container = orientation === 'horizontal' ? Horizontal : Vertical;
19155
19700
  return /*#__PURE__*/React.createElement(Container, Object.assign({
19156
19701
  role: "menubar",
@@ -19197,16 +19742,30 @@ var MenubarTrigger = _ref4 => {
19197
19742
  setActiveMenuId,
19198
19743
  toggleMenu,
19199
19744
  isMenuOpen,
19200
- size
19745
+ size,
19746
+ triggerRefs
19201
19747
  } = useMenubarContext();
19748
+ var triggerRef = useRef(null);
19202
19749
  var isActive = activeMenuId === menuId;
19203
19750
  var isOpen = isMenuOpen(menuId);
19751
+ // Store the trigger ref in the context
19752
+ useEffect(() => {
19753
+ if (triggerRef.current && menuId) {
19754
+ triggerRefs.current[menuId] = triggerRef.current;
19755
+ }
19756
+ return () => {
19757
+ if (menuId) {
19758
+ delete triggerRefs.current[menuId];
19759
+ }
19760
+ };
19761
+ }, [menuId, triggerRefs]);
19204
19762
  var handleClick = () => {
19205
19763
  if (disabled) return;
19206
19764
  setActiveMenuId(menuId);
19207
19765
  toggleMenu(menuId);
19208
19766
  };
19209
19767
  return /*#__PURE__*/React.createElement(View, Object.assign({
19768
+ ref: triggerRef,
19210
19769
  id: "menubar-trigger",
19211
19770
  role: "menuitem",
19212
19771
  "aria-haspopup": "true",
@@ -19229,23 +19788,149 @@ var MenubarContent = _ref5 => {
19229
19788
  } = _ref5;
19230
19789
  var {
19231
19790
  isMenuOpen,
19232
- orientation
19791
+ orientation,
19792
+ triggerRefs
19233
19793
  } = useMenubarContext();
19794
+ var contentRef = useRef(null);
19795
+ var [optimalPosition, setOptimalPosition] = useState({
19796
+ x: 0,
19797
+ y: 0,
19798
+ placement: orientation === 'horizontal' ? 'bottom' : 'right'
19799
+ });
19234
19800
  var isOpen = isMenuOpen(menuId);
19801
+ // Calculate optimal position when the menu opens
19802
+ useEffect(() => {
19803
+ if (isOpen && contentRef.current && menuId && triggerRefs.current[menuId]) {
19804
+ var contentRect = contentRef.current.getBoundingClientRect();
19805
+ var triggerRect = triggerRefs.current[menuId].getBoundingClientRect();
19806
+ // Get content dimensions
19807
+ var contentWidth = Math.max(contentRect.width || 200, 200);
19808
+ var contentHeight = Math.max(contentRect.height || 150, 150);
19809
+ // Get viewport dimensions
19810
+ var viewportWidth = window.innerWidth;
19811
+ var viewportHeight = window.innerHeight;
19812
+ // Calculate available space on all sides from the trigger
19813
+ var availableSpace = {
19814
+ top: triggerRect.top,
19815
+ right: viewportWidth - triggerRect.right,
19816
+ bottom: viewportHeight - triggerRect.bottom,
19817
+ left: triggerRect.left
19818
+ };
19819
+ // Determine optimal placement based on orientation and available space
19820
+ var placements = orientation === 'horizontal' ? [
19821
+ // For horizontal menubar, prefer bottom placement
19822
+ {
19823
+ placement: 'bottom',
19824
+ space: availableSpace.bottom,
19825
+ fits: availableSpace.bottom >= contentHeight + 8,
19826
+ x: triggerRect.left,
19827
+ y: triggerRect.bottom + 8
19828
+ }, {
19829
+ placement: 'top',
19830
+ space: availableSpace.top,
19831
+ fits: availableSpace.top >= contentHeight + 8,
19832
+ x: triggerRect.left,
19833
+ y: triggerRect.top - contentHeight - 8
19834
+ }, {
19835
+ placement: 'right',
19836
+ space: availableSpace.right,
19837
+ fits: availableSpace.right >= contentWidth + 8,
19838
+ x: triggerRect.right + 8,
19839
+ y: triggerRect.top
19840
+ }, {
19841
+ placement: 'left',
19842
+ space: availableSpace.left,
19843
+ fits: availableSpace.left >= contentWidth + 8,
19844
+ x: triggerRect.left - contentWidth - 8,
19845
+ y: triggerRect.top
19846
+ }] : [
19847
+ // For vertical menubar, prefer right placement
19848
+ {
19849
+ placement: 'right',
19850
+ space: availableSpace.right,
19851
+ fits: availableSpace.right >= contentWidth + 8,
19852
+ x: triggerRect.right + 8,
19853
+ y: triggerRect.top
19854
+ }, {
19855
+ placement: 'left',
19856
+ space: availableSpace.left,
19857
+ fits: availableSpace.left >= contentWidth + 8,
19858
+ x: triggerRect.left - contentWidth - 8,
19859
+ y: triggerRect.top
19860
+ }, {
19861
+ placement: 'bottom',
19862
+ space: availableSpace.bottom,
19863
+ fits: availableSpace.bottom >= contentHeight + 8,
19864
+ x: triggerRect.left,
19865
+ y: triggerRect.bottom + 8
19866
+ }, {
19867
+ placement: 'top',
19868
+ space: availableSpace.top,
19869
+ fits: availableSpace.top >= contentHeight + 8,
19870
+ x: triggerRect.left,
19871
+ y: triggerRect.top - contentHeight - 8
19872
+ }];
19873
+ // Find the best fitting placement
19874
+ var fittingPlacement = placements.find(p => p.fits);
19875
+ if (fittingPlacement) {
19876
+ setOptimalPosition({
19877
+ x: fittingPlacement.x,
19878
+ y: fittingPlacement.y,
19879
+ placement: fittingPlacement.placement
19880
+ });
19881
+ return;
19882
+ }
19883
+ // If nothing fits, choose the placement with the most space
19884
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
19885
+ // Ensure the content stays within viewport bounds
19886
+ var finalX = bestPlacement.x;
19887
+ var finalY = bestPlacement.y;
19888
+ if (finalX + contentWidth > viewportWidth) {
19889
+ finalX = viewportWidth - contentWidth - 8;
19890
+ }
19891
+ if (finalX < 8) {
19892
+ finalX = 8;
19893
+ }
19894
+ if (finalY + contentHeight > viewportHeight) {
19895
+ finalY = viewportHeight - contentHeight - 8;
19896
+ }
19897
+ if (finalY < 8) {
19898
+ finalY = 8;
19899
+ }
19900
+ setOptimalPosition({
19901
+ x: finalX,
19902
+ y: finalY,
19903
+ placement: bestPlacement.placement
19904
+ });
19905
+ }
19906
+ }, [isOpen, orientation, menuId, triggerRefs]);
19235
19907
  if (!isOpen) {
19236
19908
  return null;
19237
19909
  }
19910
+ // Create intelligent positioning styles
19911
+ var positionStyles = {
19912
+ position: 'fixed',
19913
+ left: optimalPosition.x,
19914
+ top: optimalPosition.y,
19915
+ zIndex: 1000
19916
+ };
19238
19917
  return /*#__PURE__*/React.createElement(View, Object.assign({
19918
+ ref: contentRef,
19239
19919
  id: "menubar-content",
19240
19920
  role: "menu",
19241
- position: "absolute",
19242
- zIndex: 1000,
19243
19921
  minWidth: "200px",
19244
19922
  backgroundColor: "color.white",
19245
19923
  borderRadius: 4,
19246
19924
  boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)",
19247
- overflow: "hidden"
19248
- }, getMenubarContentPosition(orientation), views == null ? void 0 : views.content), children);
19925
+ overflow: "hidden",
19926
+ style: positionStyles
19927
+ }, views == null ? void 0 : views.content), children, process.env.NODE_ENV === 'development' && (/*#__PURE__*/React.createElement("div", {
19928
+ style: {
19929
+ fontSize: '8px',
19930
+ opacity: 0.7,
19931
+ padding: '4px'
19932
+ }
19933
+ }, "Placement: ", optimalPosition.placement)));
19249
19934
  };
19250
19935
  // Menubar Item component
19251
19936
  var MenubarItem = _ref6 => {
@@ -19336,7 +20021,7 @@ var MenubarView = _ref8 => {
19336
20021
  })))))));
19337
20022
  };
19338
20023
 
19339
- var _excluded$X = ["items", "orientation", "size", "variant", "defaultActiveMenuId", "defaultOpenMenuId", "views"];
20024
+ var _excluded$Z = ["items", "orientation", "size", "variant", "defaultActiveMenuId", "defaultOpenMenuId", "views"];
19340
20025
  /**
19341
20026
  * Menubar component for creating horizontal or vertical menu bars with dropdown menus.
19342
20027
  */
@@ -19350,7 +20035,7 @@ var MenubarComponent = _ref => {
19350
20035
  defaultOpenMenuId = null,
19351
20036
  views
19352
20037
  } = _ref,
19353
- props = _objectWithoutPropertiesLoose(_ref, _excluded$X);
20038
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$Z);
19354
20039
  var {
19355
20040
  activeMenuId,
19356
20041
  setActiveMenuId,
@@ -19359,6 +20044,7 @@ var MenubarComponent = _ref => {
19359
20044
  isMenuOpen,
19360
20045
  toggleMenu
19361
20046
  } = useMenubarState(defaultActiveMenuId, defaultOpenMenuId);
20047
+ var triggerRefs = useRef({});
19362
20048
  return /*#__PURE__*/React.createElement(MenubarProvider, {
19363
20049
  value: {
19364
20050
  activeMenuId,
@@ -19369,7 +20055,8 @@ var MenubarComponent = _ref => {
19369
20055
  toggleMenu,
19370
20056
  orientation,
19371
20057
  size,
19372
- variant
20058
+ variant,
20059
+ triggerRefs
19373
20060
  }
19374
20061
  }, /*#__PURE__*/React.createElement(MenubarView, Object.assign({
19375
20062
  items: items,
@@ -19506,7 +20193,7 @@ var DisabledButtonStyles = {
19506
20193
  }
19507
20194
  };
19508
20195
 
19509
- var _excluded$Y = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "visiblePageNumbers", "views"];
20196
+ var _excluded$_ = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "visiblePageNumbers", "views"];
19510
20197
  var PaginationView = _ref => {
19511
20198
  var {
19512
20199
  currentPage,
@@ -19537,7 +20224,7 @@ var PaginationView = _ref => {
19537
20224
  visiblePageNumbers,
19538
20225
  views
19539
20226
  } = _ref,
19540
- props = _objectWithoutPropertiesLoose(_ref, _excluded$Y);
20227
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$_);
19541
20228
  var handlePageChange = page => {
19542
20229
  if (page < 1 || page > totalPages || page === currentPage) {
19543
20230
  return;
@@ -19656,7 +20343,7 @@ var PaginationView = _ref => {
19656
20343
  }, option.label))))));
19657
20344
  };
19658
20345
 
19659
- var _excluded$Z = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "views"];
20346
+ var _excluded$$ = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "views"];
19660
20347
  /**
19661
20348
  * Pagination component for navigating through pages of content.
19662
20349
  */
@@ -19677,7 +20364,7 @@ var PaginationComponent = _ref => {
19677
20364
  shape = 'rounded',
19678
20365
  views
19679
20366
  } = _ref,
19680
- props = _objectWithoutPropertiesLoose(_ref, _excluded$Z);
20367
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$$);
19681
20368
  var {
19682
20369
  visiblePageNumbers
19683
20370
  } = usePaginationState(currentPage, totalPages, maxPageButtons);
@@ -19747,7 +20434,7 @@ var DefaultSeparatorStyles = {
19747
20434
  }
19748
20435
  };
19749
20436
 
19750
- var _excluded$_ = ["orientation", "variant", "thickness", "color", "spacing", "label", "decorative", "views", "themeMode"];
20437
+ var _excluded$10 = ["orientation", "variant", "thickness", "color", "spacing", "label", "decorative", "views", "themeMode"];
19751
20438
  var SeparatorView = _ref => {
19752
20439
  var {
19753
20440
  orientation = 'horizontal',
@@ -19759,7 +20446,7 @@ var SeparatorView = _ref => {
19759
20446
  decorative = false,
19760
20447
  views
19761
20448
  } = _ref,
19762
- props = _objectWithoutPropertiesLoose(_ref, _excluded$_);
20449
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$10);
19763
20450
  // Access theme if needed for future enhancements
19764
20451
  var {
19765
20452
  themeMode
@@ -19997,7 +20684,7 @@ var SidebarTransitions = {
19997
20684
  bounce: 'width 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55), transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55)'
19998
20685
  };
19999
20686
 
20000
- var _excluded$$ = ["children", "showToggleButton", "views"],
20687
+ var _excluded$11 = ["children", "showToggleButton", "views"],
20001
20688
  _excluded2$f = ["children", "views"],
20002
20689
  _excluded3$a = ["children", "views"],
20003
20690
  _excluded4$9 = ["children", "position", "size", "variant", "fixed", "hasBackdrop", "expandedWidth", "collapsedWidth", "breakpointBehavior", "elevation", "transitionPreset", "ariaLabel", "isExpanded", "isMobile", "collapse", "views", "themeMode"];
@@ -20030,7 +20717,7 @@ var SidebarHeader = _ref2 => {
20030
20717
  showToggleButton = true,
20031
20718
  views
20032
20719
  } = _ref2,
20033
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$$);
20720
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$11);
20034
20721
  var {
20035
20722
  isExpanded,
20036
20723
  toggleExpanded,
@@ -20185,7 +20872,7 @@ var SidebarView = _ref5 => {
20185
20872
  }))));
20186
20873
  };
20187
20874
 
20188
- var _excluded$10 = ["children", "position", "size", "variant", "defaultExpanded", "expanded", "onExpandedChange", "fixed", "hasBackdrop", "showToggleButton", "expandedWidth", "collapsedWidth", "breakpoint", "breakpointBehavior", "views"];
20875
+ var _excluded$12 = ["children", "position", "size", "variant", "defaultExpanded", "expanded", "onExpandedChange", "fixed", "hasBackdrop", "showToggleButton", "expandedWidth", "collapsedWidth", "breakpoint", "breakpointBehavior", "views"];
20189
20876
  /**
20190
20877
  * Sidebar component for creating collapsible, themeable and customizable sidebars.
20191
20878
  */
@@ -20207,7 +20894,7 @@ var SidebarComponent = _ref => {
20207
20894
  breakpointBehavior = 'overlay',
20208
20895
  views
20209
20896
  } = _ref,
20210
- props = _objectWithoutPropertiesLoose(_ref, _excluded$10);
20897
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$12);
20211
20898
  var {
20212
20899
  isExpanded,
20213
20900
  toggleExpanded,
@@ -20672,7 +21359,7 @@ var HandleIconStyles = {
20672
21359
  }
20673
21360
  };
20674
21361
 
20675
- var _excluded$11 = ["children", "id", "defaultSize", "minSize", "maxSize", "collapsible", "defaultCollapsed", "onCollapseChange", "views"],
21362
+ var _excluded$13 = ["children", "id", "defaultSize", "minSize", "maxSize", "collapsible", "defaultCollapsed", "onCollapseChange", "views"],
20676
21363
  _excluded2$g = ["id", "position", "disabled", "withVisualIndicator", "withCollapseButton", "collapseTarget", "views"],
20677
21364
  _excluded3$b = ["children", "orientation", "size", "variant", "defaultSizes", "minSize", "maxSize", "collapsible", "containerRef", "autoSaveId", "views"];
20678
21365
  // Create context for the Resizable component
@@ -20717,7 +21404,7 @@ var ResizablePanel = _ref2 => {
20717
21404
  onCollapseChange,
20718
21405
  views
20719
21406
  } = _ref2,
20720
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$11);
21407
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$13);
20721
21408
  var {
20722
21409
  orientation,
20723
21410
  registerPanel,
@@ -20932,7 +21619,7 @@ var ResizableView = _ref4 => {
20932
21619
  }, ResizableOrientations[orientation], views == null ? void 0 : views.container, props), children);
20933
21620
  };
20934
21621
 
20935
- var _excluded$12 = ["children", "orientation", "size", "variant", "defaultSizes", "onSizesChange", "minSize", "maxSize", "collapsible", "autoSaveId", "storage", "keyboardResizeBy", "views"];
21622
+ var _excluded$14 = ["children", "orientation", "size", "variant", "defaultSizes", "onSizesChange", "minSize", "maxSize", "collapsible", "autoSaveId", "storage", "keyboardResizeBy", "views"];
20936
21623
  /**
20937
21624
  * Resizable component for creating resizable panel groups and layouts.
20938
21625
  */
@@ -20952,7 +21639,7 @@ var ResizableComponent = _ref => {
20952
21639
  keyboardResizeBy = 10,
20953
21640
  views
20954
21641
  } = _ref,
20955
- props = _objectWithoutPropertiesLoose(_ref, _excluded$12);
21642
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$14);
20956
21643
  var {
20957
21644
  isResizing,
20958
21645
  setIsResizing,
@@ -21720,7 +22407,7 @@ var CommandFooterStyles = {
21720
22407
  color: 'color.gray.500'
21721
22408
  };
21722
22409
 
21723
- var _excluded$13 = ["value", "onValueChange", "placeholder", "views"],
22410
+ var _excluded$15 = ["value", "onValueChange", "placeholder", "views"],
21724
22411
  _excluded2$h = ["children", "views"],
21725
22412
  _excluded3$c = ["heading", "children", "views"],
21726
22413
  _excluded4$a = ["item", "selected", "onSelect", "views"],
@@ -21752,7 +22439,7 @@ var CommandInput = _ref2 => {
21752
22439
  placeholder = 'Type a command or search...',
21753
22440
  views
21754
22441
  } = _ref2,
21755
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$13);
22442
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$15);
21756
22443
  var inputRef = useRef(null);
21757
22444
  // Focus input when component mounts
21758
22445
  React.useEffect(() => {
@@ -21935,7 +22622,7 @@ var CommandView = _ref7 => {
21935
22622
  })))), footer && (/*#__PURE__*/React.createElement(View, Object.assign({}, CommandFooterStyles, views == null ? void 0 : views.footer), footer)))));
21936
22623
  };
21937
22624
 
21938
- var _excluded$14 = ["open", "onOpenChange", "groups", "commands", "placeholder", "size", "variant", "filter", "emptyState", "footer", "views"];
22625
+ var _excluded$16 = ["open", "onOpenChange", "groups", "commands", "placeholder", "size", "variant", "filter", "emptyState", "footer", "views"];
21939
22626
  /**
21940
22627
  * Command component for displaying a command palette with search functionality.
21941
22628
  */
@@ -21953,7 +22640,7 @@ var CommandComponent = _ref => {
21953
22640
  footer,
21954
22641
  views
21955
22642
  } = _ref,
21956
- props = _objectWithoutPropertiesLoose(_ref, _excluded$14);
22643
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$16);
21957
22644
  var {
21958
22645
  search,
21959
22646
  setSearch,
@@ -22132,65 +22819,6 @@ var getTooltip = themeMode => {
22132
22819
  };
22133
22820
  // For backward compatibility
22134
22821
  var TooltipVariants = /*#__PURE__*/getTooltip();
22135
- var getTooltipPositionStyles = (position, align) => {
22136
- var baseStyles = {
22137
- position: 'absolute',
22138
- zIndex: 1000
22139
- };
22140
- // Position styles
22141
- switch (position) {
22142
- case 'top':
22143
- return Object.assign({}, baseStyles, {
22144
- bottom: '100%',
22145
- marginBottom: '8px'
22146
- }, align === 'start' ? {
22147
- left: '0'
22148
- } : align === 'end' ? {
22149
- right: '0'
22150
- } : {
22151
- left: '50%',
22152
- transform: 'translateX(-50%)'
22153
- });
22154
- case 'right':
22155
- return Object.assign({}, baseStyles, {
22156
- left: '100%',
22157
- marginLeft: '8px'
22158
- }, align === 'start' ? {
22159
- top: '0'
22160
- } : align === 'end' ? {
22161
- bottom: '0'
22162
- } : {
22163
- top: '50%',
22164
- transform: 'translateY(-50%)'
22165
- });
22166
- case 'bottom':
22167
- return Object.assign({}, baseStyles, {
22168
- top: '100%',
22169
- marginTop: '8px'
22170
- }, align === 'start' ? {
22171
- left: '0'
22172
- } : align === 'end' ? {
22173
- right: '0'
22174
- } : {
22175
- left: '50%',
22176
- transform: 'translateX(-50%)'
22177
- });
22178
- case 'left':
22179
- return Object.assign({}, baseStyles, {
22180
- right: '100%',
22181
- marginRight: '8px'
22182
- }, align === 'start' ? {
22183
- top: '0'
22184
- } : align === 'end' ? {
22185
- bottom: '0'
22186
- } : {
22187
- top: '50%',
22188
- transform: 'translateY(-50%)'
22189
- });
22190
- default:
22191
- return baseStyles;
22192
- }
22193
- };
22194
22822
  var getArrowStyles = position => {
22195
22823
  var baseStyles = {
22196
22824
  position: 'absolute',
@@ -22240,7 +22868,7 @@ var getArrowStyles = position => {
22240
22868
  }
22241
22869
  };
22242
22870
 
22243
- var _excluded$15 = ["children", "views", "asChild"],
22871
+ var _excluded$17 = ["children", "views", "asChild"],
22244
22872
  _excluded2$i = ["children", "views"],
22245
22873
  _excluded3$d = ["content", "children", "position", "align", "size", "variant", "showArrow", "views", "themeMode"];
22246
22874
  // Create context for the Tooltip
@@ -22276,7 +22904,7 @@ var TooltipTrigger = _ref2 => {
22276
22904
  views,
22277
22905
  asChild = false
22278
22906
  } = _ref2,
22279
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$15);
22907
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$17);
22280
22908
  var {
22281
22909
  openTooltip,
22282
22910
  closeTooltip,
@@ -22345,17 +22973,113 @@ var TooltipView = _ref4 => {
22345
22973
  props = _objectWithoutPropertiesLoose(_ref4, _excluded3$d);
22346
22974
  var {
22347
22975
  isOpen,
22348
- // openTooltip,
22349
- // closeTooltip,
22350
- // triggerRef,
22976
+ triggerRef,
22351
22977
  contentRef,
22352
22978
  contentId,
22353
22979
  triggerId
22354
22980
  } = useTooltipContext();
22355
- // Get position styles
22356
- var positionStyles = getTooltipPositionStyles(position, align);
22357
- // Get arrow styles
22358
- var arrowStyles = showArrow ? getArrowStyles(position) : {};
22981
+ var [optimalPosition, setOptimalPosition] = useState({
22982
+ x: 0,
22983
+ y: 0,
22984
+ placement: position
22985
+ });
22986
+ // Calculate optimal position when the tooltip opens
22987
+ useEffect(() => {
22988
+ if (isOpen && contentRef != null && contentRef.current && triggerRef != null && triggerRef.current) {
22989
+ var contentRect = contentRef.current.getBoundingClientRect();
22990
+ var triggerRect = triggerRef.current.getBoundingClientRect();
22991
+ // Get content dimensions
22992
+ var contentWidth = Math.max(contentRect.width || 120, 120);
22993
+ var contentHeight = Math.max(contentRect.height || 32, 32);
22994
+ // Get viewport dimensions
22995
+ var viewportWidth = window.innerWidth;
22996
+ var viewportHeight = window.innerHeight;
22997
+ // Calculate available space on all sides from the trigger
22998
+ var availableSpace = {
22999
+ top: triggerRect.top,
23000
+ right: viewportWidth - triggerRect.right,
23001
+ bottom: viewportHeight - triggerRect.bottom,
23002
+ left: triggerRect.left
23003
+ };
23004
+ // Determine optimal placement based on available space and preferred position
23005
+ var placements = [{
23006
+ placement: 'top',
23007
+ space: availableSpace.top,
23008
+ fits: availableSpace.top >= contentHeight + 16,
23009
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
23010
+ y: triggerRect.top - contentHeight - 8
23011
+ }, {
23012
+ placement: 'bottom',
23013
+ space: availableSpace.bottom,
23014
+ fits: availableSpace.bottom >= contentHeight + 16,
23015
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
23016
+ y: triggerRect.bottom + 8
23017
+ }, {
23018
+ placement: 'right',
23019
+ space: availableSpace.right,
23020
+ fits: availableSpace.right >= contentWidth + 16,
23021
+ x: triggerRect.right + 8,
23022
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
23023
+ }, {
23024
+ placement: 'left',
23025
+ space: availableSpace.left,
23026
+ fits: availableSpace.left >= contentWidth + 16,
23027
+ x: triggerRect.left - contentWidth - 8,
23028
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
23029
+ }];
23030
+ // First try the preferred position if it fits
23031
+ var preferredPlacement = placements.find(p => p.placement === position && p.fits);
23032
+ if (preferredPlacement) {
23033
+ setOptimalPosition({
23034
+ x: preferredPlacement.x,
23035
+ y: preferredPlacement.y,
23036
+ placement: preferredPlacement.placement
23037
+ });
23038
+ return;
23039
+ }
23040
+ // Otherwise, find the best fitting placement
23041
+ var fittingPlacement = placements.find(p => p.fits);
23042
+ if (fittingPlacement) {
23043
+ setOptimalPosition({
23044
+ x: fittingPlacement.x,
23045
+ y: fittingPlacement.y,
23046
+ placement: fittingPlacement.placement
23047
+ });
23048
+ return;
23049
+ }
23050
+ // If nothing fits, choose the placement with the most space
23051
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
23052
+ // Ensure the content stays within viewport bounds
23053
+ var finalX = bestPlacement.x;
23054
+ var finalY = bestPlacement.y;
23055
+ if (finalX + contentWidth > viewportWidth) {
23056
+ finalX = viewportWidth - contentWidth - 8;
23057
+ }
23058
+ if (finalX < 8) {
23059
+ finalX = 8;
23060
+ }
23061
+ if (finalY + contentHeight > viewportHeight) {
23062
+ finalY = viewportHeight - contentHeight - 8;
23063
+ }
23064
+ if (finalY < 8) {
23065
+ finalY = 8;
23066
+ }
23067
+ setOptimalPosition({
23068
+ x: finalX,
23069
+ y: finalY,
23070
+ placement: bestPlacement.placement
23071
+ });
23072
+ }
23073
+ }, [isOpen, position, align, triggerRef, contentRef]);
23074
+ // Get arrow styles based on optimal placement
23075
+ var arrowStyles = showArrow ? getArrowStyles(optimalPosition.placement) : {};
23076
+ // Create intelligent positioning styles
23077
+ var positionStyles = {
23078
+ position: 'fixed',
23079
+ left: optimalPosition.x,
23080
+ top: optimalPosition.y,
23081
+ zIndex: 1000
23082
+ };
22359
23083
  return /*#__PURE__*/React.createElement(View, Object.assign({
22360
23084
  position: "relative",
22361
23085
  display: "inline-block"
@@ -22365,11 +23089,18 @@ var TooltipView = _ref4 => {
22365
23089
  role: "tooltip",
22366
23090
  "aria-labelledby": triggerId,
22367
23091
  borderRadius: 4,
22368
- boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)"
22369
- }, TooltipSizes[size], TooltipVariants[variant], positionStyles, views == null ? void 0 : views.content), typeof content === 'string' ? (/*#__PURE__*/React.createElement(Text$1, Object.assign({}, views == null ? void 0 : views.text), content)) : content, showArrow && /*#__PURE__*/React.createElement(View, Object.assign({}, arrowStyles, views == null ? void 0 : views.arrow)))));
23092
+ boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)",
23093
+ style: positionStyles
23094
+ }, TooltipSizes[size], TooltipVariants[variant], views == null ? void 0 : views.content), typeof content === 'string' ? (/*#__PURE__*/React.createElement(Text$1, Object.assign({}, views == null ? void 0 : views.text), content)) : content, showArrow && /*#__PURE__*/React.createElement(View, Object.assign({}, arrowStyles, views == null ? void 0 : views.arrow)), process.env.NODE_ENV === 'development' && (/*#__PURE__*/React.createElement("div", {
23095
+ style: {
23096
+ fontSize: '8px',
23097
+ opacity: 0.7,
23098
+ marginTop: '2px'
23099
+ }
23100
+ }, "Placement: ", optimalPosition.placement)))));
22370
23101
  };
22371
23102
 
22372
- var _excluded$16 = ["content", "children", "position", "align", "size", "variant", "openDelay", "closeDelay", "showArrow", "defaultOpen", "isDisabled", "views"];
23103
+ var _excluded$18 = ["content", "children", "position", "align", "size", "variant", "openDelay", "closeDelay", "showArrow", "defaultOpen", "isDisabled", "views"];
22373
23104
  /**
22374
23105
  * Tooltip component for displaying additional information when hovering over an element.
22375
23106
  * Supports configurable positions, delays, and styling.
@@ -22389,7 +23120,7 @@ var TooltipComponent = _ref => {
22389
23120
  isDisabled = false,
22390
23121
  views
22391
23122
  } = _ref,
22392
- props = _objectWithoutPropertiesLoose(_ref, _excluded$16);
23123
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$18);
22393
23124
  var tooltipState = useTooltipState({
22394
23125
  defaultOpen,
22395
23126
  openDelay,
@@ -22862,7 +23593,7 @@ var TreeItemStates = {
22862
23593
  }
22863
23594
  };
22864
23595
 
22865
- var _excluded$17 = ["children", "views", "baseId"],
23596
+ var _excluded$19 = ["children", "views", "baseId"],
22866
23597
  _excluded2$j = ["value", "disabled", "icon", "children", "views", "style", "draggable"],
22867
23598
  _excluded3$e = ["children", "onClick", "onToggleExpand", "hasChildren", "expanded", "icon", "disabled", "isSelected", "isDragging", "size", "variant", "views"],
22868
23599
  _excluded4$b = ["children", "views"];
@@ -22898,7 +23629,7 @@ var TreeView = _ref2 => {
22898
23629
  baseId
22899
23630
  // themeMode, // If 'app-studio' ViewProps supports themeMode
22900
23631
  } = _ref2,
22901
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$17);
23632
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$19);
22902
23633
  var {
22903
23634
  allowDragAndDrop,
22904
23635
  handleDrop,
@@ -23178,7 +23909,7 @@ var DataDrivenTreeView = _ref7 => {
23178
23909
  }))));
23179
23910
  };
23180
23911
 
23181
- var _excluded$18 = ["children", "items", "size", "variant", "defaultExpandedItems", "expandedItems", "onExpandedItemsChange", "defaultSelectedItem", "selectedItem", "onItemSelect", "multiSelect", "allowDragAndDrop", "dragHandleIcon", "onItemsReorder", "onDragStart", "onDragEnd", "views"];
23912
+ var _excluded$1a = ["children", "items", "size", "variant", "defaultExpandedItems", "expandedItems", "onExpandedItemsChange", "defaultSelectedItem", "selectedItem", "onItemSelect", "multiSelect", "allowDragAndDrop", "dragHandleIcon", "onItemsReorder", "onDragStart", "onDragEnd", "views"];
23182
23913
  /**
23183
23914
  * Tree component for displaying hierarchical data.
23184
23915
  * Supports both compound component pattern (using Tree.Item, Tree.ItemLabel, Tree.ItemContent)
@@ -23247,7 +23978,7 @@ var TreeComponent = _ref => {
23247
23978
  views // Global views configuration
23248
23979
  // Remaining ViewProps for the root TreeView container
23249
23980
  } = _ref,
23250
- props = _objectWithoutPropertiesLoose(_ref, _excluded$18);
23981
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1a);
23251
23982
  var treeState = useTreeState({
23252
23983
  defaultExpandedItems,
23253
23984
  expandedItems,
@@ -23820,7 +24551,7 @@ var FlowNodeStates = {
23820
24551
  }
23821
24552
  };
23822
24553
 
23823
- var _excluded$19 = ["node", "onSelect", "isSelected", "isDragging", "onDragStart", "onDrag", "onDragEnd", "size", "variant", "views"],
24554
+ var _excluded$1b = ["node", "onSelect", "isSelected", "isDragging", "onDragStart", "onDrag", "onDragEnd", "size", "variant", "views"],
23824
24555
  _excluded2$k = ["onZoomIn", "onZoomOut", "onReset", "views"],
23825
24556
  _excluded3$f = ["onClick", "views"],
23826
24557
  _excluded4$c = ["nodes", "edges", "selectedNodeId", "draggedNodeId", "onNodeSelect", "onAddNode", "onNodeDragStart", "onNodeDrag", "onNodeDragEnd", "size", "variant", "direction", "showControls", "allowAddingNodes", "allowDraggingNodes", "views", "baseId", "viewport", "onZoomIn", "onZoomOut", "onReset", "onViewportChange"];
@@ -23836,7 +24567,7 @@ var FlowNodeView = _ref => {
23836
24567
  variant = 'default',
23837
24568
  views
23838
24569
  } = _ref,
23839
- props = _objectWithoutPropertiesLoose(_ref, _excluded$19);
24570
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1b);
23840
24571
  var handleClick = () => {
23841
24572
  if (onSelect) {
23842
24573
  onSelect(node.id);
@@ -24483,7 +25214,7 @@ var FlowView = _ref5 => {
24483
25214
  }, "Zoom: ", Math.round(viewport.zoom * 100), "%")));
24484
25215
  };
24485
25216
 
24486
- var _excluded$1a = ["children", "nodes", "edges", "size", "variant", "direction", "showControls", "allowAddingNodes", "allowDraggingNodes", "onNodesChange", "onEdgesChange", "onNodeSelect", "onNodeAdd", "onNodeDragStart", "onNodeDrag", "onNodeDragEnd", "selectedNodeId", "initialViewport", "viewport", "onViewportChange", "views"];
25217
+ var _excluded$1c = ["children", "nodes", "edges", "size", "variant", "direction", "showControls", "allowAddingNodes", "allowDraggingNodes", "onNodesChange", "onEdgesChange", "onNodeSelect", "onNodeAdd", "onNodeDragStart", "onNodeDrag", "onNodeDragEnd", "selectedNodeId", "initialViewport", "viewport", "onViewportChange", "views"];
24487
25218
  /**
24488
25219
  * Flow component for creating workflow diagrams.
24489
25220
  *
@@ -24540,7 +25271,7 @@ var FlowComponent = _ref => {
24540
25271
  onViewportChange,
24541
25272
  views
24542
25273
  } = _ref,
24543
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1a);
25274
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1c);
24544
25275
  var flowState = useFlowState({
24545
25276
  initialNodes: controlledNodes,
24546
25277
  initialEdges: controlledEdges,
@@ -24982,9 +25713,6 @@ var Shapes$4 = {
24982
25713
  },
24983
25714
  rounded: {
24984
25715
  borderRadius: '8px'
24985
- },
24986
- pillShaped: {
24987
- borderRadius: '9999px'
24988
25716
  }
24989
25717
  };
24990
25718
  /**
@@ -25130,71 +25858,373 @@ var AttachmentGroup = _ref => {
25130
25858
  };
25131
25859
 
25132
25860
  var EditableInput = /*#__PURE__*/forwardRef((_ref, ref) => {
25861
+ var _containerRef$current, _containerRef$current2;
25133
25862
  var {
25134
25863
  value,
25135
25864
  onChange,
25136
- onSubmit,
25137
25865
  placeholder = 'Type your message...',
25138
25866
  disabled = false,
25139
25867
  autoFocus = true,
25868
+ suggestions = [],
25869
+ onSuggestionSelect,
25870
+ showSuggestions = false,
25871
+ mentionData = [],
25872
+ mentionTrigger = '@',
25873
+ onMentionSelect,
25874
+ maxHeight = '200px',
25875
+ minHeight = '40px',
25140
25876
  views = {}
25141
25877
  } = _ref;
25142
- var {
25143
- getColor
25144
- } = useTheme();
25145
25878
  var lastValueRef = useRef(value);
25879
+ var [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(-1);
25880
+ var [showPlaceholder, setShowPlaceholder] = useState(!value);
25881
+ var containerRef = useRef(null);
25882
+ var [isFocused, setIsFocused] = useState(false);
25883
+ // Mention-specific state
25884
+ var [showMentions, setShowMentions] = useState(false);
25885
+ var [mentionQuery, setMentionQuery] = useState('');
25886
+ var [mentionStartPos, setMentionStartPos] = useState(-1);
25887
+ var [selectedMentionIndex, setSelectedMentionIndex] = useState(-1);
25888
+ var [filteredMentions, setFilteredMentions] = useState([]);
25889
+ // Positioning state for dropdowns
25890
+ var [mentionPosition, setMentionPosition] = useState({
25891
+ x: 0,
25892
+ y: 0
25893
+ });
25894
+ var [suggestionPosition, setSuggestionPosition] = useState({
25895
+ x: 0,
25896
+ y: 0
25897
+ });
25898
+ // Note: Using custom positioning logic for better control over dropdown placement
25146
25899
  // Update the content of the editable div when the value prop changes
25147
25900
  useEffect(() => {
25148
25901
  var editableDiv = ref;
25149
25902
  if (editableDiv.current && value !== lastValueRef.current) {
25150
25903
  editableDiv.current.textContent = value;
25151
25904
  lastValueRef.current = value;
25905
+ setShowPlaceholder(!value);
25152
25906
  }
25153
25907
  }, [value, ref]);
25908
+ // Auto-focus effect
25909
+ useEffect(() => {
25910
+ if (autoFocus && ref && typeof ref === 'object' && ref.current) {
25911
+ ref.current.focus();
25912
+ }
25913
+ }, [autoFocus, ref]);
25914
+ // Get cursor position
25915
+ var getCursorPosition = () => {
25916
+ var selection = window.getSelection();
25917
+ if (!selection || selection.rangeCount === 0) return -1;
25918
+ var range = selection.getRangeAt(0);
25919
+ var preCaretRange = range.cloneRange();
25920
+ preCaretRange.selectNodeContents(ref && typeof ref === 'object' && ref.current ? ref.current : document.body);
25921
+ preCaretRange.setEnd(range.endContainer, range.endOffset);
25922
+ return preCaretRange.toString().length;
25923
+ };
25924
+ // Check for mention trigger and filter mentions
25925
+ var checkForMentions = useCallback((text, cursorPos) => {
25926
+ var beforeCursor = text.substring(0, cursorPos);
25927
+ var triggerIndex = beforeCursor.lastIndexOf(mentionTrigger);
25928
+ if (triggerIndex !== -1) {
25929
+ var afterTrigger = beforeCursor.substring(triggerIndex + 1);
25930
+ var hasSpaceAfterTrigger = afterTrigger.includes(' ');
25931
+ if (!hasSpaceAfterTrigger) {
25932
+ var query = afterTrigger.toLowerCase();
25933
+ var filtered = mentionData.filter(mention => mention.name.toLowerCase().includes(query));
25934
+ setMentionQuery(query);
25935
+ setMentionStartPos(triggerIndex);
25936
+ setFilteredMentions(filtered);
25937
+ setShowMentions(filtered.length > 0);
25938
+ setSelectedMentionIndex(0);
25939
+ // Calculate position for mentions dropdown
25940
+ var position = calculateDropdownPosition();
25941
+ setMentionPosition(position);
25942
+ return;
25943
+ }
25944
+ }
25945
+ setShowMentions(false);
25946
+ setMentionQuery('');
25947
+ setMentionStartPos(-1);
25948
+ setSelectedMentionIndex(-1);
25949
+ }, [mentionData, mentionTrigger]);
25950
+ // Calculate optimal position for dropdowns
25951
+ var calculateDropdownPosition = useCallback(function (dropdownHeight) {
25952
+ if (dropdownHeight === void 0) {
25953
+ dropdownHeight = 200;
25954
+ }
25955
+ if (!containerRef.current) return {
25956
+ x: 0,
25957
+ y: 0
25958
+ };
25959
+ var containerRect = containerRef.current.getBoundingClientRect();
25960
+ var viewportHeight = window.innerHeight;
25961
+ var viewportWidth = window.innerWidth;
25962
+ // Calculate available space
25963
+ var availableSpace = {
25964
+ top: containerRect.top,
25965
+ bottom: viewportHeight - containerRect.bottom,
25966
+ left: containerRect.left,
25967
+ right: viewportWidth - containerRect.right
25968
+ };
25969
+ // Prefer bottom placement, but use top if not enough space
25970
+ var useTopPlacement = availableSpace.bottom < dropdownHeight + 8 && availableSpace.top > availableSpace.bottom;
25971
+ return {
25972
+ x: containerRect.left,
25973
+ y: useTopPlacement ? containerRect.top - dropdownHeight - 8 : containerRect.bottom + 8
25974
+ };
25975
+ }, []);
25976
+ // Handle focus events
25977
+ var handleFocus = useCallback(() => {
25978
+ setIsFocused(true);
25979
+ // Calculate position for suggestions when focused
25980
+ var position = calculateDropdownPosition();
25981
+ setSuggestionPosition(position);
25982
+ }, [calculateDropdownPosition]);
25983
+ var handleBlur = useCallback(() => {
25984
+ // Delay hiding to allow for dropdown interactions
25985
+ setTimeout(() => {
25986
+ setIsFocused(false);
25987
+ setSelectedSuggestionIndex(-1);
25988
+ }, 150);
25989
+ }, []);
25154
25990
  // Handle input events
25155
25991
  var handleInput = e => {
25156
25992
  var newValue = e.currentTarget.textContent || '';
25157
25993
  if (newValue !== lastValueRef.current) {
25158
25994
  onChange(newValue);
25159
25995
  lastValueRef.current = newValue;
25996
+ setShowPlaceholder(!newValue);
25997
+ // Check for mentions
25998
+ var cursorPos = getCursorPosition();
25999
+ checkForMentions(newValue, cursorPos);
25160
26000
  }
25161
26001
  };
26002
+ // Handle mention selection
26003
+ var handleMentionSelect = useCallback(mention => {
26004
+ if (ref && typeof ref === 'object' && ref.current) {
26005
+ var currentText = ref.current.textContent || '';
26006
+ var beforeMention = currentText.substring(0, mentionStartPos);
26007
+ var afterMention = currentText.substring(mentionStartPos + mentionTrigger.length + mentionQuery.length);
26008
+ var newText = beforeMention + mentionTrigger + mention.name + ' ' + afterMention;
26009
+ onChange(newText);
26010
+ lastValueRef.current = newText;
26011
+ ref.current.textContent = newText;
26012
+ // Set cursor position after the mention
26013
+ var newCursorPos = beforeMention.length + mentionTrigger.length + mention.name.length + 1;
26014
+ setTimeout(() => {
26015
+ if (ref.current) {
26016
+ var range = document.createRange();
26017
+ var selection = window.getSelection();
26018
+ var textNode = ref.current.firstChild;
26019
+ if (textNode && selection) {
26020
+ var _textNode$textContent;
26021
+ range.setStart(textNode, Math.min(newCursorPos, ((_textNode$textContent = textNode.textContent) == null ? void 0 : _textNode$textContent.length) || 0));
26022
+ range.collapse(true);
26023
+ selection.removeAllRanges();
26024
+ selection.addRange(range);
26025
+ }
26026
+ }
26027
+ }, 0);
26028
+ }
26029
+ setShowMentions(false);
26030
+ setMentionQuery('');
26031
+ setMentionStartPos(-1);
26032
+ setSelectedMentionIndex(-1);
26033
+ if (onMentionSelect) {
26034
+ onMentionSelect(mention);
26035
+ }
26036
+ }, [mentionStartPos, mentionTrigger, mentionQuery, onChange, onMentionSelect, ref]);
26037
+ // Handle suggestion selection
26038
+ var handleSuggestionSelect = useCallback(suggestion => {
26039
+ if (onSuggestionSelect) {
26040
+ onSuggestionSelect(suggestion);
26041
+ }
26042
+ setSelectedSuggestionIndex(-1);
26043
+ }, [onSuggestionSelect]);
25162
26044
  // Handle key down events
25163
26045
  var handleKeyDown = e => {
25164
- if (e.key === 'Enter' && !e.shiftKey) {
25165
- e.preventDefault();
25166
- onSubmit(e);
26046
+ // Handle mention navigation
26047
+ if (showMentions && filteredMentions.length > 0) {
26048
+ if (e.key === 'ArrowDown') {
26049
+ e.preventDefault();
26050
+ setSelectedMentionIndex(prev => prev < filteredMentions.length - 1 ? prev + 1 : 0);
26051
+ return;
26052
+ }
26053
+ if (e.key === 'ArrowUp') {
26054
+ e.preventDefault();
26055
+ setSelectedMentionIndex(prev => prev > 0 ? prev - 1 : filteredMentions.length - 1);
26056
+ return;
26057
+ }
26058
+ if ((e.key === 'Tab' || e.key === 'Enter') && selectedMentionIndex >= 0) {
26059
+ e.preventDefault();
26060
+ handleMentionSelect(filteredMentions[selectedMentionIndex]);
26061
+ return;
26062
+ }
26063
+ if (e.key === 'Escape') {
26064
+ setShowMentions(false);
26065
+ setSelectedMentionIndex(-1);
26066
+ return;
26067
+ }
26068
+ }
26069
+ // Handle suggestion navigation
26070
+ if (showSuggestions && suggestions.length > 0) {
26071
+ if (e.key === 'ArrowDown') {
26072
+ e.preventDefault();
26073
+ setSelectedSuggestionIndex(prev => prev < suggestions.length - 1 ? prev + 1 : 0);
26074
+ return;
26075
+ }
26076
+ if (e.key === 'ArrowUp') {
26077
+ e.preventDefault();
26078
+ setSelectedSuggestionIndex(prev => prev > 0 ? prev - 1 : suggestions.length - 1);
26079
+ return;
26080
+ }
26081
+ if (e.key === 'Tab' && selectedSuggestionIndex >= 0) {
26082
+ e.preventDefault();
26083
+ handleSuggestionSelect(suggestions[selectedSuggestionIndex]);
26084
+ return;
26085
+ }
26086
+ if (e.key === 'Escape') {
26087
+ setSelectedSuggestionIndex(-1);
26088
+ return;
26089
+ }
25167
26090
  }
26091
+ // Allow Enter for line breaks (remove submission on Enter)
26092
+ // Submission should only happen via the send button
25168
26093
  };
25169
26094
  return /*#__PURE__*/React.createElement(View, Object.assign({
26095
+ ref: containerRef,
25170
26096
  width: "100%",
25171
- minHeight: "40px",
25172
- maxHeight: "200px",
25173
- overflowY: "auto"
25174
- }, views == null ? void 0 : views.container), /*#__PURE__*/React.createElement(View, Object.assign({
26097
+ position: "relative"
26098
+ }, views == null ? void 0 : views.container), /*#__PURE__*/React.createElement(View, {
26099
+ width: "100%",
26100
+ minHeight: minHeight,
26101
+ maxHeight: maxHeight,
26102
+ overflowY: "auto",
26103
+ position: "relative"
26104
+ }, showPlaceholder && (/*#__PURE__*/React.createElement(Text$1, Object.assign({
26105
+ position: "absolute",
26106
+ top: "8px",
26107
+ left: "8px",
26108
+ color: "color.gray.400",
26109
+ pointerEvents: "none",
26110
+ fontSize: "14px",
26111
+ lineHeight: "1.5",
26112
+ zIndex: 1
26113
+ }, views == null ? void 0 : views.placeholder), placeholder)), /*#__PURE__*/React.createElement(View, Object.assign({
25175
26114
  as: "div",
25176
26115
  ref: ref,
25177
26116
  contentEditable: !disabled,
25178
26117
  suppressContentEditableWarning: true,
25179
26118
  onInput: handleInput,
25180
26119
  onKeyDown: handleKeyDown,
26120
+ onFocus: handleFocus,
26121
+ onBlur: handleBlur,
25181
26122
  role: "textbox",
25182
26123
  "aria-multiline": "true",
25183
26124
  "aria-placeholder": placeholder,
25184
- "data-placeholder": placeholder,
25185
26125
  width: "100%",
25186
26126
  minHeight: "24px",
26127
+ padding: "8px",
25187
26128
  outline: "none",
25188
26129
  whiteSpace: "pre-wrap",
25189
26130
  wordBreak: "break-word",
25190
- _empty: {
25191
- _before: {
25192
- content: 'attr(data-placeholder)',
25193
- color: 'color.gray.400',
25194
- pointerEvents: 'none'
25195
- }
26131
+ fontSize: "14px",
26132
+ lineHeight: "1.5",
26133
+ color: "color.gray.900",
26134
+ backgroundColor: "transparent"
26135
+ }, views == null ? void 0 : views.input))), showMentions && filteredMentions.length > 0 && (/*#__PURE__*/React.createElement(View, Object.assign({
26136
+ position: "fixed",
26137
+ left: mentionPosition.x,
26138
+ top: mentionPosition.y,
26139
+ width: ((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth) || 300,
26140
+ backgroundColor: "color.white",
26141
+ border: "2px solid",
26142
+ borderColor: "color.blue.300",
26143
+ borderRadius: "8px",
26144
+ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.15)",
26145
+ zIndex: 9999,
26146
+ maxHeight: "200px",
26147
+ overflowY: "auto"
26148
+ }, views == null ? void 0 : views.mentionContainer), /*#__PURE__*/React.createElement(Vertical, {
26149
+ gap: 0
26150
+ }, filteredMentions.map((mention, index) => (/*#__PURE__*/React.createElement(View, Object.assign({
26151
+ key: mention.id,
26152
+ as: "button",
26153
+ type: "button",
26154
+ width: "100%",
26155
+ padding: "12px 16px",
26156
+ backgroundColor: index === selectedMentionIndex ? 'color.blue.50' : 'transparent',
26157
+ border: "none",
26158
+ cursor: "pointer",
26159
+ textAlign: "left",
26160
+ transition: "background-color 0.2s ease",
26161
+ onClick: () => handleMentionSelect(mention),
26162
+ onMouseEnter: () => setSelectedMentionIndex(index),
26163
+ _hover: {
26164
+ backgroundColor: 'color.blue.50'
25196
26165
  }
25197
- }, views == null ? void 0 : views.input)));
26166
+ }, views == null ? void 0 : views.mentionItem), /*#__PURE__*/React.createElement(Vertical, {
26167
+ gap: 4
26168
+ }, /*#__PURE__*/React.createElement(Text$1, {
26169
+ fontSize: "14px",
26170
+ color: "color.gray.900",
26171
+ fontWeight: "medium"
26172
+ }, mentionTrigger, mention.name), mention.description && (/*#__PURE__*/React.createElement(Text$1, {
26173
+ fontSize: "12px",
26174
+ color: "color.gray.600"
26175
+ }, mention.description)))))), process.env.NODE_ENV === 'development' && (/*#__PURE__*/React.createElement("div", {
26176
+ style: {
26177
+ fontSize: '8px',
26178
+ opacity: 0.7,
26179
+ padding: '4px'
26180
+ }
26181
+ }, "Mentions (Trigger: ", mentionTrigger, ")"))))), showSuggestions && suggestions.length > 0 && !showMentions && isFocused && !value && (/*#__PURE__*/React.createElement(View, Object.assign({
26182
+ position: "fixed",
26183
+ left: suggestionPosition.x,
26184
+ top: suggestionPosition.y,
26185
+ width: ((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.offsetWidth) || 300,
26186
+ backgroundColor: "color.white",
26187
+ border: "2px solid",
26188
+ borderColor: "color.green.300",
26189
+ borderRadius: "8px",
26190
+ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.15)",
26191
+ zIndex: 9998,
26192
+ maxHeight: "200px",
26193
+ overflowY: "auto"
26194
+ }, views == null ? void 0 : views.suggestionsContainer), /*#__PURE__*/React.createElement(Vertical, {
26195
+ gap: 0
26196
+ }, suggestions.map((suggestion, index) => (/*#__PURE__*/React.createElement(View, Object.assign({
26197
+ key: suggestion.id,
26198
+ as: "button",
26199
+ type: "button",
26200
+ width: "100%",
26201
+ padding: "12px 16px",
26202
+ backgroundColor: index === selectedSuggestionIndex ? 'color.blue.50' : 'transparent',
26203
+ border: "none",
26204
+ cursor: "pointer",
26205
+ textAlign: "left",
26206
+ transition: "background-color 0.2s ease",
26207
+ onClick: () => handleSuggestionSelect(suggestion),
26208
+ onMouseEnter: () => setSelectedSuggestionIndex(index),
26209
+ _hover: {
26210
+ backgroundColor: 'color.blue.50'
26211
+ }
26212
+ }, views == null ? void 0 : views.suggestionItem), /*#__PURE__*/React.createElement(Vertical, {
26213
+ gap: 4
26214
+ }, /*#__PURE__*/React.createElement(Text$1, {
26215
+ fontSize: "14px",
26216
+ color: "color.gray.900",
26217
+ fontWeight: "medium"
26218
+ }, suggestion.text), suggestion.description && (/*#__PURE__*/React.createElement(Text$1, {
26219
+ fontSize: "12px",
26220
+ color: "color.gray.600"
26221
+ }, suggestion.description)))))), process.env.NODE_ENV === 'development' && (/*#__PURE__*/React.createElement("div", {
26222
+ style: {
26223
+ fontSize: '8px',
26224
+ opacity: 0.7,
26225
+ padding: '4px'
26226
+ }
26227
+ }, "Suggestions (Focus-triggered)"))))));
25198
26228
  });
25199
26229
  EditableInput.displayName = 'EditableInput';
25200
26230
 
@@ -25235,7 +26265,7 @@ var PromptExamples = _ref => {
25235
26265
  }, views == null ? void 0 : views.text), example.text)))));
25236
26266
  };
25237
26267
 
25238
- var _excluded$1b = ["onSubmit", "placeholder", "loading", "disabled", "isAgentRunning", "onStopAgent", "loadingText", "autoFocus", "sandboxId", "hideAttachments", "attachmentText", "promptExamples", "showReferenceImageButton", "errorMessage", "size", "shape", "variant", "views", "value", "handleChange", "handleSubmit", "editableRef", "fileInputRef", "isUploading", "isDraggingOver", "uploadedFiles", "removeUploadedFile", "setPendingFiles", "setUploadedFiles", "setIsUploading", "selectedModel", "handleModelChange", "modelOptions", "subscriptionStatus", "canAccessModel", "isGuideTipShown", "hideGuideTip", "isReferenceImageModalShown", "toggleReferenceImageModal", "handlePromptExampleSelect", "handleDragOver", "handleDragLeave", "handleReferenceImageUpload", "removeReferenceImage", "setFileAsReference"];
26268
+ var _excluded$1d = ["onSubmit", "placeholder", "loading", "disabled", "isAgentRunning", "leftButtons", "rightButtons", "onStopAgent", "loadingText", "autoFocus", "sandboxId", "hideAttachments", "attachmentText", "promptExamples", "showReferenceImageButton", "errorMessage", "size", "shape", "variant", "views", "mentionData", "mentionTrigger", "onMentionSelect", "value", "handleChange", "handleSubmit", "editableRef", "fileInputRef", "isUploading", "isDraggingOver", "uploadedFiles", "removeUploadedFile", "setPendingFiles", "setUploadedFiles", "setIsUploading", "selectedModel", "handleModelChange", "modelOptions", "subscriptionStatus", "canAccessModel", "isGuideTipShown", "hideGuideTip", "isReferenceImageModalShown", "toggleReferenceImageModal", "handlePromptExampleSelect", "handleDragOver", "handleDragLeave", "handleReferenceImageUpload", "removeReferenceImage", "setFileAsReference"];
25239
26269
  var ChatInputView = _ref => {
25240
26270
  var _value$trim$length;
25241
26271
  var {
@@ -25244,6 +26274,8 @@ var ChatInputView = _ref => {
25244
26274
  loading = false,
25245
26275
  disabled = false,
25246
26276
  isAgentRunning = false,
26277
+ leftButtons,
26278
+ rightButtons,
25247
26279
  loadingText = 'Agent is working...',
25248
26280
  autoFocus = true,
25249
26281
  sandboxId,
@@ -25256,6 +26288,9 @@ var ChatInputView = _ref => {
25256
26288
  shape = 'rounded',
25257
26289
  variant = 'default',
25258
26290
  views = {},
26291
+ mentionData = [],
26292
+ mentionTrigger = '@',
26293
+ onMentionSelect,
25259
26294
  // Props from state
25260
26295
  value,
25261
26296
  handleChange,
@@ -25275,7 +26310,7 @@ var ChatInputView = _ref => {
25275
26310
  setFileAsReference
25276
26311
  // Other props
25277
26312
  } = _ref,
25278
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1b);
26313
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1d);
25279
26314
  var {} = useTheme();
25280
26315
  // Combine styles
25281
26316
  var containerStyles = Object.assign({}, DefaultChatInputStyles.container, Shapes$4[shape], views == null ? void 0 : views.container);
@@ -25367,16 +26402,18 @@ var ChatInputView = _ref => {
25367
26402
  color: "color.gray.500"
25368
26403
  }, loadingText))), /*#__PURE__*/React.createElement(View, {
25369
26404
  position: "relative",
25370
- width: "100%"
26405
+ width: "100%",
26406
+ overflow: "visible"
25371
26407
  }, /*#__PURE__*/React.createElement(View, Object.assign({
25372
26408
  as: "form",
25373
26409
  onSubmit: handleSubmit,
25374
- overflowY: "auto",
26410
+ overflow: "visible",
25375
26411
  display: "flex",
25376
26412
  flexDirection: "column",
25377
26413
  position: "relative"
25378
26414
  }, contentStyles, containerStyles, {
25379
- paddingHorizontal: 20,
26415
+ paddingHorizontal: 16,
26416
+ paddingVertical: 10,
25380
26417
  backgroundColor: isDraggingOver ? 'color.blue.50' : undefined
25381
26418
  }), /*#__PURE__*/React.createElement(AttachmentGroup, {
25382
26419
  files: uploadedFiles,
@@ -25395,10 +26432,21 @@ var ChatInputView = _ref => {
25395
26432
  ref: editableRef,
25396
26433
  value: value || '',
25397
26434
  onChange: handleChange,
25398
- onSubmit: handleSubmit,
25399
26435
  placeholder: placeholder,
25400
26436
  disabled: disabled && !isAgentRunning,
25401
26437
  autoFocus: autoFocus,
26438
+ suggestions: (promptExamples == null ? void 0 : promptExamples.map(example => ({
26439
+ id: example.id,
26440
+ text: example.text,
26441
+ description: undefined
26442
+ }))) || [],
26443
+ showSuggestions: promptExamples && promptExamples.length > 0 && !value,
26444
+ onSuggestionSelect: suggestion => {
26445
+ handleChange(suggestion.text);
26446
+ },
26447
+ mentionData: mentionData,
26448
+ mentionTrigger: mentionTrigger,
26449
+ onMentionSelect: onMentionSelect,
25402
26450
  views: {
25403
26451
  container: {},
25404
26452
  input: views == null ? void 0 : views.editableInput
@@ -25424,7 +26472,7 @@ var ChatInputView = _ref => {
25424
26472
  views: {
25425
26473
  container: Object.assign({
25426
26474
  height: '36px',
25427
- margin: '0 12px',
26475
+ //margin: '0 12px',
25428
26476
  // borderRadius: '8px',
25429
26477
  // backgroundColor: 'transparent',
25430
26478
  // border: '1px solid',
@@ -25433,13 +26481,15 @@ var ChatInputView = _ref => {
25433
26481
  _hover: {
25434
26482
  backgroundColor: 'color.gray.100'
25435
26483
  }
25436
- }, views == null ? void 0 : views.fileButton, containerStyles)
26484
+ }, views == null ? void 0 : views.fileButton)
25437
26485
  },
25438
26486
  containerProps: {
25439
26487
  display: 'flex',
25440
26488
  alignItems: 'center',
25441
26489
  justifyContent: 'center',
25442
- gap: 4
26490
+ gap: 4,
26491
+ borderRadius: shape === 'rounded' ? '50%' : 4,
26492
+ padding: 10
25443
26493
  },
25444
26494
  textProps: {
25445
26495
  fontSize: '14px',
@@ -25451,9 +26501,13 @@ var ChatInputView = _ref => {
25451
26501
  }
25452
26502
  return null;
25453
26503
  }
25454
- }))), /*#__PURE__*/React.createElement(View, Object.assign({
26504
+ })), leftButtons), /*#__PURE__*/React.createElement(Horizontal, {
26505
+ gap: 8,
26506
+ alignItems: "center"
26507
+ }, /*#__PURE__*/React.createElement(View, Object.assign({
25455
26508
  as: "button",
25456
- type: "submit",
26509
+ type: "button",
26510
+ onClick: handleSubmit,
25457
26511
  height: "40px",
25458
26512
  width: "40px",
25459
26513
  display: "flex",
@@ -25461,7 +26515,7 @@ var ChatInputView = _ref => {
25461
26515
  justifyContent: "center",
25462
26516
  backgroundColor: isAgentRunning ? 'theme.error' : hasText ? 'theme.primary' : 'color.gray.300',
25463
26517
  color: "color.white",
25464
- borderRadius: "50%",
26518
+ borderRadius: shape === 'rounded' ? '50%' : 4,
25465
26519
  border: "none",
25466
26520
  cursor: hasText ? 'pointer' : 'not-allowed',
25467
26521
  disabled: !hasText || loading || disabled && !isAgentRunning,
@@ -25481,7 +26535,7 @@ var ChatInputView = _ref => {
25481
26535
  widthHeight: 16,
25482
26536
  color: "currentColor",
25483
26537
  filled: false
25484
- })))))), errorMessage && (/*#__PURE__*/React.createElement(Text$1, Object.assign({
26538
+ }))), rightButtons)))), errorMessage && (/*#__PURE__*/React.createElement(Text$1, Object.assign({
25485
26539
  color: "theme.error",
25486
26540
  marginTop: "4px"
25487
26541
  }, views == null ? void 0 : views.bottomTip), errorMessage)));
@@ -25542,7 +26596,7 @@ var AuroraStyles = {
25542
26596
  }
25543
26597
  };
25544
26598
 
25545
- var _excluded$1c = ["children", "showRadialGradient", "views", "themeMode"],
26599
+ var _excluded$1e = ["children", "showRadialGradient", "views", "themeMode"],
25546
26600
  _excluded2$l = ["number"],
25547
26601
  _excluded3$g = ["rows", "cols", "squareSize"],
25548
26602
  _excluded4$d = ["count", "colors", "speed", "shapes"],
@@ -25560,7 +26614,7 @@ var AuroraBackground = _ref => {
25560
26614
  showRadialGradient = true,
25561
26615
  views
25562
26616
  } = _ref,
25563
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1c);
26617
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1e);
25564
26618
  var gradientColors = {
25565
26619
  white: 'rgba(255,255,255,1)',
25566
26620
  transparent: 'rgba(255,255,255,0)'
@@ -25984,5 +27038,5 @@ var Background = /*#__PURE__*/Object.assign(BackgroundComponent, {
25984
27038
  });
25985
27039
  Background.displayName = 'Background';
25986
27040
 
25987
- export { Accordion, Alert, ArrowIcon, AspectRatio, AttachmentIcon, Avatar, Background, Badge, BatteryIcon, BluetoothIcon, BoldArrowIcon, BookmarkIcon, Button, CalendarIcon, CameraIcon, Card, Carousel, Chart, ChartIcon, ChatInput, CheckIcon, Checkbox, ChevronIcon, ClockIcon, CloseEyeIcon, CloseIcon, CloudIcon, ColorInput, ColorPicker, ComboBox, Command, ContextMenu, CookieConsent, CopyIcon, CountryPicker, CropIcon, DatePicker, DeleteIcon, Divider, DocumentIcon, DownloadIcon, DragAndDrop, DragAndDropComponent, DragHandleIcon, DragHandleLinesIcon, DropdownMenu, DustBinIcon, EditIcon, EmojiPicker, ErrorIcon, ExternalLinkIcon, FacebookIcon, FileIcon, FileImage, FileSVG, FilterIcon, Flow, FolderIcon, FormikCheckbox, FormikColorInput, FormikComboBox, FormikCountryPicker, FormikDatePicker, FormikForm, FormikOTPInput, FormikPassword, FormikSelect, FormikSlider, FormikSwitch, FormikTextArea, FormikTextField, GiftIcon, HeartIcon, HelpIcon, HomeIcon, HoverCard, Icon, ImageIcon, InfoIcon, InstagramIcon, LikeIcon, Link, LinkedinIcon, Loader, LoadingSpinnerIcon, LocationIcon, LockIcon, LogoutIcon, MagicWandIcon, MenuIcon, Menubar, MessageLayout, MessageView, MicrophoneIcon, MinusIcon, Modal, MoonIcon, NavigationMenu, NotificationIcon, OTPInput, OpenEyeIcon, Pagination, PanelIcon, Password, PauseIcon, PlayIcon, PlusIcon, PowerOffIcon, PrintIcon, ProfileIcon, RefreshIcon, Resizable, RotateIcon, SaveIcon, SearchIcon, Select, SendIcon, Separator, SettingsIcon, ShapeIcon, ShareIcon, ShieldIcon, Sidebar, Slider, SliderIcon, SpinnerIcon, StarIcon, StopIcon, SuccessIcon, Switch, Table, Tabs, Text, TextArea, TextField, TextIcon, ThreadsIcon, TickIcon, Title, Toast, Toggle, ToggleGroup, Tooltip, TrashIcon, Tree, TwitchIcon, TwitterIcon, UnLikeIcon, UnlockIcon, UploadIcon, Uploader, UserIcon, VideoIcon, WarningIcon, WifiIcon, XIcon, YoutubeIcon, ZoomInIcon, ZoomOutIcon, hideMessage, hideModal, showMessage, showModal, showToast, useMessageStore, useModalStore, useToast$1 as useToast };
27041
+ export { Accordion, Alert, ArrowIcon, AspectRatio, AttachmentIcon, Avatar, Background, Badge, BatteryIcon, BluetoothIcon, BoldArrowIcon, BookmarkIcon, Button, CalendarIcon, CameraIcon, Card, Carousel, Chart, ChartIcon, ChatInput, CheckIcon, Checkbox, ChevronIcon, ClockIcon, CloseEyeIcon, CloseIcon, CloudIcon, ColorInput, ColorPicker, ComboBox, Command, ContextMenu, CookieConsent, CopyIcon, CountryPicker, CropIcon, DatePicker, DeleteIcon, Divider, DocumentIcon, DownloadIcon, DragAndDrop, DragAndDropComponent, DragHandleIcon, DragHandleLinesIcon, DropdownMenu, DustBinIcon, EditIcon, EmojiPicker, ErrorIcon, ExternalLinkIcon, FacebookIcon, FileIcon, FileImage, FileSVG, FilterIcon, Flow, FolderIcon, FormikCheckbox, FormikColorInput, FormikComboBox, FormikCountryPicker, FormikDatePicker, FormikForm, FormikOTPInput, FormikPassword, FormikSelect, FormikSlider, FormikSwitch, FormikTextArea, FormikTextField, GiftIcon, HeartIcon, HelpIcon, HomeIcon, HoverCard, Icon, ImageIcon, InfoIcon, InstagramIcon, LikeIcon, Link, LinkedinIcon, Loader, LoadingSpinnerIcon, LocationIcon, LockIcon, LogoutIcon, MagicWandIcon, MenuIcon, Menubar, MessageLayout, MessageView, MicrophoneIcon, MinusIcon, Modal, MoonIcon, NavigationMenu, NotificationIcon, OTPInput, OpenEyeIcon, Pagination, PanelIcon, Password, PauseIcon, PlayIcon, PlusIcon, PowerOffIcon, PrintIcon, ProfileIcon, RefreshIcon, Resizable, RotateIcon, SaveIcon, SearchIcon, Select, SendIcon, Separator, SettingsIcon, ShapeIcon, ShareIcon, ShieldIcon, Sidebar, Slider, SliderIcon, SpinnerIcon, StarIcon, StopIcon, SuccessIcon, Switch, Table, Tabs, TagInput, Text, TextArea, TextField, TextIcon, ThreadsIcon, TickIcon, Title, Toast, Toggle, ToggleGroup, Tooltip, TrashIcon, Tree, TwitchIcon, TwitterIcon, UnLikeIcon, UnlockIcon, UploadIcon, Uploader, UserIcon, VideoIcon, WarningIcon, WifiIcon, XIcon, YoutubeIcon, ZoomInIcon, ZoomOutIcon, hideMessage, hideModal, showMessage, showModal, showToast, useMessageStore, useModalStore, useToast$1 as useToast };
25988
27042
  //# sourceMappingURL=web.esm.js.map