UXF Core
Cookie
- Cookie options
secure?: boolean;
httpOnly?: boolean;
path?: string;
import { Cookie } from "@uxf/core/cookie";
const cookie = Cookie.create();
const cookie = Cookie.create(ctx);
cookie.has("cookie-name");
cookie.get("cookie-name");
cookie.set("cookie-name", "value", , )
cookie.delete("cookie-name", );
Hooks
import { useBodyScrollLock } from "@uxf/core/hooks/useBodyScrollLock";
const [isOpen, setIsOpen] = useState<boolean>();
const scrollLockTargetRef = useBodyScrollLock<HTMLDivElement>(isOpen);
<div ref={scrollLockTargetRef}>Element with scroll lock outside</div>
import { useIsMounted } from "@uxf/core/hooks/useIsMounted";
const isMounted = useIsMounted();
import { useIsomorphicLayoutEffect } from "@uxf/core/hooks/useIsomorphicLayoutEffect";
useIsomorphicLayoutEffect(() => {}, []);
import { useMinWindowWidth } from "@uxf/core/hooks/useMinWindowWidth";
const isDesktop = useMinWindowWidth(992 , 1280 );
import { useRafState } from "@uxf/core/hooks/useRafState";
const [state, setState] = useRafState<boolean>(false);
import { useUnmount } from "@uxf/core/hooks/useUnmount";
const exampleCallback = () => {};
useUnmount(exampleCallback());
import { useUpdateEffect } from "@uxf/core/hooks/useUpdateEffect";
useUpdateEffect(() => {}, []);
import { useWindowSize } from "@uxf/core/hooks/useWindowSize";
const { width, height } = useWindowSize(1280 , 800 );
Next
import { queryParamToString, queryParamToNumber } from "@uxf/core/next";
queryParamToNumber(ctx.query.id);
queryParamToString(ctx.query.name);
Utils
import { cameCaseToDash } from "@uxf/core/utils/cameCaseToDash";
const example = cameCaseToDash("fooBar")
import { composeRefs } from "@uxf/core/utils/composeRefs";
const firstRef = useRef<HTMLDivElement>(null);
const secondRef = useRef<HTMLDivElement>(null);
const example = <div ref={composeRefs(firstRef, secondRef)} />;
import { isBrowser } from "@uxf/core/utils/isBrowser";
import { isServer } from "@uxf/core/utils/isServer";
const browserExample = isBrowser
const serverExample = isServer
import { slugify } from "@uxf/core/utils/slugify";
const example = slugify("Jak se dnes máte?")
import { trimTrailingZeros } from "@uxf/core/utils/trimTrailingZeros";
const example = trimTrailingZeros("120,450")
Validators
import { Validator } from "@uxf/core";
Validator.isEmail("...");
Validator.isPhone("...");