@shopware-ag/meteor-component-library
Version:
The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).
1 lines • 9.77 kB
Source Map (JSON)
{"version":3,"file":"floating-ui.vue-fe27ebef.mjs","sources":["../../../node_modules/@floating-ui/vue/dist/floating-ui.vue.mjs"],"sourcesContent":["import { arrow as arrow$1, computePosition } from '@floating-ui/dom';\nexport { autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size } from '@floating-ui/dom';\nimport { isNode, getNodeName } from '@floating-ui/utils/dom';\nimport { unref, computed, ref, shallowRef, watch, getCurrentScope, onScopeDispose, shallowReadonly } from 'vue-demi';\n\nfunction isComponentPublicInstance(target) {\n return target != null && typeof target === 'object' && '$el' in target;\n}\nfunction unwrapElement(target) {\n if (isComponentPublicInstance(target)) {\n const element = target.$el;\n return isNode(element) && getNodeName(element) === '#comment' ? null : element;\n }\n return target;\n}\n\nfunction toValue(source) {\n return typeof source === 'function' ? source() : unref(source);\n}\n\n/**\n * Positions an inner element of the floating element such that it is centered to the reference element.\n * @param options The arrow options.\n * @see https://floating-ui.com/docs/arrow\n */\nfunction arrow(options) {\n return {\n name: 'arrow',\n options,\n fn(args) {\n const element = unwrapElement(toValue(options.element));\n if (element == null) {\n return {};\n }\n return arrow$1({\n element,\n padding: options.padding\n }).fn(args);\n }\n };\n}\n\nfunction getDPR(element) {\n if (typeof window === 'undefined') {\n return 1;\n }\n const win = element.ownerDocument.defaultView || window;\n return win.devicePixelRatio || 1;\n}\n\nfunction roundByDPR(element, value) {\n const dpr = getDPR(element);\n return Math.round(value * dpr) / dpr;\n}\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element next to a reference element when it is given a certain CSS positioning strategy.\n * @param reference The reference template ref.\n * @param floating The floating template ref.\n * @param options The floating options.\n * @see https://floating-ui.com/docs/vue\n */\nfunction useFloating(reference, floating, options) {\n if (options === void 0) {\n options = {};\n }\n const whileElementsMountedOption = options.whileElementsMounted;\n const openOption = computed(() => {\n var _toValue;\n return (_toValue = toValue(options.open)) != null ? _toValue : true;\n });\n const middlewareOption = computed(() => toValue(options.middleware));\n const placementOption = computed(() => {\n var _toValue2;\n return (_toValue2 = toValue(options.placement)) != null ? _toValue2 : 'bottom';\n });\n const strategyOption = computed(() => {\n var _toValue3;\n return (_toValue3 = toValue(options.strategy)) != null ? _toValue3 : 'absolute';\n });\n const transformOption = computed(() => {\n var _toValue4;\n return (_toValue4 = toValue(options.transform)) != null ? _toValue4 : true;\n });\n const referenceElement = computed(() => unwrapElement(reference.value));\n const floatingElement = computed(() => unwrapElement(floating.value));\n const x = ref(0);\n const y = ref(0);\n const strategy = ref(strategyOption.value);\n const placement = ref(placementOption.value);\n const middlewareData = shallowRef({});\n const isPositioned = ref(false);\n const floatingStyles = computed(() => {\n const initialStyles = {\n position: strategy.value,\n left: '0',\n top: '0'\n };\n if (!floatingElement.value) {\n return initialStyles;\n }\n const xVal = roundByDPR(floatingElement.value, x.value);\n const yVal = roundByDPR(floatingElement.value, y.value);\n if (transformOption.value) {\n return {\n ...initialStyles,\n transform: \"translate(\" + xVal + \"px, \" + yVal + \"px)\",\n ...(getDPR(floatingElement.value) >= 1.5 && {\n willChange: 'transform'\n })\n };\n }\n return {\n position: strategy.value,\n left: xVal + \"px\",\n top: yVal + \"px\"\n };\n });\n let whileElementsMountedCleanup;\n function update() {\n if (referenceElement.value == null || floatingElement.value == null) {\n return;\n }\n const open = openOption.value;\n computePosition(referenceElement.value, floatingElement.value, {\n middleware: middlewareOption.value,\n placement: placementOption.value,\n strategy: strategyOption.value\n }).then(position => {\n x.value = position.x;\n y.value = position.y;\n strategy.value = position.strategy;\n placement.value = position.placement;\n middlewareData.value = position.middlewareData;\n /**\n * The floating element's position may be recomputed while it's closed\n * but still mounted (such as when transitioning out). To ensure\n * `isPositioned` will be `false` initially on the next open, avoid\n * setting it to `true` when `open === false` (must be specified).\n */\n isPositioned.value = open !== false;\n });\n }\n function cleanup() {\n if (typeof whileElementsMountedCleanup === 'function') {\n whileElementsMountedCleanup();\n whileElementsMountedCleanup = undefined;\n }\n }\n function attach() {\n cleanup();\n if (whileElementsMountedOption === undefined) {\n update();\n return;\n }\n if (referenceElement.value != null && floatingElement.value != null) {\n whileElementsMountedCleanup = whileElementsMountedOption(referenceElement.value, floatingElement.value, update);\n return;\n }\n }\n function reset() {\n if (!openOption.value) {\n isPositioned.value = false;\n }\n }\n watch([middlewareOption, placementOption, strategyOption, openOption], update, {\n flush: 'sync'\n });\n watch([referenceElement, floatingElement], attach, {\n flush: 'sync'\n });\n watch(openOption, reset, {\n flush: 'sync'\n });\n if (getCurrentScope()) {\n onScopeDispose(cleanup);\n }\n return {\n x: shallowReadonly(x),\n y: shallowReadonly(y),\n strategy: shallowReadonly(strategy),\n placement: shallowReadonly(placement),\n middlewareData: shallowReadonly(middlewareData),\n isPositioned: shallowReadonly(isPositioned),\n floatingStyles,\n update\n };\n}\n\nexport { arrow, useFloating };\n"],"names":[],"mappings":";;AAKA,SAAS,0BAA0B,QAAQ;AACzC,SAAO,UAAU,QAAQ,OAAO,WAAW,YAAY,SAAS;AAClE;AACA,SAAS,cAAc,QAAQ;AAC7B,MAAI,0BAA0B,MAAM,GAAG;AACrC,UAAM,UAAU,OAAO;AACvB,WAAO,OAAO,OAAO,KAAK,YAAY,OAAO,MAAM,aAAa,OAAO;AAAA,EACxE;AACD,SAAO;AACT;AAEA,SAAS,QAAQ,QAAQ;AACvB,SAAO,OAAO,WAAW,aAAa,OAAM,IAAK,MAAM,MAAM;AAC/D;AAOA,SAAS,MAAM,SAAS;AACtB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,GAAG,MAAM;AACP,YAAM,UAAU,cAAc,QAAQ,QAAQ,OAAO,CAAC;AACtD,UAAI,WAAW,MAAM;AACnB,eAAO;MACR;AACD,aAAO,QAAQ;AAAA,QACb;AAAA,QACA,SAAS,QAAQ;AAAA,MACzB,CAAO,EAAE,GAAG,IAAI;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