@banzamel/mineralui 2.1.2 → 2.1.4
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/README.md +1 -1
- package/dist/{MDetailList-BhKBJwpd.cjs → MDetailList-DTLU7HQZ.cjs} +2 -2
- package/dist/{MDetailList-BhKBJwpd.cjs.map → MDetailList-DTLU7HQZ.cjs.map} +1 -1
- package/dist/{MDetailList-BjvZUyNj.js → MDetailList-fDhVyhm7.js} +3 -3
- package/dist/{MDetailList-BjvZUyNj.js.map → MDetailList-fDhVyhm7.js.map} +1 -1
- package/dist/{MDropdownMenu-hXaIMkAj.cjs → MDropdownMenu-BvN5grK5.cjs} +2 -2
- package/dist/{MDropdownMenu-hXaIMkAj.cjs.map → MDropdownMenu-BvN5grK5.cjs.map} +1 -1
- package/dist/{MDropdownMenu-CZmU3uku.js → MDropdownMenu-CFoKJ7V6.js} +2 -2
- package/dist/{MDropdownMenu-CZmU3uku.js.map → MDropdownMenu-CFoKJ7V6.js.map} +1 -1
- package/dist/{MInput-BhTAfpYS.cjs → MInput-BpTlP8GE.cjs} +2 -2
- package/dist/{MInput-BhTAfpYS.cjs.map → MInput-BpTlP8GE.cjs.map} +1 -1
- package/dist/{MInput-CgtX0fUN.js → MInput-C8ObGzQk.js} +2 -2
- package/dist/{MInput-CgtX0fUN.js.map → MInput-C8ObGzQk.js.map} +1 -1
- package/dist/{MInputCVC-BGYhUGDE.js → MInputCVC-B4V0QI5h.js} +24 -24
- package/dist/{MInputCVC-BGYhUGDE.js.map → MInputCVC-B4V0QI5h.js.map} +1 -1
- package/dist/{MInputCVC-E2Z2hYfy.cjs → MInputCVC-BlY5OrVn.cjs} +2 -2
- package/dist/{MInputCVC-E2Z2hYfy.cjs.map → MInputCVC-BlY5OrVn.cjs.map} +1 -1
- package/dist/{MInputSearch-DE9Jqp0i.cjs → MInputSearch-9wcXlY8-.cjs} +2 -2
- package/dist/{MInputSearch-DE9Jqp0i.cjs.map → MInputSearch-9wcXlY8-.cjs.map} +1 -1
- package/dist/{MInputSearch-DEr5HBgw.js → MInputSearch-BM8gLlJ1.js} +3 -3
- package/dist/{MInputSearch-DEr5HBgw.js.map → MInputSearch-BM8gLlJ1.js.map} +1 -1
- package/dist/{MPagination-DTqT33Mx.cjs → MPagination-C6QQdEj_.cjs} +2 -2
- package/dist/{MPagination-DTqT33Mx.cjs.map → MPagination-C6QQdEj_.cjs.map} +1 -1
- package/dist/{MPagination-7yTbB8dZ.js → MPagination-CgmNEAZX.js} +6 -6
- package/dist/{MPagination-7yTbB8dZ.js.map → MPagination-CgmNEAZX.js.map} +1 -1
- package/dist/MPopover-C5aaGhma.js +150 -0
- package/dist/MPopover-C5aaGhma.js.map +1 -0
- package/dist/MPopover-CV-9MArH.cjs +2 -0
- package/dist/MPopover-CV-9MArH.cjs.map +1 -0
- package/dist/{MTag-BtlOVMRl.cjs → MTag-BzTp1crT.cjs} +2 -2
- package/dist/{MTag-BtlOVMRl.cjs.map → MTag-BzTp1crT.cjs.map} +1 -1
- package/dist/{MTag-BF6htPr-.js → MTag-D9q6faIk.js} +2 -2
- package/dist/{MTag-BF6htPr-.js.map → MTag-D9q6faIk.js.map} +1 -1
- package/dist/{MTreeView-DQaRF0ty.js → MTreeView-B1J7uqd1.js} +63 -63
- package/dist/{MTreeView-DQaRF0ty.js.map → MTreeView-B1J7uqd1.js.map} +1 -1
- package/dist/{MTreeView-1IqmVPMv.cjs → MTreeView-DuQkm0ZV.cjs} +2 -2
- package/dist/{MTreeView-1IqmVPMv.cjs.map → MTreeView-DuQkm0ZV.cjs.map} +1 -1
- package/dist/{cards-BBYh24NQ.cjs → cards-CQSYgH9U.cjs} +2 -2
- package/dist/{cards-BBYh24NQ.cjs.map → cards-CQSYgH9U.cjs.map} +1 -1
- package/dist/{cards-Du2kX3Br.js → cards-Cpr9B8Mu.js} +73 -73
- package/dist/{cards-Du2kX3Br.js.map → cards-Cpr9B8Mu.js.map} +1 -1
- package/dist/cards.cjs +1 -1
- package/dist/cards.js +1 -1
- package/dist/components/primitives/MPopover/popoverStack.d.ts +32 -0
- package/dist/{controls-Cbv4FmNq.js → controls-BKAhqjNM.js} +2 -2
- package/dist/{controls-Cbv4FmNq.js.map → controls-BKAhqjNM.js.map} +1 -1
- package/dist/{controls-DrdHBBtm.cjs → controls-CT_0lIPr.cjs} +2 -2
- package/dist/{controls-DrdHBBtm.cjs.map → controls-CT_0lIPr.cjs.map} +1 -1
- package/dist/controls.cjs +1 -1
- package/dist/controls.js +1 -1
- package/dist/{data-Csb03WFo.cjs → data-BZ92hzXx.cjs} +2 -2
- package/dist/{data-Csb03WFo.cjs.map → data-BZ92hzXx.cjs.map} +1 -1
- package/dist/{data-BgTkBMkP.js → data-C-6DP7iY.js} +16 -16
- package/dist/{data-BgTkBMkP.js.map → data-C-6DP7iY.js.map} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.js +2 -2
- package/dist/{display-D9H8MP8D.js → display-BF4jASt9.js} +16 -16
- package/dist/{display-D9H8MP8D.js.map → display-BF4jASt9.js.map} +1 -1
- package/dist/{display-IMWtdmxS.cjs → display-DMix8BmD.cjs} +3 -3
- package/dist/{display-IMWtdmxS.cjs.map → display-DMix8BmD.cjs.map} +1 -1
- package/dist/display.cjs +1 -1
- package/dist/display.js +2 -2
- package/dist/{dropdowns-oj4--GbK.js → dropdowns-DiThUF7D.js} +91 -91
- package/dist/{dropdowns-oj4--GbK.js.map → dropdowns-DiThUF7D.js.map} +1 -1
- package/dist/{dropdowns-D_nUdflh.cjs → dropdowns-bQ0cEKNN.cjs} +2 -2
- package/dist/{dropdowns-D_nUdflh.cjs.map → dropdowns-bQ0cEKNN.cjs.map} +1 -1
- package/dist/dropdowns.cjs +1 -1
- package/dist/dropdowns.js +1 -1
- package/dist/{feedback-u1ssUT7e.cjs → feedback-4TjD57rX.cjs} +2 -2
- package/dist/{feedback-u1ssUT7e.cjs.map → feedback-4TjD57rX.cjs.map} +1 -1
- package/dist/{feedback-D7BTlioj.js → feedback-DW-cehnb.js} +35 -35
- package/dist/{feedback-D7BTlioj.js.map → feedback-DW-cehnb.js.map} +1 -1
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.js +2 -2
- package/dist/icons/glyphs/MCoinIcon.d.ts +2 -0
- package/dist/icons/glyphs/MMoneyIcon.d.ts +2 -0
- package/dist/icons/glyphs/MReceiptIcon.d.ts +2 -0
- package/dist/icons/glyphs/MWalletIcon.d.ts +2 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/{icons-DLP-Rs6z.js → icons-CBMl-kOM.js} +221 -166
- package/dist/icons-CBMl-kOM.js.map +1 -0
- package/dist/icons-D675Im0B.cjs +2 -0
- package/dist/icons-D675Im0B.cjs.map +1 -0
- package/dist/icons.cjs +1 -1
- package/dist/icons.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +53 -53
- package/dist/{inputs-DQrjGfwd.js → inputs-CQoi402V.js} +180 -180
- package/dist/{inputs-DQrjGfwd.js.map → inputs-CQoi402V.js.map} +1 -1
- package/dist/{inputs-DsFdc0Io.cjs → inputs-yaaTPTsY.cjs} +2 -2
- package/dist/{inputs-DsFdc0Io.cjs.map → inputs-yaaTPTsY.cjs.map} +1 -1
- package/dist/inputs.cjs +1 -1
- package/dist/inputs.js +4 -4
- package/dist/{layout-BuvV-N9H.js → layout-CdSpVJuK.js} +32 -32
- package/dist/{layout-BuvV-N9H.js.map → layout-CdSpVJuK.js.map} +1 -1
- package/dist/{layout-B_2yBP1M.cjs → layout-Ddo7HUPu.cjs} +2 -2
- package/dist/{layout-B_2yBP1M.cjs.map → layout-Ddo7HUPu.cjs.map} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.js +2 -2
- package/dist/{media-Xt6MkVhb.cjs → media-DRz3JZfr.cjs} +2 -2
- package/dist/{media-Xt6MkVhb.cjs.map → media-DRz3JZfr.cjs.map} +1 -1
- package/dist/{media-5IsYrhIQ.js → media-vOQOIYFD.js} +11 -11
- package/dist/{media-5IsYrhIQ.js.map → media-vOQOIYFD.js.map} +1 -1
- package/dist/media.cjs +1 -1
- package/dist/media.js +1 -1
- package/dist/{overlays-BAJDNT1m.cjs → overlays-BUZEaZaJ.cjs} +2 -2
- package/dist/{overlays-BAJDNT1m.cjs.map → overlays-BUZEaZaJ.cjs.map} +1 -1
- package/dist/{overlays-WA3jnWTG.js → overlays-C1vO_A2I.js} +50 -50
- package/dist/{overlays-WA3jnWTG.js.map → overlays-C1vO_A2I.js.map} +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.js +2 -2
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.js +1 -1
- package/package.json +1 -1
- package/dist/MPopover-BRuwva-c.js +0 -95
- package/dist/MPopover-BRuwva-c.js.map +0 -1
- package/dist/MPopover-hDqrn317.cjs +0 -2
- package/dist/MPopover-hDqrn317.cjs.map +0 -1
- package/dist/icons-BfdQ45F2.cjs +0 -2
- package/dist/icons-BfdQ45F2.cjs.map +0 -1
- package/dist/icons-DLP-Rs6z.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ji as e, qi as t } from "./icons-CBMl-kOM.js";
|
|
2
2
|
import { t as n } from "./cn-YER3QsV1.js";
|
|
3
3
|
import { t as r } from "./MButton-C1pnL4_j.js";
|
|
4
4
|
import { useMemo as i } from "react";
|
|
@@ -52,7 +52,7 @@ function l({ total: s, page: l, pageSize: u = 10, onChange: d, siblings: f = 1,
|
|
|
52
52
|
disabled: v <= 1,
|
|
53
53
|
onClick: () => d(v - 1),
|
|
54
54
|
className: "nav",
|
|
55
|
-
children: /* @__PURE__ */ a(
|
|
55
|
+
children: /* @__PURE__ */ a(e, {})
|
|
56
56
|
}),
|
|
57
57
|
/* @__PURE__ */ o("span", {
|
|
58
58
|
className: "info",
|
|
@@ -69,7 +69,7 @@ function l({ total: s, page: l, pageSize: u = 10, onChange: d, siblings: f = 1,
|
|
|
69
69
|
disabled: v >= _,
|
|
70
70
|
onClick: () => d(v + 1),
|
|
71
71
|
className: "nav",
|
|
72
|
-
children: /* @__PURE__ */ a(
|
|
72
|
+
children: /* @__PURE__ */ a(t, {})
|
|
73
73
|
})
|
|
74
74
|
]
|
|
75
75
|
}) : /* @__PURE__ */ o("nav", {
|
|
@@ -84,7 +84,7 @@ function l({ total: s, page: l, pageSize: u = 10, onChange: d, siblings: f = 1,
|
|
|
84
84
|
disabled: v <= 1,
|
|
85
85
|
onClick: () => d(v - 1),
|
|
86
86
|
className: "nav",
|
|
87
|
-
children: /* @__PURE__ */ a(
|
|
87
|
+
children: /* @__PURE__ */ a(e, {})
|
|
88
88
|
}),
|
|
89
89
|
y.map((e, t) => e === "dots" ? /* @__PURE__ */ a("span", {
|
|
90
90
|
className: "dots",
|
|
@@ -102,7 +102,7 @@ function l({ total: s, page: l, pageSize: u = 10, onChange: d, siblings: f = 1,
|
|
|
102
102
|
disabled: v >= _,
|
|
103
103
|
onClick: () => d(v + 1),
|
|
104
104
|
className: "nav",
|
|
105
|
-
children: /* @__PURE__ */ a(
|
|
105
|
+
children: /* @__PURE__ */ a(t, {})
|
|
106
106
|
})
|
|
107
107
|
]
|
|
108
108
|
});
|
|
@@ -110,4 +110,4 @@ function l({ total: s, page: l, pageSize: u = 10, onChange: d, siblings: f = 1,
|
|
|
110
110
|
//#endregion
|
|
111
111
|
export { l as t };
|
|
112
112
|
|
|
113
|
-
//# sourceMappingURL=MPagination-
|
|
113
|
+
//# sourceMappingURL=MPagination-CgmNEAZX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MPagination-
|
|
1
|
+
{"version":3,"file":"MPagination-CgmNEAZX.js","names":[],"sources":["../src/components/layout/MPagination/MPagination.tsx"],"sourcesContent":["import {useMemo} from 'react'\nimport {cn} from '../../../utils/cn'\nimport {MButton} from '../../controls'\nimport {MChevronLeftIcon, MChevronRightIcon} from '../../../icons'\nimport type {MPaginationProps} from './MPagination.types'\nimport './MPagination.css'\n\nfunction range(start: number, end: number): number[] {\n const result: number[] = []\n for (let i = start; i <= end; i++) result.push(i)\n return result\n}\n\nfunction buildPages(totalPages: number, page: number, siblings: number, boundaries: number): (number | 'dots')[] {\n if (totalPages <= boundaries * 2 + siblings * 2 + 3) {\n return range(1, totalPages)\n }\n\n const leftBound = Math.max(page - siblings, boundaries + 2)\n const rightBound = Math.min(page + siblings, totalPages - boundaries - 1)\n\n const showLeftDots = leftBound > boundaries + 2\n const showRightDots = rightBound < totalPages - boundaries - 1\n\n const leftEdge = range(1, boundaries)\n const rightEdge = range(totalPages - boundaries + 1, totalPages)\n\n if (!showLeftDots && showRightDots) {\n const leftCount = siblings * 2 + boundaries + 2\n return [...range(1, leftCount), 'dots', ...rightEdge]\n }\n\n if (showLeftDots && !showRightDots) {\n const rightCount = siblings * 2 + boundaries + 2\n return [...leftEdge, 'dots', ...range(totalPages - rightCount + 1, totalPages)]\n }\n\n return [...leftEdge, 'dots', ...range(leftBound, rightBound), 'dots', ...rightEdge]\n}\n\nexport function MPagination({\n total,\n page,\n pageSize = 10,\n onChange,\n siblings = 1,\n boundaries = 1,\n variant = 'numbered',\n className,\n ...rest\n}: MPaginationProps) {\n const totalPages = Math.max(1, Math.ceil(total / pageSize))\n const currentPage = Math.min(Math.max(1, page), totalPages)\n\n const pages = useMemo(\n () => buildPages(totalPages, currentPage, siblings, boundaries),\n [totalPages, currentPage, siblings, boundaries]\n )\n\n if (variant === 'simple') {\n return (\n <nav aria-label=\"pagination\" className={cn('pagination', className)} {...rest}>\n <MButton\n variant=\"outlined\"\n size=\"sm\"\n iconOnly\n disabled={currentPage <= 1}\n onClick={() => onChange(currentPage - 1)}\n className=\"nav\"\n >\n <MChevronLeftIcon />\n </MButton>\n <span className=\"info\">\n {currentPage} / {totalPages}\n </span>\n <MButton\n variant=\"outlined\"\n size=\"sm\"\n iconOnly\n disabled={currentPage >= totalPages}\n onClick={() => onChange(currentPage + 1)}\n className=\"nav\"\n >\n <MChevronRightIcon />\n </MButton>\n </nav>\n )\n }\n\n return (\n <nav aria-label=\"pagination\" className={cn('pagination', className)} {...rest}>\n <MButton\n variant=\"outlined\"\n size=\"sm\"\n iconOnly\n disabled={currentPage <= 1}\n onClick={() => onChange(currentPage - 1)}\n className=\"nav\"\n >\n <MChevronLeftIcon />\n </MButton>\n {pages.map((p, i) =>\n p === 'dots' ? (\n <span key={`dots-${i}`} className=\"dots\">\n …\n </span>\n ) : (\n <button\n key={p}\n type=\"button\"\n className={cn('btn', p === currentPage && 'active')}\n onClick={() => onChange(p)}\n >\n {p}\n </button>\n )\n )}\n <MButton\n variant=\"outlined\"\n size=\"sm\"\n iconOnly\n disabled={currentPage >= totalPages}\n onClick={() => onChange(currentPage + 1)}\n className=\"nav\"\n >\n <MChevronRightIcon />\n </MButton>\n </nav>\n )\n}\n"],"mappings":";;;;;;AAOA,SAAS,EAAM,GAAe,GAAuB;CACjD,IAAM,IAAmB,EAAE;AAC3B,MAAK,IAAI,IAAI,GAAO,KAAK,GAAK,IAAK,GAAO,KAAK,EAAE;AACjD,QAAO;;AAGX,SAAS,EAAW,GAAoB,GAAc,GAAkB,GAAyC;AAC7G,KAAI,KAAc,IAAa,IAAI,IAAW,IAAI,EAC9C,QAAO,EAAM,GAAG,EAAW;CAG/B,IAAM,IAAY,KAAK,IAAI,IAAO,GAAU,IAAa,EAAE,EACrD,IAAa,KAAK,IAAI,IAAO,GAAU,IAAa,IAAa,EAAE,EAEnE,IAAe,IAAY,IAAa,GACxC,IAAgB,IAAa,IAAa,IAAa,GAEvD,IAAW,EAAM,GAAG,EAAW,EAC/B,IAAY,EAAM,IAAa,IAAa,GAAG,EAAW;AAEhE,KAAI,CAAC,KAAgB,EAEjB,QAAO;EAAC,GAAG,EAAM,GADC,IAAW,IAAI,IAAa,EAChB;EAAE;EAAQ,GAAG;EAAU;AAGzD,KAAI,KAAgB,CAAC,GAAe;EAChC,IAAM,IAAa,IAAW,IAAI,IAAa;AAC/C,SAAO;GAAC,GAAG;GAAU;GAAQ,GAA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C,EAFI,QAAQ,IAEZ,GAEP,kBAAC,UAAD;IAEI,MAAK;IACL,WAAW,EAAG,OAAO,MAAM,KAAe,SAAS;IACnD,eAAe,EAAS,EAAE;cAEzB;IACI,EANA,EAMA,CAEhB;GACD,kBAAC,GAAD;IACI,SAAQ;IACR,MAAK;IACL,UAAA;IACA,UAAU,KAAe;IACzB,eAAe,EAAS,IAAc,EAAE;IACxC,WAAU;cAEV,kBAAC,GAAD,EAAqB,CAAA;IACf,CAAA;GACR"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { t as e } from "./cn-YER3QsV1.js";
|
|
2
|
+
import { t } from "./MPortal-Ba2Sxset.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
|
|
4
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/primitives/MPopover/popoverStack.ts
|
|
6
|
+
var s = [], c = 1;
|
|
7
|
+
function l() {
|
|
8
|
+
return c++;
|
|
9
|
+
}
|
|
10
|
+
function u(e) {
|
|
11
|
+
return s.push(e), () => {
|
|
12
|
+
let t = s.indexOf(e);
|
|
13
|
+
t !== -1 && s.splice(t, 1);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function d(e) {
|
|
17
|
+
let t = e.getAnchorEl();
|
|
18
|
+
if (!t) return null;
|
|
19
|
+
for (let n of s) {
|
|
20
|
+
if (n.id === e.id) continue;
|
|
21
|
+
let r = n.getPopoverEl();
|
|
22
|
+
if (r && r.contains(t)) return n.id;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function f(e, t) {
|
|
27
|
+
if (!t) return !1;
|
|
28
|
+
for (let n of s) {
|
|
29
|
+
if (n.id === e) continue;
|
|
30
|
+
let r = n.getPopoverEl();
|
|
31
|
+
if (!r || !r.contains(t)) continue;
|
|
32
|
+
let i = /* @__PURE__ */ new Set(), a = d(n);
|
|
33
|
+
for (; a !== null && !i.has(a);) {
|
|
34
|
+
if (a === e) return !0;
|
|
35
|
+
i.add(a);
|
|
36
|
+
let t = s.find((e) => e.id === a);
|
|
37
|
+
a = t ? d(t) : null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return !1;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/components/primitives/MPopover/MPopover.tsx
|
|
44
|
+
function p({ open: s, anchorRef: c, onClose: d, placement: p = "bottom-start", matchWidth: m = !1, offset: h = 4, zIndex: g, children: _, className: v, style: y }) {
|
|
45
|
+
let b = i(null), x = i(null);
|
|
46
|
+
x.current === null && (x.current = l());
|
|
47
|
+
let S = x.current, [C, w] = a(null), [T, E] = a(!1), [D, O] = a(null), k = n(() => {
|
|
48
|
+
if (g !== void 0) {
|
|
49
|
+
O(g);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let e = c.current;
|
|
53
|
+
if (!e || typeof window > "u") {
|
|
54
|
+
O(null);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let t = e.closest(".drawer-backdrop, .modal-backdrop, .sheet-backdrop, .sidebar.mobile-open, .popover");
|
|
58
|
+
if (!t) {
|
|
59
|
+
O(null);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let n = window.getComputedStyle(t).zIndex, r = Number.parseInt(n, 10);
|
|
63
|
+
O(Number.isFinite(r) ? r + 1 : null);
|
|
64
|
+
}, [c, g]), A = n(() => {
|
|
65
|
+
if (!c.current || !b.current) return;
|
|
66
|
+
let e = c.current.getBoundingClientRect(), t = b.current.getBoundingClientRect(), n = {
|
|
67
|
+
width: window.innerWidth,
|
|
68
|
+
height: window.innerHeight
|
|
69
|
+
}, r = p.startsWith("top"), i = p.startsWith("right"), a = p.startsWith("left"), o = i || a, s = p.endsWith("end"), l, u;
|
|
70
|
+
if (o) {
|
|
71
|
+
let r = n.width - e.right - h, a = e.left - h, o = i ? r < t.width && a > r : a < t.width && r > a;
|
|
72
|
+
E(o), u = (i ? !o : o) ? e.right + h + window.scrollX : e.left - t.width - h + window.scrollX, l = s ? e.bottom - t.height + window.scrollY : e.top + window.scrollY;
|
|
73
|
+
} else {
|
|
74
|
+
let i = n.height - e.bottom - h, a = e.top - h, o = r ? a < t.height && i > a : i < t.height && a > i;
|
|
75
|
+
E(o), l = (r ? !o : o) ? e.top - t.height - h + window.scrollY : e.bottom + h + window.scrollY, u = s ? e.right - t.width + window.scrollX : e.left + window.scrollX;
|
|
76
|
+
}
|
|
77
|
+
u = Math.max(8, Math.min(u, n.width - t.width - 8)), l = Math.max(8 + window.scrollY, l), w({
|
|
78
|
+
top: l,
|
|
79
|
+
left: u,
|
|
80
|
+
width: m ? e.width : void 0
|
|
81
|
+
});
|
|
82
|
+
}, [
|
|
83
|
+
c,
|
|
84
|
+
p,
|
|
85
|
+
h,
|
|
86
|
+
m
|
|
87
|
+
]);
|
|
88
|
+
return r(() => {
|
|
89
|
+
if (!s) {
|
|
90
|
+
w(null), O(null);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
return k(), requestAnimationFrame(A), document.addEventListener("scroll", A, {
|
|
94
|
+
capture: !0,
|
|
95
|
+
passive: !0
|
|
96
|
+
}), window.addEventListener("resize", A, { passive: !0 }), () => {
|
|
97
|
+
document.removeEventListener("scroll", A, { capture: !0 }), window.removeEventListener("resize", A);
|
|
98
|
+
};
|
|
99
|
+
}, [
|
|
100
|
+
s,
|
|
101
|
+
k,
|
|
102
|
+
A
|
|
103
|
+
]), r(() => {
|
|
104
|
+
if (!s) return;
|
|
105
|
+
let e = (e) => {
|
|
106
|
+
e.key === "Escape" && d();
|
|
107
|
+
};
|
|
108
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
109
|
+
}, [s, d]), r(() => {
|
|
110
|
+
if (s) return u({
|
|
111
|
+
id: S,
|
|
112
|
+
getPopoverEl: () => b.current,
|
|
113
|
+
getAnchorEl: () => c.current
|
|
114
|
+
});
|
|
115
|
+
}, [
|
|
116
|
+
s,
|
|
117
|
+
S,
|
|
118
|
+
c
|
|
119
|
+
]), r(() => {
|
|
120
|
+
if (!s) return;
|
|
121
|
+
let e = (e) => {
|
|
122
|
+
let t = e.target;
|
|
123
|
+
b.current?.contains(t) || c.current?.contains(t) || f(S, t) || d();
|
|
124
|
+
};
|
|
125
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
126
|
+
}, [
|
|
127
|
+
s,
|
|
128
|
+
d,
|
|
129
|
+
c,
|
|
130
|
+
S
|
|
131
|
+
]), s ? /* @__PURE__ */ o(t, { children: /* @__PURE__ */ o("div", {
|
|
132
|
+
ref: b,
|
|
133
|
+
className: e("popover", T ? "flipped" : "normal", v),
|
|
134
|
+
style: {
|
|
135
|
+
position: "absolute",
|
|
136
|
+
top: C?.top ?? 0,
|
|
137
|
+
left: C?.left ?? 0,
|
|
138
|
+
width: C?.width,
|
|
139
|
+
zIndex: D ?? void 0,
|
|
140
|
+
visibility: C ? "visible" : "hidden",
|
|
141
|
+
...y
|
|
142
|
+
},
|
|
143
|
+
role: "listbox",
|
|
144
|
+
children: _
|
|
145
|
+
}) }) : null;
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
export { p as t };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=MPopover-C5aaGhma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MPopover-C5aaGhma.js","names":[],"sources":["../src/components/primitives/MPopover/popoverStack.ts","../src/components/primitives/MPopover/MPopover.tsx"],"sourcesContent":["/**\n * Registry of currently-open MPopover instances.\n *\n * Every popover portals its content to `document.body`, so a popover opened\n * from inside another popover is NOT a DOM descendant of its parent. That\n * breaks the naive outside-click test (`parent.contains(target)`): pressing a\n * nested dropdown item looks like an outside click to the parent, the parent\n * closes, React unmounts the nested menu mid-gesture, and the browser never\n * gets to fire `click` because mousedown and mouseup landed on different\n * elements. The action silently does nothing.\n *\n * This registry restores the nesting relation the DOM lost. Nesting is derived\n * from where each popover's ANCHOR lives, not from open order: a popover whose\n * anchor sits inside another popover's element is that popover's child. Open\n * order would misclassify two independent popovers that happen to be open at\n * the same time — clicking the newer one must still close the older one.\n */\n\nexport interface PopoverRegistration {\n id: number\n getPopoverEl: () => HTMLElement | null\n getAnchorEl: () => HTMLElement | null\n}\n\nconst registrations: PopoverRegistration[] = []\nlet nextId = 1\n\nexport function nextPopoverId(): number {\n return nextId++\n}\n\nexport function registerPopover(registration: PopoverRegistration): () => void {\n registrations.push(registration)\n return () => {\n const index = registrations.indexOf(registration)\n if (index !== -1) registrations.splice(index, 1)\n }\n}\n\n/** The registered popover whose element contains `entry`'s anchor, if any. */\nfunction parentIdOf(entry: PopoverRegistration): number | null {\n const anchor = entry.getAnchorEl()\n if (!anchor) return null\n\n for (const other of registrations) {\n if (other.id === entry.id) continue\n const element = other.getPopoverEl()\n if (element && element.contains(anchor)) return other.id\n }\n\n return null\n}\n\n/**\n * True when `target` lies inside a popover that is nested (at any depth) within\n * the popover identified by `id`. Callers use it to keep a parent open while\n * the interaction belongs to one of its descendants.\n */\nexport function isInsideDescendantPopover(id: number, target: Node | null): boolean {\n if (!target) return false\n\n for (const entry of registrations) {\n if (entry.id === id) continue\n\n const element = entry.getPopoverEl()\n if (!element || !element.contains(target)) continue\n\n // Walk the ancestor chain of the popover that was actually hit.\n // `seen` guards against a cycle if a malformed tree ever produces one.\n const seen = new Set<number>()\n let cursor = parentIdOf(entry)\n\n while (cursor !== null && !seen.has(cursor)) {\n if (cursor === id) return true\n seen.add(cursor)\n const parent = registrations.find((candidate) => candidate.id === cursor)\n cursor = parent ? parentIdOf(parent) : null\n }\n }\n\n return false\n}\n\n/** Test-only helper — the registry is module state that outlives a render. */\nexport function __resetPopoverStack(): void {\n registrations.length = 0\n nextId = 1\n}\n","import {useState, useEffect, useRef, useCallback} from 'react'\nimport {MPortal} from '../MPortal'\nimport {cn} from '../../../utils/cn'\nimport {isInsideDescendantPopover, nextPopoverId, registerPopover} from './popoverStack'\nimport type {MPopoverProps} from './MPopover.types'\nimport './MPopover.css'\n\n// Position floating content relative to an anchor with viewport-aware flipping.\nexport function MPopover({\n open,\n anchorRef,\n onClose,\n placement = 'bottom-start',\n matchWidth = false,\n offset = 4,\n zIndex,\n children,\n className,\n style,\n}: MPopoverProps) {\n const popoverRef = useRef<HTMLDivElement>(null)\n const popoverIdRef = useRef<number>(null)\n if (popoverIdRef.current === null) popoverIdRef.current = nextPopoverId()\n const popoverId = popoverIdRef.current\n const [position, setPosition] = useState<{top: number; left: number; width?: number} | null>(null)\n const [flipped, setFlipped] = useState(false)\n const [layerZ, setLayerZ] = useState<number | string | null>(null)\n\n // Lift popovers above drawers, modals and mobile sidebars when the anchor sits inside them.\n const updateLayer = useCallback(() => {\n if (zIndex !== undefined) {\n setLayerZ(zIndex)\n return\n }\n\n const anchor = anchorRef.current\n if (!anchor || typeof window === 'undefined') {\n setLayerZ(null)\n return\n }\n\n const layerHost = anchor.closest(\n '.drawer-backdrop, .modal-backdrop, .sheet-backdrop, .sidebar.mobile-open, .popover'\n )\n if (!layerHost) {\n setLayerZ(null)\n return\n }\n\n const computedZ = window.getComputedStyle(layerHost).zIndex\n const parsedZ = Number.parseInt(computedZ, 10)\n setLayerZ(Number.isFinite(parsedZ) ? parsedZ + 1 : null)\n }, [anchorRef, zIndex])\n\n // Recalculate popover position whenever layout or viewport constraints change.\n const updatePosition = useCallback(() => {\n if (!anchorRef.current || !popoverRef.current) return\n\n const anchor = anchorRef.current.getBoundingClientRect()\n const popover = popoverRef.current.getBoundingClientRect()\n const viewport = {\n width: window.innerWidth,\n height: window.innerHeight,\n }\n\n const isTop = placement.startsWith('top')\n const isRight = placement.startsWith('right')\n const isLeft = placement.startsWith('left')\n const isHorizontal = isRight || isLeft\n const isEnd = placement.endsWith('end')\n\n let top: number\n let left: number\n\n if (isHorizontal) {\n // Horizontal placement: position to the right or left of the anchor\n const spaceRight = viewport.width - anchor.right - offset\n const spaceLeft = anchor.left - offset\n const shouldFlip = isRight\n ? spaceRight < popover.width && spaceLeft > spaceRight\n : spaceLeft < popover.width && spaceRight > spaceLeft\n\n setFlipped(shouldFlip)\n\n const showOnRight = isRight ? !shouldFlip : shouldFlip\n\n if (showOnRight) {\n left = anchor.right + offset + window.scrollX\n } else {\n left = anchor.left - popover.width - offset + window.scrollX\n }\n\n if (isEnd) {\n top = anchor.bottom - popover.height + window.scrollY\n } else {\n top = anchor.top + window.scrollY\n }\n } else {\n // Vertical placement: position above or below the anchor\n const spaceBelow = viewport.height - anchor.bottom - offset\n const spaceAbove = anchor.top - offset\n const shouldFlip = isTop\n ? spaceAbove < popover.height && spaceBelow > spaceAbove\n : spaceBelow < popover.height && spaceAbove > spaceBelow\n\n setFlipped(shouldFlip)\n\n const showOnTop = isTop ? !shouldFlip : shouldFlip\n\n if (showOnTop) {\n top = anchor.top - popover.height - offset + window.scrollY\n } else {\n top = anchor.bottom + offset + window.scrollY\n }\n\n if (isEnd) {\n left = anchor.right - popover.width + window.scrollX\n } else {\n left = anchor.left + window.scrollX\n }\n }\n\n // Clamp to viewport\n left = Math.max(8, Math.min(left, viewport.width - popover.width - 8))\n top = Math.max(8 + window.scrollY, top)\n\n setPosition({\n top,\n left,\n width: matchWidth ? anchor.width : undefined,\n })\n }, [anchorRef, placement, offset, matchWidth])\n\n useEffect(() => {\n if (!open) {\n setPosition(null)\n setLayerZ(null)\n return\n }\n\n updateLayer()\n // Wait one frame so the rendered popover can be measured accurately.\n requestAnimationFrame(updatePosition)\n\n // `scroll` does not bubble, so a window listener only ever sees the\n // document scrolling. Anchors living inside a scrollable ancestor — an\n // app shell with a scrolling main region, MStickyPanel, an overflowing\n // card — would leave the popover stranded at its opening coordinates\n // while the anchor moved away underneath it. Scroll events do capture,\n // so a capture-phase listener on the document catches scrolling from\n // ANY container, including the document itself.\n document.addEventListener('scroll', updatePosition, {capture: true, passive: true})\n window.addEventListener('resize', updatePosition, {passive: true})\n return () => {\n document.removeEventListener('scroll', updatePosition, {capture: true})\n window.removeEventListener('resize', updatePosition)\n }\n }, [open, updateLayer, updatePosition])\n\n // Close the popover with the standard Escape key interaction.\n useEffect(() => {\n if (!open) return\n const handleKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose()\n }\n document.addEventListener('keydown', handleKey)\n return () => document.removeEventListener('keydown', handleKey)\n }, [open, onClose])\n\n // Publish this instance while it is open so nested popovers can be related\n // back to it — see popoverStack.ts for why the DOM alone cannot answer this.\n useEffect(() => {\n if (!open) return\n return registerPopover({\n id: popoverId,\n getPopoverEl: () => popoverRef.current,\n getAnchorEl: () => anchorRef.current,\n })\n }, [open, popoverId, anchorRef])\n\n // Close when the user interacts outside both the popover and its anchor.\n useEffect(() => {\n if (!open) return\n const handleClick = (e: MouseEvent) => {\n const target = e.target as Node\n\n if (popoverRef.current?.contains(target) || anchorRef.current?.contains(target)) {\n return\n }\n\n // A popover nested inside this one is portaled to `document.body`,\n // so it fails the `contains` checks above even though the click\n // belongs to this popover's own subtree. Closing here would unmount\n // that child between mousedown and mouseup and swallow its click.\n if (isInsideDescendantPopover(popoverId, target)) {\n return\n }\n\n onClose()\n }\n document.addEventListener('mousedown', handleClick)\n return () => document.removeEventListener('mousedown', handleClick)\n }, [open, onClose, anchorRef, popoverId])\n\n if (!open) return null\n\n return (\n <MPortal>\n <div\n ref={popoverRef}\n className={cn('popover', flipped ? 'flipped' : 'normal', className)}\n style={{\n position: 'absolute',\n top: position?.top ?? 0,\n left: position?.left ?? 0,\n width: position?.width,\n zIndex: layerZ ?? undefined,\n visibility: position ? 'visible' : 'hidden',\n ...style,\n }}\n role=\"listbox\"\n >\n {children}\n </div>\n </MPortal>\n )\n}\n"],"mappings":";;;;;AAwBA,IAAM,IAAuC,EAAE,EAC3C,IAAS;AAEb,SAAgB,IAAwB;AACpC,QAAO;;AAGX,SAAgB,EAAgB,GAA+C;AAE3E,QADA,EAAc,KAAK,EAAa,QACnB;EACT,IAAM,IAAQ,EAAc,QAAQ,EAAa;AACjD,EA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EACX,IAAM,KAAe,MAAkB;GACnC,IAAM,IAAS,EAAE;AAEb,KAAW,SAAS,SAAS,EAAO,IAAI,EAAU,SAAS,SAAS,EAAO,IAQ3E,EAA0B,GAAW,EAAO,IAIhD,GAAS;;AAGb,SADA,SAAS,iBAAiB,aAAa,EAAY,QACtC,SAAS,oBAAoB,aAAa,EAAY;IACpE;EAAC;EAAM;EAAS;EAAW;EAAU,CAAC,EAEpC,IAGD,kBAAC,GAAD,EAAA,UACI,kBAAC,OAAD;EACI,KAAK;EACL,WAAW,EAAG,WAAW,IAAU,YAAY,UAAU,EAAU;EACnE,OAAO;GACH,UAAU;GACV,KAAK,GAAU,OAAO;GACtB,MAAM,GAAU,QAAQ;GACxB,OAAO,GAAU;GACjB,QAAQ,KAAU,KAAA;GAClB,YAAY,IAAW,YAAY;GACnC,GAAG;GACN;EACD,MAAK;EAEJ;EACC,CAAA,EACA,CAAA,GApBI"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./cn-CU5TNITO.cjs`),t=require(`./MPortal-BciZHNDC.cjs`);require(`./core-DBpQf3uY.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=[],a=1;function o(){return a++}function s(e){return i.push(e),()=>{let t=i.indexOf(e);t!==-1&&i.splice(t,1)}}function c(e){let t=e.getAnchorEl();if(!t)return null;for(let n of i){if(n.id===e.id)continue;let r=n.getPopoverEl();if(r&&r.contains(t))return n.id}return null}function l(e,t){if(!t)return!1;for(let n of i){if(n.id===e)continue;let r=n.getPopoverEl();if(!r||!r.contains(t))continue;let a=new Set,o=c(n);for(;o!==null&&!a.has(o);){if(o===e)return!0;a.add(o);let t=i.find(e=>e.id===o);o=t?c(t):null}}return!1}function u({open:i,anchorRef:a,onClose:c,placement:u=`bottom-start`,matchWidth:d=!1,offset:f=4,zIndex:p,children:m,className:h,style:g}){let _=(0,n.useRef)(null),v=(0,n.useRef)(null);v.current===null&&(v.current=o());let y=v.current,[b,x]=(0,n.useState)(null),[S,C]=(0,n.useState)(!1),[w,T]=(0,n.useState)(null),E=(0,n.useCallback)(()=>{if(p!==void 0){T(p);return}let e=a.current;if(!e||typeof window>`u`){T(null);return}let t=e.closest(`.drawer-backdrop, .modal-backdrop, .sheet-backdrop, .sidebar.mobile-open, .popover`);if(!t){T(null);return}let n=window.getComputedStyle(t).zIndex,r=Number.parseInt(n,10);T(Number.isFinite(r)?r+1:null)},[a,p]),D=(0,n.useCallback)(()=>{if(!a.current||!_.current)return;let e=a.current.getBoundingClientRect(),t=_.current.getBoundingClientRect(),n={width:window.innerWidth,height:window.innerHeight},r=u.startsWith(`top`),i=u.startsWith(`right`),o=u.startsWith(`left`),s=i||o,c=u.endsWith(`end`),l,p;if(s){let r=n.width-e.right-f,a=e.left-f,o=i?r<t.width&&a>r:a<t.width&&r>a;C(o),p=(i?!o:o)?e.right+f+window.scrollX:e.left-t.width-f+window.scrollX,l=c?e.bottom-t.height+window.scrollY:e.top+window.scrollY}else{let i=n.height-e.bottom-f,a=e.top-f,o=r?a<t.height&&i>a:i<t.height&&a>i;C(o),l=(r?!o:o)?e.top-t.height-f+window.scrollY:e.bottom+f+window.scrollY,p=c?e.right-t.width+window.scrollX:e.left+window.scrollX}p=Math.max(8,Math.min(p,n.width-t.width-8)),l=Math.max(8+window.scrollY,l),x({top:l,left:p,width:d?e.width:void 0})},[a,u,f,d]);return(0,n.useEffect)(()=>{if(!i){x(null),T(null);return}return E(),requestAnimationFrame(D),document.addEventListener(`scroll`,D,{capture:!0,passive:!0}),window.addEventListener(`resize`,D,{passive:!0}),()=>{document.removeEventListener(`scroll`,D,{capture:!0}),window.removeEventListener(`resize`,D)}},[i,E,D]),(0,n.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&c()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c]),(0,n.useEffect)(()=>{if(i)return s({id:y,getPopoverEl:()=>_.current,getAnchorEl:()=>a.current})},[i,y,a]),(0,n.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;_.current?.contains(t)||a.current?.contains(t)||l(y,t)||c()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i,c,a,y]),i?(0,r.jsx)(t.t,{children:(0,r.jsx)(`div`,{ref:_,className:e.t(`popover`,S?`flipped`:`normal`,h),style:{position:`absolute`,top:b?.top??0,left:b?.left??0,width:b?.width,zIndex:w??void 0,visibility:b?`visible`:`hidden`,...g},role:`listbox`,children:m})}):null}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
|
2
|
+
//# sourceMappingURL=MPopover-CV-9MArH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MPopover-CV-9MArH.cjs","names":[],"sources":["../src/components/primitives/MPopover/popoverStack.ts","../src/components/primitives/MPopover/MPopover.tsx"],"sourcesContent":["/**\n * Registry of currently-open MPopover instances.\n *\n * Every popover portals its content to `document.body`, so a popover opened\n * from inside another popover is NOT a DOM descendant of its parent. That\n * breaks the naive outside-click test (`parent.contains(target)`): pressing a\n * nested dropdown item looks like an outside click to the parent, the parent\n * closes, React unmounts the nested menu mid-gesture, and the browser never\n * gets to fire `click` because mousedown and mouseup landed on different\n * elements. The action silently does nothing.\n *\n * This registry restores the nesting relation the DOM lost. Nesting is derived\n * from where each popover's ANCHOR lives, not from open order: a popover whose\n * anchor sits inside another popover's element is that popover's child. Open\n * order would misclassify two independent popovers that happen to be open at\n * the same time — clicking the newer one must still close the older one.\n */\n\nexport interface PopoverRegistration {\n id: number\n getPopoverEl: () => HTMLElement | null\n getAnchorEl: () => HTMLElement | null\n}\n\nconst registrations: PopoverRegistration[] = []\nlet nextId = 1\n\nexport function nextPopoverId(): number {\n return nextId++\n}\n\nexport function registerPopover(registration: PopoverRegistration): () => void {\n registrations.push(registration)\n return () => {\n const index = registrations.indexOf(registration)\n if (index !== -1) registrations.splice(index, 1)\n }\n}\n\n/** The registered popover whose element contains `entry`'s anchor, if any. */\nfunction parentIdOf(entry: PopoverRegistration): number | null {\n const anchor = entry.getAnchorEl()\n if (!anchor) return null\n\n for (const other of registrations) {\n if (other.id === entry.id) continue\n const element = other.getPopoverEl()\n if (element && element.contains(anchor)) return other.id\n }\n\n return null\n}\n\n/**\n * True when `target` lies inside a popover that is nested (at any depth) within\n * the popover identified by `id`. Callers use it to keep a parent open while\n * the interaction belongs to one of its descendants.\n */\nexport function isInsideDescendantPopover(id: number, target: Node | null): boolean {\n if (!target) return false\n\n for (const entry of registrations) {\n if (entry.id === id) continue\n\n const element = entry.getPopoverEl()\n if (!element || !element.contains(target)) continue\n\n // Walk the ancestor chain of the popover that was actually hit.\n // `seen` guards against a cycle if a malformed tree ever produces one.\n const seen = new Set<number>()\n let cursor = parentIdOf(entry)\n\n while (cursor !== null && !seen.has(cursor)) {\n if (cursor === id) return true\n seen.add(cursor)\n const parent = registrations.find((candidate) => candidate.id === cursor)\n cursor = parent ? parentIdOf(parent) : null\n }\n }\n\n return false\n}\n\n/** Test-only helper — the registry is module state that outlives a render. */\nexport function __resetPopoverStack(): void {\n registrations.length = 0\n nextId = 1\n}\n","import {useState, useEffect, useRef, useCallback} from 'react'\nimport {MPortal} from '../MPortal'\nimport {cn} from '../../../utils/cn'\nimport {isInsideDescendantPopover, nextPopoverId, registerPopover} from './popoverStack'\nimport type {MPopoverProps} from './MPopover.types'\nimport './MPopover.css'\n\n// Position floating content relative to an anchor with viewport-aware flipping.\nexport function MPopover({\n open,\n anchorRef,\n onClose,\n placement = 'bottom-start',\n matchWidth = false,\n offset = 4,\n zIndex,\n children,\n className,\n style,\n}: MPopoverProps) {\n const popoverRef = useRef<HTMLDivElement>(null)\n const popoverIdRef = useRef<number>(null)\n if (popoverIdRef.current === null) popoverIdRef.current = nextPopoverId()\n const popoverId = popoverIdRef.current\n const [position, setPosition] = useState<{top: number; left: number; width?: number} | null>(null)\n const [flipped, setFlipped] = useState(false)\n const [layerZ, setLayerZ] = useState<number | string | null>(null)\n\n // Lift popovers above drawers, modals and mobile sidebars when the anchor sits inside them.\n const updateLayer = useCallback(() => {\n if (zIndex !== undefined) {\n setLayerZ(zIndex)\n return\n }\n\n const anchor = anchorRef.current\n if (!anchor || typeof window === 'undefined') {\n setLayerZ(null)\n return\n }\n\n const layerHost = anchor.closest(\n '.drawer-backdrop, .modal-backdrop, .sheet-backdrop, .sidebar.mobile-open, .popover'\n )\n if (!layerHost) {\n setLayerZ(null)\n return\n }\n\n const computedZ = window.getComputedStyle(layerHost).zIndex\n const parsedZ = Number.parseInt(computedZ, 10)\n setLayerZ(Number.isFinite(parsedZ) ? parsedZ + 1 : null)\n }, [anchorRef, zIndex])\n\n // Recalculate popover position whenever layout or viewport constraints change.\n const updatePosition = useCallback(() => {\n if (!anchorRef.current || !popoverRef.current) return\n\n const anchor = anchorRef.current.getBoundingClientRect()\n const popover = popoverRef.current.getBoundingClientRect()\n const viewport = {\n width: window.innerWidth,\n height: window.innerHeight,\n }\n\n const isTop = placement.startsWith('top')\n const isRight = placement.startsWith('right')\n const isLeft = placement.startsWith('left')\n const isHorizontal = isRight || isLeft\n const isEnd = placement.endsWith('end')\n\n let top: number\n let left: number\n\n if (isHorizontal) {\n // Horizontal placement: position to the right or left of the anchor\n const spaceRight = viewport.width - anchor.right - offset\n const spaceLeft = anchor.left - offset\n const shouldFlip = isRight\n ? spaceRight < popover.width && spaceLeft > spaceRight\n : spaceLeft < popover.width && spaceRight > spaceLeft\n\n setFlipped(shouldFlip)\n\n const showOnRight = isRight ? !shouldFlip : shouldFlip\n\n if (showOnRight) {\n left = anchor.right + offset + window.scrollX\n } else {\n left = anchor.left - popover.width - offset + window.scrollX\n }\n\n if (isEnd) {\n top = anchor.bottom - popover.height + window.scrollY\n } else {\n top = anchor.top + window.scrollY\n }\n } else {\n // Vertical placement: position above or below the anchor\n const spaceBelow = viewport.height - anchor.bottom - offset\n const spaceAbove = anchor.top - offset\n const shouldFlip = isTop\n ? spaceAbove < popover.height && spaceBelow > spaceAbove\n : spaceBelow < popover.height && spaceAbove > spaceBelow\n\n setFlipped(shouldFlip)\n\n const showOnTop = isTop ? !shouldFlip : shouldFlip\n\n if (showOnTop) {\n top = anchor.top - popover.height - offset + window.scrollY\n } else {\n top = anchor.bottom + offset + window.scrollY\n }\n\n if (isEnd) {\n left = anchor.right - popover.width + window.scrollX\n } else {\n left = anchor.left + window.scrollX\n }\n }\n\n // Clamp to viewport\n left = Math.max(8, Math.min(left, viewport.width - popover.width - 8))\n top = Math.max(8 + window.scrollY, top)\n\n setPosition({\n top,\n left,\n width: matchWidth ? anchor.width : undefined,\n })\n }, [anchorRef, placement, offset, matchWidth])\n\n useEffect(() => {\n if (!open) {\n setPosition(null)\n setLayerZ(null)\n return\n }\n\n updateLayer()\n // Wait one frame so the rendered popover can be measured accurately.\n requestAnimationFrame(updatePosition)\n\n // `scroll` does not bubble, so a window listener only ever sees the\n // document scrolling. Anchors living inside a scrollable ancestor — an\n // app shell with a scrolling main region, MStickyPanel, an overflowing\n // card — would leave the popover stranded at its opening coordinates\n // while the anchor moved away underneath it. Scroll events do capture,\n // so a capture-phase listener on the document catches scrolling from\n // ANY container, including the document itself.\n document.addEventListener('scroll', updatePosition, {capture: true, passive: true})\n window.addEventListener('resize', updatePosition, {passive: true})\n return () => {\n document.removeEventListener('scroll', updatePosition, {capture: true})\n window.removeEventListener('resize', updatePosition)\n }\n }, [open, updateLayer, updatePosition])\n\n // Close the popover with the standard Escape key interaction.\n useEffect(() => {\n if (!open) return\n const handleKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose()\n }\n document.addEventListener('keydown', handleKey)\n return () => document.removeEventListener('keydown', handleKey)\n }, [open, onClose])\n\n // Publish this instance while it is open so nested popovers can be related\n // back to it — see popoverStack.ts for why the DOM alone cannot answer this.\n useEffect(() => {\n if (!open) return\n return registerPopover({\n id: popoverId,\n getPopoverEl: () => popoverRef.current,\n getAnchorEl: () => anchorRef.current,\n })\n }, [open, popoverId, anchorRef])\n\n // Close when the user interacts outside both the popover and its anchor.\n useEffect(() => {\n if (!open) return\n const handleClick = (e: MouseEvent) => {\n const target = e.target as Node\n\n if (popoverRef.current?.contains(target) || anchorRef.current?.contains(target)) {\n return\n }\n\n // A popover nested inside this one is portaled to `document.body`,\n // so it fails the `contains` checks above even though the click\n // belongs to this popover's own subtree. Closing here would unmount\n // that child between mousedown and mouseup and swallow its click.\n if (isInsideDescendantPopover(popoverId, target)) {\n return\n }\n\n onClose()\n }\n document.addEventListener('mousedown', handleClick)\n return () => document.removeEventListener('mousedown', handleClick)\n }, [open, onClose, anchorRef, popoverId])\n\n if (!open) return null\n\n return (\n <MPortal>\n <div\n ref={popoverRef}\n className={cn('popover', flipped ? 'flipped' : 'normal', className)}\n style={{\n position: 'absolute',\n top: position?.top ?? 0,\n left: position?.left ?? 0,\n width: position?.width,\n zIndex: layerZ ?? undefined,\n visibility: position ? 'visible' : 'hidden',\n ...style,\n }}\n role=\"listbox\"\n >\n {children}\n </div>\n </MPortal>\n )\n}\n"],"mappings":"8JAwBA,IAAM,EAAuC,EAAE,CAC3C,EAAS,EAEb,SAAgB,GAAwB,CACpC,MAAO,KAGX,SAAgB,EAAgB,EAA+C,CAE3E,OADA,EAAc,KAAK,EAAa,KACnB,CACT,IAAM,EAAQ,EAAc,QAAQ,EAAa,CAC7C,IAAU,IAAI,EAAc,OAAO,EAAO,EAAE,EAKxD,SAAS,EAAW,EAA2C,CAC3D,IAAM,EAAS,EAAM,aAAa,CAClC,GAAI,CAAC,EAAQ,OAAO,KAEpB,IAAK,IAAM,KAAS,EAAe,CAC/B,GAAI,EAAM,KAAO,EAAM,GAAI,SAC3B,IAAM,EAAU,EAAM,cAAc,CACpC,GAAI,GAAW,EAAQ,SAAS,EAAO,CAAE,OAAO,EAAM,GAG1D,OAAO,KAQX,SAAgB,EAA0B,EAAY,EAA8B,CAChF,GAAI,CAAC,EAAQ,MAAO,GAEpB,IAAK,IAAM,KAAS,EAAe,CAC/B,GAAI,EAAM,KAAO,EAAI,SAErB,IAAM,EA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W,EAAU,UAAY,SAAU,EAAU,CACnE,MAAO,CACH,SAAU,WACV,IAAK,GAAU,KAAO,EACtB,KAAM,GAAU,MAAQ,EACxB,MAAO,GAAU,MACjB,OAAQ,GAAU,IAAA,GAClB,WAAY,EAAW,UAAY,SACnC,GAAG,EACN,CACD,KAAK,UAEJ,WACC,CAAA,CACA,CAAA,CApBI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./theme-BfNZicWk.cjs`),t=require(`./icons-
|
|
2
|
-
//# sourceMappingURL=MTag-
|
|
1
|
+
const e=require(`./theme-BfNZicWk.cjs`),t=require(`./icons-D675Im0B.cjs`),n=require(`./cn-CU5TNITO.cjs`),r=require(`./MButton-R08y1HCT.cjs`);require(`./core-DBpQf3uY.cjs`);let i=require(`react/jsx-runtime`);function a({label:a,color:o=`primary`,variant:s=`solid`,size:c=`md`,hidden:l,rounded:u=!1,closable:d=!1,onClose:f,icon:p,className:m,...h}){return(0,i.jsxs)(`span`,{className:n.t(`m-tag`,`color-${o}`,s,c,u&&`rounded`,m),...e.r(l),...h,children:[p&&(0,i.jsx)(`span`,{className:`m-tag icon`,children:p}),(0,i.jsx)(`span`,{className:`m-tag label`,children:a}),d&&(0,i.jsx)(r.t,{variant:`link`,color:`neutral`,iconOnly:!0,size:`xs`,className:`m-tag close`,onClick:e=>{e.stopPropagation(),f?.()},"aria-label":`Remove`,children:(0,i.jsx)(t.Xi,{})})]})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
2
|
+
//# sourceMappingURL=MTag-BzTp1crT.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MTag-
|
|
1
|
+
{"version":3,"file":"MTag-BzTp1crT.cjs","names":[],"sources":["../src/components/feedback/MTag/MTag.tsx"],"sourcesContent":["import type {MTagProps} from './MTag.types'\nimport {getHiddenProps} from '../../../theme'\nimport {cn} from '../../../utils/cn'\nimport {MButton} from '../../controls'\nimport {MCloseIcon} from '../../../icons'\nimport './MTag.css'\n\nexport function MTag({\n label,\n color = 'primary',\n variant = 'solid',\n size = 'md',\n hidden,\n rounded = false,\n closable = false,\n onClose,\n icon,\n className,\n ...rest\n}: MTagProps) {\n return (\n <span\n className={cn('m-tag', `color-${color}`, variant, size, rounded && 'rounded', className)}\n {...getHiddenProps(hidden)}\n {...rest}\n >\n {icon && <span className=\"m-tag icon\">{icon}</span>}\n <span className=\"m-tag label\">{label}</span>\n {closable && (\n <MButton\n variant=\"link\"\n color=\"neutral\"\n iconOnly\n size=\"xs\"\n className=\"m-tag close\"\n onClick={(e) => {\n e.stopPropagation()\n onClose?.()\n }}\n aria-label=\"Remove\"\n >\n <MCloseIcon />\n </MButton>\n )}\n </span>\n )\n}\n"],"mappings":"+MAOA,SAAgB,EAAK,CACjB,QACA,QAAQ,UACR,UAAU,QACV,OAAO,KACP,SACA,UAAU,GACV,WAAW,GACX,UACA,OACA,YACA,GAAG,GACO,CACV,OACI,EAAA,EAAA,MAAC,OAAD,CACI,UAAW,EAAA,EAAG,QAAS,SAAS,IAAS,EAAS,EAAM,GAAW,UAAW,EAAU,CACxF,GAAI,EAAA,EAAe,EAAO,CAC1B,GAAI,WAHR,CAKK,IAAQ,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,sBAAc,EAAY,CAAA,EACnD,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,uBAAe,EAAa,CAAA,CAC3C,IACG,EAAA,EAAA,KAAC,EAAA,EAAD,CACI,QAAQ,OACR,MAAM,UACN,SAAA,GACA,KAAK,KACL,UAAU,cACV,QAAU,GAAM,CACZ,EAAE,iBAAiB,CACnB,KAAW,EAEf,aAAW,mBAEX,EAAA,EAAA,KAAC,EAAA,GAAD,EAAc,CAAA,CACR,CAAA,CAEX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as e } from "./theme-DAOU1aPs.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Xi as t } from "./icons-CBMl-kOM.js";
|
|
3
3
|
import { t as n } from "./cn-YER3QsV1.js";
|
|
4
4
|
import { t as r } from "./MButton-C1pnL4_j.js";
|
|
5
5
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
@@ -36,4 +36,4 @@ function o({ label: o, color: s = "primary", variant: c = "solid", size: l = "md
|
|
|
36
36
|
//#endregion
|
|
37
37
|
export { o as t };
|
|
38
38
|
|
|
39
|
-
//# sourceMappingURL=MTag-
|
|
39
|
+
//# sourceMappingURL=MTag-D9q6faIk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MTag-
|
|
1
|
+
{"version":3,"file":"MTag-D9q6faIk.js","names":[],"sources":["../src/components/feedback/MTag/MTag.tsx"],"sourcesContent":["import type {MTagProps} from './MTag.types'\nimport {getHiddenProps} from '../../../theme'\nimport {cn} from '../../../utils/cn'\nimport {MButton} from '../../controls'\nimport {MCloseIcon} from '../../../icons'\nimport './MTag.css'\n\nexport function MTag({\n label,\n color = 'primary',\n variant = 'solid',\n size = 'md',\n hidden,\n rounded = false,\n closable = false,\n onClose,\n icon,\n className,\n ...rest\n}: MTagProps) {\n return (\n <span\n className={cn('m-tag', `color-${color}`, variant, size, rounded && 'rounded', className)}\n {...getHiddenProps(hidden)}\n {...rest}\n >\n {icon && <span className=\"m-tag icon\">{icon}</span>}\n <span className=\"m-tag label\">{label}</span>\n {closable && (\n <MButton\n variant=\"link\"\n color=\"neutral\"\n iconOnly\n size=\"xs\"\n className=\"m-tag close\"\n onClick={(e) => {\n e.stopPropagation()\n onClose?.()\n }}\n aria-label=\"Remove\"\n >\n <MCloseIcon />\n </MButton>\n )}\n </span>\n )\n}\n"],"mappings":";;;;;;AAOA,SAAgB,EAAK,EACjB,UACA,WAAQ,WACR,aAAU,SACV,UAAO,MACP,WACA,aAAU,IACV,cAAW,IACX,YACA,SACA,cACA,GAAG,KACO;AACV,QACI,kBAAC,QAAD;EACI,WAAW,EAAG,SAAS,SAAS,KAAS,GAAS,GAAM,KAAW,WAAW,EAAU;EACxF,GAAI,EAAe,EAAO;EAC1B,GAAI;YAHR;GAKK,KAAQ,kBAAC,QAAD;IAAM,WAAU;cAAc;IAAY,CAAA;GACnD,kBAAC,QAAD;IAAM,WAAU;cAAe;IAAa,CAAA;GAC3C,KACG,kBAAC,GAAD;IACI,SAAQ;IACR,OAAM;IACN,UAAA;IACA,MAAK;IACL,WAAU;IACV,UAAU,MAAM;AAEZ,KADA,EAAE,iBAAiB,EACnB,KAAW;;IAEf,cAAW;cAEX,kBAAC,GAAD,EAAc,CAAA;IACR,CAAA;GAEX"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $r as e, Br as t,
|
|
1
|
+
import { $r as e, Br as t, Fr as n, Gr as r, Hr as i, Ir as a, Jr as o, Lr as s, Qr as c, Rr as l, Ur as u, Vr as d, Wr as f, Xr as p, Yr as m, Zr as h, _i as g, ai as _, ci as v, di as y, ei as b, fi as x, ii as S, mi as C, ni as w, oi as T, pi as E, qi as D, qr as O, ri as k, si as A, ti as j } from "./icons-CBMl-kOM.js";
|
|
2
2
|
import { t as M } from "./cn-YER3QsV1.js";
|
|
3
3
|
import { t as N } from "./MPortal-Ba2Sxset.js";
|
|
4
4
|
import { t as P } from "./MCheckbox-B7SpcD4H.js";
|
|
@@ -6,34 +6,34 @@ import { useEffect as ee, useRef as F, useState as I } from "react";
|
|
|
6
6
|
import { jsx as L, jsxs as R } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/data/MTreeView/MTreeView.tsx
|
|
8
8
|
var z = {
|
|
9
|
-
pdf: /* @__PURE__ */ L(
|
|
10
|
-
ts: /* @__PURE__ */ L(
|
|
11
|
-
tsx: /* @__PURE__ */ L(
|
|
12
|
-
js: /* @__PURE__ */ L(
|
|
13
|
-
jsx: /* @__PURE__ */ L(
|
|
14
|
-
css: /* @__PURE__ */ L(
|
|
15
|
-
scss: /* @__PURE__ */ L(
|
|
16
|
-
html: /* @__PURE__ */ L(
|
|
17
|
-
json: /* @__PURE__ */ L(
|
|
18
|
-
md: /* @__PURE__ */ L(
|
|
19
|
-
txt: /* @__PURE__ */ L(
|
|
9
|
+
pdf: /* @__PURE__ */ L(E, {}),
|
|
10
|
+
ts: /* @__PURE__ */ L(w, {}),
|
|
11
|
+
tsx: /* @__PURE__ */ L(k, {}),
|
|
12
|
+
js: /* @__PURE__ */ L(f, {}),
|
|
13
|
+
jsx: /* @__PURE__ */ L(y, {}),
|
|
14
|
+
css: /* @__PURE__ */ L(s, {}),
|
|
15
|
+
scss: /* @__PURE__ */ L(s, {}),
|
|
16
|
+
html: /* @__PURE__ */ L(i, {}),
|
|
17
|
+
json: /* @__PURE__ */ L(r, {}),
|
|
18
|
+
md: /* @__PURE__ */ L(O, {}),
|
|
19
|
+
txt: /* @__PURE__ */ L(S, {}),
|
|
20
20
|
csv: /* @__PURE__ */ L(l, {}),
|
|
21
|
-
zip: /* @__PURE__ */ L(
|
|
22
|
-
rar: /* @__PURE__ */ L(
|
|
23
|
-
svg: /* @__PURE__ */ L(
|
|
24
|
-
png: /* @__PURE__ */ L(
|
|
25
|
-
jpg: /* @__PURE__ */ L(
|
|
26
|
-
jpeg: /* @__PURE__ */ L(
|
|
27
|
-
gif: /* @__PURE__ */ L(
|
|
28
|
-
webp: /* @__PURE__ */ L(
|
|
29
|
-
php: /* @__PURE__ */ L(
|
|
30
|
-
xml: /* @__PURE__ */ L(
|
|
31
|
-
xls: /* @__PURE__ */ L(
|
|
32
|
-
ppt: /* @__PURE__ */ L(
|
|
33
|
-
odt: /* @__PURE__ */ L(
|
|
34
|
-
exe: /* @__PURE__ */ L(
|
|
35
|
-
mp3: /* @__PURE__ */ L(
|
|
36
|
-
mp4: /* @__PURE__ */ L(
|
|
21
|
+
zip: /* @__PURE__ */ L(v, {}),
|
|
22
|
+
rar: /* @__PURE__ */ L(b, {}),
|
|
23
|
+
svg: /* @__PURE__ */ L(j, {}),
|
|
24
|
+
png: /* @__PURE__ */ L(c, {}),
|
|
25
|
+
jpg: /* @__PURE__ */ L(u, {}),
|
|
26
|
+
jpeg: /* @__PURE__ */ L(x, {}),
|
|
27
|
+
gif: /* @__PURE__ */ L(d, {}),
|
|
28
|
+
webp: /* @__PURE__ */ L(_, {}),
|
|
29
|
+
php: /* @__PURE__ */ L(h, {}),
|
|
30
|
+
xml: /* @__PURE__ */ L(A, {}),
|
|
31
|
+
xls: /* @__PURE__ */ L(T, {}),
|
|
32
|
+
ppt: /* @__PURE__ */ L(e, {}),
|
|
33
|
+
odt: /* @__PURE__ */ L(p, {}),
|
|
34
|
+
exe: /* @__PURE__ */ L(t, {}),
|
|
35
|
+
mp3: /* @__PURE__ */ L(o, {}),
|
|
36
|
+
mp4: /* @__PURE__ */ L(m, {})
|
|
37
37
|
};
|
|
38
38
|
function B(e) {
|
|
39
39
|
let t = e.lastIndexOf(".");
|
|
@@ -44,10 +44,10 @@ function V(e) {
|
|
|
44
44
|
}
|
|
45
45
|
function H(e) {
|
|
46
46
|
let t = B(e);
|
|
47
|
-
return t ? z[t] ?? /* @__PURE__ */ L(
|
|
47
|
+
return t ? z[t] ?? /* @__PURE__ */ L(C, {}) : /* @__PURE__ */ L(g, {});
|
|
48
48
|
}
|
|
49
|
-
function U(e, t,
|
|
50
|
-
return e.icon ? e.icon :
|
|
49
|
+
function U(e, t, r) {
|
|
50
|
+
return e.icon ? e.icon : r ? V(e) ? L(t ? n : a, {}) : H(e.label) : null;
|
|
51
51
|
}
|
|
52
52
|
function te(e) {
|
|
53
53
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
@@ -94,30 +94,30 @@ function re(e, t) {
|
|
|
94
94
|
y: Math.max(8, Math.min(t, window.innerHeight - 16))
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function W({ node: e, color: t, level: n, expandable: r, selectable: i, expandedIds: a, selectedId: o, draggedId: s, dropTargetId: c, onToggle: l, onSelect: u, checkable: d, checkedIds:
|
|
98
|
-
let
|
|
97
|
+
function W({ node: e, color: t, level: n, expandable: r, selectable: i, expandedIds: a, selectedId: o, draggedId: s, dropTargetId: c, onToggle: l, onSelect: u, checkable: d, checkedIds: f, indeterminateIds: p, onCheck: m, indent: h, showLines: g, fileIcons: _, draggable: v, canDropOnNode: y, onContextMenu: b, onDragStart: x, onDragOver: S, onDrop: C, onDragEnd: w }) {
|
|
98
|
+
let T = V(e), E = a.has(e.id), O = o === e.id, k = s === e.id, A = c === e.id, j = y?.(e), N = U(e, E, !!_), ee = f?.has(e.id) ?? !1, F = p?.has(e.id) ?? !1;
|
|
99
99
|
return /* @__PURE__ */ R("li", {
|
|
100
100
|
role: "treeitem",
|
|
101
|
-
"aria-expanded":
|
|
101
|
+
"aria-expanded": T ? E : void 0,
|
|
102
102
|
children: [/* @__PURE__ */ R("div", {
|
|
103
|
-
className: M("item", O && "selected", e.disabled && "disabled", i && !e.disabled && "selectable",
|
|
103
|
+
className: M("item", O && "selected", e.disabled && "disabled", i && !e.disabled && "selectable", v && !e.disabled && "draggable", k && "dragging", j && "can-drop", A && "drop-target"),
|
|
104
104
|
"data-color": t,
|
|
105
|
-
style: { paddingLeft: n *
|
|
106
|
-
draggable:
|
|
105
|
+
style: { paddingLeft: n * h },
|
|
106
|
+
draggable: v && !e.disabled,
|
|
107
107
|
onClick: () => {
|
|
108
|
-
e.disabled || (
|
|
108
|
+
e.disabled || (T && r && l(e.id), i && u?.(e.id, e));
|
|
109
109
|
},
|
|
110
|
-
onContextMenu: (t) =>
|
|
111
|
-
onDragStart: (t) =>
|
|
112
|
-
onDragOver: (t) =>
|
|
113
|
-
onDrop: (t) =>
|
|
114
|
-
onDragEnd:
|
|
110
|
+
onContextMenu: (t) => b?.(t, e),
|
|
111
|
+
onDragStart: (t) => x?.(t, e),
|
|
112
|
+
onDragOver: (t) => S?.(t, e),
|
|
113
|
+
onDrop: (t) => C?.(t, e),
|
|
114
|
+
onDragEnd: w,
|
|
115
115
|
children: [
|
|
116
116
|
/* @__PURE__ */ L("span", {
|
|
117
117
|
className: "toggle",
|
|
118
|
-
children:
|
|
119
|
-
className: M("arrow",
|
|
120
|
-
children: /* @__PURE__ */ L(
|
|
118
|
+
children: T && r ? /* @__PURE__ */ L("span", {
|
|
119
|
+
className: M("arrow", E && "expanded"),
|
|
120
|
+
children: /* @__PURE__ */ L(D, {})
|
|
121
121
|
}) : /* @__PURE__ */ L("span", { className: "spacer" })
|
|
122
122
|
}),
|
|
123
123
|
d && /* @__PURE__ */ L("span", {
|
|
@@ -129,7 +129,7 @@ function W({ node: e, color: t, level: n, expandable: r, selectable: i, expanded
|
|
|
129
129
|
disabled: e.disabled,
|
|
130
130
|
checked: ee,
|
|
131
131
|
indeterminate: F,
|
|
132
|
-
onChange: () =>
|
|
132
|
+
onChange: () => m?.(e.id)
|
|
133
133
|
})
|
|
134
134
|
}),
|
|
135
135
|
N && /* @__PURE__ */ L("span", {
|
|
@@ -141,10 +141,10 @@ function W({ node: e, color: t, level: n, expandable: r, selectable: i, expanded
|
|
|
141
141
|
children: e.label
|
|
142
142
|
})
|
|
143
143
|
]
|
|
144
|
-
}),
|
|
144
|
+
}), T && E && /* @__PURE__ */ L("ul", {
|
|
145
145
|
className: "list",
|
|
146
146
|
role: "group",
|
|
147
|
-
style:
|
|
147
|
+
style: g ? { "--line-left": `${n * h + 17}px` } : void 0,
|
|
148
148
|
children: (e.children ?? []).map((e) => /* @__PURE__ */ L(W, {
|
|
149
149
|
node: e,
|
|
150
150
|
color: t,
|
|
@@ -158,19 +158,19 @@ function W({ node: e, color: t, level: n, expandable: r, selectable: i, expanded
|
|
|
158
158
|
onToggle: l,
|
|
159
159
|
onSelect: u,
|
|
160
160
|
checkable: d,
|
|
161
|
-
checkedIds:
|
|
162
|
-
indeterminateIds:
|
|
163
|
-
onCheck:
|
|
164
|
-
indent:
|
|
165
|
-
showLines:
|
|
166
|
-
fileIcons:
|
|
167
|
-
draggable:
|
|
168
|
-
canDropOnNode:
|
|
169
|
-
onContextMenu:
|
|
170
|
-
onDragStart:
|
|
171
|
-
onDragOver:
|
|
172
|
-
onDrop:
|
|
173
|
-
onDragEnd:
|
|
161
|
+
checkedIds: f,
|
|
162
|
+
indeterminateIds: p,
|
|
163
|
+
onCheck: m,
|
|
164
|
+
indent: h,
|
|
165
|
+
showLines: g,
|
|
166
|
+
fileIcons: _,
|
|
167
|
+
draggable: v,
|
|
168
|
+
canDropOnNode: y,
|
|
169
|
+
onContextMenu: b,
|
|
170
|
+
onDragStart: x,
|
|
171
|
+
onDragOver: S,
|
|
172
|
+
onDrop: C,
|
|
173
|
+
onDragEnd: w
|
|
174
174
|
}, e.id))
|
|
175
175
|
})]
|
|
176
176
|
});
|
|
@@ -312,4 +312,4 @@ function G({ items: e, color: t = "primary", expandable: n = !0, selectable: r =
|
|
|
312
312
|
//#endregion
|
|
313
313
|
export { G as t };
|
|
314
314
|
|
|
315
|
-
//# sourceMappingURL=MTreeView-
|
|
315
|
+
//# sourceMappingURL=MTreeView-B1J7uqd1.js.map
|