amotify
Version:
UI Component for React,NextJS,esbuild
75 lines (74 loc) • 2.71 kB
TypeScript
import $$, { Time } from 'jmini';
import { StyleProps, ReactElement } from '../@declares';
import React from 'react';
import { Box } from '../atoms';
declare namespace Sheet {
type Type = 'topLeft' | 'topCenter' | 'topRight' | 'middleLeft' | 'middleCenter' | 'middleRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'drawer.left' | 'drawer.right' | 'drawer.bottom' | 'custom';
type Sizes = 'XS' | 'S' | 'R' | 'L' | '2L' | '3L' | 'MAX';
type Methods = {
Wrapper(): React.JSX.Element;
Element<P = any>(p: Omit<Input<P>, 'content'> & {
type: Type;
isOpen: boolean;
children: Content<P>;
}): ReactElement;
image(params: Omit<Input, 'content'>, src: string | string[]): void;
open<P = any>(type: Type, params: Input<P>, defaultOpen?: boolean | 'inherit'): void;
update<P = any>(sheetID: string, params: Partial<Input<P>>): void;
customSheet: {
reposition(sheetID: string): void;
};
close(key: string, eventType?: 'Escape' | 'pageTransit', force?: boolean): void;
closeGroup(keyGroup: string): void;
closeAll(pageTransit?: boolean): void;
Body: React.FC<Box.DefaultInput>;
};
type Input<P = any> = {
type?: Type;
props?: P;
sheetID?: string;
size?: Sizes;
content: Content<P>;
sheetGroups?: string | string[];
backgroundEffect?: boolean;
overwrap?: boolean;
hold_state?: boolean;
bodyScrolls?: number;
wrapperClassName?: string;
onOpen?(): void;
onClose?(): void;
/**
* optional for type:custom
*/
resize?: boolean;
nextToCursor?: boolean;
gravityPoint?: number;
event?: any;
parent?: $$.Args;
/**
* optional for type:drawer.bottom
*/
sizeChanged?(size: Sizes): void;
baseStyles?: StyleProps.States;
} & StyleProps.BasicElement & CloseOptions;
type Content<T = any> = ReactElement | ((props: T) => React.JSX.Element);
type CloseOptions = {
closeAtPageTransit?: boolean;
closeAtEscapeKeyDown?: boolean;
closeAtAroundClick?: boolean;
closeAtParentBlur?: boolean;
closeAtSwipeDown?: boolean;
};
type CoreProps = {
sheetID: string;
isOpen: boolean;
created_at: Time.Chains;
};
type SheetContent = CoreProps & Sheet.Input;
type WrapperStates = {
val_sheets: SheetContent[];
set_sheets: React.Dispatch<React.SetStateAction<SheetContent[]>>;
};
}
declare const Sheet: Sheet.Methods;
export { Sheet, Sheet as default };