@app-studio/web 0.9.7 → 0.9.9

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
@@ -25,6 +25,7 @@ require('core-js/modules/es.array.reduce.js');
25
25
  require('core-js/modules/es.number.to-fixed.js');
26
26
  require('core-js/modules/es.string.starts-with.js');
27
27
  var format = _interopDefault(require('date-fns/format'));
28
+ require('core-js/modules/es.string.trim.js');
28
29
  require('core-js/modules/es.regexp.constructor.js');
29
30
  require('core-js/modules/es.regexp.exec.js');
30
31
  var formik = require('formik');
@@ -37,7 +38,6 @@ require('core-js/modules/es.string.match.js');
37
38
  require('core-js/modules/es.string.search.js');
38
39
  require('core-js/modules/es.array.flat-map.js');
39
40
  require('core-js/modules/es.array.unscopables.flat-map.js');
40
- require('core-js/modules/es.string.trim.js');
41
41
 
42
42
  function _objectWithoutPropertiesLoose(r, e) {
43
43
  if (null == r) return {};
@@ -6417,60 +6417,8 @@ var ContextMenuItemStates = {
6417
6417
  cursor: 'not-allowed'
6418
6418
  }
6419
6419
  };
6420
- // Helper function to calculate position based on available space
6421
- var calculateMenuPosition = function calculateMenuPosition(x, y, menuWidth, menuHeight, windowWidth, windowHeight, side, align) {
6422
- if (side === void 0) {
6423
- side = 'right';
6424
- }
6425
- if (align === void 0) {
6426
- align = 'start';
6427
- }
6428
- var posX = x;
6429
- var posY = y;
6430
- // Adjust horizontal position based on side
6431
- if (side === 'left') {
6432
- posX = x - menuWidth;
6433
- } else if (side === 'right') {
6434
- posX = x;
6435
- } else if (side === 'top' || side === 'bottom') {
6436
- // Adjust horizontal position based on alignment for top/bottom
6437
- if (align === 'center') {
6438
- posX = x - menuWidth / 2;
6439
- } else if (align === 'end') {
6440
- posX = x - menuWidth;
6441
- }
6442
- }
6443
- // Adjust vertical position based on side
6444
- if (side === 'top') {
6445
- posY = y - menuHeight;
6446
- } else if (side === 'bottom') {
6447
- posY = y;
6448
- } else if (side === 'left' || side === 'right') {
6449
- // Adjust vertical position based on alignment for left/right
6450
- if (align === 'center') {
6451
- posY = y - menuHeight / 2;
6452
- } else if (align === 'end') {
6453
- posY = y - menuHeight;
6454
- }
6455
- }
6456
- // Ensure menu stays within window bounds
6457
- if (posX + menuWidth > windowWidth) {
6458
- posX = windowWidth - menuWidth;
6459
- }
6460
- if (posX < 0) {
6461
- posX = 0;
6462
- }
6463
- if (posY + menuHeight > windowHeight) {
6464
- posY = windowHeight - menuHeight;
6465
- }
6466
- if (posY < 0) {
6467
- posY = 0;
6468
- }
6469
- return {
6470
- x: posX,
6471
- y: posY
6472
- };
6473
- };
6420
+ // Note: Manual positioning logic has been replaced with intelligent positioning
6421
+ // using viewport-aware algorithms in the ContextMenu component
6474
6422
 
6475
6423
  var _excluded$f = ["children", "disableNativeContextMenu", "asChild", "isDisabled", "views"],
6476
6424
  _excluded2$6 = ["items", "children", "position", "side", "align", "views", "style"],
@@ -6591,28 +6539,72 @@ var ContextMenuContent = _ref3 => {
6591
6539
  variant
6592
6540
  } = useContextMenuContext();
6593
6541
  var menuRef = React.useRef(null);
6542
+ // Use contentRef if provided, otherwise use local menuRef
6543
+ var ref = contentRef || menuRef;
6544
+ // Use useElementPosition for intelligent positioning
6545
+ var {
6546
+ ref: positionRef,
6547
+ relation
6548
+ } = appStudio.useElementPosition({
6549
+ // trackChanges: true,
6550
+ // trackOnHover: false,
6551
+ // trackOnScroll: true,
6552
+ // trackOnResize: true,
6553
+ // throttleMs: 50,
6554
+ });
6594
6555
  var [menuPosition, setMenuPosition] = React.useState({
6595
6556
  x: 0,
6596
6557
  y: 0
6597
6558
  });
6598
- // Use contentRef if provided, otherwise use local menuRef
6599
- var ref = contentRef || menuRef;
6600
- // Calculate the position of the menu
6559
+ // Calculate the position of the menu using useElementPosition
6601
6560
  React.useEffect(() => {
6602
6561
  if (isOpen && ref.current) {
6562
+ var pos = position || contextPosition;
6603
6563
  var menuWidth = ref.current.offsetWidth;
6604
6564
  var menuHeight = ref.current.offsetHeight;
6605
- var windowWidth = window.innerWidth;
6606
- var windowHeight = window.innerHeight;
6607
- var pos = position || contextPosition;
6608
- var calculatedPosition = calculateMenuPosition(pos.x, pos.y, menuWidth, menuHeight, windowWidth, windowHeight, side, align);
6609
- setMenuPosition(calculatedPosition);
6565
+ // Get viewport dimensions for boundary checking
6566
+ var viewportWidth = window.innerWidth;
6567
+ var viewportHeight = window.innerHeight;
6568
+ // Calculate optimal position based on available space
6569
+ var finalX = pos.x;
6570
+ var finalY = pos.y;
6571
+ // Use relation data if available for smarter positioning
6572
+ if (relation) {
6573
+ // Position based on where there's more space
6574
+ if (relation.space.horizontal === 'left') {
6575
+ finalX = pos.x - menuWidth;
6576
+ } else {
6577
+ finalX = pos.x;
6578
+ }
6579
+ if (relation.space.vertical === 'top') {
6580
+ finalY = pos.y - menuHeight;
6581
+ } else {
6582
+ finalY = pos.y;
6583
+ }
6584
+ }
6585
+ // Ensure the menu stays within viewport bounds
6586
+ if (finalX + menuWidth > viewportWidth) {
6587
+ finalX = viewportWidth - menuWidth - 8; // 8px margin
6588
+ }
6589
+ if (finalX < 8) {
6590
+ finalX = 8; // 8px margin
6591
+ }
6592
+ if (finalY + menuHeight > viewportHeight) {
6593
+ finalY = viewportHeight - menuHeight - 8; // 8px margin
6594
+ }
6595
+ if (finalY < 8) {
6596
+ finalY = 8; // 8px margin
6597
+ }
6598
+ setMenuPosition({
6599
+ x: finalX,
6600
+ y: finalY
6601
+ });
6610
6602
  }
6611
- }, [isOpen, contextPosition, position, side, align, ref]);
6603
+ }, [isOpen, contextPosition, position, side, align, ref, relation]);
6612
6604
  if (!isOpen) {
6613
6605
  return null;
6614
6606
  }
6615
- // Basic positioning - place top-left corner at calculated position
6607
+ // Intelligent positioning - place at calculated optimal position
6616
6608
  var positionStyles = {
6617
6609
  position: 'fixed',
6618
6610
  top: menuPosition.y + "px",
@@ -6665,7 +6657,6 @@ var ContextMenuItem = _ref4 => {
6665
6657
  var [isHovered, setIsHovered] = React.useState(false);
6666
6658
  var hasSubmenu = item.items && item.items.length > 0;
6667
6659
  var isSubmenuActive = activeSubmenuId === item.id;
6668
- var itemRef = React.useRef(null);
6669
6660
  var [submenuPosition, setSubmenuPosition] = React.useState({
6670
6661
  x: 0,
6671
6662
  y: 0
@@ -6690,16 +6681,40 @@ var ContextMenuItem = _ref4 => {
6690
6681
  if (closeMenu) closeMenu();
6691
6682
  }
6692
6683
  };
6693
- // Calculate the position of the submenu
6684
+ // Use useElementPosition for submenu positioning
6685
+ var {
6686
+ ref: itemRef,
6687
+ relation: submenuRelation
6688
+ } = appStudio.useElementPosition({
6689
+ // trackChanges: true,
6690
+ // trackOnHover: false,
6691
+ // trackOnScroll: true,
6692
+ // trackOnResize: true,
6693
+ // throttleMs: 50,
6694
+ });
6695
+ // Calculate the position of the submenu with intelligent positioning
6694
6696
  React.useEffect(() => {
6695
6697
  if (isSubmenuActive && itemRef.current) {
6696
6698
  var rect = itemRef.current.getBoundingClientRect();
6699
+ var viewportWidth = window.innerWidth;
6700
+ // Estimate submenu dimensions (will be refined when submenu renders)
6701
+ var estimatedSubmenuWidth = 200; // Default submenu width
6702
+ // Use relation data for smarter positioning if available
6703
+ var useLeftSide = false;
6704
+ if (submenuRelation) {
6705
+ useLeftSide = submenuRelation.space.horizontal === 'left';
6706
+ } else {
6707
+ // Fallback to manual calculation
6708
+ var rightSpace = viewportWidth - rect.right;
6709
+ var leftSpace = rect.left;
6710
+ useLeftSide = rightSpace < estimatedSubmenuWidth && leftSpace > rightSpace;
6711
+ }
6697
6712
  setSubmenuPosition({
6698
- x: rect.right,
6713
+ x: useLeftSide ? rect.left - estimatedSubmenuWidth : rect.right,
6699
6714
  y: rect.top
6700
6715
  });
6701
6716
  }
6702
- }, [isSubmenuActive]);
6717
+ }, [isSubmenuActive, item.items, submenuRelation]);
6703
6718
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
6704
6719
  ref: itemRef,
6705
6720
  role: "menuitem",
@@ -6993,7 +7008,7 @@ var HelperText = _ref => {
6993
7008
  };
6994
7009
 
6995
7010
  var _excluded$j = ["children", "helperText", "error", "views"];
6996
- var FieldContainer = _ref => {
7011
+ var FieldContainer = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
6997
7012
  var {
6998
7013
  children,
6999
7014
  helperText,
@@ -7001,9 +7016,8 @@ var FieldContainer = _ref => {
7001
7016
  views
7002
7017
  } = _ref,
7003
7018
  props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
7004
- return /*#__PURE__*/React__default.createElement(appStudio.Vertical
7005
- // Layout properties
7006
- , Object.assign({
7019
+ return /*#__PURE__*/React__default.createElement(appStudio.Vertical, Object.assign({
7020
+ ref: ref,
7007
7021
  // Layout properties
7008
7022
  gap: 8,
7009
7023
  position: "relative",
@@ -7019,7 +7033,8 @@ var FieldContainer = _ref => {
7019
7033
  color: "color.red.500",
7020
7034
  transition: "all 0.2s ease"
7021
7035
  }, views == null ? void 0 : views.error), error)));
7022
- };
7036
+ });
7037
+ FieldContainer.displayName = 'FieldContainer';
7023
7038
 
7024
7039
  /**
7025
7040
  * Input Styles
@@ -7610,6 +7625,47 @@ var SelectView = _ref7 => {
7610
7625
  highlightedIndex
7611
7626
  } = _ref7,
7612
7627
  props = _objectWithoutPropertiesLoose(_ref7, _excluded4$6);
7628
+ var {
7629
+ ref: triggerRef,
7630
+ relation,
7631
+ updateRelation
7632
+ } = appStudio.useElementPosition({
7633
+ trackChanges: true,
7634
+ throttleMs: 100
7635
+ });
7636
+ var dropdownRef = React.useRef(null);
7637
+ // Get optimal positioning style based on available space
7638
+ var getDropdownStyle = () => {
7639
+ if (!relation) {
7640
+ // Default positioning when relation is not available
7641
+ return {
7642
+ position: 'absolute',
7643
+ top: '100%',
7644
+ marginTop: '8px',
7645
+ left: 0,
7646
+ right: 0,
7647
+ zIndex: 10000
7648
+ };
7649
+ }
7650
+ var baseStyle = {
7651
+ position: 'absolute',
7652
+ left: 0,
7653
+ right: 0,
7654
+ zIndex: 10000
7655
+ };
7656
+ // Place dropdown where there's more space vertically
7657
+ if (relation.space.vertical === 'top') {
7658
+ return Object.assign({}, baseStyle, {
7659
+ bottom: '100%',
7660
+ marginBottom: '8px'
7661
+ });
7662
+ } else {
7663
+ return Object.assign({}, baseStyle, {
7664
+ top: '100%',
7665
+ marginTop: '8px'
7666
+ });
7667
+ }
7668
+ };
7613
7669
  // close when *any* other select opens
7614
7670
  React__default.useEffect(() => {
7615
7671
  var handleCloseAll = () => setHide(true);
@@ -7668,11 +7724,10 @@ var SelectView = _ref7 => {
7668
7724
  }
7669
7725
  };
7670
7726
  return /*#__PURE__*/React__default.createElement(FieldContainer, {
7671
- style: {
7672
- position: 'relative',
7673
- width: '100%',
7674
- display: 'inline-block'
7675
- },
7727
+ ref: triggerRef,
7728
+ position: "relative",
7729
+ width: "100%",
7730
+ display: "inline-block",
7676
7731
  id: id,
7677
7732
  role: "SelectBox",
7678
7733
  helperText: helperText,
@@ -7702,7 +7757,8 @@ var SelectView = _ref7 => {
7702
7757
  isFocused: isFocused,
7703
7758
  showLabel: showLabel,
7704
7759
  onMouseEnter: handleHover,
7705
- onMouseLeave: handleHover
7760
+ onMouseLeave: handleHover,
7761
+ position: "relative"
7706
7762
  }, /*#__PURE__*/React__default.createElement(FieldWrapper, null, showLabel && (/*#__PURE__*/React__default.createElement(FieldLabel, Object.assign({
7707
7763
  htmlFor: id,
7708
7764
  color: 'theme.primary',
@@ -7735,15 +7791,10 @@ var SelectView = _ref7 => {
7735
7791
  orientation: "up",
7736
7792
  widthHeight: IconSizes$2[size],
7737
7793
  style: views.icon
7738
- })))))), !hide && options.length > 0 && (/*#__PURE__*/React__default.createElement(appStudio.Element, {
7794
+ }))))), !hide && options.length > 0 && (/*#__PURE__*/React__default.createElement(appStudio.Element, {
7795
+ ref: dropdownRef,
7739
7796
  onClick: e => e.stopPropagation(),
7740
- style: {
7741
- position: 'absolute',
7742
- top: 'calc(100% + 4px)',
7743
- left: 0,
7744
- right: 0,
7745
- zIndex: 1000
7746
- }
7797
+ style: getDropdownStyle()
7747
7798
  }, /*#__PURE__*/React__default.createElement(DropDown, {
7748
7799
  size: size,
7749
7800
  views: Object.assign({}, views, {
@@ -7760,7 +7811,7 @@ var SelectView = _ref7 => {
7760
7811
  callback: handleCallback,
7761
7812
  highlightedIndex: highlightedIndex,
7762
7813
  setHighlightedIndex: setHighlightedIndex
7763
- }))));
7814
+ })))));
7764
7815
  };
7765
7816
 
7766
7817
  // Defines a functional component named 'SelectComponent', which is expected to receive 'SelectProps' as properties.
@@ -11185,6 +11236,45 @@ var ComboBoxView = _ref => {
11185
11236
  // Collects all further props not destructured explicitly.
11186
11237
  } = _ref,
11187
11238
  props = _objectWithoutPropertiesLoose(_ref, _excluded$y);
11239
+ var {
11240
+ ref: triggerRef,
11241
+ relation
11242
+ } = appStudio.useElementPosition();
11243
+ var dropdownRef = React.useRef(null);
11244
+ // Get optimal positioning style based on available space
11245
+ var getDropdownStyle = () => {
11246
+ if (!relation) {
11247
+ // Default positioning when relation is not available
11248
+ return {
11249
+ position: 'absolute',
11250
+ top: '100%',
11251
+ marginTop: '8px',
11252
+ left: 0,
11253
+ right: 0,
11254
+ zIndex: 10000,
11255
+ maxHeight: '240px'
11256
+ };
11257
+ }
11258
+ var baseStyle = {
11259
+ position: 'absolute',
11260
+ left: 0,
11261
+ right: 0,
11262
+ zIndex: 10000,
11263
+ maxHeight: '240px'
11264
+ };
11265
+ // Place dropdown where there's more space vertically
11266
+ if (relation.space.vertical === 'top') {
11267
+ return Object.assign({}, baseStyle, {
11268
+ bottom: '100%',
11269
+ marginBottom: '8px'
11270
+ });
11271
+ } else {
11272
+ return Object.assign({}, baseStyle, {
11273
+ top: '100%',
11274
+ marginTop: '8px'
11275
+ });
11276
+ }
11277
+ };
11188
11278
  // Sets up an effect to handle clicking outside the dropdown to close it.
11189
11279
  React.useEffect(() => {
11190
11280
  var handleClickOutside = event => {
@@ -11227,6 +11317,7 @@ var ComboBoxView = _ref => {
11227
11317
  }, label)), /*#__PURE__*/React__default.createElement(appStudio.View, {
11228
11318
  position: "relative"
11229
11319
  }, /*#__PURE__*/React__default.createElement(appStudio.Horizontal, Object.assign({
11320
+ ref: triggerRef,
11230
11321
  cursor: "pointer",
11231
11322
  backgroundColor: "color.white",
11232
11323
  boxShadow: "rgba(0, 0, 0, 0.16) 0px 1px 4px",
@@ -11247,19 +11338,14 @@ var ComboBoxView = _ref => {
11247
11338
  weight: "medium",
11248
11339
  flexGrow: 1,
11249
11340
  color: "color.gray.800"
11250
- }, views == null ? void 0 : views.label), selectedItem.label)), right, isDropdownVisible && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
11341
+ }, views == null ? void 0 : views.label), selectedItem.label)), right), isDropdownVisible && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
11342
+ ref: dropdownRef,
11251
11343
  id: "combobox-dropdown",
11252
- position: "absolute",
11253
11344
  backgroundColor: "color.white",
11254
- boxShadow: "rgba(0, 0 ,0 ,0.16) 0px 1px 4px",
11255
- width: "100%",
11345
+ boxShadow: "rgba(0, 0, 0, 0.16) 0px 1px 4px",
11256
11346
  overflowY: "auto",
