benflux-ui 0.1.4 → 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";
@@ -214,6 +214,7 @@ export function cn(...inputs: ClassValue[]) {
214
214
 
215
215
  // src/commands/add.ts
216
216
  var clack2 = __toESM(require("@clack/prompts"));
217
+ var import_checkbox = __toESM(require("@inquirer/checkbox"));
217
218
  var import_execa2 = require("execa");
218
219
  var import_fs_extra3 = __toESM(require("fs-extra"));
219
220
  var import_path3 = __toESM(require("path"));
@@ -808,6 +809,16 @@ function getComponent(name) {
808
809
  }
809
810
 
810
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
+ };
811
822
  async function addCommand(components, options) {
812
823
  const cwd = process.cwd();
813
824
  clack2.intro(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" Benflux UI \u2014 Add Components ")));
@@ -819,28 +830,29 @@ async function addCommand(components, options) {
819
830
  const defaultDir = options.path ?? await getComponentsPath(cwd);
820
831
  let selectedComponents = components;
821
832
  if (selectedComponents.length === 0) {
822
- const categoryLabel = {
823
- layout: "Layout",
824
- inputs: "Inputs",
825
- navigation: "Navigation",
826
- feedback: "Feedback",
827
- "data-display": "Data Display",
828
- ai: "AI",
829
- wow: "WOW Effects"
830
- };
831
- const sorted = [...REGISTRY].sort(
832
- (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
833
- );
834
- const selected = await clack2.multiselect({
835
- message: "Which components would you like to add? \u2191\u2193 navigate \xB7 Space select \xB7 Enter confirm",
836
- options: sorted.map((c) => ({
837
- label: c.name,
838
- hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
839
- value: c.name
840
- }))
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)({
849
+ message: "Which components would you like to add?",
850
+ choices,
851
+ pageSize: 16,
852
+ loop: false
841
853
  });
842
- if (clack2.isCancel(selected)) {
843
- clack2.cancel("Cancelled.");
854
+ if (!selected.length) {
855
+ clack2.cancel("No components selected.");
844
856
  process.exit(0);
845
857
  }
846
858
  selectedComponents = selected;
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";
@@ -232,6 +232,7 @@ export function cn(...inputs: ClassValue[]) {
232
232
 
233
233
  // src/commands/add.ts
234
234
  var clack2 = __toESM(require("@clack/prompts"));
235
+ var import_checkbox = __toESM(require("@inquirer/checkbox"));
235
236
  var import_execa2 = require("execa");
236
237
  var import_fs_extra3 = __toESM(require("fs-extra"));
237
238
  var import_path3 = __toESM(require("path"));
@@ -835,6 +836,16 @@ function searchComponents(query) {
835
836
  }
836
837
 
837
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
+ };
838
849
  async function addCommand(components, options) {
839
850
  const cwd = process.cwd();
840
851
  clack2.intro(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" Benflux UI \u2014 Add Components ")));
@@ -846,28 +857,29 @@ async function addCommand(components, options) {
846
857
  const defaultDir = options.path ?? await getComponentsPath(cwd);
847
858
  let selectedComponents = components;
848
859
  if (selectedComponents.length === 0) {
849
- const categoryLabel = {
850
- layout: "Layout",
851
- inputs: "Inputs",
852
- navigation: "Navigation",
853
- feedback: "Feedback",
854
- "data-display": "Data Display",
855
- ai: "AI",
856
- wow: "WOW Effects"
857
- };
858
- const sorted = [...REGISTRY].sort(
859
- (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
860
- );
861
- const selected = await clack2.multiselect({
862
- message: "Which components would you like to add? \u2191\u2193 navigate \xB7 Space select \xB7 Enter confirm",
863
- options: sorted.map((c) => ({
864
- label: c.name,
865
- hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
866
- value: c.name
867
- }))
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)({
876
+ message: "Which components would you like to add?",
877
+ choices,
878
+ pageSize: 16,
879
+ loop: false
868
880
  });
869
- if (clack2.isCancel(selected)) {
870
- clack2.cancel("Cancelled.");
881
+ if (!selected.length) {
882
+ clack2.cancel("No components selected.");
871
883
  process.exit(0);
872
884
  }
873
885
  selectedComponents = selected;
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";
@@ -185,6 +185,7 @@ export function cn(...inputs: ClassValue[]) {
185
185
 
186
186
  // src/commands/add.ts
187
187
  import * as clack2 from "@clack/prompts";
188
+ import checkbox, { Separator } from "@inquirer/checkbox";
188
189
  import { execa as execa2 } from "execa";
189
190
  import fs3 from "fs-extra";
190
191
  import path3 from "path";
@@ -788,6 +789,16 @@ function searchComponents(query) {
788
789
  }
789
790
 
790
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
+ };
791
802
  async function addCommand(components, options) {
792
803
  const cwd = process.cwd();
793
804
  clack2.intro(pc2.bgCyan(pc2.black(" Benflux UI \u2014 Add Components ")));
@@ -799,28 +810,29 @@ async function addCommand(components, options) {
799
810
  const defaultDir = options.path ?? await getComponentsPath(cwd);
800
811
  let selectedComponents = components;
801
812
  if (selectedComponents.length === 0) {
802
- const categoryLabel = {
803
- layout: "Layout",
804
- inputs: "Inputs",
805
- navigation: "Navigation",
806
- feedback: "Feedback",
807
- "data-display": "Data Display",
808
- ai: "AI",
809
- wow: "WOW Effects"
810
- };
811
- const sorted = [...REGISTRY].sort(
812
- (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
813
- );
814
- const selected = await clack2.multiselect({
815
- message: "Which components would you like to add? \u2191\u2193 navigate \xB7 Space select \xB7 Enter confirm",
816
- options: sorted.map((c) => ({
817
- label: c.name,
818
- hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
819
- value: c.name
820
- }))
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({
829
+ message: "Which components would you like to add?",
830
+ choices,
831
+ pageSize: 16,
832
+ loop: false
821
833
  });
822
- if (clack2.isCancel(selected)) {
823
- clack2.cancel("Cancelled.");
834
+ if (!selected.length) {
835
+ clack2.cancel("No components selected.");
824
836
  process.exit(0);
825
837
  }
826
838
  selectedComponents = selected;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benflux-ui",
3
- "version": "0.1.4",
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",