@nextworks/blocks-core 0.1.0-alpha.0 → 0.1.0-alpha.11

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.
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  export default function AppProviders({ children, }: Readonly<{
2
3
  children: React.ReactNode;
3
4
  }>): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -1 +1 @@
1
- {"version":3,"file":"AppProviders.server.d.ts","sourceRoot":"","sources":["../../src/components/AppProviders.server.tsx"],"names":[],"mappings":"AAwDA,wBAA8B,YAAY,CAAC,EACzC,QAAQ,GACT,EAAE,QAAQ,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,oDA0CzC"}
1
+ {"version":3,"file":"AppProviders.server.d.ts","sourceRoot":"","sources":["../../src/components/AppProviders.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,wBAA8B,YAAY,CAAC,EACzC,QAAQ,GACT,EAAE,QAAQ,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,oDAazC"}
@@ -1,60 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Geist, Geist_Mono, Outfit, Inter, Poppins } from "next/font/google";
3
- import { EnhancedThemeProvider } from "./enhanced-theme-provider";
4
- import { cookies } from "next/headers";
5
- import { themes, darkThemes, } from "../lib/themes";
6
- const geistSans = Geist({
7
- variable: "--font-geist-sans",
8
- subsets: ["latin"],
9
- });
10
- const geistMono = Geist_Mono({
11
- variable: "--font-geist-mono",
12
- subsets: ["latin"],
13
- });
14
- const outfit = Outfit({
15
- variable: "--font-outfit",
16
- subsets: ["latin"],
17
- });
18
- const inter = Inter({
19
- variable: "--font-inter",
20
- subsets: ["latin"],
21
- });
22
- const poppins = Poppins({
23
- variable: "--font-poppins",
24
- subsets: ["latin"],
25
- weight: ["100", "200", "300", "400", "500", "600", "700", "800", "900"],
26
- });
27
- function toCssVars(colors) {
28
- return Object.entries(colors)
29
- .map(([key, value]) => `--${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value};`)
30
- .join("");
31
- }
32
- function safeParseCustomTokens(value) {
33
- if (!value)
34
- return null;
35
- try {
36
- return JSON.parse(decodeURIComponent(value));
37
- }
38
- catch (_a) {
39
- return null;
40
- }
41
- }
2
+ import { BlocksAppProviders } from "../providers/BlocksAppProviders";
3
+ import { getInitialThemeFromCookies } from "../server/theme-vars";
42
4
  export default async function AppProviders({ children, }) {
43
- var _a, _b;
44
- // Read cookies for SSR: chosen variant and optional custom tokens
45
- const cookieStore = await cookies();
46
- const cookieVariant = (_a = cookieStore.get("theme-variant")) === null || _a === void 0 ? void 0 : _a.value;
47
- const variant = cookieVariant && cookieVariant in themes ? cookieVariant : "default";
48
- const cookieCustom = variant === "custom"
49
- ? safeParseCustomTokens((_b = cookieStore.get("theme-custom")) === null || _b === void 0 ? void 0 : _b.value)
50
- : null;
51
- const baseLight = themes[variant].colors;
52
- const baseDark = darkThemes[variant].colors;
53
- const lightMerged = cookieCustom
54
- ? Object.assign(Object.assign({}, baseLight), cookieCustom) : baseLight;
55
- const darkMerged = cookieCustom ? Object.assign(Object.assign({}, baseDark), cookieCustom) : baseDark;
56
- const lightVars = toCssVars(lightMerged);
57
- const darkVars = toCssVars(darkMerged);
58
- const inlineThemeCss = `:root{${lightVars}}.dark{${darkVars}}`;
59
- return (_jsxs(_Fragment, { children: [_jsx("style", { id: "theme-variant-vars", dangerouslySetInnerHTML: { __html: inlineThemeCss } }), _jsx("div", { className: `${geistSans.variable} ${geistMono.variable} ${outfit.variable} ${inter.variable} ${poppins.variable} antialiased`, children: _jsx(EnhancedThemeProvider, { defaultThemeVariant: variant, children: children }) })] }));
5
+ const { variant, styleTag } = await getInitialThemeFromCookies();
6
+ return (_jsxs(_Fragment, { children: [styleTag, _jsx("div", { className: "antialiased", children: _jsx(BlocksAppProviders, { defaultThemeVariant: variant, children: children }) })] }));
60
7
  }
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./lib/themes";
4
4
  export * from "./lib/utils";
5
5
  export * from "./components/enhanced-theme-provider";
6
6
  export * from "./components/theme-provider";
7
+ export * from "./providers/BlocksAppProviders";
7
8
  export * from "./ui/alert-dialog";
8
9
  export * from "./ui/brand-node";
9
10
  export * from "./ui/button";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAG5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAG5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAG5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAG5C,cAAc,gCAAgC,CAAC;AAG/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
- // Public exports for @nextworks/blocks-core
2
- // NOTE: This entry is safe for client and server usage. Server-only
3
- // components like AppProviders are exported from a separate entry.
4
1
  // Theme data & utilities
5
2
  export * from "./lib/themes";
6
3
  export * from "./lib/utils";
7
4
  // Client-safe providers/hooks
8
5
  export * from "./components/enhanced-theme-provider";
9
6
  export * from "./components/theme-provider";
7
+ // Provider composition (no next/* imports)
8
+ export * from "./providers/BlocksAppProviders";
10
9
  // UI primitives
11
10
  export * from "./ui/alert-dialog";