11257
- zIndex: 10000,
11258
- bottom: -8,
11259
- left: 0,
11260
- transform: "translateY(100%)",
11261
- marginTop: "4px",
11262
- borderRadius: "4px"
11347
+ borderRadius: "4px",
11348
+ style: getDropdownStyle()
11263
11349
  }, views == null ? void 0 : views.dropdown), searchEnabled && (/*#__PURE__*/React__default.createElement(TextFieldView, {
11264
11350
  id: props.id,
11265
11351
  name: props.name,
@@ -11293,7 +11379,7 @@ var ComboBoxView = _ref => {
11293
11379
  onClick: () => handleSelect(item)
11294
11380
  }, views == null ? void 0 : views.item), /*#__PURE__*/React__default.createElement(Text, null, item.label), /*#__PURE__*/React__default.createElement(React__default.Fragment, null, item.icon && item.icon, item.value === selectedItem.value && showTick && !item.icon && /*#__PURE__*/React__default.createElement(TickIcon, {
11295
11381
  widthHeight: 20
11296
- }))))))))))));
11382
+ })))))))))));
11297
11383
  };
11298
11384
 
11299
11385
  var _excluded$z = ["id", "name", "items", "placeholder", "searchPlaceholder"];
@@ -11328,136 +11414,547 @@ var ComboBoxComponent = _ref => {
11328
11414
  // Exports the ComboBoxComponent as ComboBox
11329
11415
  var ComboBox = ComboBoxComponent;
11330
11416
 
11331
- function syncTimeouts(cb) {
11332
- var t1 = setTimeout(cb, 0); // For faster machines
11333
- var t2 = setTimeout(cb, 10);
11334
- var t3 = setTimeout(cb, 50);
11335
- return [t1, t2, t3];
11336
- }
11337
-
11338
- var useOTPInputState = _ref => {
11339
- var _window;
11340
- var {
11341
- value: controlledValue,
11342
- defaultValue = '',
11343
- length = 6,
11344
- onChange,
11345
- onChangeText,
11346
- onComplete,
11347
- onKeyDown,
11348
- onKeyPress,
11349
- onBlur,
11350
- onFocus,
11351
- isReadOnly,
11352
- isDisabled,
11353
- pattern,
11354
- stepValues,
11355
- pasteTransformer
11356
- } = _ref;
11357
- // Determine if component is controlled
11358
- var isControlled = controlledValue !== undefined;
11359
- var initialValue = isControlled ? controlledValue : defaultValue;
11360
- // State for the OTP value
11361
- var [value, setInternalValue] = React.useState((initialValue == null ? void 0 : initialValue.slice(0, length)) || '');
11417
+ /**
11418
+ * Custom hook for managing TagInput state
11419
+ */
11420
+ var useTagInputState = props => {
11421
+ var {
11422
+ tags: controlledTags,
11423
+ defaultTags = [],
11424
+ onTagsChange,
11425
+ onTagAdd,
11426
+ onTagRemove,
11427
+ maxTags,
11428
+ minTagLength = 1,
11429
+ maxTagLength = 50,
11430
+ allowDuplicates = false,
11431
+ separators = ['enter', 'comma'],
11432
+ isDisabled = false,
11433
+ isReadOnly = false
11434
+ } = props;
11435
+ // State for input value
11436
+ var [inputValue, setInputValue] = React.useState('');
11437
+ // State for tags (controlled vs uncontrolled)
11438
+ var [internalTags, setInternalTags] = React.useState(() => {
11439
+ var initialValue = controlledTags || defaultTags || [];
11440
+ return initialValue.map((tag, index) => ({
11441
+ id: "tag-" + index + "-" + Date.now(),
11442
+ value: tag
11443
+ }));
11444
+ });
11362
11445
  // State for focus and hover
11363
11446
  var [isFocused, setIsFocused] = React.useState(false);
11364
11447
  var [isHovered, setIsHovered] = React.useState(false);
11365
- // State for selection tracking
11366
- var [mirrorSelectionStart, setMirrorSelectionStart] = React.useState(null);
11367
- var [mirrorSelectionEnd, setMirrorSelectionEnd] = React.useState(null);
11368
- // Refs
11369
- var inputRef = React.useRef(null);
11370
- var containerRef = React.useRef(null);
11371
- var initialLoadRef = React.useRef({
11372
- value,
11373
- onChange: onChange || (() => {}),
11374
- isIOS: typeof window !== 'undefined' && ((_window = window) == null || (_window = _window.CSS) == null || _window.supports == null ? void 0 : _window.supports('-webkit-touch-callout', 'none'))
11375
- });
11376
- var inputMetadataRef = React.useRef({
11377
- prev: [null, null, 'none']
11378
- });
11379
- // Create regexp for validation
11380
- var regexp = pattern ? typeof pattern === 'string' ? new RegExp(pattern) : pattern : null;
11381
- // Sync with controlled value
11448
+ // Use controlled value if provided, otherwise use internal state
11449
+ var tags = controlledTags && Array.isArray(controlledTags) ? controlledTags.map((tag, index) => ({
11450
+ id: "tag-" + index + "-" + Date.now(),
11451
+ value: tag
11452
+ })) : internalTags;
11453
+ // Update internal tags when controlled value changes
11382
11454
  React.useEffect(() => {
11383
- if (isControlled && controlledValue !== value) {
11384
- setInternalValue((controlledValue == null ? void 0 : controlledValue.slice(0, length)) || '');
11455
+ if (controlledTags && Array.isArray(controlledTags)) {
11456
+ setInternalTags(controlledTags.map((tag, index) => ({
11457
+ id: "tag-" + index + "-" + Date.now(),
11458
+ value: tag
11459
+ })));
11385
11460
  }
11386
- }, [isControlled, controlledValue, length, value]);
11387
- // Handle value changes with completion check
11388
- var setValue = React.useCallback(newValue => {
11389
- // If step values are provided, find the closest step
11390
- var valueToSet = newValue;
11391
- if (stepValues && stepValues.length > 0 && newValue) {
11392
- // Convert to number for comparison
11393
- var numValue = parseInt(newValue, 10);
11394
- if (!isNaN(numValue)) {
11395
- // Find the closest step value
11396
- var closest = stepValues[0];
11397
- var minDiff = Math.abs(numValue - closest);
11398
- for (var i = 1; i < stepValues.length; i++) {
11399
- var diff = Math.abs(numValue - stepValues[i]);
11400
- if (diff < minDiff) {
11401
- minDiff = diff;
11402
- closest = stepValues[i];
11403
- }
11404
- }
11405
- // Convert back to string
11406
- valueToSet = closest.toString();
11461
+ }, [controlledTags]);
11462
+ /**
11463
+ * Validates a tag before adding
11464
+ */
11465
+ var validateTag = React.useCallback(tag => {
11466
+ var trimmed = tag.trim();
11467
+ // Check length constraints
11468
+ if (trimmed.length < minTagLength || trimmed.length > maxTagLength) {
11469
+ return false;
11470
+ }
11471
+ // Check for duplicates if not allowed
11472
+ if (!allowDuplicates) {
11473
+ var tagValues = tags.map(t => t.value.toLowerCase());
11474
+ if (tagValues.includes(trimmed.toLowerCase())) {
11475
+ return false;
11407
11476
  }
11408
11477
  }
11409
- // Always update internal state for both controlled and uncontrolled components
11410
- setInternalValue(valueToSet);
11411
- // Call onChange if provided
11412
- if (onChange) {
11413
- onChange(valueToSet);
11478
+ // Check maximum tags limit
11479
+ if (maxTags && tags.length >= maxTags) {
11480
+ return false;
11414
11481
  }
11415
- // Call onChangeText if provided
11416
- if (onChangeText) {
11417
- onChangeText(valueToSet);
11482
+ return true;
11483
+ }, [tags, minTagLength, maxTagLength, allowDuplicates, maxTags]);
11484
+ /**
11485
+ * Adds a new tag
11486
+ */
11487
+ var addTag = React.useCallback(tag => {
11488
+ if (isDisabled || isReadOnly) return;
11489
+ var trimmed = tag.trim();
11490
+ if (!trimmed || !validateTag(trimmed)) return;
11491
+ var newTag = {
11492
+ id: "tag-" + Date.now() + "-" + Math.random(),
11493
+ value: trimmed
11494
+ };
11495
+ var newTags = [...tags, newTag];
11496
+ var tagValues = newTags.map(t => t.value);
11497
+ if (!controlledTags) {
11498
+ setInternalTags(newTags);
11499
+ }
11500
+ onTagsChange == null || onTagsChange(tagValues);
11501
+ onTagAdd == null || onTagAdd(trimmed);
11502
+ setInputValue('');
11503
+ }, [tags, validateTag, onTagsChange, onTagAdd, isDisabled, isReadOnly, controlledTags]);
11504
+ /**
11505
+ * Removes a tag by index
11506
+ */
11507
+ var removeTag = React.useCallback(index => {
11508
+ if (isDisabled || isReadOnly) return;
11509
+ var tagToRemove = tags[index];
11510
+ if (!tagToRemove) return;
11511
+ var newTags = tags.filter((_, i) => i !== index);
11512
+ var tagValues = newTags.map(t => t.value);
11513
+ if (!controlledTags) {
11514
+ setInternalTags(newTags);
11515
+ }
11516
+ onTagsChange == null || onTagsChange(tagValues);
11517
+ onTagRemove == null || onTagRemove(tagToRemove.value, index);
11518
+ }, [tags, onTagsChange, onTagRemove, isDisabled, isReadOnly, controlledTags]);
11519
+ /**
11520
+ * Handles input change
11521
+ */
11522
+ var handleInputChange = React.useCallback(event => {
11523
+ if (isDisabled || isReadOnly) return;
11524
+ var newValue = event.target.value;
11525
+ // Check for comma separator
11526
+ if (separators.includes('comma') && newValue.includes(',')) {
11527
+ var parts = newValue.split(',');
11528
+ var tagToAdd = parts[0];
11529
+ var remaining = parts.slice(1).join(',');
11530
+ if (tagToAdd.trim()) {
11531
+ addTag(tagToAdd);
11532
+ }
11533
+ setInputValue(remaining);
11534
+ return;
11418
11535
  }
11419
- // Check if the OTP is complete and call onComplete if provided
11420
- if (onComplete && valueToSet.length === length) {
11421
- onComplete(valueToSet);
11536
+ setInputValue(newValue);
11537
+ }, [addTag, separators, isDisabled, isReadOnly]);
11538
+ /**
11539
+ * Handles key down events
11540
+ */
11541
+ var handleKeyDown = React.useCallback(event => {
11542
+ if (isDisabled || isReadOnly) return;
11543
+ var {
11544
+ key
11545
+ } = event;
11546
+ // Handle Enter key
11547
+ if (separators.includes('enter') && key === 'Enter') {
11548
+ event.preventDefault();
11549
+ if (inputValue.trim()) {
11550
+ addTag(inputValue);
11551
+ }
11552
+ return;
11422
11553
  }
11423
- }, [onChange, onChangeText, onComplete, length, stepValues]);
11424
- // Set up input ref
11425
- var setInputRef = React.useCallback(ref => {
11426
- // We can't directly assign to inputRef.current, so we use this workaround
11427
- if (ref && inputRef.current !== ref) {
11428
- // Store the reference without directly assigning
11429
- Object.defineProperty(inputRef, 'current', {
11430
- value: ref,
11431
- writable: true
11432
- });
11554
+ // Handle Tab key
11555
+ if (separators.includes('tab') && key === 'Tab' && inputValue.trim()) {
11556
+ event.preventDefault();
11557
+ addTag(inputValue);
11558
+ return;
11433
11559
  }
11434
- }, []);
11435
- // Event handlers
11436
- var handleChange = React.useCallback(e => {
11437
- var newValue = e.currentTarget.value.slice(0, length);
11438
- if (newValue.length > 0 && regexp && !regexp.test(newValue)) {
11439
- e.preventDefault();
11560
+ // Handle Space key
11561
+ if (separators.includes('space') && key === ' ' && inputValue.trim()) {
11562
+ event.preventDefault();
11563
+ addTag(inputValue);
11440
11564
  return;
11441
11565
  }
11442
- // Always update the value
11443
- setValue(newValue);
11444
- // Update the input field value directly to ensure it's always in sync
11445
- if (inputRef.current) {
11446
- inputRef.current.value = newValue;
11566
+ // Handle Backspace to remove last tag
11567
+ if (key === 'Backspace' && !inputValue && tags.length > 0) {
11568
+ event.preventDefault();
11569
+ removeTag(tags.length - 1);
11570
+ return;
11447
11571
  }
11448
- }, [length, regexp, setValue, inputRef]);
11572
+ }, [addTag, removeTag, inputValue, tags, separators, isDisabled, isReadOnly]);
11573
+ /**
11574
+ * Handles input focus
11575
+ */
11449
11576
  var handleFocus = React.useCallback(() => {
11450
- if (inputRef.current) {
11451
- var _inputRef$current;
11452
- var start = Math.min(inputRef.current.value.length, length - 1);
11453
- var end = inputRef.current.value.length;
11454
- (_inputRef$current = inputRef.current) == null || _inputRef$current.setSelectionRange(start, end);
11455
- setMirrorSelectionStart(start);
11456
- setMirrorSelectionEnd(end);
11457
- }
11458
11577
  setIsFocused(true);
11459
- }, [length]);
11460
- var handleBlur = React.useCallback(() => {
11578
+ props.onFocus == null || props.onFocus();
11579
+ }, [props.onFocus]);
11580
+ /**
11581
+ * Handles input blur
11582
+ */
11583
+ var handleBlur = React.useCallback(() => {
11584
+ setIsFocused(false);
11585
+ // Add current input value as tag on blur if it exists
11586
+ if (inputValue.trim()) {
11587
+ addTag(inputValue);
11588
+ }
11589
+ props.onBlur == null || props.onBlur();
11590
+ }, [addTag, inputValue, props.onBlur]);
11591
+ return {
11592
+ inputValue,
11593
+ setInputValue,
11594
+ tags,
11595
+ setTags: setInternalTags,
11596
+ isFocused,
11597
+ setIsFocused,
11598
+ isHovered,
11599
+ setIsHovered,
11600
+ addTag,
11601
+ removeTag,
11602
+ handleInputChange,
11603
+ handleKeyDown,
11604
+ handleFocus,
11605
+ handleBlur,
11606
+ validateTag
11607
+ };
11608
+ };
11609
+
11610
+ 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"];
11611
+ /**
11612
+ * Individual tag chip component
11613
+ */
11614
+ var TagChip = _ref => {
11615
+ var {
11616
+ tag,
11617
+ onRemove,
11618
+ isRemovable,
11619
+ size,
11620
+ views,
11621
+ isDisabled,
11622
+ isReadOnly
11623
+ } = _ref;
11624
+ var {
11625
+ getColor
11626
+ } = appStudio.useTheme();
11627
+ var chipSize = {
11628
+ xs: {
11629
+ padding: '2px 6px',
11630
+ fontSize: '10px',
11631
+ iconSize: 10
11632
+ },
11633
+ sm: {
11634
+ padding: '4px 8px',
11635
+ fontSize: '12px',
11636
+ iconSize: 12
11637
+ },
11638
+ md: {
11639
+ padding: '6px 10px',
11640
+ fontSize: '14px',
11641
+ iconSize: 14
11642
+ },
11643
+ lg: {
11644
+ padding: '8px 12px',
11645
+ fontSize: '16px',
11646
+ iconSize: 16
11647
+ },
11648
+ xl: {
11649
+ padding: '10px 14px',
11650
+ fontSize: '18px',
11651
+ iconSize: 18
11652
+ }
11653
+ }[size] || {
11654
+ padding: '6px 10px',
11655
+ fontSize: '14px',
11656
+ iconSize: 14
11657
+ };
11658
+ return /*#__PURE__*/React__default.createElement(appStudio.Horizontal, Object.assign({
11659
+ alignItems: "center",
11660
+ gap: 4,
11661
+ padding: chipSize.padding,
11662
+ backgroundColor: "color.gray.100",
11663
+ borderRadius: "16px",
11664
+ border: "1px solid",
11665
+ borderColor: "color.gray.200",
11666
+ transition: "all 0.2s ease",
11667
+ opacity: isDisabled ? 0.6 : 1,
11668
+ _hover: !isDisabled && !isReadOnly ? {
11669
+ backgroundColor: 'color.gray.200',
11670
+ borderColor: 'color.gray.300'
11671
+ } : {}
11672
+ }, views == null ? void 0 : views.tag), /*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({
11673
+ fontSize: chipSize.fontSize,
11674
+ color: isDisabled ? 'color.gray.400' : 'color.gray.700',
11675
+ fontWeight: "500",
11676
+ whiteSpace: "nowrap"
11677
+ }, views == null ? void 0 : views.tagText), tag), isRemovable && !isDisabled && !isReadOnly && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
11678
+ cursor: "pointer",
11679
+ padding: "2px",
11680
+ borderRadius: "50%",
11681
+ transition: "all 0.2s ease",
11682
+ _hover: {
11683
+ backgroundColor: 'color.gray.300'
11684
+ },
11685
+ onClick: onRemove
11686
+ }, views == null ? void 0 : views.tagRemove), /*#__PURE__*/React__default.createElement(CloseIcon, {
11687
+ widthHeight: chipSize.iconSize,
11688
+ color: "color.gray.500"
11689
+ }))));
11690
+ };
11691
+ /**
11692
+ * Main TagInput view component
11693
+ */
11694
+ var TagInputView = _ref2 => {
11695
+ var {
11696
+ id,
11697
+ name,
11698
+ label,
11699
+ placeholder = 'Type and press Enter to add tags...',
11700
+ helperText,
11701
+ error = false,
11702
+ inputValue = '',
11703
+ tags = [],
11704
+ left,
11705
+ right,
11706
+ shadow = {},
11707
+ views = {},
11708
+ size = 'md',
11709
+ shape = 'default',
11710
+ variant = 'default',
11711
+ isDisabled = false,
11712
+ isReadOnly = false,
11713
+ isAutoFocus = false,
11714
+ isRemovable = true,
11715
+ isFocused = false,
11716
+ isHovered = false,
11717
+ maxTags,
11718
+ handleInputChange,
11719
+ handleKeyDown,
11720
+ handleFocus,
11721
+ handleBlur,
11722
+ removeTag,
11723
+ setIsHovered,
11724
+ onClick
11725
+ } = _ref2,
11726
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$A);
11727
+ var {
11728
+ getColor,
11729
+ themeMode
11730
+ } = appStudio.useTheme();
11731
+ // Determine if we should show the label
11732
+ var showLabel = Boolean(label && (isFocused || tags.length > 0 || inputValue));
11733
+ // Calculate if max tags reached
11734
+ var isMaxReached = maxTags && tags.length >= maxTags;
11735
+ // Container styles
11736
+ var containerStyles = Object.assign({}, Shapes[shape], InputVariants[variant], views == null ? void 0 : views.inputContainer);
11737
+ // Input styles
11738
+ var inputStyles = Object.assign({
11739
+ border: 'none',
11740
+ outline: 'none',
11741
+ backgroundColor: 'transparent',
11742
+ fontSize: appStudio.Typography.fontSizes[size],
11743
+ color: isDisabled ? 'color.gray.400' : 'color.gray.900',
11744
+ flex: 1,
11745
+ minWidth: '120px'
11746
+ }, views == null ? void 0 : views.input);
11747
+ return /*#__PURE__*/React__default.createElement(FieldContainer, Object.assign({
11748
+ error: !!error,
11749
+ helperText: typeof error === 'string' ? error : helperText,
11750
+ views: views
11751
+ }, props), /*#__PURE__*/React__default.createElement(FieldContent, Object.assign({
11752
+ label: label,
11753
+ shadow: shadow,
11754
+ value: tags.length > 0 || inputValue ? 'has-content' : '',
11755
+ size: size,
11756
+ shape: shape,
11757
+ variant: variant,
11758
+ error: !!error,
11759
+ showLabel: showLabel,
11760
+ isFocused: isFocused,
11761
+ isHovered: isHovered,
11762
+ isDisabled: isDisabled,
11763
+ isReadOnly: isReadOnly,
11764
+ views: views,
11765
+ onClick: onClick,
11766
+ onMouseEnter: () => setIsHovered == null ? void 0 : setIsHovered(true),
11767
+ onMouseLeave: () => setIsHovered == null ? void 0 : setIsHovered(false)
11768
+ }, containerStyles), left, /*#__PURE__*/React__default.createElement(FieldWrapper, null, label && (/*#__PURE__*/React__default.createElement(FieldLabel, {
11769
+ size: size,
11770
+ error: !!error,
11771
+ views: views
11772
+ }, label)), /*#__PURE__*/React__default.createElement(appStudio.Horizontal, Object.assign({
11773
+ alignItems: "center",
11774
+ gap: 4,
11775
+ flexWrap: "wrap",
11776
+ width: "100%",
11777
+ minHeight: appStudio.Typography.fontSizes[size],
11778
+ padding: "8px 0"
11779
+ }, views == null ? void 0 : views.tagsContainer), tags.map((tag, index) => (/*#__PURE__*/React__default.createElement(TagChip, {
11780
+ key: tag.id,
11781
+ tag: tag.value,
11782
+ onRemove: () => removeTag == null ? void 0 : removeTag(index),
11783
+ isRemovable: isRemovable,
11784
+ size: size,
11785
+ views: views,
11786
+ isDisabled: isDisabled,
11787
+ isReadOnly: isReadOnly
11788
+ }))), !isMaxReached && (/*#__PURE__*/React__default.createElement(appStudio.Input, Object.assign({
11789
+ id: id,
11790
+ name: name,
11791
+ type: "text",
11792
+ value: inputValue,
11793
+ placeholder: tags.length === 0 ? placeholder : '',
11794
+ disabled: isDisabled,
11795
+ readOnly: isReadOnly,
11796
+ autoFocus: isAutoFocus,
11797
+ onChange: handleInputChange,
11798
+ onKeyDown: handleKeyDown,
11799
+ onFocus: handleFocus,
11800
+ onBlur: handleBlur,
11801
+ autoComplete: "off"
11802
+ }, inputStyles))), isMaxReached && (/*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({
11803
+ fontSize: appStudio.Typography.fontSizes[size],
11804
+ color: "color.gray.500",
11805
+ fontStyle: "italic"
11806
+ }, views == null ? void 0 : views.placeholder), "Maximum ", maxTags, " tags reached")))), right));
11807
+ };
11808
+
11809
+ var _excluded$B = ["tags"];
11810
+ /**
11811
+ * TagInput Component
11812
+ *
11813
+ * A form input component for managing a list of tags.
11814
+ * Users can add tags by typing and pressing Enter or comma,
11815
+ * and remove them by clicking the X button or using backspace.
11816
+ */
11817
+ var TagInputComponent = props => {
11818
+ // Initialize state management with the custom hook
11819
+ var tagInputState = useTagInputState(props);
11820
+ // Separate the tags prop to avoid type conflicts
11821
+ var restProps = _objectWithoutPropertiesLoose(props, _excluded$B);
11822
+ // Render the view component with combined props and state
11823
+ return /*#__PURE__*/React__default.createElement(TagInputView, Object.assign({}, tagInputState, restProps));
11824
+ };
11825
+ // Export the component
11826
+ var TagInput = TagInputComponent;
11827
+
11828
+ function syncTimeouts(cb) {
11829
+ var t1 = setTimeout(cb, 0); // For faster machines
11830
+ var t2 = setTimeout(cb, 10);
11831
+ var t3 = setTimeout(cb, 50);
11832
+ return [t1, t2, t3];
11833
+ }
11834
+
11835
+ var useOTPInputState = _ref => {
11836
+ var _window;
11837
+ var {
11838
+ value: controlledValue,
11839
+ defaultValue = '',
11840
+ length = 6,
11841
+ onChange,
11842
+ onChangeText,
11843
+ onComplete,
11844
+ onKeyDown,
11845
+ onKeyPress,
11846
+ onBlur,
11847
+ onFocus,
11848
+ isReadOnly,
11849
+ isDisabled,
11850
+ pattern,
11851
+ stepValues,
11852
+ pasteTransformer
11853
+ } = _ref;
11854
+ // Determine if component is controlled
11855
+ var isControlled = controlledValue !== undefined;
11856
+ var initialValue = isControlled ? controlledValue : defaultValue;
11857
+ // State for the OTP value
11858
+ var [value, setInternalValue] = React.useState((initialValue == null ? void 0 : initialValue.slice(0, length)) || '');
11859
+ // State for focus and hover
11860
+ var [isFocused, setIsFocused] = React.useState(false);
11861
+ var [isHovered, setIsHovered] = React.useState(false);
11862
+ // State for selection tracking
11863
+ var [mirrorSelectionStart, setMirrorSelectionStart] = React.useState(null);
11864
+ var [mirrorSelectionEnd, setMirrorSelectionEnd] = React.useState(null);
11865
+ // Refs
11866
+ var inputRef = React.useRef(null);
11867
+ var containerRef = React.useRef(null);
11868
+ var initialLoadRef = React.useRef({
11869
+ value,
11870
+ onChange: onChange || (() => {}),
11871
+ isIOS: typeof window !== 'undefined' && ((_window = window) == null || (_window = _window.CSS) == null || _window.supports == null ? void 0 : _window.supports('-webkit-touch-callout', 'none'))
11872
+ });
11873
+ var inputMetadataRef = React.useRef({
11874
+ prev: [null, null, 'none']
11875
+ });
11876
+ // Create regexp for validation
11877
+ var regexp = pattern ? typeof pattern === 'string' ? new RegExp(pattern) : pattern : null;
11878
+ // Sync with controlled value
11879
+ React.useEffect(() => {
11880
+ if (isControlled && controlledValue !== value) {
11881
+ setInternalValue((controlledValue == null ? void 0 : controlledValue.slice(0, length)) || '');
11882
+ }
11883
+ }, [isControlled, controlledValue, length, value]);
11884
+ // Handle value changes with completion check
11885
+ var setValue = React.useCallback(newValue => {
11886
+ // If step values are provided, find the closest step
11887
+ var valueToSet = newValue;
11888
+ if (stepValues && stepValues.length > 0 && newValue) {
11889
+ // Convert to number for comparison
11890
+ var numValue = parseInt(newValue, 10);
11891
+ if (!isNaN(numValue)) {
11892
+ // Find the closest step value
11893
+ var closest = stepValues[0];
11894
+ var minDiff = Math.abs(numValue - closest);
11895
+ for (var i = 1; i < stepValues.length; i++) {
11896
+ var diff = Math.abs(numValue - stepValues[i]);
11897
+ if (diff < minDiff) {
11898
+ minDiff = diff;
11899
+ closest = stepValues[i];
11900
+ }
11901
+ }
11902
+ // Convert back to string
11903
+ valueToSet = closest.toString();
11904
+ }
11905
+ }
11906
+ // Always update internal state for both controlled and uncontrolled components
11907
+ setInternalValue(valueToSet);
11908
+ // Call onChange if provided
11909
+ if (onChange) {
11910
+ onChange(valueToSet);
11911
+ }
11912
+ // Call onChangeText if provided
11913
+ if (onChangeText) {
11914
+ onChangeText(valueToSet);
11915
+ }
11916
+ // Check if the OTP is complete and call onComplete if provided
11917
+ if (onComplete && valueToSet.length === length) {
11918
+ onComplete(valueToSet);
11919
+ }
11920
+ }, [onChange, onChangeText, onComplete, length, stepValues]);
11921
+ // Set up input ref
11922
+ var setInputRef = React.useCallback(ref => {
11923
+ // We can't directly assign to inputRef.current, so we use this workaround
11924
+ if (ref && inputRef.current !== ref) {
11925
+ // Store the reference without directly assigning
11926
+ Object.defineProperty(inputRef, 'current', {
11927
+ value: ref,
11928
+ writable: true
11929
+ });
11930
+ }
11931
+ }, []);
11932
+ // Event handlers
11933
+ var handleChange = React.useCallback(e => {
11934
+ var newValue = e.currentTarget.value.slice(0, length);
11935
+ if (newValue.length > 0 && regexp && !regexp.test(newValue)) {
11936
+ e.preventDefault();
11937
+ return;
11938
+ }
11939
+ // Always update the value
11940
+ setValue(newValue);
11941
+ // Update the input field value directly to ensure it's always in sync
11942
+ if (inputRef.current) {
11943
+ inputRef.current.value = newValue;
11944
+ }
11945
+ }, [length, regexp, setValue, inputRef]);
11946
+ var handleFocus = React.useCallback(() => {
11947
+ if (inputRef.current) {
11948
+ var _inputRef$current;
11949
+ var start = Math.min(inputRef.current.value.length, length - 1);
11950
+ var end = inputRef.current.value.length;
11951
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.setSelectionRange(start, end);
11952
+ setMirrorSelectionStart(start);
11953
+ setMirrorSelectionEnd(end);
11954
+ }
11955
+ setIsFocused(true);
11956
+ }, [length]);
11957
+ var handleBlur = React.useCallback(() => {
11461
11958
  setIsFocused(false);
11462
11959
  }, []);
11463
11960
  var handleKeyDown = React.useCallback(_ => {
@@ -11634,7 +12131,7 @@ var useOTPInputState = _ref => {
11634
12131
  };
11635
12132
  };
11636
12133
 
11637
- 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"];
12134
+ 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"];
11638
12135
  // Create a context for OTP input slots
11639
12136
  var OTPInputContext = /*#__PURE__*/React.createContext({
11640
12137
  slots: [],
@@ -11688,7 +12185,7 @@ var OTPInputView = _ref => {
11688
12185
  onFocus = () => {}
11689
12186
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11690
12187
  } = _ref,
11691
- props = _objectWithoutPropertiesLoose(_ref, _excluded$A);
12188
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$C);
11692
12189
  appStudio.useTheme(); // Initialize theme context
11693
12190
  var showLabel = !!label;
11694
12191
  // Create context value for slots
@@ -11920,7 +12417,7 @@ var OTPInputComponent = props => {
11920
12417
  };
11921
12418
  var OTPInput = OTPInputComponent;
11922
12419
 
11923
- var _excluded$B = ["children", "autoFocus", "initFocus", "onChange"];
12420
+ var _excluded$D = ["children", "autoFocus", "initFocus", "onChange"];
11924
12421
  var FocusContext = /*#__PURE__*/React.createContext({
11925
12422
  active: false,
11926
12423
  focusNextInput: () => {},
@@ -11936,7 +12433,7 @@ var FormikForm = _ref => {
11936
12433
  initFocus,
11937
12434
  onChange = () => {}
11938
12435
  } = _ref,
11939
- props = _objectWithoutPropertiesLoose(_ref, _excluded$B);
12436
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$D);
11940
12437
  var formik$1 = formik.useFormikContext();
11941
12438
  React.useEffect(() => {
11942
12439
  onChange(formik$1.values);
@@ -11984,7 +12481,7 @@ var FormikForm = _ref => {
11984
12481
  }, /*#__PURE__*/React__default.createElement(appStudio.Form, Object.assign({}, props), children));
11985
12482
  };
11986
12483
 
11987
- var _excluded$C = ["name", "type"];
12484
+ var _excluded$E = ["name", "type"];
11988
12485
  var getInputTypeProps = type => {
11989
12486
  switch (type) {
11990
12487
  case 'email':
@@ -12023,7 +12520,7 @@ var useFormikInput = _ref => {
12023
12520
  name,
12024
12521
  type
12025
12522
  } = _ref,
12026
- props = _objectWithoutPropertiesLoose(_ref, _excluded$C);
12523
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$E);
12027
12524
  var focus = useFormFocus();
12028
12525
  var {
12029
12526
  touched,
@@ -12067,13 +12564,13 @@ var useFormikInput = _ref => {
12067
12564
  } : {});
12068
12565
  };
12069
12566
 
12070
- var _excluded$D = ["value"];
12567
+ var _excluded$F = ["value"];
12071
12568
  var CheckboxComponent$1 = props => {
12072
12569
  var _useFormikInput = useFormikInput(props),
12073
12570
  {
12074
12571
  value
12075
12572
  } = _useFormikInput,
12076
- formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$D);
12573
+ formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$F);
12077
12574
  formProps.isChecked = value;
12078
12575
  var checkboxStates = useCheckboxState(props);
12079
12576
  return /*#__PURE__*/React__default.createElement(CheckboxView, Object.assign({}, checkboxStates, formProps));
@@ -12141,11 +12638,11 @@ var TextAreaComponent$1 = props => {
12141
12638
  */
12142
12639
  var FormikTextArea = TextAreaComponent$1;
12143
12640
 
12144
- var _excluded$E = ["value"];
12641
+ var _excluded$G = ["value"];
12145
12642
  var TextFieldComponent$1 = props => {
12146
12643
  var formProps = useFormikInput(props);
12147
12644
  var _useTextFieldState = useTextFieldState(props),
12148
- textFieldStates = _objectWithoutPropertiesLoose(_useTextFieldState, _excluded$E);
12645
+ textFieldStates = _objectWithoutPropertiesLoose(_useTextFieldState, _excluded$G);
12149
12646
  return /*#__PURE__*/React__default.createElement(TextFieldView, Object.assign({}, textFieldStates, formProps));
12150
12647
  };
12151
12648
  /**
@@ -12153,7 +12650,7 @@ var TextFieldComponent$1 = props => {
12153
12650
  */
12154
12651
  var FormikTextField = TextFieldComponent$1;
12155
12652
 
12156
- var _excluded$F = ["visibleIcon", "hiddenIcon"],
12653
+ var _excluded$H = ["visibleIcon", "hiddenIcon"],
12157
12654
  _excluded2$b = ["isVisible", "setIsVisible"];
12158
12655
  var PasswordComponent$1 = _ref => {
12159
12656
  var {
@@ -12164,7 +12661,7 @@ var PasswordComponent$1 = _ref => {
12164
12661
  widthHeight: 14
12165
12662
  })
12166
12663
  } = _ref,
12167
- props = _objectWithoutPropertiesLoose(_ref, _excluded$F);
12664
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$H);
12168
12665
  var formProps = useFormikInput(props);
12169
12666
  var _usePasswordState = usePasswordState(formProps),
12170
12667
  {
@@ -12189,14 +12686,14 @@ var PasswordComponent$1 = _ref => {
12189
12686
  */
12190
12687
  var FormikPassword = PasswordComponent$1;
12191
12688
 
12192
- var _excluded$G = ["items", "placeholder", "searchPlaceholder"];
12689
+ var _excluded$I = ["items", "placeholder", "searchPlaceholder"];
12193
12690
  var ComboBoxComponent$1 = _ref => {
12194
12691
  var {
12195
12692
  items,
12196
12693
  placeholder,
12197
12694
  searchPlaceholder
12198
12695
  } = _ref,
12199
- props = _objectWithoutPropertiesLoose(_ref, _excluded$G);
12696
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$I);
12200
12697
  var formProps = useFormikInput(props);
12201
12698
  var ComboBoxStates = useComboBoxState(items, placeholder, searchPlaceholder);
12202
12699
  // Ensure the onChange function from formProps is being called when an item is selected
@@ -12477,7 +12974,7 @@ var OrientationStyles = {
12477
12974
  }
12478
12975
  };
12479
12976
 
12480
- 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"];
12977
+ 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"];
12481
12978
  var SliderView = _ref => {
12482
12979
  var _views$tooltip, _views$tooltip2;
12483
12980
  var {
@@ -12520,7 +13017,7 @@ var SliderView = _ref => {
12520
13017
  tooltip: {}
12521
13018
  }
12522
13019
  } = _ref,
12523
- props = _objectWithoutPropertiesLoose(_ref, _excluded$H);
13020
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$J);
12524
13021
  var {
12525
13022
  getColor,
12526
13023
  themeMode
@@ -13433,7 +13930,7 @@ var UploadView = _ref => {
13433
13930
  }, views == null ? void 0 : views.view)));
13434
13931
  };
13435
13932
 
13436
- var _excluded$I = ["accept", "icon", "text", "maxSize", "onFileSelect", "onMultipleFileSelect", "validateFile", "isLoading", "progress", "fileType", "multiple"];
13933
+ var _excluded$K = ["accept", "icon", "text", "maxSize", "onFileSelect", "onMultipleFileSelect", "validateFile", "isLoading", "progress", "fileType", "multiple"];
13437
13934
  var Uploader = _ref => {
13438
13935
  var {
13439
13936
  accept = '*/*',
@@ -13448,7 +13945,7 @@ var Uploader = _ref => {
13448
13945
  fileType,
13449
13946
  multiple = false
13450
13947
  } = _ref,
13451
- props = _objectWithoutPropertiesLoose(_ref, _excluded$I);
13948
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$K);
13452
13949
  var {
13453
13950
  previewUrl,
13454
13951
  thumbnailUrl,
@@ -13644,7 +14141,7 @@ var ModalTypography = {
13644
14141
  }
13645
14142
  };
13646
14143
 
13647
- var _excluded$J = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position", "views"],
14144
+ var _excluded$L = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position", "views"],
13648
14145
  _excluded2$c = ["children", "shadow", "isFullScreen", "shape", "views", "isOpen"],
13649
14146
  _excluded3$8 = ["children", "buttonColor", "iconSize", "buttonPosition", "views"],
13650
14147
  _excluded4$7 = ["children", "views"],
@@ -13659,7 +14156,7 @@ var ModalOverlay = _ref => {
13659
14156
  position = 'center',
13660
14157
  views
13661
14158
  } = _ref,
13662
- props = _objectWithoutPropertiesLoose(_ref, _excluded$J);
14159
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$L);
13663
14160
  var handleClick = () => {
13664
14161
  if (!isClosePrevented) onClose();
13665
14162
  };
@@ -13955,7 +14452,7 @@ var NavigationMenuItemStates = {
13955
14452
  }
13956
14453
  };
13957
14454
 
13958
- var _excluded$K = ["href", "children", "views"];
14455
+ var _excluded$M = ["href", "children", "views"];
13959
14456
  // Create context for the NavigationMenu
13960
14457
  var NavigationMenuContext = /*#__PURE__*/React.createContext({
13961
14458
  activeItemId: null,
@@ -14186,7 +14683,7 @@ var NavigationMenuLink = _ref6 => {
14186
14683
  children,
14187
14684
  views
14188
14685
  } = _ref6,
14189
- props = _objectWithoutPropertiesLoose(_ref6, _excluded$K);
14686
+ props = _objectWithoutPropertiesLoose(_ref6, _excluded$M);
14190
14687
  var {
14191
14688
  itemValue,
14192
14689
  isDisabled
@@ -14253,7 +14750,7 @@ var NavigationMenuView = _ref7 => {
14253
14750
  })))));
14254
14751
  };
14255
14752
 
14256
- var _excluded$L = ["items", "children", "orientation", "size", "variant", "defaultActiveItemId", "defaultExpandedItemIds", "onItemActivate", "views"];
14753
+ var _excluded$N = ["items", "children", "orientation", "size", "variant", "defaultActiveItemId", "defaultExpandedItemIds", "onItemActivate", "views"];
14257
14754
  /**
14258
14755
  * NavigationMenu component for creating navigation menus with optional nested items.
14259
14756
  * Supports both data-driven approach (with items prop) and compound component pattern.
@@ -14270,7 +14767,7 @@ var NavigationMenuComponent = _ref => {
14270
14767
  onItemActivate,
14271
14768
  views
14272
14769
  } = _ref,
14273
- props = _objectWithoutPropertiesLoose(_ref, _excluded$L);
14770
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$N);
14274
14771
  var {
14275
14772
  activeItemId,
14276
14773
  setActiveItemId,
@@ -14793,20 +15290,20 @@ var useTitleState = props => {
14793
15290
  * Font sizes for different title sizes
14794
15291
  */
14795
15292
  var TitleSizes = {
14796
- xs: 16,
14797
- sm: 20,
14798
- md: 32,
14799
- lg: 48,
15293
+ xs: 24,
15294
+ sm: 36,
15295
+ md: 48,
15296
+ lg: 64,
14800
15297
  xl: 72
14801
15298
  };
14802
15299
  /**
14803
15300
  * Line heights for different title sizes
14804
15301
  */
14805
15302
  var LineHeights$1 = {
14806
- xs: 24,
14807
- sm: 28,
14808
- md: 40,
14809
- lg: 56,
15303
+ xs: 32,
15304
+ sm: 40,
15305
+ md: 56,
15306
+ lg: 72,
14810
15307
  xl: 80
14811
15308
  };
14812
15309
  /**
@@ -14846,7 +15343,7 @@ var HighlightStyles = {
14846
15343
  })
14847
15344
  };
14848
15345
 
14849
- var _excluded$M = ["text", "typingSpeed", "pauseTime", "onComplete", "showCursor", "cursorColor", "textStyle", "as"];
15346
+ var _excluded$O = ["text", "typingSpeed", "pauseTime", "onComplete", "showCursor", "cursorColor", "textStyle", "as"];
14850
15347
  /**
14851
15348
  * A component that creates a typewriter effect for text
14852
15349
  */
@@ -14860,7 +15357,7 @@ var TypewriterEffect = _ref => {
14860
15357
  cursorColor = 'currentColor',
14861
15358
  textStyle
14862
15359
  } = _ref,
14863
- props = _objectWithoutPropertiesLoose(_ref, _excluded$M);
15360
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$O);
14864
15361
  // Convert text to array if it's a string
14865
15362
  var textArray = Array.isArray(text) ? text : [text];
14866
15363
  // State for the currently displayed text
@@ -14927,7 +15424,7 @@ var TypewriterEffect = _ref => {
14927
15424
  }))))));
14928
15425
  };
14929
15426
 
14930
- var _excluded$N = ["children", "highlightText", "highlightStyle", "highlightColor", "highlightSecondaryColor", "size", "centered", "views", "highlightAnimate", "animate", "highlightTypewriter", "highlightTypewriterDuration"];
15427
+ var _excluded$P = ["children", "highlightText", "highlightStyle", "highlightColor", "highlightSecondaryColor", "size", "centered", "views", "highlightAnimate", "animate", "highlightTypewriter", "highlightTypewriterDuration"];
14931
15428
  function escapeRegExp(string) {
14932
15429
  return string.replace(/[.*+?^${}()|[\\]\\/g, '\\$&');
14933
15430
  }
@@ -14946,7 +15443,7 @@ var TitleView = _ref => {
14946
15443
  highlightTypewriter: propHighlightTypewriter = false,
14947
15444
  highlightTypewriterDuration = 3000
14948
15445
  } = _ref,
14949
- props = _objectWithoutPropertiesLoose(_ref, _excluded$N);
15446
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$P);
14950
15447
  var {
14951
15448
  ref,
14952
15449
  inView
@@ -15117,7 +15614,7 @@ var useToggleState = defaultToggled => {
15117
15614
  };
15118
15615
  };
15119
15616
 
15120
- var _excluded$O = ["children", "shape", "variant", "isHovered", "setIsHovered", "isDisabled", "isToggle", "setIsToggled", "onToggle", "views"];
15617
+ var _excluded$Q = ["children", "shape", "variant", "isHovered", "setIsHovered", "isDisabled", "isToggle", "setIsToggled", "onToggle", "views"];
15121
15618
  var ToggleView = _ref => {
15122
15619
  var {
15123
15620
  children,
@@ -15131,7 +15628,7 @@ var ToggleView = _ref => {
15131
15628
  onToggle,
15132
15629
  views
15133
15630
  } = _ref,
15134
- props = _objectWithoutPropertiesLoose(_ref, _excluded$O);
15631
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$Q);
15135
15632
  var toggleColor = !isDisabled ? 'color.trueGray.400' : 'theme.disabled';
15136
15633
  var isActive = !!(isToggle || isHovered);
15137
15634
  var toggleVariants = {
@@ -15174,7 +15671,7 @@ var ToggleView = _ref => {
15174
15671
  }, toggleVariants[variant], props, views == null ? void 0 : views.container), children);
15175
15672
  };
