react-core-ts 1.0.2 → 1.0.4
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/.babel.config.js +7 -0
- package/.npmingnore +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/components/autocomplete.css +1 -1
- package/dist/styles/styles/components/autocomplete.css +1 -1
- package/dist/utilities/tooltip.js +0 -10
- package/dist/utilities/tooltip.js.map +1 -1
- package/docs/App.tsx +214 -0
- package/docs/index.html +40 -0
- package/docs/index.tsx +12 -0
- package/docs/style.css +4 -0
- package/package.json +1 -5
- package/postcss.config.js +7 -0
- package/src/AutoComplete.tsx +489 -0
- package/src/commontypes.ts +38 -0
- package/src/index.html +1 -0
- package/src/index.tsx +7 -0
- package/src/styles/components/autocomplete.css +522 -0
- package/src/styles/global.css +1 -0
- package/src/utilities/autosuggestions.ts +83 -0
- package/src/utilities/debounce.ts +15 -0
- package/src/utilities/deepEqual.ts +54 -0
- package/src/utilities/filterSuggestions.ts +46 -0
- package/src/utilities/icons.tsx +84 -0
- package/src/utilities/tooltip.tsx +52 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +66 -0
- package/dist/bundle.js +0 -2
- package/dist/bundle.js.LICENSE.txt +0 -14
- package/dist/utilities/tootltip.d.ts +0 -3
- package/dist/utilities/tootltip.js +0 -74
- package/dist/utilities/tootltip.js.map +0 -1
package/.babel.config.js
ADDED
package/.npmingnore
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './styles/global.css';
|
|
2
2
|
export { default as AutoComplete } from './AutoComplete';
|
|
3
3
|
export { default as CustomAutoComplete } from './AutoComplete';
|
|
4
|
+
export { default as ToolTip } from './utilities/tooltip';
|
|
5
|
+
export { deepEqual } from './utilities/deepEqual';
|
|
4
6
|
export type { AutoSuggestionInputProps } from './commontypes';
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CustomAutoComplete = exports.AutoComplete = void 0;
|
|
6
|
+
exports.deepEqual = exports.ToolTip = exports.CustomAutoComplete = exports.AutoComplete = void 0;
|
|
7
7
|
require("./styles/global.css");
|
|
8
8
|
var AutoComplete_1 = require("./AutoComplete");
|
|
9
9
|
Object.defineProperty(exports, "AutoComplete", { enumerable: true, get: function () { return __importDefault(AutoComplete_1).default; } });
|
|
10
10
|
var AutoComplete_2 = require("./AutoComplete");
|
|
11
11
|
Object.defineProperty(exports, "CustomAutoComplete", { enumerable: true, get: function () { return __importDefault(AutoComplete_2).default; } });
|
|
12
|
+
var tooltip_1 = require("./utilities/tooltip");
|
|
13
|
+
Object.defineProperty(exports, "ToolTip", { enumerable: true, get: function () { return __importDefault(tooltip_1).default; } });
|
|
14
|
+
var deepEqual_1 = require("./utilities/deepEqual");
|
|
15
|
+
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return deepEqual_1.deepEqual; } });
|
|
12
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAAA,+BAA6B;AAE7B,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,+CAA+D;AAAtD,mIAAA,OAAO,OAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAAA,+BAA6B;AAE7B,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,+CAA+D;AAAtD,mIAAA,OAAO,OAAsB;AACtC,+CAAyD;AAAhD,mHAAA,OAAO,OAAW;AAC3B,mDAAkD;AAAzC,sGAAA,SAAS,OAAA"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import React from 'react';
|
|
3
|
-
// const Tooltip: React.FC<any> = ({ children, title }) => {
|
|
4
|
-
// return (
|
|
5
|
-
// <div className="tooltip-wrapper">
|
|
6
|
-
// {children}
|
|
7
|
-
// <div className="tooltip-content">{title}</div>
|
|
8
|
-
// </div>
|
|
9
|
-
// );
|
|
10
|
-
// };
|
|
11
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
3
|
if (k2 === undefined) k2 = k;
|
|
13
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -32,7 +23,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
23
|
return result;
|
|
33
24
|
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
// export default Tooltip;
|
|
36
26
|
var react_1 = __importStar(require("react"));
|
|
37
27
|
var ToolTip = function (_a) {
|
|
38
28
|
var title = _a.title, children = _a.children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../src/utilities/tooltip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../src/utilities/tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgD;AAEhD,IAAM,OAAO,GAAkB,UAAC,EAAmB;QAAjB,KAAK,WAAA,EAAE,QAAQ,cAAA;IACzC,IAAA,KAA0C,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,EAApE,gBAAgB,QAAA,EAAE,mBAAmB,QAA+B,CAAC;IAC5E,IAAM,OAAO,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAC7B,IAAM,aAAa,GAAG,IAAA,cAAM,EAAc,IAAI,CAAC,CAAC;IAChD,IAAM,sBAAsB,GAAG;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AO,CAAC"}
|
package/docs/App.tsx
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import AutoComplete from '../src/AutoComplete';
|
|
4
|
+
|
|
5
|
+
import '../src/styles/global.css';
|
|
6
|
+
|
|
7
|
+
export default function App() {
|
|
8
|
+
const [dropData, setDropData] = useState();
|
|
9
|
+
const [nexBlock, setNexBlock] = useState(1);
|
|
10
|
+
const [prev, setPrev] = useState(1);
|
|
11
|
+
|
|
12
|
+
const getData = (keyName?: string, next?: number) => {
|
|
13
|
+
return fetch(
|
|
14
|
+
keyName
|
|
15
|
+
? `https://jsonplaceholder.typicode.com/posts?_page=${next}&_limit=10&title_like=${keyName}`
|
|
16
|
+
: `https://jsonplaceholder.typicode.com/posts?_page=${next}&_limit=10`
|
|
17
|
+
)
|
|
18
|
+
.then((res) => res.json())
|
|
19
|
+
.then((res) => {
|
|
20
|
+
setNexBlock(nexBlock + 1);
|
|
21
|
+
const result = res.map((item: any) => {
|
|
22
|
+
return { ...item, ['name']: item?.title, id: item?.id.toString() };
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const getDatas = (keyName?: string) => {
|
|
28
|
+
return fetch(
|
|
29
|
+
keyName
|
|
30
|
+
? `https://jsonplaceholder.typicode.com/posts?title_like=${keyName}`
|
|
31
|
+
: `https://jsonplaceholder.typicode.com/posts`
|
|
32
|
+
)
|
|
33
|
+
.then((res) => res.json())
|
|
34
|
+
.then((res) => {
|
|
35
|
+
setPrev(prev + 1);
|
|
36
|
+
const result = res.map((item: any) => {
|
|
37
|
+
return { ...item, ['name']: item?.title, id: item?.id.toString() };
|
|
38
|
+
});
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
return (
|
|
43
|
+
<React.Fragment>
|
|
44
|
+
<div>
|
|
45
|
+
<div
|
|
46
|
+
style={{
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
gap: 20,
|
|
50
|
+
padding: 20,
|
|
51
|
+
maxWidth: 700,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<div className="autocomplete-section">
|
|
55
|
+
<h2>Custom Select</h2>
|
|
56
|
+
<p>
|
|
57
|
+
Select an option from a predefined static list. Ideal for a
|
|
58
|
+
scenario when the available options are limited and known.
|
|
59
|
+
</p>
|
|
60
|
+
</div>
|
|
61
|
+
<div style={{ width: 300 }}>
|
|
62
|
+
<AutoComplete
|
|
63
|
+
label="Custom Select"
|
|
64
|
+
name="sample"
|
|
65
|
+
placeholder="Custom Select"
|
|
66
|
+
desc="name"
|
|
67
|
+
descId="id"
|
|
68
|
+
type="custom_select"
|
|
69
|
+
data={[
|
|
70
|
+
{ name: 'test', id: '1' },
|
|
71
|
+
{ name: 'test1', id: '2' },
|
|
72
|
+
|
|
73
|
+
{ name: 'test2', id: '3' },
|
|
74
|
+
|
|
75
|
+
{ name: 'test3', id: '4' },
|
|
76
|
+
]}
|
|
77
|
+
// getData={getData}
|
|
78
|
+
onChange={() => console.log('onchange')}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<div className="autocomplete-section">
|
|
82
|
+
<h2>Auto Complete</h2>
|
|
83
|
+
<p>
|
|
84
|
+
Type in the input field and get real-time suggestions from
|
|
85
|
+
dynamically fetched data. Useful for selecting from large datasets
|
|
86
|
+
where displaying all available options is impractical.
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
<div style={{ width: 300 }}>
|
|
90
|
+
<AutoComplete
|
|
91
|
+
label="Auto Complete"
|
|
92
|
+
name="sample"
|
|
93
|
+
desc="name"
|
|
94
|
+
paginationEnabled={true}
|
|
95
|
+
nextBlock={nexBlock}
|
|
96
|
+
descId="id"
|
|
97
|
+
async={true}
|
|
98
|
+
type="auto_complete"
|
|
99
|
+
placeholder="Auto Complete"
|
|
100
|
+
// data={[{ name: 'test', id: '1' }]}
|
|
101
|
+
getData={getData}
|
|
102
|
+
onChange={() => console.log('onchange')}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
<div style={{ width: 300 }}>
|
|
106
|
+
<AutoComplete
|
|
107
|
+
label="Auto Complete"
|
|
108
|
+
name="sample"
|
|
109
|
+
desc="name"
|
|
110
|
+
descId="id"
|
|
111
|
+
async={false}
|
|
112
|
+
type="auto_complete"
|
|
113
|
+
placeholder="Auto Complete"
|
|
114
|
+
// data={[{ name: 'test', id: '1' }]}
|
|
115
|
+
getData={getDatas}
|
|
116
|
+
onChange={() => console.log('onchange')}
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
<div className="autocomplete-section">
|
|
120
|
+
<h2>Custom Search Select</h2>
|
|
121
|
+
<p>
|
|
122
|
+
This allows you to search through static data, providing a
|
|
123
|
+
filtered list based on your query or select from available items.
|
|
124
|
+
Optimal for scenarios where you might have predefined options but
|
|
125
|
+
also want to enable users to quickly narrow down their choices.
|
|
126
|
+
</p>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div style={{ width: 300 }}>
|
|
130
|
+
<AutoComplete
|
|
131
|
+
label="Custom Search Select"
|
|
132
|
+
name="sample"
|
|
133
|
+
placeholder="Custom Search Select"
|
|
134
|
+
desc="name"
|
|
135
|
+
descId="id"
|
|
136
|
+
type="custom_search_select"
|
|
137
|
+
data={[
|
|
138
|
+
{ name: 'Apple', id: '1' },
|
|
139
|
+
{ name: 'Banana', id: '2' },
|
|
140
|
+
{ name: 'Cherry', id: '3' },
|
|
141
|
+
{ name: 'Date', id: '4' },
|
|
142
|
+
{ name: 'Fig', id: '5' },
|
|
143
|
+
{ name: 'Grape', id: '6' },
|
|
144
|
+
{ name: 'Honeydew', id: '7' },
|
|
145
|
+
{ name: 'Kiwi', id: '8' },
|
|
146
|
+
{ name: 'Lemon', id: '9' },
|
|
147
|
+
{ name: 'Mango', id: '10' },
|
|
148
|
+
]}
|
|
149
|
+
onChange={() => console.log('onchange')}
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
<div className="autocomplete-section">
|
|
153
|
+
<h2>Auto Suggestion</h2>
|
|
154
|
+
<p>
|
|
155
|
+
As you type, suggestions will appear based on your input, aiding
|
|
156
|
+
in quicker and potentially more accurate data entry. This mode
|
|
157
|
+
supports both listed and non-listed input, providing flexibility
|
|
158
|
+
in user input while still offering assistance.
|
|
159
|
+
</p>
|
|
160
|
+
</div>
|
|
161
|
+
<div style={{ width: 300 }}>
|
|
162
|
+
<AutoComplete
|
|
163
|
+
label="select Auto Suggestion"
|
|
164
|
+
name="sample"
|
|
165
|
+
type="auto_suggestion"
|
|
166
|
+
desc="name"
|
|
167
|
+
descId="id"
|
|
168
|
+
async
|
|
169
|
+
placeholder="Auto Suggestion"
|
|
170
|
+
// data={[{ name: 'test', id: '1' }]}
|
|
171
|
+
getData={getData}
|
|
172
|
+
onChange={() => console.log('onchange')}
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
<div style={{ width: 300 }}>
|
|
176
|
+
<AutoComplete
|
|
177
|
+
label="Auto Suggestion"
|
|
178
|
+
name="sample"
|
|
179
|
+
type="auto_suggestion"
|
|
180
|
+
required
|
|
181
|
+
desc="name"
|
|
182
|
+
async
|
|
183
|
+
isMultiple
|
|
184
|
+
descId="id"
|
|
185
|
+
placeholder="Auto Suggestion"
|
|
186
|
+
selectedItems={[{ name: 'test', id: '1' }]}
|
|
187
|
+
// data={[{ name: 'test', id: '1' }]}
|
|
188
|
+
getData={getData}
|
|
189
|
+
onChange={(value) => console.log(value, 'onchange')}
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
<div style={{ width: 300 }}>
|
|
193
|
+
<AutoComplete
|
|
194
|
+
label="Auto Suggestion"
|
|
195
|
+
name="sample"
|
|
196
|
+
type="auto_suggestion"
|
|
197
|
+
// async
|
|
198
|
+
desc="name"
|
|
199
|
+
singleSelect
|
|
200
|
+
descId="id"
|
|
201
|
+
paginationEnabled={false}
|
|
202
|
+
initialLoad={true}
|
|
203
|
+
// nextBlock={nexBlock}
|
|
204
|
+
placeholder="Auto Suggestion"
|
|
205
|
+
selectedItems={[{ name: 'test', id: '1' }]}
|
|
206
|
+
getData={getData}
|
|
207
|
+
onChange={(e) => console.log(e, 'onchange')}
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</React.Fragment>
|
|
213
|
+
);
|
|
214
|
+
}
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="theme-color" content="#000000" />
|
|
7
|
+
<meta
|
|
8
|
+
name="description"
|
|
9
|
+
content="Web site created using create-react-app"
|
|
10
|
+
/>
|
|
11
|
+
<!--
|
|
12
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
13
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
14
|
+
-->
|
|
15
|
+
<!--
|
|
16
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
17
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
18
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
19
|
+
|
|
20
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
21
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
22
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
23
|
+
-->
|
|
24
|
+
<title>React App</title>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
28
|
+
<div id="root"></div>
|
|
29
|
+
<!--
|
|
30
|
+
This HTML file is a template.
|
|
31
|
+
If you open it directly in the browser, you will see an empty page.
|
|
32
|
+
|
|
33
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
34
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
35
|
+
|
|
36
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
37
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
38
|
+
-->
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
package/docs/index.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import App from './App';
|
|
4
|
+
|
|
5
|
+
const root = ReactDOM.createRoot(
|
|
6
|
+
document.getElementById('root') as HTMLElement
|
|
7
|
+
);
|
|
8
|
+
root.render(
|
|
9
|
+
<React.StrictMode>
|
|
10
|
+
<App />
|
|
11
|
+
</React.StrictMode>
|
|
12
|
+
);
|
package/docs/style.css
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-core-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "React Components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"README.md"
|
|
10
|
-
],
|
|
11
7
|
"scripts": {
|
|
12
8
|
"start": "webpack serve --open --mode development",
|
|
13
9
|
"build": "tsc && cp -R src/styles dist/styles",
|