Remove no longer used tools
This commit is contained in:
@ -1 +0,0 @@
|
|||||||
export type SetOptional<T extends Record<string, unknown>, K extends keyof T> = Omit<T, K> & Partial<Record<K, T[K]>>;
|
|
@ -1,5 +0,0 @@
|
|||||||
import "minimal-polyfills/Object.fromEntries";
|
|
||||||
|
|
||||||
export function allPropertiesValuesToUndefined<T extends Record<string, unknown>>(obj: T): Record<keyof T, undefined> {
|
|
||||||
return Object.fromEntries(Object.entries(obj).map(([key]) => [key, undefined])) as any;
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
import { useRef, useState } from "react";
|
|
||||||
import { id } from "tsafe/id";
|
|
||||||
import { memoize } from "./memoize";
|
|
||||||
|
|
||||||
export type CallbackFactory<FactoryArgs extends unknown[], Args extends unknown[], R> = (...factoryArgs: FactoryArgs) => (...args: Args) => R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://docs.powerhooks.dev/api-reference/usecallbackfactory
|
|
||||||
*
|
|
||||||
* const callbackFactory= useCallbackFactory(
|
|
||||||
* ([key]: [string], [params]: [{ foo: number; }]) => {
|
|
||||||
* ...
|
|
||||||
* },
|
|
||||||
* []
|
|
||||||
* );
|
|
||||||
*
|
|
||||||
* WARNING: Factory args should not be of variable length.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export function useCallbackFactory<FactoryArgs extends (string | number | boolean)[], Args extends unknown[], R = void>(
|
|
||||||
callback: (...callbackArgs: [FactoryArgs, Args]) => R
|
|
||||||
): CallbackFactory<FactoryArgs, Args, R> {
|
|
||||||
type Out = CallbackFactory<FactoryArgs, Args, R>;
|
|
||||||
|
|
||||||
const callbackRef = useRef<typeof callback>(callback);
|
|
||||||
|
|
||||||
callbackRef.current = callback;
|
|
||||||
|
|
||||||
const memoizedRef = useRef<Out | undefined>(undefined);
|
|
||||||
|
|
||||||
return useState(() =>
|
|
||||||
id<Out>((...factoryArgs) => {
|
|
||||||
if (memoizedRef.current === undefined) {
|
|
||||||
memoizedRef.current = memoize(
|
|
||||||
(...factoryArgs: FactoryArgs) =>
|
|
||||||
(...args: Args) =>
|
|
||||||
callbackRef.current(factoryArgs, args),
|
|
||||||
{ "argsLength": factoryArgs.length }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return memoizedRef.current(...factoryArgs);
|
|
||||||
})
|
|
||||||
)[0];
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
import { clsx as cx } from "./clsx";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated: Use clsx instead.
|
|
||||||
* import { clsx } from "keycloakify/lib/tools/clsx";
|
|
||||||
* You can use clsx as cx.
|
|
||||||
* If you where using the css() function you can import
|
|
||||||
* it from @emotion/css: https://emotion.sh/docs/@emotion/css
|
|
||||||
*/
|
|
||||||
export function useCssAndCx() {
|
|
||||||
return { cx };
|
|
||||||
}
|
|
Reference in New Issue
Block a user