react-core-ts 1.0.22 → 1.0.24

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 (44) hide show
  1. package/dist/AutoCompleteWithTreeStructure.d.ts +4 -0
  2. package/dist/AutoCompleteWithTreeStructure.js +453 -0
  3. package/dist/AutoCompleteWithTreeStructure.js.map +1 -0
  4. package/dist/ExpandableAutoComplete.d.ts +2 -2
  5. package/dist/ExpandableAutoComplete.js +54 -71
  6. package/dist/ExpandableAutoComplete.js.map +1 -1
  7. package/dist/commontypes.d.ts +3 -2
  8. package/dist/components/DropdownList.d.ts +14 -0
  9. package/dist/components/DropdownList.js +18 -0
  10. package/dist/components/DropdownList.js.map +1 -0
  11. package/dist/components/Icons.d.ts +3 -0
  12. package/dist/components/Icons.js +18 -0
  13. package/dist/components/Icons.js.map +1 -0
  14. package/dist/components/InputActions.d.ts +14 -0
  15. package/dist/components/InputActions.js +18 -0
  16. package/dist/components/InputActions.js.map +1 -0
  17. package/dist/components/TreeNode.d.ts +3 -0
  18. package/dist/components/TreeNode.js +34 -0
  19. package/dist/components/TreeNode.js.map +1 -0
  20. package/dist/index.d.ts +8 -8
  21. package/dist/index.js +6 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/styles/components/autocomplete.css +4 -1
  24. package/dist/styles/global.css +4 -0
  25. package/dist/styles/styles/global.css +4 -0
  26. package/dist/utilities/filterSuggestions.d.ts +1 -1
  27. package/dist/utilities/filterSuggestions.js +4 -3
  28. package/dist/utilities/filterSuggestions.js.map +1 -1
  29. package/docs/App.tsx +64 -36
  30. package/docs/store.ts +76 -0
  31. package/package.json +6 -5
  32. package/postcss.config.js +4 -5
  33. package/src/AutoCompleteWithTreeStructure.tsx +638 -0
  34. package/src/ExpandableAutoComplete.tsx +83 -144
  35. package/src/commontypes.ts +6 -5
  36. package/src/components/DropdownList.tsx +70 -0
  37. package/src/components/Icons.tsx +38 -0
  38. package/src/components/InputActions.tsx +63 -0
  39. package/src/components/TreeNode.tsx +79 -0
  40. package/src/index.tsx +11 -8
  41. package/src/styles/global.css +4 -0
  42. package/src/utilities/filterSuggestions.ts +5 -3
  43. package/tailwind.config.js +15 -0
  44. package/webpack.config.js +17 -3
@@ -255,6 +255,9 @@ body * {
255
255
  cursor: pointer;
256
256
  padding: 0px 1px;
257
257
  }
258
+ .icon-button-rotate{
259
+ rotate: 180deg;
260
+ }
258
261
  .labels {
259
262
  font-size: 12px;
260
263
  }
@@ -275,7 +278,7 @@ body * {
275
278
  .qbs-autocomplete-suggestions-sub {
276
279
  position: relative;
277
280
  overflow: auto;
278
- max-height: 192px;
281
+ max-height: 184px;
279
282
  top: 0;
280
283
  display: flex;
281
284
  flex-direction: column;
@@ -1 +1,5 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
1
5
  @import './components/autocomplete.css';
@@ -1 +1,5 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
1
5
  @import './components/autocomplete.css';
@@ -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) => Item[];
4
+ export declare const filterSuggestions: (data: Item[], query: string, type: string, desc: string, inputValue?: string, async?: boolean, isTreeDropdown?: boolean) => Item[];
5
5
  export {};
@@ -10,17 +10,18 @@ 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) {
13
+ var filterSuggestions = function (data, query, type, desc, inputValue, async, isTreeDropdown) {
14
14
  if ((type === 'custom_search_select' ||
15
15
  type === 'auto_complete' ||
16
16
  type === 'auto_suggestion') &&
17
17
  !async &&
18
- query) {
18
+ query &&
19
+ !isTreeDropdown) {
19
20
  return data === null || data === void 0 ? void 0 : data.filter(function (item) {
20
21
  return item[desc].toLowerCase().includes(query.toLowerCase());
21
22
  });
22
23
  }
23
- return sortedArrayData(data, inputValue, desc);
24
+ return isTreeDropdown ? data : sortedArrayData(data, inputValue, desc);
24
25
  };
25
26
  exports.filterSuggestions = filterSuggestions;
26
27
  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,UAAmB,EACnB,KAAe;IAEf,IACE,CAAC,IAAI,KAAK,sBAAsB;QAC9B,IAAI,KAAK,eAAe;QACxB,IAAI,KAAK,iBAAiB,CAAC;QAC7B,CAAC,KAAK;QACN,KAAK,EACL;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,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC,CAAC;AApBW,QAAA,iBAAiB,qBAoB5B;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,CAA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AM,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
@@ -1,8 +1,13 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState } from "react";
2
2
 
