@alexandregme/zljs 3.17.0 → 3.18.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,12 @@ A change that needs action in an app has a **Migration** note. When updating, re
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [3.18.0] - 2026-11-19
12
+
13
+ ### Added
14
+
15
+ - `Toaster`: `toast.error` and `toast.warning` (and the `useToastStore` toasts of those types) show a `Copy` button when the message is text. It copies the message and its text `description`, then reads `Copied` and keeps the toast open. An `action` passed by the app replaces it
16
+
11
17
  ## [3.17.0] - 2026-11-19
12
18
 
13
19
  ### Added
@@ -571,7 +577,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
571
577
 
572
578
  The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
573
579
 
574
- [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.17.0...HEAD
580
+ [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.18.0...HEAD
581
+ [3.18.0]: https://github.com/alexandregme/zljs/compare/v3.17.0...v3.18.0
575
582
  [3.17.0]: https://github.com/alexandregme/zljs/compare/v3.16.0...v3.17.0
576
583
  [3.16.0]: https://github.com/alexandregme/zljs/compare/v3.15.0...v3.16.0
577
584
  [3.15.0]: https://github.com/alexandregme/zljs/compare/v3.14.0...v3.15.0
@@ -1137,9 +1137,15 @@ var TopNav = ({
1137
1137
  ] });
1138
1138
  };
1139
1139
 
1140
- // features/toaster/components/toaster/toaster.tsx
1141
- import { useEffect as useEffect3 } from "react";
1142
- import { Toaster as SonnerToaster, toast } from "sonner";
1140
+ // features/toaster/components/toaster/toast.tsx
1141
+ import { toast as sonnerToast } from "sonner";
1142
+
1143
+ // features/toaster/components/toaster/toaster-copy-button.tsx
1144
+ import { useState as useState4 } from "react";
1145
+
1146
+ // features/toaster/components/toaster/toaster.const.ts
1147
+ var toasterCopyLabel = "Copy";
1148
+ var toasterCopiedLabel = "Copied";
1143
1149
 
1144
1150
  // features/toaster/components/toaster/toaster.styles.ts
1145
1151
  import { tv as tv10 } from "tailwind-variants";
@@ -1147,7 +1153,9 @@ var focusOutline = "focus-visible:outline-2! focus-visible:outline-offset-2! foc
1147
1153
  var toaster = tv10({
1148
1154
  slots: {
1149
1155
  toast: focusOutline,
1150
- closeButton: focusOutline
1156
+ closeButton: focusOutline,
1157
+ // Sonner pushes its own action button to the end; this does the same for ours.
1158
+ copyButton: "ms-auto shrink-0"
1151
1159
  }
1152
1160
  });
