react-core-ts 2.0.23 → 2.1.0

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.
@@ -0,0 +1,97 @@
1
+ .qbs-tree-list-container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ }
5
+ .qbs-tree-list-container-sub {
6
+ display: flex;
7
+ flex-direction: row;
8
+ align-items: flex-start;
9
+ gap: 7px;
10
+ }
11
+
12
+ .qbs-tree-list-container-sub .no-children {
13
+ margin-left: 1.75rem; /* Corresponds to ml-7 in Tailwind */
14
+ }
15
+ .qbs-tree-list-container-sub-icon {
16
+ margin-top: 0.25rem; /* Corresponds to mt-1 in Tailwind */
17
+ cursor: pointer;
18
+ padding-top: 0.5rem; /* Corresponds to py-2 in Tailwind */
19
+ padding-bottom: 0.5rem;
20
+ transition: transform 0.3s ease; /* Smooth rotation transition */
21
+ color: #003c71;
22
+ }
23
+
24
+ .qbs-tree-list-container-sub-icon.expanded {
25
+ transform: rotate(90deg); /* Corresponds to rotate-90 in Tailwind */
26
+ }
27
+ .qbs-tree-list-container-sub-container {
28
+ display: flex;
29
+ gap: 15px; /* Corresponds to gap-2 in Tailwind */
30
+ padding: 0.5rem; /* Corresponds to p-2 in Tailwind */
31
+ flex-direction: row; /* Corresponds to flex-row in Tailwind */
32
+ width: 100%; /* Corresponds to w-full in Tailwind */
33
+ color: #3d414a;
34
+ }
35
+ .qbs-tree-list-container-sub-container-hideicon {
36
+ display: flex;
37
+ gap: 6px; /* Corresponds to gap-2 in Tailwind */
38
+ padding: 0.5rem; /* Corresponds to p-2 in Tailwind */
39
+ flex-direction: row; /* Corresponds to flex-row in Tailwind */
40
+ width: 100%; /* Corresponds to w-full in Tailwind */
41
+ color: #3d414a;
42
+ }
43
+ .qbs-tree-list-container-sub-container-hideicon:hover {
44
+ color: #003c71;
45
+ background-color: rgba(141, 194, 240, 0.15) !important;
46
+ }
47
+ .qbs-tree-list-container-sub-container:hover {
48
+ color: #003c71;
49
+ background-color: rgba(141, 194, 240, 0.15) !important;
50
+ }
51
+ .qbs-tree-list-container-sub-container.qbs-expanded-child {
52
+ color: #003c71;
53
+ }
54
+ .qbs-tree-list-container-sub-text.qbs-expanded-child {
55
+ color: #003c71;
56
+ }
57
+ .qbs-tree-list-container-sub-text:hover {
58
+ color: #003c71;
59
+ /* background-color: rgba(141, 194, 240, 0.15) !important; */
60
+ }
61
+
62
+ .qbs-tree-list-container-sub-container.checked,
63
+ .qbs-tree-list-container-sub-container-hideicon.checked {
64
+ color: #003c71;
65
+ background-color: rgba(
66
+ 141,
67
+ 194,
68
+ 240,
69
+ 0.15
70
+ ) !important; /* Corresponds to bg-green-200 in Tailwind */
71
+ }
72
+
73
+ .marginLeft {
74
+ margin-left: 28px; /* Corresponds to ml-2 in Tailwind */
75
+ }
76
+ .lightmarginLeft {
77
+ margin-left: 19px; /* Corresponds to ml-2 in Tailwind */
78
+ }
79
+ .qbs-tree-list-container-sub- {
80
+ line-height: 18px; /* Corresponds to leading-[18px] in Tailwind */
81
+ font-size: 0.875rem; /* Corresponds to text-sm in Tailwind (14px) */
82
+ }
83
+ .qbs-tree-list-container-child {
84
+ margin-left: 1rem; /* Corresponds to ml-4 in Tailwind */
85
+ margin-top: 0.5rem; /* Corresponds to mt-2 in Tailwind */
86
+ display: flex; /* Corresponds to flex in Tailwind */
87
+ flex-direction: column; /* Corresponds to flex-col in Tailwind */
88
+ gap: 0.5rem; /* Corresponds to gap-2 in Tailwind */
89
+ }
90
+ .qbs-tree-list-container-sub-text {
91
+ line-height: 18px; /* Corresponds to leading-[18px] in Tailwind */
92
+ font-size: 14px; /* Corresponds to text-sm in Tailwind (14px) */
93
+ font-weight: 500;
94
+ letter-spacing: 0.28px;
95
+ font-family: 'Noto Sans';
96
+ /* color: #3d414a; */
97
+ }
@@ -0,0 +1,8 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ @import './components/autocomplete.css';
6
+ @import './components/treedropdown.css';
7
+ @import './components/selectedautocomplete.css';
8
+ @import './components/tooltip.css';
package/docs/App.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from "react";
2
2
 
