react-core-ts 2.0.24 → 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.
- package/dist/AutoComplete.js +28 -3
- package/dist/AutoComplete.js.map +1 -1
- package/dist/ReactAutoComplete.js +29 -1
- package/dist/ReactAutoComplete.js.map +1 -1
- package/dist/ReactAutoCompleteDropdown.js +29 -1
- package/dist/ReactAutoCompleteDropdown.js.map +1 -1
- package/dist/ReactAutoCompleteSuggections.d.ts +74 -0
- package/dist/ReactAutoCompleteSuggections.js +379 -0
- package/dist/ReactAutoCompleteSuggections.js.map +1 -0
- package/dist/dropdownFilterTabs.js +128 -94
- package/dist/dropdownFilterTabs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/styles/components/autocomplete.css +744 -0
- package/dist/styles/styles/components/selectedautocomplete.css +221 -0
- package/dist/styles/styles/components/tooltip.css +497 -0
- package/dist/styles/styles/components/treedropdown.css +97 -0
- package/dist/styles/styles/global.css +8 -0
- package/docs/App.tsx +16 -1
- package/package.json +1 -1
- package/src/AutoComplete.tsx +29 -1
- package/src/ReactAutoComplete.tsx +30 -1
- package/src/ReactAutoCompleteDropdown.tsx +30 -1
- package/src/ReactAutoCompleteSuggections.tsx +559 -0
- package/src/dropdownFilterTabs.tsx +73 -35
- package/src/index.tsx +1 -0
|
@@ -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
|
+
}
|
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");
|
|
@@ -241,6 +242,20 @@ export default function App() {
|
|
|
241
242
|
/>
|
|
242
243
|
</div>
|
|
243
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
|
+
|
|
244
259
|
<div style={{ width: 300 }}>
|
|
245
260
|
<ModernAutoCompleteDropdown
|
|
246
261
|
name="sample"
|
package/package.json
CHANGED
package/src/AutoComplete.tsx
CHANGED
|
@@ -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
|
-
|
|
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={
|
|
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={
|
|
846
|
+
onBlur={() => {
|
|
847
|
+
handleClearInputValue();
|
|
848
|
+
selectExactMatchFromSuggestions();
|
|
849
|
+
}}
|
|
821
850
|
autoComplete="off"
|
|
822
851
|
disabled={disabled}
|
|
823
852
|
ref={inputRef}
|