1153
1161
  var toasterColors = {
@@ -1165,8 +1173,52 @@ var toasterColors = {
1165
1173
  "--error-border": "color-mix(in oklab, var(--color-zl-danger) 30%, white)"
1166
1174
  };
1167
1175
 
1168
- // features/toaster/components/toaster/toaster.tsx
1176
+ // features/toaster/components/toaster/toaster-copy-button.tsx
1169
1177
  import { jsx as jsx13 } from "react/jsx-runtime";
1178
+ var ToasterCopyButton = ({ text: text2 }) => {
1179
+ const [copied, setCopied] = useState4(false);
1180
+ const { copyButton } = toaster();
1181
+ const copy = () => navigator.clipboard.writeText(text2).then(
1182
+ () => setCopied(true),
1183
+ // Without permission the browser refuses, and the button stays on Copy.
1184
+ () => void 0
1185
+ );
1186
+ return /* @__PURE__ */ jsx13("span", { className: copyButton(), children: /* @__PURE__ */ jsx13(
1187
+ Button,
1188
+ {
1189
+ color: "ghost",
1190
+ size: "sm",
1191
+ icon: copied ? "Check" : void 0,
1192
+ onClick: copy,
1193
+ children: copied ? toasterCopiedLabel : toasterCopyLabel
1194
+ }
1195
+ ) });
1196
+ };
1197
+
1198
+ // features/toaster/components/toaster/toast.tsx
1199
+ import { jsx as jsx14 } from "react/jsx-runtime";
1200
+ var copyText = (message, description2) => typeof description2 === "string" ? `${message}
1201
+ ${description2}` : message;
1202
+ var withCopy = (show) => (message, data) => show(
1203
+ message,
1204
+ typeof message === "string" ? {
1205
+ action: /* @__PURE__ */ jsx14(ToasterCopyButton, { text: copyText(message, data?.description) }),
1206
+ ...data
1207
+ } : data
1208
+ );
1209
+ var toast = Object.assign(
1210
+ (...args) => sonnerToast(...args),
1211
+ sonnerToast,
1212
+ {
1213
+ error: withCopy(sonnerToast.error),
1214
+ warning: withCopy(sonnerToast.warning)
1215
+ }
1216
+ );
1217
+
1218
+ // features/toaster/components/toaster/toaster.tsx
1219
+ import { useEffect as useEffect3 } from "react";
1220
+ import { Toaster as SonnerToaster } from "sonner";
1221
+ import { jsx as jsx15 } from "react/jsx-runtime";
1170
1222
  var Toaster = () => {
1171
1223
  const toasts = useToastStore((s) => s.toasts);
1172
1224
  const removeToast = useToastStore((s) => s.removeToast);
@@ -1177,7 +1229,7 @@ var Toaster = () => {
1177
1229
  removeToast(t.id);
1178
1230
  });
1179
1231
  }, [toasts, removeToast]);
