element-plus
Version:
A Component Library for Vue 3
1 lines • 2.35 kB
Source Map (JSON)
{"version":3,"file":"build-modifiers.mjs","sources":["../../../../../../../packages/components/popper/src/use-popper/build-modifiers.ts"],"sourcesContent":["import type { StrictModifiers, Placement } from '@popperjs/core'\n\ninterface ModifierProps {\n offset?: number\n arrow?: HTMLElement\n arrowOffset?: number\n gpuAcceleration?: boolean\n fallbackPlacements?: Array<Placement>\n}\n\nexport default function buildModifier(\n props: ModifierProps,\n externalModifiers: StrictModifiers[] = []\n) {\n const { arrow, arrowOffset, offset, gpuAcceleration, fallbackPlacements } =\n props\n\n const modifiers: Array<StrictModifiers> = [\n {\n name: 'offset',\n options: {\n offset: [0, offset ?? 12],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n padding: {\n top: 2,\n bottom: 2,\n left: 5,\n right: 5,\n },\n },\n },\n {\n name: 'flip',\n options: {\n padding: 5,\n fallbackPlacements: fallbackPlacements ?? [],\n },\n },\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration,\n adaptive: gpuAcceleration,\n },\n },\n // tippyModifier,\n ]\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrow,\n // the arrow size is an equailateral triangle with 10px side length, the 3rd side length ~ 14.1px\n // adding a offset to the ceil of 4.1 should be 5 this resolves the problem of arrow overflowing out of popper.\n padding: arrowOffset ?? 5,\n },\n })\n }\n\n modifiers.push(...externalModifiers)\n return modifiers\n}\n"],"names":[],"mappings":"uBAWE,OACA,oBAAuC,IACvC;AACA,QAAM,EAAE,OAAO,aAAa,QAAQ,iBAAiB,uBACnD;AAEF,QAAM,YAAoC;AAAA,IACxC;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,QACP,QAAQ,CAAC,GAAG,0BAAU;AAAA;AAAA;AAAA,IAG1B;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,QACP,SAAS;AAAA,UACP,KAAK;AAAA,UACL,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,OAAO;AAAA;AAAA;AAAA;AAAA,IAIb;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,QACP,SAAS;AAAA,QACT,oBAAoB,kDAAsB;AAAA;AAAA;AAAA,IAG9C;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,QACP;AAAA,QACA,UAAU;AAAA;AAAA;AAAA;AAMhB,MAAI,OAAO;AACT,cAAU,KAAK;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,QACP,SAAS;AAAA,QAGT,SAAS,oCAAe;AAAA;AAAA;AAAA;AAK9B,YAAU,KAAK,GAAG;AAClB,SAAO;AAAA;;;;"}