15176
15673
 
15177
- var _excluded$P = ["children", "shape", "variant", "isDisabled", "isToggled", "onToggle"];
15674
+ var _excluded$R = ["children", "shape", "variant", "isDisabled", "isToggled", "onToggle"];
15178
15675
  // Destructuring properties from ToggleProps to be used within the ToggleComponent.
15179
15676
  var ToggleComponent = _ref => {
15180
15677
  var {
@@ -15186,7 +15683,7 @@ var ToggleComponent = _ref => {
15186
15683
  isToggled = false,
15187
15684
  onToggle
15188
15685
  } = _ref,
15189
- props = _objectWithoutPropertiesLoose(_ref, _excluded$P);
15686
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$R);
15190
15687
  // Initializing toggle state and set state functions using the custom hook useToggleState.
15191
15688
  var {
15192
15689
  isHovered,
@@ -15520,64 +16017,8 @@ var DropdownMenuItemStates = {
15520
16017
  cursor: 'not-allowed'
15521
16018
  }
15522
16019
  };
15523
- // Helper function to calculate position based on side and alignment
15524
- var getDropdownPosition = function getDropdownPosition(side, align) {
15525
- if (side === void 0) {
15526
- side = 'bottom';
15527
- }
15528
- if (align === void 0) {
15529
- align = 'start';
15530
- }
15531
- var positions = {
15532
- top: Object.assign({
15533
- bottom: '100%',
15534
- marginBottom: '8px'
15535
- }, align === 'start' && {
15536
- left: 0
15537
- }, align === 'center' && {
15538
- left: '50%',
15539
- transform: 'translateX(-50%)'
15540
- }, align === 'end' && {
15541
- right: 0
15542
- }),
15543
- right: Object.assign({
15544
- left: '100%',
15545
- marginLeft: '8px'
15546
- }, align === 'start' && {
15547
- top: 0
15548
- }, align === 'center' && {
15549
- top: '50%',
15550
- transform: 'translateY(-50%)'
15551
- }, align === 'end' && {
15552
- bottom: 0
15553
- }),
15554
- bottom: Object.assign({
15555
- top: '100%',
15556
- marginTop: '8px'
15557
- }, align === 'start' && {
15558
- left: 0
15559
- }, align === 'center' && {
15560
- left: '50%',
15561
- transform: 'translateX(-50%)'
15562
- }, align === 'end' && {
15563
- right: 0
15564
- }),
15565
- left: Object.assign({
15566
- right: '100%',
15567
- marginRight: '8px'
15568
- }, align === 'start' && {
15569
- top: 0
15570
- }, align === 'center' && {
15571
- top: '50%',
15572
- transform: 'translateY(-50%)'
15573
- }, align === 'end' && {
15574
- bottom: 0
15575
- })
15576
- };
15577
- return positions[side];
15578
- };
15579
16020
 
15580
- var _excluded$Q = ["children", "views"],
16021
+ var _excluded$S = ["children", "views"],
15581
16022
  _excluded2$d = ["items", "side", "align", "views"],
15582
16023
  _excluded3$9 = ["item", "views"],
15583
16024
  _excluded4$8 = ["views"],
@@ -15589,7 +16030,10 @@ var DropdownMenuContext = /*#__PURE__*/React.createContext({
15589
16030
  activeSubmenuId: null,
15590
16031
  setActiveSubmenuId: () => {},
15591
16032
  size: 'md',
15592
- variant: 'default'
16033
+ variant: 'default',
16034
+ triggerRef: {
16035
+ current: null
16036
+ }
15593
16037
  });
15594
16038
  // Provider component for the DropdownMenu context
15595
16039
  var DropdownMenuProvider = _ref => {
@@ -15615,16 +16059,18 @@ var DropdownMenuTrigger = _ref2 => {
15615
16059
  children,
15616
16060
  views
15617
16061
  } = _ref2,
15618
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$Q);
16062
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$S);
15619
16063
  var {
15620
16064
  isOpen,
15621
- setIsOpen
16065
+ setIsOpen,
16066
+ triggerRef
15622
16067
  } = useDropdownMenuContext();