3
3
  import { ValueProps } from "../src/commontypes";
4
- import { AutoComplete, AutoCompleteWithSelectedList, AutoCompleteWithTabFilter, AutoCompleteWithTreeStructure, ExpandableAutoComplete, ModernAutoComplete, ModernAutoCompleteDropdown, ModernAutoCompleteTableView, ModernTextField } from "../src/index";
4
+ import { AutoComplete, AutoCompleteWithSelectedList, AutoCompleteWithTabFilter, AutoCompleteWithTreeStructure, ExpandableAutoComplete, ModernAutoComplete, ModernAutoCompleteDropdown, ModernAutoCompleteTableView, ModernAutoCompleteSuggections, ModernTextField } from "../src/index";
5
5
  import ModernTextArea from "../src/ReactTextArea";
6
6
  import TextField from "../src/ReactTextField";
7
7
  import { treeDropData } from "./store";
@@ -15,6 +15,7 @@ export default function App() {
15
15
  const [prev, setPrev] = useState(1);
16
16
  const [selectedTabItems, setSelectedTabItems] = useState<ValueProps[]>([]);
17
17
  const [selectedItems, setSelectedItems] = useState<ValueProps[]>([]);
18
+ const [nameCountValue, setNameCountValue] = useState<string>('a');
18
19
 
19
20
  const getData = (keyName?: string, next?: number) => {
20
21
  console.log(keyName, "keyName");
@@ -68,7 +69,8 @@ export default function App() {
68
69
  return {
69
70
  ...item,
70
71
  ["name"]: item?.title + " - " + tab?.toString(),
71
- id: `${item?.id.toString()}-${tab?.toString()}`,
72
+ //id: `${item?.id.toString()}-${tab?.toString()}`,
73
+ id: item?.id.toString(),
72
74
  };
73
75
  });
74
76
  return result;
@@ -240,6 +242,20 @@ export default function App() {
240
242
  />
241
243
  </div>
242
244
 
245
+ <div style={{ width: 300 }}>
246
+ <ModernAutoCompleteSuggections
247
+ name="sample-name-count"
248
+ label="TextField (Name, Count)"
249
+ id="name-count-id"
250
+ placeholder="TextField"
251
+ getData={getDatas}
252
+ value={nameCountValue}
253
+ onChange={setNameCountValue}
254
+ // use userId as the "count" field for demo purposes
255
+ countField="userId"
256
+ />
257
+ </div>
258
+
243
259
  <div style={{ width: 300 }}>
244
260
  <ModernAutoCompleteDropdown
245
261
  name="sample"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-core-ts",
3
- "version": "2.0.23",
3
+ "version": "2.1.0",
4
4
  "description": "React Components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -156,6 +156,31 @@ const AutoComplete = forwardRef<HTMLInputElement, AutoSuggestionInputProps>(
156
156
  setInputValue(value ?? '');
157
157
  }, [value]);
158
158
 
159
+ const selectExactMatchFromSuggestions = () => {
160
+ if (!inputValue) {
161
+ return;
162
+ }
163
+
164
+ if (!filteredData || filteredData.length === 0) {
165
+ // No suggestions to match against – notify parent with raw value
166
+ onChange({ [descId]: '', [desc]: inputValue });
167
+ return;
168
+ }
169
+
170
+ const normalizedInput = inputValue.toString().trim().toLowerCase();
171
+ const match = filteredData.find((item: ValueProps) => {
172
+ const descValue = item?.[desc]?.toString().trim().toLowerCase();
173
+ return descValue === normalizedInput;
174
+ });
175
+
176
+ if (match) {
177
+ handleSuggestionClick(match);
178
+ } else {
179
+ // No exact match – notify parent with typed value
180
+ onChange({ [descId]: '', [desc]: inputValue });
181
+ }
182
+ };
183
+
159
184
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
160
185
  const { value } = e.target;
