@vitus-labs/core
Version:
Core and utility functions for vitus-labs packages
218 lines (180 loc) • 11.6 kB
TypeScript
import { cloneElement } from 'react';
import type { ComponentType } from 'react';
import { createElement } from 'react';
import { css } from 'styled-components';
import type { FC } from 'react';
import { get } from 'lodash-es';
import memoize from 'moize';
import { merge } from 'lodash-es';
import { omit } from 'lodash-es';
import { pick } from 'lodash-es';
import * as React_2 from 'react';
import { default as React_3 } from 'react';
import type { ReactNode } from 'react';
import { set } from 'lodash-es';
import { styled } from 'styled-components';
import { ThemeProvider } from 'styled-components';
import { throttle } from 'lodash-es';
declare type ArityOneFn = (arg: any) => any;
declare type Base = React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLElement>, HTMLElement>;
export declare type BreakpointKeys = keyof Breakpoints;
export declare type Breakpoints = Record<string, number>;
declare type CloneTypes = Parameters<typeof cloneElement>[0];
export declare const compose: <T extends ArityOneFn[]>(...fns: T) => (p: FirstFnParameterType<T>) => LastFnReturnType<T>;
export declare const config: Configuration;
declare class Configuration {
css: Internal['css'];
styled: Internal['styled'];
ExternalProvider: Internal['provider'];
component: Internal['component'];
textComponent: Internal['textComponent'];
constructor(props: Internal);
init: (props: Partial<Internal>) => void;
}
export declare const context: React_3.Context<any>;
declare type CreateTypes = Parameters<typeof createElement>[0];
declare type FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any];
export { get }
export declare const HTML_TAGS: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "meter", "nav", "object", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "small", "source", "span", "strong", "sub", "summary", "sup", "svg", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "u", "ul", "var", "video", "wbr"];
export declare const HTML_TEXT_TAGS: readonly ["abbr", "b", "bdi", "bdo", "big", "blockquote", "cite", "code", "dl", "dt", "em", "figcaption", "h1", "h2", "h3", "h4", "h5", "h6", "i", "ins", "kbd", "label", "legend", "li", "p", "pre", "q", "rp", "rt", "s", "small", "span", "strong", "sub", "summary", "sup", "time", "u"];
export declare interface HTMLElementAttrs {
a: React_2.DetailedHTMLProps<React_2.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
abbr: Base;
address: Base;
area: React_2.DetailedHTMLProps<React_2.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
article: Base;
aside: Base;
audio: React_2.DetailedHTMLProps<React_2.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
b: Base;
bdi: Base;
bdo: Base;
big: Base;
blockquote: React_2.DetailedHTMLProps<React_2.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
body: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
br: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
button: React_2.DetailedHTMLProps<React_2.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
canvas: React_2.DetailedHTMLProps<React_2.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
caption: Base;
cite: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
code: Base;
col: React_2.DetailedHTMLProps<React_2.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
colgroup: React_2.DetailedHTMLProps<React_2.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
data: React_2.DetailedHTMLProps<React_2.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
datalist: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
dd: Base;
del: React_2.DetailedHTMLProps<React_2.DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
details: Base;
dfn: Base;
dialog: React_2.DetailedHTMLProps<React_2.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
div: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
dl: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
dt: Base;
em: Base;
embed: React_2.DetailedHTMLProps<React_2.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
fieldset: React_2.DetailedHTMLProps<React_2.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
figcaption: Base;
figure: Base;
footer: Base;
form: React_2.DetailedHTMLProps<React_2.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
h1: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
h2: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
h3: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
h4: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
h5: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
h6: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
header: Base;
hr: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
html: React_2.DetailedHTMLProps<React_2.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
i: Base;
iframe: React_2.DetailedHTMLProps<React_2.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
img: React_2.DetailedHTMLProps<React_2.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
input: React_2.DetailedHTMLProps<React_2.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
ins: React_2.DetailedHTMLProps<React_2.InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
kbd: Base;
label: React_2.DetailedHTMLProps<React_2.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
legend: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
li: React_2.DetailedHTMLProps<React_2.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
main: Base;
map: React_2.DetailedHTMLProps<React_2.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
mark: Base;
meter: Base;
nav: Base;
object: React_2.DetailedHTMLProps<React_2.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
ol: React_2.DetailedHTMLProps<React_2.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
optgroup: React_2.DetailedHTMLProps<React_2.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
option: React_2.DetailedHTMLProps<React_2.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
output: Base;
p: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
picture: Base;
pre: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
progress: React_2.DetailedHTMLProps<React_2.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
q: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
rp: Base;
rt: Base;
ruby: Base;
s: Base;
samp: Base;
section: Base;
select: React_2.DetailedHTMLProps<React_2.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
small: Base;
source: React_2.DetailedHTMLProps<React_2.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
span: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
strong: Base;
sub: Base;
summary: Base;
sup: Base;
svg: React_2.SVGProps<SVGSVGElement>;
table: React_2.DetailedHTMLProps<React_2.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
tbody: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
td: React_2.DetailedHTMLProps<React_2.TdHTMLAttributes<HTMLTableCellElement>, HTMLTableCellElement>;
template: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
textarea: React_2.DetailedHTMLProps<React_2.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
tfoot: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
th: React_2.DetailedHTMLProps<React_2.ThHTMLAttributes<HTMLTableCellElement>, HTMLTableCellElement>;
thead: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
time: Base;
tr: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
track: React_2.DetailedHTMLProps<React_2.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
u: Base;
ul: React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
var: Base;
video: React_2.DetailedHTMLProps<React_2.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
wbr: Base;
}
export declare type HTMLTagAttrsByTag<T extends HTMLTags> = T extends HTMLTags ? HTMLElementAttrs[T] : {};
export declare type HTMLTags = (typeof HTML_TAGS)[number];
export declare type HTMLTextTags = (typeof HTML_TEXT_TAGS)[number];
export declare const init: (props: Partial<Internal>) => void;
declare interface Internal {
css: typeof css;
styled: typeof styled;
provider: typeof ThemeProvider;
component: ComponentType | HTMLTags;
textComponent: ComponentType | HTMLTags;
}
export declare type IsEmpty = <T extends Record<number | string, any> | any[] | null | undefined>(param: T) => T extends null | undefined ? true : keyof T extends never ? true : T extends T[] ? T[number] extends never ? true : false : false;
export declare const isEmpty: IsEmpty;
declare type LastFnReturnType<T extends any[]> = ReturnType<T[0]>;
export { memoize }
export { merge }
export { omit }
export { pick }
declare type PickLastInTuple<T extends any[]> = T extends [
...rest: infer U,
argn: infer L
] ? L : any;
export declare const Provider: FC<ProviderType>;
declare type ProviderType = Partial<{
theme: Theme;
children: ReactNode;
} & Record<string, any>>;
export declare type Render = <T extends Record<string, any> | undefined>(content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>, attachProps?: T) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null;
export declare const render: Render;
declare type RenderProps<T extends Record<string, unknown> | undefined> = (props: Partial<T>) => ReactNode;
export { set }
declare type Theme = Partial<{
rootSize: number;
breakpoints: Breakpoints;
} & Record<string, any>>;
export { throttle }
export { }