@xanui/ui 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ClickOutside/index.d.ts +4 -3
- package/ClickOutside/index.js +4 -5
- package/ClickOutside/index.js.map +1 -1
- package/ClickOutside/index.mjs +4 -5
- package/ClickOutside/index.mjs.map +1 -1
- package/Collaps/index.js +2 -2
- package/Collaps/index.js.map +1 -1
- package/Collaps/index.mjs +2 -2
- package/Collaps/index.mjs.map +1 -1
- package/Drawer/index.js +2 -2
- package/Drawer/index.js.map +1 -1
- package/Drawer/index.mjs +2 -2
- package/Drawer/index.mjs.map +1 -1
- package/Layer/index.js +5 -4
- package/Layer/index.js.map +1 -1
- package/Layer/index.mjs +5 -4
- package/Layer/index.mjs.map +1 -1
- package/Menu/index.d.ts +4 -4
- package/Menu/index.js +114 -28
- package/Menu/index.js.map +1 -1
- package/Menu/index.mjs +114 -28
- package/Menu/index.mjs.map +1 -1
- package/Portal/index.d.ts +1 -2
- package/Portal/index.js +8 -11
- package/Portal/index.js.map +1 -1
- package/Portal/index.mjs +9 -12
- package/Portal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/Menu/getOrigin.js +0 -42
- package/Menu/getOrigin.js.map +0 -1
- package/Menu/getOrigin.mjs +0 -42
- package/Menu/getOrigin.mjs.map +0 -1
- package/Menu/placedMenu.d.ts +0 -5
- package/Menu/placedMenu.js +0 -95
- package/Menu/placedMenu.js.map +0 -1
- package/Menu/placedMenu.mjs +0 -95
- package/Menu/placedMenu.mjs.map +0 -1
package/Menu/placedMenu.mjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const placements = [
|
|
2
|
-
"top",
|
|
3
|
-
"top-left",
|
|
4
|
-
"top-right",
|
|
5
|
-
"bottom",
|
|
6
|
-
"bottom-left",
|
|
7
|
-
"bottom-right",
|
|
8
|
-
"right",
|
|
9
|
-
"right-top",
|
|
10
|
-
"right-bottom",
|
|
11
|
-
"left",
|
|
12
|
-
"left-top",
|
|
13
|
-
"left-bottom"
|
|
14
|
-
];
|
|
15
|
-
const isOffScreen = (menu) => {
|
|
16
|
-
const { x, y, width, height } = menu.getBoundingClientRect();
|
|
17
|
-
return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight;
|
|
18
|
-
};
|
|
19
|
-
let setStyles = ({ place, menu, target }) => {
|
|
20
|
-
const { height, width } = menu.getBoundingClientRect();
|
|
21
|
-
const targetBoundary = target.getBoundingClientRect();
|
|
22
|
-
let targetTop = targetBoundary.top + window.scrollY;
|
|
23
|
-
let targetBottom = targetBoundary.bottom + window.scrollY;
|
|
24
|
-
let targetLeft = targetBoundary.left + window.scrollX;
|
|
25
|
-
let targetRight = targetBoundary.right + window.scrollX;
|
|
26
|
-
const _styles = {
|
|
27
|
-
"top": () => {
|
|
28
|
-
menu.style.top = `${targetTop - height}px`;
|
|
29
|
-
menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`;
|
|
30
|
-
},
|
|
31
|
-
"top-left": () => {
|
|
32
|
-
menu.style.top = `${targetTop - height}px`;
|
|
33
|
-
menu.style.left = `${targetLeft}px`;
|
|
34
|
-
},
|
|
35
|
-
"top-right": () => {
|
|
36
|
-
menu.style.top = `${targetTop - height}px`;
|
|
37
|
-
menu.style.left = `${targetRight - width}px`;
|
|
38
|
-
},
|
|
39
|
-
"bottom": () => {
|
|
40
|
-
menu.style.top = `${targetBottom}px`;
|
|
41
|
-
menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`;
|
|
42
|
-
},
|
|
43
|
-
"bottom-left": () => {
|
|
44
|
-
menu.style.top = `${targetBottom}px`;
|
|
45
|
-
menu.style.left = `${targetLeft}px`;
|
|
46
|
-
},
|
|
47
|
-
"bottom-right": () => {
|
|
48
|
-
menu.style.top = `${targetBottom}px`;
|
|
49
|
-
menu.style.left = `${targetRight - width}px`;
|
|
50
|
-
},
|
|
51
|
-
"right": () => {
|
|
52
|
-
menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`;
|
|
53
|
-
menu.style.left = `${targetRight}px`;
|
|
54
|
-
},
|
|
55
|
-
"right-top": () => {
|
|
56
|
-
menu.style.top = `${targetTop}px`;
|
|
57
|
-
menu.style.left = `${targetRight}px`;
|
|
58
|
-
},
|
|
59
|
-
"right-bottom": () => {
|
|
60
|
-
menu.style.top = `${(targetTop + targetBoundary.height) - height}px`;
|
|
61
|
-
menu.style.left = `${targetRight}px`;
|
|
62
|
-
},
|
|
63
|
-
"left": () => {
|
|
64
|
-
menu.style.left = `${targetLeft - width}px`;
|
|
65
|
-
menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`;
|
|
66
|
-
},
|
|
67
|
-
"left-top": () => {
|
|
68
|
-
menu.style.top = `${targetTop}px`;
|
|
69
|
-
menu.style.left = `${targetLeft - width}px`;
|
|
70
|
-
},
|
|
71
|
-
"left-bottom": () => {
|
|
72
|
-
menu.style.top = `${targetBottom - height}px`;
|
|
73
|
-
menu.style.left = `${targetLeft - width}px`;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
_styles[place] && _styles[place]();
|
|
77
|
-
};
|
|
78
|
-
const placedMenu = ({ place, menu, target }) => {
|
|
79
|
-
setStyles({ place, menu, target });
|
|
80
|
-
if (isOffScreen(menu)) {
|
|
81
|
-
let found_placement = false;
|
|
82
|
-
for (let i = 0; i < placements.length; i++) {
|
|
83
|
-
let _place = placements[i];
|
|
84
|
-
setStyles({ place: _place, menu, target });
|
|
85
|
-
if (!isOffScreen(menu)) {
|
|
86
|
-
found_placement = true;
|
|
87
|
-
return _place;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (!found_placement) {
|
|
91
|
-
setStyles({ place, menu, target });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return place;
|
|
95
|
-
};export{placedMenu,placements};//# sourceMappingURL=placedMenu.mjs.map
|
package/Menu/placedMenu.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"placedMenu.mjs","sources":["../../src/Menu/placedMenu.ts"],"sourcesContent":["\n\nexport const placements = [\n \"top\",\n \"top-left\",\n \"top-right\",\n \"bottom\",\n \"bottom-left\",\n \"bottom-right\",\n \"right\",\n \"right-top\",\n \"right-bottom\",\n \"left\",\n \"left-top\",\n \"left-bottom\"\n] as const\n\n\nexport type PlacementTypes = typeof placements[number]\n\nconst isOffScreen = (menu: HTMLElement) => {\n const { x, y, width, height } = menu.getBoundingClientRect()\n return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight\n};\n\ntype Props = {\n place: PlacementTypes,\n menu: HTMLElement,\n target: HTMLElement\n}\n\n\nlet setStyles = ({ place, menu, target }: Props) => {\n\n const { height, width } = menu.getBoundingClientRect()\n const targetBoundary = target.getBoundingClientRect()\n let targetTop = targetBoundary.top + window.scrollY\n let targetBottom = targetBoundary.bottom + window.scrollY\n let targetLeft = targetBoundary.left + window.scrollX\n let targetRight = targetBoundary.right + window.scrollX\n\n const _styles = {\n \"top\": () => {\n menu.style.top = `${targetTop - height}px`\n menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`\n },\n \"top-left\": () => {\n menu.style.top = `${targetTop - height}px`\n menu.style.left = `${targetLeft}px`\n },\n \"top-right\": () => {\n menu.style.top = `${targetTop - height}px`\n menu.style.left = `${targetRight - width}px`\n },\n \"bottom\": () => {\n menu.style.top = `${targetBottom}px`\n menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`\n },\n \"bottom-left\": () => {\n menu.style.top = `${targetBottom}px`\n menu.style.left = `${targetLeft}px`\n },\n \"bottom-right\": () => {\n menu.style.top = `${targetBottom}px`\n menu.style.left = `${targetRight - width}px`\n },\n \"right\": () => {\n menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`\n menu.style.left = `${targetRight}px`\n },\n \"right-top\": () => {\n menu.style.top = `${targetTop}px`\n menu.style.left = `${targetRight}px`\n },\n \"right-bottom\": () => {\n menu.style.top = `${(targetTop + targetBoundary.height) - height}px`\n menu.style.left = `${targetRight}px`\n },\n \"left\": () => {\n menu.style.left = `${targetLeft - width}px`\n menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`\n },\n \"left-top\": () => {\n menu.style.top = `${targetTop}px`\n menu.style.left = `${targetLeft - width}px`\n },\n \"left-bottom\": () => {\n menu.style.top = `${targetBottom - height}px`\n menu.style.left = `${targetLeft - width}px`\n }\n }\n _styles[place] && _styles[place]()\n}\n\nexport const placedMenu = ({ place, menu, target }: Props) => {\n setStyles({ place, menu, target })\n if (isOffScreen(menu)) {\n let found_placement = false\n for (let i = 0; i < placements.length; i++) {\n let _place = placements[i]\n setStyles({ place: _place, menu, target })\n if (!isOffScreen(menu)) {\n found_placement = true\n return _place\n }\n }\n if (!found_placement) {\n setStyles({ place, menu, target })\n }\n }\n return place\n}\n\n"],"names":[],"mappings":"AAEO,MAAM,UAAU,GAAG;IACtB,KAAK;IACL,UAAU;IACV,WAAW;IACX,QAAQ;IACR,aAAa;IACb,cAAc;IACd,OAAO;IACP,WAAW;IACX,cAAc;IACd,MAAM;IACN,UAAU;IACV;;AAMJ,MAAM,WAAW,GAAG,CAAC,IAAiB,KAAI;AACtC,IAAA,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,EAAE;IAC5D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,WAAW;AAC7F,CAAC;AASD,IAAI,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAS,KAAI;IAE/C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,qBAA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