@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 1.52 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/DraggablePanel/utils.ts"],"sourcesContent":["import type { Size } from 're-resizable';\n\nimport type { DraggablePanelProps } from './type';\n\ninterface IsBelowCollapseThresholdOptions {\n axis: 'height' | 'width';\n collapseThreshold?: number;\n size: Size;\n}\n\nexport const isBelowCollapseThreshold = ({\n axis,\n collapseThreshold,\n size,\n}: IsBelowCollapseThresholdOptions): boolean => {\n if (collapseThreshold === undefined) return false;\n\n const currentSize = size[axis];\n if (currentSize === undefined) return false;\n\n const numericSize =\n typeof currentSize === 'number' ? currentSize : Number.parseFloat(currentSize);\n\n return Number.isFinite(numericSize) && numericSize <= Math.max(collapseThreshold, 0);\n};\n\nexport const reversePlacement = (placement: DraggablePanelProps['placement']) => {\n switch (placement) {\n case 'bottom': {\n return 'top';\n }\n case 'top': {\n return 'bottom';\n }\n case 'right': {\n return 'left';\n }\n case 'left': {\n return 'right';\n }\n }\n};\n"],"mappings":";AAUA,MAAa,4BAA4B,EACvC,MACA,mBACA,WAC8C;CAC9C,IAAI,sBAAsB,KAAA,GAAW,OAAO;CAE5C,MAAM,cAAc,KAAK;CACzB,IAAI,gBAAgB,KAAA,GAAW,OAAO;CAEtC,MAAM,cACJ,OAAO,gBAAgB,WAAW,cAAc,OAAO,WAAW,WAAW;CAE/E,OAAO,OAAO,SAAS,WAAW,KAAK,eAAe,KAAK,IAAI,mBAAmB,CAAC;AACrF;AAEA,MAAa,oBAAoB,cAAgD;CAC/E,QAAQ,WAAR;EACE,KAAK,UACH,OAAO;EAET,KAAK,OACH,OAAO;EAET,KAAK,SACH,OAAO;EAET,KAAK,QACH,OAAO;CAEX;AACF"}