locationStrategies.mjs.map 29 KB

1
  1. {"version":3,"file":"locationStrategies.mjs","names":["useToggleScope","computed","nextTick","onScopeDispose","ref","watch","anchorToPoint","getOffset","clamp","consoleError","convertToUnit","destructComputed","flipAlign","flipCorner","flipSide","getAxis","getScrollParents","IN_BROWSER","isFixedPosition","nullifyTransforms","parseAnchor","propsFactory","Box","getOverflow","locationStrategies","static","staticLocationStrategy","connected","connectedLocationStrategy","makeLocationStrategyProps","locationStrategy","type","String","Function","default","validator","val","location","origin","offset","Number","Array","useLocationStrategies","props","data","contentStyles","updateLocation","isActive","value","reset","undefined","window","addEventListener","onResize","passive","removeEventListener","e","getIntrinsicSize","el","isRtl","style","removeProperty","contentBox","x","parseFloat","right","left","y","top","activatorFixed","activatorEl","Object","assign","position","preferredAnchor","preferredOrigin","parsedAnchor","parsedOrigin","side","align","minWidth","minHeight","maxWidth","maxHeight","map","key","isNaN","Infinity","isArray","split","length","push","observe","observer","ResizeObserver","contentEl","_ref","_ref2","newActivatorEl","newContentEl","oldActivatorEl","oldContentEl","unobserve","immediate","disconnect","requestAnimationFrame","targetBox","getBoundingClientRect","scrollParents","viewportMargin","document","documentElement","getPropertyValue","viewport","reduce","box","rect","scrollBox","width","clientWidth","height","clientHeight","Math","max","min","bottom","placement","anchor","checkOverflow","_placement","targetPoint","contentPoint","overflows","available","flipped","resets","_x","_y","axis","hasOverflowX","before","after","hasOverflowY","forEach","newPlacement","flip","newOverflows","transformOrigin","pixelRound","pixelCeil","result","round","devicePixelRatio","ceil"],"sources":["../../../src/components/VOverlay/locationStrategies.ts"],"sourcesContent":["// Composables\nimport { useToggleScope } from '@/composables/toggleScope'\n\n// Utilities\nimport { computed, nextTick, onScopeDispose, ref, watch } from 'vue'\nimport { anchorToPoint, getOffset } from './util/point'\nimport {\n clamp,\n consoleError,\n convertToUnit,\n destructComputed,\n flipAlign,\n flipCorner,\n flipSide,\n getAxis,\n getScrollParents,\n IN_BROWSER,\n isFixedPosition,\n nullifyTransforms,\n parseAnchor,\n propsFactory,\n} from '@/util'\nimport { Box, getOverflow } from '@/util/box'\n\n// Types\nimport type { PropType, Ref } from 'vue'\nimport type { Anchor } from '@/util'\n\nexport interface LocationStrategyData {\n contentEl: Ref<HTMLElement | undefined>\n activatorEl: Ref<HTMLElement | undefined>\n isActive: Ref<boolean>\n isRtl: Ref<boolean>\n}\n\ntype LocationStrategyFn = (\n data: LocationStrategyData,\n props: StrategyProps,\n contentStyles: Ref<Record<string, string>>\n) => undefined | { updateLocation: (e: Event) => void }\n\nconst locationStrategies = {\n static: staticLocationStrategy, // specific viewport position, usually centered\n connected: connectedLocationStrategy, // connected to a certain element\n}\n\nexport interface StrategyProps {\n locationStrategy: keyof typeof locationStrategies | LocationStrategyFn\n location: Anchor\n origin: Anchor | 'auto' | 'overlap'\n offset?: number | string | number[]\n maxHeight?: number | string\n maxWidth?: number | string\n minHeight?: number | string\n minWidth?: number | string\n}\n\nexport const makeLocationStrategyProps = propsFactory({\n locationStrategy: {\n type: [String, Function] as PropType<StrategyProps['locationStrategy']>,\n default: 'static',\n validator: (val: any) => typeof val === 'function' || val in locationStrategies,\n },\n location: {\n type: String as PropType<StrategyProps['location']>,\n default: 'bottom',\n },\n origin: {\n type: String as PropType<StrategyProps['origin']>,\n default: 'auto',\n },\n offset: [Number, String, Array] as PropType<StrategyProps['offset']>,\n}, 'VOverlay-location-strategies')\n\nexport function useLocationStrategies (\n props: StrategyProps,\n data: LocationStrategyData\n) {\n const contentStyles = ref({})\n const updateLocation = ref<(e: Event) => void>()\n\n if (IN_BROWSER) {\n useToggleScope(() => !!(data.isActive.value && props.locationStrategy), reset => {\n watch(() => props.locationStrategy, reset)\n onScopeDispose(() => {\n updateLocation.value = undefined\n })\n\n if (typeof props.locationStrategy === 'function') {\n updateLocation.value = props.locationStrategy(data, props, contentStyles)?.updateLocation\n } else {\n updateLocation.value = locationStrategies[props.locationStrategy](data, props, contentStyles)?.updateLocation\n }\n })\n\n window.addEventListener('resize', onResize, { passive: true })\n\n onScopeDispose(() => {\n window.removeEventListener('resize', onResize)\n updateLocation.value = undefined\n })\n }\n\n function onResize (e: Event) {\n updateLocation.value?.(e)\n }\n\n return {\n contentStyles,\n updateLocation,\n }\n}\n\nfunction staticLocationStrategy () {\n // TODO\n}\n\n/** Get size of element ignoring max-width/max-height */\nfunction getIntrinsicSize (el: HTMLElement, isRtl: boolean) {\n // const scrollables = new Map<Element, [number, number]>()\n // el.querySelectorAll('*').forEach(el => {\n // const x = el.scrollLeft\n // const y = el.scrollTop\n // if (x || y) {\n // scrollables.set(el, [x, y])\n // }\n // })\n\n // const initialMaxWidth = el.style.maxWidth\n // const initialMaxHeight = el.style.maxHeight\n // el.style.removeProperty('max-width')\n // el.style.removeProperty('max-height')\n\n if (isRtl) {\n el.style.removeProperty('left')\n } else {\n el.style.removeProperty('right')\n }\n\n /* eslint-disable-next-line sonarjs/prefer-immediate-return */\n const contentBox = nullifyTransforms(el)\n\n if (isRtl) {\n contentBox.x += parseFloat(el.style.right || 0)\n } else {\n contentBox.x -= parseFloat(el.style.left || 0)\n }\n contentBox.y -= parseFloat(el.style.top || 0)\n\n // el.style.maxWidth = initialMaxWidth\n // el.style.maxHeight = initialMaxHeight\n // scrollables.forEach((position, el) => {\n // el.scrollTo(...position)\n // })\n\n return contentBox\n}\n\nfunction connectedLocationStrategy (data: LocationStrategyData, props: StrategyProps, contentStyles: Ref<Record<string, string>>) {\n const activatorFixed = isFixedPosition(data.activatorEl.value)\n if (activatorFixed) {\n Object.assign(contentStyles.value, {\n position: 'fixed',\n top: 0,\n [data.isRtl.value ? 'right' : 'left']: 0,\n })\n }\n\n const { preferredAnchor, preferredOrigin } = destructComputed(() => {\n const parsedAnchor = parseAnchor(props.location, data.isRtl.value)\n const parsedOrigin =\n props.origin === 'overlap' ? parsedAnchor\n : props.origin === 'auto' ? flipSide(parsedAnchor)\n : parseAnchor(props.origin, data.isRtl.value)\n\n // Some combinations of props may produce an invalid origin\n if (parsedAnchor.side === parsedOrigin.side && parsedAnchor.align === flipAlign(parsedOrigin).align) {\n return {\n preferredAnchor: flipCorner(parsedAnchor),\n preferredOrigin: flipCorner(parsedOrigin),\n }\n } else {\n return {\n preferredAnchor: parsedAnchor,\n preferredOrigin: parsedOrigin,\n }\n }\n })\n\n const [minWidth, minHeight, maxWidth, maxHeight] =\n (['minWidth', 'minHeight', 'maxWidth', 'maxHeight'] as const).map(key => {\n return computed(() => {\n const val = parseFloat(props[key]!)\n return isNaN(val) ? Infinity : val\n })\n })\n\n const offset = computed(() => {\n if (Array.isArray(props.offset)) {\n return props.offset\n }\n if (typeof props.offset === 'string') {\n const offset = props.offset.split(' ').map(parseFloat)\n if (offset.length < 2) offset.push(0)\n return offset\n }\n return typeof props.offset === 'number' ? [props.offset, 0] : [0, 0]\n })\n\n let observe = false\n const observer = new ResizeObserver(() => {\n if (observe) updateLocation()\n })\n\n watch([data.activatorEl, data.contentEl], ([newActivatorEl, newContentEl], [oldActivatorEl, oldContentEl]) => {\n if (oldActivatorEl) observer.unobserve(oldActivatorEl)\n if (newActivatorEl) observer.observe(newActivatorEl)\n\n if (oldContentEl) observer.unobserve(oldContentEl)\n if (newContentEl) observer.observe(newContentEl)\n }, {\n immediate: true,\n })\n\n onScopeDispose(() => {\n observer.disconnect()\n })\n\n // eslint-disable-next-line max-statements\n function updateLocation () {\n observe = false\n requestAnimationFrame(() => {\n requestAnimationFrame(() => observe = true)\n })\n\n if (!data.activatorEl.value || !data.contentEl.value) return\n\n const targetBox = data.activatorEl.value.getBoundingClientRect()\n const contentBox = getIntrinsicSize(data.contentEl.value, data.isRtl.value)\n const scrollParents = getScrollParents(data.contentEl.value)\n const viewportMargin = 12\n\n if (!scrollParents.length) {\n scrollParents.push(document.documentElement)\n if (!(data.contentEl.value.style.top && data.contentEl.value.style.left)) {\n contentBox.x -= parseFloat(document.documentElement.style.getPropertyValue('--v-body-scroll-x') || 0)\n contentBox.y -= parseFloat(document.documentElement.style.getPropertyValue('--v-body-scroll-y') || 0)\n }\n }\n\n const viewport = scrollParents.reduce<Box>((box: Box | undefined, el) => {\n const rect = el.getBoundingClientRect()\n const scrollBox = new Box({\n x: el === document.documentElement ? 0 : rect.x,\n y: el === document.documentElement ? 0 : rect.y,\n width: el.clientWidth,\n height: el.clientHeight,\n })\n\n if (box) {\n return new Box({\n x: Math.max(box.left, scrollBox.left),\n y: Math.max(box.top, scrollBox.top),\n width: Math.min(box.right, scrollBox.right) - Math.max(box.left, scrollBox.left),\n height: Math.min(box.bottom, scrollBox.bottom) - Math.max(box.top, scrollBox.top),\n })\n }\n return scrollBox\n }, undefined!)\n viewport.x += viewportMargin\n viewport.y += viewportMargin\n viewport.width -= viewportMargin * 2\n viewport.height -= viewportMargin * 2\n\n let placement = {\n anchor: preferredAnchor.value,\n origin: preferredOrigin.value,\n }\n\n function checkOverflow (_placement: typeof placement) {\n const box = new Box(contentBox)\n const targetPoint = anchorToPoint(_placement.anchor, targetBox)\n const contentPoint = anchorToPoint(_placement.origin, box)\n\n let { x, y } = getOffset(targetPoint, contentPoint)\n\n switch (_placement.anchor.side) {\n case 'top': y -= offset.value[0]; break\n case 'bottom': y += offset.value[0]; break\n case 'left': x -= offset.value[0]; break\n case 'right': x += offset.value[0]; break\n }\n\n switch (_placement.anchor.align) {\n case 'top': y -= offset.value[1]; break\n case 'bottom': y += offset.value[1]; break\n case 'left': x -= offset.value[1]; break\n case 'right': x += offset.value[1]; break\n }\n\n box.x += x\n box.y += y\n\n box.width = Math.min(box.width, maxWidth.value)\n box.height = Math.min(box.height, maxHeight.value)\n\n const overflows = getOverflow(box, viewport)\n\n return { overflows, x, y }\n }\n\n let x = 0; let y = 0\n const available = { x: 0, y: 0 }\n const flipped = { x: false, y: false }\n let resets = -1\n while (true) {\n if (resets++ > 10) {\n consoleError('Infinite loop detected in connectedLocationStrategy')\n break\n }\n\n const { x: _x, y: _y, overflows } = checkOverflow(placement)\n\n x += _x\n y += _y\n\n contentBox.x += _x\n contentBox.y += _y\n\n // flip\n {\n const axis = getAxis(placement.anchor)\n const hasOverflowX = overflows.x.before || overflows.x.after\n const hasOverflowY = overflows.y.before || overflows.y.after\n\n let reset = false\n ;['x', 'y'].forEach(key => {\n if (\n (key === 'x' && hasOverflowX && !flipped.x) ||\n (key === 'y' && hasOverflowY && !flipped.y)\n ) {\n const newPlacement = { anchor: { ...placement.anchor }, origin: { ...placement.origin } }\n const flip = key === 'x'\n ? axis === 'y' ? flipAlign : flipSide\n : axis === 'y' ? flipSide : flipAlign\n newPlacement.anchor = flip(newPlacement.anchor)\n newPlacement.origin = flip(newPlacement.origin)\n const { overflows: newOverflows } = checkOverflow(newPlacement)\n if (\n (newOverflows[key].before <= overflows[key].before &&\n newOverflows[key].after <= overflows[key].after) ||\n (newOverflows[key].before + newOverflows[key].after <\n (overflows[key].before + overflows[key].after) / 2)\n ) {\n placement = newPlacement\n reset = flipped[key] = true\n }\n }\n })\n if (reset) continue\n }\n\n // shift\n if (overflows.x.before) {\n x += overflows.x.before\n contentBox.x += overflows.x.before\n }\n if (overflows.x.after) {\n x -= overflows.x.after\n contentBox.x -= overflows.x.after\n }\n if (overflows.y.before) {\n y += overflows.y.before\n contentBox.y += overflows.y.before\n }\n if (overflows.y.after) {\n y -= overflows.y.after\n contentBox.y -= overflows.y.after\n }\n\n // size\n {\n const overflows = getOverflow(contentBox, viewport)\n available.x = viewport.width - overflows.x.before - overflows.x.after\n available.y = viewport.height - overflows.y.before - overflows.y.after\n\n x += overflows.x.before\n contentBox.x += overflows.x.before\n y += overflows.y.before\n contentBox.y += overflows.y.before\n }\n\n break\n }\n\n const axis = getAxis(placement.anchor)\n\n Object.assign(contentStyles.value, {\n '--v-overlay-anchor-origin': `${placement.anchor.side} ${placement.anchor.align}`,\n transformOrigin: `${placement.origin.side} ${placement.origin.align}`,\n // transform: `translate(${pixelRound(x)}px, ${pixelRound(y)}px)`,\n top: convertToUnit(pixelRound(y)),\n left: data.isRtl.value ? undefined : convertToUnit(pixelRound(x)),\n right: data.isRtl.value ? convertToUnit(pixelRound(-x)) : undefined,\n minWidth: convertToUnit(axis === 'y' ? Math.min(minWidth.value, targetBox.width) : minWidth.value),\n maxWidth: convertToUnit(pixelCeil(clamp(available.x, minWidth.value === Infinity ? 0 : minWidth.value, maxWidth.value))),\n maxHeight: convertToUnit(pixelCeil(clamp(available.y, minHeight.value === Infinity ? 0 : minHeight.value, maxHeight.value))),\n })\n\n return {\n available,\n contentBox,\n }\n }\n\n watch(\n () => [\n preferredAnchor.value,\n preferredOrigin.value,\n props.offset,\n props.minWidth,\n props.minHeight,\n props.maxWidth,\n props.maxHeight,\n ],\n () => updateLocation(),\n )\n\n nextTick(() => {\n const result = updateLocation()\n\n // TODO: overflowing content should only require a single updateLocation call\n // Icky hack to make sure the content is positioned consistently\n if (!result) return\n const { available, contentBox } = result\n if (contentBox.height > available.y) {\n requestAnimationFrame(() => {\n updateLocation()\n requestAnimationFrame(() => {\n updateLocation()\n })\n })\n }\n })\n\n return { updateLocation }\n}\n\nfunction pixelRound (val: number) {\n return Math.round(val * devicePixelRatio) / devicePixelRatio\n}\n\nfunction pixelCeil (val: number) {\n return Math.ceil(val * devicePixelRatio) / devicePixelRatio\n}\n"],"mappings":"AAAA;AAAA,SACSA,cAAc,6CAEvB;AACA,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,GAAG,EAAEC,KAAK,QAAQ,KAAK;AAAA,SAC3DC,aAAa,EAAEC,SAAS;AAAA,SAE/BC,KAAK,EACLC,YAAY,EACZC,aAAa,EACbC,gBAAgB,EAChBC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPC,gBAAgB,EAChBC,UAAU,EACVC,eAAe,EACfC,iBAAiB,EACjBC,WAAW,EACXC,YAAY;AAAA,SAELC,GAAG,EAAEC,WAAW,8BAEzB;AAiBA,MAAMC,kBAAkB,GAAG;EACzBC,MAAM,EAAEC,sBAAsB;EAAE;EAChCC,SAAS,EAAEC,yBAAyB,CAAE;AACxC,CAAC;;AAaD,OAAO,M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