react-core-ts 1.0.42 → 1.0.43
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/README.md +50 -0
- package/dist/AutoComplete.d.ts +2 -2
- package/dist/AutoComplete.js +44 -37
- package/dist/AutoComplete.js.map +1 -1
- package/dist/AutoCompleteWithSelectedList.d.ts +4 -0
- package/dist/AutoCompleteWithSelectedList.js +446 -0
- package/dist/AutoCompleteWithSelectedList.js.map +1 -0
- package/dist/ExpandableAutoComplete.js +12 -5
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/commontypes.d.ts +11 -4
- package/dist/components/DropdownList.js +2 -2
- package/dist/components/DropdownList.js.map +1 -1
- package/dist/components/InputActions.d.ts +1 -0
- package/dist/components/InputActions.js +2 -2
- package/dist/components/InputActions.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 +602 -0
- package/dist/styles/styles/components/selectedautocomplete.css +121 -0
- package/dist/styles/styles/components/treedropdown.css +63 -0
- package/dist/styles/styles/global.css +7 -0
- package/dist/utilities/autosuggestions.d.ts +2 -2
- package/dist/utilities/autosuggestions.js +10 -7
- package/dist/utilities/autosuggestions.js.map +1 -1
- package/dist/utilities/filterSuggestions.d.ts +1 -1
- package/dist/utilities/filterSuggestions.js +10 -5
- package/dist/utilities/filterSuggestions.js.map +1 -1
- package/docs/App.tsx +96 -4
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/AutoComplete.tsx +66 -51
- package/src/AutoCompleteWithSelectedList.tsx +677 -0
- package/src/ExpandableAutoComplete.tsx +13 -5
- package/src/commontypes.ts +14 -6
- package/src/components/DropdownList.tsx +3 -3
- package/src/components/InputActions.tsx +3 -1
- package/src/index.html +1 -1
- package/src/index.tsx +1 -0
- package/src/styles/components/autocomplete.css +18 -1
- package/src/styles/components/selectedautocomplete.css +121 -0
- package/src/styles/global.css +2 -1
- package/src/utilities/autosuggestions.ts +18 -12
- package/src/utilities/filterSuggestions.ts +10 -7
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
.qbs-flex {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
.qbs-flex-wrap {
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
}
|
|
7
|
+
.qbs-w-full {
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
.qbs-mb-2 {
|
|
11
|
+
margin-bottom: 0.5rem;
|
|
12
|
+
}
|
|
13
|
+
.-qbs-mt-2 {
|
|
14
|
+
margin-top: -0.5rem;
|
|
15
|
+
}
|
|
16
|
+
.qbs-flex-1 {
|
|
17
|
+
flex: 1 1 0%;
|
|
18
|
+
}
|
|
19
|
+
.qbs-inline-block {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
}
|
|
22
|
+
.qbs-text-sm {
|
|
23
|
+
font-size: 0.875rem;
|
|
24
|
+
}
|
|
25
|
+
.qbs-cursor-pointer {
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
.qbs-text-center {
|
|
29
|
+
text-align: center;
|
|
30
|
+
}
|
|
31
|
+
.qbs-p-1 {
|
|
32
|
+
padding: 0.25rem;
|
|
33
|
+
}
|
|
34
|
+
.qbs-border-b-2 {
|
|
35
|
+
border-bottom-width: 2px;
|
|
36
|
+
}
|
|
37
|
+
.qbs-tab-item {
|
|
38
|
+
color: #4b5563;
|
|
39
|
+
border-color: #d1d5db;
|
|
40
|
+
}
|
|
41
|
+
.qbs-tab-item:hover {
|
|
42
|
+
color: #2563eb;
|
|
43
|
+
}
|
|
44
|
+
.qbs-tab-active-item {
|
|
45
|
+
color: #2563eb;
|
|
46
|
+
border-color: #2563eb;
|
|
47
|
+
}
|
|
48
|
+
.qbs-relative {
|
|
49
|
+
position: relative;
|
|
50
|
+
}
|
|
51
|
+
.qbs-gap-1 {
|
|
52
|
+
gap: 0.25rem;
|
|
53
|
+
}
|
|
54
|
+
.qbs-rounded-full {
|
|
55
|
+
border-radius: 9999px;
|
|
56
|
+
}
|
|
57
|
+
.qbs-text-xs {
|
|
58
|
+
font-size: 0.75rem;
|
|
59
|
+
}
|
|
60
|
+
.qbs-inline-flex {
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
}
|
|
63
|
+
.qbs-items-center {
|
|
64
|
+
align-items: center;
|
|
65
|
+
}
|
|
66
|
+
.qbs-justify-center {
|
|
67
|
+
justify-content: center;
|
|
68
|
+
}
|
|
69
|
+
.qbs-px-2 {
|
|
70
|
+
padding-left: 0.5rem;
|
|
71
|
+
padding-right: 0.5rem;
|
|
72
|
+
}
|
|
73
|
+
.qbs-py-1 {
|
|
74
|
+
padding-top: 0.25rem;
|
|
75
|
+
padding-bottom: 0.25rem;
|
|
76
|
+
}
|
|
77
|
+
.qbs-leading-none {
|
|
78
|
+
line-height: 1;
|
|
79
|
+
}
|
|
80
|
+
.qbs-min-w-6 {
|
|
81
|
+
min-width: 1.5rem;
|
|
82
|
+
}
|
|
83
|
+
.qbs-min-h-6 {
|
|
84
|
+
min-height: 1.5rem;
|
|
85
|
+
}
|
|
86
|
+
.qbs-align-middle {
|
|
87
|
+
vertical-align: middle;
|
|
88
|
+
}
|
|
89
|
+
.qbs-min-emp-h {
|
|
90
|
+
min-height: 183px;
|
|
91
|
+
}
|
|
92
|
+
.qbs-py-80 {
|
|
93
|
+
padding-top: 80px;
|
|
94
|
+
padding-bottom: 80px;
|
|
95
|
+
}
|
|
96
|
+
.qbs-flex-grow {
|
|
97
|
+
flex-grow: 1;
|
|
98
|
+
}
|
|
99
|
+
.qbs-text-right {
|
|
100
|
+
text-align: right;
|
|
101
|
+
}
|
|
102
|
+
.qbs-readmore-collapse {
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
width: 100%;
|
|
105
|
+
text-align: center;
|
|
106
|
+
display: flex;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
margin-top: 5px;
|
|
109
|
+
}
|
|
110
|
+
.qbs-readmore-collapse div {
|
|
111
|
+
border-radius: 9999px;
|
|
112
|
+
min-width: 1.5rem;
|
|
113
|
+
min-height: 1.5rem;
|
|
114
|
+
padding: 5px;
|
|
115
|
+
}
|
|
116
|
+
.qbs-more-collapse:hover {
|
|
117
|
+
background-color: #d1d5db;
|
|
118
|
+
}
|
|
119
|
+
.qbs-hidden {
|
|
120
|
+
display: none;
|
|
121
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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: 1rem; /* Corresponds to gap-4 in Tailwind */
|
|
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
|
+
}
|
|
22
|
+
|
|
23
|
+
.qbs-tree-list-container-sub-icon.expanded {
|
|
24
|
+
transform: rotate(90deg); /* Corresponds to rotate-90 in Tailwind */
|
|
25
|
+
}
|
|
26
|
+
.qbs-tree-list-container-sub-container {
|
|
27
|
+
display: flex;
|
|
28
|
+
gap: 0.5rem; /* Corresponds to gap-2 in Tailwind */
|
|
29
|
+
padding: 0.5rem; /* Corresponds to p-2 in Tailwind */
|
|
30
|
+
flex-direction: row; /* Corresponds to flex-row in Tailwind */
|
|
31
|
+
width: 100%; /* Corresponds to w-full in Tailwind */
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.qbs-tree-list-container-sub-container.checked {
|
|
35
|
+
background-color: rgba(
|
|
36
|
+
141,
|
|
37
|
+
194,
|
|
38
|
+
240,
|
|
39
|
+
0.15
|
|
40
|
+
) !important; /* Corresponds to bg-green-200 in Tailwind */
|
|
41
|
+
}
|
|
42
|
+
.qbs-tree-list-container-sub-container.marginLeft {
|
|
43
|
+
margin-left: 28px; /* Corresponds to ml-2 in Tailwind */
|
|
44
|
+
}
|
|
45
|
+
.qbs-tree-list-container-sub- {
|
|
46
|
+
line-height: 18px; /* Corresponds to leading-[18px] in Tailwind */
|
|
47
|
+
font-size: 0.875rem; /* Corresponds to text-sm in Tailwind (14px) */
|
|
48
|
+
}
|
|
49
|
+
.qbs-tree-list-container-child {
|
|
50
|
+
margin-left: 1rem; /* Corresponds to ml-4 in Tailwind */
|
|
51
|
+
margin-top: 0.5rem; /* Corresponds to mt-2 in Tailwind */
|
|
52
|
+
display: flex; /* Corresponds to flex in Tailwind */
|
|
53
|
+
flex-direction: column; /* Corresponds to flex-col in Tailwind */
|
|
54
|
+
gap: 0.5rem; /* Corresponds to gap-2 in Tailwind */
|
|
55
|
+
}
|
|
56
|
+
.qbs-tree-list-container-sub-text {
|
|
57
|
+
line-height: 18px; /* Corresponds to leading-[18px] in Tailwind */
|
|
58
|
+
font-size: 14px; /* Corresponds to text-sm in Tailwind (14px) */
|
|
59
|
+
font-weight: 500;
|
|
60
|
+
letter-spacing: 0.28px;
|
|
61
|
+
font-family: 'Noto Sans';
|
|
62
|
+
color: #3d414a;
|
|
63
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
type ValueProps = {
|
|
2
2
|
[key: string]: string;
|
|
3
3
|
};
|
|
4
|
-
type UseSuggestionsType = (getData: (key?: string, next?: number) => Promise<ValueProps[]>, initialData?: ValueProps[], dropOpen?: boolean, asyncFetch?: boolean, paginationEnabled?: boolean,
|
|
4
|
+
type UseSuggestionsType = (getData: (key?: string, next?: number, tabValue?: number | string) => Promise<ValueProps[]>, initialData?: ValueProps[], dropOpen?: boolean, asyncFetch?: boolean, paginationEnabled?: boolean, typeOnlyFetch?: boolean, inputValue?: string, isMultiple?: boolean, setNextPage?: (value: number) => void, selectedItems?: any[], initialLoad?: boolean) => {
|
|
5
5
|
suggestions: ValueProps[];
|
|
6
6
|
isLoading: boolean;
|
|
7
|
-
handlePickSuggestions: (value?: string, next?: number, append?: boolean) => Promise<void>;
|
|
7
|
+
handlePickSuggestions: (value?: string, next?: number, append?: boolean, tabValue?: string | number) => Promise<void>;
|
|
8
8
|
};
|
|
9
9
|
export declare const useSuggestions: UseSuggestionsType;
|
|
10
10
|
export {};
|
|
@@ -47,17 +47,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.useSuggestions = void 0;
|
|
49
49
|
var react_1 = require("react");
|
|
50
|
-
var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, paginationEnabled, initialLoad, inputValue, isMultiple, setNextPage, selectedItems) {
|
|
50
|
+
var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, paginationEnabled, initialLoad, inputValue, isMultiple, setNextPage, selectedItems, typeOnlyFetch) {
|
|
51
51
|
if (initialData === void 0) { initialData = []; }
|
|
52
52
|
if (dropOpen === void 0) { dropOpen = false; }
|
|
53
53
|
if (asyncFetch === void 0) { asyncFetch = false; }
|
|
54
54
|
if (paginationEnabled === void 0) { paginationEnabled = false; }
|
|
55
55
|
if (initialLoad === void 0) { initialLoad = false; }
|
|
56
|
-
if (inputValue === void 0) { inputValue =
|
|
56
|
+
if (inputValue === void 0) { inputValue = ""; }
|
|
57
57
|
if (selectedItems === void 0) { selectedItems = []; }
|
|
58
|
+
if (typeOnlyFetch === void 0) { typeOnlyFetch = false; }
|
|
58
59
|
var _a = (0, react_1.useState)(initialData), suggestions = _a[0], setSuggestions = _a[1];
|
|
59
60
|
var _b = (0, react_1.useState)(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
60
|
-
var handlePickSuggestions = function (value, nextPage, appendData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var handlePickSuggestions = function (value, nextPage, appendData, tabValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
62
|
var data, newSuggestions, error_1;
|
|
62
63
|
return __generator(this, function (_a) {
|
|
63
64
|
switch (_a.label) {
|
|
@@ -67,7 +68,9 @@ var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, pagin
|
|
|
67
68
|
case 1:
|
|
68
69
|
_a.trys.push([1, 3, 4, 5]);
|
|
69
70
|
return [4 /*yield*/, (asyncFetch || initialLoad
|
|
70
|
-
?
|
|
71
|
+
? typeOnlyFetch && value === ""
|
|
72
|
+
? Promise.resolve([])
|
|
73
|
+
: getData(value, nextPage, tabValue)
|
|
71
74
|
: Promise.resolve(initialData))];
|
|
72
75
|
case 2:
|
|
73
76
|
data = _a.sent();
|
|
@@ -79,7 +82,7 @@ var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, pagin
|
|
|
79
82
|
return [3 /*break*/, 5];
|
|
80
83
|
case 3:
|
|
81
84
|
error_1 = _a.sent();
|
|
82
|
-
console.error(
|
|
85
|
+
console.error("Error fetching data:", error_1);
|
|
83
86
|
return [3 /*break*/, 5];
|
|
84
87
|
case 4:
|
|
85
88
|
setIsLoading(false);
|
|
@@ -92,13 +95,13 @@ var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, pagin
|
|
|
92
95
|
if (dropOpen) {
|
|
93
96
|
if (!isMultiple && (!inputValue || suggestions.length === 0)) {
|
|
94
97
|
setNextPage(1);
|
|
95
|
-
handlePickSuggestions(
|
|
98
|
+
handlePickSuggestions("", paginationEnabled ? 1 : undefined);
|
|
96
99
|
}
|
|
97
100
|
else if (isMultiple &&
|
|
98
101
|
(suggestions.length === 0 ||
|
|
99
102
|
!selectedItems ||
|
|
100
103
|
(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) === 0)) {
|
|
101
|
-
handlePickSuggestions(
|
|
104
|
+
handlePickSuggestions("", paginationEnabled ? 1 : undefined);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
}, [dropOpen]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autosuggestions.js","sourceRoot":"","sources":["../../src/utilities/autosuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4C;
|
|
1
|
+
{"version":3,"file":"autosuggestions.js","sourceRoot":"","sources":["../../src/utilities/autosuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4C;AA8BrC,IAAM,cAAc,GAAuB,UAChD,OAAO,EACP,WAAgB,EAChB,QAAgB,EAChB,UAAkB,EAClB,iBAAyB,EACzB,WAAmB,EACnB,UAAe,EACf,UAAU,EACV,WAAW,EACX,aAAkB,EAClB,aAAqB;IATrB,4BAAA,EAAA,gBAAgB;IAChB,yBAAA,EAAA,gBAAgB;IAChB,2BAAA,EAAA,kBAAkB;IAClB,kCAAA,EAAA,yBAAyB;IACzB,4BAAA,EAAA,mBAAmB;IACnB,2BAAA,EAAA,eAAe;IAGf,8BAAA,EAAA,kBAAkB;IAClB,8BAAA,EAAA,qBAAqB;IAEf,IAAA,KAAgC,IAAA,gBAAQ,EAAe,WAAW,CAAC,EAAlE,WAAW,QAAA,EAAE,cAAc,QAAuC,CAAC;IACpE,IAAA,KAA4B,IAAA,gBAAQ,EAAU,KAAK,CAAC,EAAnD,SAAS,QAAA,EAAE,YAAY,QAA4B,CAAC;IAE3D,IAAM,qBAAqB,GAAG,UAC5B,KAAc,EACd,QAAiB,EACjB,UAAoB,EACpB,QAA0B;;;;;oBAE1B,YAAY,CAAC,IAAI,CAAC,CAAC;;;;oBAEJ,qBAAM,CAAC,UAAU,IAAI,WAAW;4BAC3C,CAAC,CAAC,aAAa,IAAI,KAAK,KAAK,EAAE;gCAC7B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gCACrB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC;4BACtC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAA;;oBAJ3B,IAAI,GAAG,SAIoB;oBACjC,IAAI,CAAC,IAAI,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,MAAK,CAAC,EAAE;wBAC/B,WAAW,CAAC,SAAS,CAAC,CAAC;qBACxB;oBACK,cAAc,GAAG,UAAU,CAAC,CAAC,iCAAK,WAAW,SAAK,IAAI,QAAE,CAAC,CAAC,IAAI,CAAC;oBACrE,cAAc,CAAC,cAAc,CAAC,CAAC;;;;oBAE/B,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,OAAK,CAAC,CAAC;;;oBAE7C,YAAY,CAAC,KAAK,CAAC,CAAC;;;;;SAEvB,CAAC;IAEF,IAAA,iBAAS,EAAC;QACR,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;gBAC5D,WAAW,CAAC,CAAC,CAAC,CAAC;gBACf,qBAAqB,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;aAC9D;iBAAM,IACL,UAAU;gBACV,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;oBACvB,CAAC,aAAa;oBACd,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,MAAK,CAAC,CAAC,EAC9B;gBACA,qBAAqB,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;aAC9D;SACF;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,EAAE,WAAW,aAAA,EAAE,SAAS,WAAA,EAAE,qBAAqB,uBAAA,EAAE,CAAC;AAC3D,CAAC,CAAC;AA1DW,QAAA,cAAc,kBA0DzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
interface Item {
|
|
2
2
|
[key: string]: string;
|
|
3
3
|
}
|
|
4
|
-
export declare const filterSuggestions: (data: Item[], query: string, type: string, desc: string, inputValue?: string, async?: boolean, isTreeDropdown?: boolean) => Item[];
|
|
4
|
+
export declare const filterSuggestions: (data: Item[], query: string, type: string, desc: string, inputValue?: any[] | string, async?: boolean, isTreeDropdown?: boolean, withoutSort?: boolean) => Item[];
|
|
5
5
|
export {};
|
|
@@ -10,10 +10,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.filterSuggestions = void 0;
|
|
13
|
-
var filterSuggestions = function (data, query, type, desc, inputValue, async,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var filterSuggestions = function (data, query, type, desc, inputValue, async, // API filter
|
|
14
|
+
isTreeDropdown, // Tree dropdowns
|
|
15
|
+
withoutSort // Don't show selected items on top of the suggections
|
|
16
|
+
) {
|
|
17
|
+
if ((type === "custom_search_select" ||
|
|
18
|
+
type === "auto_complete" ||
|
|
19
|
+
type === "auto_suggestion") &&
|
|
17
20
|
!async &&
|
|
18
21
|
query &&
|
|
19
22
|
!isTreeDropdown) {
|
|
@@ -21,7 +24,9 @@ var filterSuggestions = function (data, query, type, desc, inputValue, async, is
|
|
|
21
24
|
return item[desc].toLowerCase().includes(query.toLowerCase());
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
|
-
return isTreeDropdown
|
|
27
|
+
return isTreeDropdown || withoutSort
|
|
28
|
+
? data
|
|
29
|
+
: sortedArrayData(data, inputValue, desc);
|
|
25
30
|
};
|
|
26
31
|
exports.filterSuggestions = filterSuggestions;
|
|
27
32
|
var sortedArrayData = function (filteredData, selectedItems, desc) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterSuggestions.js","sourceRoot":"","sources":["../../src/utilities/filterSuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIO,IAAM,iBAAiB,GAAG,UAC/B,IAAY,EACZ,KAAa,EACb,IAAY,EACZ,IAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"filterSuggestions.js","sourceRoot":"","sources":["../../src/utilities/filterSuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIO,IAAM,iBAAiB,GAAG,UAC/B,IAAY,EACZ,KAAa,EACb,IAAY,EACZ,IAAY,EACZ,UAA2B,EAC3B,KAAe,EAAE,aAAa;AAC9B,cAAwB,EAAE,iBAAiB;AAC3C,WAAqB,CAAC,sDAAsD;;IAE5E,IACE,CAAC,IAAI,KAAK,sBAAsB;QAC9B,IAAI,KAAK,eAAe;QACxB,IAAI,KAAK,iBAAiB,CAAC;QAC7B,CAAC,KAAK;QACN,KAAK;QACL,CAAC,cAAc,EACf;QACA,OAAO,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,CAAC,UAAC,IAAI;YACvB,OAAA,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAAtD,CAAsD,CACvD,CAAC;KACH;IACD,OAAO,cAAc,IAAI,WAAW;QAClC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC;AAzBW,QAAA,iBAAiB,qBAyB5B;AAEF,IAAM,eAAe,GAAG,UACtB,YAAmB,EACnB,aAA6B,EAC7B,IAAS;IAET,OAAO,kBAAI,YAAY,QAAE,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC;QACjC,IAAI,WAAoB,CAAC;QACzB,IAAI,WAAoB,CAAC;QAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YAChC,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAtB,CAAsB,CAAC,CAAC;YACnE,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAtB,CAAsB,CAAC,CAAC;SACpE;aAAM;YACL,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,aAAa,CAAC;YACxC,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,aAAa,CAAC;SACzC;QAED,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/docs/App.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
AutoComplete,
|
|
5
|
+
AutoCompleteWithSelectedList,
|
|
5
6
|
AutoCompleteWithTreeStructure,
|
|
6
7
|
ExpandableAutoComplete,
|
|
7
8
|
} from "../src/index";
|
|
@@ -44,6 +45,23 @@ export default function App() {
|
|
|
44
45
|
return result;
|
|
45
46
|
});
|
|
46
47
|
};
|
|
48
|
+
|
|
49
|
+
const getDataWithTab = (keyName?: string, next?: number, tab?: number | string) => {
|
|
50
|
+
console.log(tab)
|
|
51
|
+
return fetch(
|
|
52
|
+
keyName
|
|
53
|
+
? `https://jsonplaceholder.typicode.com/posts?_page=${next}&_limit=10&title_like=${keyName}`
|
|
54
|
+
: `https://jsonplaceholder.typicode.com/posts?_page=${next}&_limit=10`
|
|
55
|
+
)
|
|
56
|
+
.then((res) => res.json())
|
|
57
|
+
.then((res) => {
|
|
58
|
+
setNexBlock(nexBlock + 1);
|
|
59
|
+
const result = res.map((item: any) => {
|
|
60
|
+
return { ...item, ["name"]: item?.title, id: item?.id.toString() };
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
47
65
|
return (
|
|
48
66
|
<React.Fragment>
|
|
49
67
|
<div
|
|
@@ -79,12 +97,19 @@ export default function App() {
|
|
|
79
97
|
initialLoad={true}
|
|
80
98
|
itemCount={5}
|
|
81
99
|
// nextBlock={nexBlock}
|
|
82
|
-
placeholder="Auto Suggestion
|
|
83
|
-
selectedItems={[
|
|
100
|
+
placeholder="Auto Suggestion"
|
|
101
|
+
selectedItems={[]}
|
|
84
102
|
getData={getData}
|
|
85
103
|
onChange={(e) => console.log(e, "onchange")}
|
|
86
104
|
/>
|
|
87
105
|
</div>
|
|
106
|
+
<div className="autocomplete-section">
|
|
107
|
+
<h2>TreeView Auto Suggestion</h2>
|
|
108
|
+
<p>
|
|
109
|
+
Able to select, expand/collapse child items based on the suggections
|
|
110
|
+
data
|
|
111
|
+
</p>
|
|
112
|
+
</div>
|
|
88
113
|
<div style={{ width: 800 }}>
|
|
89
114
|
<AutoCompleteWithTreeStructure
|
|
90
115
|
label="Auto Suggestion"
|
|
@@ -103,12 +128,79 @@ export default function App() {
|
|
|
103
128
|
initialLoad={false}
|
|
104
129
|
itemCount={5}
|
|
105
130
|
// nextBlock={nexBlock}
|
|
106
|
-
placeholder="Auto Suggestion
|
|
131
|
+
placeholder="Auto Suggestion"
|
|
107
132
|
selectedItems={[{ name: "test", id: "1" }]}
|
|
108
133
|
// getData={getData}
|
|
109
134
|
onChange={(e) => console.log(e, "onchange")}
|
|
110
135
|
/>
|
|
111
136
|
</div>
|
|
137
|
+
|
|
138
|
+
<div className="autocomplete-section">
|
|
139
|
+
<h2>Auto Suggestion with Selected list</h2>
|
|
140
|
+
<p>
|
|
141
|
+
Selected items will be displayed in the suggestion box, with options
|
|
142
|
+
to expand/collapse and clear them. The select box will show the
|
|
143
|
+
total number of things selected.
|
|
144
|
+
</p>
|
|
145
|
+
</div>
|
|
146
|
+
<div style={{ width: 300 }}>
|
|
147
|
+
<AutoCompleteWithSelectedList
|
|
148
|
+
label="Auto Suggestion With Data"
|
|
149
|
+
name="sample"
|
|
150
|
+
type="auto_suggestion"
|
|
151
|
+
// async
|
|
152
|
+
desc="name"
|
|
153
|
+
isMultiple={true}
|
|
154
|
+
singleSelect={false}
|
|
155
|
+
descId="id"
|
|
156
|
+
data={treeDropData}
|
|
157
|
+
paginationEnabled={false}
|
|
158
|
+
initialLoad={false}
|
|
159
|
+
itemCount={3}
|
|
160
|
+
placeholder="Auto Suggestion"
|
|
161
|
+
selectedItems={[]}
|
|
162
|
+
onChange={(e) => console.log(e, "onchange")}
|
|
163
|
+
countOnly={true}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
<div style={{ width: 300 }}>
|
|
167
|
+
<AutoCompleteWithSelectedList
|
|
168
|
+
label="Auto Suggestion API Data"
|
|
169
|
+
name="sample"
|
|
170
|
+
type="auto_suggestion"
|
|
171
|
+
async={true}
|
|
172
|
+
desc="name"
|
|
173
|
+
isMultiple={true}
|
|
174
|
+
typeOnlyFetch={true}
|
|
175
|
+
descId="id"
|
|
176
|
+
getData={getData}
|
|
177
|
+
itemCount={3}
|
|
178
|
+
placeholder="Auto Suggestion"
|
|
179
|
+
selectedItems={[]}
|
|
180
|
+
onChange={(e) => console.log(e, "onchange")}
|
|
181
|
+
countOnly={true}
|
|
182
|
+
/>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div style={{ width: 300 }}>
|
|
186
|
+
<AutoCompleteWithSelectedList
|
|
187
|
+
label="Auto Suggestion API Data With Tab"
|
|
188
|
+
name="sample"
|
|
189
|
+
type="auto_suggestion"
|
|
190
|
+
async={true}
|
|
191
|
+
desc="name"
|
|
192
|
+
isMultiple={true}
|
|
193
|
+
typeOnlyFetch={true}
|
|
194
|
+
descId="id"
|
|
195
|
+
getData={getDataWithTab}
|
|
196
|
+
itemCount={3}
|
|
197
|
+
placeholder="Auto Suggestion"
|
|
198
|
+
selectedItems={[]}
|
|
199
|
+
onChange={(e) => console.log(e, "onchange")}
|
|
200
|
+
countOnly={true}
|
|
201
|
+
tab={[{id: 1, label: "Tab 1"}, {id: 2, label: "Tab 2"}]}
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
112
204
|
<div className="autocomplete-section">
|
|
113
205
|
<h2>Custom Select</h2>
|
|
114
206
|
<p>
|
|
@@ -289,7 +381,7 @@ export default function App() {
|
|
|
289
381
|
initialLoad={true}
|
|
290
382
|
itemCount={5}
|
|
291
383
|
// nextBlock={nexBlock}
|
|
292
|
-
placeholder="Auto Suggestion
|
|
384
|
+
placeholder="Auto Suggestion"
|
|
293
385
|
selectedItems={[{ name: "test", id: "1" }]}
|
|
294
386
|
getData={getData}
|
|
295
387
|
onChange={(e) => console.log(e, "onchange")}
|
package/docs/index.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
work correctly both with client-side routing and a non-root public URL.
|
|
22
22
|
Learn how to configure a non-root public URL by running `npm run build`.
|
|
23
23
|
-->
|
|
24
|
-
<title>
|
|
24
|
+
<title>Autocomplete App</title>
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|