amotify
Version:
UI Component for React,NextJS,esbuild
95 lines (94 loc) • 3.08 kB
TypeScript
import $$, { Time } from 'jmini';
import { StyleTags, ReactElement } from '../@declares';
import React from 'react';
import { Box } from '../atoms';
declare namespace Sheet {
type Methods = {
Wrapper(): JSX.Element;
Element(p: Omit<Input, 'content'> & {
isOpen: boolean;
children: ReactElement;
}): ReactElement;
open<T extends Input>(p: T, defaultOpen?: boolean | 'inherit'): void;
resize(p: {
sheetID: string;
size: Size;
}): 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 = Normal | Edge | Custom | Image | Bottom.Input;
type UniInput = {
sheetID?: string;
size?: Size;
sheetGroups?: string | string[];
backgroundEffect?: boolean;
overwrap?: boolean;
hold_state?: boolean;
bodyScrolls?: number;
openAfter?(): void;
closeAfter?(): void;
} & StyleTags.BasicElement & CloseOptions;
type Size = 'S' | 'R' | 'L' | '2L' | '3L' | 'MAX';
type Content = ReactElement | (() => JSX.Element);
type CloseOptions = {
closeAtPageTransit?: boolean;
closeAtEscapeKeyDown?: boolean;
closeAtAroundClick?: boolean;
closeAtParentBlur?: boolean;
closeAtSwipeDown?: boolean;
};
type Sheet = 'normal.topLeft' | 'normal.topCenter' | 'normal.topRight' | 'normal.middleLeft' | 'normal.middleCenter' | 'normal.middleRight' | 'normal.bottomLeft' | 'normal.bottomCenter' | 'normal.bottomRight' | 'drawer.left' | 'drawer.right' | 'drawer.bottom' | 'custom' | 'image';
type Normal = UniInput & {
type: Sheet;
content: Content;
};
type Edge = UniInput & {
type: Sheet;
content: Content;
};
type Custom = UniInput & {
type: 'custom';
content: Content;
resize?: boolean;
nextToCursor?: boolean;
gravityPoint?: number;
} & ({
event: any;
parent?: $$.Args;
} | {
event?: any;
parent: $$.Args;
});
type Image = UniInput & {
type: 'image';
src: string | string[];
};
namespace Bottom {
type Sizes = 'S' | 'R' | 'L';
type Input = UniInput & {
type: 'drawer.bottom';
content: Content;
size: Sizes;
sizeChanged?(size: Sizes): void;
baseStyles?: StyleTags.States;
};
}
type CoreProps = {
sheetID: string;
isOpen: boolean;
created_at: Time.Chains;
};
type SheetContent = Sheet.Input & CoreProps;
type WrapperStates = {
val_sheets: SheetContent[];
set_sheets: React.Dispatch<React.SetStateAction<SheetContent[]>>;
};
}
declare const Sheet: Sheet.Methods;
export { Sheet, Sheet as default };