15623
16068
  var handleClick = e => {
15624
16069
  e.stopPropagation();
15625
16070
  setIsOpen(!isOpen);
15626
16071
  };
15627
16072
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
16073
+ ref: triggerRef,
15628
16074
  id: "dropdown-trigger",
15629
16075
  onClick: handleClick,
15630
16076
  cursor: "pointer",
@@ -15643,20 +16089,121 @@ var DropdownMenuContent = _ref3 => {
15643
16089
  props = _objectWithoutPropertiesLoose(_ref3, _excluded2$d);
15644
16090
  var {
15645
16091
  isOpen,
15646
- //activeSubmenuId, setActiveSubmenuId, size,
15647
- variant
16092
+ variant,
16093
+ triggerRef
15648
16094
  } = useDropdownMenuContext();
16095
+ var contentRef = React.useRef(null);
16096
+ var [optimalPosition, setOptimalPosition] = React.useState({
16097
+ x: 0,
16098
+ y: 0,
16099
+ placement: side
16100
+ });
16101
+ // Calculate optimal position when the dropdown opens
16102
+ React.useEffect(() => {
16103
+ if (isOpen && contentRef.current && triggerRef.current) {
16104
+ var contentRect = contentRef.current.getBoundingClientRect();
16105
+ var triggerRect = triggerRef.current.getBoundingClientRect();
16106
+ // Get content dimensions
16107
+ var contentWidth = Math.max(contentRect.width || 180, 180);
16108
+ var contentHeight = Math.max(contentRect.height || 100, 100);
16109
+ // Get viewport dimensions
16110
+ var viewportWidth = window.innerWidth;
16111
+ var viewportHeight = window.innerHeight;
16112
+ // Calculate available space on all sides from the trigger
16113
+ var availableSpace = {
16114
+ top: triggerRect.top,
16115
+ right: viewportWidth - triggerRect.right,
16116
+ bottom: viewportHeight - triggerRect.bottom,
16117
+ left: triggerRect.left
16118
+ };
16119
+ // Determine optimal placement based on available space and preferred side
16120
+ var placements = [{
16121
+ placement: 'bottom',
16122
+ space: availableSpace.bottom,
16123
+ fits: availableSpace.bottom >= contentHeight + 8,
16124
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
16125
+ y: triggerRect.bottom + 8
16126
+ }, {
16127
+ placement: 'top',
16128
+ space: availableSpace.top,
16129
+ fits: availableSpace.top >= contentHeight + 8,
16130
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
16131
+ y: triggerRect.top - contentHeight - 8
16132
+ }, {
16133
+ placement: 'right',
16134
+ space: availableSpace.right,
16135
+ fits: availableSpace.right >= contentWidth + 8,
16136
+ x: triggerRect.right + 8,
16137
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
16138
+ }, {
16139
+ placement: 'left',
16140
+ space: availableSpace.left,
16141
+ fits: availableSpace.left >= contentWidth + 8,
16142
+ x: triggerRect.left - contentWidth - 8,
16143
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
16144
+ }];
16145
+ // First try the preferred side if it fits
16146
+ var preferredPlacement = placements.find(p => p.placement === side && p.fits);
16147
+ if (preferredPlacement) {
16148
+ setOptimalPosition({
16149
+ x: preferredPlacement.x,
16150
+ y: preferredPlacement.y,
16151
+ placement: preferredPlacement.placement
16152
+ });
16153
+ return;
16154
+ }
16155
+ // Otherwise, find the best fitting placement
16156
+ var fittingPlacement = placements.find(p => p.fits);
16157
+ if (fittingPlacement) {
16158
+ setOptimalPosition({
16159
+ x: fittingPlacement.x,
16160
+ y: fittingPlacement.y,
16161
+ placement: fittingPlacement.placement
16162
+ });
16163
+ return;
16164
+ }
16165
+ // If nothing fits, choose the placement with the most space
16166
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
16167
+ // Ensure the content stays within viewport bounds
16168
+ var finalX = bestPlacement.x;
16169
+ var finalY = bestPlacement.y;
16170
+ if (finalX + contentWidth > viewportWidth) {
16171
+ finalX = viewportWidth - contentWidth - 8;
16172
+ }
16173
+ if (finalX < 8) {
16174
+ finalX = 8;
16175
+ }
16176
+ if (finalY + contentHeight > viewportHeight) {
16177
+ finalY = viewportHeight - contentHeight - 8;
16178
+ }
16179
+ if (finalY < 8) {
16180
+ finalY = 8;
16181
+ }
16182
+ setOptimalPosition({
16183
+ x: finalX,
16184
+ y: finalY,
16185
+ placement: bestPlacement.placement
16186
+ });
16187
+ }
16188
+ }, [isOpen, side, align, triggerRef]);
15649
16189
  if (!isOpen) {
15650
16190
  return null;
15651
16191
  }
16192
+ // Create intelligent positioning styles
16193
+ var positionStyles = {
16194
+ position: 'fixed',
16195
+ left: optimalPosition.x,
16196
+ top: optimalPosition.y,
16197
+ zIndex: 1000
16198
+ };
15652
16199
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
16200
+ ref: contentRef,
15653
16201
  id: "dropdown-menu",
15654
- position: "absolute",
15655
- zIndex: 1000,
15656
16202
  borderRadius: 4,
15657
16203
  boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)",
15658
- overflow: "hidden"
15659
- }, getDropdownPosition(side, align), DropdownMenuVariants[variant], views == null ? void 0 : views.menu, props), items.map((item, index) => {
16204
+ overflow: "hidden",
16205
+ style: positionStyles
16206
+ }, DropdownMenuVariants[variant], views == null ? void 0 : views.menu, props), items.map((item, index) => {
15660
16207
  if (item.divider) {
15661
16208
  return /*#__PURE__*/React__default.createElement(DropdownMenuDivider, {
15662
16209
  key: "divider-" + index,
@@ -15668,7 +16215,13 @@ var DropdownMenuContent = _ref3 => {
15668
16215
  item: item,
15669
16216
  views: views
15670
16217
  });
15671
- }));
16218
+ }), (/*#__PURE__*/React__default.createElement("div", {
16219
+ style: {
16220
+ fontSize: '10px',
16221
+ opacity: 0.7,
16222
+ padding: '4px'
16223
+ }
16224
+ }, "Placement: ", optimalPosition.placement)));
15672
16225
  };
15673
16226
  // DropdownMenu Item component
15674
16227
  var DropdownMenuItem = _ref4 => {
@@ -15771,7 +16324,7 @@ var DropdownMenuView = _ref6 => {
15771
16324
  }));
15772
16325
  };
15773
16326
 
15774
- var _excluded$R = ["trigger", "items", "size", "variant", "side", "align", "defaultOpen", "views"];
16327
+ var _excluded$T = ["trigger", "items", "size", "variant", "side", "align", "defaultOpen", "views"];
15775
16328
  /**
15776
16329
  * DropdownMenu component for displaying a menu when clicking on a trigger element.
15777
16330
  */
@@ -15786,13 +16339,14 @@ var DropdownMenuComponent = _ref => {
15786
16339
  defaultOpen = false,
15787
16340
  views
15788
16341
  } = _ref,
15789
- props = _objectWithoutPropertiesLoose(_ref, _excluded$R);
16342
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$T);
15790
16343
  var {
15791
16344
  isOpen,
15792
16345
  setIsOpen,
15793
16346
  activeSubmenuId,
15794
16347
  setActiveSubmenuId
15795
16348
  } = useDropdownMenuState(defaultOpen);
