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.
- package/dist/AutoCompleteWithTreeStructure.d.ts +4 -0
- package/dist/AutoCompleteWithTreeStructure.js +453 -0
- package/dist/AutoCompleteWithTreeStructure.js.map +1 -0
- package/dist/ExpandableAutoComplete.d.ts +2 -2
- package/dist/ExpandableAutoComplete.js +54 -71
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/commontypes.d.ts +3 -2
- package/dist/components/DropdownList.d.ts +14 -0
- package/dist/components/DropdownList.js +18 -0
- package/dist/components/DropdownList.js.map +1 -0
- package/dist/components/Icons.d.ts +3 -0
- package/dist/components/Icons.js +18 -0
- package/dist/components/Icons.js.map +1 -0
- package/dist/components/InputActions.d.ts +14 -0
- package/dist/components/InputActions.js +18 -0
- package/dist/components/InputActions.js.map +1 -0
- package/dist/components/TreeNode.d.ts +3 -0
- package/dist/components/TreeNode.js +34 -0
- package/dist/components/TreeNode.js.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/styles/components/autocomplete.css +4 -1
- package/dist/styles/global.css +4 -0
- package/dist/styles/styles/global.css +4 -0
- package/dist/utilities/filterSuggestions.d.ts +1 -1
- package/dist/utilities/filterSuggestions.js +4 -3
- package/dist/utilities/filterSuggestions.js.map +1 -1
- package/docs/App.tsx +64 -36
- package/docs/store.ts +76 -0
- package/package.json +6 -5
- package/postcss.config.js +4 -5
- package/src/AutoCompleteWithTreeStructure.tsx +638 -0
- package/src/ExpandableAutoComplete.tsx +83 -144
- package/src/commontypes.ts +6 -5
- package/src/components/DropdownList.tsx +70 -0
- package/src/components/Icons.tsx +38 -0
- package/src/components/InputActions.tsx +63 -0
- package/src/components/TreeNode.tsx +79 -0
- package/src/index.tsx +11 -8
- package/src/styles/global.css +4 -0
- package/src/utilities/filterSuggestions.ts +5 -3
- package/tailwind.config.js +15 -0
- package/webpack.config.js +17 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DropSideIcon } from "./Icons";
|
|
3
|
+
|
|
4
|
+
const TreeNode: React.FC<any> = ({
|
|
5
|
+
node,
|
|
6
|
+
isMultiple,
|
|
7
|
+
singleSelect,
|
|
8
|
+
idx,
|
|
9
|
+
desc,
|
|
10
|
+
toggleExpand,
|
|
11
|
+
updateNode,
|
|
12
|
+
children,
|
|
13
|
+
descId,
|
|
14
|
+
}) => {
|
|
15
|
+
// Toggle the expanded state when clicking on the node
|
|
16
|
+
const handleToggle = (node?: any) => {
|
|
17
|
+
console.log(node, "node");
|
|
18
|
+
toggleExpand(node[descId]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const handleCheckbox = (e: any, dataItem: any) => {
|
|
22
|
+
const { checked } = e.target;
|
|
23
|
+
updateNode(dataItem[descId], checked);
|
|
24
|
+
};
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<li className="flex flex-col">
|
|
28
|
+
<div
|
|
29
|
+
style={{ display: "flex" }}
|
|
30
|
+
className={`items-start gap-4 flex-row ${
|
|
31
|
+
node?.children?.length > 0 ? "" : "ml-5"
|
|
32
|
+
}`}
|
|
33
|
+
>
|
|
34
|
+
{/* Show an icon based on the expanded/collapsed state */}
|
|
35
|
+
|
|
36
|
+
{node?.children && node?.children?.length > 0 && (
|
|
37
|
+
<span
|
|
38
|
+
onClick={() => handleToggle(node)}
|
|
39
|
+
className={`mt-1 cursor-pointer ${
|
|
40
|
+
node.expanded ? " rotate-90" : ""
|
|
41
|
+
}`}
|
|
42
|
+
>
|
|
43
|
+
<DropSideIcon />
|
|
44
|
+
</span>
|
|
45
|
+
)}
|
|
46
|
+
{(isMultiple || singleSelect) && (
|
|
47
|
+
<div className="qbs-autocomplete-checkbox">
|
|
48
|
+
<input
|
|
49
|
+
onChange={(e) => handleCheckbox(e, node)} // Pass correct node to the handler
|
|
50
|
+
type="checkbox"
|
|
51
|
+
checked={node.checked}
|
|
52
|
+
id={`qbs-checkbox-${idx.toString()}`}
|
|
53
|
+
/>
|
|
54
|
+
<label htmlFor={`qbs-checkbox-${idx.toString()}`}>
|
|
55
|
+
<svg
|
|
56
|
+
width="8"
|
|
57
|
+
height="6"
|
|
58
|
+
viewBox="0 0 8 6"
|
|
59
|
+
fill="none"
|
|
60
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
+
>
|
|
62
|
+
<path
|
|
63
|
+
d="M0 3.21739L2.89883 6L8 1.06994L6.89494 0L2.89883 3.86768L1.09728 2.14745L0 3.21739Z"
|
|
64
|
+
fill="white"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
</label>
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
<span className=" leading-[18px]">{node[desc]}</span>
|
|
71
|
+
</div>
|
|
72
|
+
</li>
|
|
73
|
+
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default TreeNode;
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./styles/global.css";
|
|
2
2
|
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { default as
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
3
|
+
export {
|
|
4
|
+
default as AutoComplete,
|
|
5
|
+
default as CustomAutoComplete,
|
|
6
|
+
} from "./AutoComplete";
|
|
7
|
+
export { default as AutoCompleteWithTreeStructure } from "./AutoCompleteWithTreeStructure";
|
|
8
|
+
export type { AutoSuggestionInputProps } from "./commontypes";
|
|
9
|
+
export { default as ExpandableAutoComplete } from "./ExpandableAutoComplete";
|
|
10
|
+
export { deepEqual } from "./utilities/deepEqual";
|
|
11
|
+
export { default as ExpandableToolTip } from "./utilities/expandableTootltip";
|
|
12
|
+
export { default as ToolTip } from "./utilities/tooltip";
|
package/src/styles/global.css
CHANGED
|
@@ -8,20 +8,22 @@ export const filterSuggestions = (
|
|
|
8
8
|
type: string,
|
|
9
9
|
desc: string,
|
|
10
10
|
inputValue?: string,
|
|
11
|
-
async?: boolean
|
|
11
|
+
async?: boolean,
|
|
12
|
+
isTreeDropdown?: boolean
|
|
12
13
|
): Item[] => {
|
|
13
14
|
if (
|
|
14
15
|
(type === 'custom_search_select' ||
|
|
15
16
|
type === 'auto_complete' ||
|
|
16
17
|
type === 'auto_suggestion') &&
|
|
17
18
|
!async &&
|
|
18
|
-
query
|
|
19
|
+
query &&
|
|
20
|
+
!isTreeDropdown
|
|
19
21
|
) {
|
|
20
22
|
return data?.filter((item) =>
|
|
21
23
|
item[desc].toLowerCase().includes(query.toLowerCase())
|
|
22
24
|
);
|
|
23
25
|
}
|
|
24
|
-
return sortedArrayData(data, inputValue, desc);
|
|
26
|
+
return isTreeDropdown ? data : sortedArrayData(data, inputValue, desc);
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
const sortedArrayData = (
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
content: [],
|
|
4
|
+
purge: ['./src/**/*.{js,jsx,ts,tsx}', './docs/**/*.{html,js}'],
|
|
5
|
+
theme: {
|
|
6
|
+
extend: {
|
|
7
|
+
colors: {
|
|
8
|
+
'blue-navy': '#001f3f',
|
|
9
|
+
'table-hover': '#f8f8f8',
|
|
10
|
+
'neutrals-grey-20': '#f4f4f4',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
plugins: [],
|
|
15
|
+
};
|
package/webpack.config.js
CHANGED
|
@@ -4,7 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
//...
|
|
7
|
-
entry: './docs',
|
|
7
|
+
entry: ['./docs', './src/styles/global.css'],
|
|
8
8
|
devtool: 'source-map',
|
|
9
9
|
devServer: {
|
|
10
10
|
contentBase: './docs',
|
|
@@ -15,11 +15,25 @@ module.exports = {
|
|
|
15
15
|
},
|
|
16
16
|
module: {
|
|
17
17
|
rules: [
|
|
18
|
+
// {
|
|
19
|
+
// test: /\.css$/i,
|
|
20
|
+
// use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
|
21
|
+
// },
|
|
18
22
|
{
|
|
19
23
|
test: /\.css$/i,
|
|
20
|
-
use: [
|
|
24
|
+
use: [
|
|
25
|
+
MiniCssExtractPlugin.loader,
|
|
26
|
+
'css-loader',
|
|
27
|
+
{
|
|
28
|
+
loader: 'postcss-loader',
|
|
29
|
+
options: {
|
|
30
|
+
postcssOptions: {
|
|
31
|
+
plugins: ['tailwindcss', 'autoprefixer'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
21
36
|
},
|
|
22
|
-
|
|
23
37
|
{
|
|
24
38
|
test: /\.tsx?$/,
|
|
25
39
|
exclude: (file) =>
|