UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines 2.44 kB
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/base-ui/Drawer/constants.ts"],"sourcesContent":["import type { MotionProps } from 'motion/react';\n\nimport type { DrawerPlacement } from './type';\n\ntype CubicBezier = [number, number, number, number];\n\nconst softEase: CubicBezier = [0.32, 0.72, 0, 1];\nconst exitEase: CubicBezier = [0.4, 0, 1, 1];\n\nexport const DEFAULT_PUSH_DISTANCE = 180;\nexport const DEFAULT_SIDEBAR_WIDTH = 280;\nexport const DEFAULT_CONTAINER_MAX_WIDTH = 1024;\nexport const DEFAULT_DRAWER_WIDTH = 378;\nexport const DEFAULT_DRAWER_HEIGHT = 378;\n\nconst offscreen: Record<DrawerPlacement, MotionProps['initial']> = {\n bottom: { y: '100%' },\n left: { x: '-100%' },\n right: { x: '100%' },\n top: { y: '-100%' },\n};\n\nexport const pushAxis: Record<DrawerPlacement, { axis: 'x' | 'y'; sign: 1 | -1 }> = {\n bottom: { axis: 'y', sign: -1 },\n left: { axis: 'x', sign: 1 },\n right: { axis: 'x', sign: -1 },\n top: { axis: 'y', sign: 1 },\n};\n\nexport const getDrawerMotionConfig = (\n placement: DrawerPlacement,\n pushOffset = 0,\n): MotionProps & { animate: { x: number; y: number } } => {\n const hidden = offscreen[placement];\n const { axis, sign } = pushAxis[placement];\n const shift = pushOffset === 0 ? 0 : pushOffset * sign;\n\n return {\n animate: axis === 'x' ? { x: shift, y: 0 } : { x: 0, y: shift },\n exit: {\n ...(hidden as object),\n transition: { duration: 0.22, ease: exitEase },\n },\n initial: hidden,\n transition: { duration: 0.3, ease: softEase },\n };\n};\n\nexport const drawerBackdropTransition = {\n duration: 0.18,\n ease: softEase,\n};\n"],"mappings":";AAMA,MAAM,WAAwB;CAAC;CAAM;CAAM;CAAG;AAAC;AAC/C,MAAM,WAAwB;CAAC;CAAK;CAAG;CAAG;AAAC;AAI3C,MAAa,8BAA8B;AAI3C,MAAM,YAA6D;CACjE,QAAQ,EAAE,GAAG,OAAO;CACpB,MAAM,EAAE,GAAG,QAAQ;CACnB,OAAO,EAAE,GAAG,OAAO;CACnB,KAAK,EAAE,GAAG,QAAQ;AACpB;AAEA,MAAa,WAAuE;CAClF,QAAQ;EAAE,MAAM;EAAK,MAAM;CAAG;CAC9B,MAAM;EAAE,MAAM;EAAK,MAAM;CAAE;CAC3B,OAAO;EAAE,MAAM;EAAK,MAAM;CAAG;CAC7B,KAAK;EAAE,MAAM;EAAK,MAAM;CAAE;AAC5B;AAEA,MAAa,yBACX,WACA,aAAa,MAC2C;CACxD,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,MAAM,SAAS,SAAS;CAChC,MAAM,QAAQ,eAAe,IAAI,IAAI,aAAa;CAElD,OAAO;EACL,SAAS,SAAS,MAAM;GAAE,GAAG;GAAO,GAAG;EAAE,IAAI;GAAE,GAAG;GAAG,GAAG;EAAM;EAC9D,MAAM;GACJ,GAAI;GACJ,YAAY;IAAE,UAAU;IAAM,MAAM;GAAS;EAC/C;EACA,SAAS;EACT,YAAY;GAAE,UAAU;GAAK,MAAM;EAAS;CAC9C;AACF;AAEA,MAAa,2BAA2B;CACtC,UAAU;CACV,MAAM;AACR"}