@alexandregme/zljs 3.13.1 → 3.14.0

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/CHANGELOG.md CHANGED
@@ -8,6 +8,19 @@ A change that needs action in an app has a **Migration** note. When updating, re
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [3.14.0] - 2026-11-12
12
+
13
+ ### Added
14
+
15
+ - `RootLayout` counts the page views with [Vercel Web Analytics](https://vercel.com/docs/analytics): it renders `Analytics` from `@vercel/analytics/next`, which zljs now installs, so an app has nothing to install or import. It adds a script to the document and nothing to the page. It is always on. In development it sends nothing and stays silent in the console
16
+
17
+ #### Migration
18
+
19
+ An app that uses `RootLayout` starts loading the analytics script when it updates:
20
+
21
+ - Enable Web Analytics in the project on Vercel (Analytics tab), then deploy. Until it is enabled the script answers 404 and nothing is counted
22
+ - An app that already renders `<Analytics />` from `@vercel/analytics` itself: remove its own, or the views are counted by two components. Find it with `grep -rn "@vercel/analytics" app src pages`
23
+
11
24
  ## [3.13.1] - 2026-11-12
12
25
 
13
26
  ### Fixed
@@ -530,7 +543,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
530
543
 
531
544
  The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
532
545
 
533
- [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.13.1...HEAD
546
+ [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.14.0...HEAD
547
+ [3.14.0]: https://github.com/alexandregme/zljs/compare/v3.13.1...v3.14.0
534
548
  [3.13.1]: https://github.com/alexandregme/zljs/compare/v3.13.0...v3.13.1
535
549
  [3.13.0]: https://github.com/alexandregme/zljs/compare/v3.11.0...v3.13.0
536
550
  [3.11.0]: https://github.com/alexandregme/zljs/compare/v3.10.0...v3.11.0
package/README.md CHANGED
@@ -43,6 +43,23 @@ import { FormProvider, FormInput } from "@alexandregme/zljs/rhf";
43
43
  <Button onClick={handleClick}>Submit</Button>;
44
44
  ```
45
45
 
46
+ `RootLayout` goes in the root layout of a Next.js app, around its content. It renders the page's `<main>` and counts the page views with [Vercel Web Analytics](https://vercel.com/docs/analytics), so the app installs nothing for it: enable Web Analytics in the project on Vercel and deploy.
47
+
48
+ ```tsx
49
+ // app/layout.tsx
50
+ import { RootLayout } from "@alexandregme/zljs/next";
51
+
52
+ export default function Layout({ children }: { children: React.ReactNode }) {
53
+ return (
54
+ <html lang="en">
55
+ <body>
56
+ <RootLayout>{children}</RootLayout>
57
+ </body>
58
+ </html>
59
+ );
60
+ }
61
+ ```
62
+
46
63
  ## Colors
47
64
 
48
65
  The components work with no setup, using the default colors. To use your own, redefine the values you want after importing the styles:
@@ -852,7 +852,7 @@ var Sidebar = ({
852
852
  };
853
853
 
854
854
  // core/top-nav/top-nav.tsx
855
- import { useState as useState2 } from "react";
855
+ import { useEffect, useRef, useState as useState2 } from "react";
856
856
 
857
857
  // core/top-nav/top-nav.styles.ts
858
858
  import { tv as tv9 } from "tailwind-variants";
@@ -893,7 +893,27 @@ var TopNav = ({
893
893
  onLogout
894
894
  }) => {
895
895
  const [open, setOpen] = useState2(null);
896
+ const pressedInside = useRef(false);
896
897
  const styles = topNav();
898
+ useEffect(() => {
899
+ if (!open) {
900
+ return;
901
+ }
902
+ pressedInside.current = false;
903
+ const closeOnPressOutside = () => {
904
+ if (!pressedInside.current) {
905
+ setOpen(null);
906
+ }
907
+ pressedInside.current = false;
908
+ };
909
+ document.addEventListener("pointerdown", closeOnPressOutside);
910
+ return () => {
911
+ document.removeEventListener("pointerdown", closeOnPressOutside);
912
+ };
913
+ }, [open]);
914
+ const markPressInside = () => {
915
+ pressedInside.current = true;
916
+ };
897
917
  const hasLinks = sections.some((section2) => section2.items.length > 0);
898
918
  const menuOpen = open === "menu";
899
919
  const accountOpen = open === "account";
@@ -907,7 +927,7 @@ var TopNav = ({
907
927
  const close = () => {
908
928
  setOpen(null);
909
929
  };
910
- return /* @__PURE__ */ jsxs6("header", { className: styles.base(), children: [
930
+ return /* @__PURE__ */ jsxs6("header", { className: styles.base(), onPointerDown: markPressInside, children: [
911
931
  /* @__PURE__ */ jsxs6("div", { className: styles.bar(), children: [
912
932
  hasLinks ? /* @__PURE__ */ jsx11(
913
933
  Button,
@@ -985,7 +1005,7 @@ var TopNav = ({
985
1005
  };
986
1006
 
987
1007
  // features/toaster/components/toaster/toaster.tsx
988
- import { useEffect } from "react";
1008
+ import { useEffect as useEffect2 } from "react";
989
1009
  import { Toaster as SonnerToaster, toast } from "sonner";
990
1010
 
991
1011
  // features/toaster/components/toaster/toaster.styles.ts
@@ -1018,7 +1038,7 @@ var Toaster = () => {
1018
1038
  const toasts = useToastStore((s) => s.toasts);
1019
1039
  const removeToast = useToastStore((s) => s.removeToast);
1020
1040
  const { toast: toastStyles, closeButton } = toaster();
1021
- useEffect(() => {
1041
+ useEffect2(() => {
1022
1042
  toasts.forEach((t) => {
1023
1043
  toast[t.type](t.message, { id: `store-${t.id}` });
1024
1044
  removeToast(t.id);
@@ -1365,7 +1385,7 @@ var AccessPending = ({
1365
1385
  };
1366
1386
 
1367
1387
  // features/auth/components/auth-provider/auth-provider.tsx
1368
- import { useEffect as useEffect2 } from "react";
1388
+ import { useEffect as useEffect3 } from "react";
1369
1389
  import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
1370
1390
  var AuthProvider = ({
1371
1391
  adapter,
@@ -1375,7 +1395,7 @@ var AuthProvider = ({
1375
1395
  const configure = useAuthStore((s) => s.configure);
1376
1396
  const setSession = useAuthStore((s) => s.setSession);
1377
1397
  const reset = useAuthStore((s) => s.reset);
1378
- useEffect2(() => {
1398
+ useEffect3(() => {
1379
1399
  configure(adapter, appId);
1380
1400
  const unsubscribe = adapter.onSessionChange(setSession);
1381
1401
  return () => {
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  usePageStore,
31
31
  useRouterStore,
32
32
  useToastStore
33
- } from "./chunk-H4EDTEZB.js";
33
+ } from "./chunk-ZB76FFTW.js";
34
34
  import {
35
35
  Error,
36
36
  FormInput,
@@ -7,7 +7,10 @@ import {
7
7
  ZustandProviders,
8
8
  usePageStore,
9
9
  useRouterStore
10
- } from "../chunk-H4EDTEZB.js";
10
+ } from "../chunk-ZB76FFTW.js";
11
+
12
+ // core/next/root-layout/root-layout.tsx
13
+ import { Analytics } from "@vercel/analytics/next";
11
14
 
12
15
  // core/next/root-layout/root-layout.styles.ts
13
16
  import { tv } from "tailwind-variants";
@@ -16,9 +19,12 @@ var rootLayout = tv({
16
19
  });
17
20
 
18
21
  // core/next/root-layout/root-layout.tsx
19
- import { jsx } from "react/jsx-runtime";
22
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
20
23
  var RootLayout = ({ children }) => {
21
- return /* @__PURE__ */ jsx("main", { className: rootLayout(), children });
24
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
25
+ /* @__PURE__ */ jsx("main", { className: rootLayout(), children }),
26
+ /* @__PURE__ */ jsx(Analytics, { debug: false })
27
+ ] });
22
28
  };
23
29
 
24
30
  // core/next/not-found/not-found.styles.ts
@@ -32,7 +38,7 @@ var notFound = tv2({
32
38
  });
33
39
 
34
40
  // core/next/not-found/not-found.tsx
35
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
41
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
36
42
  var NotFound = ({
37
43
  title = "Page not found",
38
44
  message = "The page you are looking for does not exist.",
@@ -40,9 +46,9 @@ var NotFound = ({
40
46
  backLabel = "Go back home"
41
47
  }) => {
42
48
  const { base, code, content } = notFound();
43
- return /* @__PURE__ */ jsxs("div", { className: base(), children: [
49
+ return /* @__PURE__ */ jsxs2("div", { className: base(), children: [
44
50
  /* @__PURE__ */ jsx2("span", { className: code(), children: "404" }),
45
- /* @__PURE__ */ jsxs("div", { className: content(), children: [
51
+ /* @__PURE__ */ jsxs2("div", { className: content(), children: [
46
52
  /* @__PURE__ */ jsx2(Heading, { children: title }),
47
53
  /* @__PURE__ */ jsx2(Text, { color: "muted", children: message })
48
54
  ] }),
@@ -69,7 +75,7 @@ var PageWrapper = ({ children }) => {
69
75
  // core/next/app-providers/app-providers.tsx
70
76
  import { useEffect } from "react";
71
77
  import { usePathname } from "next/navigation.js";
72
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
78
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
73
79
  var RouteSync = () => {
74
80
  const pathname = usePathname();
75
81
  const setRoute = useRouterStore((s) => s.setRoute);
@@ -84,7 +90,7 @@ var AppProviders = ({
84
90
  children,
85
91
  auth,
86
92
  ...store
87
- }) => /* @__PURE__ */ jsxs2(ReduxProvider, { ...store, children: [
93
+ }) => /* @__PURE__ */ jsxs3(ReduxProvider, { ...store, children: [
88
94
  /* @__PURE__ */ jsx4(RouteSync, {}),
89
95
  /* @__PURE__ */ jsx4(ZustandProviders, { auth, children })
90
96
  ] });
@@ -92,7 +98,7 @@ var AppProviders = ({
92
98
  // core/next/page-config/page-config.tsx
93
99
  import { useEffect as useEffect2 } from "react";
94
100
  import { useDispatch, useStore } from "react-redux";
95
- import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
101
+ import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
96
102
  var PageConfig = ({
97
103
  children,
98
104
  title,
@@ -115,7 +121,7 @@ var PageConfig = ({
115
121
  initPage(dispatch);
116
122
  }
117
123
  }, []);
118
- return /* @__PURE__ */ jsx5(Fragment, { children });
124
+ return /* @__PURE__ */ jsx5(Fragment2, { children });
119
125
  };
120
126
  export {
121
127
  AppProviders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "3.13.1",
3
+ "version": "3.14.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",
@@ -76,6 +76,7 @@
76
76
  "@hookform/resolvers": "^5.2.2",
77
77
  "@radix-ui/react-dialog": "^1.1.15",
78
78
  "@radix-ui/react-tabs": "^1.2.1",
79
+ "@vercel/analytics": "^2.0.1",
79
80
  "ag-grid-community": "^36.2.0",
80
81
  "ag-grid-react": "^36.2.0",
81
82
  "axios": "^1.13.5",