@esri/solutions-components 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/buffer-tools_6.cjs.entry.js +26 -8
- package/dist/cjs/calcite-combobox_3.cjs.entry.js +2 -2
- package/dist/cjs/calcite-input-message_5.cjs.entry.js +6 -4
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
- package/dist/cjs/{csvUtils-83af7ae1.js → csvUtils-34666909.js} +1 -1
- package/dist/cjs/{interfaces-772edf61.js → interfaces-17c631bf.js} +1 -1
- package/dist/cjs/layer-table.cjs.entry.js +3 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-card.cjs.entry.js +1 -1
- package/dist/cjs/{mapViewUtils-55ac76cb.js → mapViewUtils-24d1d859.js} +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +41 -7
- package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
- package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
- package/dist/cjs/{solution-store-39726b81.js → solution-store-2dbab624.js} +1 -1
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/components/buffer-tools/buffer-tools.js +48 -0
- package/dist/collection/components/map-draw-tools/map-draw-tools.js +10 -4
- package/dist/collection/components/public-notification/public-notification.css +12 -12
- package/dist/collection/components/public-notification/public-notification.js +50 -4
- package/dist/collection/components/refine-selection/refine-selection.js +4 -2
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.css +1 -0
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +3 -1
- package/dist/collection/demos/new-public-notification.html +7 -6
- package/dist/collection/utils/interfaces.js +1 -1
- package/dist/collection/utils/interfaces.ts +7 -2
- package/dist/components/buffer-tools2.js +10 -0
- package/dist/components/interfaces3.js +1 -1
- package/dist/components/map-draw-tools2.js +10 -4
- package/dist/components/public-notification.js +40 -6
- package/dist/components/refine-selection-tools2.js +4 -2
- package/dist/components/refine-selection2.js +4 -2
- package/dist/esm/buffer-tools_6.entry.js +26 -8
- package/dist/esm/calcite-combobox_3.entry.js +2 -2
- package/dist/esm/calcite-input-message_5.entry.js +6 -4
- package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
- package/dist/esm/{csvUtils-eb231cfb.js → csvUtils-ae3004b9.js} +1 -1
- package/dist/esm/{interfaces-3b23a5f9.js → interfaces-d0d83efa.js} +1 -1
- package/dist/esm/layer-table.entry.js +3 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-card.entry.js +1 -1
- package/dist/esm/{mapViewUtils-e5d8a1e1.js → mapViewUtils-541e7a3c.js} +1 -1
- package/dist/esm/public-notification.entry.js +41 -7
- package/dist/esm/solution-configuration.entry.js +2 -2
- package/dist/esm/solution-contents_3.entry.js +2 -2
- package/dist/esm/{solution-store-c0bf9200.js → solution-store-41e15f1c.js} +1 -1
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/new-public-notification.html +7 -6
- package/dist/solutions-components/p-05e64bd1.js +498 -2
- package/dist/solutions-components/p-08a95b33.entry.js +138 -0
- package/dist/solutions-components/p-0da5bbdf.entry.js +91 -0
- package/dist/solutions-components/p-0ef91144.entry.js +913 -0
- package/dist/solutions-components/p-0f523243.entry.js +1916 -0
- package/dist/solutions-components/p-11b9510e.entry.js +173 -0
- package/dist/solutions-components/p-1b875d94.entry.js +58 -0
- package/dist/solutions-components/p-1c567f3a.js +23 -16
- package/dist/solutions-components/p-1c883db9.entry.js +43 -0
- package/dist/solutions-components/p-1f225056.js +322 -0
- package/dist/solutions-components/p-1f499e67.entry.js +72 -0
- package/dist/solutions-components/p-20d3d758.entry.js +881 -0
- package/dist/solutions-components/p-2274ac9e.entry.js +160 -0
- package/dist/solutions-components/p-23ec5ac5.entry.js +93 -0
- package/dist/solutions-components/p-2447798c.entry.js +155 -0
- package/dist/solutions-components/p-2525e691.entry.js +432 -0
- package/dist/solutions-components/p-2561f5b5.js +4092 -0
- package/dist/solutions-components/p-29f887c0.entry.js +234 -0
- package/dist/solutions-components/p-2a0d8047.entry.js +345 -0
- package/dist/solutions-components/p-2c177e6a.entry.js +101 -0
- package/dist/solutions-components/p-2e9ed892.js +46 -1
- package/dist/solutions-components/p-316f56db.js +219 -2
- package/dist/solutions-components/p-327f3ebf.entry.js +98 -0
- package/dist/solutions-components/p-356f8b54.entry.js +138 -0
- package/dist/solutions-components/p-359c58de.entry.js +172 -0
- package/dist/solutions-components/p-37336c0d.entry.js +116 -0
- package/dist/solutions-components/p-374a5031.js +105 -2
- package/dist/solutions-components/p-39ea6ef4.entry.js +71 -0
- package/dist/solutions-components/p-3b010ce1.js +17 -1
- package/dist/solutions-components/p-4307dacd.js +194 -1
- package/dist/solutions-components/p-44da2507.js +405 -14
- package/dist/solutions-components/p-46bdffe8.entry.js +54 -0
- package/dist/solutions-components/p-4894bbeb.js +53 -2
- package/dist/solutions-components/p-4cd569f1.entry.js +1298 -0
- package/dist/solutions-components/p-4d4160f9.entry.js +121 -0
- package/dist/solutions-components/p-4e32bf8c.js +482 -1
- package/dist/solutions-components/p-4e9cbd32.entry.js +184 -0
- package/dist/solutions-components/p-508317b3.js +13 -2
- package/dist/solutions-components/p-54697d58.entry.js +198 -0
- package/dist/solutions-components/p-55c79103.entry.js +311 -0
- package/dist/solutions-components/p-57fd19c0.entry.js +706 -0
- package/dist/solutions-components/p-59b48fde.entry.js +443 -0
- package/dist/solutions-components/p-60e0e6a0.entry.js +214 -0
- package/dist/solutions-components/p-621d0534.entry.js +123 -0
- package/dist/solutions-components/p-63f6e8f1.js +14 -1
- package/dist/solutions-components/p-66aeec57.entry.js +61 -0
- package/dist/solutions-components/p-69834f46.entry.js +618 -0
- package/dist/solutions-components/p-6d9da8e5.entry.js +21530 -0
- package/dist/solutions-components/p-6e0da576.js +13 -1
- package/dist/solutions-components/p-6ec3f294.entry.js +106 -0
- package/dist/solutions-components/p-6fe17794.js +9 -1
- package/dist/solutions-components/p-7024cb16.entry.js +72 -0
- package/dist/solutions-components/p-70535506.entry.js +226 -0
- package/dist/solutions-components/p-708a63a8.js +12 -1
- package/dist/solutions-components/p-729708a3.js +14 -1
- package/dist/solutions-components/p-73e23995.js +6 -1
- package/dist/solutions-components/p-74b29d75.entry.js +231 -0
- package/dist/solutions-components/p-74b7ee25.entry.js +711 -0
- package/dist/solutions-components/p-77182c3a.js +3015 -1
- package/dist/solutions-components/p-78b3ef80.entry.js +456 -0
- package/dist/solutions-components/p-79709c19.js +60 -3
- package/dist/solutions-components/p-7a46ef97.js +181 -2
- package/dist/solutions-components/p-7be159e6.entry.js +175 -0
- package/dist/solutions-components/p-7d4451c2.entry.js +71 -0
- package/dist/solutions-components/p-7daea1df.js +41 -1
- package/dist/solutions-components/p-7e39e5ad.entry.js +102 -0
- package/dist/solutions-components/p-7fb45059.entry.js +43 -0
- package/dist/solutions-components/p-815533de.js +306 -3
- package/dist/solutions-components/p-816622ca.entry.js +248 -0
- package/dist/solutions-components/p-83166522.js +205 -2
- package/dist/solutions-components/p-83bd1991.entry.js +36 -0
- package/dist/solutions-components/p-856464d7.entry.js +572 -0
- package/dist/solutions-components/p-8c349bad.entry.js +347 -0
- package/dist/solutions-components/p-8dccb390.entry.js +1986 -0
- package/dist/solutions-components/p-904c185a.entry.js +228 -0
- package/dist/solutions-components/p-9092f8b3.entry.js +156 -0
- package/dist/solutions-components/p-9371145a.entry.js +477 -0
- package/dist/solutions-components/p-93d3119d.js +1948 -1
- package/dist/solutions-components/p-95ec8062.entry.js +173 -0
- package/dist/solutions-components/p-991ee695.js +109 -1
- package/dist/solutions-components/p-9a57dab7.entry.js +213 -0
- package/dist/solutions-components/p-9a9955db.js +41 -1
- package/dist/solutions-components/p-9c1ebc90.js +35 -16
- package/dist/solutions-components/p-9eba5c66.js +399 -3
- package/dist/solutions-components/p-a033a507.entry.js +252 -0
- package/dist/solutions-components/p-a3773415.entry.js +1132 -0
- package/dist/solutions-components/p-a44fe40f.entry.js +94 -0
- package/dist/solutions-components/p-a5b1ab03.js +33 -3
- package/dist/solutions-components/p-a5b2c13d.entry.js +723 -0
- package/dist/solutions-components/p-a6d729b7.entry.js +85 -0
- package/dist/solutions-components/p-a8005026.entry.js +565 -0
- package/dist/solutions-components/p-a80b3880.js +14 -1
- package/dist/solutions-components/p-a89198a3.entry.js +2620 -0
- package/dist/solutions-components/p-aa04bd1f.entry.js +95 -0
- package/dist/solutions-components/p-aa0a0922.entry.js +80 -0
- package/dist/solutions-components/p-ae1fd76b.js +11 -1
- package/dist/solutions-components/p-b2cf435e.entry.js +87 -0
- package/dist/solutions-components/p-b359dc78.js +41 -1
- package/dist/solutions-components/p-b57bc4eb.entry.js +71 -0
- package/dist/solutions-components/p-b75cc407.entry.js +145 -0
- package/dist/solutions-components/p-b911cb75.entry.js +71 -0
- package/dist/solutions-components/p-b965e177.entry.js +335 -0
- package/dist/solutions-components/p-b978636e.js +14 -1
- package/dist/solutions-components/p-ba10a5c8.entry.js +42 -0
- package/dist/solutions-components/p-bd67334c.js +122 -2
- package/dist/solutions-components/p-bde20dba.entry.js +212 -0
- package/dist/solutions-components/p-be0b5a94.entry.js +248 -0
- package/dist/solutions-components/p-c023e6a1.js +2028 -2
- package/dist/solutions-components/p-c27b0c2d.entry.js +150 -0
- package/dist/solutions-components/p-c579ed60.entry.js +447 -0
- package/dist/solutions-components/p-c92bc231.js +101 -2
- package/dist/solutions-components/p-cc815aca.js +839 -16
- package/dist/solutions-components/p-cc8beabb.entry.js +695 -0
- package/dist/solutions-components/p-cdc46c0c.js +1751 -2
- package/dist/solutions-components/p-d12e6992.entry.js +118 -0
- package/dist/solutions-components/p-d1dfed6b.entry.js +179 -0
- package/dist/solutions-components/p-d48a24e6.js +754 -2
- package/dist/solutions-components/p-d96ee3ef.entry.js +579 -0
- package/dist/solutions-components/p-dbc9a5a8.js +80 -0
- package/dist/solutions-components/p-dcdbe712.entry.js +278 -0
- package/dist/solutions-components/p-de39206f.entry.js +113 -0
- package/dist/solutions-components/p-de5416e8.js +28 -1
- package/dist/solutions-components/p-df420d54.entry.js +213 -0
- package/dist/solutions-components/p-e3138cf0.entry.js +20 -0
- package/dist/solutions-components/p-e4845fec.entry.js +152 -0
- package/dist/solutions-components/p-e611d8c8.js +28 -1
- package/dist/solutions-components/p-e947d3b0.js +5 -1
- package/dist/solutions-components/p-ea534300.js +41 -2
- package/dist/solutions-components/p-ec84ee85.entry.js +55 -0
- package/dist/solutions-components/p-ed36c637.entry.js +85 -0
- package/dist/solutions-components/p-f0add71c.js +74 -0
- package/dist/solutions-components/p-f42e014b.js +171 -2
- package/dist/solutions-components/p-fc02e7de.entry.js +308 -0
- package/dist/solutions-components/p-fc884dd6.js +28 -16
- package/dist/solutions-components/p-fcbfa59c.entry.js +181 -0
- package/dist/solutions-components/p-fdc5cf5f.entry.js +138 -0
- package/dist/solutions-components/solutions-components.esm.js +20 -1
- package/dist/solutions-components/utils/interfaces.ts +7 -2
- package/dist/types/components/buffer-tools/buffer-tools.d.ts +9 -1
- package/dist/types/components/public-notification/public-notification.d.ts +26 -0
- package/dist/types/components.d.ts +9 -1
- package/dist/types/preact.d.ts +3 -1
- package/dist/types/utils/interfaces.d.ts +4 -0
- package/package.json +1 -1
- package/dist/solutions-components/p-021432b8.entry.js +0 -12
- package/dist/solutions-components/p-03440b1e.entry.js +0 -11
- package/dist/solutions-components/p-0512635b.entry.js +0 -6
- package/dist/solutions-components/p-086ef115.entry.js +0 -29
- package/dist/solutions-components/p-0b4bf57f.entry.js +0 -6
- package/dist/solutions-components/p-0c088725.entry.js +0 -6
- package/dist/solutions-components/p-0f820c08.entry.js +0 -6
- package/dist/solutions-components/p-164780a0.entry.js +0 -6
- package/dist/solutions-components/p-179a68a0.entry.js +0 -6
- package/dist/solutions-components/p-184b5005.entry.js +0 -11
- package/dist/solutions-components/p-1d082fee.entry.js +0 -11
- package/dist/solutions-components/p-1e6c02a2.entry.js +0 -11
- package/dist/solutions-components/p-20a58e62.entry.js +0 -17
- package/dist/solutions-components/p-20b2458c.entry.js +0 -11
- package/dist/solutions-components/p-245d47c1.entry.js +0 -6
- package/dist/solutions-components/p-2cb057a9.entry.js +0 -11
- package/dist/solutions-components/p-2cc72806.entry.js +0 -23
- package/dist/solutions-components/p-2de1db9c.entry.js +0 -11
- package/dist/solutions-components/p-2e9c7055.entry.js +0 -11
- package/dist/solutions-components/p-2ed5e6c8.entry.js +0 -11
- package/dist/solutions-components/p-3109d940.entry.js +0 -6
- package/dist/solutions-components/p-31a8bcfa.entry.js +0 -6
- package/dist/solutions-components/p-3f88ba73.entry.js +0 -6
- package/dist/solutions-components/p-3fa9b3c8.js +0 -36
- package/dist/solutions-components/p-40c41709.entry.js +0 -6
- package/dist/solutions-components/p-40e963c7.entry.js +0 -11
- package/dist/solutions-components/p-40f480da.entry.js +0 -11
- package/dist/solutions-components/p-49d5d2d3.entry.js +0 -11
- package/dist/solutions-components/p-4f7049a4.entry.js +0 -11
- package/dist/solutions-components/p-506e4d78.entry.js +0 -6
- package/dist/solutions-components/p-576fdcab.entry.js +0 -6
- package/dist/solutions-components/p-5bd0cf34.entry.js +0 -23
- package/dist/solutions-components/p-65e177f1.entry.js +0 -6
- package/dist/solutions-components/p-67d710c2.entry.js +0 -6
- package/dist/solutions-components/p-7268b445.entry.js +0 -11
- package/dist/solutions-components/p-75ea4667.entry.js +0 -6
- package/dist/solutions-components/p-778c0a36.entry.js +0 -17
- package/dist/solutions-components/p-7a22509b.entry.js +0 -12
- package/dist/solutions-components/p-7bff51db.entry.js +0 -6
- package/dist/solutions-components/p-7d2d0d5d.entry.js +0 -6
- package/dist/solutions-components/p-7f0036f1.entry.js +0 -11
- package/dist/solutions-components/p-8060fb94.entry.js +0 -6
- package/dist/solutions-components/p-80a1b305.entry.js +0 -6
- package/dist/solutions-components/p-81eae877.entry.js +0 -12
- package/dist/solutions-components/p-84e86b8b.entry.js +0 -6
- package/dist/solutions-components/p-877dd0dc.entry.js +0 -18
- package/dist/solutions-components/p-9106950a.entry.js +0 -11
- package/dist/solutions-components/p-979804a4.entry.js +0 -11
- package/dist/solutions-components/p-9862baa8.entry.js +0 -11
- package/dist/solutions-components/p-9b5a9117.entry.js +0 -12
- package/dist/solutions-components/p-9deff0c2.entry.js +0 -6
- package/dist/solutions-components/p-9f400eeb.entry.js +0 -6
- package/dist/solutions-components/p-a0639ad1.entry.js +0 -11
- package/dist/solutions-components/p-a33c044e.entry.js +0 -6
- package/dist/solutions-components/p-a516c658.entry.js +0 -6
- package/dist/solutions-components/p-aa0ef36d.entry.js +0 -11
- package/dist/solutions-components/p-aaccbdf3.entry.js +0 -18
- package/dist/solutions-components/p-ab03a5c9.entry.js +0 -11
- package/dist/solutions-components/p-ad469b92.entry.js +0 -11
- package/dist/solutions-components/p-adc86ac3.entry.js +0 -6
- package/dist/solutions-components/p-addc1156.entry.js +0 -11
- package/dist/solutions-components/p-ae846934.entry.js +0 -11
- package/dist/solutions-components/p-b0572fc4.entry.js +0 -37
- package/dist/solutions-components/p-b4e476b7.js +0 -257
- package/dist/solutions-components/p-b668daf8.js +0 -21
- package/dist/solutions-components/p-b6e6eae1.entry.js +0 -6
- package/dist/solutions-components/p-bc317a7f.entry.js +0 -6
- package/dist/solutions-components/p-bd4d0773.entry.js +0 -6
- package/dist/solutions-components/p-be41429f.js +0 -21
- package/dist/solutions-components/p-bf6b6353.entry.js +0 -11
- package/dist/solutions-components/p-c2e3dfbb.entry.js +0 -11
- package/dist/solutions-components/p-c4afae53.entry.js +0 -12
- package/dist/solutions-components/p-c9da1c26.entry.js +0 -6
- package/dist/solutions-components/p-cbf8cd49.entry.js +0 -6
- package/dist/solutions-components/p-cc1a064a.entry.js +0 -11
- package/dist/solutions-components/p-d09a168c.entry.js +0 -6
- package/dist/solutions-components/p-d377f913.entry.js +0 -11
- package/dist/solutions-components/p-d4cefead.entry.js +0 -37
- package/dist/solutions-components/p-d7bc0baf.entry.js +0 -16
- package/dist/solutions-components/p-d8968487.entry.js +0 -11
- package/dist/solutions-components/p-e00a0b86.entry.js +0 -11
- package/dist/solutions-components/p-e9a7ed49.entry.js +0 -11
- package/dist/solutions-components/p-ec27e493.entry.js +0 -11
- package/dist/solutions-components/p-ed6404eb.entry.js +0 -6
- package/dist/solutions-components/p-ef21e195.entry.js +0 -23
- package/dist/solutions-components/p-f6068a2d.entry.js +0 -11
- package/dist/solutions-components/p-f6c4cff3.entry.js +0 -11
- package/dist/solutions-components/p-f847291f.entry.js +0 -6
- package/dist/solutions-components/p-f90fd262.entry.js +0 -11
- package/dist/solutions-components/p-fc973005.entry.js +0 -6
- package/dist/solutions-components/p-ff9fb6bc.entry.js +0 -11
@@ -3,9 +3,1758 @@
|
|
3
3
|
* Licensed under the Apache License, Version 2.0
|
4
4
|
* http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
*/
|
6
|
-
import{c as t,b as n}from"./p-83166522.js";import{d as e}from"./p-4e32bf8c.js";function o(t){return t.split("-")[1]}function r(t){return"y"===t?"height":"width"}function i(t){return t.split("-")[0]}function a(t){return["top","bottom"].includes(i(t))?"x":"y"}function l(t,n,e){let{reference:l,floating:s}=t;const c=l.x+l.width/2-s.width/2,u=l.y+l.height/2-s.height/2,f=a(n),d=r(f),m=l[d]/2-s[d]/2,p="x"===f;let y;switch(i(n)){case"top":y={x:c,y:l.y-s.height};break;case"bottom":y={x:c,y:l.y+l.height};break;case"right":y={x:l.x+l.width,y:u};break;case"left":y={x:l.x-s.width,y:u};break;default:y={x:l.x,y:l.y}}switch(o(n)){case"start":y[f]-=m*(e&&p?-1:1);break;case"end":y[f]+=m*(e&&p?-1:1)}return y}function s(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function c(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function u(t,n){var e;void 0===n&&(n={});const{x:o,y:r,platform:i,rects:a,elements:l,strategy:u}=t,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:m="floating",altBoundary:p=!1,padding:y=0}=n,g=s(y),v=l[p?"floating"===m?"reference":"floating":m],x=c(await i.getClippingRect({element:null==(e=await(null==i.isElement?void 0:i.isElement(v)))||e?v:v.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:d,strategy:u})),h="floating"===m?{...a.floating,x:o,y:r}:a.reference,w=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),b=await(null==i.isElement?void 0:i.isElement(w))&&await(null==i.getScale?void 0:i.getScale(w))||{x:1,y:1},A=c(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:h,offsetParent:w,strategy:u}):h);return{top:(x.top-A.top+g.top)/b.y,bottom:(A.bottom-x.bottom+g.bottom)/b.y,left:(x.left-A.left+g.left)/b.x,right:(A.right-x.right+g.right)/b.x}}const f=Math.min,d=Math.max;function m(t,n,e){return d(t,f(n,e))}const p=["top","right","bottom","left"],y=p.reduce(((t,n)=>t.concat(n,n+"-start",n+"-end")),[]),g={left:"right",right:"left",bottom:"top",top:"bottom"};function v(t){return t.replace(/left|right|bottom|top/g,(t=>g[t]))}function x(t,n,e){void 0===e&&(e=!1);const i=o(t),l=a(t),s=r(l);let c="x"===l?i===(e?"end":"start")?"right":"left":"start"===i?"bottom":"top";return n.reference[s]>n.floating[s]&&(c=v(c)),{main:c,cross:v(c)}}const h={start:"end",end:"start"};function w(t){return t.replace(/start|end/g,(t=>h[t]))}const b=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var e;const{placement:r,middlewareData:a,rects:l,initialPlacement:s,platform:c,elements:f}=n,{mainAxis:d=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=t,A=i(r),P=i(s)===s,k=await(null==c.isRTL?void 0:c.isRTL(f.floating)),R=p||(P||!h?[v(s)]:function(t){const n=v(t);return[w(t),n,w(n)]}(s));p||"none"===g||R.push(...function(t,n,e,r){const a=o(t);let l=function(t,n,e){const o=["left","right"],r=["right","left"],i=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return e?n?r:o:n?o:r;case"left":case"right":return n?i:a;default:return[]}}(i(t),"start"===e,r);return a&&(l=l.map((t=>t+"-"+a)),n&&(l=l.concat(l.map(w)))),l}(s,h,g,k));const D=[s,...R],E=await u(n,b),F=[];let M=(null==(e=a.flip)?void 0:e.overflows)||[];if(d&&F.push(E[A]),m){const{main:t,cross:n}=x(r,l,k);F.push(E[t],E[n])}if(M=[...M,{placement:r,overflows:F}],!F.every((t=>t<=0))){var $;const t=((null==($=a.flip)?void 0:$.index)||0)+1,n=D[t];if(n)return{data:{index:t,overflows:M},reset:{placement:n}};let e="bottom";switch(y){case"bestFit":{var O;const t=null==(O=M.map((t=>[t,t.overflows.filter((t=>t>0)).reduce(((t,n)=>t+n),0)])).sort(((t,n)=>t[1]-n[1]))[0])?void 0:O[0].placement;t&&(e=t);break}case"initialPlacement":e=s}if(r!==e)return{reset:{placement:e}}}return{}}}};function A(t,n){return{top:t.top-n.height,right:t.right-n.width,bottom:t.bottom-n.height,left:t.left-n.width}}function P(t){return p.some((n=>t[n]>=0))}const k=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(n){const{strategy:e="referenceHidden",...o}=t,{rects:r}=n;switch(e){case"referenceHidden":{const t=A(await u(n,{...o,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:P(t)}}}case"escaped":{const t=A(await u(n,{...o,altBoundary:!0}),r.floating);return{data:{escapedOffsets:t,escaped:P(t)}}}default:return{}}}}};function R(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function D(t){if(null==t)return window;if(!R(t)){const n=t.ownerDocument;return n&&n.defaultView||window}return t}function E(t){return D(t).getComputedStyle(t)}function F(t){return R(t)?"":t?(t.nodeName||"").toLowerCase():""}function M(){const t=navigator.userAgentData;return null!=t&&t.brands?t.brands.map((t=>t.brand+"/"+t.version)).join(" "):navigator.userAgent}function $(t){return t instanceof D(t).HTMLElement}function O(t){return t instanceof D(t).Element}function S(t){return"undefined"!=typeof ShadowRoot&&(t instanceof D(t).ShadowRoot||t instanceof ShadowRoot)}function T(t){const{overflow:n,overflowX:e,overflowY:o,display:r}=E(t);return/auto|scroll|overlay|hidden/.test(n+o+e)&&!["inline","contents"].includes(r)}function j(t){return["table","td","th"].includes(F(t))}function B(t){const n=/firefox/i.test(M()),e=E(t);return"none"!==e.transform||"none"!==e.perspective||n&&"filter"===e.willChange||n&&!!e.filter&&"none"!==e.filter||["transform","perspective"].some((t=>e.willChange.includes(t)))||["paint","layout","strict","content"].some((t=>{const n=e.contain;return null!=n&&n.includes(t)}))}function C(){return!/^((?!chrome|android).)*safari/i.test(M())}function z(t){return["html","body","#document"].includes(F(t))}const L=Math.min,H=Math.max,I=Math.round;function W(t,n,e){var o,r,i,a;void 0===n&&(n=!1),void 0===e&&(e=!1);const l=t.getBoundingClientRect();let s=1,c=1;n&&$(t)&&(s=t.offsetWidth>0&&I(l.width)/t.offsetWidth||1,c=t.offsetHeight>0&&I(l.height)/t.offsetHeight||1);const u=O(t)?D(t):window,f=!C()&&e,d=(l.left+(f&&null!=(o=null==(r=u.visualViewport)?void 0:r.offsetLeft)?o:0))/s,m=(l.top+(f&&null!=(i=null==(a=u.visualViewport)?void 0:a.offsetTop)?i:0))/c,p=l.width/s,y=l.height/c;return{width:p,height:y,top:m,right:d+p,bottom:m+y,left:d,x:d,y:m}}function q(t){return(n=t,(n instanceof D(n).Node?t.ownerDocument:t.document)||window.document).documentElement;var n}function N(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function U(t){return W(q(t)).left+N(t).scrollLeft}function V(t,n,e){const o=$(n),r=q(n),i=W(t,o&&function(t){const n=W(t);return I(n.width)!==t.offsetWidth||I(n.height)!==t.offsetHeight}(n),"fixed"===e);let a={scrollLeft:0,scrollTop:0};const l={x:0,y:0};if(o||!o&&"fixed"!==e)if(("body"!==F(n)||T(r))&&(a=N(n)),$(n)){const t=W(n,!0);l.x=t.x+n.clientLeft,l.y=t.y+n.clientTop}else r&&(l.x=U(r));return{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function X(t){return"html"===F(t)?t:t.assignedSlot||t.parentNode||(S(t)?t.host:null)||q(t)}function Y(t){return $(t)&&"fixed"!==E(t).position?t.offsetParent:null}function G(t){const n=D(t);let e=Y(t);for(;e&&j(e)&&"static"===E(e).position;)e=Y(e);return e&&("html"===F(e)||"body"===F(e)&&"static"===E(e).position&&!B(e))?n:e||function(t){let n=X(t);for(S(n)&&(n=n.host);$(n)&&!z(n);){if(B(n))return n;{const t=n.parentNode;n=S(t)?t.host:t}}return null}(t)||n}function J(t){if($(t))return{width:t.offsetWidth,height:t.offsetHeight};const n=W(t);return{width:n.width,height:n.height}}function K(t){const n=X(t);return z(n)?t.ownerDocument.body:$(n)&&T(n)?n:K(n)}function Q(t,n){var e;void 0===n&&(n=[]);const o=K(t),r=o===(null==(e=t.ownerDocument)?void 0:e.body),i=D(o),a=r?[i].concat(i.visualViewport||[],T(o)?o:[]):o,l=n.concat(a);return r?l:l.concat(Q(a))}function Z(t,n,e){return"viewport"===n?c(function(t,n){const e=D(t),o=q(t),r=e.visualViewport;let i=o.clientWidth,a=o.clientHeight,l=0,s=0;if(r){i=r.width,a=r.height;const t=C();(t||!t&&"fixed"===n)&&(l=r.offsetLeft,s=r.offsetTop)}return{width:i,height:a,x:l,y:s}}(t,e)):O(n)?function(t,n){const e=W(t,!1,"fixed"===n),o=e.top+t.clientTop,r=e.left+t.clientLeft;return{top:o,left:r,x:r,y:o,right:r+t.clientWidth,bottom:o+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}(n,e):c(function(t){var n;const e=q(t),o=N(t),r=null==(n=t.ownerDocument)?void 0:n.body,i=H(e.scrollWidth,e.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=H(e.scrollHeight,e.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let l=-o.scrollLeft+U(t);const s=-o.scrollTop;return"rtl"===E(r||e).direction&&(l+=H(e.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:l,y:s}}(q(t)))}function _(t){const n=Q(t),e=function(t,n){let e=t;for(;e&&!z(e)&&!n.includes(e)&&(!O(e)||!["absolute","fixed"].includes(E(e).position));){const t=X(e);e=S(t)?t.host:t}return e}(t,n);let o=null;if(e&&$(e)){const t=G(e);T(e)?o=e:$(t)&&(o=t)}return O(o)?n.filter((t=>o&&O(t)&&function(t,n){const e=null==n.getRootNode?void 0:n.getRootNode();if(t.contains(n))return!0;if(e&&S(e)){let e=n;do{if(e&&t===e)return!0;e=e.parentNode||e.host}while(e)}return!1}(t,o)&&"body"!==F(t))):[]}const tt={getClippingRect:function(t){let{element:n,boundary:e,rootBoundary:o,strategy:r}=t;const i=[..."clippingAncestors"===e?_(n):[].concat(e),o],a=i.reduce(((t,e)=>{const o=Z(n,e,r);return t.top=H(o.top,t.top),t.right=L(o.right,t.right),t.bottom=L(o.bottom,t.bottom),t.left=H(o.left,t.left),t}),Z(n,i[0],r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:n,offsetParent:e,strategy:o}=t;const r=$(e),i=q(e);if(e===i)return n;let a={scrollLeft:0,scrollTop:0};const l={x:0,y:0};if((r||!r&&"fixed"!==o)&&(("body"!==F(e)||T(i))&&(a=N(e)),$(e))){const t=W(e,!0);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}return{...n,x:n.x-a.scrollLeft+l.x,y:n.y-a.scrollTop+l.y}},isElement:O,getDimensions:J,getOffsetParent:G,getDocumentElement:q,getElementRects:t=>{let{reference:n,floating:e,strategy:o}=t;return{reference:V(n,G(e),o),floating:{...J(e),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===E(t).direction};const nt={floatingUINonChromiumPositioningFix:!0,...globalThis.calciteComponentsConfig},et=async function(){if(nt.floatingUINonChromiumPositioningFix&&/firefox|safari/i.test(function(){const t=navigator.userAgentData;return(null==t?void 0:t.brands)?t.brands.map((t=>`${t.brand}/${t.version}`)).join(" "):navigator.userAgent}())){const{getClippingRect:t,getElementRects:n,getOffsetParent:e}=await import("./p-05e64bd1.js");tt.getClippingRect=t,tt.getOffsetParent=e,tt.getElementRects=n}}(),ot="data-placement",rt=["top","bottom","right","left","top-start","top-end","bottom-start","bottom-end","right-start","right-end","left-start","left-end"],it="bottom-start",at={animation:"calcite-floating-ui-anim",animationActive:"calcite-floating-ui-anim--active"};
|
6
|
+
import { c as closestElementCrossShadowBoundary, b as getElementDir } from './p-83166522.js';
|
7
|
+
import { d as debounce } from './p-4e32bf8c.js';
|
8
|
+
|
9
|
+
function getAlignment(placement) {
|
10
|
+
return placement.split('-')[1];
|
11
|
+
}
|
12
|
+
|
13
|
+
function getLengthFromAxis(axis) {
|
14
|
+
return axis === 'y' ? 'height' : 'width';
|
15
|
+
}
|
16
|
+
|
17
|
+
function getSide(placement) {
|
18
|
+
return placement.split('-')[0];
|
19
|
+
}
|
20
|
+
|
21
|
+
function getMainAxisFromPlacement(placement) {
|
22
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
23
|
+
}
|
24
|
+
|
25
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
26
|
+
let {
|
27
|
+
reference,
|
28
|
+
floating
|
29
|
+
} = _ref;
|
30
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
31
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
32
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
33
|
+
const length = getLengthFromAxis(mainAxis);
|
34
|
+
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
35
|
+
const side = getSide(placement);
|
36
|
+
const isVertical = mainAxis === 'x';
|
37
|
+
let coords;
|
38
|
+
switch (side) {
|
39
|
+
case 'top':
|
40
|
+
coords = {
|
41
|
+
x: commonX,
|
42
|
+
y: reference.y - floating.height
|
43
|
+
};
|
44
|
+
break;
|
45
|
+
case 'bottom':
|
46
|
+
coords = {
|
47
|
+
x: commonX,
|
48
|
+
y: reference.y + reference.height
|
49
|
+
};
|
50
|
+
break;
|
51
|
+
case 'right':
|
52
|
+
coords = {
|
53
|
+
x: reference.x + reference.width,
|
54
|
+
y: commonY
|
55
|
+
};
|
56
|
+
break;
|
57
|
+
case 'left':
|
58
|
+
coords = {
|
59
|
+
x: reference.x - floating.width,
|
60
|
+
y: commonY
|
61
|
+
};
|
62
|
+
break;
|
63
|
+
default:
|
64
|
+
coords = {
|
65
|
+
x: reference.x,
|
66
|
+
y: reference.y
|
67
|
+
};
|
68
|
+
}
|
69
|
+
switch (getAlignment(placement)) {
|
70
|
+
case 'start':
|
71
|
+
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
72
|
+
break;
|
73
|
+
case 'end':
|
74
|
+
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
return coords;
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
82
|
+
* next to a reference element when it is given a certain positioning strategy.
|
83
|
+
*
|
84
|
+
* This export does not have any `platform` interface logic. You will need to
|
85
|
+
* write one for the platform you are using Floating UI with.
|
86
|
+
*/
|
87
|
+
const computePosition$1 = async (reference, floating, config) => {
|
88
|
+
const {
|
89
|
+
placement = 'bottom',
|
90
|
+
strategy = 'absolute',
|
91
|
+
middleware = [],
|
92
|
+
platform
|
93
|
+
} = config;
|
94
|
+
const validMiddleware = middleware.filter(Boolean);
|
95
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
96
|
+
let rects = await platform.getElementRects({
|
97
|
+
reference,
|
98
|
+
floating,
|
99
|
+
strategy
|
100
|
+
});
|
101
|
+
let {
|
102
|
+
x,
|
103
|
+
y
|
104
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
105
|
+
let statefulPlacement = placement;
|
106
|
+
let middlewareData = {};
|
107
|
+
let resetCount = 0;
|
108
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
109
|
+
const {
|
110
|
+
name,
|
111
|
+
fn
|
112
|
+
} = validMiddleware[i];
|
113
|
+
const {
|
114
|
+
x: nextX,
|
115
|
+
y: nextY,
|
116
|
+
data,
|
117
|
+
reset
|
118
|
+
} = await fn({
|
119
|
+
x,
|
120
|
+
y,
|
121
|
+
initialPlacement: placement,
|
122
|
+
placement: statefulPlacement,
|
123
|
+
strategy,
|
124
|
+
middlewareData,
|
125
|
+
rects,
|
126
|
+
platform,
|
127
|
+
elements: {
|
128
|
+
reference,
|
129
|
+
floating
|
130
|
+
}
|
131
|
+
});
|
132
|
+
x = nextX != null ? nextX : x;
|
133
|
+
y = nextY != null ? nextY : y;
|
134
|
+
middlewareData = {
|
135
|
+
...middlewareData,
|
136
|
+
[name]: {
|
137
|
+
...middlewareData[name],
|
138
|
+
...data
|
139
|
+
}
|
140
|
+
};
|
141
|
+
if (reset && resetCount <= 50) {
|
142
|
+
resetCount++;
|
143
|
+
if (typeof reset === 'object') {
|
144
|
+
if (reset.placement) {
|
145
|
+
statefulPlacement = reset.placement;
|
146
|
+
}
|
147
|
+
if (reset.rects) {
|
148
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
149
|
+
reference,
|
150
|
+
floating,
|
151
|
+
strategy
|
152
|
+
}) : reset.rects;
|
153
|
+
}
|
154
|
+
({
|
155
|
+
x,
|
156
|
+
y
|
157
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
158
|
+
}
|
159
|
+
i = -1;
|
160
|
+
continue;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
return {
|
164
|
+
x,
|
165
|
+
y,
|
166
|
+
placement: statefulPlacement,
|
167
|
+
strategy,
|
168
|
+
middlewareData
|
169
|
+
};
|
170
|
+
};
|
171
|
+
|
172
|
+
function expandPaddingObject(padding) {
|
173
|
+
return {
|
174
|
+
top: 0,
|
175
|
+
right: 0,
|
176
|
+
bottom: 0,
|
177
|
+
left: 0,
|
178
|
+
...padding
|
179
|
+
};
|
180
|
+
}
|
181
|
+
|
182
|
+
function getSideObjectFromPadding(padding) {
|
183
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
184
|
+
top: padding,
|
185
|
+
right: padding,
|
186
|
+
bottom: padding,
|
187
|
+
left: padding
|
188
|
+
};
|
189
|
+
}
|
190
|
+
|
191
|
+
function rectToClientRect(rect) {
|
192
|
+
return {
|
193
|
+
...rect,
|
194
|
+
top: rect.y,
|
195
|
+
left: rect.x,
|
196
|
+
right: rect.x + rect.width,
|
197
|
+
bottom: rect.y + rect.height
|
198
|
+
};
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
203
|
+
* element is overflowing a given clipping boundary.
|
204
|
+
* - positive = overflowing the boundary by that number of pixels
|
205
|
+
* - negative = how many pixels left before it will overflow
|
206
|
+
* - 0 = lies flush with the boundary
|
207
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
208
|
+
*/
|
209
|
+
async function detectOverflow(middlewareArguments, options) {
|
210
|
+
var _await$platform$isEle;
|
211
|
+
if (options === void 0) {
|
212
|
+
options = {};
|
213
|
+
}
|
214
|
+
const {
|
215
|
+
x,
|
216
|
+
y,
|
217
|
+
platform,
|
218
|
+
rects,
|
219
|
+
elements,
|
220
|
+
strategy
|
221
|
+
} = middlewareArguments;
|
222
|
+
const {
|
223
|
+
boundary = 'clippingAncestors',
|
224
|
+
rootBoundary = 'viewport',
|
225
|
+
elementContext = 'floating',
|
226
|
+
altBoundary = false,
|
227
|
+
padding = 0
|
228
|
+
} = options;
|
229
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
230
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
231
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
232
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
233
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
234
|
+
boundary,
|
235
|
+
rootBoundary,
|
236
|
+
strategy
|
237
|
+
}));
|
238
|
+
const rect = elementContext === 'floating' ? {
|
239
|
+
...rects.floating,
|
240
|
+
x,
|
241
|
+
y
|
242
|
+
} : rects.reference;
|
243
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
244
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
245
|
+
x: 1,
|
246
|
+
y: 1
|
247
|
+
} : {
|
248
|
+
x: 1,
|
249
|
+
y: 1
|
250
|
+
};
|
251
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
252
|
+
rect,
|
253
|
+
offsetParent,
|
254
|
+
strategy
|
255
|
+
}) : rect);
|
256
|
+
return {
|
257
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
258
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
259
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
260
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
261
|
+
};
|
262
|
+
}
|
263
|
+
|
264
|
+
const min$1 = Math.min;
|
265
|
+
const max$1 = Math.max;
|
266
|
+
|
267
|
+
function within(min$1$1, value, max$1$1) {
|
268
|
+
return max$1(min$1$1, min$1(value, max$1$1));
|
269
|
+
}
|
270
|
+
|
271
|
+
/**
|
272
|
+
* Positions an inner element of the floating element such that it is centered
|
273
|
+
* to the reference element.
|
274
|
+
* @see https://floating-ui.com/docs/arrow
|
275
|
+
*/
|
276
|
+
const arrow = options => ({
|
277
|
+
name: 'arrow',
|
278
|
+
options,
|
279
|
+
async fn(middlewareArguments) {
|
280
|
+
// Since `element` is required, we don't Partial<> the type.
|
281
|
+
const {
|
282
|
+
element,
|
283
|
+
padding = 0
|
284
|
+
} = options || {};
|
285
|
+
const {
|
286
|
+
x,
|
287
|
+
y,
|
288
|
+
placement,
|
289
|
+
rects,
|
290
|
+
platform
|
291
|
+
} = middlewareArguments;
|
292
|
+
if (element == null) {
|
293
|
+
return {};
|
294
|
+
}
|
295
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
296
|
+
const coords = {
|
297
|
+
x,
|
298
|
+
y
|
299
|
+
};
|
300
|
+
const axis = getMainAxisFromPlacement(placement);
|
301
|
+
const length = getLengthFromAxis(axis);
|
302
|
+
const arrowDimensions = await platform.getDimensions(element);
|
303
|
+
const minProp = axis === 'y' ? 'top' : 'left';
|
304
|
+
const maxProp = axis === 'y' ? 'bottom' : 'right';
|
305
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
306
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
307
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
308
|
+
let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
309
|
+
if (clientSize === 0) {
|
310
|
+
clientSize = rects.floating[length];
|
311
|
+
}
|
312
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
313
|
+
|
314
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
315
|
+
// point is outside the floating element's bounds.
|
316
|
+
const min = paddingObject[minProp];
|
317
|
+
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
318
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
319
|
+
const offset = within(min, center, max);
|
320
|
+
|
321
|
+
// If the reference is small enough that the arrow's padding causes it to
|
322
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
323
|
+
// floating element itself. This stops `shift()` from taking action, but can
|
324
|
+
// be worked around by calling it again after the `arrow()` if desired.
|
325
|
+
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
|
326
|
+
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
327
|
+
return {
|
328
|
+
[axis]: coords[axis] - alignmentOffset,
|
329
|
+
data: {
|
330
|
+
[axis]: offset,
|
331
|
+
centerOffset: center - offset
|
332
|
+
}
|
333
|
+
};
|
334
|
+
}
|
335
|
+
});
|
336
|
+
|
337
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
338
|
+
const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
|
339
|
+
|
340
|
+
const oppositeSideMap = {
|
341
|
+
left: 'right',
|
342
|
+
right: 'left',
|
343
|
+
bottom: 'top',
|
344
|
+
top: 'bottom'
|
345
|
+
};
|
346
|
+
function getOppositePlacement(placement) {
|
347
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
348
|
+
}
|
349
|
+
|
350
|
+
function getAlignmentSides(placement, rects, rtl) {
|
351
|
+
if (rtl === void 0) {
|
352
|
+
rtl = false;
|
353
|
+
}
|
354
|
+
const alignment = getAlignment(placement);
|
355
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
356
|
+
const length = getLengthFromAxis(mainAxis);
|
357
|
+
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
358
|
+
if (rects.reference[length] > rects.floating[length]) {
|
359
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
360
|
+
}
|
361
|
+
return {
|
362
|
+
main: mainAlignmentSide,
|
363
|
+
cross: getOppositePlacement(mainAlignmentSide)
|
364
|
+
};
|
365
|
+
}
|
366
|
+
|
367
|
+
const oppositeAlignmentMap = {
|
368
|
+
start: 'end',
|
369
|
+
end: 'start'
|
370
|
+
};
|
371
|
+
function getOppositeAlignmentPlacement(placement) {
|
372
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
373
|
+
}
|
374
|
+
|
375
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
376
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
377
|
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
378
|
+
if (alignment) {
|
379
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
380
|
+
}
|
381
|
+
return true;
|
382
|
+
});
|
383
|
+
}
|
384
|
+
/**
|
385
|
+
* Automatically chooses the `placement` which has the most space available.
|
386
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
387
|
+
*/
|
388
|
+
const autoPlacement = function (options) {
|
389
|
+
if (options === void 0) {
|
390
|
+
options = {};
|
391
|
+
}
|
392
|
+
return {
|
393
|
+
name: 'autoPlacement',
|
394
|
+
options,
|
395
|
+
async fn(middlewareArguments) {
|
396
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsSortedByLe;
|
397
|
+
const {
|
398
|
+
rects,
|
399
|
+
middlewareData,
|
400
|
+
placement,
|
401
|
+
platform,
|
402
|
+
elements
|
403
|
+
} = middlewareArguments;
|
404
|
+
const {
|
405
|
+
alignment,
|
406
|
+
allowedPlacements = allPlacements,
|
407
|
+
autoAlignment = true,
|
408
|
+
...detectOverflowOptions
|
409
|
+
} = options;
|
410
|
+
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
411
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
412
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
413
|
+
const currentPlacement = placements[currentIndex];
|
414
|
+
if (currentPlacement == null) {
|
415
|
+
return {};
|
416
|
+
}
|
417
|
+
const {
|
418
|
+
main,
|
419
|
+
cross
|
420
|
+
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
421
|
+
|
422
|
+
// Make `computeCoords` start from the right place.
|
423
|
+
if (placement !== currentPlacement) {
|
424
|
+
return {
|
425
|
+
reset: {
|
426
|
+
placement: placements[0]
|
427
|
+
}
|
428
|
+
};
|
429
|
+
}
|
430
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
|
431
|
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
432
|
+
placement: currentPlacement,
|
433
|
+
overflows: currentOverflows
|
434
|
+
}];
|
435
|
+
const nextPlacement = placements[currentIndex + 1];
|
436
|
+
|
437
|
+
// There are more placements to check.
|
438
|
+
if (nextPlacement) {
|
439
|
+
return {
|
440
|
+
data: {
|
441
|
+
index: currentIndex + 1,
|
442
|
+
overflows: allOverflows
|
443
|
+
},
|
444
|
+
reset: {
|
445
|
+
placement: nextPlacement
|
446
|
+
}
|
447
|
+
};
|
448
|
+
}
|
449
|
+
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
|
450
|
+
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
|
451
|
+
let {
|
452
|
+
overflows
|
453
|
+
} = _ref;
|
454
|
+
return overflows.every(overflow => overflow <= 0);
|
455
|
+
})) == null ? void 0 : _placementsSortedByLe.placement;
|
456
|
+
const resetPlacement = placementThatFitsOnAllSides || placementsSortedByLeastOverflow[0].placement;
|
457
|
+
if (resetPlacement !== placement) {
|
458
|
+
return {
|
459
|
+
data: {
|
460
|
+
index: currentIndex + 1,
|
461
|
+
overflows: allOverflows
|
462
|
+
},
|
463
|
+
reset: {
|
464
|
+
placement: resetPlacement
|
465
|
+
}
|
466
|
+
};
|
467
|
+
}
|
468
|
+
return {};
|
469
|
+
}
|
470
|
+
};
|
471
|
+
};
|
472
|
+
|
473
|
+
function getExpandedPlacements(placement) {
|
474
|
+
const oppositePlacement = getOppositePlacement(placement);
|
475
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
476
|
+
}
|
477
|
+
|
478
|
+
function getSideList(side, isStart, rtl) {
|
479
|
+
const lr = ['left', 'right'];
|
480
|
+
const rl = ['right', 'left'];
|
481
|
+
const tb = ['top', 'bottom'];
|
482
|
+
const bt = ['bottom', 'top'];
|
483
|
+
switch (side) {
|
484
|
+
case 'top':
|
485
|
+
case 'bottom':
|
486
|
+
if (rtl) return isStart ? rl : lr;
|
487
|
+
return isStart ? lr : rl;
|
488
|
+
case 'left':
|
489
|
+
case 'right':
|
490
|
+
return isStart ? tb : bt;
|
491
|
+
default:
|
492
|
+
return [];
|
493
|
+
}
|
494
|
+
}
|
495
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
496
|
+
const alignment = getAlignment(placement);
|
497
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
498
|
+
if (alignment) {
|
499
|
+
list = list.map(side => side + "-" + alignment);
|
500
|
+
if (flipAlignment) {
|
501
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
502
|
+
}
|
503
|
+
}
|
504
|
+
return list;
|
505
|
+
}
|
506
|
+
|
507
|
+
/**
|
508
|
+
* Changes the placement of the floating element to one that will fit if the
|
509
|
+
* initially specified `placement` does not.
|
510
|
+
* @see https://floating-ui.com/docs/flip
|
511
|
+
*/
|
512
|
+
const flip = function (options) {
|
513
|
+
if (options === void 0) {
|
514
|
+
options = {};
|
515
|
+
}
|
516
|
+
return {
|
517
|
+
name: 'flip',
|
518
|
+
options,
|
519
|
+
async fn(middlewareArguments) {
|
520
|
+
var _middlewareData$flip;
|
521
|
+
const {
|
522
|
+
placement,
|
523
|
+
middlewareData,
|
524
|
+
rects,
|
525
|
+
initialPlacement,
|
526
|
+
platform,
|
527
|
+
elements
|
528
|
+
} = middlewareArguments;
|
529
|
+
const {
|
530
|
+
mainAxis: checkMainAxis = true,
|
531
|
+
crossAxis: checkCrossAxis = true,
|
532
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
533
|
+
fallbackStrategy = 'bestFit',
|
534
|
+
fallbackAxisSideDirection = 'none',
|
535
|
+
flipAlignment = true,
|
536
|
+
...detectOverflowOptions
|
537
|
+
} = options;
|
538
|
+
const side = getSide(placement);
|
539
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
540
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
541
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
542
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
543
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
544
|
+
}
|
545
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
546
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
547
|
+
const overflows = [];
|
548
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
549
|
+
if (checkMainAxis) {
|
550
|
+
overflows.push(overflow[side]);
|
551
|
+
}
|
552
|
+
if (checkCrossAxis) {
|
553
|
+
const {
|
554
|
+
main,
|
555
|
+
cross
|
556
|
+
} = getAlignmentSides(placement, rects, rtl);
|
557
|
+
overflows.push(overflow[main], overflow[cross]);
|
558
|
+
}
|
559
|
+
overflowsData = [...overflowsData, {
|
560
|
+
placement,
|
561
|
+
overflows
|
562
|
+
}];
|
563
|
+
|
564
|
+
// One or more sides is overflowing.
|
565
|
+
if (!overflows.every(side => side <= 0)) {
|
566
|
+
var _middlewareData$flip2;
|
567
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
568
|
+
const nextPlacement = placements[nextIndex];
|
569
|
+
if (nextPlacement) {
|
570
|
+
// Try next placement and re-run the lifecycle.
|
571
|
+
return {
|
572
|
+
data: {
|
573
|
+
index: nextIndex,
|
574
|
+
overflows: overflowsData
|
575
|
+
},
|
576
|
+
reset: {
|
577
|
+
placement: nextPlacement
|
578
|
+
}
|
579
|
+
};
|
580
|
+
}
|
581
|
+
let resetPlacement = 'bottom';
|
582
|
+
switch (fallbackStrategy) {
|
583
|
+
case 'bestFit':
|
584
|
+
{
|
585
|
+
var _overflowsData$map$so;
|
586
|
+
const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
|
587
|
+
if (placement) {
|
588
|
+
resetPlacement = placement;
|
589
|
+
}
|
590
|
+
break;
|
591
|
+
}
|
592
|
+
case 'initialPlacement':
|
593
|
+
resetPlacement = initialPlacement;
|
594
|
+
break;
|
595
|
+
}
|
596
|
+
if (placement !== resetPlacement) {
|
597
|
+
return {
|
598
|
+
reset: {
|
599
|
+
placement: resetPlacement
|
600
|
+
}
|
601
|
+
};
|
602
|
+
}
|
603
|
+
}
|
604
|
+
return {};
|
605
|
+
}
|
606
|
+
};
|
607
|
+
};
|
608
|
+
|
609
|
+
function getSideOffsets(overflow, rect) {
|
610
|
+
return {
|
611
|
+
top: overflow.top - rect.height,
|
612
|
+
right: overflow.right - rect.width,
|
613
|
+
bottom: overflow.bottom - rect.height,
|
614
|
+
left: overflow.left - rect.width
|
615
|
+
};
|
616
|
+
}
|
617
|
+
function isAnySideFullyClipped(overflow) {
|
618
|
+
return sides.some(side => overflow[side] >= 0);
|
619
|
+
}
|
620
|
+
/**
|
621
|
+
* Provides data to hide the floating element in applicable situations, such as
|
622
|
+
* when it is not in the same clipping context as the reference element.
|
623
|
+
* @see https://floating-ui.com/docs/hide
|
624
|
+
*/
|
625
|
+
const hide = function (options) {
|
626
|
+
if (options === void 0) {
|
627
|
+
options = {};
|
628
|
+
}
|
629
|
+
return {
|
630
|
+
name: 'hide',
|
631
|
+
options,
|
632
|
+
async fn(middlewareArguments) {
|
633
|
+
const {
|
634
|
+
strategy = 'referenceHidden',
|
635
|
+
...detectOverflowOptions
|
636
|
+
} = options;
|
637
|
+
const {
|
638
|
+
rects
|
639
|
+
} = middlewareArguments;
|
640
|
+
switch (strategy) {
|
641
|
+
case 'referenceHidden':
|
642
|
+
{
|
643
|
+
const overflow = await detectOverflow(middlewareArguments, {
|
644
|
+
...detectOverflowOptions,
|
645
|
+
elementContext: 'reference'
|
646
|
+
});
|
647
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
648
|
+
return {
|
649
|
+
data: {
|
650
|
+
referenceHiddenOffsets: offsets,
|
651
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
652
|
+
}
|
653
|
+
};
|
654
|
+
}
|
655
|
+
case 'escaped':
|
656
|
+
{
|
657
|
+
const overflow = await detectOverflow(middlewareArguments, {
|
658
|
+
...detectOverflowOptions,
|
659
|
+
altBoundary: true
|
660
|
+
});
|
661
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
662
|
+
return {
|
663
|
+
data: {
|
664
|
+
escapedOffsets: offsets,
|
665
|
+
escaped: isAnySideFullyClipped(offsets)
|
666
|
+
}
|
667
|
+
};
|
668
|
+
}
|
669
|
+
default:
|
670
|
+
{
|
671
|
+
return {};
|
672
|
+
}
|
673
|
+
}
|
674
|
+
}
|
675
|
+
};
|
676
|
+
};
|
677
|
+
|
678
|
+
async function convertValueToCoords(middlewareArguments, value) {
|
679
|
+
const {
|
680
|
+
placement,
|
681
|
+
platform,
|
682
|
+
elements
|
683
|
+
} = middlewareArguments;
|
684
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
685
|
+
const side = getSide(placement);
|
686
|
+
const alignment = getAlignment(placement);
|
687
|
+
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
688
|
+
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
689
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
690
|
+
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
|
691
|
+
|
692
|
+
// eslint-disable-next-line prefer-const
|
693
|
+
let {
|
694
|
+
mainAxis,
|
695
|
+
crossAxis,
|
696
|
+
alignmentAxis
|
697
|
+
} = typeof rawValue === 'number' ? {
|
698
|
+
mainAxis: rawValue,
|
699
|
+
crossAxis: 0,
|
700
|
+
alignmentAxis: null
|
701
|
+
} : {
|
702
|
+
mainAxis: 0,
|
703
|
+
crossAxis: 0,
|
704
|
+
alignmentAxis: null,
|
705
|
+
...rawValue
|
706
|
+
};
|
707
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
708
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
709
|
+
}
|
710
|
+
return isVertical ? {
|
711
|
+
x: crossAxis * crossAxisMulti,
|
712
|
+
y: mainAxis * mainAxisMulti
|
713
|
+
} : {
|
714
|
+
x: mainAxis * mainAxisMulti,
|
715
|
+
y: crossAxis * crossAxisMulti
|
716
|
+
};
|
717
|
+
}
|
718
|
+
|
719
|
+
/**
|
720
|
+
* Displaces the floating element from its reference element.
|
721
|
+
* @see https://floating-ui.com/docs/offset
|
722
|
+
*/
|
723
|
+
const offset = function (value) {
|
724
|
+
if (value === void 0) {
|
725
|
+
value = 0;
|
726
|
+
}
|
727
|
+
return {
|
728
|
+
name: 'offset',
|
729
|
+
options: value,
|
730
|
+
async fn(middlewareArguments) {
|
731
|
+
const {
|
732
|
+
x,
|
733
|
+
y
|
734
|
+
} = middlewareArguments;
|
735
|
+
const diffCoords = await convertValueToCoords(middlewareArguments, value);
|
736
|
+
return {
|
737
|
+
x: x + diffCoords.x,
|
738
|
+
y: y + diffCoords.y,
|
739
|
+
data: diffCoords
|
740
|
+
};
|
741
|
+
}
|
742
|
+
};
|
743
|
+
};
|
744
|
+
|
745
|
+
function getCrossAxis(axis) {
|
746
|
+
return axis === 'x' ? 'y' : 'x';
|
747
|
+
}
|
748
|
+
|
749
|
+
/**
|
750
|
+
* Shifts the floating element in order to keep it in view when it will overflow
|
751
|
+
* a clipping boundary.
|
752
|
+
* @see https://floating-ui.com/docs/shift
|
753
|
+
*/
|
754
|
+
const shift = function (options) {
|
755
|
+
if (options === void 0) {
|
756
|
+
options = {};
|
757
|
+
}
|
758
|
+
return {
|
759
|
+
name: 'shift',
|
760
|
+
options,
|
761
|
+
async fn(middlewareArguments) {
|
762
|
+
const {
|
763
|
+
x,
|
764
|
+
y,
|
765
|
+
placement
|
766
|
+
} = middlewareArguments;
|
767
|
+
const {
|
768
|
+
mainAxis: checkMainAxis = true,
|
769
|
+
crossAxis: checkCrossAxis = false,
|
770
|
+
limiter = {
|
771
|
+
fn: _ref => {
|
772
|
+
let {
|
773
|
+
x,
|
774
|
+
y
|
775
|
+
} = _ref;
|
776
|
+
return {
|
777
|
+
x,
|
778
|
+
y
|
779
|
+
};
|
780
|
+
}
|
781
|
+
},
|
782
|
+
...detectOverflowOptions
|
783
|
+
} = options;
|
784
|
+
const coords = {
|
785
|
+
x,
|
786
|
+
y
|
787
|
+
};
|
788
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
789
|
+
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
790
|
+
const crossAxis = getCrossAxis(mainAxis);
|
791
|
+
let mainAxisCoord = coords[mainAxis];
|
792
|
+
let crossAxisCoord = coords[crossAxis];
|
793
|
+
if (checkMainAxis) {
|
794
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
795
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
796
|
+
const min = mainAxisCoord + overflow[minSide];
|
797
|
+
const max = mainAxisCoord - overflow[maxSide];
|
798
|
+
mainAxisCoord = within(min, mainAxisCoord, max);
|
799
|
+
}
|
800
|
+
if (checkCrossAxis) {
|
801
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
802
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
803
|
+
const min = crossAxisCoord + overflow[minSide];
|
804
|
+
const max = crossAxisCoord - overflow[maxSide];
|
805
|
+
crossAxisCoord = within(min, crossAxisCoord, max);
|
806
|
+
}
|
807
|
+
const limitedCoords = limiter.fn({
|
808
|
+
...middlewareArguments,
|
809
|
+
[mainAxis]: mainAxisCoord,
|
810
|
+
[crossAxis]: crossAxisCoord
|
811
|
+
});
|
812
|
+
return {
|
813
|
+
...limitedCoords,
|
814
|
+
data: {
|
815
|
+
x: limitedCoords.x - x,
|
816
|
+
y: limitedCoords.y - y
|
817
|
+
}
|
818
|
+
};
|
819
|
+
}
|
820
|
+
};
|
821
|
+
};
|
822
|
+
|
823
|
+
function isWindow(value) {
|
824
|
+
return value && value.document && value.location && value.alert && value.setInterval;
|
825
|
+
}
|
826
|
+
function getWindow(node) {
|
827
|
+
if (node == null) {
|
828
|
+
return window;
|
829
|
+
}
|
830
|
+
|
831
|
+
if (!isWindow(node)) {
|
832
|
+
const ownerDocument = node.ownerDocument;
|
833
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
834
|
+
}
|
835
|
+
|
836
|
+
return node;
|
837
|
+
}
|
838
|
+
|
839
|
+
function getComputedStyle(element) {
|
840
|
+
return getWindow(element).getComputedStyle(element);
|
841
|
+
}
|
842
|
+
|
843
|
+
function getNodeName(node) {
|
844
|
+
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
845
|
+
}
|
846
|
+
|
847
|
+
function getUAString() {
|
848
|
+
const uaData = navigator.userAgentData;
|
849
|
+
|
850
|
+
if (uaData != null && uaData.brands) {
|
851
|
+
return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
852
|
+
}
|
853
|
+
|
854
|
+
return navigator.userAgent;
|
855
|
+
}
|
856
|
+
|
857
|
+
function isHTMLElement(value) {
|
858
|
+
return value instanceof getWindow(value).HTMLElement;
|
859
|
+
}
|
860
|
+
function isElement(value) {
|
861
|
+
return value instanceof getWindow(value).Element;
|
862
|
+
}
|
863
|
+
function isNode(value) {
|
864
|
+
return value instanceof getWindow(value).Node;
|
865
|
+
}
|
866
|
+
function isShadowRoot(node) {
|
867
|
+
// Browsers without `ShadowRoot` support
|
868
|
+
if (typeof ShadowRoot === 'undefined') {
|
869
|
+
return false;
|
870
|
+
}
|
871
|
+
|
872
|
+
const OwnElement = getWindow(node).ShadowRoot;
|
873
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
874
|
+
}
|
875
|
+
function isOverflowElement(element) {
|
876
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
877
|
+
const {
|
878
|
+
overflow,
|
879
|
+
overflowX,
|
880
|
+
overflowY,
|
881
|
+
display
|
882
|
+
} = getComputedStyle(element);
|
883
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
884
|
+
}
|
885
|
+
function isTableElement(element) {
|
886
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
887
|
+
}
|
888
|
+
function isContainingBlock(element) {
|
889
|
+
// TODO: Try and use feature detection here instead
|
890
|
+
const isFirefox = /firefox/i.test(getUAString());
|
891
|
+
const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that
|
892
|
+
// create a containing block.
|
893
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
894
|
+
|
895
|
+
return css.transform !== 'none' || css.perspective !== 'none' || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some( // TS 4.1 compat
|
896
|
+
value => {
|
897
|
+
const contain = css.contain;
|
898
|
+
return contain != null ? contain.includes(value) : false;
|
899
|
+
});
|
900
|
+
}
|
901
|
+
function isLayoutViewport() {
|
902
|
+
// Not Safari
|
903
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
|
904
|
+
// • Always-visible scrollbar or not
|
905
|
+
// • Width of <html>, etc.
|
906
|
+
// const vV = win.visualViewport;
|
907
|
+
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
|
908
|
+
}
|
909
|
+
function isLastTraversableNode(node) {
|
910
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
911
|
+
}
|
912
|
+
|
913
|
+
const min = Math.min;
|
914
|
+
const max = Math.max;
|
915
|
+
const round = Math.round;
|
916
|
+
|
917
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
918
|
+
var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
|
919
|
+
|
920
|
+
if (includeScale === void 0) {
|
921
|
+
includeScale = false;
|
922
|
+
}
|
923
|
+
|
924
|
+
if (isFixedStrategy === void 0) {
|
925
|
+
isFixedStrategy = false;
|
926
|
+
}
|
927
|
+
|
928
|
+
const clientRect = element.getBoundingClientRect();
|
929
|
+
let scaleX = 1;
|
930
|
+
let scaleY = 1;
|
931
|
+
|
932
|
+
if (includeScale && isHTMLElement(element)) {
|
933
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
934
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
935
|
+
}
|
936
|
+
|
937
|
+
const win = isElement(element) ? getWindow(element) : window;
|
938
|
+
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
939
|
+
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
|
940
|
+
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
|
941
|
+
const width = clientRect.width / scaleX;
|
942
|
+
const height = clientRect.height / scaleY;
|
943
|
+
return {
|
944
|
+
width,
|
945
|
+
height,
|
946
|
+
top: y,
|
947
|
+
right: x + width,
|
948
|
+
bottom: y + height,
|
949
|
+
left: x,
|
950
|
+
x,
|
951
|
+
y
|
952
|
+
};
|
953
|
+
}
|
954
|
+
|
955
|
+
function getDocumentElement(node) {
|
956
|
+
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
957
|
+
}
|
958
|
+
|
959
|
+
function getNodeScroll(element) {
|
960
|
+
if (isElement(element)) {
|
961
|
+
return {
|
962
|
+
scrollLeft: element.scrollLeft,
|
963
|
+
scrollTop: element.scrollTop
|
964
|
+
};
|
965
|
+
}
|
966
|
+
|
967
|
+
return {
|
968
|
+
scrollLeft: element.pageXOffset,
|
969
|
+
scrollTop: element.pageYOffset
|
970
|
+
};
|
971
|
+
}
|
972
|
+
|
973
|
+
function getWindowScrollBarX(element) {
|
974
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
975
|
+
// incorrect for RTL.
|
976
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
977
|
+
}
|
978
|
+
|
979
|
+
function isScaled(element) {
|
980
|
+
const rect = getBoundingClientRect(element);
|
981
|
+
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
982
|
+
}
|
983
|
+
|
984
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
985
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
986
|
+
const documentElement = getDocumentElement(offsetParent);
|
987
|
+
const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
|
988
|
+
isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
|
989
|
+
let scroll = {
|
990
|
+
scrollLeft: 0,
|
991
|
+
scrollTop: 0
|
992
|
+
};
|
993
|
+
const offsets = {
|
994
|
+
x: 0,
|
995
|
+
y: 0
|
996
|
+
};
|
997
|
+
|
998
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
999
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
1000
|
+
scroll = getNodeScroll(offsetParent);
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
if (isHTMLElement(offsetParent)) {
|
1004
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
1005
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
1006
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
1007
|
+
} else if (documentElement) {
|
1008
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
1009
|
+
}
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
return {
|
1013
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
1014
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
1015
|
+
width: rect.width,
|
1016
|
+
height: rect.height
|
1017
|
+
};
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
function getParentNode(node) {
|
1021
|
+
if (getNodeName(node) === 'html') {
|
1022
|
+
return node;
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
1026
|
+
// @ts-ignore
|
1027
|
+
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
1028
|
+
node.parentNode || ( // DOM Element detected
|
1029
|
+
isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
1030
|
+
getDocumentElement(node) // fallback
|
1031
|
+
|
1032
|
+
);
|
1033
|
+
}
|
1034
|
+
|
1035
|
+
function getTrueOffsetParent(element) {
|
1036
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
1037
|
+
return null;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
return element.offsetParent;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
function getContainingBlock(element) {
|
1044
|
+
let currentNode = getParentNode(element);
|
1045
|
+
|
1046
|
+
if (isShadowRoot(currentNode)) {
|
1047
|
+
currentNode = currentNode.host;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
1051
|
+
if (isContainingBlock(currentNode)) {
|
1052
|
+
return currentNode;
|
1053
|
+
} else {
|
1054
|
+
const parent = currentNode.parentNode;
|
1055
|
+
currentNode = isShadowRoot(parent) ? parent.host : parent;
|
1056
|
+
}
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
return null;
|
1060
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
1061
|
+
// such as table ancestors and cross browser bugs.
|
1062
|
+
|
1063
|
+
|
1064
|
+
function getOffsetParent(element) {
|
1065
|
+
const window = getWindow(element);
|
1066
|
+
let offsetParent = getTrueOffsetParent(element);
|
1067
|
+
|
1068
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
1069
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
1073
|
+
return window;
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
return offsetParent || getContainingBlock(element) || window;
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
function getDimensions(element) {
|
1080
|
+
if (isHTMLElement(element)) {
|
1081
|
+
return {
|
1082
|
+
width: element.offsetWidth,
|
1083
|
+
height: element.offsetHeight
|
1084
|
+
};
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
const rect = getBoundingClientRect(element);
|
1088
|
+
return {
|
1089
|
+
width: rect.width,
|
1090
|
+
height: rect.height
|
1091
|
+
};
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
1095
|
+
let {
|
1096
|
+
rect,
|
1097
|
+
offsetParent,
|
1098
|
+
strategy
|
1099
|
+
} = _ref;
|
1100
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
1101
|
+
const documentElement = getDocumentElement(offsetParent);
|
1102
|
+
|
1103
|
+
if (offsetParent === documentElement) {
|
1104
|
+
return rect;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
let scroll = {
|
1108
|
+
scrollLeft: 0,
|
1109
|
+
scrollTop: 0
|
1110
|
+
};
|
1111
|
+
const offsets = {
|
1112
|
+
x: 0,
|
1113
|
+
y: 0
|
1114
|
+
};
|
1115
|
+
|
1116
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
1117
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
1118
|
+
scroll = getNodeScroll(offsetParent);
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
if (isHTMLElement(offsetParent)) {
|
1122
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
1123
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
1124
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
1125
|
+
} // This doesn't appear to be need to be negated.
|
1126
|
+
// else if (documentElement) {
|
1127
|
+
// offsets.x = getWindowScrollBarX(documentElement);
|
1128
|
+
// }
|
1129
|
+
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
return { ...rect,
|
1133
|
+
x: rect.x - scroll.scrollLeft + offsets.x,
|
1134
|
+
y: rect.y - scroll.scrollTop + offsets.y
|
1135
|
+
};
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
function getViewportRect(element, strategy) {
|
1139
|
+
const win = getWindow(element);
|
1140
|
+
const html = getDocumentElement(element);
|
1141
|
+
const visualViewport = win.visualViewport;
|
1142
|
+
let width = html.clientWidth;
|
1143
|
+
let height = html.clientHeight;
|
1144
|
+
let x = 0;
|
1145
|
+
let y = 0;
|
1146
|
+
|
1147
|
+
if (visualViewport) {
|
1148
|
+
width = visualViewport.width;
|
1149
|
+
height = visualViewport.height;
|
1150
|
+
const layoutViewport = isLayoutViewport();
|
1151
|
+
|
1152
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
1153
|
+
x = visualViewport.offsetLeft;
|
1154
|
+
y = visualViewport.offsetTop;
|
1155
|
+
}
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
return {
|
1159
|
+
width,
|
1160
|
+
height,
|
1161
|
+
x,
|
1162
|
+
y
|
1163
|
+
};
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
1167
|
+
|
1168
|
+
function getDocumentRect(element) {
|
1169
|
+
var _element$ownerDocumen;
|
1170
|
+
|
1171
|
+
const html = getDocumentElement(element);
|
1172
|
+
const scroll = getNodeScroll(element);
|
1173
|
+
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
1174
|
+
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
1175
|
+
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
1176
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
1177
|
+
const y = -scroll.scrollTop;
|
1178
|
+
|
1179
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
1180
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
return {
|
1184
|
+
width,
|
1185
|
+
height,
|
1186
|
+
x,
|
1187
|
+
y
|
1188
|
+
};
|
1189
|
+
}
|
1190
|
+
|
1191
|
+
function getNearestOverflowAncestor(node) {
|
1192
|
+
const parentNode = getParentNode(node);
|
1193
|
+
|
1194
|
+
if (isLastTraversableNode(parentNode)) {
|
1195
|
+
// @ts-ignore assume body is always available
|
1196
|
+
return node.ownerDocument.body;
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
1200
|
+
return parentNode;
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
return getNearestOverflowAncestor(parentNode);
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
function getOverflowAncestors(node, list) {
|
1207
|
+
var _node$ownerDocument;
|
1208
|
+
|
1209
|
+
if (list === void 0) {
|
1210
|
+
list = [];
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
1214
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
1215
|
+
const win = getWindow(scrollableAncestor);
|
1216
|
+
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
1217
|
+
const updatedList = list.concat(target);
|
1218
|
+
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
1219
|
+
updatedList.concat(getOverflowAncestors(target));
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
function contains(parent, child) {
|
1223
|
+
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
|
1224
|
+
|
1225
|
+
if (parent.contains(child)) {
|
1226
|
+
return true;
|
1227
|
+
} // then fallback to custom implementation with Shadow DOM support
|
1228
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
1229
|
+
let next = child;
|
1230
|
+
|
1231
|
+
do {
|
1232
|
+
// use `===` replace node.isSameNode()
|
1233
|
+
if (next && parent === next) {
|
1234
|
+
return true;
|
1235
|
+
} // @ts-ignore: need a better way to handle this...
|
1236
|
+
|
1237
|
+
|
1238
|
+
next = next.parentNode || next.host;
|
1239
|
+
} while (next);
|
1240
|
+
}
|
1241
|
+
|
1242
|
+
return false;
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
function getNearestParentCapableOfEscapingClipping(element, clippingAncestors) {
|
1246
|
+
let currentNode = element;
|
1247
|
+
|
1248
|
+
while (currentNode && !isLastTraversableNode(currentNode) && // @ts-expect-error
|
1249
|
+
!clippingAncestors.includes(currentNode)) {
|
1250
|
+
if (isElement(currentNode) && ['absolute', 'fixed'].includes(getComputedStyle(currentNode).position)) {
|
1251
|
+
break;
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
const parentNode = getParentNode(currentNode);
|
1255
|
+
currentNode = isShadowRoot(parentNode) ? parentNode.host : parentNode;
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
return currentNode;
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
function getInnerBoundingClientRect(element, strategy) {
|
1262
|
+
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
|
1263
|
+
const top = clientRect.top + element.clientTop;
|
1264
|
+
const left = clientRect.left + element.clientLeft;
|
1265
|
+
return {
|
1266
|
+
top,
|
1267
|
+
left,
|
1268
|
+
x: left,
|
1269
|
+
y: top,
|
1270
|
+
right: left + element.clientWidth,
|
1271
|
+
bottom: top + element.clientHeight,
|
1272
|
+
width: element.clientWidth,
|
1273
|
+
height: element.clientHeight
|
1274
|
+
};
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
1278
|
+
if (clippingParent === 'viewport') {
|
1279
|
+
return rectToClientRect(getViewportRect(element, strategy));
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
if (isElement(clippingParent)) {
|
1283
|
+
return getInnerBoundingClientRect(clippingParent, strategy);
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
1287
|
+
} // A "clipping ancestor" is an overflowable container with the characteristic of
|
1288
|
+
// clipping (or hiding) overflowing elements with a position different from
|
1289
|
+
// `initial`
|
1290
|
+
|
1291
|
+
|
1292
|
+
function getClippingAncestors(element) {
|
1293
|
+
const clippingAncestors = getOverflowAncestors(element);
|
1294
|
+
const nearestEscapableParent = getNearestParentCapableOfEscapingClipping(element, clippingAncestors);
|
1295
|
+
let clipperElement = null;
|
1296
|
+
|
1297
|
+
if (nearestEscapableParent && isHTMLElement(nearestEscapableParent)) {
|
1298
|
+
const offsetParent = getOffsetParent(nearestEscapableParent);
|
1299
|
+
|
1300
|
+
if (isOverflowElement(nearestEscapableParent)) {
|
1301
|
+
clipperElement = nearestEscapableParent;
|
1302
|
+
} else if (isHTMLElement(offsetParent)) {
|
1303
|
+
clipperElement = offsetParent;
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
if (!isElement(clipperElement)) {
|
1308
|
+
return [];
|
1309
|
+
} // @ts-ignore isElement check ensures we return Array<Element>
|
1310
|
+
|
1311
|
+
|
1312
|
+
return clippingAncestors.filter(clippingAncestors => clipperElement && isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
|
1313
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
1314
|
+
// clipping ancestors
|
1315
|
+
|
1316
|
+
|
1317
|
+
function getClippingRect(_ref) {
|
1318
|
+
let {
|
1319
|
+
element,
|
1320
|
+
boundary,
|
1321
|
+
rootBoundary,
|
1322
|
+
strategy
|
1323
|
+
} = _ref;
|
1324
|
+
const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
|
1325
|
+
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
|
1326
|
+
const firstClippingAncestor = clippingAncestors[0];
|
1327
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
1328
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
1329
|
+
accRect.top = max(rect.top, accRect.top);
|
1330
|
+
accRect.right = min(rect.right, accRect.right);
|
1331
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
1332
|
+
accRect.left = max(rect.left, accRect.left);
|
1333
|
+
return accRect;
|
1334
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
1335
|
+
return {
|
1336
|
+
width: clippingRect.right - clippingRect.left,
|
1337
|
+
height: clippingRect.bottom - clippingRect.top,
|
1338
|
+
x: clippingRect.left,
|
1339
|
+
y: clippingRect.top
|
1340
|
+
};
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
const platform = {
|
1344
|
+
getClippingRect,
|
1345
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
1346
|
+
isElement,
|
1347
|
+
getDimensions,
|
1348
|
+
getOffsetParent,
|
1349
|
+
getDocumentElement,
|
1350
|
+
getElementRects: _ref => {
|
1351
|
+
let {
|
1352
|
+
reference,
|
1353
|
+
floating,
|
1354
|
+
strategy
|
1355
|
+
} = _ref;
|
1356
|
+
return {
|
1357
|
+
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
1358
|
+
floating: { ...getDimensions(floating),
|
1359
|
+
x: 0,
|
1360
|
+
y: 0
|
1361
|
+
}
|
1362
|
+
};
|
1363
|
+
},
|
1364
|
+
getClientRects: element => Array.from(element.getClientRects()),
|
1365
|
+
isRTL: element => getComputedStyle(element).direction === 'rtl'
|
1366
|
+
};
|
1367
|
+
|
1368
|
+
/**
|
1369
|
+
* Automatically updates the position of the floating element when necessary.
|
1370
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
1371
|
+
*/
|
1372
|
+
function autoUpdate(reference, floating, update, options) {
|
1373
|
+
if (options === void 0) {
|
1374
|
+
options = {};
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
const {
|
1378
|
+
ancestorScroll: _ancestorScroll = true,
|
1379
|
+
ancestorResize = true,
|
1380
|
+
elementResize = true,
|
1381
|
+
animationFrame = false
|
1382
|
+
} = options;
|
1383
|
+
const ancestorScroll = _ancestorScroll && !animationFrame;
|
1384
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
|
1385
|
+
ancestors.forEach(ancestor => {
|
1386
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
1387
|
+
passive: true
|
1388
|
+
});
|
1389
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
1390
|
+
});
|
1391
|
+
let observer = null;
|
1392
|
+
|
1393
|
+
if (elementResize) {
|
1394
|
+
let initialUpdate = true;
|
1395
|
+
observer = new ResizeObserver(() => {
|
1396
|
+
if (!initialUpdate) {
|
1397
|
+
update();
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
initialUpdate = false;
|
1401
|
+
});
|
1402
|
+
isElement(reference) && !animationFrame && observer.observe(reference);
|
1403
|
+
observer.observe(floating);
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
let frameId;
|
1407
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
1408
|
+
|
1409
|
+
if (animationFrame) {
|
1410
|
+
frameLoop();
|
1411
|
+
}
|
1412
|
+
|
1413
|
+
function frameLoop() {
|
1414
|
+
const nextRefRect = getBoundingClientRect(reference);
|
1415
|
+
|
1416
|
+
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
1417
|
+
update();
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
prevRefRect = nextRefRect;
|
1421
|
+
frameId = requestAnimationFrame(frameLoop);
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
update();
|
1425
|
+
return () => {
|
1426
|
+
var _observer;
|
1427
|
+
|
1428
|
+
ancestors.forEach(ancestor => {
|
1429
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
1430
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
1431
|
+
});
|
1432
|
+
(_observer = observer) == null ? void 0 : _observer.disconnect();
|
1433
|
+
observer = null;
|
1434
|
+
|
1435
|
+
if (animationFrame) {
|
1436
|
+
cancelAnimationFrame(frameId);
|
1437
|
+
}
|
1438
|
+
};
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
/**
|
1442
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
1443
|
+
* next to a reference element when it is given a certain CSS positioning
|
1444
|
+
* strategy.
|
1445
|
+
*/
|
1446
|
+
|
1447
|
+
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
|
1448
|
+
platform,
|
1449
|
+
...options
|
1450
|
+
});
|
1451
|
+
|
7
1452
|
/*!
|
8
1453
|
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
9
1454
|
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
10
1455
|
* v1.0.0-beta.97
|
11
|
-
*/
|
1456
|
+
*/
|
1457
|
+
/**
|
1458
|
+
* This module helps users provide custom configuration for component internals.
|
1459
|
+
*
|
1460
|
+
* @internal
|
1461
|
+
*/
|
1462
|
+
const configOverrides = globalThis["calciteComponentsConfig"];
|
1463
|
+
const config = {
|
1464
|
+
/**
|
1465
|
+
* We apply a custom fix to improve positioning for non-Chromium browsers.
|
1466
|
+
* The fix comes at a performance cost, so provides users a way to opt-out if necessary.
|
1467
|
+
*
|
1468
|
+
* @internal
|
1469
|
+
*/
|
1470
|
+
floatingUINonChromiumPositioningFix: true,
|
1471
|
+
...configOverrides
|
1472
|
+
};
|
1473
|
+
|
1474
|
+
/*!
|
1475
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
1476
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
1477
|
+
* v1.0.0-beta.97
|
1478
|
+
*/
|
1479
|
+
const floatingUIBrowserCheck = patchFloatingUiForNonChromiumBrowsers();
|
1480
|
+
async function patchFloatingUiForNonChromiumBrowsers() {
|
1481
|
+
function getUAString() {
|
1482
|
+
const uaData = navigator.userAgentData;
|
1483
|
+
if (uaData === null || uaData === void 0 ? void 0 : uaData.brands) {
|
1484
|
+
return uaData.brands.map((item) => `${item.brand}/${item.version}`).join(" ");
|
1485
|
+
}
|
1486
|
+
return navigator.userAgent;
|
1487
|
+
}
|
1488
|
+
if (config.floatingUINonChromiumPositioningFix &&
|
1489
|
+
// ⚠️ browser-sniffing is not a best practice and should be avoided ⚠️
|
1490
|
+
/firefox|safari/i.test(getUAString())) {
|
1491
|
+
const { getClippingRect, getElementRects, getOffsetParent } = await import('./p-05e64bd1.js');
|
1492
|
+
platform.getClippingRect = getClippingRect;
|
1493
|
+
platform.getOffsetParent = getOffsetParent;
|
1494
|
+
platform.getElementRects = getElementRects;
|
1495
|
+
}
|
1496
|
+
}
|
1497
|
+
const placementDataAttribute = "data-placement";
|
1498
|
+
/**
|
1499
|
+
* Exported for testing purposes only
|
1500
|
+
*/
|
1501
|
+
const repositionDebounceTimeout = 100;
|
1502
|
+
const effectivePlacements = [
|
1503
|
+
"top",
|
1504
|
+
"bottom",
|
1505
|
+
"right",
|
1506
|
+
"left",
|
1507
|
+
"top-start",
|
1508
|
+
"top-end",
|
1509
|
+
"bottom-start",
|
1510
|
+
"bottom-end",
|
1511
|
+
"right-start",
|
1512
|
+
"right-end",
|
1513
|
+
"left-start",
|
1514
|
+
"left-end"
|
1515
|
+
];
|
1516
|
+
const defaultMenuPlacement = "bottom-start";
|
1517
|
+
const FloatingCSS = {
|
1518
|
+
animation: "calcite-floating-ui-anim",
|
1519
|
+
animationActive: "calcite-floating-ui-anim--active"
|
1520
|
+
};
|
1521
|
+
function getMiddleware({ placement, disableFlip, flipPlacements, offsetDistance, offsetSkidding, arrowEl, type }) {
|
1522
|
+
const defaultMiddleware = [shift(), hide()];
|
1523
|
+
if (type === "menu") {
|
1524
|
+
return [
|
1525
|
+
...defaultMiddleware,
|
1526
|
+
flip({
|
1527
|
+
fallbackPlacements: flipPlacements || ["top-start", "top", "top-end", "bottom-start", "bottom", "bottom-end"]
|
1528
|
+
})
|
1529
|
+
];
|
1530
|
+
}
|
1531
|
+
if (type === "popover" || type === "tooltip") {
|
1532
|
+
const middleware = [
|
1533
|
+
...defaultMiddleware,
|
1534
|
+
offset({
|
1535
|
+
mainAxis: typeof offsetDistance === "number" ? offsetDistance : 0,
|
1536
|
+
crossAxis: typeof offsetSkidding === "number" ? offsetSkidding : 0
|
1537
|
+
})
|
1538
|
+
];
|
1539
|
+
if (placement === "auto" || placement === "auto-start" || placement === "auto-end") {
|
1540
|
+
middleware.push(autoPlacement({ alignment: placement === "auto-start" ? "start" : placement === "auto-end" ? "end" : null }));
|
1541
|
+
}
|
1542
|
+
else if (!disableFlip) {
|
1543
|
+
middleware.push(flip(flipPlacements ? { fallbackPlacements: flipPlacements } : {}));
|
1544
|
+
}
|
1545
|
+
if (arrowEl) {
|
1546
|
+
middleware.push(arrow({
|
1547
|
+
element: arrowEl
|
1548
|
+
}));
|
1549
|
+
}
|
1550
|
+
return middleware;
|
1551
|
+
}
|
1552
|
+
return [];
|
1553
|
+
}
|
1554
|
+
function filterComputedPlacements(placements, el) {
|
1555
|
+
const filteredPlacements = placements.filter((placement) => effectivePlacements.includes(placement));
|
1556
|
+
if (filteredPlacements.length !== placements.length) {
|
1557
|
+
console.warn(`${el.tagName}: Invalid value found in: flipPlacements. Try any of these: ${effectivePlacements
|
1558
|
+
.map((placement) => `"${placement}"`)
|
1559
|
+
.join(", ")
|
1560
|
+
.trim()}`, { el });
|
1561
|
+
}
|
1562
|
+
return filteredPlacements;
|
1563
|
+
}
|
1564
|
+
/*
|
1565
|
+
In floating-ui, "*-start" and "*-end" are already flipped in RTL.
|
1566
|
+
There is no need for our "*-leading" and "*-trailing" values anymore.
|
1567
|
+
https://github.com/floating-ui/floating-ui/issues/1530
|
1568
|
+
https://github.com/floating-ui/floating-ui/issues/1563
|
1569
|
+
*/
|
1570
|
+
function getEffectivePlacement(floatingEl, placement) {
|
1571
|
+
const placements = ["left", "right"];
|
1572
|
+
if (getElementDir(floatingEl) === "rtl") {
|
1573
|
+
placements.reverse();
|
1574
|
+
}
|
1575
|
+
return placement
|
1576
|
+
.replace(/-leading/gi, "-start")
|
1577
|
+
.replace(/-trailing/gi, "-end")
|
1578
|
+
.replace(/leading/gi, placements[0])
|
1579
|
+
.replace(/trailing/gi, placements[1]);
|
1580
|
+
}
|
1581
|
+
/**
|
1582
|
+
* Convenience function to manage `reposition` calls for FloatingUIComponents that use `positionFloatingUI.
|
1583
|
+
*
|
1584
|
+
* Note: this is not needed for components that use `calcite-popover`.
|
1585
|
+
*
|
1586
|
+
* @param component
|
1587
|
+
* @param options
|
1588
|
+
* @param options.referenceEl
|
1589
|
+
* @param options.floatingEl
|
1590
|
+
* @param options.overlayPositioning
|
1591
|
+
* @param options.placement
|
1592
|
+
* @param options.disableFlip
|
1593
|
+
* @param options.flipPlacements
|
1594
|
+
* @param options.offsetDistance
|
1595
|
+
* @param options.offsetSkidding
|
1596
|
+
* @param options.arrowEl
|
1597
|
+
* @param options.type
|
1598
|
+
* @param delayed
|
1599
|
+
*/
|
1600
|
+
async function reposition(component, options, delayed = false) {
|
1601
|
+
if (!component.open) {
|
1602
|
+
return;
|
1603
|
+
}
|
1604
|
+
return delayed ? debouncedReposition(options) : positionFloatingUI(options);
|
1605
|
+
}
|
1606
|
+
const debouncedReposition = debounce(positionFloatingUI, repositionDebounceTimeout, {
|
1607
|
+
leading: true,
|
1608
|
+
maxWait: repositionDebounceTimeout
|
1609
|
+
});
|
1610
|
+
/**
|
1611
|
+
* Positions the floating element relative to the reference element.
|
1612
|
+
*
|
1613
|
+
* **Note:** exported for testing purposes only
|
1614
|
+
*
|
1615
|
+
* @param root0
|
1616
|
+
* @param root0.referenceEl
|
1617
|
+
* @param root0.floatingEl
|
1618
|
+
* @param root0.overlayPositioning
|
1619
|
+
* @param root0.placement
|
1620
|
+
* @param root0.disableFlip
|
1621
|
+
* @param root0.flipPlacements
|
1622
|
+
* @param root0.offsetDistance
|
1623
|
+
* @param root0.offsetSkidding
|
1624
|
+
* @param root0.arrowEl
|
1625
|
+
* @param root0.type
|
1626
|
+
* @param root0.includeArrow
|
1627
|
+
*/
|
1628
|
+
async function positionFloatingUI({ referenceEl, floatingEl, overlayPositioning = "absolute", placement, disableFlip, flipPlacements, offsetDistance, offsetSkidding, includeArrow = false, arrowEl, type }) {
|
1629
|
+
var _a;
|
1630
|
+
if (!referenceEl || !floatingEl || (includeArrow && !arrowEl)) {
|
1631
|
+
return null;
|
1632
|
+
}
|
1633
|
+
await floatingUIBrowserCheck;
|
1634
|
+
const { x, y, placement: effectivePlacement, strategy: position, middlewareData } = await computePosition(referenceEl, floatingEl, {
|
1635
|
+
strategy: overlayPositioning,
|
1636
|
+
placement: placement === "auto" || placement === "auto-start" || placement === "auto-end"
|
1637
|
+
? undefined
|
1638
|
+
: getEffectivePlacement(floatingEl, placement),
|
1639
|
+
middleware: getMiddleware({
|
1640
|
+
placement,
|
1641
|
+
disableFlip,
|
1642
|
+
flipPlacements,
|
1643
|
+
offsetDistance,
|
1644
|
+
offsetSkidding,
|
1645
|
+
arrowEl,
|
1646
|
+
type
|
1647
|
+
})
|
1648
|
+
});
|
1649
|
+
if (middlewareData === null || middlewareData === void 0 ? void 0 : middlewareData.arrow) {
|
1650
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
1651
|
+
Object.assign(arrowEl.style, {
|
1652
|
+
left: arrowX != null ? `${arrowX}px` : "",
|
1653
|
+
top: arrowY != null ? `${arrowY}px` : ""
|
1654
|
+
});
|
1655
|
+
}
|
1656
|
+
const referenceHidden = (_a = middlewareData === null || middlewareData === void 0 ? void 0 : middlewareData.hide) === null || _a === void 0 ? void 0 : _a.referenceHidden;
|
1657
|
+
const visibility = referenceHidden ? "hidden" : null;
|
1658
|
+
const pointerEvents = visibility ? "none" : null;
|
1659
|
+
floatingEl.setAttribute(placementDataAttribute, effectivePlacement);
|
1660
|
+
const transform = `translate(${Math.round(x)}px,${Math.round(y)}px)`;
|
1661
|
+
Object.assign(floatingEl.style, {
|
1662
|
+
visibility,
|
1663
|
+
pointerEvents,
|
1664
|
+
position,
|
1665
|
+
top: "0",
|
1666
|
+
left: "0",
|
1667
|
+
transform
|
1668
|
+
});
|
1669
|
+
}
|
1670
|
+
/**
|
1671
|
+
* Exported for testing purposes only
|
1672
|
+
*
|
1673
|
+
* @internal
|
1674
|
+
*/
|
1675
|
+
const cleanupMap = new WeakMap();
|
1676
|
+
/**
|
1677
|
+
* Helper to set up floating element interactions on connectedCallback.
|
1678
|
+
*
|
1679
|
+
* @param component
|
1680
|
+
* @param referenceEl
|
1681
|
+
* @param floatingEl
|
1682
|
+
*/
|
1683
|
+
function connectFloatingUI(component, referenceEl, floatingEl) {
|
1684
|
+
if (!floatingEl || !referenceEl) {
|
1685
|
+
return;
|
1686
|
+
}
|
1687
|
+
disconnectFloatingUI(component, referenceEl, floatingEl);
|
1688
|
+
const position = component.overlayPositioning;
|
1689
|
+
// ensure position matches for initial positioning
|
1690
|
+
floatingEl.style.position = position;
|
1691
|
+
if (position === "absolute") {
|
1692
|
+
moveOffScreen(floatingEl);
|
1693
|
+
}
|
1694
|
+
const runAutoUpdate = autoUpdate
|
1695
|
+
;
|
1696
|
+
cleanupMap.set(component, runAutoUpdate(referenceEl, floatingEl, () => component.reposition()));
|
1697
|
+
}
|
1698
|
+
/**
|
1699
|
+
* Helper to tear down floating element interactions on disconnectedCallback.
|
1700
|
+
*
|
1701
|
+
* @param component
|
1702
|
+
* @param referenceEl
|
1703
|
+
* @param floatingEl
|
1704
|
+
*/
|
1705
|
+
function disconnectFloatingUI(component, referenceEl, floatingEl) {
|
1706
|
+
if (!floatingEl || !referenceEl) {
|
1707
|
+
return;
|
1708
|
+
}
|
1709
|
+
getTransitionTarget(floatingEl).removeEventListener("transitionend", handleTransitionElTransitionEnd);
|
1710
|
+
const cleanup = cleanupMap.get(component);
|
1711
|
+
if (cleanup) {
|
1712
|
+
cleanup();
|
1713
|
+
}
|
1714
|
+
cleanupMap.delete(component);
|
1715
|
+
}
|
1716
|
+
const visiblePointerSize = 4;
|
1717
|
+
/**
|
1718
|
+
* Default offset the position of the floating element away from the reference element.
|
1719
|
+
*
|
1720
|
+
* @default 6
|
1721
|
+
*/
|
1722
|
+
const defaultOffsetDistance = Math.ceil(Math.hypot(visiblePointerSize, visiblePointerSize));
|
1723
|
+
/**
|
1724
|
+
* This utils applies floating element styles to avoid affecting layout when closed.
|
1725
|
+
*
|
1726
|
+
* This should be called when the closing transition will start.
|
1727
|
+
*
|
1728
|
+
* @param floatingEl
|
1729
|
+
*/
|
1730
|
+
function updateAfterClose(floatingEl) {
|
1731
|
+
if (!floatingEl || floatingEl.style.position !== "absolute") {
|
1732
|
+
return;
|
1733
|
+
}
|
1734
|
+
getTransitionTarget(floatingEl).addEventListener("transitionend", handleTransitionElTransitionEnd);
|
1735
|
+
}
|
1736
|
+
function getTransitionTarget(floatingEl) {
|
1737
|
+
// assumes floatingEl w/ shadowRoot is a FloatingUIComponent
|
1738
|
+
return floatingEl.shadowRoot || floatingEl;
|
1739
|
+
}
|
1740
|
+
function handleTransitionElTransitionEnd(event) {
|
1741
|
+
const floatingTransitionEl = event.target;
|
1742
|
+
if (
|
1743
|
+
// using any prop from floating-ui transition
|
1744
|
+
event.propertyName === "opacity" &&
|
1745
|
+
floatingTransitionEl.classList.contains(FloatingCSS.animation)) {
|
1746
|
+
const floatingEl = getFloatingElFromTransitionTarget(floatingTransitionEl);
|
1747
|
+
moveOffScreen(floatingEl);
|
1748
|
+
getTransitionTarget(floatingEl).removeEventListener("transitionend", handleTransitionElTransitionEnd);
|
1749
|
+
}
|
1750
|
+
}
|
1751
|
+
function moveOffScreen(floatingEl) {
|
1752
|
+
floatingEl.style.transform = "";
|
1753
|
+
floatingEl.style.top = "-99999px";
|
1754
|
+
floatingEl.style.left = "-99999px";
|
1755
|
+
}
|
1756
|
+
function getFloatingElFromTransitionTarget(floatingTransitionEl) {
|
1757
|
+
return closestElementCrossShadowBoundary(floatingTransitionEl, `[${placementDataAttribute}]`);
|
1758
|
+
}
|
1759
|
+
|
1760
|
+
export { FloatingCSS as F, disconnectFloatingUI as a, defaultOffsetDistance as b, connectFloatingUI as c, defaultMenuPlacement as d, rectToClientRect as e, filterComputedPlacements as f, reposition as r, updateAfterClose as u };
|