16349
+ var triggerRef = React.useRef(null);
15796
16350
  return /*#__PURE__*/React__default.createElement(DropdownMenuProvider, {
15797
16351
  value: {
15798
16352
  isOpen,
@@ -15800,7 +16354,8 @@ var DropdownMenuComponent = _ref => {
15800
16354
  activeSubmenuId,
15801
16355
  setActiveSubmenuId,
15802
16356
  size,
15803
- variant
16357
+ variant,
16358
+ triggerRef
15804
16359
  }
15805
16360
  }, /*#__PURE__*/React__default.createElement(DropdownMenuView, Object.assign({
15806
16361
  trigger: trigger,
@@ -16198,7 +16753,7 @@ var DefaultColorPalette$1 = [
16198
16753
  category: 'neutral'
16199
16754
  }];
16200
16755
 
16201
- 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"];
16756
+ 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"];
16202
16757
  var ColorPickerView = _ref => {
16203
16758
  var {
16204
16759
  // Basic props
@@ -16233,7 +16788,7 @@ var ColorPickerView = _ref => {
16233
16788
  dropdownRef
16234
16789
  // Other props
16235
16790
  } = _ref,
16236
- props = _objectWithoutPropertiesLoose(_ref, _excluded$S);
16791
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$U);
16237
16792
  var {
16238
16793
  getColor
16239
16794
  } = appStudio.useTheme();
@@ -18563,7 +19118,7 @@ var useEmojiPickerState = props => {
18563
19118
  };
18564
19119
  };
18565
19120
 
18566
- 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"];
19121
+ 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"];
18567
19122
  var EmojiPickerView = _ref => {
18568
19123
  var {
18569
19124
  // Basic props
@@ -18601,7 +19156,7 @@ var EmojiPickerView = _ref => {
18601
19156
  dropdownRef
18602
19157
  // Other props
18603
19158
  } = _ref,
18604
- props = _objectWithoutPropertiesLoose(_ref, _excluded$T);
19159
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$V);
18605
19160
  var {
18606
19161
  getColor
18607
19162
  } = appStudio.useTheme();
@@ -18753,109 +19308,7 @@ var useHoverCardState = function useHoverCardState(_temp) {
18753
19308
  };
18754
19309
  };
18755
19310
 
18756
- // More advanced positioning using element measurements
18757
- var getContentPositionStyles = function getContentPositionStyles(triggerRect, side, align, sideOffset) {
18758
- if (side === void 0) {
18759
- side = 'bottom';
18760
- }
18761
- if (align === void 0) {
18762
- align = 'center';
18763
- }
18764
- if (sideOffset === void 0) {
18765
- sideOffset = 8;
18766
- }
18767
- if (!triggerRect) {
18768
- return {
18769
- position: 'absolute',
18770
- opacity: 0,
18771
- pointerEvents: 'none'
18772
- }; // Hide if trigger isn't measured
18773
- }
18774
- var styles = {
18775
- position: 'absolute',
18776
- zIndex: 1000
18777
- };
18778
- // Calculate position based on side and alignment
18779
- switch (side) {
18780
- case 'top':
18781
- styles.bottom = '100%';
18782
- styles.marginBottom = sideOffset;
18783
- if (align === 'start') {
18784
- styles.left = 0;
18785
- } else if (align === 'center') {
18786
- styles.left = '50%';
18787
- styles.transform = 'translateX(-50%)';
18788
- } else if (align === 'end') {
18789
- styles.right = 0;
18790
- }
18791
- break;
18792
- case 'right':
18793
- styles.left = '100%';
18794
- styles.marginLeft = sideOffset;
18795
- if (align === 'start') {
18796
- styles.top = 0;
18797
- } else if (align === 'center') {
18798
- styles.top = '50%';
18799
- styles.transform = 'translateY(-50%)';
18800
- } else if (align === 'end') {
18801
- styles.bottom = 0;
18802
- }
18803
- break;
18804
- case 'bottom':
18805
- styles.top = '100%';
18806
- styles.marginTop = sideOffset;
18807
- if (align === 'start') {
18808
- styles.left = 0;
18809
- } else if (align === 'center') {
18810
- styles.left = '50%';
18811
- styles.transform = 'translateX(-50%)';
18812
- } else if (align === 'end') {
18813
- styles.right = 0;
18814
- }
18815
- break;
18816
- case 'left':
18817
- styles.right = '100%';
18818
- styles.marginRight = sideOffset;
18819
- if (align === 'start') {
18820
- styles.top = 0;
18821
- } else if (align === 'center') {
18822
- styles.top = '50%';
18823
- styles.transform = 'translateY(-50%)';
18824
- } else if (align === 'end') {
18825
- styles.bottom = 0;
18826
- }
18827
- break;
18828
- }
18829
- return styles;
18830
- };
18831
-
18832
- /**
18833
- * A hook that returns the DOMRect of an element.
18834
- * @param ref React ref object for the element to measure
18835
- * @returns DOMRect of the element or null if the element is not available
18836
- */
18837
- var useRect = ref => {
18838
- var [rect, setRect] = React.useState(null);
18839
- var updateRect = React.useCallback(() => {
18840
- if (ref.current) {
18841
- setRect(ref.current.getBoundingClientRect());
18842
- }
18843
- }, [ref]);
18844
- React.useLayoutEffect(() => {
18845
- if (!ref.current) return;
18846
- updateRect();
18847
- // Update on resize and scroll
18848
- window.addEventListener('resize', updateRect);
18849
- window.addEventListener('scroll', updateRect);
18850
- return () => {
18851
- window.removeEventListener('resize', updateRect);
18852
- window.removeEventListener('scroll', updateRect);
18853
- };
18854
- }, [ref, updateRect]);
18855
- return rect;
18856
- };
18857
-
18858
- var _excluded$U = ["children", "views", "asChild"],
19311
+ var _excluded$W = ["children", "views", "asChild"],
18859
19312
  _excluded2$e = ["children", "views", "side", "align", "sideOffset", "style", "backgroundColor", "borderRadius", "boxShadow", "padding", "minWidth", "maxWidth"];
18860
19313
  // Create context for the HoverCard
18861
19314
  var HoverCardContext = /*#__PURE__*/React.createContext({
@@ -18894,7 +19347,7 @@ var HoverCardTrigger = _ref2 => {
18894
19347
  views,
18895
19348
  asChild = false
18896
19349
  } = _ref2,
18897
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$U);
19350
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$W);
18898
19351
  var {
18899
19352
  openCard,
18900
19353
  closeCard,
@@ -18952,15 +19405,111 @@ var HoverCardContent = _ref3 => {
18952
19405
  contentId,
18953
19406
  triggerId
18954
19407
  } = useHoverCardContext();
18955
- // Use hook to measure trigger for positioning
18956
- var triggerRect = useRect(triggerRef);
18957
- // Calculate position based on trigger dimensions and side prop
18958
- var positionStyles = getContentPositionStyles(triggerRect, side, align, sideOffset);
19408
+ var [optimalPosition, setOptimalPosition] = React.useState({
19409
+ x: 0,
19410
+ y: 0,
19411
+ placement: side
19412
+ });
19413
+ // Calculate optimal position when the card opens or content dimensions change
19414
+ React.useEffect(() => {
19415
+ if (isOpen && contentRef != null && contentRef.current && triggerRef != null && triggerRef.current) {
19416
+ var contentRect = contentRef.current.getBoundingClientRect();
19417
+ var triggerRect = triggerRef.current.getBoundingClientRect();
19418
+ // Get content dimensions
19419
+ var contentWidth = Math.max(contentRect.width || 200, 200);
19420
+ var contentHeight = Math.max(contentRect.height || 100, 100);
19421
+ // Get viewport dimensions
19422
+ var viewportWidth = window.innerWidth;
19423
+ var viewportHeight = window.innerHeight;
19424
+ // Calculate available space on all sides from the trigger
19425
+ var availableSpace = {
19426
+ top: triggerRect.top,
19427
+ right: viewportWidth - triggerRect.right,
19428
+ bottom: viewportHeight - triggerRect.bottom,
19429
+ left: triggerRect.left
19430
+ };
19431
+ // Determine optimal placement based on available space and preferred side
19432
+ var placements = [{
19433
+ placement: 'bottom',
19434
+ space: availableSpace.bottom,
19435
+ fits: availableSpace.bottom >= contentHeight + sideOffset,
19436
+ x: triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
19437
+ y: triggerRect.bottom + sideOffset
19438
+ }, {
19439
+ placement: 'top',
19440
+ space: availableSpace.top,
19441
+ fits: availableSpace.top >= contentHeight + sideOffset,
19442
+ x: triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
19443
+ y: triggerRect.top - contentHeight - sideOffset
19444
+ }, {
19445
+ placement: 'right',
19446
+ space: availableSpace.right,
19447
+ fits: availableSpace.right >= contentWidth + sideOffset,
19448
+ x: triggerRect.right + sideOffset,
19449
+ y: triggerRect.top + triggerRect.height / 2 - contentHeight / 2
19450
+ }, {
19451
+ placement: 'left',
19452
+ space: availableSpace.left,
19453
+ fits: availableSpace.left >= contentWidth + sideOffset,
19454
+ x: triggerRect.left - contentWidth - sideOffset,
19455
+ y: triggerRect.top + triggerRect.height / 2 - contentHeight / 2
19456
+ }];
19457
+ // First try the preferred side if it fits
19458
+ var preferredPlacement = placements.find(p => p.placement === side && p.fits);
19459
+ if (preferredPlacement) {
19460
+ setOptimalPosition({
19461
+ x: preferredPlacement.x,
19462
+ y: preferredPlacement.y,
19463
+ placement: preferredPlacement.placement
19464
+ });
19465
+ return;
19466
+ }
19467
+ // Otherwise, find the best fitting placement
19468
+ var fittingPlacement = placements.find(p => p.fits);
19469
+ if (fittingPlacement) {
19470
+ setOptimalPosition({
19471
+ x: fittingPlacement.x,
19472
+ y: fittingPlacement.y,
19473
+ placement: fittingPlacement.placement
19474
+ });
19475
+ return;
19476
+ }
19477
+ // If nothing fits, choose the placement with the most space
19478
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
19479
+ // Ensure the content stays within viewport bounds
19480
+ var finalX = bestPlacement.x;
19481
+ var finalY = bestPlacement.y;
19482
+ if (finalX + contentWidth > viewportWidth) {
19483
+ finalX = viewportWidth - contentWidth - 8;
19484
+ }
19485
+ if (finalX < 8) {
19486
+ finalX = 8;
19487
+ }
19488
+ if (finalY + contentHeight > viewportHeight) {
19489
+ finalY = viewportHeight - contentHeight - 8;
19490
+ }
19491
+ if (finalY < 8) {
19492
+ finalY = 8;
19493
+ }
19494
+ setOptimalPosition({
19495
+ x: finalX,
19496
+ y: finalY,
19497
+ placement: bestPlacement.placement
19498
+ });
19499
+ }
19500
+ }, [isOpen, side, sideOffset, contentRef, triggerRef]);
18959
19501
  var handleMouseEnter = () => cancelCloseTimer(); // Keep card open if mouse enters content
18960
19502
  var handleMouseLeave = () => closeCard();
18961
19503
  if (!isOpen) {
18962
19504
  return null; // Don't render content if not open
18963
19505
  }
19506
+ // Create intelligent positioning styles
19507
+ var positionStyles = {
19508
+ position: 'fixed',
19509
+ left: optimalPosition.x,
19510
+ top: optimalPosition.y,
19511
+ zIndex: 1000
19512
+ };
18964
19513
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
18965
19514
  ref: contentRef,
18966
19515
  id: contentId,
@@ -18975,13 +19524,18 @@ var HoverCardContent = _ref3 => {
18975
19524
  padding: padding,
18976
19525
  minWidth: minWidth,
18977
19526
  maxWidth: maxWidth,
18978
- zIndex: 1000,
18979
- // Combine calculated position styles with user styles
19527
+ // Combine intelligent position styles with user styles
18980
19528
  style: Object.assign({}, positionStyles, userStyle)
18981
- }, views == null ? void 0 : views.container, props), children);
19529
+ }, views == null ? void 0 : views.container, props), children, (/*#__PURE__*/React__default.createElement("div", {
19530
+ style: {
19531
+ fontSize: '10px',
19532
+ opacity: 0.7,
19533
+ marginTop: '4px'
19534
+ }
19535
+ }, "Placement: ", optimalPosition.placement)));
18982
19536
  };
18983
19537
 
18984
- var _excluded$V = ["children", "views", "openDelay", "closeDelay"];
19538
+ var _excluded$X = ["children", "views", "openDelay", "closeDelay"];
18985
19539
  /**
18986
19540
  * HoverCard component displays floating content when hovering over a trigger element.
18987
19541
  * Supports configurable open and close delays for a smoother user experience.
@@ -18993,7 +19547,7 @@ var HoverCardComponent = _ref => {
18993
19547
  openDelay,
18994
19548
  closeDelay
18995
19549
  } = _ref,
18996
- props = _objectWithoutPropertiesLoose(_ref, _excluded$V);
19550
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$X);
18997
19551
  var hoverCardState = useHoverCardState({
18998
19552
  openDelay,
18999
19553
  closeDelay
@@ -19110,20 +19664,8 @@ var MenubarItemStates = {
19110
19664
  cursor: 'not-allowed'
19111
19665
  }
19112
19666
  };
19113
- var getMenubarContentPosition = orientation => {
19114
- if (orientation === 'horizontal') {
19115
- return {
19116
- top: '100%',
19117
- left: 0
19118
- };
19119
- }
19120
- return {
19121
- top: 0,
19122
- left: '100%'
19123
- };
19124
- };
19125
19667
 
19126
- var _excluded$W = ["children", "orientation", "size", "variant", "views"];
19668
+ var _excluded$Y = ["children", "orientation", "size", "variant", "views"];
19127
19669
  // Create context for the Menubar
19128
19670
  var MenubarContext = /*#__PURE__*/React.createContext({
19129
19671
  activeMenuId: null,
@@ -19134,7 +19676,10 @@ var MenubarContext = /*#__PURE__*/React.createContext({
19134
19676
  toggleMenu: () => {},
19135
19677
  orientation: 'horizontal',
19136
19678
  size: 'md',
19137
- variant: 'default'
19679
+ variant: 'default',
19680
+ triggerRefs: {
19681
+ current: {}
19682
+ }
19138
19683
  });
19139
19684
  // Hook to use the Menubar context
19140
19685
  var useMenubarContext = () => React.useContext(MenubarContext);
@@ -19157,7 +19702,7 @@ var MenubarRoot = _ref2 => {
19157
19702
  variant = 'default',
19158
19703
  views
19159
19704
  } = _ref2,
19160
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$W);
19705
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$Y);
19161
19706
  var Container = orientation === 'horizontal' ? appStudio.Horizontal : appStudio.Vertical;
19162
19707
  return /*#__PURE__*/React__default.createElement(Container, Object.assign({
19163
19708
  role: "menubar",
@@ -19204,16 +19749,30 @@ var MenubarTrigger = _ref4 => {
19204
19749
  setActiveMenuId,
19205
19750
  toggleMenu,
19206
19751
  isMenuOpen,
19207
- size
19752
+ size,
19753
+ triggerRefs
19208
19754
  } = useMenubarContext();
19755
+ var triggerRef = React.useRef(null);
19209
19756
  var isActive = activeMenuId === menuId;
19210
19757
  var isOpen = isMenuOpen(menuId);
19758
+ // Store the trigger ref in the context
19759
+ React.useEffect(() => {
19760
+ if (triggerRef.current && menuId) {
19761
+ triggerRefs.current[menuId] = triggerRef.current;
19762
+ }
19763
+ return () => {
19764
+ if (menuId) {
19765
+ delete triggerRefs.current[menuId];
19766
+ }
19767
+ };
19768
+ }, [menuId, triggerRefs]);
19211
19769
  var handleClick = () => {
19212
19770
  if (disabled) return;
19213
19771
  setActiveMenuId(menuId);
19214
19772
  toggleMenu(menuId);
19215
19773
  };
19216
19774
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
19775
+ ref: triggerRef,
19217
19776
  id: "menubar-trigger",
19218
19777
  role: "menuitem",
19219
19778
  "aria-haspopup": "true",
@@ -19236,23 +19795,149 @@ var MenubarContent = _ref5 => {
19236
19795
  } = _ref5;
19237
19796
  var {
19238
19797
  isMenuOpen,
19239
- orientation
19798
+ orientation,
19799
+ triggerRefs
19240
19800
  } = useMenubarContext();
19801
+ var contentRef = React.useRef(null);
19802
+ var [optimalPosition, setOptimalPosition] = React.useState({
19803
+ x: 0,
19804
+ y: 0,
19805
+ placement: orientation === 'horizontal' ? 'bottom' : 'right'
19806
+ });
19241
19807
  var isOpen = isMenuOpen(menuId);
19808
+ // Calculate optimal position when the menu opens
19809
+ React.useEffect(() => {
19810
+ if (isOpen && contentRef.current && menuId && triggerRefs.current[menuId]) {
19811
+ var contentRect = contentRef.current.getBoundingClientRect();
19812
+ var triggerRect = triggerRefs.current[menuId].getBoundingClientRect();
19813
+ // Get content dimensions
19814
+ var contentWidth = Math.max(contentRect.width || 200, 200);
19815
+ var contentHeight = Math.max(contentRect.height || 150, 150);
19816
+ // Get viewport dimensions
19817
+ var viewportWidth = window.innerWidth;
19818
+ var viewportHeight = window.innerHeight;
19819
+ // Calculate available space on all sides from the trigger
19820
+ var availableSpace = {
19821
+ top: triggerRect.top,
19822
+ right: viewportWidth - triggerRect.right,
19823
+ bottom: viewportHeight - triggerRect.bottom,
19824
+ left: triggerRect.left
19825
+ };
19826
+ // Determine optimal placement based on orientation and available space
19827
+ var placements = orientation === 'horizontal' ? [
19828
+ // For horizontal menubar, prefer bottom placement
19829
+ {
19830
+ placement: 'bottom',
19831
+ space: availableSpace.bottom,
19832
+ fits: availableSpace.bottom >= contentHeight + 8,
19833
+ x: triggerRect.left,
19834
+ y: triggerRect.bottom + 8
19835
+ }, {
19836
+ placement: 'top',
19837
+ space: availableSpace.top,
19838
+ fits: availableSpace.top >= contentHeight + 8,
19839
+ x: triggerRect.left,
19840
+ y: triggerRect.top - contentHeight - 8
19841
+ }, {
19842
+ placement: 'right',
19843
+ space: availableSpace.right,
19844
+ fits: availableSpace.right >= contentWidth + 8,
19845
+ x: triggerRect.right + 8,
19846
+ y: triggerRect.top
19847
+ }, {
19848
+ placement: 'left',
19849
+ space: availableSpace.left,
19850
+ fits: availableSpace.left >= contentWidth + 8,
19851
+ x: triggerRect.left - contentWidth - 8,
19852
+ y: triggerRect.top
19853
+ }] : [
19854
+ // For vertical menubar, prefer right placement
19855
+ {
19856
+ placement: 'right',
19857
+ space: availableSpace.right,
19858
+ fits: availableSpace.right >= contentWidth + 8,
19859
+ x: triggerRect.right + 8,
19860
+ y: triggerRect.top
19861
+ }, {
19862
+ placement: 'left',
19863
+ space: availableSpace.left,
19864
+ fits: availableSpace.left >= contentWidth + 8,
19865
+ x: triggerRect.left - contentWidth - 8,
19866
+ y: triggerRect.top
19867
+ }, {
19868
+ placement: 'bottom',
19869
+ space: availableSpace.bottom,
19870
+ fits: availableSpace.bottom >= contentHeight + 8,
19871
+ x: triggerRect.left,
19872
+ y: triggerRect.bottom + 8
19873
+ }, {
19874
+ placement: 'top',
19875
+ space: availableSpace.top,
19876
+ fits: availableSpace.top >= contentHeight + 8,
19877
+ x: triggerRect.left,
19878
+ y: triggerRect.top - contentHeight - 8
19879
+ }];
19880
+ // Find the best fitting placement
19881
+ var fittingPlacement = placements.find(p => p.fits);
19882
+ if (fittingPlacement) {
19883
+ setOptimalPosition({
19884
+ x: fittingPlacement.x,
19885
+ y: fittingPlacement.y,
19886
+ placement: fittingPlacement.placement
19887
+ });
19888
+ return;
19889
+ }
19890
+ // If nothing fits, choose the placement with the most space
19891
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
19892
+ // Ensure the content stays within viewport bounds
19893
+ var finalX = bestPlacement.x;
19894
+ var finalY = bestPlacement.y;
19895
+ if (finalX + contentWidth > viewportWidth) {
19896
+ finalX = viewportWidth - contentWidth - 8;
19897
+ }
19898
+ if (finalX < 8) {
19899
+ finalX = 8;
19900
+ }
19901
+ if (finalY + contentHeight > viewportHeight) {
19902
+ finalY = viewportHeight - contentHeight - 8;
19903
+ }
19904
+ if (finalY < 8) {
19905
+ finalY = 8;
19906
+ }
19907
+ setOptimalPosition({
19908
+ x: finalX,
19909
+ y: finalY,
19910
+ placement: bestPlacement.placement
19911
+ });
19912
+ }
19913
+ }, [isOpen, orientation, menuId, triggerRefs]);
19242
19914
  if (!isOpen) {
19243
19915
  return null;
19244
19916
  }
19917
+ // Create intelligent positioning styles
19918
+ var positionStyles = {
19919
+ position: 'fixed',
19920
+ left: optimalPosition.x,
19921
+ top: optimalPosition.y,
19922
+ zIndex: 1000
19923
+ };
19245
19924
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
19925
+ ref: contentRef,
19246
19926
  id: "menubar-content",
19247
19927
  role: "menu",
19248
- position: "absolute",
19249
- zIndex: 1000,
19250
19928
  minWidth: "200px",
19251
19929
  backgroundColor: "color.white",
19252
19930
  borderRadius: 4,
19253
19931
  boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)",
19254
- overflow: "hidden"
19255
- }, getMenubarContentPosition(orientation), views == null ? void 0 : views.content), children);
19932
+ overflow: "hidden",
19933
+ style: positionStyles
19934
+ }, views == null ? void 0 : views.content), children, (/*#__PURE__*/React__default.createElement("div", {
19935
+ style: {
19936
+ fontSize: '8px',
19937
+ opacity: 0.7,
19938
+ padding: '4px'
19939
+ }
19940
+ }, "Placement: ", optimalPosition.placement)));
19256
19941
  };