1180
- return /* @__PURE__ */ jsx13(
1232
+ return /* @__PURE__ */ jsx15(
1181
1233
  SonnerToaster,
1182
1234
  {
1183
1235
  position: "bottom-right",
@@ -1194,9 +1246,6 @@ var Toaster = () => {
1194
1246
  );
1195
1247
  };
1196
1248
 
1197
- // features/toaster/components/toaster/index.ts
1198
- import { toast as toast2 } from "sonner";
1199
-
1200
1249
  // core/spinner/spinner.const.ts
1201
1250
  var spinnerIcons = {
1202
1251
  circle: "LoaderCircle",
@@ -1211,19 +1260,19 @@ var spinner = tv11({
1211
1260
  });
1212
1261
 
1213
1262
  // core/spinner/spinner.tsx
1214
- import { jsx as jsx14 } from "react/jsx-runtime";
1263
+ import { jsx as jsx16 } from "react/jsx-runtime";
1215
1264
  var Spinner = ({
1216
1265
  variant = "circle",
1217
1266
  size = "md",
1218
1267
  label = "Loading"
1219
- }) => /* @__PURE__ */ jsx14(
1268
+ }) => /* @__PURE__ */ jsx16(
1220
1269
  "span",
1221
1270
  {
1222
1271
  "data-testid": "spinner",
1223
1272
  role: "status",
1224
1273
  "aria-label": label,
1225
1274
  className: spinner(),
1226
- children: /* @__PURE__ */ jsx14(Icon, { name: spinnerIcons[variant], size })
1275
+ children: /* @__PURE__ */ jsx16(Icon, { name: spinnerIcons[variant], size })
1227
1276
  }
1228
1277
  );
1229
1278
 
@@ -1234,15 +1283,15 @@ var loader = tv12({
1234
1283
  });
1235
1284
 
1236
1285
  // features/app/components/loader/loader.tsx
1237
- import { jsx as jsx15 } from "react/jsx-runtime";
1286
+ import { jsx as jsx17 } from "react/jsx-runtime";
1238
1287
  var Loader = ({ label = "Loading" }) => {
1239
1288
  const fetching = useAppStore((s) => s.fetching);
1240
1289
  if (!fetching) return null;
1241
- return /* @__PURE__ */ jsx15("div", { className: loader(), children: /* @__PURE__ */ jsx15(Spinner, { size: "lg", label }) });
1290
+ return /* @__PURE__ */ jsx17("div", { className: loader(), children: /* @__PURE__ */ jsx17(Spinner, { size: "lg", label }) });
1242
1291
  };
1243
1292
 
1244
1293
  // features/app/components/navigation/navigation.tsx
1245
- import { jsx as jsx16 } from "react/jsx-runtime";
1294
+ import { jsx as jsx18 } from "react/jsx-runtime";
1246
1295
  var Navigation = ({
1247
1296
  mode = "auto",
1248
1297
  sections,
@@ -1266,7 +1315,7 @@ var Navigation = ({
1266
1315
  return null;
1267
1316
  }
1268
1317
  if (desktop) {
1269
- return /* @__PURE__ */ jsx16(
1318
+ return /* @__PURE__ */ jsx18(
1270
1319
  Sidebar,
1271
1320
  {
1272
1321
  sections,
@@ -1283,7 +1332,7 @@ var Navigation = ({
1283
1332
  }
1284
1333
  );
1285
1334
  }
1286
- return /* @__PURE__ */ jsx16(
1335
+ return /* @__PURE__ */ jsx18(
1287
1336
  TopNav,
1288
1337
  {
1289
1338
  sections,
@@ -1302,7 +1351,7 @@ var Navigation = ({
1302
1351
  };
1303
1352
 
1304
1353
  // core/state/redux/redux-provider/redux-provider.tsx
1305
- import { useState as useState4 } from "react";
1354
+ import { useState as useState5 } from "react";
1306
1355
  import { Provider } from "react-redux";
1307
1356
 
1308
1357
  // core/state/redux/store/store.ts
@@ -1335,7 +1384,7 @@ var createReduxStore = ({
1335
1384
  };
1336
1385
 
1337
1386
  // core/state/redux/redux-provider/redux-provider.tsx
1338
- import { jsx as jsx17 } from "react/jsx-runtime";
1387
+ import { jsx as jsx19 } from "react/jsx-runtime";
1339
1388
  var ReduxProvider = ({
1340
1389
  children,
1341
1390
  reducers = {},
@@ -1343,7 +1392,7 @@ var ReduxProvider = ({
1343
1392
  preloadedState = {},
1344
1393
  coreReducers = {}
1345
1394
  }) => {
1346
- const [store] = useState4(
1395
+ const [store] = useState5(
1347
1396
  () => createReduxStore({
1348
1397
  reducers,
1349
1398
  middlewares,
@@ -1351,7 +1400,7 @@ var ReduxProvider = ({
1351
1400
  coreReducers
1352
1401
  })
1353
1402
  );
1354
- return /* @__PURE__ */ jsx17(Provider, { store, children });
1403
+ return /* @__PURE__ */ jsx19(Provider, { store, children });
1355
1404
  };
1356
1405
 
1357
1406
  // core/state/zustand/router/router.utils.ts
@@ -1443,7 +1492,7 @@ var card = tv13({
1443
1492
  });
1444
1493
 
1445
1494
  // core/card/card.tsx
1446
- import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
1495
+ import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
1447
1496
  var Card = ({
1448
1497
  children,
1449
1498
  title: title2,
@@ -1455,8 +1504,8 @@ var Card = ({
1455
1504
  const messageColor = color === "none" ? "muted" : "none";
1456
1505
  return /* @__PURE__ */ jsxs8("div", { "data-testid": "card", className: base(), children: [
1457
1506
  (title2 || message) && /* @__PURE__ */ jsxs8("div", { className: header3(), children: [
1458
- title2 && /* @__PURE__ */ jsx18(Heading, { level: titleLevel, children: title2 }),
1459
- message && /* @__PURE__ */ jsx18(Text, { color: messageColor, children: message })
1507
+ title2 && /* @__PURE__ */ jsx20(Heading, { level: titleLevel, children: title2 }),
1508
+ message && /* @__PURE__ */ jsx20(Text, { color: messageColor, children: message })
1460
1509
  ] }),
1461
1510
  children
1462
1511
  ] });
@@ -1471,7 +1520,7 @@ var accessPending = tv14({
1471
1520
  });
1472
1521
 
1473
1522
  // features/auth/components/access-pending/access-pending.tsx
1474
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
1523
+ import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
1475
1524
  var AccessPending = ({
1476
1525
  title: title2 = "Waiting for approval",
1477
1526
  message = "Your access to this app has not been approved yet.",
@@ -1486,9 +1535,9 @@ var AccessPending = ({
1486
1535
  if (!user) {
1487
1536
  return null;
1488
1537
  }
1489
- return /* @__PURE__ */ jsx19(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs9("div", { className: account(), children: [
1490
- /* @__PURE__ */ jsx19(Text, { variant: "caption", color: "muted", children: user.email }),
1491
- /* @__PURE__ */ jsx19(
1538
+ return /* @__PURE__ */ jsx21(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs9("div", { className: account(), children: [
1539
+ /* @__PURE__ */ jsx21(Text, { variant: "caption", color: "muted", children: user.email }),
1540
+ /* @__PURE__ */ jsx21(
1492
1541
  SignOutButton,
1493
1542
  {
1494
1543
  label: signOutLabel,
@@ -1503,7 +1552,7 @@ var AccessPending = ({
1503
1552
 
1504
1553
  // features/auth/components/auth-provider/auth-provider.tsx
1505
1554
  import { useEffect as useEffect4 } from "react";
1506
- import { Fragment as Fragment6, jsx as jsx20 } from "react/jsx-runtime";
1555
+ import { Fragment as Fragment6, jsx as jsx22 } from "react/jsx-runtime";
1507
1556
  var AuthProvider = ({
1508
1557
  adapter,
1509
1558
  appId,
@@ -1520,7 +1569,7 @@ var AuthProvider = ({
1520
1569
  reset();
1521
1570
  };
1522
1571
  }, [adapter, appId, configure, setSession, reset]);
1523
- return /* @__PURE__ */ jsx20(Fragment6, { children });
1572
+ return /* @__PURE__ */ jsx22(Fragment6, { children });
1524
1573
  };
1525
1574
 
1526
1575
  // features/auth/components/login/login.const.ts
@@ -1542,7 +1591,7 @@ var login = tv15({
1542
1591
  });
1543
1592
 
1544
1593
  // features/auth/components/login/login.tsx
1545
- import { jsx as jsx21 } from "react/jsx-runtime";
1594
+ import { jsx as jsx23 } from "react/jsx-runtime";
1546
1595
  var LoginProviderButton = ({
1547
1596
  id,
1548
1597
  label,
@@ -1551,7 +1600,7 @@ var LoginProviderButton = ({
1551
1600
  const signIn = () => {
1552
1601
  onSignIn(id);
1553
1602
  };
1554
- return /* @__PURE__ */ jsx21(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
1603
+ return /* @__PURE__ */ jsx23(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
1555
1604
  };
1556
1605
  var Login = ({
1557
1606
  vendor,
@@ -1569,9 +1618,9 @@ var Login = ({
1569
1618
  useToastStore.getState().error(errorMessage);
1570
1619
  });
1571
1620
  };
1572
- return /* @__PURE__ */ jsx21(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx21("div", { className: options(), children: providers.map((provider) => {
1621
+ return /* @__PURE__ */ jsx23(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx23("div", { className: options(), children: providers.map((provider) => {
1573
1622
  const id = String(provider);
1574
- return /* @__PURE__ */ jsx21(
1623
+ return /* @__PURE__ */ jsx23(
1575
1624
  LoginProviderButton,
1576
1625
  {
1577
1626
  id,
@@ -1584,7 +1633,7 @@ var Login = ({
1584
1633
  };
1585
1634
 
1586
1635
  // features/auth/components/authorized/authorized.tsx
1587
- import { Fragment as Fragment7, jsx as jsx22 } from "react/jsx-runtime";
1636
+ import { Fragment as Fragment7, jsx as jsx24 } from "react/jsx-runtime";
1588
1637
  var Authorized = ({
1589
1638
  children,
1590
1639
  roles,
@@ -1593,18 +1642,18 @@ var Authorized = ({
1593
1642
  }) => {
1594
1643
  const { status, user, role } = useAuth();
1595
1644
  if (status === "loading") return null;
1596
- if (!user) return /* @__PURE__ */ jsx22(Login, { ...login2 });
1645
+ if (!user) return /* @__PURE__ */ jsx24(Login, { ...login2 });
1597
1646
  const hasRole = !roles || role !== null && roles.includes(role);
1598
- if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx22(AccessPending, { ...accessPending2 });
1599
- return /* @__PURE__ */ jsx22(Fragment7, { children });
1647
+ if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx24(AccessPending, { ...accessPending2 });
1648
+ return /* @__PURE__ */ jsx24(Fragment7, { children });
1600
1649
  };
1601
1650
 
1602
1651
  // features/providers/components/zustand-providers/zustand-providers.tsx
1603
- import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
1652
+ import { Fragment as Fragment8, jsx as jsx25, jsxs as jsxs10 } from "react/jsx-runtime";
1604
1653
  var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs10(Fragment8, { children: [
1605
- /* @__PURE__ */ jsx23(Loader, {}),
1606
- /* @__PURE__ */ jsx23(Toaster, {}),
1607
- auth ? /* @__PURE__ */ jsx23(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
1654
+ /* @__PURE__ */ jsx25(Loader, {}),
1655
+ /* @__PURE__ */ jsx25(Toaster, {}),
1656
+ auth ? /* @__PURE__ */ jsx25(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
1608
1657
  ] });
1609
1658
 
1610
1659
  export {
@@ -1626,8 +1675,8 @@ export {
1626
1675
  useInstallApp,
1627
1676
  useIsDesktop,
1628
1677
  TopNav,
1678
+ toast,
1629
1679
  Toaster,
1630
- toast2 as toast,
1631
1680
  Spinner,
1632
1681
  Loader,
1633
1682
  Navigation,
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as react from 'react';
2
2
  import { ReactNode, ChangeEvent, FormEvent, HTMLInputAutoCompleteAttribute, FocusEvent, KeyboardEvent, Ref } from 'react';
3
3
  import { S as SemanticColor, D as DataColor, A as AuxiliaryColor, R as ReduxProviderProps, a as AuthSession, b as AuthConfig, c as AuthAdapter, d as AuthStatus, e as AuthUser, Z as ZustandProvidersProps } from './zustand-providers.interface-CeC8U2hM.js';
4
4
  export { FormInput, FormInputProps, FormProvider, FormProviderProps } from './rhf/index.js';
5
- export { toast } from 'sonner';
5
+ import { toast as toast$1 } from 'sonner';
6
6
  import * as zustand from 'zustand';
7
7
  import { Store, Reducer } from '@reduxjs/toolkit';
8
8
  import 'react-hook-form';
@@ -433,6 +433,8 @@ declare const Tag: ({ children, color, size, onRemove, removeLabel, }: TagProps)
433
433
 
434
434
  declare const Toaster: () => react.JSX.Element;
435
435
 
436
+ declare const toast: typeof toast$1;
437
+
436
438
  type ToastType = "success" | "error" | "info" | "warning";
437
439
  interface Toast {
438
440
  id: number;
@@ -727,5 +729,5 @@ declare const useAuth: () => UseAuthResult;
727
729
 
728
730
  declare const ZustandProviders: ({ children, auth }: ZustandProvidersProps) => react.JSX.Element;
729
731
 
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 };
732
+ 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, toast, useAppStore, useAuth, useInstallApp, useIsDesktop, usePageStore, useRouterStore, useToastStore };
731
733
  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
@@ -32,7 +32,7 @@ import {
32
32
  usePageStore,
33
33
  useRouterStore,
34
34
  useToastStore
35
- } from "./chunk-W44HHGBY.js";
35
+ } from "./chunk-MC6RA4BA.js";
36
36
  import {
37
37
  Error,
38
38
  FormInput,
@@ -7,7 +7,7 @@ import {
7
7
  ZustandProviders,
8
8
  usePageStore,
9
9
  useRouterStore
10
- } from "../chunk-W44HHGBY.js";
10
+ } from "../chunk-MC6RA4BA.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.17.0",
3
+ "version": "3.18.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",