@alexandregme/zljs 3.14.0 → 3.16.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,28 @@ A change that needs action in an app has a **Migration** note. When updating, re
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [3.16.0] - 2026-11-19
12
+
13
+ ### Added
14
+
15
+ - `target` on `Link`, as on an HTML link: `_blank` opens a new tab, for a link that leaves the app
16
+
17
+ ## [3.15.0] - 2026-11-18
18
+
19
+ ### Added
20
+
21
+ - `TopNav`, and so `Navigation` on a small screen, shows an install button before the logout button in the account panel: it puts the app on the home screen of the phone, to open like an installed app. It only shows when the browser can do it. Where the browser offers the install (Chrome on Android), a tap shows its install dialog. On an iPhone a tap opens a modal with the steps. Opened from the home screen, or in a browser that can't install, there is no button. `install` takes its texts: `label`, `instructionsTitle` and `instructions`
22
+ - `useInstallApp` and `InstallAppButton`, the hook and the button `TopNav` uses, for an app that puts the install somewhere else
23
+ - `Icon` has the `Download` icon
24
+
25
+ #### Migration
26
+
27
+ An app that uses `TopNav` or `Navigation` gets the install button when it updates:
28
+
29
+ - An app in another language passes `install={{ label, instructionsTitle, instructions }}`, or the button and its modal are in English. Find where with `grep -rnE "<(TopNav|Navigation)" app src pages`
30
+ - Chrome on Android only offers the install to an app with a web app manifest, so without one the button never shows there. In Next.js, add `app/manifest.ts` with `name`, `icons` (192px and 512px), `start_url` and `display: "standalone"`
31
+ - On an iPhone the button shows with or without a manifest. Without one, the app opens from the home screen inside the browser
32
+
11
33
  ## [3.14.0] - 2026-11-12
12
34
 
13
35
  ### Added
@@ -543,7 +565,9 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
543
565
 
544
566
  The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
545
567
 
