react-core-ts 1.3.74 → 1.3.75

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.
@@ -1,11 +1,4 @@
1
- import React, {
2
- forwardRef,
3
- useCallback,
4
- useEffect,
5
- useImperativeHandle,
6
- useRef,
7
- useState,
8
- } from 'react';
1
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
2
  import ReactDOM from 'react-dom';
10
3
 
11
4
  import { AutoSuggestionInputProps } from './commontypes';
@@ -70,6 +63,8 @@ const AutoCompleteWithTreeStructure = forwardRef<
70
63
  showIcon,
71
64
  handleShowIcon,
72
65
  hasDisableSelection,
66
+ inputType = 'text',
67
+ onFocusTreeDropdown,
73
68
  },
74
69
  ref
75
70
  ) => {
@@ -600,6 +595,7 @@ const AutoCompleteWithTreeStructure = forwardRef<
600
595
  className={`qbs-textfield-expandable ${
601
596
  !expandable ? 'qbs-normal' : ''
602
597
  }`}
598
+ style={{ width: inputType === 'text' ? '100%' : 'auto' }}
603
599
  data-value={
604
600
  selectedItems?.length > 0 || searchValue
605
601
  ? searchValue
@@ -607,29 +603,59 @@ const AutoCompleteWithTreeStructure = forwardRef<
607
603
  }
608
604
  onClick={() => onInputFocus()}
609
605
  >
610
- <input
611
- id={id}
612
- ref={inputRef}
613
- type="text"
614
- value={
615
- type === 'auto_suggestion' && !expandable
616
- ? inputValue
617
- : inputValue
618
- }
619
- onChange={handleChange}
620
- // onBlur={handleBlur}
621
- onFocus={onFocus}
622
- onClick={() => handleOnClick()}
623
- className={generateClassName()}
624
- placeholder={selectedItems?.length > 0 ? '' : placeholder ?? ''}
625
- readOnly={
626
- readOnly ||
627
- type === 'custom_select' ||
628
- (type == 'auto_suggestion' && !expandable)
629
- }
630
- disabled={disabled}
631
- data-testid="custom-autocomplete"
632
- />
606
+ {inputType === 'text' ? (
607
+ <input
608
+ id={id}
609
+ ref={inputRef}
610
+ type="text"
611
+ value={
612
+ type === 'auto_suggestion' && !expandable
613
+ ? inputValue
614
+ : inputValue
615
+ }
616
+ onChange={handleChange}
617
+ // onBlur={handleBlur}
618
+ onFocus={onFocus}
619
+ onClick={() => handleOnClick()}
620
+ className={generateClassName()}
621
+ placeholder={selectedItems?.length > 0 ? '' : placeholder ?? ''}
622
+ readOnly={
623
+ readOnly ||
624
+ type === 'custom_select' ||
625
+ (type == 'auto_suggestion' && !expandable)
626
+ }
627
+ disabled={disabled}
628
+ data-testid="custom-autocomplete"
629
+ />
630
+ ) : (
631
+ <textarea
632
+ id={id}
633
+ ref={inputRef}
634
+ value={inputValue}
635
+ // onChange={handleChange}
636
+ onFocus={onFocusTreeDropdown}
637
+ onClick={() => handleOnClick()}
638
+ className={`${generateClassName()} resize-none overflow-y-auto`}
639
+ placeholder={selectedItems?.length > 0 ? '' : placeholder ?? ''}
640
+ readOnly={
641
+ readOnly ||
642
+ type === 'custom_select' ||
643
+ (type == 'auto_suggestion' && !expandable)
644
+ }
645
+ disabled={disabled}
646
+ data-testid="custom-autocomplete"
647
+ rows={4} // Set initial rows to 4
648
+ style={{
649
+ height: 'auto', // Allow it to expand
650
+ minHeight: '80px', // Approx. 4 lines of text
651
+ maxHeight: '160px', // Restrict max height to prevent large expansion
652
+ overflowY: 'auto', // Add scrollbar when exceeding 4 lines
653
+ wordWrap: 'break-word', // Ensure long words wrap correctly
654
+ whiteSpace: 'pre-wrap', // Preserve line breaks & spacing
655
+ }}
656
+ />
657
+ )}
658
+ )
633
659
  </div>
634
660
 
635
661
  {/* Icons for Clearing Input or Toggling Dropdown */}
@@ -69,6 +69,10 @@ export interface AutoSuggestionInputProps {
69
69
  showIcon?: boolean;
70
70
  handleShowIcon?: (node: any) => boolean;
71
71
  hasDisableSelection?: (node: any) => boolean;
72
+ onFocusTreeDropdown?: (
73
+ e: React.FocusEvent<HTMLTextAreaElement, Element>
74
+ ) => void;
75
+ inputType?: 'text' | 'textarea';
72
76
  }
73
77
  export interface IconsProps {
74
78
  name: any;
@@ -144,6 +148,7 @@ export interface TextFieldProps {
144
148
  onCreatableChange?: (e: string[]) => void;
145
149
  infoTitle?: string;
146
150
  showInfo?: boolean;
151
+ inputType?: 'text' | 'textarea';
147
152
  }
148
153
 
149
154
  export interface TextAreaProps {