This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { getContext, setContext } from "svelte"; | |
| /** | |
| * The context object. | |
| */ | |
| export interface Context<T> { | |
| get: () => T; | |
| set: (ctx: T) => T; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use client'; | |
| import { useEffect, useState } from 'react'; | |
| type ColorScheme = 'light' | 'dark'; | |
| const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); | |
| function getPreferredColorScheme(matches: boolean): ColorScheme { | |
| return matches ? 'dark' : 'light'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { type PropsWithChildren, useEffect, useState } from 'react'; | |
| import { createPortal } from 'react-dom'; | |
| type PortalProps = PropsWithChildren & { targetId: string }; | |
| export function Portal({ children, targetId }: PortalProps) { | |
| const [targetElement, setTargetElement] = useState<HTMLElement | null>(null); | |
| useEffect(() => { | |
| const updateTargetElement = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { isEqual } from 'lodash-es'; | |
| import { useEffect, useRef, useState } from 'react'; | |
| /** | |
| * Checks if a passed value has changed based on the provided equality function and returns the old instance of the | |
| * value if it has not changed. | |
| * | |
| * @param value The value that is compared. | |
| * @param equalFn A function that compares the old and the new value. Defaults to `lodash.isEqual`. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { RefObject, useCallback, useEffect, useState } from 'react'; | |
| export interface ScrollToOptions { | |
| x?: number; | |
| y?: number; | |
| behavior?: ScrollBehavior; | |
| } | |
| export interface UseScrollOptions { | |
| disabled?: boolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.redigital.rebased.ext.flow | |
| import arrow.core.None | |
| import arrow.core.Option | |
| import arrow.core.some | |
| import kotlinx.coroutines.flow.Flow | |
| import kotlinx.coroutines.flow.transform | |
| fun <T> Flow<T>.dedup(): Flow<T> = dedupBy { it } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlinx.coroutines.coroutineScope | |
| import kotlinx.coroutines.delay | |
| import kotlinx.coroutines.flow.Flow | |
| import kotlinx.coroutines.flow.channelFlow | |
| import kotlinx.coroutines.isActive | |
| import kotlinx.coroutines.launch | |
| import kotlinx.coroutines.sync.Mutex | |
| import kotlinx.coroutines.sync.withLock | |
| import kotlin.time.Duration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { type RefObject, useEffect, useState } from 'react'; | |
| function checkOverflow(el: HTMLElement | null): boolean { | |
| if (!el) return false; | |
| return el.offsetHeight < el.scrollHeight || el.offsetWidth < el.scrollWidth; | |
| } | |
| export function useHasOverflow(ref: RefObject<HTMLElement | null>) { | |
| const [overflow, setOverflow] = useState(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useCallback, useEffect, useRef, useState } from 'react'; | |
| function wrapArray<T>(value: T | T[]): T[] { | |
| return Array.isArray(value) ? value : [value]; | |
| } | |
| type UseFileOnSelectCallbackArg<TMultiple extends boolean | undefined> = | |
| TMultiple extends true ? FileList : File; | |
| type UseFileOnSelectCallback<TMultiple extends boolean | undefined = false> = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useCallback } from 'react'; | |
| export function useDownload() { | |
| return useCallback((obj: Blob | MediaSource, filename: string) => { | |
| const url = URL.createObjectURL(obj); | |
| const link = document.createElement('a'); | |
| link.href = url; | |
| if (filename) { |
NewerOlder