161
186
  setDropOpen(true);
@@ -327,7 +352,10 @@ const AutoComplete = forwardRef<HTMLInputElement, AutoSuggestionInputProps>(
327
352
  : searchValue || inputValue
328
353
  }
329
354
  onChange={handleChange}
330
- // onBlur={handleBlur}
355
+ onBlur={() => {
356
+ handleBlur();
357
+ selectExactMatchFromSuggestions();
358
+ }}
331
359
  onFocus={onFocus}
332
360
  onClick={() => handleOnClick()}
333
361
  className={generateClassName()}
@@ -489,6 +489,32 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
489
489
  // const getPosition = () => {
490
490
  // return 'bottom'
491
491
  // }
492
+ const selectExactMatchFromSuggestions = () => {
493
+ if (!inputValue) {
494
+ return;
495
+ }
496
+
497
+ if (!filteredData || filteredData.length === 0) {
498
+ // No suggestions to match against – notify parent with raw value
499
+ onChange({ id: undefined, name: inputValue, from: 4 });
500
+ return;
501
+ }
502
+
503
+ const normalizedInput = inputValue.toString().trim().toLowerCase();
504
+ const matchIndex = filteredData.findIndex((item: valueProps) => {
505
+ const name = item?.name?.toString().trim().toLowerCase();
506
+ const label = item?.label?.toString().trim().toLowerCase();
507
+ return name === normalizedInput || label === normalizedInput;
508
+ });
509
+
510
+ if (matchIndex >= 0) {
511
+ const match = filteredData[matchIndex];
512
+ handleSuggestionClick(match, matchIndex);
513
+ } else {
514
+ // No exact match – notify parent with typed value
515
+ onChange({ id: undefined, name: inputValue, from: 4 });
516
+ }
517
+ };
492
518
  const filteredData =
493
519
  inputValue !== '*' &&
494
520
  inputValue !== '' &&
@@ -794,7 +820,10 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
794
820
  type="text"
795
821
  readOnly={readOnly ?? type === 'custom_select'}
796
822
  value={inputValue ? inputValue : ''}
797
- onBlur={handleClearInputValue}
823
+ onBlur={() => {
824
+ handleClearInputValue();
825
+ selectExactMatchFromSuggestions();
826
+ }}
798
827
  autoComplete="off"
799
828
  disabled={disabled}
800
829
  ref={inputRef}
@@ -511,6 +511,32 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
511
511
  // const getPosition = () => {
512
512
  // return 'bottom'
513
513
  // }
514
+ const selectExactMatchFromSuggestions = () => {
515
+ if (!inputValue) {
516
+ return;
517
+ }
518
+
519
+ if (!filteredData || filteredData.length === 0) {
520
+ // No suggestions to match against – notify parent with raw value
521
+ onChange({ id: undefined, name: inputValue, from: 4 });
522
+ return;
523
+ }
524
+
525
+ const normalizedInput = inputValue.toString().trim().toLowerCase();
526
+ const matchIndex = filteredData.findIndex((item: valueProps) => {
527
+ const name = item?.name?.toString().trim().toLowerCase();
528
+ const label = item?.label?.toString().trim().toLowerCase();
529
+ return name === normalizedInput || label === normalizedInput;
530
+ });
531
+
532
+ if (matchIndex >= 0) {
533
+ const match = filteredData[matchIndex];
534
+ handleSuggestionClick(match, matchIndex);
535
+ } else {
536
+ // No exact match – notify parent with typed value
537
+ onChange({ id: undefined, name: inputValue, from: 4 });
538
+ }
539
+ };
514
540
  const filteredData =
515
541
  inputValue !== '*' &&
516
542
  inputValue !== '' &&
@@ -817,7 +843,10 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
817
843
  type="text"
818
844
  readOnly={readOnly ?? type === 'custom_select'}
819
845
  value={inputValue ? inputValue : ''}
820
- onBlur={handleClearInputValue}
846
+ onBlur={() => {
847
+ handleClearInputValue();
848
+ selectExactMatchFromSuggestions();
849
+ }}
821
850
  autoComplete="off"
822
851
  disabled={disabled}
823
852
  ref={inputRef}