@dinachi/cli 0.6.3 → 0.7.1
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/dist/index.js +133 -34
- package/package.json +2 -3
- package/templates/alert-dialog/alert-dialog.tsx +62 -47
- package/templates/autocomplete/autocomplete.tsx +7 -7
- package/templates/badge/badge.tsx +58 -119
- package/templates/card/card.tsx +1 -1
- package/templates/checkbox/checkbox.tsx +16 -14
- package/templates/combobox/combobox.tsx +5 -5
- package/templates/context-menu/context-menu.tsx +124 -186
- package/templates/context-menu/index.ts +3 -1
- package/templates/dialog/dialog.tsx +26 -27
- package/templates/drawer/drawer.tsx +23 -21
- package/templates/field/field.tsx +5 -15
- package/templates/form/form.tsx +9 -66
- package/templates/label/index.ts +1 -0
- package/templates/label/label.tsx +21 -0
- package/templates/menu/index.ts +2 -0
- package/templates/menu/menu.tsx +59 -61
- package/templates/menubar/menubar.tsx +44 -72
- package/templates/navigation-menu/navigation-menu.tsx +61 -18
- package/templates/popover/index.ts +4 -1
- package/templates/popover/popover.tsx +80 -30
- package/templates/preview-card/preview-card.tsx +19 -5
- package/templates/radio/index.ts +1 -1
- package/templates/radio/radio.tsx +30 -14
- package/templates/select/select.tsx +75 -73
- package/templates/skeleton/index.ts +1 -0
- package/templates/skeleton/skeleton.tsx +12 -0
- package/templates/slider/slider.tsx +9 -15
- package/templates/switch/switch.tsx +15 -11
- package/templates/tabs/tabs.tsx +2 -2
- package/templates/toast/toast.tsx +137 -74
- package/templates/toggle/toggle.tsx +0 -17
- package/templates/toggle-group/toggle-group.tsx +8 -3
- package/templates/toolbar/toolbar.tsx +5 -4
- package/templates/tooltip/tooltip.tsx +9 -54
package/dist/index.js
CHANGED
|
@@ -202,6 +202,13 @@ function getComponentRegistry() {
|
|
|
202
202
|
dependencies: ["@base-ui/react"],
|
|
203
203
|
utilityDependencies: ["cn"]
|
|
204
204
|
},
|
|
205
|
+
label: {
|
|
206
|
+
name: "label",
|
|
207
|
+
description: "A styled label component for form fields.",
|
|
208
|
+
files: [{ name: "label.tsx" }, { name: "index.ts" }],
|
|
209
|
+
dependencies: [],
|
|
210
|
+
utilityDependencies: ["cn"]
|
|
211
|
+
},
|
|
205
212
|
menu: {
|
|
206
213
|
name: "menu",
|
|
207
214
|
description: "A popup menu for actions and options triggered by a button.",
|
|
@@ -262,7 +269,7 @@ function getComponentRegistry() {
|
|
|
262
269
|
name: "radio",
|
|
263
270
|
description: "A radio input and group for selecting a single option from a set.",
|
|
264
271
|
files: [{ name: "radio.tsx" }, { name: "index.ts" }],
|
|
265
|
-
dependencies: ["@base-ui/react"
|
|
272
|
+
dependencies: ["@base-ui/react"],
|
|
266
273
|
utilityDependencies: ["cn"]
|
|
267
274
|
},
|
|
268
275
|
"scroll-area": {
|
|
@@ -286,6 +293,13 @@ function getComponentRegistry() {
|
|
|
286
293
|
dependencies: ["@base-ui/react"],
|
|
287
294
|
utilityDependencies: ["cn"]
|
|
288
295
|
},
|
|
296
|
+
skeleton: {
|
|
297
|
+
name: "skeleton",
|
|
298
|
+
description: "A placeholder loading animation component.",
|
|
299
|
+
files: [{ name: "skeleton.tsx" }, { name: "index.ts" }],
|
|
300
|
+
dependencies: [],
|
|
301
|
+
utilityDependencies: ["cn"]
|
|
302
|
+
},
|
|
289
303
|
slider: {
|
|
290
304
|
name: "slider",
|
|
291
305
|
description: "An input where the user selects a value from within a given range.",
|
|
@@ -318,7 +332,7 @@ function getComponentRegistry() {
|
|
|
318
332
|
name: "toast",
|
|
319
333
|
description: "Generates toast notifications with support for different types, promises, actions, and global management.",
|
|
320
334
|
files: [{ name: "toast.tsx" }, { name: "index.ts" }],
|
|
321
|
-
dependencies: ["@base-ui/react", "class-variance-authority"],
|
|
335
|
+
dependencies: ["@base-ui/react", "class-variance-authority", "lucide-react"],
|
|
322
336
|
utilityDependencies: ["cn"]
|
|
323
337
|
},
|
|
324
338
|
toggle: {
|
|
@@ -472,6 +486,7 @@ var DEPENDENCY_VERSION_MAP = {
|
|
|
472
486
|
"lucide-react": "^0.552.0",
|
|
473
487
|
"class-variance-authority": "^0.7.1",
|
|
474
488
|
"tailwindcss-animate": "^1.0.7",
|
|
489
|
+
"tw-animate-css": "^1.3.4",
|
|
475
490
|
"clsx": "^2.1.1",
|
|
476
491
|
"tailwind-merge": "^3.3.1"
|
|
477
492
|
};
|
|
@@ -566,9 +581,23 @@ function resolveConfiguredPath(aliasOrPath, projectRoot, compilerConfig) {
|
|
|
566
581
|
}
|
|
567
582
|
return path3.resolve(projectRoot, normalized);
|
|
568
583
|
}
|
|
569
|
-
function
|
|
570
|
-
|
|
571
|
-
const
|
|
584
|
+
function tryResolveAsAlias(absoluteFilePath, compilerConfig) {
|
|
585
|
+
if (!compilerConfig) return null;
|
|
586
|
+
for (const [pattern, targets] of Object.entries(compilerConfig.paths)) {
|
|
587
|
+
if (!pattern.includes("*") || !targets[0]?.includes("*")) continue;
|
|
588
|
+
const [prefix] = pattern.split("*");
|
|
589
|
+
const [targetPrefix] = targets[0].split("*");
|
|
590
|
+
const targetBase = path3.resolve(compilerConfig.baseUrl, targetPrefix);
|
|
591
|
+
const rel = path3.relative(targetBase, absoluteFilePath).replace(/\\/g, "/");
|
|
592
|
+
if (!rel.startsWith("..")) {
|
|
593
|
+
return prefix + stripExtension(rel);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
function rewriteTemplateImports(content, targetFilePath, utilsFilePath, libDirPath, compilerConfig) {
|
|
599
|
+
const utilsImportPath = tryResolveAsAlias(utilsFilePath, compilerConfig) ?? toImportPath(targetFilePath, utilsFilePath);
|
|
600
|
+
const variantsImportPath = tryResolveAsAlias(path3.join(libDirPath, "variants.ts"), compilerConfig) ?? toImportPath(targetFilePath, path3.join(libDirPath, "variants.ts"));
|
|
572
601
|
return content.replace(/(['"])@\/lib\/utils\1/g, `$1${utilsImportPath}$1`).replace(/(['"])@\/lib\/variants\1/g, `$1${variantsImportPath}$1`);
|
|
573
602
|
}
|
|
574
603
|
function getComponentDependencies(componentName, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -659,25 +688,25 @@ function detectTailwindMajorVersion(projectRoot) {
|
|
|
659
688
|
}
|
|
660
689
|
}
|
|
661
690
|
async function ensureTW4Plugin(deps, cssFilePath) {
|
|
662
|
-
if (!deps.includes("tailwindcss-animate")) {
|
|
691
|
+
if (!deps.includes("tw-animate-css") && !deps.includes("tailwindcss-animate")) {
|
|
663
692
|
return null;
|
|
664
693
|
}
|
|
665
694
|
if (!fs3.existsSync(cssFilePath)) {
|
|
666
695
|
return { skipped: true, path: cssFilePath };
|
|
667
696
|
}
|
|
668
697
|
const content = await fs3.readFile(cssFilePath, "utf-8");
|
|
669
|
-
if (content.includes("tailwindcss-animate")) {
|
|
698
|
+
if (content.includes("tw-animate-css") || content.includes("tailwindcss-animate")) {
|
|
670
699
|
return { exists: true, path: cssFilePath };
|
|
671
700
|
}
|
|
672
|
-
const
|
|
701
|
+
const importLine = '@import "tw-animate-css";';
|
|
673
702
|
const importMatch = content.match(/^@import\s+["']tailwindcss["'];?\s*$/m);
|
|
674
703
|
let updated;
|
|
675
704
|
if (importMatch) {
|
|
676
705
|
updated = content.replace(importMatch[0], `${importMatch[0].trimEnd()}
|
|
677
|
-
${
|
|
706
|
+
${importLine}
|
|
678
707
|
`);
|
|
679
708
|
} else {
|
|
680
|
-
updated = `${
|
|
709
|
+
updated = `${importLine}
|
|
681
710
|
${content}`;
|
|
682
711
|
}
|
|
683
712
|
await fs3.writeFile(cssFilePath, updated);
|
|
@@ -904,16 +933,37 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
904
933
|
spinner.start();
|
|
905
934
|
}
|
|
906
935
|
const templateContent = stripTemplateDirective(await fs3.readFile(sourcePath, "utf-8"));
|
|
907
|
-
const rewrittenContent = rewriteTemplateImports(templateContent, targetPath, utilsFilePath, libDir);
|
|
936
|
+
const rewrittenContent = rewriteTemplateImports(templateContent, targetPath, utilsFilePath, libDir, compilerPathConfig);
|
|
908
937
|
await fs3.writeFile(targetPath, rewrittenContent);
|
|
909
938
|
allFilesAdded.push({ name: file.name, path: targetPath });
|
|
910
939
|
}
|
|
911
940
|
if (comp.dependencies?.length) {
|
|
912
941
|
allDepsInstalled.push(...comp.dependencies);
|
|
913
942
|
}
|
|
943
|
+
if (name === "toast") {
|
|
944
|
+
const toastLibPath = path3.join(libDir, "toast.ts");
|
|
945
|
+
if (!fs3.existsSync(toastLibPath)) {
|
|
946
|
+
const toastContent = `import { createToastManager } from "${config.aliases.ui}/toast";
|
|
947
|
+
export const toastManager = createToastManager();
|
|
948
|
+
`;
|
|
949
|
+
await fs3.writeFile(toastLibPath, toastContent);
|
|
950
|
+
allFilesAdded.push({ name: "toast.ts", path: toastLibPath });
|
|
951
|
+
}
|
|
952
|
+
}
|
|
914
953
|
}
|
|
915
954
|
spinner.text = "Updating Tailwind configuration...";
|
|
916
955
|
const tailwindMajor = detectTailwindMajorVersion(projectRoot);
|
|
956
|
+
if (tailwindMajor >= 4) {
|
|
957
|
+
const idx = allDepsInstalled.indexOf("tailwindcss-animate");
|
|
958
|
+
if (idx !== -1) {
|
|
959
|
+
allDepsInstalled[idx] = "tw-animate-css";
|
|
960
|
+
}
|
|
961
|
+
for (let i = 0; i < allDepsInstalled.length; i++) {
|
|
962
|
+
if (allDepsInstalled[i] === "tailwindcss-animate") {
|
|
963
|
+
allDepsInstalled[i] = "tw-animate-css";
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
917
967
|
const tailwindConfigInfo = tailwindMajor >= 4 ? await ensureTW4Plugin(
|
|
918
968
|
allDepsInstalled,
|
|
919
969
|
path3.resolve(projectRoot, config.tailwind?.css || "src/index.css")
|
|
@@ -953,14 +1003,15 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
953
1003
|
console.log(` ${chalk.green("+")} ${file.path}`);
|
|
954
1004
|
});
|
|
955
1005
|
if (tailwindConfigInfo) {
|
|
1006
|
+
const animatePackage = tailwindMajor >= 4 ? "tw-animate-css" : "tailwindcss-animate";
|
|
956
1007
|
console.log();
|
|
957
1008
|
if (tailwindConfigInfo.created) {
|
|
958
|
-
console.log(` ${chalk.green("+")} ${tailwindConfigInfo.path} (created with
|
|
1009
|
+
console.log(` ${chalk.green("+")} ${tailwindConfigInfo.path} (created with ${animatePackage} plugin)`);
|
|
959
1010
|
} else if (tailwindConfigInfo.updated) {
|
|
960
|
-
console.log(` ${chalk.blue("~")} ${tailwindConfigInfo.path} (updated with
|
|
1011
|
+
console.log(` ${chalk.blue("~")} ${tailwindConfigInfo.path} (updated with ${animatePackage} plugin)`);
|
|
961
1012
|
} else if (tailwindConfigInfo.skipped) {
|
|
962
1013
|
console.log(
|
|
963
|
-
` ${chalk.yellow("!")} ${tailwindConfigInfo.path} (could not safely update automatically; add
|
|
1014
|
+
` ${chalk.yellow("!")} ${tailwindConfigInfo.path} (could not safely update automatically; add ${animatePackage} manually)`
|
|
964
1015
|
);
|
|
965
1016
|
}
|
|
966
1017
|
}
|
|
@@ -1058,6 +1109,10 @@ function getThemeCSS(tailwindMajor, mode, preservedThemeVars = []) {
|
|
|
1058
1109
|
--accent-foreground: oklch(0.1459 0.0497 142.4953);
|
|
1059
1110
|
--destructive: oklch(0.5248 0.1368 20.8317);
|
|
1060
1111
|
--destructive-foreground: oklch(1 0 0);
|
|
1112
|
+
--success: oklch(0.5882 0.1655 145.39);
|
|
1113
|
+
--success-foreground: oklch(1 0 0);
|
|
1114
|
+
--warning: oklch(0.6365 0.1639 55.49);
|
|
1115
|
+
--warning-foreground: oklch(1 0 0);
|
|
1061
1116
|
--border: oklch(0.9239 0.0017 145.5613);
|
|
1062
1117
|
--input: oklch(0.8481 0.0105 145.4823);
|
|
1063
1118
|
--ring: oklch(0.1459 0.0497 142.4953);
|
|
@@ -1080,6 +1135,10 @@ function getThemeCSS(tailwindMajor, mode, preservedThemeVars = []) {
|
|
|
1080
1135
|
--accent-foreground: oklch(0.9742 0.0101 131.3574);
|
|
1081
1136
|
--destructive: oklch(0.2258 0.0524 12.6119);
|
|
1082
1137
|
--destructive-foreground: oklch(1 0 0);
|
|
1138
|
+
--success: oklch(0.5484 0.1497 145.39);
|
|
1139
|
+
--success-foreground: oklch(1 0 0);
|
|
1140
|
+
--warning: oklch(0.5966 0.1499 55.49);
|
|
1141
|
+
--warning-foreground: oklch(1 0 0);
|
|
1083
1142
|
--border: oklch(0.1811 0.0128 129.2819);
|
|
1084
1143
|
--input: oklch(0.2213 0.0193 135.2915);
|
|
1085
1144
|
--ring: oklch(0.9248 0.0051 145.5339);
|
|
@@ -1108,6 +1167,10 @@ function getThemeCSS(tailwindMajor, mode, preservedThemeVars = []) {
|
|
|
1108
1167
|
--color-accent-foreground: var(--accent-foreground);
|
|
1109
1168
|
--color-destructive: var(--destructive);
|
|
1110
1169
|
--color-destructive-foreground: var(--destructive-foreground);
|
|
1170
|
+
--color-success: var(--success);
|
|
1171
|
+
--color-success-foreground: var(--success-foreground);
|
|
1172
|
+
--color-warning: var(--warning);
|
|
1173
|
+
--color-warning-foreground: var(--warning-foreground);
|
|
1111
1174
|
--color-border: var(--border);
|
|
1112
1175
|
--color-input: var(--input);
|
|
1113
1176
|
--color-ring: var(--ring);
|
|
@@ -1187,6 +1250,14 @@ function getTW3ColorExtend() {
|
|
|
1187
1250
|
DEFAULT: "var(--destructive)",
|
|
1188
1251
|
foreground: "var(--destructive-foreground)",
|
|
1189
1252
|
},
|
|
1253
|
+
success: {
|
|
1254
|
+
DEFAULT: "var(--success)",
|
|
1255
|
+
foreground: "var(--success-foreground)",
|
|
1256
|
+
},
|
|
1257
|
+
warning: {
|
|
1258
|
+
DEFAULT: "var(--warning)",
|
|
1259
|
+
foreground: "var(--warning-foreground)",
|
|
1260
|
+
},
|
|
1190
1261
|
muted: {
|
|
1191
1262
|
DEFAULT: "var(--muted)",
|
|
1192
1263
|
foreground: "var(--muted-foreground)",
|
|
@@ -1364,7 +1435,7 @@ async function ensureAtAlias(projectRoot, srcDir, isTypeScript) {
|
|
|
1364
1435
|
return { path: configPath, skipped: true };
|
|
1365
1436
|
}
|
|
1366
1437
|
}
|
|
1367
|
-
var initCommand = new Command2("init").description("Initialize Dinachi UI in your project").option("--skip-install", "Skip package installation").action(async (options) => {
|
|
1438
|
+
var initCommand = new Command2("init").description("Initialize Dinachi UI in your project").option("--skip-install", "Skip package installation").option("-y, --yes", "Accept all defaults without prompting").action(async (options) => {
|
|
1368
1439
|
console.log(chalk2.bold.cyan("\u{1F3A8} Welcome to Dinachi UI!"));
|
|
1369
1440
|
console.log();
|
|
1370
1441
|
const projectRoot = process.cwd();
|
|
@@ -1376,28 +1447,40 @@ var initCommand = new Command2("init").description("Initialize Dinachi UI in you
|
|
|
1376
1447
|
const projectConfig = detectProjectType();
|
|
1377
1448
|
console.log(chalk2.gray(`Detected ${projectConfig.framework} project`));
|
|
1378
1449
|
console.log();
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1450
|
+
let componentsPath;
|
|
1451
|
+
let utilsPath;
|
|
1452
|
+
if (options.yes) {
|
|
1453
|
+
componentsPath = projectConfig.componentsPath;
|
|
1454
|
+
utilsPath = projectConfig.utilsPath;
|
|
1455
|
+
console.log(chalk2.gray(`Components: ${componentsPath}`));
|
|
1456
|
+
console.log(chalk2.gray(`Utilities: ${utilsPath}`));
|
|
1457
|
+
console.log();
|
|
1458
|
+
} else {
|
|
1459
|
+
const response = await prompts2([
|
|
1460
|
+
{
|
|
1461
|
+
type: "text",
|
|
1462
|
+
name: "componentsPath",
|
|
1463
|
+
message: "Where would you like to install components?",
|
|
1464
|
+
initial: projectConfig.componentsPath
|
|
1465
|
+
},
|
|
1466
|
+
{
|
|
1467
|
+
type: "text",
|
|
1468
|
+
name: "utilsPath",
|
|
1469
|
+
message: "Where would you like to install utilities?",
|
|
1470
|
+
initial: projectConfig.utilsPath
|
|
1471
|
+
}
|
|
1472
|
+
]);
|
|
1473
|
+
if (!response.componentsPath || !response.utilsPath) {
|
|
1474
|
+
console.log(chalk2.red("\u274C Setup cancelled."));
|
|
1475
|
+
process.exit(1);
|
|
1391
1476
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
console.log(chalk2.red("\u274C Setup cancelled."));
|
|
1395
|
-
process.exit(1);
|
|
1477
|
+
componentsPath = response.componentsPath;
|
|
1478
|
+
utilsPath = response.utilsPath;
|
|
1396
1479
|
}
|
|
1397
1480
|
const spinner = ora2("Setting up Dinachi UI...").start();
|
|
1398
1481
|
try {
|
|
1399
|
-
const normalizedComponentsPath = normalizeProjectPath(
|
|
1400
|
-
const normalizedUtilsPath = normalizeProjectPath(
|
|
1482
|
+
const normalizedComponentsPath = normalizeProjectPath(componentsPath, projectRoot);
|
|
1483
|
+
const normalizedUtilsPath = normalizeProjectPath(utilsPath, projectRoot);
|
|
1401
1484
|
const componentsDirPath = path4.resolve(projectRoot, normalizedComponentsPath);
|
|
1402
1485
|
const utilsDirPath = path4.resolve(projectRoot, normalizedUtilsPath);
|
|
1403
1486
|
const utilsFilePath = path4.join(utilsDirPath, "utils.ts");
|
|
@@ -1425,7 +1508,7 @@ var initCommand = new Command2("init").description("Initialize Dinachi UI in you
|
|
|
1425
1508
|
const configContent = JSON.stringify(
|
|
1426
1509
|
{
|
|
1427
1510
|
style: "default",
|
|
1428
|
-
rsc: projectConfig.framework
|
|
1511
|
+
rsc: detectRsc(projectRoot, projectConfig.framework),
|
|
1429
1512
|
tsx: true,
|
|
1430
1513
|
tailwind: {
|
|
1431
1514
|
config: projectConfig.tailwindConfig,
|
|
@@ -1516,6 +1599,22 @@ var initCommand = new Command2("init").description("Initialize Dinachi UI in you
|
|
|
1516
1599
|
process.exit(1);
|
|
1517
1600
|
}
|
|
1518
1601
|
});
|
|
1602
|
+
function detectRsc(projectRoot, framework) {
|
|
1603
|
+
const configPath = path4.join(projectRoot, "components.json");
|
|
1604
|
+
if (fs4.existsSync(configPath)) {
|
|
1605
|
+
try {
|
|
1606
|
+
const existing = JSON.parse(fs4.readFileSync(configPath, "utf-8"));
|
|
1607
|
+
if (typeof existing.rsc === "boolean") return existing.rsc;
|
|
1608
|
+
} catch {
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
if (framework !== "next.js") return false;
|
|
1612
|
+
const hasAppRouter = fs4.existsSync(path4.join(projectRoot, "app")) || fs4.existsSync(path4.join(projectRoot, "src", "app"));
|
|
1613
|
+
const hasPagesRouter = fs4.existsSync(path4.join(projectRoot, "pages")) || fs4.existsSync(path4.join(projectRoot, "src", "pages"));
|
|
1614
|
+
if (hasAppRouter) return true;
|
|
1615
|
+
if (hasPagesRouter) return false;
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1519
1618
|
function detectProjectType() {
|
|
1520
1619
|
const packageJsonPath = path4.join(process.cwd(), "package.json");
|
|
1521
1620
|
if (!fs4.existsSync(packageJsonPath)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinachi/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "CLI for adding Dinachi UI components to your project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://dinachi.dev",
|
|
21
21
|
"bin": {
|
|
22
|
-
"dinachi": "dist/index.js"
|
|
23
|
-
"dinachi-ui": "dist/index.js"
|
|
22
|
+
"dinachi": "dist/index.js"
|
|
24
23
|
},
|
|
25
24
|
"files": [
|
|
26
25
|
"dist",
|
|
@@ -1,46 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import { AlertDialog as BaseAlertDialog } from "@base-ui/react";
|
|
3
|
-
import { cn } from "@/lib/utils";
|
|
1
|
+
"use client"
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { AlertDialog as BaseAlertDialog } from "@base-ui/react/alert-dialog"
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const AlertDialog = BaseAlertDialog.Root
|
|
8
|
+
const AlertDialogTrigger = BaseAlertDialog.Trigger
|
|
9
|
+
const AlertDialogPortal = BaseAlertDialog.Portal
|
|
10
|
+
|
|
11
|
+
const AlertDialogBackdrop = React.forwardRef<
|
|
12
|
+
HTMLDivElement,
|
|
13
|
+
React.ComponentProps<typeof BaseAlertDialog.Backdrop>
|
|
10
14
|
>(({ className, ...props }, ref) => (
|
|
11
|
-
<BaseAlertDialog.
|
|
15
|
+
<BaseAlertDialog.Backdrop
|
|
12
16
|
ref={ref}
|
|
13
17
|
className={cn(
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
18
|
-
"h-10 px-4 py-2",
|
|
18
|
+
"fixed inset-0 z-50 bg-black/80",
|
|
19
|
+
"data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",
|
|
20
|
+
"transition-all duration-150",
|
|
19
21
|
className
|
|
20
22
|
)}
|
|
21
23
|
{...props}
|
|
22
24
|
/>
|
|
23
|
-
))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const AlertDialogPortal = BaseAlertDialog.Portal;
|
|
25
|
+
))
|
|
26
|
+
AlertDialogBackdrop.displayName = "AlertDialogBackdrop"
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const AlertDialogViewport = React.forwardRef<
|
|
29
29
|
HTMLDivElement,
|
|
30
|
-
React.ComponentProps<typeof BaseAlertDialog.
|
|
30
|
+
React.ComponentProps<typeof BaseAlertDialog.Viewport>
|
|
31
31
|
>(({ className, ...props }, ref) => (
|
|
32
|
-
<BaseAlertDialog.
|
|
32
|
+
<BaseAlertDialog.Viewport
|
|
33
33
|
ref={ref}
|
|
34
34
|
className={cn(
|
|
35
|
-
"fixed inset-0 z-50
|
|
36
|
-
"data-starting-style:opacity-0 data-ending-style:opacity-0",
|
|
37
|
-
"transition-all duration-150",
|
|
35
|
+
"fixed inset-0 z-50 flex items-center justify-center overflow-auto",
|
|
38
36
|
className
|
|
39
37
|
)}
|
|
40
38
|
{...props}
|
|
41
39
|
/>
|
|
42
|
-
))
|
|
43
|
-
|
|
40
|
+
))
|
|
41
|
+
AlertDialogViewport.displayName = "AlertDialogViewport"
|
|
44
42
|
|
|
45
43
|
const AlertDialogPopup = React.forwardRef<
|
|
46
44
|
HTMLDivElement,
|
|
@@ -49,16 +47,16 @@ const AlertDialogPopup = React.forwardRef<
|
|
|
49
47
|
<BaseAlertDialog.Popup
|
|
50
48
|
ref={ref}
|
|
51
49
|
className={cn(
|
|
52
|
-
"
|
|
53
|
-
"data-starting-style:scale-95 data-starting-style:opacity-0",
|
|
54
|
-
"data-ending-style:scale-95 data-ending-style:opacity-0",
|
|
50
|
+
"w-[95%] max-w-lg gap-4 rounded-lg border bg-background p-6 shadow-lg",
|
|
51
|
+
"data-[starting-style]:scale-95 data-[starting-style]:opacity-0",
|
|
52
|
+
"data-[ending-style]:scale-95 data-[ending-style]:opacity-0",
|
|
55
53
|
"transition-all duration-150",
|
|
56
54
|
className
|
|
57
55
|
)}
|
|
58
56
|
{...props}
|
|
59
57
|
/>
|
|
60
|
-
))
|
|
61
|
-
AlertDialogPopup.displayName = "AlertDialogPopup"
|
|
58
|
+
))
|
|
59
|
+
AlertDialogPopup.displayName = "AlertDialogPopup"
|
|
62
60
|
|
|
63
61
|
const AlertDialogTitle = React.forwardRef<
|
|
64
62
|
HTMLHeadingElement,
|
|
@@ -66,11 +64,11 @@ const AlertDialogTitle = React.forwardRef<
|
|
|
66
64
|
>(({ className, ...props }, ref) => (
|
|
67
65
|
<BaseAlertDialog.Title
|
|
68
66
|
ref={ref}
|
|
69
|
-
className={cn("text-lg font-
|
|
67
|
+
className={cn("text-lg font-medium leading-none tracking-tight", className)}
|
|
70
68
|
{...props}
|
|
71
69
|
/>
|
|
72
|
-
))
|
|
73
|
-
AlertDialogTitle.displayName = "AlertDialogTitle"
|
|
70
|
+
))
|
|
71
|
+
AlertDialogTitle.displayName = "AlertDialogTitle"
|
|
74
72
|
|
|
75
73
|
const AlertDialogDescription = React.forwardRef<
|
|
76
74
|
HTMLParagraphElement,
|
|
@@ -81,8 +79,8 @@ const AlertDialogDescription = React.forwardRef<
|
|
|
81
79
|
className={cn("text-sm text-muted-foreground", className)}
|
|
82
80
|
{...props}
|
|
83
81
|
/>
|
|
84
|
-
))
|
|
85
|
-
AlertDialogDescription.displayName = "AlertDialogDescription"
|
|
82
|
+
))
|
|
83
|
+
AlertDialogDescription.displayName = "AlertDialogDescription"
|
|
86
84
|
|
|
87
85
|
const AlertDialogAction = React.forwardRef<
|
|
88
86
|
HTMLButtonElement,
|
|
@@ -91,15 +89,15 @@ const AlertDialogAction = React.forwardRef<
|
|
|
91
89
|
<BaseAlertDialog.Close
|
|
92
90
|
ref={ref}
|
|
93
91
|
className={cn(
|
|
94
|
-
"inline-flex h-10 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-
|
|
92
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors",
|
|
95
93
|
"hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
96
94
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
97
95
|
className
|
|
98
96
|
)}
|
|
99
97
|
{...props}
|
|
100
98
|
/>
|
|
101
|
-
))
|
|
102
|
-
AlertDialogAction.displayName = "AlertDialogAction"
|
|
99
|
+
))
|
|
100
|
+
AlertDialogAction.displayName = "AlertDialogAction"
|
|
103
101
|
|
|
104
102
|
const AlertDialogCancel = React.forwardRef<
|
|
105
103
|
HTMLButtonElement,
|
|
@@ -108,15 +106,15 @@ const AlertDialogCancel = React.forwardRef<
|
|
|
108
106
|
<BaseAlertDialog.Close
|
|
109
107
|
ref={ref}
|
|
110
108
|
className={cn(
|
|
111
|
-
"inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-
|
|
109
|
+
"inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors",
|
|
112
110
|
"hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
113
111
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
114
112
|
className
|
|
115
113
|
)}
|
|
116
114
|
{...props}
|
|
117
115
|
/>
|
|
118
|
-
))
|
|
119
|
-
AlertDialogCancel.displayName = "AlertDialogCancel"
|
|
116
|
+
))
|
|
117
|
+
AlertDialogCancel.displayName = "AlertDialogCancel"
|
|
120
118
|
|
|
121
119
|
const AlertDialogHeader = ({
|
|
122
120
|
className,
|
|
@@ -129,8 +127,8 @@ const AlertDialogHeader = ({
|
|
|
129
127
|
)}
|
|
130
128
|
{...props}
|
|
131
129
|
/>
|
|
132
|
-
)
|
|
133
|
-
AlertDialogHeader.displayName = "AlertDialogHeader"
|
|
130
|
+
)
|
|
131
|
+
AlertDialogHeader.displayName = "AlertDialogHeader"
|
|
134
132
|
|
|
135
133
|
const AlertDialogFooter = ({
|
|
136
134
|
className,
|
|
@@ -138,19 +136,35 @@ const AlertDialogFooter = ({
|
|
|
138
136
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
139
137
|
<div
|
|
140
138
|
className={cn(
|
|
141
|
-
"flex flex-col-reverse sm:flex-row sm:justify-end
|
|
139
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-1.5",
|
|
142
140
|
className
|
|
143
141
|
)}
|
|
144
142
|
{...props}
|
|
145
143
|
/>
|
|
146
|
-
)
|
|
147
|
-
AlertDialogFooter.displayName = "AlertDialogFooter"
|
|
144
|
+
)
|
|
145
|
+
AlertDialogFooter.displayName = "AlertDialogFooter"
|
|
146
|
+
|
|
147
|
+
const AlertDialogContent = React.forwardRef<
|
|
148
|
+
HTMLDivElement,
|
|
149
|
+
React.ComponentProps<typeof BaseAlertDialog.Popup>
|
|
150
|
+
>(({ className, children, ...props }, ref) => (
|
|
151
|
+
<AlertDialogPortal>
|
|
152
|
+
<AlertDialogBackdrop />
|
|
153
|
+
<AlertDialogViewport>
|
|
154
|
+
<AlertDialogPopup ref={ref} className={className} {...props}>
|
|
155
|
+
{children}
|
|
156
|
+
</AlertDialogPopup>
|
|
157
|
+
</AlertDialogViewport>
|
|
158
|
+
</AlertDialogPortal>
|
|
159
|
+
))
|
|
160
|
+
AlertDialogContent.displayName = "AlertDialogContent"
|
|
148
161
|
|
|
149
162
|
export {
|
|
150
163
|
AlertDialog,
|
|
151
164
|
AlertDialogTrigger,
|
|
152
165
|
AlertDialogPortal,
|
|
153
166
|
AlertDialogBackdrop,
|
|
167
|
+
AlertDialogViewport,
|
|
154
168
|
AlertDialogPopup,
|
|
155
169
|
AlertDialogTitle,
|
|
156
170
|
AlertDialogDescription,
|
|
@@ -158,4 +172,5 @@ export {
|
|
|
158
172
|
AlertDialogCancel,
|
|
159
173
|
AlertDialogHeader,
|
|
160
174
|
AlertDialogFooter,
|
|
161
|
-
|
|
175
|
+
AlertDialogContent,
|
|
176
|
+
}
|
|
@@ -17,9 +17,9 @@ const AutocompleteInput = React.forwardRef<
|
|
|
17
17
|
<AutocompletePrimitive.Input
|
|
18
18
|
ref={ref}
|
|
19
19
|
className={cn(
|
|
20
|
-
"flex h-10 w-full
|
|
20
|
+
"flex h-10 w-full bg-transparent px-3 py-2 text-sm",
|
|
21
21
|
"placeholder:text-muted-foreground",
|
|
22
|
-
"focus:outline-none
|
|
22
|
+
"focus:outline-none",
|
|
23
23
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
24
24
|
className
|
|
25
25
|
)}
|
|
@@ -35,8 +35,8 @@ const AutocompleteTrigger = React.forwardRef<
|
|
|
35
35
|
<AutocompletePrimitive.Trigger
|
|
36
36
|
ref={ref}
|
|
37
37
|
className={cn(
|
|
38
|
-
"inline-flex h-10 items-center justify-center
|
|
39
|
-
"focus-visible:outline-none
|
|
38
|
+
"inline-flex h-10 items-center justify-center px-3",
|
|
39
|
+
"focus-visible:outline-none",
|
|
40
40
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
41
41
|
className
|
|
42
42
|
)}
|
|
@@ -80,7 +80,7 @@ const AutocompleteContent = React.forwardRef<
|
|
|
80
80
|
<AutocompletePrimitive.Popup
|
|
81
81
|
ref={ref}
|
|
82
82
|
className={cn(
|
|
83
|
-
"relative z-50 min-w-
|
|
83
|
+
"relative z-50 min-w-(--anchor-width) overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
84
84
|
"origin-(--transform-origin) outline-none",
|
|
85
85
|
"data-starting-style:animate-in data-starting-style:fade-in-0 data-starting-style:zoom-in-95",
|
|
86
86
|
"data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95",
|
|
@@ -118,8 +118,8 @@ const AutocompleteItem = React.forwardRef<
|
|
|
118
118
|
<AutocompletePrimitive.Item
|
|
119
119
|
ref={ref}
|
|
120
120
|
className={cn(
|
|
121
|
-
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
122
|
-
"data-highlighted:bg-accent data-highlighted:text-accent-foreground",
|
|
121
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm lg:text-base outline-none",
|
|
122
|
+
"data-highlighted:bg-accent font-normal data-highlighted:text-accent-foreground",
|
|
123
123
|
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
124
124
|
inset && "pl-8",
|
|
125
125
|
className
|