19257
19942
  // Menubar Item component
19258
19943
  var MenubarItem = _ref6 => {
@@ -19343,7 +20028,7 @@ var MenubarView = _ref8 => {
19343
20028
  })))))));
19344
20029
  };
19345
20030
 
19346
- var _excluded$X = ["items", "orientation", "size", "variant", "defaultActiveMenuId", "defaultOpenMenuId", "views"];
20031
+ var _excluded$Z = ["items", "orientation", "size", "variant", "defaultActiveMenuId", "defaultOpenMenuId", "views"];
19347
20032
  /**
19348
20033
  * Menubar component for creating horizontal or vertical menu bars with dropdown menus.
19349
20034
  */
@@ -19357,7 +20042,7 @@ var MenubarComponent = _ref => {
19357
20042
  defaultOpenMenuId = null,
19358
20043
  views
19359
20044
  } = _ref,
19360
- props = _objectWithoutPropertiesLoose(_ref, _excluded$X);
20045
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$Z);
19361
20046
  var {
19362
20047
  activeMenuId,
19363
20048
  setActiveMenuId,
@@ -19366,6 +20051,7 @@ var MenubarComponent = _ref => {
19366
20051
  isMenuOpen,
19367
20052
  toggleMenu
19368
20053
  } = useMenubarState(defaultActiveMenuId, defaultOpenMenuId);
20054
+ var triggerRefs = React.useRef({});
19369
20055
  return /*#__PURE__*/React__default.createElement(MenubarProvider, {
19370
20056
  value: {
19371
20057
  activeMenuId,
@@ -19376,7 +20062,8 @@ var MenubarComponent = _ref => {
19376
20062
  toggleMenu,
19377
20063
  orientation,
19378
20064
  size,
19379
- variant
20065
+ variant,
20066
+ triggerRefs
19380
20067
  }
19381
20068
  }, /*#__PURE__*/React__default.createElement(MenubarView, Object.assign({
19382
20069
  items: items,
@@ -19513,7 +20200,7 @@ var DisabledButtonStyles = {
19513
20200
  }
19514
20201
  };
19515
20202
 
19516
- var _excluded$Y = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "visiblePageNumbers", "views"];
20203
+ var _excluded$_ = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "visiblePageNumbers", "views"];
19517
20204
  var PaginationView = _ref => {
19518
20205
  var {
19519
20206
  currentPage,
@@ -19544,7 +20231,7 @@ var PaginationView = _ref => {
19544
20231
  visiblePageNumbers,
19545
20232
  views
19546
20233
  } = _ref,
19547
- props = _objectWithoutPropertiesLoose(_ref, _excluded$Y);
20234
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$_);
19548
20235
  var handlePageChange = page => {
19549
20236
  if (page < 1 || page > totalPages || page === currentPage) {
19550
20237
  return;
@@ -19663,7 +20350,7 @@ var PaginationView = _ref => {
19663
20350
  }, option.label))))));
19664
20351
  };
19665
20352
 
19666
- var _excluded$Z = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "views"];
20353
+ var _excluded$$ = ["currentPage", "totalPages", "onPageChange", "pageSize", "pageSizeOptions", "onPageSizeChange", "showPageSizeSelector", "showPageInfo", "maxPageButtons", "showFirstLastButtons", "size", "variant", "shape", "views"];
19667
20354
  /**
19668
20355
  * Pagination component for navigating through pages of content.
19669
20356
  */
@@ -19684,7 +20371,7 @@ var PaginationComponent = _ref => {
19684
20371
  shape = 'rounded',
19685
20372
  views
19686
20373
  } = _ref,
19687
- props = _objectWithoutPropertiesLoose(_ref, _excluded$Z);
20374
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$$);
19688
20375
  var {
19689
20376
  visiblePageNumbers
19690
20377
  } = usePaginationState(currentPage, totalPages, maxPageButtons);
@@ -19754,7 +20441,7 @@ var DefaultSeparatorStyles = {
19754
20441
  }
19755
20442
  };
19756
20443
 
19757
- var _excluded$_ = ["orientation", "variant", "thickness", "color", "spacing", "label", "decorative", "views", "themeMode"];
20444
+ var _excluded$10 = ["orientation", "variant", "thickness", "color", "spacing", "label", "decorative", "views", "themeMode"];
19758
20445
  var SeparatorView = _ref => {
19759
20446
  var {
19760
20447
  orientation = 'horizontal',
@@ -19766,7 +20453,7 @@ var SeparatorView = _ref => {
19766
20453
  decorative = false,
19767
20454
  views
19768
20455
  } = _ref,
19769
- props = _objectWithoutPropertiesLoose(_ref, _excluded$_);
20456
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$10);
19770
20457
  // Access theme if needed for future enhancements
19771
20458
  var {
19772
20459
  themeMode
@@ -20004,7 +20691,7 @@ var SidebarTransitions = {
20004
20691
  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)'
20005
20692
  };
20006
20693
 
20007
- var _excluded$$ = ["children", "showToggleButton", "views"],
20694
+ var _excluded$11 = ["children", "showToggleButton", "views"],
20008
20695
  _excluded2$f = ["children", "views"],
20009
20696
  _excluded3$a = ["children", "views"],
20010
20697
  _excluded4$9 = ["children", "position", "size", "variant", "fixed", "hasBackdrop", "expandedWidth", "collapsedWidth", "breakpointBehavior", "elevation", "transitionPreset", "ariaLabel", "isExpanded", "isMobile", "collapse", "views", "themeMode"];
@@ -20037,7 +20724,7 @@ var SidebarHeader = _ref2 => {
20037
20724
  showToggleButton = true,
20038
20725
  views
20039
20726
  } = _ref2,
20040
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$$);
20727
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$11);
20041
20728
  var {
20042
20729
  isExpanded,
20043
20730
  toggleExpanded,
@@ -20192,7 +20879,7 @@ var SidebarView = _ref5 => {
20192
20879
  }))));
20193
20880
  };
20194
20881
 
20195
- var _excluded$10 = ["children", "position", "size", "variant", "defaultExpanded", "expanded", "onExpandedChange", "fixed", "hasBackdrop", "showToggleButton", "expandedWidth", "collapsedWidth", "breakpoint", "breakpointBehavior", "views"];
20882
+ var _excluded$12 = ["children", "position", "size", "variant", "defaultExpanded", "expanded", "onExpandedChange", "fixed", "hasBackdrop", "showToggleButton", "expandedWidth", "collapsedWidth", "breakpoint", "breakpointBehavior", "views"];
20196
20883
  /**
20197
20884
  * Sidebar component for creating collapsible, themeable and customizable sidebars.
20198
20885
  */
@@ -20214,7 +20901,7 @@ var SidebarComponent = _ref => {
20214
20901
  breakpointBehavior = 'overlay',
20215
20902
  views
20216
20903
  } = _ref,
20217
- props = _objectWithoutPropertiesLoose(_ref, _excluded$10);
20904
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$12);
20218
20905
  var {
20219
20906
  isExpanded,
20220
20907
  toggleExpanded,
@@ -20679,7 +21366,7 @@ var HandleIconStyles = {
20679
21366
  }
20680
21367
  };
20681
21368
 
20682
- var _excluded$11 = ["children", "id", "defaultSize", "minSize", "maxSize", "collapsible", "defaultCollapsed", "onCollapseChange", "views"],
21369
+ var _excluded$13 = ["children", "id", "defaultSize", "minSize", "maxSize", "collapsible", "defaultCollapsed", "onCollapseChange", "views"],
20683
21370
  _excluded2$g = ["id", "position", "disabled", "withVisualIndicator", "withCollapseButton", "collapseTarget", "views"],
20684
21371
  _excluded3$b = ["children", "orientation", "size", "variant", "defaultSizes", "minSize", "maxSize", "collapsible", "containerRef", "autoSaveId", "views"];
20685
21372
  // Create context for the Resizable component
@@ -20724,7 +21411,7 @@ var ResizablePanel = _ref2 => {
20724
21411
  onCollapseChange,
20725
21412
  views
20726
21413
  } = _ref2,
20727
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$11);
21414
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$13);
20728
21415
  var {
20729
21416
  orientation,
20730
21417
  registerPanel,
@@ -20939,7 +21626,7 @@ var ResizableView = _ref4 => {
20939
21626
  }, ResizableOrientations[orientation], views == null ? void 0 : views.container, props), children);
20940
21627
  };
20941
21628
 
20942
- var _excluded$12 = ["children", "orientation", "size", "variant", "defaultSizes", "onSizesChange", "minSize", "maxSize", "collapsible", "autoSaveId", "storage", "keyboardResizeBy", "views"];
21629
+ var _excluded$14 = ["children", "orientation", "size", "variant", "defaultSizes", "onSizesChange", "minSize", "maxSize", "collapsible", "autoSaveId", "storage", "keyboardResizeBy", "views"];
20943
21630
  /**
20944
21631
  * Resizable component for creating resizable panel groups and layouts.
20945
21632
  */
@@ -20959,7 +21646,7 @@ var ResizableComponent = _ref => {
20959
21646
  keyboardResizeBy = 10,
20960
21647
  views
20961
21648
  } = _ref,
20962
- props = _objectWithoutPropertiesLoose(_ref, _excluded$12);
21649
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$14);
20963
21650
  var {
20964
21651
  isResizing,
20965
21652
  setIsResizing,
@@ -21727,7 +22414,7 @@ var CommandFooterStyles = {
21727
22414
  color: 'color.gray.500'
21728
22415
  };
21729
22416
 
21730
- var _excluded$13 = ["value", "onValueChange", "placeholder", "views"],
22417
+ var _excluded$15 = ["value", "onValueChange", "placeholder", "views"],
21731
22418
  _excluded2$h = ["children", "views"],
21732
22419
  _excluded3$c = ["heading", "children", "views"],
21733
22420
  _excluded4$a = ["item", "selected", "onSelect", "views"],
@@ -21759,7 +22446,7 @@ var CommandInput = _ref2 => {
21759
22446
  placeholder = 'Type a command or search...',
21760
22447
  views
21761
22448
  } = _ref2,
21762
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$13);
22449
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$15);
21763
22450
  var inputRef = React.useRef(null);
21764
22451
  // Focus input when component mounts
21765
22452
  React__default.useEffect(() => {
@@ -21942,7 +22629,7 @@ var CommandView = _ref7 => {
21942
22629
  })))), footer && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, CommandFooterStyles, views == null ? void 0 : views.footer), footer)))));
21943
22630
  };
21944
22631
 
21945
- var _excluded$14 = ["open", "onOpenChange", "groups", "commands", "placeholder", "size", "variant", "filter", "emptyState", "footer", "views"];
22632
+ var _excluded$16 = ["open", "onOpenChange", "groups", "commands", "placeholder", "size", "variant", "filter", "emptyState", "footer", "views"];
21946
22633
  /**
21947
22634
  * Command component for displaying a command palette with search functionality.
21948
22635
  */
@@ -21960,7 +22647,7 @@ var CommandComponent = _ref => {
21960
22647
  footer,
21961
22648
  views
21962
22649
  } = _ref,
21963
- props = _objectWithoutPropertiesLoose(_ref, _excluded$14);
22650
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$16);
21964
22651
  var {
21965
22652
  search,
21966
22653
  setSearch,
@@ -22139,65 +22826,6 @@ var getTooltip = themeMode => {
22139
22826
  };
22140
22827
  // For backward compatibility
22141
22828
  var TooltipVariants = /*#__PURE__*/getTooltip();
22142
- var getTooltipPositionStyles = (position, align) => {
22143
- var baseStyles = {
22144
- position: 'absolute',
22145
- zIndex: 1000
22146
- };
22147
- // Position styles
22148
- switch (position) {
22149
- case 'top':
22150
- return Object.assign({}, baseStyles, {
22151
- bottom: '100%',
22152
- marginBottom: '8px'
22153
- }, align === 'start' ? {
22154
- left: '0'
22155
- } : align === 'end' ? {
22156
- right: '0'
22157
- } : {
22158
- left: '50%',
22159
- transform: 'translateX(-50%)'
22160
- });
22161
- case 'right':
22162
- return Object.assign({}, baseStyles, {
22163
- left: '100%',
22164
- marginLeft: '8px'
22165
- }, align === 'start' ? {
22166
- top: '0'
22167
- } : align === 'end' ? {
22168
- bottom: '0'
22169
- } : {
22170
- top: '50%',
22171
- transform: 'translateY(-50%)'
22172
- });
22173
- case 'bottom':
22174
- return Object.assign({}, baseStyles, {
22175
- top: '100%',
22176
- marginTop: '8px'
22177
- }, align === 'start' ? {
22178
- left: '0'
22179
- } : align === 'end' ? {
22180
- right: '0'
22181
- } : {
22182
- left: '50%',
22183
- transform: 'translateX(-50%)'
22184
- });
22185
- case 'left':
22186
- return Object.assign({}, baseStyles, {
22187
- right: '100%',
22188
- marginRight: '8px'
22189
- }, align === 'start' ? {
22190
- top: '0'
22191
- } : align === 'end' ? {
22192
- bottom: '0'
22193
- } : {
22194
- top: '50%',
22195
- transform: 'translateY(-50%)'
22196
- });
22197
- default:
22198
- return baseStyles;
22199
- }
22200
- };
22201
22829
  var getArrowStyles = position => {
22202
22830
  var baseStyles = {
22203
22831
  position: 'absolute',
@@ -22247,7 +22875,7 @@ var getArrowStyles = position => {
22247
22875
  }
22248
22876
  };
22249
22877
 
22250
- var _excluded$15 = ["children", "views", "asChild"],
22878
+ var _excluded$17 = ["children", "views", "asChild"],
22251
22879
  _excluded2$i = ["children", "views"],
22252
22880
  _excluded3$d = ["content", "children", "position", "align", "size", "variant", "showArrow", "views", "themeMode"];
22253
22881
  // Create context for the Tooltip
@@ -22283,7 +22911,7 @@ var TooltipTrigger = _ref2 => {
22283
22911
  views,
22284
22912
  asChild = false
22285
22913
  } = _ref2,
22286
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$15);
22914
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$17);
22287
22915
  var {
22288
22916
  openTooltip,
22289
22917
  closeTooltip,
@@ -22352,17 +22980,113 @@ var TooltipView = _ref4 => {
22352
22980
  props = _objectWithoutPropertiesLoose(_ref4, _excluded3$d);
22353
22981
  var {
22354
22982
  isOpen,
22355
- // openTooltip,
22356
- // closeTooltip,
22357
- // triggerRef,
22983
+ triggerRef,
22358
22984
  contentRef,
22359
22985
  contentId,
22360
22986
  triggerId
22361
22987
  } = useTooltipContext();
22362
- // Get position styles
22363
- var positionStyles = getTooltipPositionStyles(position, align);
22364
- // Get arrow styles
22365
- var arrowStyles = showArrow ? getArrowStyles(position) : {};
22988
+ var [optimalPosition, setOptimalPosition] = React.useState({
22989
+ x: 0,
22990
+ y: 0,
22991
+ placement: position
22992
+ });
22993
+ // Calculate optimal position when the tooltip opens
22994
+ React.useEffect(() => {
22995
+ if (isOpen && contentRef != null && contentRef.current && triggerRef != null && triggerRef.current) {
22996
+ var contentRect = contentRef.current.getBoundingClientRect();
22997
+ var triggerRect = triggerRef.current.getBoundingClientRect();
22998
+ // Get content dimensions
22999
+ var contentWidth = Math.max(contentRect.width || 120, 120);
23000
+ var contentHeight = Math.max(contentRect.height || 32, 32);
23001
+ // Get viewport dimensions
23002
+ var viewportWidth = window.innerWidth;
23003
+ var viewportHeight = window.innerHeight;
23004
+ // Calculate available space on all sides from the trigger
23005
+ var availableSpace = {
23006
+ top: triggerRect.top,
23007
+ right: viewportWidth - triggerRect.right,
23008
+ bottom: viewportHeight - triggerRect.bottom,
23009
+ left: triggerRect.left
23010
+ };
23011
+ // Determine optimal placement based on available space and preferred position
23012
+ var placements = [{
23013
+ placement: 'top',
23014
+ space: availableSpace.top,
23015
+ fits: availableSpace.top >= contentHeight + 16,
23016
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
23017
+ y: triggerRect.top - contentHeight - 8
23018
+ }, {
23019
+ placement: 'bottom',
23020
+ space: availableSpace.bottom,
23021
+ fits: availableSpace.bottom >= contentHeight + 16,
23022
+ x: align === 'start' ? triggerRect.left : align === 'end' ? triggerRect.right - contentWidth : triggerRect.left + triggerRect.width / 2 - contentWidth / 2,
23023
+ y: triggerRect.bottom + 8
23024
+ }, {
23025
+ placement: 'right',
23026
+ space: availableSpace.right,
23027
+ fits: availableSpace.right >= contentWidth + 16,
23028
+ x: triggerRect.right + 8,
23029
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
23030
+ }, {
23031
+ placement: 'left',
23032
+ space: availableSpace.left,
23033
+ fits: availableSpace.left >= contentWidth + 16,
23034
+ x: triggerRect.left - contentWidth - 8,
23035
+ y: align === 'start' ? triggerRect.top : align === 'end' ? triggerRect.bottom - contentHeight : triggerRect.top + triggerRect.height / 2 - contentHeight / 2
23036
+ }];
23037
+ // First try the preferred position if it fits
23038
+ var preferredPlacement = placements.find(p => p.placement === position && p.fits);
23039
+ if (preferredPlacement) {
23040
+ setOptimalPosition({
23041
+ x: preferredPlacement.x,
23042
+ y: preferredPlacement.y,
23043
+ placement: preferredPlacement.placement
23044
+ });
23045
+ return;
23046
+ }
23047
+ // Otherwise, find the best fitting placement
23048
+ var fittingPlacement = placements.find(p => p.fits);
23049
+ if (fittingPlacement) {
23050
+ setOptimalPosition({
23051
+ x: fittingPlacement.x,
23052
+ y: fittingPlacement.y,
23053
+ placement: fittingPlacement.placement
23054
+ });
23055
+ return;
23056
+ }
23057
+ // If nothing fits, choose the placement with the most space
23058
+ var bestPlacement = placements.reduce((best, current) => current.space > best.space ? current : best);
23059
+ // Ensure the content stays within viewport bounds
23060
+ var finalX = bestPlacement.x;
23061
+ var finalY = bestPlacement.y;
23062
+ if (finalX + contentWidth > viewportWidth) {
23063
+ finalX = viewportWidth - contentWidth - 8;
23064
+ }
23065
+ if (finalX < 8) {
23066
+ finalX = 8;
23067
+ }
23068
+ if (finalY + contentHeight > viewportHeight) {
23069
+ finalY = viewportHeight - contentHeight - 8;
23070
+ }
23071
+ if (finalY < 8) {
23072
+ finalY = 8;
23073
+ }
23074
+ setOptimalPosition({
23075
+ x: finalX,
23076
+ y: finalY,
23077
+ placement: bestPlacement.placement
23078
+ });
23079
+ }
23080
+ }, [isOpen, position, align, triggerRef, contentRef]);
23081
+ // Get arrow styles based on optimal placement
23082
+ var arrowStyles = showArrow ? getArrowStyles(optimalPosition.placement) : {};
23083
+ // Create intelligent positioning styles
23084
+ var positionStyles = {
23085
+ position: 'fixed',
23086
+ left: optimalPosition.x,
23087
+ top: optimalPosition.y,
23088
+ zIndex: 1000
23089
+ };
22366
23090
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
22367
23091
  position: "relative",
22368
23092
  display: "inline-block"
@@ -22372,11 +23096,18 @@ var TooltipView = _ref4 => {
22372
23096
  role: "tooltip",
22373
23097
  "aria-labelledby": triggerId,
22374
23098
  borderRadius: 4,
22375
- boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)"
22376
- }, TooltipSizes[size], TooltipVariants[variant], positionStyles, views == null ? void 0 : views.content), typeof content === 'string' ? (/*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({}, views == null ? void 0 : views.text), content)) : content, showArrow && /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, arrowStyles, views == null ? void 0 : views.arrow)))));
23099
+ boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.15)",
23100
+ style: positionStyles
23101
+ }, TooltipSizes[size], TooltipVariants[variant], views == null ? void 0 : views.content), typeof content === 'string' ? (/*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({}, views == null ? void 0 : views.text), content)) : content, showArrow && /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, arrowStyles, views == null ? void 0 : views.arrow)), (/*#__PURE__*/React__default.createElement("div", {
23102
+ style: {
23103
+ fontSize: '8px',
23104
+ opacity: 0.7,
23105
+ marginTop: '2px'
23106
+ }
23107
+ }, "Placement: ", optimalPosition.placement)))));
22377
23108
  };
