tw-react-components 0.0.150 → 0.0.152

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/index.esm.js CHANGED
@@ -3,10 +3,10 @@ import { forwardRef, useMemo, useState, useEffect, useId, useCallback, useRef, c
3
3
  import { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
5
5
  import dayjs from 'dayjs';
6
- import advancedFormat from 'dayjs/plugin/advancedFormat';
6
+ import advancedFormat from 'dayjs/plugin/advancedFormat.js';
7
7
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
8
8
  import { HelpCircle, XIcon, AtSignIcon, EyeIcon, EyeOffIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon, CalendarIcon, ClockIcon, CheckIcon, CircleIcon, CloudUploadIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsDownUpIcon, ChevronsUpDownIcon, ArrowUpDownIcon, SortAscIcon, SortDescIcon, MinusIcon, PlusIcon, PanelLeft, MoonIcon, SunIcon, MonitorIcon } from 'lucide-react';
9
- import localeData from 'dayjs/plugin/localeData';
9
+ import localeData from 'dayjs/plugin/localeData.js';
10
10
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
11
11
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
12
12
  import { useFormContext, Controller, FormProvider } from 'react-hook-form';
@@ -1790,7 +1790,7 @@ const SidebarContextProvider = forwardRef((_a, ref) => {
1790
1790
  var { defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children } = _a, props = __rest(_a, ["defaultOpen", "open", "onOpenChange", "className", "style", "children"]);
1791
1791
  const isMobile = useIsMobile();
1792
1792
  const [openMobile, setOpenMobile] = useState(false);
1793
- const screenRef = useRef(document.documentElement);
1793
+ const screenRef = useRef(typeof document === 'undefined' ? null : document.documentElement);
1794
1794
  // This is the internal state of the sidebar.
1795
1795
  // We use openProp and setOpenProp for control from outside the component.
1796
1796
  const [_open, _setOpen] = useState(getValueFromCookie(SIDEBAR_COOKIE_NAME, defaultOpen));
@@ -2112,8 +2112,8 @@ const THEME_COOKIE_NAME = 'theme:state';
2112
2112
  const THEME_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
2113
2113
  const SHOW_IDS_COOKIE_NAME = 'show-ids:state';
2114
2114
  const SHOW_IDS_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
2115
- const LayoutContextProvider = ({ children }) => {
2116
- const [theme, _setTheme] = useState(getValueFromCookie(THEME_COOKIE_NAME, 'system'));
2115
+ const LayoutContextProvider = ({ children, defaultTheme, }) => {
2116
+ const [theme, _setTheme] = useState(defaultTheme !== null && defaultTheme !== void 0 ? defaultTheme : getValueFromCookie(THEME_COOKIE_NAME, 'system'));
2117
2117
  const [showIds, _setShowIds] = useState(getValueFromCookie(SHOW_IDS_COOKIE_NAME, false));
2118
2118
  const [resolvedTheme, setResolvedTheme] = useState(() => theme === 'system' ? getSystemTheme() : theme);
2119
2119
  useEffect(() => {
@@ -2156,6 +2156,8 @@ function useLayoutContext() {
2156
2156
  return context;
2157
2157
  }
2158
2158
  function getSystemTheme(e) {
2159
+ if (typeof window === 'undefined')
2160
+ return 'light';
2159
2161
  if (!e)
2160
2162
  e = window.matchMedia(THEME_MEDIA_QUERY);
2161
2163
  return e.matches ? 'dark' : 'light';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tw-react-components",
3
3
  "description": "A set of React components build with TailwindCSS to make a nice dashboard.",
4
- "version": "0.0.150",
4
+ "version": "0.0.152",
5
5
  "license": "MIT",
6
6
  "homepage": "https://bacali95.github.io/tw-react-components",
7
7
  "type": "module",
@@ -13,5 +13,7 @@ export declare const THEME_COOKIE_NAME = "theme:state";
13
13
  export declare const THEME_COOKIE_MAX_AGE: number;
14
14
  export declare const SHOW_IDS_COOKIE_NAME = "show-ids:state";
15
15
  export declare const SHOW_IDS_COOKIE_MAX_AGE: number;
16
- export declare const LayoutContextProvider: FC<PropsWithChildren>;
16
+ export declare const LayoutContextProvider: FC<PropsWithChildren<{
17
+ defaultTheme?: ThemeState;
18
+ }>>;
17
19
  export declare function useLayoutContext(): LayoutContext;