3
- import { AutoComplete, ExpandableAutoComplete } from '../src/index';
3
+ import {
4
+ AutoComplete,
5
+ AutoCompleteWithTreeStructure,
6
+ ExpandableAutoComplete,
7
+ } from "../src/index";
4
8
 
5
- import '../src/styles/global.css';
9
+ import "../src/styles/global.css";
10
+ import { treeDropData } from "./store";
6
11
 
7
12
  export default function App() {
8
13
  const [dropData, setDropData] = useState();
@@ -19,7 +24,7 @@ export default function App() {
19
24
  .then((res) => {
20
25
  setNexBlock(nexBlock + 1);
21
26
  const result = res.map((item: any) => {
22
- return { ...item, ['name']: item?.title, id: item?.id.toString() };
27
+ return { ...item, ["name"]: item?.title, id: item?.id.toString() };
23
28
  });
24
29
  return result;
25
30
  });
@@ -34,7 +39,7 @@ export default function App() {
34
39
  .then((res) => {
35
40
  setPrev(prev + 1);
36
41
  const result = res.map((item: any) => {
37
- return { ...item, ['name']: item?.title, id: item?.id.toString() };
42
+ return { ...item, ["name"]: item?.title, id: item?.id.toString() };
38
43
  });
39
44
  return result;
40
45
  });
@@ -43,12 +48,12 @@ export default function App() {
43
48
  <React.Fragment>
44
49
  <div
45
50
  style={{
46
- display: 'flex',
47
- flexDirection: 'column',
51
+ display: "flex",
52
+ flexDirection: "column",
48
53
  gap: 20,
49
54
  padding: 20,
50
55
 
51
- overflowY: 'scroll',
56
+ overflowY: "scroll",
52
57
  }}
53
58
  >
54
59
  <div className="autocomplete-section">
@@ -60,7 +65,7 @@ export default function App() {
60
65
  input while still offering assistance.
61
66
  </p>
62
67
  </div>
63
- <div style={{ width: 300 }}>
68
+ <div style={{ width: 800 }}>
64
69
  <ExpandableAutoComplete
65
70
  label="Auto Suggestion"
66
71
  name="sample"
@@ -75,9 +80,32 @@ export default function App() {
75
80
  itemCount={5}
76
81
  // nextBlock={nexBlock}
77
82
  placeholder="Auto Suggestion Suggestion Suggestion Suggestion"
78
- selectedItems={[{ name: 'test', id: '1' }]}
83
+ selectedItems={[{ name: "test", id: "1" }]}
79
84
  getData={getData}
80
- onChange={(e) => console.log(e, 'onchange')}
85
+ onChange={(e) => console.log(e, "onchange")}
86
+ />
87
+ </div>
88
+ <div style={{ width: 800 }}>
89
+ <AutoCompleteWithTreeStructure
90
+ label="Auto Suggestion"
91
+ name="sample"
92
+ type="custom_select"
93
+ // async
94
+ desc="name"
95
+ isMultiple={true}
96
+ singleSelect={false}
97
+ expandable={true}
98
+ isTreeDropdown={true}
99
+ descId="id"
100
+ data={treeDropData}
101
+ paginationEnabled={false}
102
+ initialLoad={false}
103
+ itemCount={5}
104
+ // nextBlock={nexBlock}
105
+ placeholder="Auto Suggestion Suggestion Suggestion Suggestion"
106
+ selectedItems={[{ name: "test", id: "1" }]}
107
+ // getData={getData}
108
+ onChange={(e) => console.log(e, "onchange")}
81
109
  />
82
110
  </div>
83
111
  <div className="autocomplete-section">
@@ -96,15 +124,15 @@ export default function App() {
96
124
  descId="id"
97
125
  type="custom_select"
98
126
  data={[
99
- { name: 'test', id: '1' },
100
- { name: 'test1', id: '2' },
127
+ { name: "test", id: "1" },
128
+ { name: "test1", id: "2" },
101
129
 
102
- { name: 'test2', id: '3' },
130
+ { name: "test2", id: "3" },
103
131
 
104
- { name: 'test3', id: '4' },
132
+ { name: "test3", id: "4" },
105
133
  ]}
106
134
  // getData={getData}
107
- onChange={() => console.log('onchange')}
135
+ onChange={() => console.log("onchange")}
108
136
  />
109
137
  </div>
110
138
  <div className="autocomplete-section">
@@ -128,7 +156,7 @@ export default function App() {
128
156
  placeholder="Auto Complete"
129
157
  // data={[{ name: 'test', id: '1' }]}
130
158
  getData={getData}
131
- onChange={() => console.log('onchange')}
159
+ onChange={() => console.log("onchange")}
132
160
  />
133
161
  </div>
134
162
  <div style={{ width: 300 }}>
@@ -142,7 +170,7 @@ export default function App() {
142
170
  placeholder="Auto Complete"
143
171
  // data={[{ name: 'test', id: '1' }]}
144
172
  getData={getDatas}
145
- onChange={() => console.log('onchange')}
173
+ onChange={() => console.log("onchange")}
146
174
  />
147
175
  </div>
148
176
  <div className="autocomplete-section">
@@ -164,18 +192,18 @@ export default function App() {
164
192
  descId="id"
165
193
  type="custom_search_select"
166
194
  data={[
167
- { name: 'Apple', id: '1' },
168
- { name: 'Banana', id: '2' },
169
- { name: 'Cherry', id: '3' },
170
- { name: 'Date', id: '4' },
171
- { name: 'Fig', id: '5' },
172
- { name: 'Grape', id: '6' },
173
- { name: 'Honeydew', id: '7' },
174
- { name: 'Kiwi', id: '8' },
175
- { name: 'Lemon', id: '9' },
176
- { name: 'Mango', id: '10' },
195
+ { name: "Apple", id: "1" },
196
+ { name: "Banana", id: "2" },
197
+ { name: "Cherry", id: "3" },
198
+ { name: "Date", id: "4" },
199
+ { name: "Fig", id: "5" },
200
+ { name: "Grape", id: "6" },
201
+ { name: "Honeydew", id: "7" },
202
+ { name: "Kiwi", id: "8" },
203
+ { name: "Lemon", id: "9" },
204
+ { name: "Mango", id: "10" },
177
205
  ]}
178
- onChange={() => console.log('onchange')}
206
+ onChange={() => console.log("onchange")}
179
207
  />
180
208
  </div>
181
209
  <div className="autocomplete-section">
@@ -198,7 +226,7 @@ export default function App() {
198
226
  placeholder="Auto Suggestion"
199
227
  // data={[{ name: 'test', id: '1' }]}
200
228
  getData={getData}
201
- onChange={() => console.log('onchange')}
229
+ onChange={() => console.log("onchange")}
202
230
  />
203
231
  </div>
204
232
  <div style={{ width: 300 }}>
@@ -212,10 +240,10 @@ export default function App() {
212
240
  isMultiple
213
241
  descId="id"
214
242
  placeholder="Auto Suggestion"
215
- selectedItems={[{ name: 'test', id: '1' }]}
243
+ selectedItems={[{ name: "test", id: "1" }]}
216
244
  // data={[{ name: 'test', id: '1' }]}
217
245
  getData={getData}
218
- onChange={(value) => console.log(value, 'onchange')}
246
+ onChange={(value) => console.log(value, "onchange")}
219
247
  />
220
248
  </div>
221
249
  <div style={{ width: 300 }}>
@@ -231,9 +259,9 @@ export default function App() {
231
259
  initialLoad={true}
232
260
  // nextBlock={nexBlock}
233
261
  placeholder="Auto Suggestion"
234
- selectedItems={[{ name: 'test', id: '1' }]}
262
+ selectedItems={[{ name: "test", id: "1" }]}
235
263
  getData={getData}
236
- onChange={(e) => console.log(e, 'onchange')}
264
+ onChange={(e) => console.log(e, "onchange")}
237
265
  />
238
266
  </div>
239
267
 
@@ -261,9 +289,9 @@ export default function App() {
261
289
  itemCount={5}
262
290
  // nextBlock={nexBlock}
263
291
  placeholder="Auto Suggestion Suggestion Suggestion Suggestion"
264
- selectedItems={[{ name: 'test', id: '1' }]}
292
+ selectedItems={[{ name: "test", id: "1" }]}
265
293
  getData={getData}
266
- onChange={(e) => console.log(e, 'onchange')}
294
+ onChange={(e) => console.log(e, "onchange")}
267
295
  />
268
296
  </div>
269
297
  </div>
package/docs/store.ts ADDED
@@ -0,0 +1,76 @@
1
+ export const treeDropData = [
2
+ {
3
+ name: "Port A - This is the main port in the northern region with significant traffic and operations",
4
+ id: 22,
5
+ children: [
6
+ {
7
+ name: "Port C - A key sub-port with heavy container traffic in the southern bay area",
8
+ id: 1,
9
+ children: [
10
+ {
11
+ name: "Port G - A small port used for local shipments and fishing operations",
12
+ id: 2,
13
+ children: [
14
+ {
15
+ name: "Port H - A minor local port focusing on fisheries and small-scale cargo",
16
+ id: 3,
17
+ children: [],
18
+ },
19
+ ],
20
+ },
21
+ {
22
+ name: "Port I - A coastal port for regional trade and tourism operations",
23
+ id: 4,
24
+ children: [
25
+ {
26
+ name: "Port J - A harbor for tourist cruises and commercial boats",
27
+ id: 5,
28
+ children: [],
29
+ },
30
+ ],
31
+ },
32
+ ],
33
+ },
34
+ {
35
+ name: "Port D - An industrial port dealing with large-scale cargo and ship repair services",
36
+ id: 6,
37
+ children: [
38
+ {
39
+ name: "Port K - A dock specializing in shipbuilding and marine repairs",
40
+ id: 7,
41
+ children: [
42
+ {
43
+ name: "Port L - A repair facility for both military and commercial vessels",
44
+ id: 8,
45
+ children: [],
46
+ },
47
+ ],
48
+ },
49
+ ],
50
+ },
51
+ ],
52
+ },
53
+ {
54
+ name: "Port B - This is the largest port in the central region, supporting international trade",
55
+ id: 9,
56
+ children: [
57
+ {
58
+ name: "Port E - A primary export port dealing with raw materials and heavy goods",
59
+ id: 10,
60
+ children: [
61
+ {
62
+ name: "Port M - A small export hub for agricultural and mining products",
63
+ id: 11,
64
+ children: [
65
+ {
66
+ name: "Port N - A warehouse and storage center for exported goods",
67
+ id: 12,
68
+ children: [],
69
+ },
70
+ ],
71
+ },
72
+ ],
73
+ },
74
+ ],
75
+ },
76
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-core-ts",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "React Components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,13 +38,17 @@
38
38
  "@svgr/webpack": "^8.1.0",
39
39
  "@types/react": "^18.2.24",
40
40
  "@types/react-dom": "^18.2.9",
41
+ "autoprefixer": "^10.4.20",
41
42
  "babel-loader": "^8.3.0",
42
43
  "copy-webpack-plugin": "^11.0.0",
43
44
  "css-loader": "^6.8.1",
44
45
  "file-loader": "^6.2.0",
45
46
  "html-webpack-plugin": "^4.5.2",
46
47
  "mini-css-extract-plugin": "^2.7.6",
48
+ "postcss": "^8.4.47",
49
+ "postcss-loader": "^8.1.1",
47
50
  "style-loader": "^3.3.3",
51
+ "tailwindcss": "^3.4.13",
48
52
  "ts-loader": "^9.4.4",
49
53
  "typescript": "^4.0.0",
50
54
  "webpack": "^5.88.2",
@@ -53,9 +57,6 @@
53
57
  },
54
58
  "dependencies": {
55
59
  "@babel/plugin-transform-typescript": "^7.22.15",
56
- "autoprefixer": "^10.4.16",
57
- "postcss": "^8.4.31",
58
- "source-map-loader": "^4.0.1",
59
- "tailwindcss": "^3.3.3"
60
+ "source-map-loader": "^4.0.1"
60
61
  }
61
62
  }
package/postcss.config.js CHANGED
@@ -1,7 +1,6 @@
1
- // postcss.config.js
2
1
  module.exports = {
3
- plugins: {
4
- tailwindcss: {},
5
- autoprefixer: {},
6
- },
2
+ plugins: [
3
+ require('tailwindcss'),
4
+ require('autoprefixer'),
5
+ ],
7
6
  };