1 line
15 KiB
JSON
1 line
15 KiB
JSON
{"ast":null,"code":"import { getArrowOffsetToken } from '../style/placementArrow';\nexport function getOverflowOptions(placement, arrowOffset, arrowWidth, autoAdjustOverflow) {\n if (autoAdjustOverflow === false) {\n return {\n adjustX: false,\n adjustY: false\n };\n }\n const overflow = autoAdjustOverflow && typeof autoAdjustOverflow === 'object' ? autoAdjustOverflow : {};\n const baseOverflow = {};\n switch (placement) {\n case 'top':\n case 'bottom':\n baseOverflow.shiftX = arrowOffset.arrowOffsetHorizontal * 2 + arrowWidth;\n baseOverflow.shiftY = true;\n baseOverflow.adjustY = true;\n break;\n case 'left':\n case 'right':\n baseOverflow.shiftY = arrowOffset.arrowOffsetVertical * 2 + arrowWidth;\n baseOverflow.shiftX = true;\n baseOverflow.adjustX = true;\n break;\n }\n const mergedOverflow = Object.assign(Object.assign({}, baseOverflow), overflow);\n // Support auto shift\n if (!mergedOverflow.shiftX) {\n mergedOverflow.adjustX = true;\n }\n if (!mergedOverflow.shiftY) {\n mergedOverflow.adjustY = true;\n }\n return mergedOverflow;\n}\nconst PlacementAlignMap = {\n left: {\n points: ['cr', 'cl']\n },\n right: {\n points: ['cl', 'cr']\n },\n top: {\n points: ['bc', 'tc']\n },\n bottom: {\n points: ['tc', 'bc']\n },\n topLeft: {\n points: ['bl', 'tl']\n },\n leftTop: {\n points: ['tr', 'tl']\n },\n topRight: {\n points: ['br', 'tr']\n },\n rightTop: {\n points: ['tl', 'tr']\n },\n bottomRight: {\n points: ['tr', 'br']\n },\n rightBottom: {\n points: ['bl', 'br']\n },\n bottomLeft: {\n points: ['tl', 'bl']\n },\n leftBottom: {\n points: ['br', 'bl']\n }\n};\nconst ArrowCenterPlacementAlignMap = {\n topLeft: {\n points: ['bl', 'tc']\n },\n leftTop: {\n points: ['tr', 'cl']\n },\n topRight: {\n points: ['br', 'tc']\n },\n rightTop: {\n points: ['tl', 'cr']\n },\n bottomRight: {\n points: ['tr', 'bc']\n },\n rightBottom: {\n points: ['bl', 'cr']\n },\n bottomLeft: {\n points: ['tl', 'bc']\n },\n leftBottom: {\n points: ['br', 'cl']\n }\n};\nconst DisableAutoArrowList = new Set(['topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'leftTop', 'leftBottom', 'rightTop', 'rightBottom']);\nexport default function getPlacements(config) {\n const {\n arrowWidth,\n autoAdjustOverflow,\n arrowPointAtCenter,\n offset,\n borderRadius,\n visibleFirst\n } = config;\n const halfArrowWidth = arrowWidth / 2;\n const placementMap = {};\n Object.keys(PlacementAlignMap).forEach(key => {\n const template = arrowPointAtCenter && ArrowCenterPlacementAlignMap[key] || PlacementAlignMap[key];\n const placementInfo = Object.assign(Object.assign({}, template), {\n offset: [0, 0],\n dynamicInset: true\n });\n placementMap[key] = placementInfo;\n // Disable autoArrow since design is fixed position\n if (DisableAutoArrowList.has(key)) {\n placementInfo.autoArrow = false;\n }\n // Static offset\n switch (key) {\n case 'top':\n case 'topLeft':\n case 'topRight':\n placementInfo.offset[1] = -halfArrowWidth - offset;\n break;\n case 'bottom':\n case 'bottomLeft':\n case 'bottomRight':\n placementInfo.offset[1] = halfArrowWidth + offset;\n break;\n case 'left':\n case 'leftTop':\n case 'leftBottom':\n placementInfo.offset[0] = -halfArrowWidth - offset;\n break;\n case 'right':\n case 'rightTop':\n case 'rightBottom':\n placementInfo.offset[0] = halfArrowWidth + offset;\n break;\n }\n // Dynamic offset\n const arrowOffset = getArrowOffsetToken({\n contentRadius: borderRadius,\n limitVerticalRadius: true\n });\n if (arrowPointAtCenter) {\n switch (key) {\n case 'topLeft':\n case 'bottomLeft':\n placementInfo.offset[0] = -arrowOffset.arrowOffsetHorizontal - halfArrowWidth;\n break;\n case 'topRight':\n case 'bottomRight':\n placementInfo.offset[0] = arrowOffset.arrowOffsetHorizontal + halfArrowWidth;\n break;\n case 'leftTop':\n case 'rightTop':\n placementInfo.offset[1] = -arrowOffset.arrowOffsetHorizontal - halfArrowWidth;\n break;\n case 'leftBottom':\n case 'rightBottom':\n placementInfo.offset[1] = arrowOffset.arrowOffsetHorizontal + halfArrowWidth;\n break;\n }\n }\n // Overflow\n placementInfo.overflow = getOverflowOptions(key, arrowOffset, arrowWidth, autoAdjustOverflow);\n // VisibleFirst\n if (visibleFirst) {\n placementInfo.htmlRegion = 'visibleFirst';\n }\n });\n return placementMap;\n}","map":{"version":3,"names":["getArrowOffsetToken","getOverflowOptions","placement","arrowOffset","arrowWidth","autoAdjustOverflow","adjustX","adjustY","overflow","baseOverflow","shiftX","arrowOffsetHorizontal","shiftY","arrowOffsetVertical","mergedOverflow","Object","assign","PlacementAlignMap","left","points","right","top","bottom","topLeft","leftTop","topRight","rightTop","bottomRight","rightBottom","bottomLeft","leftBottom","ArrowCenterPlacementAlignMap","DisableAutoArrowList","Set","getPlacements","config","arrowPointAtCenter","offset","borderRadius","visibleFirst","halfArrowWidth","placementMap","keys","forEach","key","template","placementInfo","dynamicInset","has","autoArrow","contentRadius","limitVerticalRadius","htmlRegion"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/_util/placements.js"],"sourcesContent":["import { getArrowOffsetToken } from '../style/placementArrow';\nexport function getOverflowOptions(placement, arrowOffset, arrowWidth, autoAdjustOverflow) {\n if (autoAdjustOverflow === false) {\n return {\n adjustX: false,\n adjustY: false\n };\n }\n const overflow = autoAdjustOverflow && typeof autoAdjustOverflow === 'object' ? autoAdjustOverflow : {};\n const baseOverflow = {};\n switch (placement) {\n case 'top':\n case 'bottom':\n baseOverflow.shiftX = arrowOffset.arrowOffsetHorizontal * 2 + arrowWidth;\n baseOverflow.shiftY = true;\n baseOverflow.adjustY = true;\n break;\n case 'left':\n case 'right':\n baseOverflow.shiftY = arrowOffset.arrowOffsetVertical * 2 + arrowWidth;\n baseOverflow.shiftX = true;\n baseOverflow.adjustX = true;\n break;\n }\n const mergedOverflow = Object.assign(Object.assign({}, baseOverflow), overflow);\n // Support auto shift\n if (!mergedOverflow.shiftX) {\n mergedOverflow.adjustX = true;\n }\n if (!mergedOverflow.shiftY) {\n mergedOverflow.adjustY = true;\n }\n return mergedOverflow;\n}\nconst PlacementAlignMap = {\n left: {\n points: ['cr', 'cl']\n },\n right: {\n points: ['cl', 'cr']\n },\n top: {\n points: ['bc', 'tc']\n },\n bottom: {\n points: ['tc', 'bc']\n },\n topLeft: {\n points: ['bl', 'tl']\n },\n leftTop: {\n points: ['tr', 'tl']\n },\n topRight: {\n points: ['br', 'tr']\n },\n rightTop: {\n points: ['tl', 'tr']\n },\n bottomRight: {\n points: ['tr', 'br']\n },\n rightBottom: {\n points: ['bl', 'br']\n },\n bottomLeft: {\n points: ['tl', 'bl']\n },\n leftBottom: {\n points: ['br', 'bl']\n }\n};\nconst ArrowCenterPlacementAlignMap = {\n topLeft: {\n points: ['bl', 'tc']\n },\n leftTop: {\n points: ['tr', 'cl']\n },\n topRight: {\n points: ['br', 'tc']\n },\n rightTop: {\n points: ['tl', 'cr']\n },\n bottomRight: {\n points: ['tr', 'bc']\n },\n rightBottom: {\n points: ['bl', 'cr']\n },\n bottomLeft: {\n points: ['tl', 'bc']\n },\n leftBottom: {\n points: ['br', 'cl']\n }\n};\nconst DisableAutoArrowList = new Set(['topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'leftTop', 'leftBottom', 'rightTop', 'rightBottom']);\nexport default function getPlacements(config) {\n const {\n arrowWidth,\n autoAdjustOverflow,\n arrowPointAtCenter,\n offset,\n borderRadius,\n visibleFirst\n } = config;\n const halfArrowWidth = arrowWidth / 2;\n const placementMap = {};\n Object.keys(PlacementAlignMap).forEach(key => {\n const template = arrowPointAtCenter && ArrowCenterPlacementAlignMap[key] || PlacementAlignMap[key];\n const placementInfo = Object.assign(Object.assign({}, template), {\n offset: [0, 0],\n dynamicInset: true\n });\n placementMap[key] = placementInfo;\n // Disable autoArrow since design is fixed position\n if (DisableAutoArrowList.has(key)) {\n placementInfo.autoArrow = false;\n }\n // Static offset\n switch (key) {\n case 'top':\n case 'topLeft':\n case 'topRight':\n placementInfo.offset[1] = -halfArrowWidth - offset;\n break;\n case 'bottom':\n case 'bottomLeft':\n case 'bottomRight':\n placementInfo.offset[1] = halfArrowWidth + offset;\n break;\n case 'left':\n case 'leftTop':\n case 'leftBottom':\n placementInfo.offset[0] = -halfArrowWidth - offset;\n break;\n case 'right':\n case 'rightTop':\n case 'rightBottom':\n placementInfo.offset[0] = halfArrowWidth + offset;\n break;\n }\n // Dynamic offset\n const arrowOffset = getArrowOffsetToken({\n contentRadius: borderRadius,\n limitVerticalRadius: true\n });\n if (arrowPointAtCenter) {\n switch (key) {\n case 'topLeft':\n case 'bottomLeft':\n placementInfo.offset[0] = -arrowOffset.arrowOffsetHorizontal - halfArrowWidth;\n break;\n case 'topRight':\n case 'bottomRight':\n placementInfo.offset[0] = arrowOffset.arrowOffsetHorizontal + halfArrowWidth;\n break;\n case 'leftTop':\n case 'rightTop':\n placementInfo.offset[1] = -arrowOffset.arrowOffsetHorizontal - halfArrowWidth;\n break;\n case 'leftBottom':\n case 'rightBottom':\n placementInfo.offset[1] = arrowOffset.arrowOffsetHorizontal + halfArrowWidth;\n break;\n }\n }\n // Overflow\n placementInfo.overflow = getOverflowOptions(key, arrowOffset, arrowWidth, autoAdjustOverflow);\n // VisibleFirst\n if (visibleFirst) {\n placementInfo.htmlRegion = 'visibleFirst';\n }\n });\n return placementMap;\n}"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,yBAAyB;AAC7D,OAAO,SAASC,kBAAkBA,CAACC,SAAS,EAAEC,WAAW,EAAEC,UAAU,EAAEC,kBAAkB,EAAE;EACzF,IAAIA,kBAAkB,KAAK,KAAK,EAAE;IAChC,OAAO;MACLC,OAAO,EAAE,KAAK;MACdC,OAAO,EAAE;IACX,CAAC;EACH;EACA,MAAMC,QAAQ,GAAGH,kBAAkB,IAAI,OAAOA,kBAAkB,KAAK,QAAQ,GAAGA,kBAAkB,GAAG,CAAC,CAAC;EACvG,MAAMI,YAAY,GAAG,CAAC,CAAC;EACvB,QAAQP,SAAS;IACf,KA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