gbs-add-block 0.0.52 → 0.0.53-beta

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/index.js CHANGED
@@ -25,6 +25,10 @@ const CONFIG = {
25
25
  "MaterialInput",
26
26
  "ContextMenu",
27
27
  ],
28
+ // Define component dependencies
29
+ dependencies: {
30
+ FormRenderer: ["Select", "MultiSelect", "Input", "DatePicker"],
31
+ },
28
32
  frameworks: {
29
33
  next: {
30
34
  name: "Next.js",
@@ -55,6 +59,11 @@ const copyCommonFiles = async (destPath) => {
55
59
  }
56
60
  };
57
61
 
62
+ const checkComponentExists = (component, destPath) => {
63
+ const componentPath = path.join(destPath, component.toLowerCase());
64
+ return fs.existsSync(componentPath);
65
+ };
66
+
58
67
  const copyComponent = async (component, destPath) => {
59
68
  try {
60
69
  const componentSrc = path.join(SOURCE_PATH, component.toLowerCase());
@@ -66,13 +75,44 @@ const copyComponent = async (component, destPath) => {
66
75
 
67
76
  await fs.copy(componentSrc, componentDest, { overwrite: true });
68
77
  console.log(`✓ Component ${component} installed successfully`);
69
- console.log(`\nFor documentation visit: ${CONFIG.docs}`);
70
78
  } catch (error) {
71
79
  console.error(`Error installing component ${component}:`, error.message);
72
80
  process.exit(1);
73
81
  }
74
82
  };
75
83
 
84
+ const installComponentWithDependencies = async (component, destPath) => {
85
+ // Get dependencies for the component
86
+ const dependencies = CONFIG.dependencies[component] || [];
87
+ const componentsToInstall = new Set([component, ...dependencies]);
88
+
89
+ // Check which components need to be installed
90
+ const pendingInstalls = Array.from(componentsToInstall).filter(
91
+ (comp) => !checkComponentExists(comp, destPath)
92
+ );
93
+
94
+ if (pendingInstalls.length === 0) {
95
+ console.log(
96
+ `✓ ${component} and all its dependencies are already installed.`
97
+ );
98
+ return;
99
+ }
100
+
101
+ // Install all pending components
102
+ for (const comp of pendingInstalls) {
103
+ await copyComponent(comp, destPath);
104
+ }
105
+
106
+ if (dependencies.length > 0) {
107
+ console.log(`\nInstalled dependencies for ${component}:`);
108
+ dependencies.forEach((dep) => {
109
+ console.log(`- ${dep}`);
110
+ });
111
+ }
112
+
113
+ console.log(`\nFor documentation visit: ${CONFIG.docs}`);
114
+ };
115
+
76
116
  const detectFramework = () => {
77
117
  // Check for Next.js
78
118
  if (fs.existsSync(path.join(process.cwd(), "next.config.js"))) {
@@ -110,7 +150,12 @@ const main = async () => {
110
150
  // List components if requested
111
151
  if (argv.list) {
112
152
  console.log("\nAvailable components:");
113
- CONFIG.components.forEach((comp) => console.log(`- ${comp}`));
153
+ CONFIG.components.forEach((comp) => {
154
+ const deps = CONFIG.dependencies[comp]
155
+ ? ` (requires: ${CONFIG.dependencies[comp].join(", ")})`
156
+ : "";
157
+ console.log(`- ${comp}${deps}`);
158
+ });
114
159
  return;
115
160
  }
116
161
 
@@ -157,8 +202,8 @@ const main = async () => {
157
202
  await copyCommonFiles(destPath);
158
203
  }
159
204
 
160
- // Copy the requested component
161
- await copyComponent(component, destPath);
205
+ // Install component and its dependencies
206
+ await installComponentWithDependencies(component, destPath);
162
207
  };
163
208
 
164
209
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.52",
3
+ "version": "0.0.53-beta",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -86,6 +86,7 @@ export default function DatePickerHandles({
86
86
  : undefined
87
87
  }
88
88
  selectedDateValue={item?.value ? new Date(item.value) : undefined}
89
+ disabled={isDisabled}
89
90
  />
90
91
  </div>
91
92
  );