22378
23109
 
22379
- var _excluded$16 = ["content", "children", "position", "align", "size", "variant", "openDelay", "closeDelay", "showArrow", "defaultOpen", "isDisabled", "views"];
23110
+ var _excluded$18 = ["content", "children", "position", "align", "size", "variant", "openDelay", "closeDelay", "showArrow", "defaultOpen", "isDisabled", "views"];
22380
23111
  /**
22381
23112
  * Tooltip component for displaying additional information when hovering over an element.
22382
23113
  * Supports configurable positions, delays, and styling.
@@ -22396,7 +23127,7 @@ var TooltipComponent = _ref => {
22396
23127
  isDisabled = false,
22397
23128
  views
22398
23129
  } = _ref,
22399
- props = _objectWithoutPropertiesLoose(_ref, _excluded$16);
23130
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$18);
22400
23131
  var tooltipState = useTooltipState({
22401
23132
  defaultOpen,
22402
23133
  openDelay,
@@ -22869,7 +23600,7 @@ var TreeItemStates = {
22869
23600
  }
22870
23601
  };
22871
23602
 
22872
- var _excluded$17 = ["children", "views", "baseId"],
23603
+ var _excluded$19 = ["children", "views", "baseId"],
22873
23604
  _excluded2$j = ["value", "disabled", "icon", "children", "views", "style", "draggable"],
22874
23605
  _excluded3$e = ["children", "onClick", "onToggleExpand", "hasChildren", "expanded", "icon", "disabled", "isSelected", "isDragging", "size", "variant", "views"],
22875
23606
  _excluded4$b = ["children", "views"];
@@ -22905,7 +23636,7 @@ var TreeView = _ref2 => {
22905
23636
  baseId
22906
23637
  // themeMode, // If 'app-studio' ViewProps supports themeMode
22907
23638
  } = _ref2,
22908
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$17);
23639
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$19);
22909
23640
  var {
22910
23641
  allowDragAndDrop,
22911
23642
  handleDrop,
@@ -23185,7 +23916,7 @@ var DataDrivenTreeView = _ref7 => {
23185
23916
  }))));
23186
23917
  };
23187
23918
 
23188
- var _excluded$18 = ["children", "items", "size", "variant", "defaultExpandedItems", "expandedItems", "onExpandedItemsChange", "defaultSelectedItem", "selectedItem", "onItemSelect", "multiSelect", "allowDragAndDrop", "dragHandleIcon", "onItemsReorder", "onDragStart", "onDragEnd", "views"];
23919
+ var _excluded$1a = ["children", "items", "size", "variant", "defaultExpandedItems", "expandedItems", "onExpandedItemsChange", "defaultSelectedItem", "selectedItem", "onItemSelect", "multiSelect", "allowDragAndDrop", "dragHandleIcon", "onItemsReorder", "onDragStart", "onDragEnd", "views"];
23189
23920
  /**
23190
23921
  * Tree component for displaying hierarchical data.
23191
23922
  * Supports both compound component pattern (using Tree.Item, Tree.ItemLabel, Tree.ItemContent)
@@ -23254,7 +23985,7 @@ var TreeComponent = _ref => {
23254
23985
  views // Global views configuration
23255
23986
  // Remaining ViewProps for the root TreeView container
23256
23987
  } = _ref,
23257
- props = _objectWithoutPropertiesLoose(_ref, _excluded$18);
23988
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1a);
23258
23989
  var treeState = useTreeState({
23259
23990
  defaultExpandedItems,
23260
23991
  expandedItems,
@@ -23827,7 +24558,7 @@ var FlowNodeStates = {
23827
24558
  }
23828
24559
  };
23829
24560
 
23830
- var _excluded$19 = ["node", "onSelect", "isSelected", "isDragging", "onDragStart", "onDrag", "onDragEnd", "size", "variant", "views"],
24561
+ var _excluded$1b = ["node", "onSelect", "isSelected", "isDragging", "onDragStart", "onDrag", "onDragEnd", "size", "variant", "views"],
23831
24562
  _excluded2$k = ["onZoomIn", "onZoomOut", "onReset", "views"],
23832
24563
  _excluded3$f = ["onClick", "views"],
23833
24564
  _excluded4$c = ["nodes", "edges", "selectedNodeId", "draggedNodeId", "onNodeSelect", "onAddNode", "onNodeDragStart", "onNodeDrag", "onNodeDragEnd", "size", "variant", "direction", "showControls", "allowAddingNodes", "allowDraggingNodes", "views", "baseId", "viewport", "onZoomIn", "onZoomOut", "onReset", "onViewportChange"];
@@ -23843,7 +24574,7 @@ var FlowNodeView = _ref => {
23843
24574
  variant = 'default',
23844
24575
  views
23845
24576
  } = _ref,
23846
- props = _objectWithoutPropertiesLoose(_ref, _excluded$19);
24577
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1b);
23847
24578
  var handleClick = () => {
23848
24579
  if (onSelect) {
23849
24580
  onSelect(node.id);
@@ -24490,7 +25221,7 @@ var FlowView = _ref5 => {
24490
25221
  }, "Zoom: ", Math.round(viewport.zoom * 100), "%")));
24491
25222
  };
24492
25223
 
24493
- var _excluded$1a = ["children", "nodes", "edges", "size", "variant", "direction", "showControls", "allowAddingNodes", "allowDraggingNodes", "onNodesChange", "onEdgesChange", "onNodeSelect", "onNodeAdd", "onNodeDragStart", "onNodeDrag", "onNodeDragEnd", "selectedNodeId", "initialViewport", "viewport", "onViewportChange", "views"];
25224
+ var _excluded$1c = ["children", "nodes", "edges", "size", "variant", "direction", "showControls", "allowAddingNodes", "allowDraggingNodes", "onNodesChange", "onEdgesChange", "onNodeSelect", "onNodeAdd", "onNodeDragStart", "onNodeDrag", "onNodeDragEnd", "selectedNodeId", "initialViewport", "viewport", "onViewportChange", "views"];
24494
25225
  /**
24495
25226
  * Flow component for creating workflow diagrams.
24496
25227
  *
@@ -24547,7 +25278,7 @@ var FlowComponent = _ref => {
24547
25278
  onViewportChange,
24548
25279
  views
24549
25280
  } = _ref,
24550
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1a);
25281
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1c);
24551
25282
  var flowState = useFlowState({
24552
25283
  initialNodes: controlledNodes,
24553
25284
  initialEdges: controlledEdges,
@@ -24989,9 +25720,6 @@ var Shapes$4 = {
24989
25720
  },
24990
25721
  rounded: {
24991
25722
  borderRadius: '8px'
24992
- },
24993
- pillShaped: {
24994
- borderRadius: '9999px'
24995
25723
  }
24996
25724
  };
24997
25725
  /**
@@ -25137,71 +25865,373 @@ var AttachmentGroup = _ref => {
25137
25865
  };
25138
25866
 
25139
25867
  var EditableInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
25868
+ var _containerRef$current, _containerRef$current2;
25140
25869
  var {
25141
25870
  value,
25142
25871
  onChange,
25143
- onSubmit,
25144
25872
  placeholder = 'Type your message...',
25145
25873
  disabled = false,
25146
25874
  autoFocus = true,
25875
+ suggestions = [],
25876
+ onSuggestionSelect,
25877
+ showSuggestions = false,
25878
+ mentionData = [],
25879
+ mentionTrigger = '@',
25880
+ onMentionSelect,
25881
+ maxHeight = '200px',
25882
+ minHeight = '40px',
25147
25883
  views = {}
25148
25884
  } = _ref;
25149
- var {
25150
- getColor
25151
- } = appStudio.useTheme();
25152
25885
  var lastValueRef = React.useRef(value);
25886
+ var [selectedSuggestionIndex, setSelectedSuggestionIndex] = React.useState(-1);
25887
+ var [showPlaceholder, setShowPlaceholder] = React.useState(!value);
25888
+ var containerRef = React.useRef(null);
25889
+ var [isFocused, setIsFocused] = React.useState(false);
25890
+ // Mention-specific state
25891
+ var [showMentions, setShowMentions] = React.useState(false);
25892
+ var [mentionQuery, setMentionQuery] = React.useState('');
25893
+ var [mentionStartPos, setMentionStartPos] = React.useState(-1);
25894
+ var [selectedMentionIndex, setSelectedMentionIndex] = React.useState(-1);
25895
+ var [filteredMentions, setFilteredMentions] = React.useState([]);
25896
+ // Positioning state for dropdowns
25897
+ var [mentionPosition, setMentionPosition] = React.useState({
25898
+ x: 0,
25899
+ y: 0
25900
+ });
25901
+ var [suggestionPosition, setSuggestionPosition] = React.useState({
25902
+ x: 0,
25903
+ y: 0
25904
+ });
25905
+ // Note: Using custom positioning logic for better control over dropdown placement
25153
25906
  // Update the content of the editable div when the value prop changes
25154
25907
  React.useEffect(() => {
25155
25908
  var editableDiv = ref;
25156
25909
  if (editableDiv.current && value !== lastValueRef.current) {
25157
25910
  editableDiv.current.textContent = value;
25158
25911
  lastValueRef.current = value;
25912
+ setShowPlaceholder(!value);
25159
25913
  }
25160
25914
  }, [value, ref]);
25915
+ // Auto-focus effect
25916
+ React.useEffect(() => {
25917
+ if (autoFocus && ref && typeof ref === 'object' && ref.current) {
25918
+ ref.current.focus();
25919
+ }
25920
+ }, [autoFocus, ref]);
25921
+ // Get cursor position
25922
+ var getCursorPosition = () => {
25923
+ var selection = window.getSelection();
25924
+ if (!selection || selection.rangeCount === 0) return -1;
25925
+ var range = selection.getRangeAt(0);
25926
+ var preCaretRange = range.cloneRange();
25927
+ preCaretRange.selectNodeContents(ref && typeof ref === 'object' && ref.current ? ref.current : document.body);
25928
+ preCaretRange.setEnd(range.endContainer, range.endOffset);
25929
+ return preCaretRange.toString().length;
25930
+ };
25931
+ // Check for mention trigger and filter mentions
25932
+ var checkForMentions = React.useCallback((text, cursorPos) => {
25933
+ var beforeCursor = text.substring(0, cursorPos);
25934
+ var triggerIndex = beforeCursor.lastIndexOf(mentionTrigger);
25935
+ if (triggerIndex !== -1) {
25936
+ var afterTrigger = beforeCursor.substring(triggerIndex + 1);
25937
+ var hasSpaceAfterTrigger = afterTrigger.includes(' ');
25938
+ if (!hasSpaceAfterTrigger) {
25939
+ var query = afterTrigger.toLowerCase();
25940
+ var filtered = mentionData.filter(mention => mention.name.toLowerCase().includes(query));
25941
+ setMentionQuery(query);
25942
+ setMentionStartPos(triggerIndex);
25943
+ setFilteredMentions(filtered);
25944
+ setShowMentions(filtered.length > 0);
25945
+ setSelectedMentionIndex(0);
25946
+ // Calculate position for mentions dropdown
25947
+ var position = calculateDropdownPosition();
25948
+ setMentionPosition(position);
25949
+ return;
25950
+ }
25951
+ }
25952
+ setShowMentions(false);
25953
+ setMentionQuery('');
25954
+ setMentionStartPos(-1);
25955
+ setSelectedMentionIndex(-1);
25956
+ }, [mentionData, mentionTrigger]);
25957
+ // Calculate optimal position for dropdowns
25958
+ var calculateDropdownPosition = React.useCallback(function (dropdownHeight) {
25959
+ if (dropdownHeight === void 0) {
25960
+ dropdownHeight = 200;
25961
+ }
25962
+ if (!containerRef.current) return {
25963
+ x: 0,
25964
+ y: 0
25965
+ };
25966
+ var containerRect = containerRef.current.getBoundingClientRect();
25967
+ var viewportHeight = window.innerHeight;
25968
+ var viewportWidth = window.innerWidth;
25969
+ // Calculate available space
25970
+ var availableSpace = {
25971
+ top: containerRect.top,
25972
+ bottom: viewportHeight - containerRect.bottom,
25973
+ left: containerRect.left,
25974
+ right: viewportWidth - containerRect.right
25975
+ };
25976
+ // Prefer bottom placement, but use top if not enough space
25977
+ var useTopPlacement = availableSpace.bottom < dropdownHeight + 8 && availableSpace.top > availableSpace.bottom;
25978
+ return {
25979
+ x: containerRect.left,
25980
+ y: useTopPlacement ? containerRect.top - dropdownHeight - 8 : containerRect.bottom + 8
25981
+ };
25982
+ }, []);
25983
+ // Handle focus events
25984
+ var handleFocus = React.useCallback(() => {
25985
+ setIsFocused(true);
25986
+ // Calculate position for suggestions when focused
25987
+ var position = calculateDropdownPosition();
25988
+ setSuggestionPosition(position);
25989
+ }, [calculateDropdownPosition]);
25990
+ var handleBlur = React.useCallback(() => {
25991
+ // Delay hiding to allow for dropdown interactions
25992
+ setTimeout(() => {
25993
+ setIsFocused(false);
25994
+ setSelectedSuggestionIndex(-1);
25995
+ }, 150);
25996
+ }, []);
25161
25997
  // Handle input events
25162
25998
  var handleInput = e => {
25163
25999
  var newValue = e.currentTarget.textContent || '';
25164
26000
  if (newValue !== lastValueRef.current) {
25165
26001
  onChange(newValue);
25166
26002
  lastValueRef.current = newValue;
26003
+ setShowPlaceholder(!newValue);
26004
+ // Check for mentions
26005
+ var cursorPos = getCursorPosition();
26006
+ checkForMentions(newValue, cursorPos);
25167
26007
  }
25168
26008
  };
26009
+ // Handle mention selection
26010
+ var handleMentionSelect = React.useCallback(mention => {
26011
+ if (ref && typeof ref === 'object' && ref.current) {
26012
+ var currentText = ref.current.textContent || '';
26013
+ var beforeMention = currentText.substring(0, mentionStartPos);
26014
+ var afterMention = currentText.substring(mentionStartPos + mentionTrigger.length + mentionQuery.length);
26015
+ var newText = beforeMention + mentionTrigger + mention.name + ' ' + afterMention;
26016
+ onChange(newText);
26017
+ lastValueRef.current = newText;
26018
+ ref.current.textContent = newText;
26019
+ // Set cursor position after the mention
26020
+ var newCursorPos = beforeMention.length + mentionTrigger.length + mention.name.length + 1;
26021
+ setTimeout(() => {
26022
+ if (ref.current) {
26023
+ var range = document.createRange();
26024
+ var selection = window.getSelection();
26025
+ var textNode = ref.current.firstChild;
26026
+ if (textNode && selection) {
26027
+ var _textNode$textContent;
26028
+ range.setStart(textNode, Math.min(newCursorPos, ((_textNode$textContent = textNode.textContent) == null ? void 0 : _textNode$textContent.length) || 0));
26029
+ range.collapse(true);
26030
+ selection.removeAllRanges();
26031
+ selection.addRange(range);
26032
+ }
26033
+ }
26034
+ }, 0);
26035
+ }
26036
+ setShowMentions(false);
26037
+ setMentionQuery('');
26038
+ setMentionStartPos(-1);
26039
+ setSelectedMentionIndex(-1);
26040
+ if (onMentionSelect) {
26041
+ onMentionSelect(mention);
26042
+ }
26043
+ }, [mentionStartPos, mentionTrigger, mentionQuery, onChange, onMentionSelect, ref]);
26044
+ // Handle suggestion selection
26045
+ var handleSuggestionSelect = React.useCallback(suggestion => {
26046
+ if (onSuggestionSelect) {
26047
+ onSuggestionSelect(suggestion);
26048
+ }
26049
+ setSelectedSuggestionIndex(-1);
26050
+ }, [onSuggestionSelect]);
25169
26051
  // Handle key down events
25170
26052
  var handleKeyDown = e => {
25171
- if (e.key === 'Enter' && !e.shiftKey) {
25172
- e.preventDefault();
25173
- onSubmit(e);
26053
+ // Handle mention navigation
26054
+ if (showMentions && filteredMentions.length > 0) {
26055
+ if (e.key === 'ArrowDown') {
26056
+ e.preventDefault();
26057
+ setSelectedMentionIndex(prev => prev < filteredMentions.length - 1 ? prev + 1 : 0);
26058
+ return;
26059
+ }
26060
+ if (e.key === 'ArrowUp') {
26061
+ e.preventDefault();
26062
+ setSelectedMentionIndex(prev => prev > 0 ? prev - 1 : filteredMentions.length - 1);
26063
+ return;
26064
+ }
26065
+ if ((e.key === 'Tab' || e.key === 'Enter') && selectedMentionIndex >= 0) {
26066
+ e.preventDefault();
26067
+ handleMentionSelect(filteredMentions[selectedMentionIndex]);
26068
+ return;
26069
+ }
26070
+ if (e.key === 'Escape') {
26071
+ setShowMentions(false);
26072
+ setSelectedMentionIndex(-1);
26073
+ return;
26074
+ }
26075
+ }
26076
+ // Handle suggestion navigation
26077
+ if (showSuggestions && suggestions.length > 0) {
26078
+ if (e.key === 'ArrowDown') {
26079
+ e.preventDefault();
26080
+ setSelectedSuggestionIndex(prev => prev < suggestions.length - 1 ? prev + 1 : 0);
26081
+ return;
26082
+ }
26083
+ if (e.key === 'ArrowUp') {
26084
+ e.preventDefault();
26085
+ setSelectedSuggestionIndex(prev => prev > 0 ? prev - 1 : suggestions.length - 1);
26086
+ return;
26087
+ }
26088
+ if (e.key === 'Tab' && selectedSuggestionIndex >= 0) {
26089
+ e.preventDefault();
26090
+ handleSuggestionSelect(suggestions[selectedSuggestionIndex]);
26091
+ return;
26092
+ }
26093
+ if (e.key === 'Escape') {
26094
+ setSelectedSuggestionIndex(-1);
26095
+ return;
26096
+ }
25174
26097
  }
26098
+ // Allow Enter for line breaks (remove submission on Enter)
26099
+ // Submission should only happen via the send button
25175
26100
  };
25176
26101
  return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26102
+ ref: containerRef,
25177
26103
  width: "100%",
25178
- minHeight: "40px",
25179
- maxHeight: "200px",
25180
- overflowY: "auto"
25181
- }, views == null ? void 0 : views.container), /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26104
+ position: "relative"
26105
+ }, views == null ? void 0 : views.container), /*#__PURE__*/React__default.createElement(appStudio.View, {
26106
+ width: "100%",
26107
+ minHeight: minHeight,
26108
+ maxHeight: maxHeight,
26109
+ overflowY: "auto",
26110
+ position: "relative"
26111
+ }, showPlaceholder && (/*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({
26112
+ position: "absolute",
26113
+ top: "8px",
26114
+ left: "8px",
26115
+ color: "color.gray.400",
26116
+ pointerEvents: "none",
26117
+ fontSize: "14px",
26118
+ lineHeight: "1.5",
26119
+ zIndex: 1
26120
+ }, views == null ? void 0 : views.placeholder), placeholder)), /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
25182
26121
  as: "div",
25183
26122
  ref: ref,
25184
26123
  contentEditable: !disabled,
25185
26124
  suppressContentEditableWarning: true,
25186
26125
  onInput: handleInput,
25187
26126
  onKeyDown: handleKeyDown,
26127
+ onFocus: handleFocus,
26128
+ onBlur: handleBlur,
25188
26129
  role: "textbox",
25189
26130
  "aria-multiline": "true",
25190
26131
  "aria-placeholder": placeholder,
25191
- "data-placeholder": placeholder,
25192
26132
  width: "100%",
25193
26133
  minHeight: "24px",
26134
+ padding: "8px",
25194
26135
  outline: "none",
25195
26136
  whiteSpace: "pre-wrap",
25196
26137
  wordBreak: "break-word",
25197
- _empty: {
25198
- _before: {
25199
- content: 'attr(data-placeholder)',
25200
- color: 'color.gray.400',
25201
- pointerEvents: 'none'
25202
- }
26138
+ fontSize: "14px",
26139
+ lineHeight: "1.5",
26140
+ color: "color.gray.900",
26141
+ backgroundColor: "transparent"
26142
+ }, views == null ? void 0 : views.input))), showMentions && filteredMentions.length > 0 && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26143
+ position: "fixed",
26144
+ left: mentionPosition.x,
26145
+ top: mentionPosition.y,
26146
+ width: ((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth) || 300,
26147
+ backgroundColor: "color.white",
26148
+ border: "2px solid",
26149
+ borderColor: "color.blue.300",
26150
+ borderRadius: "8px",
26151
+ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.15)",
26152
+ zIndex: 9999,
26153
+ maxHeight: "200px",
26154
+ overflowY: "auto"
26155
+ }, views == null ? void 0 : views.mentionContainer), /*#__PURE__*/React__default.createElement(appStudio.Vertical, {
26156
+ gap: 0
26157
+ }, filteredMentions.map((mention, index) => (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26158
+ key: mention.id,
26159
+ as: "button",
26160
+ type: "button",
26161
+ width: "100%",
26162
+ padding: "12px 16px",
26163
+ backgroundColor: index === selectedMentionIndex ? 'color.blue.50' : 'transparent',
26164
+ border: "none",
26165
+ cursor: "pointer",
26166
+ textAlign: "left",
26167
+ transition: "background-color 0.2s ease",
26168
+ onClick: () => handleMentionSelect(mention),
26169
+ onMouseEnter: () => setSelectedMentionIndex(index),
26170
+ _hover: {
26171
+ backgroundColor: 'color.blue.50'
25203
26172
  }
25204
- }, views == null ? void 0 : views.input)));
26173
+ }, views == null ? void 0 : views.mentionItem), /*#__PURE__*/React__default.createElement(appStudio.Vertical, {
26174
+ gap: 4
26175
+ }, /*#__PURE__*/React__default.createElement(appStudio.Text, {
26176
+ fontSize: "14px",
26177
+ color: "color.gray.900",
26178
+ fontWeight: "medium"
26179
+ }, mentionTrigger, mention.name), mention.description && (/*#__PURE__*/React__default.createElement(appStudio.Text, {
26180
+ fontSize: "12px",
26181
+ color: "color.gray.600"
26182
+ }, mention.description)))))), (/*#__PURE__*/React__default.createElement("div", {
26183
+ style: {
26184
+ fontSize: '8px',
26185
+ opacity: 0.7,
26186
+ padding: '4px'
26187
+ }
26188
+ }, "Mentions (Trigger: ", mentionTrigger, ")"))))), showSuggestions && suggestions.length > 0 && !showMentions && isFocused && !value && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26189
+ position: "fixed",
26190
+ left: suggestionPosition.x,
26191
+ top: suggestionPosition.y,
26192
+ width: ((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.offsetWidth) || 300,
26193
+ backgroundColor: "color.white",
26194
+ border: "2px solid",
26195
+ borderColor: "color.green.300",
26196
+ borderRadius: "8px",
26197
+ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.15)",
26198
+ zIndex: 9998,
26199
+ maxHeight: "200px",
26200
+ overflowY: "auto"
26201
+ }, views == null ? void 0 : views.suggestionsContainer), /*#__PURE__*/React__default.createElement(appStudio.Vertical, {
26202
+ gap: 0
26203
+ }, suggestions.map((suggestion, index) => (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26204
+ key: suggestion.id,
26205
+ as: "button",
26206
+ type: "button",
26207
+ width: "100%",
26208
+ padding: "12px 16px",
26209
+ backgroundColor: index === selectedSuggestionIndex ? 'color.blue.50' : 'transparent',
26210
+ border: "none",
26211
+ cursor: "pointer",
26212
+ textAlign: "left",
26213
+ transition: "background-color 0.2s ease",
26214
+ onClick: () => handleSuggestionSelect(suggestion),
26215
+ onMouseEnter: () => setSelectedSuggestionIndex(index),
26216
+ _hover: {
26217
+ backgroundColor: 'color.blue.50'
26218
+ }
26219
+ }, views == null ? void 0 : views.suggestionItem), /*#__PURE__*/React__default.createElement(appStudio.Vertical, {
26220
+ gap: 4
26221
+ }, /*#__PURE__*/React__default.createElement(appStudio.Text, {
26222
+ fontSize: "14px",
26223
+ color: "color.gray.900",
26224
+ fontWeight: "medium"
26225
+ }, suggestion.text), suggestion.description && (/*#__PURE__*/React__default.createElement(appStudio.Text, {
26226
+ fontSize: "12px",
26227
+ color: "color.gray.600"
26228
+ }, suggestion.description)))))), (/*#__PURE__*/React__default.createElement("div", {
26229
+ style: {
26230
+ fontSize: '8px',
26231
+ opacity: 0.7,
26232
+ padding: '4px'
26233
+ }
26234
+ }, "Suggestions (Focus-triggered)"))))));
25205
26235
  });
