@webdevarif/dashui 1.2.6 → 1.2.8

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/dist/index.mjs CHANGED
@@ -4057,22 +4057,31 @@ function TypographyPanel({
4057
4057
  ] });
4058
4058
  }
4059
4059
 
4060
- // src/hooks/index.ts
4061
- import { useState as useState15 } from "react";
4062
- function useDisclosure(initial = false) {
4063
- const [isOpen, setIsOpen] = useState15(initial);
4060
+ // src/setup/hooks/use-fetch.ts
4061
+ import useSWR from "swr";
4062
+ function useFetch(url, options) {
4063
+ const { data, error, isLoading, isValidating, mutate } = useSWR(
4064
+ options?.enabled === false ? null : url,
4065
+ options?.fetcher,
4066
+ {
4067
+ revalidateOnFocus: options?.revalidateOnFocus,
4068
+ refreshInterval: options?.refreshInterval
4069
+ }
4070
+ );
4064
4071
  return {
4065
- isOpen,
4066
- open: () => setIsOpen(true),
4067
- close: () => setIsOpen(false),
4068
- toggle: () => setIsOpen((prev) => !prev),
4069
- onOpenChange: setIsOpen
4072
+ data,
4073
+ isLoading,
4074
+ isValidating,
4075
+ error,
4076
+ isError: !!error,
4077
+ mutate
4070
4078
  };
4071
4079
  }
4072
- function usePagination(total, pageSize = 20) {
4073
- const [page, setPage] = useState15(1);
4074
- const totalPages = Math.ceil(total / pageSize);
4075
- return { page, setPage, pageSize, total, totalPages };
4080
+
4081
+ // src/setup/hooks/use-auth.ts
4082
+ import { useSession } from "next-auth/react";
4083
+ function useAuth() {
4084
+ return useSession();
4076
4085
  }
4077
4086
 
4078
4087
  // src/components/auth/AuthShell.tsx
@@ -4397,6 +4406,40 @@ function AuthFootnote({ text, linkText, linkHref }) {
4397
4406
 
4398
4407
  // src/index.ts
4399
4408
  import { ThemeProvider, useTheme as useTheme2 } from "next-themes";
4409
+
4410
+ // src/setup/providers/auth-provider.tsx
4411
+ import { SessionProvider } from "next-auth/react";
4412
+ import { jsx as jsx67 } from "react/jsx-runtime";
4413
+ function AuthProvider({ children, session }) {
4414
+ return /* @__PURE__ */ jsx67(SessionProvider, { session, children });
4415
+ }
4416
+
4417
+ // src/setup/providers/swr-provider.tsx
4418
+ import { SWRConfig } from "swr";
4419
+ import { jsx as jsx68 } from "react/jsx-runtime";
4420
+ var fetchFetcher = (url) => fetch(url).then((r) => r.json());
4421
+ var DEFAULT_SWR_CONFIG = {
4422
+ revalidateOnFocus: false,
4423
+ revalidateOnReconnect: true,
4424
+ dedupingInterval: 6e4,
4425
+ focusThrottleInterval: 3e5
4426
+ };
4427
+ function SWRProvider({ children, fetcher, config }) {
4428
+ return /* @__PURE__ */ jsx68(SWRConfig, { value: {
4429
+ fetcher: fetcher ?? fetchFetcher,
4430
+ ...DEFAULT_SWR_CONFIG,
4431
+ ...config
4432
+ }, children });
4433
+ }
4434
+
4435
+ // src/setup/providers/root-provider.tsx
4436
+ import { jsx as jsx69 } from "react/jsx-runtime";
4437
+ function RootProvider({
4438
+ children,
4439
+ session
4440
+ }) {
4441
+ return /* @__PURE__ */ jsx69(AuthProvider, { session, children: /* @__PURE__ */ jsx69(SWRProvider, { children }) });
4442
+ }
4400
4443
  export {
4401
4444
  Alert,
4402
4445
  AppShell,
@@ -4407,6 +4450,7 @@ export {
4407
4450
  AuthFootnote,
4408
4451
  AuthHeader,
4409
4452
  AuthLogo,
4453
+ AuthProvider,
4410
4454
  AuthShell,
4411
4455
  Badge,
4412
4456
  Button,
@@ -4482,6 +4526,8 @@ export {
4482
4526
  PostStatusBadge,
4483
4527
  ResponsiveSizeDeviceIcon,
4484
4528
  ResponsiveSizeField,
4529
+ RootProvider,
4530
+ SWRProvider,
4485
4531
  SearchBar,
4486
4532
  Select,
4487
4533
  SelectContent,
@@ -4520,9 +4566,9 @@ export {
4520
4566
  badgeVariants,
4521
4567
  buttonVariants,
4522
4568
  cn,
4569
+ useAuth,
4523
4570
  useColorPicker,
4524
- useDisclosure,
4525
- usePagination,
4571
+ useFetch,
4526
4572
  useTheme2 as useTheme
4527
4573
  };
4528
4574
  //# sourceMappingURL=index.mjs.map