546
- [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.14.0...HEAD
568
+ [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.16.0...HEAD
569
+ [3.16.0]: https://github.com/alexandregme/zljs/compare/v3.15.0...v3.16.0
570
+ [3.15.0]: https://github.com/alexandregme/zljs/compare/v3.14.0...v3.15.0
547
571
  [3.14.0]: https://github.com/alexandregme/zljs/compare/v3.13.1...v3.14.0
548
572
  [3.13.1]: https://github.com/alexandregme/zljs/compare/v3.13.0...v3.13.1
549
573
  [3.13.0]: https://github.com/alexandregme/zljs/compare/v3.11.0...v3.13.0
@@ -699,6 +699,7 @@ import { jsx as jsx9 } from "react/jsx-runtime";
699
699
  var Link = ({
700
700
  children,
701
701
  href,
702
+ target,
702
703
  variant = "inline",
703
704
  color = "primary",
704
705
  active = false,
@@ -712,6 +713,7 @@ var Link = ({
712
713
  "aria-label": ariaLabel,
713
714
  onClick,
714
715
  className: link({ variant, color, active }),
716
+ target,
715
717
  ...active && { "aria-current": "page" },
716
718
  children
717
719
  }
@@ -851,8 +853,119 @@ var Sidebar = ({
851
853
  ] });
852
854
  };
853
855
 
856
+ // features/app/components/install-app-button/install-app-button.const.ts
857
+ var INSTALL_APP_MODAL_ID = "zljs-install-app";
858
+
859
+ // features/app/components/install-app-button/install-app-button.tsx
860
+ import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
861
+ var InstallAppButton = ({
862
+ way,
863
+ label = "Install app",
864
+ size = "md",
865
+ instructionsTitle = "Install this app",
866
+ instructions = "Tap the Share button of the browser, then Add to Home Screen.",
867
+ onPrompt
868
+ }) => {
869
+ const openModal = useAppStore((s) => s.openModal);
870
+ const install = () => {
871
+ if (way === "prompt") {
872
+ onPrompt();
873
+ } else {
874
+ openModal(INSTALL_APP_MODAL_ID);
875
+ }
876
+ };
877
+ return /* @__PURE__ */ jsxs6(Fragment5, { children: [
878
+ /* @__PURE__ */ jsx11(
879
+ Button,
880
+ {
881
+ color: "ghost",
882
+ size,
883
+ icon: "Download",
884
+ "aria-label": label,
885
+ onClick: install
886
+ }
887
+ ),
888
+ way === "instructions" && /* @__PURE__ */ jsx11(
889
+ ConnectedModal,
890
+ {
891
+ modalId: INSTALL_APP_MODAL_ID,
892
+ title: instructionsTitle,
893
+ description: instructions,
894
+ size: "xs"
895
+ }
896
+ )
897
+ ] });
898
+ };
899
+
900
+ // features/app/hooks/use-install-app/use-install-app.ts
901
+ import { useEffect, useState as useState2, useSyncExternalStore } from "react";
902
+
903
+ // features/app/hooks/use-install-app/use-install-app.const.ts
904
+ var INSTALL_APP_IOS_USER_AGENT = /iPhone|iPad|iPod/i;
905
+ var INSTALLED_APP_QUERY = "(display-mode: standalone)";
906
+
907
+ // features/app/hooks/use-install-app/use-install-app.ts
908
+ var subscribeToNothing = () => () => {
909
+ };
910
+ var needsInstructions = () => INSTALL_APP_IOS_USER_AGENT.test(navigator.userAgent) && !window.matchMedia(INSTALLED_APP_QUERY).matches;
911
+ var notOnServer = () => false;
912
+ var useInstallApp = () => {
913
+ const [promptEvent, setPromptEvent] = useState2(
914
+ null
915
+ );
916
+ const instructions = useSyncExternalStore(
917
+ subscribeToNothing,
918
+ needsInstructions,
919
+ notOnServer
920
+ );
921
+ useEffect(() => {
922
+ const keep = (event) => {
923
+ event.preventDefault();
924
+ setPromptEvent(event);
925
+ };
926
+ const forget = () => {
927
+ setPromptEvent(null);
928
+ };
929
+ window.addEventListener("beforeinstallprompt", keep);
930
+ window.addEventListener("appinstalled", forget);
931
+ return () => {
932
+ window.removeEventListener("beforeinstallprompt", keep);
933
+ window.removeEventListener("appinstalled", forget);
934
+ };
935
+ }, []);
936
+ const prompt = () => {
937
+ if (!promptEvent) {
938
+ return;
939
+ }
940
+ void promptEvent.prompt();
941
+ setPromptEvent(null);
942
+ };
943
+ if (promptEvent) {
944
+ return { way: "prompt", prompt };
945
+ }
946
+ return { way: instructions ? "instructions" : null, prompt };
947
+ };
948
+
949
+ // features/app/hooks/use-is-desktop/use-is-desktop.ts
950
+ import { useSyncExternalStore as useSyncExternalStore2 } from "react";
951
+
952
+ // features/app/hooks/use-is-desktop/use-is-desktop.const.ts
953
+ var DESKTOP_QUERY = "(min-width: 768px)";
954
+
955
+ // features/app/hooks/use-is-desktop/use-is-desktop.ts
956
+ var subscribe = (onChange) => {
957
+ const media = window.matchMedia(DESKTOP_QUERY);
958
+ media.addEventListener("change", onChange);
959
+ return () => {
960
+ media.removeEventListener("change", onChange);
961
+ };
962
+ };
963
+ var isDesktop = () => window.matchMedia(DESKTOP_QUERY).matches;
964
+ var unknown = () => null;
965
+ var useIsDesktop = () => useSyncExternalStore2(subscribe, isDesktop, unknown);
966
+
854
967
  // core/top-nav/top-nav.tsx
855
- import { useEffect, useRef, useState as useState2 } from "react";
968
+ import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
856
969
 
857
970
  // core/top-nav/top-nav.styles.ts
858
971
  import { tv as tv9 } from "tailwind-variants";
@@ -879,7 +992,7 @@ var topNav = tv9({
879
992
  });
880
993
 
881
994
  // core/top-nav/top-nav.tsx
882
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
995
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
883
996
  var TopNav = ({
884
997
  sections,
885
998
  user,
@@ -889,13 +1002,15 @@ var TopNav = ({
889
1002
  navLabel = "Main navigation",
890
1003
  menuLabel = "Menu",
891
1004
  accountLabel = "Account",
1005
+ install = {},
892
1006
  logout = {},
893
1007
  onLogout
894
1008
  }) => {
895
- const [open, setOpen] = useState2(null);
1009
+ const [open, setOpen] = useState3(null);
896
1010
  const pressedInside = useRef(false);
1011
+ const installApp = useInstallApp();
897
1012
  const styles = topNav();
898
- useEffect(() => {
1013
+ useEffect2(() => {
899
1014
  if (!open) {
900
1015
  return;
901
1016
  }
@@ -927,9 +1042,9 @@ var TopNav = ({
927
1042
  const close = () => {
928
1043
  setOpen(null);
929
1044
  };
930
- return /* @__PURE__ */ jsxs6("header", { className: styles.base(), onPointerDown: markPressInside, children: [
931
- /* @__PURE__ */ jsxs6("div", { className: styles.bar(), children: [
932
- hasLinks ? /* @__PURE__ */ jsx11(
1045
+ return /* @__PURE__ */ jsxs7("header", { className: styles.base(), onPointerDown: markPressInside, children: [
1046
+ /* @__PURE__ */ jsxs7("div", { className: styles.bar(), children: [
1047
+ hasLinks ? /* @__PURE__ */ jsx12(
933
1048
  Button,
934
1049
  {
935
1050
  color: "ghost",
@@ -939,8 +1054,8 @@ var TopNav = ({
939
1054
  "aria-expanded": menuOpen,
940
1055
  onClick: toggleMenu
941
1056
  }
942
- ) : /* @__PURE__ */ jsx11("span", { "aria-hidden": "true", className: styles.spacer() }),
943
- /* @__PURE__ */ jsx11("div", { className: styles.home(), children: homeHref && /* @__PURE__ */ jsxs6(
1057
+ ) : /* @__PURE__ */ jsx12("span", { "aria-hidden": "true", className: styles.spacer() }),
1058
+ /* @__PURE__ */ jsx12("div", { className: styles.home(), children: homeHref && /* @__PURE__ */ jsxs7(
944
1059
  Link,
945
1060
  {
946
1061
  href: homeHref,
@@ -950,12 +1065,12 @@ var TopNav = ({
950
1065
  "aria-label": homeLabel || "Home",
951
1066
  onClick: close,
952
1067
  children: [
953
- /* @__PURE__ */ jsx11(Icon, { name: "Home" }),
954
- homeLabel && /* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: homeLabel })
1068
+ /* @__PURE__ */ jsx12(Icon, { name: "Home" }),
1069
+ homeLabel && /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: homeLabel })
955
1070
  ]
956
1071
  }
957
1072
  ) }),
958
- /* @__PURE__ */ jsx11(
1073
+ /* @__PURE__ */ jsx12(
959
1074
  Button,
960
1075
  {
961
1076
  color: "ghost",
@@ -967,12 +1082,23 @@ var TopNav = ({
967
1082
  }
968
1083
  )
969
1084
  ] }),
970
- accountOpen && /* @__PURE__ */ jsxs6("div", { className: styles.account(), children: [
971
- /* @__PURE__ */ jsxs6("div", { className: styles.user(), children: [
972
- /* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: user.name }),
973
- /* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: user.email })
1085
+ accountOpen && /* @__PURE__ */ jsxs7("div", { className: styles.account(), children: [
1086
+ /* @__PURE__ */ jsxs7("div", { className: styles.user(), children: [
1087
+ /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: user.name }),
1088
+ /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: user.email })
974
1089
  ] }),
975
- /* @__PURE__ */ jsx11(
1090
+ installApp.way && /* @__PURE__ */ jsx12(
1091
+ InstallAppButton,
1092
+ {
1093
+ way: installApp.way,
1094
+ size: "lg",
1095
+ label: install.label,
1096
+ instructionsTitle: install.instructionsTitle,
1097
+ instructions: install.instructions,
1098
+ onPrompt: installApp.prompt
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ jsx12(
976
1102
  SignOutButton,
977
1103
  {
978
1104
  size: "lg",
@@ -985,7 +1111,7 @@ var TopNav = ({
985
1111
  }
986
1112
  )
987
1113
  ] }),
988
- menuOpen && /* @__PURE__ */ jsx11("nav", { "aria-label": navLabel, className: styles.menu(), children: sections.map((section2, i) => /* @__PURE__ */ jsx11("div", { className: styles.section(), children: section2.items.map((item) => /* @__PURE__ */ jsxs6(
1114
+ menuOpen && /* @__PURE__ */ jsx12("nav", { "aria-label": navLabel, className: styles.menu(), children: sections.map((section2, i) => /* @__PURE__ */ jsx12("div", { className: styles.section(), children: section2.items.map((item) => /* @__PURE__ */ jsxs7(
989
1115
  Link,
990
1116
  {
991
1117
  href: item.href,
@@ -995,8 +1121,8 @@ var TopNav = ({
995
1121
  "aria-label": item.label,
996
1122
  onClick: close,
997
1123
  children: [
998
- /* @__PURE__ */ jsx11(Icon, { name: item.icon }),
999
- /* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: item.label })
1124
+ /* @__PURE__ */ jsx12(Icon, { name: item.icon }),
1125
+ /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: item.label })
1000
1126
  ]
1001
1127
  },
1002
1128
  item.href
@@ -1005,7 +1131,7 @@ var TopNav = ({
1005
1131
  };
1006
1132
 
1007
1133
  // features/toaster/components/toaster/toaster.tsx
1008
- import { useEffect as useEffect2 } from "react";
1134
+ import { useEffect as useEffect3 } from "react";
1009
1135
  import { Toaster as SonnerToaster, toast } from "sonner";
1010
1136
 
1011
1137
  // features/toaster/components/toaster/toaster.styles.ts
@@ -1033,18 +1159,18 @@ var toasterColors = {
1033
1159
  };
1034
1160
 
1035
1161
  // features/toaster/components/toaster/toaster.tsx
1036
- import { jsx as jsx12 } from "react/jsx-runtime";
1162
+ import { jsx as jsx13 } from "react/jsx-runtime";
1037
1163
  var Toaster = () => {
1038
1164
  const toasts = useToastStore((s) => s.toasts);
1039
1165
  const removeToast = useToastStore((s) => s.removeToast);
1040
1166
  const { toast: toastStyles, closeButton } = toaster();
1041
- useEffect2(() => {
1167
+ useEffect3(() => {
1042
1168
  toasts.forEach((t) => {
1043
1169
  toast[t.type](t.message, { id: `store-${t.id}` });
1044
1170
  removeToast(t.id);
1045
1171
  });
1046
1172
  }, [toasts, removeToast]);
1047
- return /* @__PURE__ */ jsx12(
1173
+ return /* @__PURE__ */ jsx13(
1048
1174
  SonnerToaster,
1049
1175
  {
1050
1176
  position: "bottom-right",
@@ -1078,19 +1204,19 @@ var spinner = tv11({
1078
1204
  });
1079
1205
 
1080
1206
  // core/spinner/spinner.tsx
1081
- import { jsx as jsx13 } from "react/jsx-runtime";
1207
+ import { jsx as jsx14 } from "react/jsx-runtime";
1082
1208
  var Spinner = ({
1083
1209
  variant = "circle",
1084
1210
  size = "md",
1085
1211
  label = "Loading"
1086
- }) => /* @__PURE__ */ jsx13(
1212
+ }) => /* @__PURE__ */ jsx14(
1087
1213
  "span",
1088
1214
  {
1089
1215
  "data-testid": "spinner",
1090
1216
  role: "status",
1091
1217
  "aria-label": label,
1092
1218
  className: spinner(),
1093
- children: /* @__PURE__ */ jsx13(Icon, { name: spinnerIcons[variant], size })
1219
+ children: /* @__PURE__ */ jsx14(Icon, { name: spinnerIcons[variant], size })
1094
1220
  }
1095
1221
  );
1096
1222
 
@@ -1101,33 +1227,15 @@ var loader = tv12({
1101
1227
  });
1102
1228
 
1103
1229
  // features/app/components/loader/loader.tsx
1104
- import { jsx as jsx14 } from "react/jsx-runtime";
1230
+ import { jsx as jsx15 } from "react/jsx-runtime";
1105
1231
  var Loader = ({ label = "Loading" }) => {
1106
1232
  const fetching = useAppStore((s) => s.fetching);
1107
1233
  if (!fetching) return null;
1108
- return /* @__PURE__ */ jsx14("div", { className: loader(), children: /* @__PURE__ */ jsx14(Spinner, { size: "lg", label }) });
1234
+ return /* @__PURE__ */ jsx15("div", { className: loader(), children: /* @__PURE__ */ jsx15(Spinner, { size: "lg", label }) });
1109
1235
  };
1110
1236
 
1111
- // features/app/hooks/use-is-desktop/use-is-desktop.ts
1112
- import { useSyncExternalStore } from "react";
1113
-
1114
- // features/app/hooks/use-is-desktop/use-is-desktop.const.ts
1115
- var DESKTOP_QUERY = "(min-width: 768px)";
1116
-
1117
- // features/app/hooks/use-is-desktop/use-is-desktop.ts
1118
- var subscribe = (onChange) => {
1119
- const media = window.matchMedia(DESKTOP_QUERY);
1120
- media.addEventListener("change", onChange);
1121
- return () => {
1122
- media.removeEventListener("change", onChange);
1123
- };
1124
- };
1125
- var isDesktop = () => window.matchMedia(DESKTOP_QUERY).matches;
1126
- var unknown = () => null;
1127
- var useIsDesktop = () => useSyncExternalStore(subscribe, isDesktop, unknown);
1128
-
1129
1237
  // features/app/components/navigation/navigation.tsx
1130
- import { jsx as jsx15 } from "react/jsx-runtime";
1238
+ import { jsx as jsx16 } from "react/jsx-runtime";
1131
1239
  var Navigation = ({
1132
1240
  mode = "auto",
1133
1241
  sections,
@@ -1141,6 +1249,7 @@ var Navigation = ({
1141
1249
  navLabel,
1142
1250
  menuLabel,
1143
1251
  accountLabel,
1252
+ install,
1144
1253
  logout,
1145
1254
  onLogout
1146
1255
  }) => {
@@ -1150,7 +1259,7 @@ var Navigation = ({
1150
1259
  return null;
1151
1260
  }
1152
1261
  if (desktop) {
1153
- return /* @__PURE__ */ jsx15(
1262
+ return /* @__PURE__ */ jsx16(
1154
1263
  Sidebar,
1155
1264
  {
1156
1265
  sections,
@@ -1167,7 +1276,7 @@ var Navigation = ({
1167
1276
  }
1168
1277
  );
1169
1278
  }
1170
- return /* @__PURE__ */ jsx15(
1279
+ return /* @__PURE__ */ jsx16(
1171
1280
  TopNav,
1172
1281
  {
1173
1282
  sections,
@@ -1178,6 +1287,7 @@ var Navigation = ({
1178
1287
  navLabel,
1179
1288
  menuLabel,
1180
1289
  accountLabel,
1290
+ install,
1181
1291
  logout,
1182
1292
  onLogout
1183
1293
  }
@@ -1185,7 +1295,7 @@ var Navigation = ({
1185
1295
  };
1186
1296
 
1187
1297
  // core/state/redux/redux-provider/redux-provider.tsx
1188
- import { useState as useState3 } from "react";
1298
+ import { useState as useState4 } from "react";
1189
1299
  import { Provider } from "react-redux";
1190
1300
 
1191
1301
  // core/state/redux/store/store.ts
@@ -1218,7 +1328,7 @@ var createReduxStore = ({
1218
1328
  };
1219
1329
 
1220
1330
  // core/state/redux/redux-provider/redux-provider.tsx
1221
- import { jsx as jsx16 } from "react/jsx-runtime";
1331
+ import { jsx as jsx17 } from "react/jsx-runtime";
1222
1332
  var ReduxProvider = ({
1223
1333
  children,
1224
1334
  reducers = {},
@@ -1226,7 +1336,7 @@ var ReduxProvider = ({
1226
1336
  preloadedState = {},
1227
1337
  coreReducers = {}
1228
1338
  }) => {
1229
- const [store] = useState3(
1339
+ const [store] = useState4(
1230
1340
  () => createReduxStore({
1231
1341
  reducers,
1232
1342
  middlewares,
@@ -1234,7 +1344,7 @@ var ReduxProvider = ({
1234
1344
  coreReducers
1235
1345
  })
1236
1346
  );
1237
- return /* @__PURE__ */ jsx16(Provider, { store, children });
1347
+ return /* @__PURE__ */ jsx17(Provider, { store, children });
1238
1348
  };
1239
1349
 
1240
1350
  // core/state/zustand/router/router.utils.ts
@@ -1326,7 +1436,7 @@ var card = tv13({
1326
1436
  });
1327
1437
 
1328
1438
  // core/card/card.tsx
1329
- import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
1439
+ import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
1330
1440
  var Card = ({
1331
1441
  children,
1332
1442
  title: title2,
@@ -1336,10 +1446,10 @@ var Card = ({
1336
1446
  }) => {
1337
1447
  const { base, header: header3 } = card({ color });
1338
1448
  const messageColor = color === "none" ? "muted" : "none";
1339
- return /* @__PURE__ */ jsxs7("div", { "data-testid": "card", className: base(), children: [
1340
- (title2 || message) && /* @__PURE__ */ jsxs7("div", { className: header3(), children: [
1341
- title2 && /* @__PURE__ */ jsx17(Heading, { level: titleLevel, children: title2 }),
1342
- message && /* @__PURE__ */ jsx17(Text, { color: messageColor, children: message })
1449
+ return /* @__PURE__ */ jsxs8("div", { "data-testid": "card", className: base(), children: [
1450
+ (title2 || message) && /* @__PURE__ */ jsxs8("div", { className: header3(), children: [
1451
+ title2 && /* @__PURE__ */ jsx18(Heading, { level: titleLevel, children: title2 }),
1452
+ message && /* @__PURE__ */ jsx18(Text, { color: messageColor, children: message })
1343
1453
  ] }),
1344
1454
  children
1345
1455
  ] });
@@ -1354,7 +1464,7 @@ var accessPending = tv14({
1354
1464
  });
1355
1465
 
1356
1466
  // features/auth/components/access-pending/access-pending.tsx
1357
- import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
1467
+ import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
1358
1468
  var AccessPending = ({
1359
1469
  title: title2 = "Waiting for approval",
1360
1470
  message = "Your access to this app has not been approved yet.",
@@ -1369,9 +1479,9 @@ var AccessPending = ({
1369
1479
  if (!user) {
1370
1480
  return null;
1371
1481
  }
1372
- return /* @__PURE__ */ jsx18(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs8("div", { className: account(), children: [
1373
- /* @__PURE__ */ jsx18(Text, { variant: "caption", color: "muted", children: user.email }),
1374
- /* @__PURE__ */ jsx18(
1482
+ return /* @__PURE__ */ jsx19(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs9("div", { className: account(), children: [
1483
+ /* @__PURE__ */ jsx19(Text, { variant: "caption", color: "muted", children: user.email }),
1484
+ /* @__PURE__ */ jsx19(
1375
1485
  SignOutButton,
1376
1486
  {
1377
1487
  label: signOutLabel,
@@ -1385,8 +1495,8 @@ var AccessPending = ({
1385
1495
  };
1386
1496
 
1387
1497
  // features/auth/components/auth-provider/auth-provider.tsx
1388
- import { useEffect as useEffect3 } from "react";
1389
- import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
1498
+ import { useEffect as useEffect4 } from "react";
1499
+ import { Fragment as Fragment6, jsx as jsx20 } from "react/jsx-runtime";
1390
1500
  var AuthProvider = ({
1391
1501
  adapter,
1392
1502
  appId,
@@ -1395,7 +1505,7 @@ var AuthProvider = ({
1395
1505
  const configure = useAuthStore((s) => s.configure);
1396
1506
  const setSession = useAuthStore((s) => s.setSession);
1397
1507
  const reset = useAuthStore((s) => s.reset);
1398
- useEffect3(() => {
1508
+ useEffect4(() => {
1399
1509
  configure(adapter, appId);
1400
1510
  const unsubscribe = adapter.onSessionChange(setSession);
1401
1511
  return () => {
@@ -1403,7 +1513,7 @@ var AuthProvider = ({
1403
1513
  reset();
1404
1514
  };
1405
1515
  }, [adapter, appId, configure, setSession, reset]);
1406
- return /* @__PURE__ */ jsx19(Fragment5, { children });
1516
+ return /* @__PURE__ */ jsx20(Fragment6, { children });
1407
1517
  };
1408
1518
 
1409
1519
  // features/auth/components/login/login.const.ts
@@ -1425,7 +1535,7 @@ var login = tv15({
1425
1535
  });
1426
1536
 
1427
1537
  // features/auth/components/login/login.tsx
1428
- import { jsx as jsx20 } from "react/jsx-runtime";
1538
+ import { jsx as jsx21 } from "react/jsx-runtime";
1429
1539
  var LoginProviderButton = ({
1430
1540
  id,
1431
1541
  label,
@@ -1434,7 +1544,7 @@ var LoginProviderButton = ({
1434
1544
  const signIn = () => {
1435
1545
  onSignIn(id);
1436
1546
  };
1437
- return /* @__PURE__ */ jsx20(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
1547
+ return /* @__PURE__ */ jsx21(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
1438
1548
  };
1439
1549
  var Login = ({
1440
1550
  vendor,
@@ -1452,9 +1562,9 @@ var Login = ({
1452
1562
  useToastStore.getState().error(errorMessage);
1453
1563
  });
1454
1564
  };
1455
- return /* @__PURE__ */ jsx20(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx20("div", { className: options(), children: providers.map((provider) => {
1565
+ return /* @__PURE__ */ jsx21(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx21("div", { className: options(), children: providers.map((provider) => {
1456
1566
  const id = String(provider);
1457
- return /* @__PURE__ */ jsx20(
1567
+ return /* @__PURE__ */ jsx21(
1458
1568
  LoginProviderButton,
1459
1569
  {
1460
1570
  id,
@@ -1467,7 +1577,7 @@ var Login = ({
1467
1577
  };
1468
1578
 
1469
1579
  // features/auth/components/authorized/authorized.tsx
1470
- import { Fragment as Fragment6, jsx as jsx21 } from "react/jsx-runtime";
1580
+ import { Fragment as Fragment7, jsx as jsx22 } from "react/jsx-runtime";
1471
1581
  var Authorized = ({
1472
1582
  children,
1473
1583
  roles,
@@ -1476,18 +1586,18 @@ var Authorized = ({
1476
1586
  }) => {
1477
1587
  const { status, user, role } = useAuth();
1478
1588
  if (status === "loading") return null;
1479
- if (!user) return /* @__PURE__ */ jsx21(Login, { ...login2 });
1589
+ if (!user) return /* @__PURE__ */ jsx22(Login, { ...login2 });
1480
1590
  const hasRole = !roles || role !== null && roles.includes(role);
1481
- if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx21(AccessPending, { ...accessPending2 });
1482
- return /* @__PURE__ */ jsx21(Fragment6, { children });
1591
+ if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx22(AccessPending, { ...accessPending2 });
1592
+ return /* @__PURE__ */ jsx22(Fragment7, { children });
1483
1593
  };
1484
1594
 
1485
1595
  // features/providers/components/zustand-providers/zustand-providers.tsx
1486
- import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
1487
- var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs9(Fragment7, { children: [
1488
- /* @__PURE__ */ jsx22(Loader, {}),
1489
- /* @__PURE__ */ jsx22(Toaster, {}),
1490
- auth ? /* @__PURE__ */ jsx22(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
1596
+ import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
1597
+ var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs10(Fragment8, { children: [
1598
+ /* @__PURE__ */ jsx23(Loader, {}),
1599
+ /* @__PURE__ */ jsx23(Toaster, {}),
1600
+ auth ? /* @__PURE__ */ jsx23(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
1491
1601
  ] });
1492
1602
 
1493
1603
  export {
@@ -1505,12 +1615,14 @@ export {
1505
1615
  SignOutButton,
1506
1616
  Link,
1507
1617
  Sidebar,
1618
+ InstallAppButton,
1619
+ useInstallApp,
1620
+ useIsDesktop,
1508
1621
  TopNav,
1509
1622
  Toaster,
1510
1623
  toast2 as toast,
1511
1624
  Spinner,
1512
1625
  Loader,
1513
- useIsDesktop,
1514
1626
  Navigation,
1515
1627
  ReduxProvider,
1516
1628
  splitURLasPath,
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import 'react-hook-form';
12
12
  */
13
13
  type Size = "sm" | "md" | "lg";
14
14
 
15
- declare const iconNames: readonly ["Check", "X", "Plus", "Minus", "Search", "Menu", "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "ChevronsUp", "ArrowUp", "Pencil", "Trash2", "Save", "RefreshCw", "Home", "MessageSquare", "Users", "Store", "ShoppingCart", "BarChart3", "Brain", "Send", "LogOut", "User", "Key", "Contact", "Package", "Warehouse", "HandCoins", "Stethoscope", "LogIn", "Megaphone", "LayoutDashboard", "Smile", "Frown", "Cat", "ArrowRight", "Loader", "LoaderCircle", "CheckCircle", "XCircle", "AlertTriangle", "Info", "Route", "Navigation", "ListChecks", "Map", "MapPinOff", "SiWhatsapp", "SiFacebook", "SiInstagram", "SiShopify"];
15
+ declare const iconNames: readonly ["Check", "X", "Plus", "Minus", "Search", "Menu", "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "ChevronsUp", "ArrowUp", "Pencil", "Trash2", "Save", "RefreshCw", "Home", "MessageSquare", "Users", "Store", "ShoppingCart", "BarChart3", "Brain", "Send", "LogOut", "Download", "User", "Key", "Contact", "Package", "Warehouse", "HandCoins", "Stethoscope", "LogIn", "Megaphone", "LayoutDashboard", "Smile", "Frown", "Cat", "ArrowRight", "Loader", "LoaderCircle", "CheckCircle", "XCircle", "AlertTriangle", "Info", "Route", "Navigation", "ListChecks", "Map", "MapPinOff", "SiWhatsapp", "SiFacebook", "SiInstagram", "SiShopify"];
16
16
 
17
17
  type IconName = (typeof iconNames)[number];
18
18
  interface IconProps {
@@ -327,6 +327,61 @@ interface TabsProps {
327
327
 
328
328
  declare const Tabs: ({ tabs, "aria-label": ariaLabel, defaultTab, onChange, }: TabsProps) => react.JSX.Element;
329
329
 
330
+ /**
331
+ * How the browser puts the app on the home screen: `prompt` shows its own
332
+ * install dialog, and `instructions` is for a browser with no dialog to show,
333
+ * where the user is told the steps.
334
+ */
335
+ type InstallAppWay = "prompt" | "instructions";
336
+ interface InstallApp {
337
+ /**
338
+ * How this browser installs the app. `null` when it can't, when the app is
339
+ * already installed, and on the server.
340
+ */
341
+ way: InstallAppWay | null;
342
+ /**
343
+ * Shows the install dialog of the browser. Call it from a click. It does
344
+ * nothing unless `way` is `prompt`.
345
+ */
346
+ prompt: () => void;
347
+ }
348
+
349
+ /**
350
+ * How the browser can put the app on the home screen of the device, to open
351
+ * like an installed app. It listens for the install offer of the browser from
352
+ * the moment it mounts, so call it in a component that stays on the page.
353
+ */
354
+ declare const useInstallApp: () => InstallApp;
355
+
356
+ /**
357
+ * Whether the screen fits `Sidebar`, and it follows the screen as it is
358
+ * resized or turned. `null` on the server, where there is no screen.
359
+ */
360
+ declare const useIsDesktop: () => boolean | null;
361
+
362
+ interface InstallAppButtonProps {
363
+ /**
364
+ * How the browser installs the app, from `useInstallApp`: `prompt` calls
365
+ * `onPrompt` on a click, and `instructions` opens a modal with the steps.
366
+ */
367
+ way: InstallAppWay;
368
+ /** The accessible name of the icon button. */
369
+ label?: string;
370
+ /** The size of the icon button. `lg` is for a touch screen. */
371
+ size?: Size;
372
+ /** The title of the modal with the steps. */
373
+ instructionsTitle?: string;
374
+ /** The steps to install the app by hand, the text of the modal. */
375
+ instructions?: string;
376
+ /**
377
+ * Shows the install dialog of the browser: the `prompt` of `useInstallApp`.
378
+ * It is called on a click when `way` is `prompt`.
379
+ */
380
+ onPrompt: () => void;
381
+ }
382
+
383
+ declare const InstallAppButton: ({ way, label, size, instructionsTitle, instructions, onPrompt, }: InstallAppButtonProps) => react.JSX.Element;
384
+
330
385
  interface TopNavProps {
331
386
  /**
332
387
  * The same sections `Sidebar` takes. The menu button opens them. With no
@@ -344,6 +399,12 @@ interface TopNavProps {
344
399
  menuLabel?: string;
345
400
  /** The accessible name of the account button. */
346
401
  accountLabel?: string;
402
+ /**
403
+ * The texts of the install button and of the modal with its steps: `label`,
404
+ * `instructionsTitle` and `instructions`. The button shows before the logout
405
+ * button, only in a browser that can put the app on the home screen.
406
+ */
407
+ install?: Pick<InstallAppButtonProps, "label" | "instructionsTitle" | "instructions">;
347
408
  /**
348
409
  * The texts of the logout button and of the modal it opens: `label`,
349
410
  * `confirmTitle`, `confirmLabel`, `cancelLabel` and `errorMessage`.
@@ -356,7 +417,7 @@ interface TopNavProps {
356
417
  onLogout: () => void | Promise<void>;
357
418
  }
358
419
 
359
- declare const TopNav: ({ sections, user, activeHref, homeHref, homeLabel, navLabel, menuLabel, accountLabel, logout, onLogout, }: TopNavProps) => react.JSX.Element;
420
+ declare const TopNav: ({ sections, user, activeHref, homeHref, homeLabel, navLabel, menuLabel, accountLabel, install, logout, onLogout, }: TopNavProps) => react.JSX.Element;
360
421
 
361
422
  type TagColor = Exclude<SemanticColor, "none"> | AuxiliaryColor;
362
423
  interface TagProps {
@@ -433,17 +494,11 @@ type NavigationMode = "auto" | "desktop" | "mobile";
433
494
  * The props of `Sidebar` and of `TopNav` together: what both take is passed to
434
495
  * the one that shows, and the rest only to its owner.
435
496
  */
436
- interface NavigationProps extends SidebarProps, Pick<TopNavProps, "menuLabel" | "accountLabel"> {
497
+ interface NavigationProps extends SidebarProps, Pick<TopNavProps, "menuLabel" | "accountLabel" | "install"> {
437
498
  mode?: NavigationMode;
438
499
  }
439
500
 
440
- declare const Navigation: ({ mode, sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, menuLabel, accountLabel, logout, onLogout, }: NavigationProps) => react.JSX.Element | null;
441
-
442
- /**
443
- * Whether the screen fits `Sidebar`, and it follows the screen as it is
444
- * resized or turned. `null` on the server, where there is no screen.
445
- */
446
- declare const useIsDesktop: () => boolean | null;
501
+ declare const Navigation: ({ mode, sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, menuLabel, accountLabel, install, logout, onLogout, }: NavigationProps) => react.JSX.Element | null;
447
502
 
448
503
  interface AppState {
449
504
  fetchingCalls: number;
@@ -672,5 +727,5 @@ declare const useAuth: () => UseAuthResult;
672
727
 
673
728
  declare const ZustandProviders: ({ children, auth }: ZustandProvidersProps) => react.JSX.Element;
674
729
 
675
- export { AccessPending, AuthAdapter, AuthProvider, AuthSession, Authorized, AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Error, Form, HTTPClient, Heading, Icon, Input, Loader, Login, Modal, Navigation, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, Sidebar, SignOutButton, Spinner, StatsCard, Tabs, Tag, Text, TextArea, Toaster, TopNav, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, splitURLasPath, useAppStore, useAuth, useIsDesktop, usePageStore, useRouterStore, useToastStore };
676
- export type { AppState, AuthorizedProps, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, LoaderProps, LoginProvider, LoginVendor, ModalProps, NavigationMode, NavigationProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TabsItem, TabsProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, TopNavProps, WhatsAppButtonProps };
730
+ export { AccessPending, AuthAdapter, AuthProvider, AuthSession, Authorized, AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Error, Form, HTTPClient, Heading, Icon, Input, InstallAppButton, Loader, Login, Modal, Navigation, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, Sidebar, SignOutButton, Spinner, StatsCard, Tabs, Tag, Text, TextArea, Toaster, TopNav, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, splitURLasPath, useAppStore, useAuth, useInstallApp, useIsDesktop, usePageStore, useRouterStore, useToastStore };
731
+ export type { AppState, AuthorizedProps, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, InstallApp, InstallAppButtonProps, InstallAppWay, LoaderProps, LoginProvider, LoginVendor, ModalProps, NavigationMode, NavigationProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TabsItem, TabsProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, TopNavProps, WhatsAppButtonProps };
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  ConnectedModal,
9
9
  Heading,
10
10
  Icon,
11
+ InstallAppButton,
11
12
  Loader,
12
13
  Login,
13
14
  Modal,
@@ -26,11 +27,12 @@ import {
26
27
  toast,
27
28
  useAppStore,
28
29
  useAuth,
30
+ useInstallApp,
29
31
  useIsDesktop,
30
32
  usePageStore,
31
33
  useRouterStore,
32
34
  useToastStore
33
- } from "./chunk-ZB76FFTW.js";
35
+ } from "./chunk-KAYLAL75.js";
34
36
  import {
35
37
  Error,
36
38
  FormInput,
@@ -784,6 +786,7 @@ export {
784
786
  Heading,
785
787
  Icon,
786
788
  Input,
789
+ InstallAppButton,
787
790
  Loader,
788
791
  Login,
789
792
  Modal,
@@ -809,6 +812,7 @@ export {
809
812
  toast,
810
813
  useAppStore,
811
814
  useAuth,
815
+ useInstallApp,
812
816
  useIsDesktop,
813
817
  usePageStore,
814
818
  useRouterStore,
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, HTMLAttributeAnchorTarget } from 'react';
3
3
  import { SemanticColor, ReduxProviderProps, ZustandProvidersProps } from '../index.js';
4
4
  import { ThunkDispatch, UnknownAction, Reducer } from '@reduxjs/toolkit';
5
5
 
@@ -29,6 +29,11 @@ type LinkVariant = "inline" | "nav";
29
29
  interface LinkProps {
30
30
  children: ReactNode;
31
31
  href: string;
32
+ /**
33
+ * Where the link opens, as on an HTML link: `_blank` is a new tab, for a
34
+ * link that leaves the app.
35
+ */
36
+ target?: HTMLAttributeAnchorTarget;
32
37
  /** `inline` is a link in a text. `nav` is a row of a menu, with no underline. */
33
38
  variant?: LinkVariant;
34
39
  color?: SemanticColor;
@@ -40,7 +45,7 @@ interface LinkProps {
40
45
  onClick?: () => void;
41
46
  }
42
47
 
43
- declare const Link: ({ children, href, variant, color, active, "aria-label": ariaLabel, onClick, }: LinkProps) => react.JSX.Element;
48
+ declare const Link: ({ children, href, target, variant, color, active, "aria-label": ariaLabel, onClick, }: LinkProps) => react.JSX.Element;
44
49
 
45
50
  type AppProvidersProps = ReduxProviderProps & Pick<ZustandProvidersProps, "auth">;
46
51
 
@@ -7,7 +7,7 @@ import {
7
7
  ZustandProviders,
8
8
  usePageStore,
9
9
  useRouterStore
10
- } from "../chunk-ZB76FFTW.js";
10
+ } from "../chunk-KAYLAL75.js";
11
11
 
12
12
  // core/next/root-layout/root-layout.tsx
13
13
  import { Analytics } from "@vercel/analytics/next";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "3.14.0",
3
+ "version": "3.16.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",