7onic 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.
- package/dist/index.js +72 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1198,7 +1198,7 @@ function installDeps(deps, options) {
|
|
|
1198
1198
|
const commands = {
|
|
1199
1199
|
npm: `npm install${devFlag} ${deps.join(" ")}`,
|
|
1200
1200
|
pnpm: `pnpm add${devFlag} ${deps.join(" ")}`,
|
|
1201
|
-
yarn: `yarn add${devFlag} ${deps.join(" ")}`,
|
|
1201
|
+
yarn: `yarn add --ignore-engines${devFlag} ${deps.join(" ")}`,
|
|
1202
1202
|
bun: `bun add${devFlag} ${deps.join(" ")}`
|
|
1203
1203
|
};
|
|
1204
1204
|
(0, import_node_child_process.execSync)(commands[pm], { cwd, stdio: "pipe" });
|
|
@@ -1246,7 +1246,11 @@ var CSS_V3_IMPORTS = `@import '@7onic-ui/tokens/css/variables.css';
|
|
|
1246
1246
|
@import '@7onic-ui/tokens/css/themes/light.css';
|
|
1247
1247
|
@import '@7onic-ui/tokens/css/themes/dark.css';
|
|
1248
1248
|
`;
|
|
1249
|
-
var CSS_V4_IMPORTS = `@import
|
|
1249
|
+
var CSS_V4_IMPORTS = `@import "tailwindcss";
|
|
1250
|
+
@import '@7onic-ui/tokens/css/variables.css';
|
|
1251
|
+
@import '@7onic-ui/tokens/tailwind/v4.css';
|
|
1252
|
+
`;
|
|
1253
|
+
var CSS_V4_TOKEN_ONLY = `@import '@7onic-ui/tokens/css/variables.css';
|
|
1250
1254
|
@import '@7onic-ui/tokens/tailwind/v4.css';
|
|
1251
1255
|
`;
|
|
1252
1256
|
async function init(args) {
|
|
@@ -1281,14 +1285,20 @@ async function init(args) {
|
|
|
1281
1285
|
const tw = detectTailwindVersion(projectRoot);
|
|
1282
1286
|
const pm = detectPackageManager(projectRoot);
|
|
1283
1287
|
let hasPathAlias = false;
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
+
const TSCONFIG_CANDIDATES = ["tsconfig.json", "tsconfig.app.json"];
|
|
1289
|
+
for (const tc of TSCONFIG_CANDIDATES) {
|
|
1290
|
+
try {
|
|
1291
|
+
const raw = import_node_fs4.default.readFileSync(import_node_path4.default.join(projectRoot, tc), "utf-8");
|
|
1292
|
+
if (raw.includes('"@/')) {
|
|
1293
|
+
hasPathAlias = true;
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
} catch {
|
|
1297
|
+
}
|
|
1288
1298
|
}
|
|
1289
1299
|
if (!hasPathAlias) {
|
|
1290
1300
|
O2.warn(
|
|
1291
|
-
|
|
1301
|
+
'No @/ path alias detected in tsconfig.\n Components use @/lib/utils \u2014 make sure your project has path aliases configured.\n Next.js: automatic (no action needed)\n Vite: add to both files:\n\n // tsconfig.app.json \u2192 "compilerOptions.paths"\n { "@/*": ["./src/*"] }\n\n // vite.config.ts \u2192 "resolve.alias"\n { "@": path.resolve(__dirname, "./src") }'
|
|
1292
1302
|
);
|
|
1293
1303
|
}
|
|
1294
1304
|
try {
|
|
@@ -1360,18 +1370,30 @@ async function init(args) {
|
|
|
1360
1370
|
process.exit(1);
|
|
1361
1371
|
}
|
|
1362
1372
|
const cssFullPath = import_node_path4.default.join(projectRoot, config.cssPath);
|
|
1363
|
-
const cssImports = tailwindVersion === 3 ? CSS_V3_IMPORTS : CSS_V4_IMPORTS;
|
|
1364
1373
|
if (!import_node_fs4.default.existsSync(cssFullPath)) {
|
|
1365
1374
|
const cssDir = import_node_path4.default.dirname(cssFullPath);
|
|
1366
1375
|
if (!import_node_fs4.default.existsSync(cssDir)) {
|
|
1367
1376
|
import_node_fs4.default.mkdirSync(cssDir, { recursive: true });
|
|
1368
1377
|
}
|
|
1378
|
+
const cssImports = tailwindVersion === 3 ? CSS_V3_IMPORTS : CSS_V4_IMPORTS;
|
|
1369
1379
|
import_node_fs4.default.writeFileSync(cssFullPath, cssImports, "utf-8");
|
|
1370
1380
|
O2.success(`Created ${config.cssPath} with token imports`);
|
|
1371
1381
|
} else {
|
|
1372
1382
|
const cssContent = import_node_fs4.default.readFileSync(cssFullPath, "utf-8");
|
|
1373
1383
|
if (!cssContent.includes("@7onic-ui/tokens")) {
|
|
1374
|
-
|
|
1384
|
+
const tokenImports = tailwindVersion === 3 ? CSS_V3_IMPORTS : CSS_V4_TOKEN_ONLY;
|
|
1385
|
+
if (tailwindVersion === 4) {
|
|
1386
|
+
const twMatch = cssContent.match(/@import\s+["']tailwindcss["'].*\n/);
|
|
1387
|
+
if (twMatch) {
|
|
1388
|
+
const insertAt = twMatch.index + twMatch[0].length;
|
|
1389
|
+
const updated = cssContent.slice(0, insertAt) + tokenImports + cssContent.slice(insertAt);
|
|
1390
|
+
import_node_fs4.default.writeFileSync(cssFullPath, updated, "utf-8");
|
|
1391
|
+
} else {
|
|
1392
|
+
import_node_fs4.default.writeFileSync(cssFullPath, CSS_V4_IMPORTS + "\n" + cssContent, "utf-8");
|
|
1393
|
+
}
|
|
1394
|
+
} else {
|
|
1395
|
+
import_node_fs4.default.writeFileSync(cssFullPath, tokenImports + "\n" + cssContent, "utf-8");
|
|
1396
|
+
}
|
|
1375
1397
|
O2.success(`Added token imports to ${config.cssPath}`);
|
|
1376
1398
|
} else {
|
|
1377
1399
|
O2.info(`Token imports already present in ${config.cssPath}`);
|
|
@@ -3223,12 +3245,6 @@ const CardRoot = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
3223
3245
|
CardRoot.displayName = 'Card'
|
|
3224
3246
|
|
|
3225
3247
|
// \u2500\u2500 Size-based padding map (responsive: mobile \u2192 desktop) \u2500\u2500
|
|
3226
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3227
|
-
const sizePaddingMap = {
|
|
3228
|
-
sm: 'p-4', // 16px
|
|
3229
|
-
default: 'p-4 sm:p-6', // 16px \u2192 24px
|
|
3230
|
-
lg: 'p-6 sm:p-8', // 24px \u2192 32px
|
|
3231
|
-
} as const
|
|
3232
3248
|
|
|
3233
3249
|
const sizePaddingXMap = {
|
|
3234
3250
|
sm: 'px-4', // 16px
|
|
@@ -8780,8 +8796,9 @@ const PaginationRoot = React.forwardRef<HTMLElement, PaginationProps>(
|
|
|
8780
8796
|
color = 'default',
|
|
8781
8797
|
radius = 'md',
|
|
8782
8798
|
disabled = false,
|
|
8783
|
-
|
|
8784
|
-
|
|
8799
|
+
// Pre-declared API; conditional auto-rendering is tracked in COMPONENT-IMPROVEMENTS.md.
|
|
8800
|
+
withControls: _withControls = true,
|
|
8801
|
+
withEdges: _withEdges = false,
|
|
8785
8802
|
loop = false,
|
|
8786
8803
|
children,
|
|
8787
8804
|
...props
|
|
@@ -13028,7 +13045,6 @@ const ToastItem = React.memo(function ToastItem({
|
|
|
13028
13045
|
}: ToastItemProps) {
|
|
13029
13046
|
const [isExiting, setIsExiting] = React.useState(false)
|
|
13030
13047
|
const [isEntered, setIsEntered] = React.useState(false)
|
|
13031
|
-
const [isPaused, setIsPaused] = React.useState(false) // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13032
13048
|
const timerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
13033
13049
|
const remainingRef = React.useRef<number>(0)
|
|
13034
13050
|
const startTimeRef = React.useRef<number>(0)
|
|
@@ -13095,10 +13111,9 @@ const ToastItem = React.memo(function ToastItem({
|
|
|
13095
13111
|
}
|
|
13096
13112
|
}, [duration, handleAutoClose])
|
|
13097
13113
|
|
|
13098
|
-
// Pause/resume on hover
|
|
13114
|
+
// Pause/resume on hover (ref-only \u2014 no state update needed, avoids unnecessary re-renders)
|
|
13099
13115
|
const handleMouseEnter = React.useCallback(() => {
|
|
13100
13116
|
if (duration <= 0) return
|
|
13101
|
-
setIsPaused(true)
|
|
13102
13117
|
if (timerRef.current) {
|
|
13103
13118
|
clearTimeout(timerRef.current)
|
|
13104
13119
|
remainingRef.current -= Date.now() - startTimeRef.current
|
|
@@ -13107,7 +13122,6 @@ const ToastItem = React.memo(function ToastItem({
|
|
|
13107
13122
|
|
|
13108
13123
|
const handleMouseLeave = React.useCallback(() => {
|
|
13109
13124
|
if (duration <= 0) return
|
|
13110
|
-
setIsPaused(false)
|
|
13111
13125
|
startTimeRef.current = Date.now()
|
|
13112
13126
|
timerRef.current = setTimeout(handleAutoClose, Math.max(remainingRef.current, TOAST_MIN_RESUME_MS))
|
|
13113
13127
|
}, [duration, handleAutoClose])
|
|
@@ -14255,6 +14269,42 @@ async function add(args) {
|
|
|
14255
14269
|
addedCount++;
|
|
14256
14270
|
logger.success(`${entry.exists ? "Overwrote" : "Added"} ${entry.fileName}`);
|
|
14257
14271
|
}
|
|
14272
|
+
if (config.tailwind.version === 4 && addedCount > 0) {
|
|
14273
|
+
try {
|
|
14274
|
+
const cssFullPath = import_node_path5.default.join(projectRoot, config.tailwind.css);
|
|
14275
|
+
if (import_node_fs5.default.existsSync(cssFullPath)) {
|
|
14276
|
+
const cssContent = import_node_fs5.default.readFileSync(cssFullPath, "utf-8");
|
|
14277
|
+
const cssDir = import_node_path5.default.dirname(cssFullPath);
|
|
14278
|
+
const relRaw = import_node_path5.default.relative(cssDir, componentsDir).replace(/\\/g, "/");
|
|
14279
|
+
const relSource = relRaw.startsWith(".") ? relRaw : `./${relRaw}`;
|
|
14280
|
+
const sourcePattern = new RegExp(`@source\\s+["']${relSource.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']`);
|
|
14281
|
+
if (!sourcePattern.test(cssContent)) {
|
|
14282
|
+
const marker = "@7onic-ui/tokens";
|
|
14283
|
+
const lastIdx = cssContent.lastIndexOf(marker);
|
|
14284
|
+
if (lastIdx !== -1) {
|
|
14285
|
+
const lineEnd = cssContent.indexOf("\n", lastIdx);
|
|
14286
|
+
const insertAt = lineEnd !== -1 ? lineEnd + 1 : cssContent.length;
|
|
14287
|
+
const updated = cssContent.slice(0, insertAt) + `@source "${relSource}";
|
|
14288
|
+
` + cssContent.slice(insertAt);
|
|
14289
|
+
import_node_fs5.default.writeFileSync(cssFullPath, updated, "utf-8");
|
|
14290
|
+
O2.success(`Added @source "${relSource}" to ${config.tailwind.css}`);
|
|
14291
|
+
} else {
|
|
14292
|
+
O2.warn(
|
|
14293
|
+
`Could not find @7onic-ui/tokens import in ${config.tailwind.css}.
|
|
14294
|
+
Run ${import_picocolors3.default.cyan("npx 7onic init")} first, or manually add to your CSS:
|
|
14295
|
+
|
|
14296
|
+
@source "${relSource}";`
|
|
14297
|
+
);
|
|
14298
|
+
}
|
|
14299
|
+
}
|
|
14300
|
+
}
|
|
14301
|
+
} catch (err) {
|
|
14302
|
+
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
|
|
14303
|
+
} else {
|
|
14304
|
+
O2.warn(`Failed to inject @source into ${config.tailwind.css}: ${err}`);
|
|
14305
|
+
}
|
|
14306
|
+
}
|
|
14307
|
+
}
|
|
14258
14308
|
if (depsToInstall.length > 0) {
|
|
14259
14309
|
const pm = detectPackageManager(projectRoot);
|
|
14260
14310
|
const s = fe();
|
|
@@ -14368,7 +14418,7 @@ function showSetupHints(names) {
|
|
|
14368
14418
|
|
|
14369
14419
|
// cli/src/index.ts
|
|
14370
14420
|
var import_picocolors4 = __toESM(require_picocolors());
|
|
14371
|
-
var VERSION = "0.1.
|
|
14421
|
+
var VERSION = "0.1.5";
|
|
14372
14422
|
var HELP = `
|
|
14373
14423
|
${import_picocolors4.default.bold("7onic")} \u2014 Add 7onic design system components to your project
|
|
14374
14424
|
|