@sudobility/building_blocks 0.0.77 → 0.0.79

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,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import React__default, { useLayoutEffect, useState, createContext, memo, useMemo, useCallback, Suspense, useRef, useEffect, useContext } from "react";
3
+ import React__default, { useLayoutEffect, useState, createContext, memo, useMemo, useCallback, useContext, useEffect, Suspense, useRef } from "react";
4
4
  import { Link, useLocation, BrowserRouter } from "react-router-dom";
5
5
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
6
6
  import { HelmetProvider } from "react-helmet-async";
@@ -6449,6 +6449,191 @@ function zl({
6449
6449
  );
6450
6450
  return /* @__PURE__ */ jsx(qr.Provider, { value: u, children: e });
6451
6451
  }
6452
+ const vn = {
6453
+ success: /* @__PURE__ */ jsx(
6454
+ "svg",
6455
+ {
6456
+ className: "h-5 w-5",
6457
+ fill: "none",
6458
+ viewBox: "0 0 24 24",
6459
+ stroke: "currentColor",
6460
+ children: /* @__PURE__ */ jsx(
6461
+ "path",
6462
+ {
6463
+ strokeLinecap: "round",
6464
+ strokeLinejoin: "round",
6465
+ strokeWidth: 2,
6466
+ d: "M5 13l4 4L19 7"
6467
+ }
6468
+ )
6469
+ }
6470
+ ),
6471
+ error: /* @__PURE__ */ jsx(
6472
+ "svg",
6473
+ {
6474
+ className: "h-5 w-5",
6475
+ fill: "none",
6476
+ viewBox: "0 0 24 24",
6477
+ stroke: "currentColor",
6478
+ children: /* @__PURE__ */ jsx(
6479
+ "path",
6480
+ {
6481
+ strokeLinecap: "round",
6482
+ strokeLinejoin: "round",
6483
+ strokeWidth: 2,
6484
+ d: "M6 18L18 6M6 6l12 12"
6485
+ }
6486
+ )
6487
+ }
6488
+ ),
6489
+ warning: /* @__PURE__ */ jsx(
6490
+ "svg",
6491
+ {
6492
+ className: "h-5 w-5",
6493
+ fill: "none",
6494
+ viewBox: "0 0 24 24",
6495
+ stroke: "currentColor",
6496
+ children: /* @__PURE__ */ jsx(
6497
+ "path",
6498
+ {
6499
+ strokeLinecap: "round",
6500
+ strokeLinejoin: "round",
6501
+ strokeWidth: 2,
6502
+ d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
6503
+ }
6504
+ )
6505
+ }
6506
+ ),
6507
+ info: /* @__PURE__ */ jsx(
6508
+ "svg",
6509
+ {
6510
+ className: "h-5 w-5",
6511
+ fill: "none",
6512
+ viewBox: "0 0 24 24",
6513
+ stroke: "currentColor",
6514
+ children: /* @__PURE__ */ jsx(
6515
+ "path",
6516
+ {
6517
+ strokeLinecap: "round",
6518
+ strokeLinejoin: "round",
6519
+ strokeWidth: 2,
6520
+ d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
6521
+ }
6522
+ )
6523
+ }
6524
+ )
6525
+ }, wn = {
6526
+ success: {
6527
+ container: "bg-green-50 border-green-200 dark:bg-green-900/30 dark:border-green-800",
6528
+ icon: "text-green-500 dark:text-green-400",
6529
+ text: "text-green-800 dark:text-green-200"
6530
+ },
6531
+ error: {
6532
+ container: "bg-red-50 border-red-200 dark:bg-red-900/30 dark:border-red-800",
6533
+ icon: "text-red-500 dark:text-red-400",
6534
+ text: "text-red-800 dark:text-red-200"
6535
+ },
6536
+ warning: {
6537
+ container: "bg-yellow-50 border-yellow-200 dark:bg-yellow-900/30 dark:border-yellow-800",
6538
+ icon: "text-yellow-500 dark:text-yellow-400",
6539
+ text: "text-yellow-800 dark:text-yellow-200"
6540
+ },
6541
+ info: {
6542
+ container: "bg-blue-50 border-blue-200 dark:bg-blue-900/30 dark:border-blue-800",
6543
+ icon: "text-blue-500 dark:text-blue-400",
6544
+ text: "text-blue-800 dark:text-blue-200"
6545
+ }
6546
+ };
6547
+ function kn({
6548
+ toast: e,
6549
+ onDismiss: t
6550
+ }) {
6551
+ const [r, n] = useState(false), [o, s] = useState(false), { type: i, message: c, id: d } = e, l = wn[i];
6552
+ useEffect(() => {
6553
+ const u = setTimeout(() => n(true), 10);
6554
+ return () => clearTimeout(u);
6555
+ }, []);
6556
+ const g = () => {
6557
+ s(true), setTimeout(() => {
6558
+ t(d);
6559
+ }, 200);
6560
+ };
6561
+ return /* @__PURE__ */ jsxs(
6562
+ "div",
6563
+ {
6564
+ className: `
6565
+ flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg
6566
+ transition-all duration-200 ease-out
6567
+ ${l.container}
6568
+ ${r && !o ? "opacity-100 translate-x-0" : "opacity-0 translate-x-4"}
6569
+ `,
6570
+ role: "alert",
6571
+ "aria-live": "polite",
6572
+ children: [
6573
+ /* @__PURE__ */ jsx("span", { className: l.icon, children: vn[i] }),
6574
+ /* @__PURE__ */ jsx("span", { className: `flex-1 text-sm font-medium ${l.text}`, children: c }),
6575
+ /* @__PURE__ */ jsx(
6576
+ "button",
6577
+ {
6578
+ onClick: g,
6579
+ className: `
6580
+ p-1 rounded-md transition-colors
6581
+ hover:bg-black/10 dark:hover:bg-white/10
6582
+ ${l.text}
6583
+ `,
6584
+ "aria-label": "Dismiss notification",
6585
+ children: /* @__PURE__ */ jsx(
6586
+ "svg",
6587
+ {
6588
+ className: "h-4 w-4",
6589
+ fill: "none",
6590
+ viewBox: "0 0 24 24",
6591
+ stroke: "currentColor",
6592
+ children: /* @__PURE__ */ jsx(
6593
+ "path",
6594
+ {
6595
+ strokeLinecap: "round",
6596
+ strokeLinejoin: "round",
6597
+ strokeWidth: 2,
6598
+ d: "M6 18L18 6M6 6l12 12"
6599
+ }
6600
+ )
6601
+ }
6602
+ )
6603
+ }
6604
+ )
6605
+ ]
6606
+ }
6607
+ );
6608
+ }
6609
+ const Nn = {
6610
+ "top-right": "top-4 right-4",
6611
+ "top-left": "top-4 left-4",
6612
+ "bottom-right": "bottom-4 right-4",
6613
+ "bottom-left": "bottom-4 left-4",
6614
+ "top-center": "top-4 left-1/2 -translate-x-1/2",
6615
+ "bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
6616
+ };
6617
+ function Bl({
6618
+ toasts: e,
6619
+ onDismiss: t,
6620
+ position: r = "bottom-right"
6621
+ }) {
6622
+ return e.length === 0 ? null : /* @__PURE__ */ jsx(
6623
+ "div",
6624
+ {
6625
+ className: `fixed z-50 flex flex-col gap-2 max-w-sm w-full ${Nn[r]}`,
6626
+ "aria-label": "Notifications",
6627
+ children: e.map((n) => /* @__PURE__ */ jsx(kn, { toast: n, onDismiss: t }, n.id))
6628
+ }
6629
+ );
6630
+ }
6631
+ function Fl() {
6632
+ const e = useContext(qr);
6633
+ if (!e)
6634
+ throw new Error("useToast must be used within a ToastProvider");
6635
+ return e;
6636
+ }
6452
6637
  var gt = {}, B = {}, Kt;
