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
const Register: FC = props => { | |
const formRef = useRef<ImperativeHandleProps>(null!); | |
return ( | |
<Fragment> | |
<Form ref={formRef} /> | |
<button onClick={() => formRef.current.onSomePropFired()}> | |
sbt form | |
</button> | |
</Fragment> | |
); |
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
function isPropsForTextareaElement( | |
props: InputProps | TextareaProps | |
): props is TextareaProps { | |
return "rows" in props; | |
} | |
export const TextareaInputGeneralComponent = ( | |
props: InputProps | TextareaProps | |
) => { | |
if (isPropsForTextareaElement(props)) { |
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 React from "react"; | |
// * modules | |
import classnames from "classnames"; | |
import { Tooltip } from "antd"; | |
// define all text types | |
type VariantProps = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p"; | |
type LineheightProps = | |
| "none" |
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 { useState, RefObject, useLayoutEffect } from "react"; | |
import useWindowSize from "./useWindowSize"; | |
export function useOverflow( | |
ref: RefObject<HTMLElement> | |
): { | |
refXOverflowing: boolean; | |
refYOverflowing: boolean; | |
refXScrollBegin: 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
export const composableHoc = (prop: string) => { | |
return function <T>(Component: ComponentType<T>) { | |
return function (props: T): JSX.Element { | |
return <Component {...props} />; | |
}; | |
}; | |
}; |
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
export const accesKeys = { | |
guest: { | |
home: true, | |
users: true, | |
user: true, | |
}, | |
}; |
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 { PartialDeep } from "type-fest"; | |
export type RouteConfigProps = PartialDeep<{ | |
layout: { | |
include: boolean; | |
topbar: boolean; | |
}; | |
accessKey: string; | |
}>; | |
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
type PathImpl<T, K extends keyof T> = K extends string | |
? T[K] extends Record<string, any> | |
? T[K] extends ArrayLike<any> | |
? K | `${K}.${PathImpl<T[K], Exclude<keyof T[K], keyof any[]>>}` | |
: K | `${K}.${PathImpl<T[K], keyof T[K]>}` | |
: K | |
: never; | |
type Path<T> = PathImpl<T, keyof T> | keyof 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
/* picked from cypress-realworld-app */ | |
import Fuse from "fuse.js"; | |
import { flow, map, curry } from "lodash/fp"; | |
type IItems = { | |
title: string; | |
body: string; | |
}; | |
export const performSearch = (items: object[], options: {}, query: string) => |
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 flat, { unflatten } from "flat"; | |
import { reduceRight } from "lodash"; | |
import { | |
pipe, | |
reject, | |
isNil, | |
isEqual, | |
get, | |
fromPairs, | |
entries, |