gbs-add-block 0.0.68 → 0.0.70
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 +2 -4
- package/package.json +2 -2
- package/source/components/datagrid/index.tsx +2 -2
- package/source/components/select/index.tsx +36 -15
- package/index.js +0 -173
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.70)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,11 +6,9 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
|
|
|
6
6
|
|
|
7
7
|
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 0.0.
|
|
9
|
+
## What's New 🎉 (Ver 0.0.70)
|
|
10
10
|
|
|
11
11
|
- Updated for bug fixes.
|
|
12
|
-
- New component "Skeleton", "Breadcrumb" & "Navbar" Added.
|
|
13
|
-
- Planned Deprecation of Current Grid Component and Adding Beta version for the New Data Grid.
|
|
14
12
|
|
|
15
13
|
## Authors
|
|
16
14
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gbs-add-block",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.70",
|
|
4
4
|
"description": "React Component Library",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"files": [
|
|
6
7
|
"index.js",
|
|
7
8
|
"source"
|
|
@@ -19,7 +20,6 @@
|
|
|
19
20
|
"author": "Anandhu Remanan",
|
|
20
21
|
"license": "ISC",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"fs-extra": "^11.2.0",
|
|
23
23
|
"path": "^0.12.7",
|
|
24
24
|
"yargs": "^17.7.2"
|
|
25
25
|
},
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { GridMemoised as GridComponent } from "./layout";
|
|
12
12
|
import { memo } from "react";
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const DataGrid = memo(GridComponent, (prevProps, nextProps) => {
|
|
15
15
|
// Custom comparison function
|
|
16
16
|
return (
|
|
17
17
|
prevProps.dataSource === nextProps.dataSource &&
|
|
@@ -23,4 +23,4 @@ const Grid = memo(GridComponent, (prevProps, nextProps) => {
|
|
|
23
23
|
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export {
|
|
26
|
+
export { DataGrid };
|
|
@@ -15,7 +15,7 @@ import React, {
|
|
|
15
15
|
} from "react";
|
|
16
16
|
import Icon from "../icon/Icon";
|
|
17
17
|
import { check, search, upDown, x } from "../icon/iconPaths";
|
|
18
|
-
import type { SelectHandle, SelectProps } from "./types";
|
|
18
|
+
import type { ItemsProps, SelectHandle, SelectProps } from "./types";
|
|
19
19
|
import { selectStyle } from "./style";
|
|
20
20
|
import { iconClass, popUp, primary } from "../globalStyle";
|
|
21
21
|
import {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
useSelectData,
|
|
24
24
|
useClickOutside,
|
|
25
25
|
applyScrollbarStyles,
|
|
26
|
+
useKeyboardNavigation,
|
|
26
27
|
} from "@grampro/headless-helpers";
|
|
27
28
|
|
|
28
29
|
const Select = forwardRef<SelectHandle, SelectProps>((props, ref) => {
|
|
@@ -71,6 +72,26 @@ const Select = forwardRef<SelectHandle, SelectProps>((props, ref) => {
|
|
|
71
72
|
setShowPopover(false)
|
|
72
73
|
);
|
|
73
74
|
|
|
75
|
+
// Update the handleSelect to accept a SelectItem
|
|
76
|
+
const handleSelect = useCallback(
|
|
77
|
+
(item: ItemsProps) => {
|
|
78
|
+
setSelectedItem(item.value);
|
|
79
|
+
setShowPopover(false);
|
|
80
|
+
setSearchTerm("");
|
|
81
|
+
if (onSelect) onSelect(item.value);
|
|
82
|
+
},
|
|
83
|
+
[onSelect, setSelectedItem, setShowPopover, setSearchTerm]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// Set up keyboard navigation with the correct item type
|
|
87
|
+
const { focusedIndex, setFocusedIndex, itemRefs, handleKeyDown } =
|
|
88
|
+
useKeyboardNavigation<ItemsProps>({
|
|
89
|
+
items: filteredItems,
|
|
90
|
+
isOpen: showPopover,
|
|
91
|
+
onSelect: handleSelect,
|
|
92
|
+
onClose: () => setShowPopover(false),
|
|
93
|
+
});
|
|
94
|
+
|
|
74
95
|
useEffect(() => {
|
|
75
96
|
if (showPopover) {
|
|
76
97
|
inputRef.current?.focus();
|
|
@@ -83,16 +104,6 @@ const Select = forwardRef<SelectHandle, SelectProps>((props, ref) => {
|
|
|
83
104
|
}
|
|
84
105
|
}, [initialSelectedItem, setSelectedItem]);
|
|
85
106
|
|
|
86
|
-
const handleSelect = useCallback(
|
|
87
|
-
(value: string) => {
|
|
88
|
-
setSelectedItem(value);
|
|
89
|
-
setShowPopover(false);
|
|
90
|
-
setSearchTerm("");
|
|
91
|
-
if (onSelect) onSelect(value);
|
|
92
|
-
},
|
|
93
|
-
[onSelect, setSelectedItem, setShowPopover, setSearchTerm]
|
|
94
|
-
);
|
|
95
|
-
|
|
96
107
|
const handleClear = () => {
|
|
97
108
|
if (disabled) return;
|
|
98
109
|
clearSelected();
|
|
@@ -110,7 +121,12 @@ const Select = forwardRef<SelectHandle, SelectProps>((props, ref) => {
|
|
|
110
121
|
}));
|
|
111
122
|
|
|
112
123
|
return (
|
|
113
|
-
<div
|
|
124
|
+
<div
|
|
125
|
+
className="relative w-full mt-2"
|
|
126
|
+
ref={selectRef}
|
|
127
|
+
id={id}
|
|
128
|
+
onKeyDown={handleKeyDown}
|
|
129
|
+
>
|
|
114
130
|
<div className="w-full relative">
|
|
115
131
|
<button
|
|
116
132
|
className={`${error ? primary["error-border"] : "border"} ${
|
|
@@ -164,16 +180,21 @@ const Select = forwardRef<SelectHandle, SelectProps>((props, ref) => {
|
|
|
164
180
|
onChange={(e) => {
|
|
165
181
|
setSearchTerm(e.target.value);
|
|
166
182
|
if (onFiltering) onFiltering(e.target.value);
|
|
183
|
+
setFocusedIndex(-1);
|
|
167
184
|
}}
|
|
168
185
|
/>
|
|
169
186
|
</div>
|
|
170
187
|
)}
|
|
171
188
|
{filteredItems.length > 0 ? (
|
|
172
|
-
filteredItems.map(({ value, label }) => (
|
|
189
|
+
filteredItems.map(({ value, label }, index) => (
|
|
173
190
|
<button
|
|
174
191
|
key={value}
|
|
175
|
-
|
|
176
|
-
|
|
192
|
+
ref={(el: any) => (itemRefs.current[index] = el)}
|
|
193
|
+
className={`${selectStyle["filter-button"]} ${
|
|
194
|
+
focusedIndex === index ? "bg-gray-100" : ""
|
|
195
|
+
}`}
|
|
196
|
+
onClick={() => handleSelect({ value, label })}
|
|
197
|
+
onMouseEnter={() => setFocusedIndex(index)}
|
|
177
198
|
>
|
|
178
199
|
<Icon
|
|
179
200
|
elements={check}
|
package/index.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require("fs-extra");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const yargs = require("yargs/yargs");
|
|
6
|
-
const { hideBin } = require("yargs/helpers");
|
|
7
|
-
|
|
8
|
-
// Configuration
|
|
9
|
-
const CONFIG = {
|
|
10
|
-
components: [
|
|
11
|
-
"Select",
|
|
12
|
-
"Grid",
|
|
13
|
-
"MultiSelect",
|
|
14
|
-
"Button",
|
|
15
|
-
"DatePicker",
|
|
16
|
-
"Checkbox",
|
|
17
|
-
"DarkMode",
|
|
18
|
-
"Dialog",
|
|
19
|
-
"Input",
|
|
20
|
-
"Modal",
|
|
21
|
-
"Spinner",
|
|
22
|
-
"Toast",
|
|
23
|
-
"Uploader",
|
|
24
|
-
"FormRenderer",
|
|
25
|
-
"MaterialInput",
|
|
26
|
-
"ContextMenu",
|
|
27
|
-
"Skeleton",
|
|
28
|
-
"Navbar",
|
|
29
|
-
"DataGrid",
|
|
30
|
-
"BreadCrumb",
|
|
31
|
-
],
|
|
32
|
-
// Define component dependencies
|
|
33
|
-
dependencies: {
|
|
34
|
-
FormRenderer: ["Select", "MultiSelect", "Input", "DatePicker"],
|
|
35
|
-
},
|
|
36
|
-
docs: "https://blackmax-designs.gitbook.io/building-block-v2.0",
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const SOURCE_PATH = path.join(__dirname, "source", "components");
|
|
40
|
-
const DEFAULT_DEST_PATH = path.join(process.cwd(), "component-lib");
|
|
41
|
-
|
|
42
|
-
const copyCommonFiles = async (destPath) => {
|
|
43
|
-
const commonFiles = [
|
|
44
|
-
{ src: ["..", "utils.ts"], dest: "utils.ts" },
|
|
45
|
-
{ src: ["..", "globalStyle.ts"], dest: "globalStyle.ts" },
|
|
46
|
-
{ src: ["..", "icon"], dest: "icon" },
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
for (const file of commonFiles) {
|
|
50
|
-
const src = path.join(SOURCE_PATH, ...file.src);
|
|
51
|
-
const dest = path.join(destPath, file.dest);
|
|
52
|
-
await fs.copy(src, dest, { overwrite: true });
|
|
53
|
-
console.log(`✓ ${file.dest} copied successfully`);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const checkComponentExists = (component, destPath) => {
|
|
58
|
-
const componentPath = path.join(destPath, component.toLowerCase());
|
|
59
|
-
return fs.existsSync(componentPath);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const copyComponent = async (component, destPath) => {
|
|
63
|
-
try {
|
|
64
|
-
const componentSrc = path.join(SOURCE_PATH, component.toLowerCase());
|
|
65
|
-
const componentDest = path.join(destPath, component.toLowerCase());
|
|
66
|
-
|
|
67
|
-
if (!fs.existsSync(componentSrc)) {
|
|
68
|
-
throw new Error(`Component ${component} not found in source directory.`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await fs.copy(componentSrc, componentDest, { overwrite: true });
|
|
72
|
-
console.log(
|
|
73
|
-
`✓ Component ${component} installed successfully ${
|
|
74
|
-
component === "Grid"
|
|
75
|
-
? "This Version of Grid will be deprecated soon. Please Install The New Data Grid Component"
|
|
76
|
-
: ""
|
|
77
|
-
}`
|
|
78
|
-
);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error(`Error installing component ${component}:`, error.message);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const installComponentWithDependencies = async (component, destPath) => {
|
|
86
|
-
// Get dependencies for the component
|
|
87
|
-
const dependencies = CONFIG.dependencies[component] || [];
|
|
88
|
-
const componentsToInstall = new Set([component, ...dependencies]);
|
|
89
|
-
|
|
90
|
-
// Check which components need to be installed
|
|
91
|
-
const pendingInstalls = Array.from(componentsToInstall).filter(
|
|
92
|
-
(comp) => !checkComponentExists(comp, destPath)
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
if (pendingInstalls.length === 0) {
|
|
96
|
-
console.log(
|
|
97
|
-
`✓ ${component} and all its dependencies are already installed.`
|
|
98
|
-
);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Install all pending components
|
|
103
|
-
for (const comp of pendingInstalls) {
|
|
104
|
-
await copyComponent(comp, destPath);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (dependencies.length > 0) {
|
|
108
|
-
console.log(`\nInstalled dependencies for ${component}:`);
|
|
109
|
-
dependencies.forEach((dep) => {
|
|
110
|
-
console.log(`- ${dep}`);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
console.log(`\nFor documentation visit: ${CONFIG.docs}`);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const main = async () => {
|
|
118
|
-
const argv = yargs(hideBin(process.argv))
|
|
119
|
-
.option("add", {
|
|
120
|
-
alias: "a",
|
|
121
|
-
describe: "Component to install",
|
|
122
|
-
type: "string",
|
|
123
|
-
})
|
|
124
|
-
.option("list", {
|
|
125
|
-
alias: "l",
|
|
126
|
-
describe: "List available components",
|
|
127
|
-
type: "boolean",
|
|
128
|
-
})
|
|
129
|
-
.help().argv;
|
|
130
|
-
|
|
131
|
-
// List components if requested
|
|
132
|
-
if (argv.list) {
|
|
133
|
-
console.log("\nAvailable components:");
|
|
134
|
-
CONFIG.components.forEach((comp) => {
|
|
135
|
-
const deps = CONFIG.dependencies[comp]
|
|
136
|
-
? ` (requires: ${CONFIG.dependencies[comp].join(", ")})`
|
|
137
|
-
: "";
|
|
138
|
-
console.log(`- ${comp}${deps}`);
|
|
139
|
-
});
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (!argv.add) {
|
|
144
|
-
console.error("Please specify a component to install using -a or --add");
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Validate component name
|
|
149
|
-
const component = argv.add;
|
|
150
|
-
if (!CONFIG.components.includes(component)) {
|
|
151
|
-
console.error(`Invalid component: ${component}`);
|
|
152
|
-
console.log("\nAvailable components:");
|
|
153
|
-
CONFIG.components.forEach((comp) => console.log(`- ${comp}`));
|
|
154
|
-
process.exit(1);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Create destination directory in project root
|
|
158
|
-
const destPath = DEFAULT_DEST_PATH;
|
|
159
|
-
await fs.ensureDir(destPath);
|
|
160
|
-
|
|
161
|
-
// Copy common files if they don't exist
|
|
162
|
-
if (!fs.existsSync(path.join(destPath, "utils.ts"))) {
|
|
163
|
-
await copyCommonFiles(destPath);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Install component and its dependencies
|
|
167
|
-
await installComponentWithDependencies(component, destPath);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
main().catch((error) => {
|
|
171
|
-
console.error("Error:", error.message);
|
|
172
|
-
process.exit(1);
|
|
173
|
-
});
|