6453
6638
  function Me() {
6454
6639
  if (Kt) return B;
@@ -10143,6 +10328,18 @@ function createDefaultThemeProvider(storageKeyPrefix) {
10143
10328
  function DefaultToastProvider({ children }) {
10144
10329
  return /* @__PURE__ */ jsx(zl, { children });
10145
10330
  }
10331
+ function DefaultToastContainer() {
10332
+ const { toasts, removeToast } = Fl();
10333
+ if (toasts.length === 0) return null;
10334
+ return /* @__PURE__ */ jsx(
10335
+ Bl,
10336
+ {
10337
+ toasts,
10338
+ onDismiss: removeToast,
10339
+ position: "bottom-right"
10340
+ }
10341
+ );
10342
+ }
10146
10343
  function SudobilityApp({
10147
10344
  children,
10148
10345
  i18n: i18nInstance,
@@ -10162,11 +10359,12 @@ function SudobilityApp({
10162
10359
  const PageTrackerComponent = PageTrackerProp === false ? null : PageTrackerProp ?? DefaultPageTracker;
10163
10360
  const ThemeProviderComponent = ThemeProviderProp ?? createDefaultThemeProvider(storageKeyPrefix);
10164
10361
  const ToastProviderComponent = ToastProviderProp ?? DefaultToastProvider;
10362
+ const ToastContainerComponent = ToastContainer ?? DefaultToastContainer;
10165
10363
  const queryClientInstance = queryClient ?? getDefaultQueryClient();
10166
10364
  let routerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
10167
10365
  PageTrackerComponent && /* @__PURE__ */ jsx(PageTrackerComponent, {}),
10168
10366
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback, {}), children }),
10169
- ToastContainer && /* @__PURE__ */ jsx(ToastContainer, {}),
10367
+ /* @__PURE__ */ jsx(ToastContainerComponent, {}),
10170
10368
  showInfoBanner && /* @__PURE__ */ jsx(InfoBanner, {})
10171
10369
  ] });
10172
10370
  routerContent = /* @__PURE__ */ jsx(BrowserRouter, { children: routerContent });
@@ -10201,11 +10399,14 @@ function useSafeSubscription() {
10201
10399
  return useContext(SafeSubscriptionContext);
10202
10400
  }
10203
10401
  export {
10402
+ Bl as B,
10403
+ Fl as F,
10204
10404
  SudobilityApp as S,
10205
10405
  SafeSubscriptionContext as a,
10206
10406
  STUB_SUBSCRIPTION_VALUE as b,
10207
10407
  getI18n as g,
10208
10408
  initializeI18n as i,
10209
- useSafeSubscription as u
10409
+ useSafeSubscription as u,
10410
+ zl as z
10210
10411
  };
10211
- //# sourceMappingURL=SafeSubscriptionContext-C2Nxvjir.js.map
10412
+ //# sourceMappingURL=SafeSubscriptionContext-BN1cInbb.js.map