benflux-ui 0.1.3 → 0.1.5

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.
@@ -35,8 +35,8 @@ var import_path2 = __toESM(require("path"));
35
35
  var import_picocolors = __toESM(require("picocolors"));
36
36
 
37
37
  // src/utils/detect-framework.ts
38
- var import_path = __toESM(require("path"));
39
38
  var import_fs_extra = __toESM(require("fs-extra"));
39
+ var import_path = __toESM(require("path"));
40
40
  async function detectFramework(cwd) {
41
41
  const pkgPath = import_path.default.join(cwd, "package.json");
42
42
  if (!await import_fs_extra.default.pathExists(pkgPath)) return "unknown";
@@ -70,6 +70,9 @@ async function hasTailwind(cwd) {
70
70
  const version = await detectTailwindVersion(cwd);
71
71
  return version !== null;
72
72
  }
73
+ async function hasSrcDir(cwd) {
74
+ return import_fs_extra.default.pathExists(import_path.default.join(cwd, "src"));
75
+ }
73
76
  async function getComponentsPath(cwd) {
74
77
  const candidates = [
75
78
  "src/components/ui",
@@ -83,11 +86,8 @@ async function getComponentsPath(cwd) {
83
86
  return candidate;
84
87
  }
85
88
  }
86
- const framework = await detectFramework(cwd);
87
- if (framework === "next") {
88
- return "src/components/ui";
89
- }
90
- return "src/components/ui";
89
+ const useSrc = await hasSrcDir(cwd);
90
+ return useSrc ? "src/components/ui" : "components/ui";
91
91
  }
92
92
 
93
93
  // src/commands/init.ts
@@ -97,6 +97,7 @@ async function initCommand(options) {
97
97
  const framework = await detectFramework(cwd);
98
98
  const pm = await detectPackageManager(cwd);
99
99
  const hasTw = await hasTailwind(cwd);
100
+ const useSrc = await hasSrcDir(cwd);
100
101
  const defaultPath = await getComponentsPath(cwd);
101
102
  clack.note(
102
103
  [
@@ -149,25 +150,28 @@ async function initCommand(options) {
149
150
  const componentsPath = import_path2.default.join(cwd, settings.componentsDir);
150
151
  await import_fs_extra2.default.ensureDir(componentsPath);
151
152
  spinner3.stop(`Components directory: ${import_picocolors.default.cyan(settings.componentsDir)}`);
153
+ const libDir = useSrc ? "src/lib" : "lib";
154
+ const globalsCss = useSrc ? "src/app/globals.css" : "app/globals.css";
155
+ const componentsAlias = `@/${settings.componentsDir.replace(/^src\//, "")}`;
152
156
  spinner3.start("Creating benflux-ui.json config...");
153
157
  const config = {
154
158
  $schema: "https://benflux-ui.vercel.app/schema.json",
155
159
  style: "default",
156
160
  typescript: settings.typescript,
157
161
  tailwind: {
158
- config: hasTw ? "tailwind.config.ts" : "tailwind.config.ts",
159
- css: "src/app/globals.css",
162
+ config: "tailwind.config.ts",
163
+ css: globalsCss,
160
164
  baseColor: "default"
161
165
  },
162
166
  aliases: {
163
- components: `@/${settings.componentsDir.replace("src/", "")}`,
167
+ components: componentsAlias,
164
168
  utils: "@/lib/utils"
165
169
  }
166
170
  };
167
171
  await import_fs_extra2.default.writeJson(import_path2.default.join(cwd, "benflux-ui.json"), config, { spaces: 2 });
168
172
  spinner3.stop("benflux-ui.json created");
169
173
  spinner3.start("Creating utility functions...");
170
- const utilsDir = import_path2.default.join(cwd, "src/lib");
174
+ const utilsDir = import_path2.default.join(cwd, libDir);
171
175
  await import_fs_extra2.default.ensureDir(utilsDir);
172
176
  await import_fs_extra2.default.writeFile(
173
177
  import_path2.default.join(utilsDir, "utils.ts"),
@@ -179,7 +183,7 @@ export function cn(...inputs: ClassValue[]) {
179
183
  }
180
184
  `
181
185
  );
182
- spinner3.stop("lib/utils.ts created");
186
+ spinner3.stop(`${libDir}/utils.ts created`);
183
187
  if (settings.installDeps) {
184
188
  spinner3.start(`Installing core dependencies with ${pm}...`);
185
189
  try {
@@ -209,11 +213,12 @@ export function cn(...inputs: ClassValue[]) {
209
213
  }
210
214
 
211
215
  // src/commands/add.ts
212
- var import_path3 = __toESM(require("path"));
213
216
  var clack2 = __toESM(require("@clack/prompts"));
214
- var import_picocolors2 = __toESM(require("picocolors"));
215
- var import_fs_extra3 = __toESM(require("fs-extra"));
217
+ var import_checkbox = __toESM(require("@inquirer/checkbox"));
216
218
  var import_execa2 = require("execa");
219
+ var import_fs_extra3 = __toESM(require("fs-extra"));
220
+ var import_path3 = __toESM(require("path"));
221
+ var import_picocolors2 = __toESM(require("picocolors"));
217
222
 
218
223
  // src/utils/registry.ts
219
224
  var REGISTRY = [
@@ -804,6 +809,16 @@ function getComponent(name) {
804
809
  }
805
810
 
806
811
  // src/commands/add.ts
812
+ var CATEGORY_ORDER = ["layout", "inputs", "navigation", "feedback", "data-display", "ai", "wow"];
813
+ var CATEGORY_LABEL = {
814
+ layout: "Layout",
815
+ inputs: "Inputs",
816
+ navigation: "Navigation",
817
+ feedback: "Feedback",
818
+ "data-display": "Data Display",
819
+ ai: "AI",
820
+ wow: "WOW Effects"
821
+ };
807
822
  async function addCommand(components, options) {
808
823
  const cwd = process.cwd();
809
824
  clack2.intro(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" Benflux UI \u2014 Add Components ")));
@@ -815,28 +830,29 @@ async function addCommand(components, options) {
815
830
  const defaultDir = options.path ?? await getComponentsPath(cwd);
816
831
  let selectedComponents = components;
817
832
  if (selectedComponents.length === 0) {
818
- const categoryLabel = {
819
- layout: "Layout",
820
- inputs: "Inputs",
821
- navigation: "Navigation",
822
- feedback: "Feedback",
823
- "data-display": "Data Display",
824
- ai: "AI",
825
- wow: "WOW Effects"
826
- };
827
- const sorted = [...REGISTRY].sort(
828
- (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
829
- );
830
- const selected = await clack2.multiselect({
833
+ const byCategory = /* @__PURE__ */ new Map();
834
+ for (const c of REGISTRY) {
835
+ const list = byCategory.get(c.category) ?? [];
836
+ list.push(c);
837
+ byCategory.set(c.category, list);
838
+ }
839
+ const choices = [];
840
+ for (const cat of CATEGORY_ORDER) {
841
+ const items = byCategory.get(cat);
842
+ if (!items?.length) continue;
843
+ choices.push(new import_checkbox.Separator(`\u2500\u2500 ${CATEGORY_LABEL[cat] ?? cat} \u2500\u2500`));
844
+ for (const c of items.sort((a, b) => a.name.localeCompare(b.name))) {
845
+ choices.push({ name: c.name, value: c.name, description: c.description });
846
+ }
847
+ }
848
+ const selected = await (0, import_checkbox.default)({
831
849
  message: "Which components would you like to add?",
832
- options: sorted.map((c) => ({
833
- label: c.name,
834
- hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
835
- value: c.name
836
- }))
850
+ choices,
851
+ pageSize: 16,
852
+ loop: false
837
853
  });
838
- if (clack2.isCancel(selected)) {
839
- clack2.cancel("Cancelled.");
854
+ if (!selected.length) {
855
+ clack2.cancel("No components selected.");
840
856
  process.exit(0);
841
857
  }
842
858
  selectedComponents = selected;
@@ -844,7 +860,9 @@ async function addCommand(components, options) {
844
860
  const validComponents = selectedComponents.map((name) => {
845
861
  const component = getComponent(name);
846
862
  if (!component) {
847
- clack2.log.warn(`Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`);
863
+ clack2.log.warn(
864
+ `Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`
865
+ );
848
866
  return null;
849
867
  }
850
868
  return component;
@@ -893,25 +911,26 @@ async function addCommand(components, options) {
893
911
  for (const file of component.files) {
894
912
  const targetPath = import_path3.default.join(cwd, defaultDir, import_path3.default.basename(file));
895
913
  if (await import_fs_extra3.default.pathExists(targetPath) && !options.overwrite) {
896
- spinner3.stop(`${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`);
914
+ spinner3.stop(
915
+ `${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`
916
+ );
897
917
  continue;
898
918
  }
899
- const sourcePath = import_path3.default.join(
900
- cwd,
901
- "node_modules/@benflux-ui/react/src",
902
- file
903
- );
904
- if (await import_fs_extra3.default.pathExists(sourcePath)) {
905
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
906
- await import_fs_extra3.default.copy(sourcePath, targetPath);
919
+ await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
920
+ const localSrc = import_path3.default.join(cwd, "node_modules/@benflux-ui/react/src", file);
921
+ if (await import_fs_extra3.default.pathExists(localSrc)) {
922
+ await import_fs_extra3.default.copy(localSrc, targetPath);
907
923
  } else {
908
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
909
- await import_fs_extra3.default.writeFile(
910
- targetPath,
911
- `// ${component.name} \u2014 Install @benflux-ui/react to get the full component
912
- export {} from "@benflux-ui/react"
913
- `
914
- );
924
+ const url = `https://unpkg.com/@benflux-ui/react@latest/src/${file}`;
925
+ try {
926
+ const res = await fetch(url);
927
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
928
+ const source = await res.text();
929
+ await import_fs_extra3.default.writeFile(targetPath, source, "utf-8");
930
+ } catch (err) {
931
+ spinner3.stop(import_picocolors2.default.red(`Failed to fetch ${file}: ${err.message}`));
932
+ clack2.log.warn(`Download manually from: ${url}`);
933
+ }
915
934
  }
916
935
  }
917
936
  spinner3.stop(`${import_picocolors2.default.green("\u2713")} Added ${component.name}`);
@@ -921,7 +940,11 @@ export {} from "@benflux-ui/react"
921
940
  import_picocolors2.default.green("\u2713") + " Components added successfully!",
922
941
  "",
923
942
  import_picocolors2.default.bold("Usage:"),
924
- ` ${import_picocolors2.default.cyan(`import { ${validComponents.map((c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")).join(", ")} } from "@benflux-ui/react"`)}`
943
+ ` ${import_picocolors2.default.cyan(
944
+ `import { ${validComponents.map(
945
+ (c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
946
+ ).join(", ")} } from "@benflux-ui/react"`
947
+ )}`
925
948
  ].join("\n")
926
949
  );
927
950
  }
package/dist/index.js CHANGED
@@ -53,8 +53,8 @@ var import_path2 = __toESM(require("path"));
53
53
  var import_picocolors = __toESM(require("picocolors"));
54
54
 
55
55
  // src/utils/detect-framework.ts
56
- var import_path = __toESM(require("path"));
57
56
  var import_fs_extra = __toESM(require("fs-extra"));
57
+ var import_path = __toESM(require("path"));
58
58
  async function detectFramework(cwd) {
59
59
  const pkgPath = import_path.default.join(cwd, "package.json");
60
60
  if (!await import_fs_extra.default.pathExists(pkgPath)) return "unknown";
@@ -88,6 +88,9 @@ async function hasTailwind(cwd) {
88
88
  const version = await detectTailwindVersion(cwd);
89
89
  return version !== null;
90
90
  }
91
+ async function hasSrcDir(cwd) {
92
+ return import_fs_extra.default.pathExists(import_path.default.join(cwd, "src"));
93
+ }
91
94
  async function getComponentsPath(cwd) {
92
95
  const candidates = [
93
96
  "src/components/ui",
@@ -101,11 +104,8 @@ async function getComponentsPath(cwd) {
101
104
  return candidate;
102
105
  }
103
106
  }
104
- const framework = await detectFramework(cwd);
105
- if (framework === "next") {
106
- return "src/components/ui";
107
- }
108
- return "src/components/ui";
107
+ const useSrc = await hasSrcDir(cwd);
108
+ return useSrc ? "src/components/ui" : "components/ui";
109
109
  }
110
110
 
111
111
  // src/commands/init.ts
@@ -115,6 +115,7 @@ async function initCommand(options) {
115
115
  const framework = await detectFramework(cwd);
116
116
  const pm = await detectPackageManager(cwd);
117
117
  const hasTw = await hasTailwind(cwd);
118
+ const useSrc = await hasSrcDir(cwd);
118
119
  const defaultPath = await getComponentsPath(cwd);
119
120
  clack.note(
120
121
  [
@@ -167,25 +168,28 @@ async function initCommand(options) {
167
168
  const componentsPath = import_path2.default.join(cwd, settings.componentsDir);
168
169
  await import_fs_extra2.default.ensureDir(componentsPath);
169
170
  spinner3.stop(`Components directory: ${import_picocolors.default.cyan(settings.componentsDir)}`);
171
+ const libDir = useSrc ? "src/lib" : "lib";
172
+ const globalsCss = useSrc ? "src/app/globals.css" : "app/globals.css";
173
+ const componentsAlias = `@/${settings.componentsDir.replace(/^src\//, "")}`;
170
174
  spinner3.start("Creating benflux-ui.json config...");
171
175
  const config = {
172
176
  $schema: "https://benflux-ui.vercel.app/schema.json",
173
177
  style: "default",
174
178
  typescript: settings.typescript,
175
179
  tailwind: {
176
- config: hasTw ? "tailwind.config.ts" : "tailwind.config.ts",
177
- css: "src/app/globals.css",
180
+ config: "tailwind.config.ts",
181
+ css: globalsCss,
178
182
  baseColor: "default"
179
183
  },
180
184
  aliases: {
181
- components: `@/${settings.componentsDir.replace("src/", "")}`,
185
+ components: componentsAlias,
182
186
  utils: "@/lib/utils"
183
187
  }
184
188
  };
185
189
  await import_fs_extra2.default.writeJson(import_path2.default.join(cwd, "benflux-ui.json"), config, { spaces: 2 });
186
190
  spinner3.stop("benflux-ui.json created");
187
191
  spinner3.start("Creating utility functions...");
188
- const utilsDir = import_path2.default.join(cwd, "src/lib");
192
+ const utilsDir = import_path2.default.join(cwd, libDir);
189
193
  await import_fs_extra2.default.ensureDir(utilsDir);
190
194
  await import_fs_extra2.default.writeFile(
191
195
  import_path2.default.join(utilsDir, "utils.ts"),
@@ -197,7 +201,7 @@ export function cn(...inputs: ClassValue[]) {
197
201
  }
198
202
  `
199
203
  );
200
- spinner3.stop("lib/utils.ts created");
204
+ spinner3.stop(`${libDir}/utils.ts created`);
201
205
  if (settings.installDeps) {
202
206
  spinner3.start(`Installing core dependencies with ${pm}...`);
203
207
  try {
@@ -227,11 +231,12 @@ export function cn(...inputs: ClassValue[]) {
227
231
  }
228
232
 
229
233
  // src/commands/add.ts
230
- var import_path3 = __toESM(require("path"));
231
234
  var clack2 = __toESM(require("@clack/prompts"));
232
- var import_picocolors2 = __toESM(require("picocolors"));
233
- var import_fs_extra3 = __toESM(require("fs-extra"));
235
+ var import_checkbox = __toESM(require("@inquirer/checkbox"));
234
236
  var import_execa2 = require("execa");
237
+ var import_fs_extra3 = __toESM(require("fs-extra"));
238
+ var import_path3 = __toESM(require("path"));
239
+ var import_picocolors2 = __toESM(require("picocolors"));
235
240
 
236
241
  // src/utils/registry.ts
237
242
  var REGISTRY = [
@@ -831,6 +836,16 @@ function searchComponents(query) {
831
836
  }
832
837
 
833
838
  // src/commands/add.ts
839
+ var CATEGORY_ORDER = ["layout", "inputs", "navigation", "feedback", "data-display", "ai", "wow"];
840
+ var CATEGORY_LABEL = {
841
+ layout: "Layout",
842
+ inputs: "Inputs",
843
+ navigation: "Navigation",
844
+ feedback: "Feedback",
845
+ "data-display": "Data Display",
846
+ ai: "AI",
847
+ wow: "WOW Effects"
848
+ };
834
849
  async function addCommand(components, options) {
835
850
  const cwd = process.cwd();
836
851
  clack2.intro(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" Benflux UI \u2014 Add Components ")));
@@ -842,28 +857,29 @@ async function addCommand(components, options) {
842
857
  const defaultDir = options.path ?? await getComponentsPath(cwd);
843
858
  let selectedComponents = components;
844
859
  if (selectedComponents.length === 0) {
845
- const categoryLabel = {
846
- layout: "Layout",
847
- inputs: "Inputs",
848
- navigation: "Navigation",
849
- feedback: "Feedback",
850
- "data-display": "Data Display",
851
- ai: "AI",
852
- wow: "WOW Effects"
853
- };
854
- const sorted = [...REGISTRY].sort(
855
- (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
856
- );
857
- const selected = await clack2.multiselect({
860
+ const byCategory = /* @__PURE__ */ new Map();
861
+ for (const c of REGISTRY) {
862
+ const list = byCategory.get(c.category) ?? [];
863
+ list.push(c);
864
+ byCategory.set(c.category, list);
865
+ }
866
+ const choices = [];
867
+ for (const cat of CATEGORY_ORDER) {
868
+ const items = byCategory.get(cat);
869
+ if (!items?.length) continue;
870
+ choices.push(new import_checkbox.Separator(`\u2500\u2500 ${CATEGORY_LABEL[cat] ?? cat} \u2500\u2500`));
871
+ for (const c of items.sort((a, b) => a.name.localeCompare(b.name))) {
872
+ choices.push({ name: c.name, value: c.name, description: c.description });
873
+ }
874
+ }
875
+ const selected = await (0, import_checkbox.default)({
858
876
  message: "Which components would you like to add?",
859
- options: sorted.map((c) => ({
860
- label: c.name,
861
- hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
862
- value: c.name
863
- }))
877
+ choices,
878
+ pageSize: 16,
879
+ loop: false
864
880
  });
865
- if (clack2.isCancel(selected)) {
866
- clack2.cancel("Cancelled.");
881
+ if (!selected.length) {
882
+ clack2.cancel("No components selected.");
867
883
  process.exit(0);
868
884
  }
869
885
  selectedComponents = selected;
@@ -871,7 +887,9 @@ async function addCommand(components, options) {
871
887
  const validComponents = selectedComponents.map((name) => {
872
888
  const component = getComponent(name);
873
889
  if (!component) {
874
- clack2.log.warn(`Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`);
890
+ clack2.log.warn(
891
+ `Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`
892
+ );
875
893
  return null;
876
894
  }
877
895
  return component;
@@ -920,25 +938,26 @@ async function addCommand(components, options) {
920
938
  for (const file of component.files) {
921
939
  const targetPath = import_path3.default.join(cwd, defaultDir, import_path3.default.basename(file));
922
940
  if (await import_fs_extra3.default.pathExists(targetPath) && !options.overwrite) {
923
- spinner3.stop(`${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`);
941
+ spinner3.stop(
942
+ `${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`
943
+ );
924
944
  continue;
925
945
  }
926
- const sourcePath = import_path3.default.join(
927
- cwd,
928
- "node_modules/@benflux-ui/react/src",
929
- file
930
- );
931
- if (await import_fs_extra3.default.pathExists(sourcePath)) {
932
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
933
- await import_fs_extra3.default.copy(sourcePath, targetPath);
946
+ await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
947
+ const localSrc = import_path3.default.join(cwd, "node_modules/@benflux-ui/react/src", file);
948
+ if (await import_fs_extra3.default.pathExists(localSrc)) {
949
+ await import_fs_extra3.default.copy(localSrc, targetPath);
934
950
  } else {
935
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
936
- await import_fs_extra3.default.writeFile(
937
- targetPath,
938
- `// ${component.name} \u2014 Install @benflux-ui/react to get the full component
939
- export {} from "@benflux-ui/react"
940
- `
941
- );
951
+ const url = `https://unpkg.com/@benflux-ui/react@latest/src/${file}`;
952
+ try {
953
+ const res = await fetch(url);
954
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
955
+ const source = await res.text();
956
+ await import_fs_extra3.default.writeFile(targetPath, source, "utf-8");
957
+ } catch (err) {
958
+ spinner3.stop(import_picocolors2.default.red(`Failed to fetch ${file}: ${err.message}`));
959
+ clack2.log.warn(`Download manually from: ${url}`);
960
+ }
942
961
  }
943
962
  }
944
963
  spinner3.stop(`${import_picocolors2.default.green("\u2713")} Added ${component.name}`);
@@ -948,7 +967,11 @@ export {} from "@benflux-ui/react"
948
967
  import_picocolors2.default.green("\u2713") + " Components added successfully!",
949
968
  "",
950
969
  import_picocolors2.default.bold("Usage:"),
951
- ` ${import_picocolors2.default.cyan(`import { ${validComponents.map((c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")).join(", ")} } from "@benflux-ui/react"`)}`
970
+ ` ${import_picocolors2.default.cyan(
971
+ `import { ${validComponents.map(
972
+ (c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
973
+ ).join(", ")} } from "@benflux-ui/react"`
974
+ )}`
952
975
  ].join("\n")
953
976
  );
954
977
  }
package/dist/index.mjs CHANGED
@@ -6,8 +6,8 @@ import path2 from "path";
6
6
  import pc from "picocolors";
7
7
 
8
8
  // src/utils/detect-framework.ts
9
- import path from "path";
10
9
  import fs from "fs-extra";
10
+ import path from "path";
11
11
  async function detectFramework(cwd) {
12
12
  const pkgPath = path.join(cwd, "package.json");
13
13
  if (!await fs.pathExists(pkgPath)) return "unknown";
@@ -41,6 +41,9 @@ async function hasTailwind(cwd) {
41
41
  const version = await detectTailwindVersion(cwd);
42
42
  return version !== null;
43
43
  }
44
+ async function hasSrcDir(cwd) {
45
+ return fs.pathExists(path.join(cwd, "src"));
46
+ }
44
47
  async function getComponentsPath(cwd) {
45
48
  const candidates = [
46
49
  "src/components/ui",
@@ -54,11 +57,8 @@ async function getComponentsPath(cwd) {
54
57
  return candidate;
55
58
  }
56
59
  }
57
- const framework = await detectFramework(cwd);
58
- if (framework === "next") {
59
- return "src/components/ui";
60
- }
61
- return "src/components/ui";
60
+ const useSrc = await hasSrcDir(cwd);
61
+ return useSrc ? "src/components/ui" : "components/ui";
62
62
  }
63
63
 
64
64
  // src/commands/init.ts
@@ -68,6 +68,7 @@ async function initCommand(options) {
68
68
  const framework = await detectFramework(cwd);
69
69
  const pm = await detectPackageManager(cwd);
70
70
  const hasTw = await hasTailwind(cwd);
71
+ const useSrc = await hasSrcDir(cwd);
71
72
  const defaultPath = await getComponentsPath(cwd);
72
73
  clack.note(
73
74
  [
@@ -120,25 +121,28 @@ async function initCommand(options) {
120
121
  const componentsPath = path2.join(cwd, settings.componentsDir);
121
122
  await fs2.ensureDir(componentsPath);
122
123
  spinner3.stop(`Components directory: ${pc.cyan(settings.componentsDir)}`);
124
+ const libDir = useSrc ? "src/lib" : "lib";
125
+ const globalsCss = useSrc ? "src/app/globals.css" : "app/globals.css";
126
+ const componentsAlias = `@/${settings.componentsDir.replace(/^src\//, "")}`;
123
127
  spinner3.start("Creating benflux-ui.json config...");
124
128
  const config = {
125
129
  $schema: "https://benflux-ui.vercel.app/schema.json",
126
130
  style: "default",
127
131
  typescript: settings.typescript,
128
132
  tailwind: {
129
- config: hasTw ? "tailwind.config.ts" : "tailwind.config.ts",
130
- css: "src/app/globals.css",
133
+ config: "tailwind.config.ts",
134
+ css: globalsCss,
131
135
  baseColor: "default"
132
136
  },
133
137
  aliases: {
134
- components: `@/${settings.componentsDir.replace("src/", "")}`,
138
+ components: componentsAlias,
135
139
  utils: "@/lib/utils"
136
140
  }
137
141
  };
138
142
  await fs2.writeJson(path2.join(cwd, "benflux-ui.json"), config, { spaces: 2 });
139
143
  spinner3.stop("benflux-ui.json created");
140
144
  spinner3.start("Creating utility functions...");
141
- const utilsDir = path2.join(cwd, "src/lib");
145
+ const utilsDir = path2.join(cwd, libDir);
142
146
  await fs2.ensureDir(utilsDir);
143
147
  await fs2.writeFile(
144
148
  path2.join(utilsDir, "utils.ts"),
@@ -150,7 +154,7 @@ export function cn(...inputs: ClassValue[]) {
150
154
  }
151
155
  `
152
156
  );
153
- spinner3.stop("lib/utils.ts created");
157
+ spinner3.stop(`${libDir}/utils.ts created`);
154
158
  if (settings.installDeps) {
155
159
  spinner3.start(`Installing core dependencies with ${pm}...`);
156
160
  try {
@@ -180,11 +184,12 @@ export function cn(...inputs: ClassValue[]) {
180
184
  }
181
185
 
182
186
  // src/commands/add.ts
183
- import path3 from "path";
184
187
  import * as clack2 from "@clack/prompts";
185
- import pc2 from "picocolors";
186
- import fs3 from "fs-extra";
188
+ import checkbox, { Separator } from "@inquirer/checkbox";
187
189
  import { execa as execa2 } from "execa";
190
+ import fs3 from "fs-extra";
191
+ import path3 from "path";
192
+ import pc2 from "picocolors";
188
193
 
189
194
  // src/utils/registry.ts
190
195
  var REGISTRY = [
@@ -784,6 +789,16 @@ function searchComponents(query) {
784
789
  }
785
790
 
786
791
  // src/commands/add.ts
792
+ var CATEGORY_ORDER = ["layout", "inputs", "navigation", "feedback", "data-display", "ai", "wow"];
793
+ var CATEGORY_LABEL = {
794
+ layout: "Layout",
795
+ inputs: "Inputs",
796
+ navigation: "Navigation",
797
+ feedback: "Feedback",
798
+ "data-display": "Data Display",
799
+ ai: "AI",
800
+ wow: "WOW Effects"
801
+ };
787
802
  async function addCommand(components, options) {
788
803
  const cwd = process.cwd();
789
804
  clack2.intro(pc2.bgCyan(pc2.black(" Benflux UI \u2014 Add Components ")));
@@ -795,28 +810,29 @@ async function addCommand(components, options) {
795
810
  const defaultDir = options.path ?? await getComponentsPath(cwd);
796
811
  let selectedComponents = components;
797
812
  if (selectedComponents.length === 0) {
798
- const categoryLabel = {
799
- layout: "Layout",
800
- inputs: "Inputs",
801
- navigation: "Navigation",
802
- feedback: "Feedback",
803
- "data-display": "Data Display",
804
- ai: "AI",
805
- wow: "WOW Effects"
806
- };
807
- const sorted = [...REGISTRY].sort(
808
- (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
809
- );
810
- const selected = await clack2.multiselect({
813
+ const byCategory = /* @__PURE__ */ new Map();
814
+ for (const c of REGISTRY) {
815
+ const list = byCategory.get(c.category) ?? [];
816
+ list.push(c);
817
+ byCategory.set(c.category, list);
818
+ }
819
+ const choices = [];
820
+ for (const cat of CATEGORY_ORDER) {
821
+ const items = byCategory.get(cat);
822
+ if (!items?.length) continue;
823
+ choices.push(new Separator(`\u2500\u2500 ${CATEGORY_LABEL[cat] ?? cat} \u2500\u2500`));
824
+ for (const c of items.sort((a, b) => a.name.localeCompare(b.name))) {
825
+ choices.push({ name: c.name, value: c.name, description: c.description });
826
+ }
827
+ }
828
+ const selected = await checkbox({
811
829
  message: "Which components would you like to add?",
812
- options: sorted.map((c) => ({
813
- label: c.name,
814
- hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
815
- value: c.name
816
- }))
830
+ choices,
831
+ pageSize: 16,
832
+ loop: false
817
833
  });
818
- if (clack2.isCancel(selected)) {
819
- clack2.cancel("Cancelled.");
834
+ if (!selected.length) {
835
+ clack2.cancel("No components selected.");
820
836
  process.exit(0);
821
837
  }
822
838
  selectedComponents = selected;
@@ -824,7 +840,9 @@ async function addCommand(components, options) {
824
840
  const validComponents = selectedComponents.map((name) => {
825
841
  const component = getComponent(name);
826
842
  if (!component) {
827
- clack2.log.warn(`Component ${pc2.yellow(name)} not found. Use ${pc2.cyan("benflux-ui list")} to see available components.`);
843
+ clack2.log.warn(
844
+ `Component ${pc2.yellow(name)} not found. Use ${pc2.cyan("benflux-ui list")} to see available components.`
845
+ );
828
846
  return null;
829
847
  }
830
848
  return component;
@@ -873,25 +891,26 @@ async function addCommand(components, options) {
873
891
  for (const file of component.files) {
874
892
  const targetPath = path3.join(cwd, defaultDir, path3.basename(file));
875
893
  if (await fs3.pathExists(targetPath) && !options.overwrite) {
876
- spinner3.stop(`${pc2.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`);
894
+ spinner3.stop(
895
+ `${pc2.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`
896
+ );
877
897
  continue;
878
898
  }
879
- const sourcePath = path3.join(
880
- cwd,
881
- "node_modules/@benflux-ui/react/src",
882
- file
883
- );
884
- if (await fs3.pathExists(sourcePath)) {
885
- await fs3.ensureDir(path3.dirname(targetPath));
886
- await fs3.copy(sourcePath, targetPath);
899
+ await fs3.ensureDir(path3.dirname(targetPath));
900
+ const localSrc = path3.join(cwd, "node_modules/@benflux-ui/react/src", file);
901
+ if (await fs3.pathExists(localSrc)) {
902
+ await fs3.copy(localSrc, targetPath);
887
903
  } else {
888
- await fs3.ensureDir(path3.dirname(targetPath));
889
- await fs3.writeFile(
890
- targetPath,
891
- `// ${component.name} \u2014 Install @benflux-ui/react to get the full component
892
- export {} from "@benflux-ui/react"
893
- `
894
- );
904
+ const url = `https://unpkg.com/@benflux-ui/react@latest/src/${file}`;
905
+ try {
906
+ const res = await fetch(url);
907
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
908
+ const source = await res.text();
909
+ await fs3.writeFile(targetPath, source, "utf-8");
910
+ } catch (err) {
911
+ spinner3.stop(pc2.red(`Failed to fetch ${file}: ${err.message}`));
912
+ clack2.log.warn(`Download manually from: ${url}`);
913
+ }
895
914
  }
896
915
  }
897
916
  spinner3.stop(`${pc2.green("\u2713")} Added ${component.name}`);
@@ -901,7 +920,11 @@ export {} from "@benflux-ui/react"
901
920
  pc2.green("\u2713") + " Components added successfully!",
902
921
  "",
903
922
  pc2.bold("Usage:"),
904
- ` ${pc2.cyan(`import { ${validComponents.map((c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")).join(", ")} } from "@benflux-ui/react"`)}`
923
+ ` ${pc2.cyan(
924
+ `import { ${validComponents.map(
925
+ (c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
926
+ ).join(", ")} } from "@benflux-ui/react"`
927
+ )}`
905
928
  ].join("\n")
906
929
  );
907
930
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benflux-ui",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CLI for adding Benflux UI components to your project",
5
5
  "keywords": [
6
6
  "benflux-ui",
@@ -35,6 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@clack/prompts": "^0.7.0",
38
+ "@inquirer/checkbox": "^5.2.0",
38
39
  "chalk": "^5.3.0",
39
40
  "commander": "^12.1.0",
40
41
  "execa": "^9.2.0",