react-core-ts 1.0.23 → 1.0.25

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 (48) hide show
  1. package/dist/AutoCompleteWithTreeStructure.d.ts +4 -0
  2. package/dist/AutoCompleteWithTreeStructure.js +415 -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 +4 -1
  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/global.css +4 -0
  24. package/dist/styles/styles/components/autocomplete.css +585 -0
  25. package/dist/styles/styles/global.css +5 -0
  26. package/dist/utilities/convertFlatArraytoTreeStructure.d.ts +1 -0
  27. package/dist/utilities/convertFlatArraytoTreeStructure.js +29 -0
  28. package/dist/utilities/convertFlatArraytoTreeStructure.js.map +1 -0
  29. package/dist/utilities/filterSuggestions.d.ts +1 -1
  30. package/dist/utilities/filterSuggestions.js +4 -3
  31. package/dist/utilities/filterSuggestions.js.map +1 -1
  32. package/docs/App.tsx +65 -36
  33. package/docs/store.ts +67 -0
  34. package/package.json +6 -5
  35. package/postcss.config.js +4 -5
  36. package/src/AutoCompleteWithTreeStructure.tsx +611 -0
  37. package/src/ExpandableAutoComplete.tsx +83 -144
  38. package/src/commontypes.ts +4 -1
  39. package/src/components/DropdownList.tsx +70 -0
  40. package/src/components/Icons.tsx +38 -0
  41. package/src/components/InputActions.tsx +63 -0
  42. package/src/components/TreeNode.tsx +80 -0
  43. package/src/index.tsx +11 -8
  44. package/src/styles/global.css +4 -0
  45. package/src/utilities/convertFlatArraytoTreeStructure.ts +27 -0
  46. package/src/utilities/filterSuggestions.ts +5 -3
  47. package/tailwind.config.js +15 -0
  48. package/webpack.config.js +17 -3
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+
3
+ import { DropSideIcon } from './Icons';
4
+
5
+ const TreeNode: React.FC<any> = ({
6
+ node,
7
+ isMultiple,
8
+ singleSelect,
9
+ idx,
10
+ desc,
11
+ toggleExpand,
12
+ updateNode,
13
+ children,
14
+ descId,
15
+ }) => {
16
+ // Toggle the expanded state when clicking on the node
17
+ const handleToggle = (node?: any) => {
18
+ console.log(node, 'node');
19
+ toggleExpand(node[descId]);
20
+ };
21
+
22
+ const handleCheckbox = (e: any, dataItem: any) => {
23
+ const { checked } = e.target;
24
+ updateNode(dataItem[descId], checked);
25
+ };
26
+ return (
27
+ <div>
28
+ <li className="flex flex-col">
29
+ <div
30
+ style={{ display: 'flex' }}
31
+ className={`items-start gap-4 flex-row ${
32
+ node?.children?.length > 0 ? '' : 'ml-5'
33
+ }`}
34
+ >
35
+ {/* Show an icon based on the expanded/collapsed state */}
36
+
37
+ {node?.children && node?.children?.length > 0 && (
38
+ <span
39
+ onClick={() => handleToggle(node)}
40
+ className={`mt-1 cursor-pointer ${
41
+ node.expanded ? ' rotate-90' : ''
42
+ }`}
43
+ >
44
+ <DropSideIcon />
45
+ </span>
46
+ )}
47
+ {(isMultiple || singleSelect) && (
48
+ <div className="qbs-autocomplete-checkbox">
49
+ <input
50
+ onChange={(e) => handleCheckbox(e, node)} // Pass correct node to the handler
51
+ type="checkbox"
52
+ checked={node.checked}
53
+ id={`qbs-checkbox-${idx.toString()}`}
54
+ />
55
+ <label htmlFor={`qbs-checkbox-${idx.toString()}`}>
56
+ <svg
57
+ width="8"
58
+ height="6"
59
+ viewBox="0 0 8 6"
60
+ fill="none"
61
+ xmlns="http://www.w3.org/2000/svg"
62
+ >
63
+ <path
64
+ d="M0 3.21739L2.89883 6L8 1.06994L6.89494 0L2.89883 3.86768L1.09728 2.14745L0 3.21739Z"
65
+ fill="white"
66
+ />
67
+ </svg>
68
+ </label>
69
+ </div>
70
+ )}
71
+ <span className=" leading-[18px]">{node[desc]}</span>
72
+ </div>
73
+ </li>
74
+
75
+ {children}
76
+ </div>
77
+ );
78
+ };
79
+
80
+ export default TreeNode;
package/src/index.tsx CHANGED
@@ -1,9 +1,12 @@
1
- import './styles/global.css';
1
+ import "./styles/global.css";
2
2
 
3
- export { default as AutoComplete } from './AutoComplete';
4
- export { default as CustomAutoComplete } from './AutoComplete';
5
- export { default as ExpandableAutoComplete } from './ExpandableAutoComplete';
6
- export { default as ExpandableToolTip } from './utilities/expandableTootltip';
7
- export { default as ToolTip } from './utilities/tooltip';
8
- export { deepEqual } from './utilities/deepEqual';
9
- export type { AutoSuggestionInputProps } from './commontypes';
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";
@@ -1 +1,5 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
1
5
  @import './components/autocomplete.css';
@@ -0,0 +1,27 @@
1
+ export function buildTree(data: any[], idField: string, parentField: string) {
2
+ const nodeMap = new Map();
3
+
4
+ // Initialize all nodes
5
+ data.forEach((node) => {
6
+ node.children = [];
7
+ nodeMap.set(node[idField], node);
8
+ });
9
+
10
+ // Build the tree structure
11
+ const tree: any[] = [];
12
+
13
+ data.forEach((node) => {
14
+ if (node[parentField]) {
15
+ // Find the parent and add the node as a child
16
+ const parent = nodeMap.get(node[parentField]);
17
+ if (parent) {
18
+ parent.children.push(node);
19
+ }
20
+ } else {
21
+ // No parentId means it's a root node
22
+ tree.push(node);
23
+ }
24
+ });
25
+
26
+ return tree;
27
+ }
@@ -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: [MiniCssExtractPlugin.loader, 'css-loader'],
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) =>