25206
26236
  EditableInput.displayName = 'EditableInput';
25207
26237
 
@@ -25242,7 +26272,7 @@ var PromptExamples = _ref => {
25242
26272
  }, views == null ? void 0 : views.text), example.text)))));
25243
26273
  };
25244
26274
 
25245
- 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"];
26275
+ 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"];
25246
26276
  var ChatInputView = _ref => {
25247
26277
  var _value$trim$length;
25248
26278
  var {
@@ -25251,6 +26281,8 @@ var ChatInputView = _ref => {
25251
26281
  loading = false,
25252
26282
  disabled = false,
25253
26283
  isAgentRunning = false,
26284
+ leftButtons,
26285
+ rightButtons,
25254
26286
  loadingText = 'Agent is working...',
25255
26287
  autoFocus = true,
25256
26288
  sandboxId,
@@ -25263,6 +26295,9 @@ var ChatInputView = _ref => {
25263
26295
  shape = 'rounded',
25264
26296
  variant = 'default',
25265
26297
  views = {},
26298
+ mentionData = [],
26299
+ mentionTrigger = '@',
26300
+ onMentionSelect,
25266
26301
  // Props from state
25267
26302
  value,
25268
26303
  handleChange,
@@ -25282,7 +26317,7 @@ var ChatInputView = _ref => {
25282
26317
  setFileAsReference
25283
26318
  // Other props
25284
26319
  } = _ref,
25285
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1b);
26320
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1d);
25286
26321
  var {} = appStudio.useTheme();
25287
26322
  // Combine styles
25288
26323
  var containerStyles = Object.assign({}, DefaultChatInputStyles.container, Shapes$4[shape], views == null ? void 0 : views.container);
@@ -25374,16 +26409,18 @@ var ChatInputView = _ref => {
25374
26409
  color: "color.gray.500"
25375
26410
  }, loadingText))), /*#__PURE__*/React__default.createElement(appStudio.View, {
25376
26411
  position: "relative",
25377
- width: "100%"
26412
+ width: "100%",
26413
+ overflow: "visible"
25378
26414
  }, /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
25379
26415
  as: "form",
25380
26416
  onSubmit: handleSubmit,
25381
- overflowY: "auto",
26417
+ overflow: "visible",
25382
26418
  display: "flex",
25383
26419
  flexDirection: "column",
25384
26420
  position: "relative"
25385
26421
  }, contentStyles, containerStyles, {
25386
- paddingHorizontal: 20,
26422
+ paddingHorizontal: 16,
26423
+ paddingVertical: 10,
25387
26424
  backgroundColor: isDraggingOver ? 'color.blue.50' : undefined
25388
26425
  }), /*#__PURE__*/React__default.createElement(AttachmentGroup, {
25389
26426
  files: uploadedFiles,
@@ -25402,10 +26439,21 @@ var ChatInputView = _ref => {
25402
26439
  ref: editableRef,
25403
26440
  value: value || '',
25404
26441
  onChange: handleChange,
25405
- onSubmit: handleSubmit,
25406
26442
  placeholder: placeholder,
25407
26443
  disabled: disabled && !isAgentRunning,
25408
26444
  autoFocus: autoFocus,
26445
+ suggestions: (promptExamples == null ? void 0 : promptExamples.map(example => ({
26446
+ id: example.id,
26447
+ text: example.text,
26448
+ description: undefined
26449
+ }))) || [],
26450
+ showSuggestions: promptExamples && promptExamples.length > 0 && !value,
26451
+ onSuggestionSelect: suggestion => {
26452
+ handleChange(suggestion.text);
26453
+ },
26454
+ mentionData: mentionData,
26455
+ mentionTrigger: mentionTrigger,
26456
+ onMentionSelect: onMentionSelect,
25409
26457
  views: {
25410
26458
  container: {},
25411
26459
  input: views == null ? void 0 : views.editableInput
@@ -25431,7 +26479,7 @@ var ChatInputView = _ref => {
25431
26479
  views: {
25432
26480
  container: Object.assign({
25433
26481
  height: '36px',
25434
- margin: '0 12px',
26482
+ //margin: '0 12px',
25435
26483
  // borderRadius: '8px',
25436
26484
  // backgroundColor: 'transparent',
25437
26485
  // border: '1px solid',
@@ -25440,13 +26488,15 @@ var ChatInputView = _ref => {
25440
26488
  _hover: {
25441
26489
  backgroundColor: 'color.gray.100'
25442
26490
  }
25443
- }, views == null ? void 0 : views.fileButton, containerStyles)
26491
+ }, views == null ? void 0 : views.fileButton)
25444
26492
  },
25445
26493
  containerProps: {
25446
26494
  display: 'flex',
25447
26495
  alignItems: 'center',
25448
26496
  justifyContent: 'center',
25449
- gap: 4
26497
+ gap: 4,
26498
+ borderRadius: shape === 'rounded' ? '50%' : 4,
26499
+ padding: 10
25450
26500
  },
25451
26501
  textProps: {
25452
26502
  fontSize: '14px',
@@ -25458,9 +26508,13 @@ var ChatInputView = _ref => {
25458
26508
  }
25459
26509
  return null;
25460
26510
  }
25461
- }))), /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
26511
+ })), leftButtons), /*#__PURE__*/React__default.createElement(appStudio.Horizontal, {
26512
+ gap: 8,
26513
+ alignItems: "center"
26514
+ }, /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
25462
26515
  as: "button",
25463
- type: "submit",
26516
+ type: "button",
26517
+ onClick: handleSubmit,
25464
26518
  height: "40px",
25465
26519
  width: "40px",
25466
26520
  display: "flex",
@@ -25468,7 +26522,7 @@ var ChatInputView = _ref => {
25468
26522
  justifyContent: "center",
25469
26523
  backgroundColor: isAgentRunning ? 'theme.error' : hasText ? 'theme.primary' : 'color.gray.300',
25470
26524
  color: "color.white",
25471
- borderRadius: "50%",
26525
+ borderRadius: shape === 'rounded' ? '50%' : 4,
25472
26526
  border: "none",
25473
26527
  cursor: hasText ? 'pointer' : 'not-allowed',
25474
26528
  disabled: !hasText || loading || disabled && !isAgentRunning,
@@ -25488,7 +26542,7 @@ var ChatInputView = _ref => {
25488
26542
  widthHeight: 16,
25489
26543
  color: "currentColor",
25490
26544
  filled: false
25491
- })))))), errorMessage && (/*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({
26545
+ }))), rightButtons)))), errorMessage && (/*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({
25492
26546
  color: "theme.error",
25493
26547
  marginTop: "4px"
25494
26548
  }, views == null ? void 0 : views.bottomTip), errorMessage)));
@@ -25549,7 +26603,7 @@ var AuroraStyles = {
25549
26603
  }
25550
26604
  };
25551
26605
 
25552
- var _excluded$1c = ["children", "showRadialGradient", "views", "themeMode"],
26606
+ var _excluded$1e = ["children", "showRadialGradient", "views", "themeMode"],
25553
26607
  _excluded2$l = ["number"],
25554
26608
  _excluded3$g = ["rows", "cols", "squareSize"],
25555
26609
  _excluded4$d = ["count", "colors", "speed", "shapes"],
@@ -25567,7 +26621,7 @@ var AuroraBackground = _ref => {
25567
26621
  showRadialGradient = true,
25568
26622
  views
25569
26623
  } = _ref,
25570
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1c);
26624
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1e);
25571
26625
  var gradientColors = {
25572
26626
  white: 'rgba(255,255,255,1)',
25573
26627
  transparent: 'rgba(255,255,255,0)'
@@ -26123,6 +27177,7 @@ exports.SuccessIcon = SuccessIcon;
26123
27177
  exports.Switch = Switch;
26124
27178
  exports.Table = Table;
26125
27179
  exports.Tabs = Tabs;
27180
+ exports.TagInput = TagInput;
26126
27181
  exports.Text = Text;
26127
27182
  exports.TextArea = TextArea;
26128
27183
  exports.TextField = TextField;