12
11
  export * from "./ui/brand-node";
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import type { ThemeVariant } from "../lib/themes";
3
+ export type BlocksAppProvidersProps = {
4
+ children: React.ReactNode;
5
+ defaultThemeVariant?: ThemeVariant;
6
+ };
7
+ /**
8
+ * Client-safe provider wrapper for Nextworks blocks.
9
+ *
10
+ * This file intentionally contains no next/* imports.
11
+ */
12
+ export declare function BlocksAppProviders({ children, defaultThemeVariant, }: BlocksAppProvidersProps): import("react/jsx-runtime").JSX.Element;
13
+ //# sourceMappingURL=BlocksAppProviders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlocksAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/BlocksAppProviders.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,mBAAmB,CAAC,EAAE,YAAY,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,mBAAkC,GACnC,EAAE,uBAAuB,2CAMzB"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { EnhancedThemeProvider } from "../components/enhanced-theme-provider";
4
+ /**
5
+ * Client-safe provider wrapper for Nextworks blocks.
6
+ *
7
+ * This file intentionally contains no next/* imports.
8
+ */
9
+ export function BlocksAppProviders({ children, defaultThemeVariant = "monochrome", }) {
10
+ return (_jsx(EnhancedThemeProvider, { defaultThemeVariant: defaultThemeVariant, children: children }));
11
+ }
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { type ThemeVariant } from "../lib/themes";
3
+ /**
4
+ * Server-only: reads cookies and returns initial theme variant + a <style> tag
5
+ * that sets CSS variables for :root and .dark.
6
+ *
7
+ * No next/font usage here (Turbopack-safe).
8
+ */
9
+ export declare function getInitialThemeFromCookies(): Promise<{
10
+ variant: ThemeVariant;
11
+ styleTag: React.ReactElement;
12
+ }>;
13
+ //# sourceMappingURL=theme-vars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-vars.d.ts","sourceRoot":"","sources":["../../src/server/theme-vars.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,eAAe,CAAC;AAsBvB;;;;;GAKG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC;IAC1D,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;CAC9B,CAAC,CAiCD"}
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cookies } from "next/headers";
3
+ import { themes, darkThemes, } from "../lib/themes";
4
+ function toCssVars(colors) {
5
+ return Object.entries(colors)
6
+ .map(([key, value]) => `--${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value};`)
7
+ .join("");
8
+ }
9
+ function safeParseCustomTokens(value) {
10
+ if (!value)
11
+ return null;
12
+ try {
13
+ return JSON.parse(decodeURIComponent(value));
14
+ }
15
+ catch (_a) {
16
+ return null;
17
+ }
18
+ }
19
+ /**
20
+ * Server-only: reads cookies and returns initial theme variant + a <style> tag
21
+ * that sets CSS variables for :root and .dark.
22
+ *
23
+ * No next/font usage here (Turbopack-safe).
24
+ */
25
+ export async function getInitialThemeFromCookies() {
26
+ var _a, _b;
27
+ const cookieStore = await cookies();
28
+ const cookieVariant = (_a = cookieStore.get("theme-variant")) === null || _a === void 0 ? void 0 : _a.value;
29
+ const variant = cookieVariant && cookieVariant in themes ? cookieVariant : "default";
30
+ const cookieCustom = variant === "custom"
31
+ ? safeParseCustomTokens((_b = cookieStore.get("theme-custom")) === null || _b === void 0 ? void 0 : _b.value)
32
+ : null;
33
+ const baseLight = themes[variant].colors;
34
+ const baseDark = darkThemes[variant].colors;
35
+ const lightMerged = cookieCustom ? Object.assign(Object.assign({}, baseLight), cookieCustom) : baseLight;
36
+ const darkMerged = cookieCustom ? Object.assign(Object.assign({}, baseDark), cookieCustom) : baseDark;
37
+ const lightVars = toCssVars(lightMerged);
38
+ const darkVars = toCssVars(darkMerged);
39
+ const inlineThemeCss = `:root{${lightVars}}.dark{${darkVars}}`;
40
+ return {
41
+ variant,
42
+ styleTag: (_jsx("style", { id: "theme-variant-vars", dangerouslySetInnerHTML: { __html: inlineThemeCss } })),
43
+ };
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextworks/blocks-core",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.11",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,17 +9,33 @@
9
9
  "package.json",
10
10
  "README.md"
11
11
  ],
12
+ "repository": "github:jblh/nextworks-cli",
13
+ "bugs": "https://github.com/jblh/nextworks-cli/issues",
14
+ "homepage": "https://github.com/jblh/nextworks-cli#readme",
12
15
  "publishConfig": {
13
16
  "access": "public"
14
17
  },
15
18
  "scripts": {
16
- "build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap --outDir dist-types",
17
- "build": "tsc -p tsconfig.build.json && npm run build:types && node scripts/postbuild.js"
19
+ "build:types": "npx tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap --outDir dist-types",
20
+ "build": "npx tsc -p tsconfig.build.json && npm run build:types && node scripts/postbuild.js"
18
21
  },
19
22
  "dependencies": {
20
23
  "next-themes": "^0.4.6",
21
24
  "clsx": "^2.1.1",
22
- "tailwind-merge": "^3.3.1"
25
+ "tailwind-merge": "^3.3.1",
26
+ "@radix-ui/react-alert-dialog": "^1.1.15",
27
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
28
+ "@radix-ui/react-label": "^2.1.7",
29
+ "@radix-ui/react-slot": "^1.2.3",
30
+ "class-variance-authority": "^0.7.1",
31
+ "lucide-react": "^0.542.0",
32
+ "sonner": "^2.0.7"
33
+ },
34
+ "devDependencies": {
35
+ "typescript": "^5.9.3",
36
+ "@types/node": "^20",
37
+ "@types/react": "^19",
38
+ "@types/react-dom": "^19"
23
39
  },
24
40
  "peerDependencies": {
25
41
  "react": "^19.0.0",