@plumile/ui 0.1.68 → 0.1.69
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/lib/esm/admin/organisms/admin_sidebar/AdminSidebar.js +62 -0
- package/lib/esm/admin/organisms/admin_sidebar/AdminSidebar.js.map +1 -0
- package/lib/esm/admin/organisms/admin_sidebar/adminSidebar.css.js +17 -0
- package/lib/esm/admin/organisms/admin_sidebar/adminSidebar.css.js.map +1 -0
- package/lib/esm/{backoffice/organisms/backoffice_topbar/BackofficeTopbar.js → admin/organisms/admin_topbar/AdminTopbar.js} +4 -4
- package/lib/esm/admin/organisms/admin_topbar/AdminTopbar.js.map +1 -0
- package/lib/esm/admin/organisms/admin_topbar/adminTopbar.css.js +8 -0
- package/lib/esm/admin/organisms/admin_topbar/adminTopbar.css.js.map +1 -0
- package/lib/esm/admin/templates/admin_shell_layout/AdminShellLayout.js +19 -0
- package/lib/esm/admin/templates/admin_shell_layout/AdminShellLayout.js.map +1 -0
- package/lib/esm/admin/theme/AdminThemeProvider.js +11 -0
- package/lib/esm/admin/theme/AdminThemeProvider.js.map +1 -0
- package/lib/esm/admin/theme/adminTheme.css.js +7 -0
- package/lib/esm/admin/theme/adminTheme.css.js.map +1 -0
- package/lib/esm/atomic/atoms/badge/Badge.js +3 -3
- package/lib/esm/atomic/atoms/button/Button.js +1 -1
- package/lib/esm/atomic/atoms/checkbox/Checkbox.js +1 -1
- package/lib/esm/atomic/atoms/error_message/ErrorMessage.js +1 -1
- package/lib/esm/atomic/atoms/formatted-date/FormattedDate.js +4 -4
- package/lib/esm/atomic/atoms/label/Label.js +1 -1
- package/lib/esm/atomic/atoms/modal/Modal.js +13 -13
- package/lib/esm/atomic/molecules/breadcrumb_navigation/BreadcrumbMenuDropdown.js +12 -12
- package/lib/esm/atomic/molecules/breadcrumb_navigation/BreadcrumbMenuPopover.js +20 -20
- package/lib/esm/atomic/molecules/breadcrumb_navigation/BreadcrumbNavigation.js +14 -14
- package/lib/esm/atomic/molecules/card/Card.js +6 -6
- package/lib/esm/atomic/molecules/checkbox_field/CheckboxField.js +1 -1
- package/lib/esm/atomic/molecules/dropdown/Dropdown.js +80 -80
- package/lib/esm/atomic/molecules/dropdown/Dropdown.js.map +1 -1
- package/lib/esm/atomic/molecules/form/Form.js +1 -1
- package/lib/esm/atomic/molecules/form_error/FormError.js +1 -1
- package/lib/esm/atomic/molecules/highlight/HighlightCode.js +25 -25
- package/lib/esm/atomic/molecules/markdown/LazyMarkdownRenderer.js +7 -7
- package/lib/esm/atomic/molecules/markdown/MarkdownRenderer.js +33 -33
- package/lib/esm/atomic/molecules/markdown/MarkdownRenderer.js.map +1 -1
- package/lib/esm/atomic/molecules/markdown/components/LazyMarkdownCodeBlock.js +9 -9
- package/lib/esm/atomic/molecules/markdown/components/MarkdownCodeBlock.js +7 -7
- package/lib/esm/atomic/molecules/markdown/components/MarkdownCodeCopyButton.js +9 -9
- package/lib/esm/atomic/molecules/markdown/components/MarkdownFootnotesSection.js +7 -7
- package/lib/esm/atomic/molecules/markdown/components/MarkdownMermaidBlock.js +34 -34
- package/lib/esm/atomic/molecules/markdown/components/MarkdownShikiCodeBlock.js +4 -4
- package/lib/esm/atomic/molecules/profile_dropdown/ProfileDropdown.js +25 -25
- package/lib/esm/atomic/molecules/toast/ToastProvider.js +15 -15
- package/lib/esm/atomic/molecules/toast/ToastViewport.js +15 -15
- package/lib/esm/atomic/organisms/login_form/LoginForm.js +1 -1
- package/lib/esm/atomic/organisms/sidebar/NavigationSidebar.js +34 -34
- package/lib/esm/atomic/organisms/sidebar/icons.js +13 -13
- package/lib/esm/atomic/templates/auth_layout/AuthLayout.js +1 -1
- package/lib/esm/backoffice/atoms/copyable_text/CopyableText.js +10 -10
- package/lib/esm/backoffice/atoms/shortcut_hint/ShortcutHint.js +6 -6
- package/lib/esm/backoffice/atoms/tag/Tag.js +7 -7
- package/lib/esm/backoffice/molecules/backoffice_filter_drawer/BackofficeFilterDrawer.js +22 -22
- package/lib/esm/backoffice/molecules/backoffice_json_viewer/BackofficeJsonViewer.js +12 -12
- package/lib/esm/backoffice/molecules/backoffice_json_viewer/LazyBackofficeJsonViewer.js +11 -11
- package/lib/esm/backoffice/molecules/backoffice_relations_menu/BackofficeRelationsMenu.js +12 -12
- package/lib/esm/backoffice/molecules/confirm_dialog/ConfirmDialog.js +9 -9
- package/lib/esm/backoffice/molecules/global_search_input/GlobalSearchInput.js +5 -5
- package/lib/esm/backoffice/molecules/sidebar_collapse_toggle/SidebarCollapseToggle.js +7 -7
- package/lib/esm/backoffice/molecules/sidebar_nav_item/SidebarNavItem.js +26 -26
- package/lib/esm/backoffice/molecules/sidebar_nav_item/SidebarNavItem.js.map +1 -1
- package/lib/esm/backoffice/molecules/sidebar_nav_section/SidebarNavSection.js +11 -11
- package/lib/esm/backoffice/organisms/backoffice_data_table/BackofficeDataTable.js +20 -20
- package/lib/esm/components/data-table/TableCell.js +17 -17
- package/lib/esm/components/data-table/VirtualizedConnectionTable.js +27 -27
- package/lib/esm/components/layout/AppShell.js +14 -0
- package/lib/esm/components/layout/AppShell.js.map +1 -0
- package/lib/esm/components/layout/PageShell.js +65 -65
- package/lib/esm/components/layout/PageShell.js.map +1 -1
- package/lib/esm/components/layout/SettingsLayout.css.js +8 -0
- package/lib/esm/components/layout/SettingsLayout.css.js.map +1 -0
- package/lib/esm/{backoffice/templates/settings_template/SettingsTemplate.js → components/layout/SettingsLayout.js} +5 -5
- package/lib/esm/components/layout/SettingsLayout.js.map +1 -0
- package/lib/esm/components/layout/SplitViewLayout.css.js +8 -0
- package/lib/esm/components/layout/SplitViewLayout.css.js.map +1 -0
- package/lib/esm/{backoffice/templates/split_view_template/SplitViewTemplate.js → components/layout/SplitViewLayout.js} +5 -5
- package/lib/esm/components/layout/SplitViewLayout.js.map +1 -0
- package/lib/esm/components/select/SimpleSelect.js +23 -23
- package/lib/esm/index.js +105 -104
- package/lib/esm/node_modules/react-shiki/dist/chunk-QPJZGYHO.js +23 -23
- package/lib/esm/node_modules/react-shiki/dist/chunk-QPJZGYHO.js.map +1 -1
- package/lib/esm/style.css +1 -1
- package/lib/esm/theme/ThemeProvider.js +11 -11
- package/lib/esm/theme/VisuallyHidden.js +3 -3
- package/lib/esm/theme/index.js +9 -9
- package/lib/types/{backoffice/organisms/backoffice_sidebar/BackofficeSidebar.d.ts → admin/organisms/admin_sidebar/AdminSidebar.d.ts} +7 -7
- package/lib/types/admin/organisms/admin_sidebar/AdminSidebar.d.ts.map +1 -0
- package/lib/types/{backoffice/organisms/backoffice_sidebar/backofficeSidebar.css.d.ts → admin/organisms/admin_sidebar/adminSidebar.css.d.ts} +1 -1
- package/lib/types/admin/organisms/admin_sidebar/adminSidebar.css.d.ts.map +1 -0
- package/lib/types/admin/organisms/admin_topbar/AdminTopbar.d.ts +10 -0
- package/lib/types/admin/organisms/admin_topbar/AdminTopbar.d.ts.map +1 -0
- package/lib/types/{backoffice/organisms/backoffice_topbar/backofficeTopbar.css.d.ts → admin/organisms/admin_topbar/adminTopbar.css.d.ts} +1 -1
- package/lib/types/admin/organisms/admin_topbar/adminTopbar.css.d.ts.map +1 -0
- package/lib/types/admin/templates/admin_shell_layout/AdminShellLayout.d.ts +14 -0
- package/lib/types/admin/templates/admin_shell_layout/AdminShellLayout.d.ts.map +1 -0
- package/lib/types/admin/theme/AdminThemeProvider.d.ts +7 -0
- package/lib/types/admin/theme/AdminThemeProvider.d.ts.map +1 -0
- package/lib/types/admin/theme/adminTheme.css.d.ts +2 -0
- package/lib/types/admin/theme/adminTheme.css.d.ts.map +1 -0
- package/lib/types/components/layout/AppShell.d.ts +12 -0
- package/lib/types/components/layout/AppShell.d.ts.map +1 -0
- package/lib/types/{backoffice/templates/settings_template/settingsTemplate.css.d.ts → components/layout/SettingsLayout.css.d.ts} +1 -1
- package/lib/types/components/layout/SettingsLayout.css.d.ts.map +1 -0
- package/lib/types/components/layout/SettingsLayout.d.ts +11 -0
- package/lib/types/components/layout/SettingsLayout.d.ts.map +1 -0
- package/lib/types/{backoffice/templates/split_view_template/splitViewTemplate.css.d.ts → components/layout/SplitViewLayout.css.d.ts} +1 -1
- package/lib/types/components/layout/SplitViewLayout.css.d.ts.map +1 -0
- package/lib/types/components/layout/SplitViewLayout.d.ts +11 -0
- package/lib/types/components/layout/SplitViewLayout.d.ts.map +1 -0
- package/lib/types/index.d.ts +9 -8
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +10 -10
- package/lib/esm/backoffice/organisms/backoffice_app_shell/BackofficeAppShell.js +0 -14
- package/lib/esm/backoffice/organisms/backoffice_app_shell/BackofficeAppShell.js.map +0 -1
- package/lib/esm/backoffice/organisms/backoffice_sidebar/BackofficeSidebar.js +0 -62
- package/lib/esm/backoffice/organisms/backoffice_sidebar/BackofficeSidebar.js.map +0 -1
- package/lib/esm/backoffice/organisms/backoffice_sidebar/backofficeSidebar.css.js +0 -17
- package/lib/esm/backoffice/organisms/backoffice_sidebar/backofficeSidebar.css.js.map +0 -1
- package/lib/esm/backoffice/organisms/backoffice_topbar/BackofficeTopbar.js.map +0 -1
- package/lib/esm/backoffice/organisms/backoffice_topbar/backofficeTopbar.css.js +0 -8
- package/lib/esm/backoffice/organisms/backoffice_topbar/backofficeTopbar.css.js.map +0 -1
- package/lib/esm/backoffice/templates/backoffice_shell_template/BackofficeShellTemplate.js +0 -19
- package/lib/esm/backoffice/templates/backoffice_shell_template/BackofficeShellTemplate.js.map +0 -1
- package/lib/esm/backoffice/templates/settings_template/SettingsTemplate.js.map +0 -1
- package/lib/esm/backoffice/templates/settings_template/settingsTemplate.css.js +0 -8
- package/lib/esm/backoffice/templates/settings_template/settingsTemplate.css.js.map +0 -1
- package/lib/esm/backoffice/templates/split_view_template/SplitViewTemplate.js.map +0 -1
- package/lib/esm/backoffice/templates/split_view_template/splitViewTemplate.css.js +0 -8
- package/lib/esm/backoffice/templates/split_view_template/splitViewTemplate.css.js.map +0 -1
- package/lib/esm/backoffice/theme/BackofficeThemeProvider.js +0 -11
- package/lib/esm/backoffice/theme/BackofficeThemeProvider.js.map +0 -1
- package/lib/esm/backoffice/theme/backofficeTheme.css.js +0 -7
- package/lib/esm/backoffice/theme/backofficeTheme.css.js.map +0 -1
- package/lib/types/backoffice/organisms/backoffice_app_shell/BackofficeAppShell.d.ts +0 -12
- package/lib/types/backoffice/organisms/backoffice_app_shell/BackofficeAppShell.d.ts.map +0 -1
- package/lib/types/backoffice/organisms/backoffice_sidebar/BackofficeSidebar.d.ts.map +0 -1
- package/lib/types/backoffice/organisms/backoffice_sidebar/backofficeSidebar.css.d.ts.map +0 -1
- package/lib/types/backoffice/organisms/backoffice_topbar/BackofficeTopbar.d.ts +0 -10
- package/lib/types/backoffice/organisms/backoffice_topbar/BackofficeTopbar.d.ts.map +0 -1
- package/lib/types/backoffice/organisms/backoffice_topbar/backofficeTopbar.css.d.ts.map +0 -1
- package/lib/types/backoffice/templates/backoffice_shell_template/BackofficeShellTemplate.d.ts +0 -14
- package/lib/types/backoffice/templates/backoffice_shell_template/BackofficeShellTemplate.d.ts.map +0 -1
- package/lib/types/backoffice/templates/settings_template/SettingsTemplate.d.ts +0 -11
- package/lib/types/backoffice/templates/settings_template/SettingsTemplate.d.ts.map +0 -1
- package/lib/types/backoffice/templates/settings_template/settingsTemplate.css.d.ts.map +0 -1
- package/lib/types/backoffice/templates/split_view_template/SplitViewTemplate.d.ts +0 -11
- package/lib/types/backoffice/templates/split_view_template/SplitViewTemplate.d.ts.map +0 -1
- package/lib/types/backoffice/templates/split_view_template/splitViewTemplate.css.d.ts.map +0 -1
- package/lib/types/backoffice/theme/BackofficeThemeProvider.d.ts +0 -7
- package/lib/types/backoffice/theme/BackofficeThemeProvider.d.ts.map +0 -1
- package/lib/types/backoffice/theme/backofficeTheme.css.d.ts +0 -2
- package/lib/types/backoffice/theme/backofficeTheme.css.d.ts.map +0 -1
|
@@ -1,149 +1,149 @@
|
|
|
1
1
|
import { cx as e } from "../../../theme/tools.js";
|
|
2
2
|
import { container as t, content as n, contentPositioned as r } from "./dropdown.css.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createPortal as
|
|
3
|
+
import { cloneElement as i, createContext as a, isValidElement as o, useCallback as s, useContext as c, useEffect as l, useLayoutEffect as u, useRef as d, useState as f } from "react";
|
|
4
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as ee } from "react-dom";
|
|
6
6
|
//#region src/atomic/molecules/dropdown/Dropdown.tsx
|
|
7
|
-
var
|
|
8
|
-
let e =
|
|
7
|
+
var h = a(null), g = () => {
|
|
8
|
+
let e = c(h);
|
|
9
9
|
if (e == null) throw Error("useDropdown must be used within a <Dropdown />");
|
|
10
10
|
return e;
|
|
11
|
-
},
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
}, [
|
|
17
|
-
|
|
18
|
-
}, [
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
let e =
|
|
11
|
+
}, _ = (e) => typeof e != "object" || !e ? !1 : e.$$typeof === Symbol.for("react.forward_ref"), v = ({ trigger: a, children: c, className: g, contentClassName: v, placement: y = "bottom-start", offset: b = 4, matchTriggerWidth: x = !0, open: S, defaultOpen: C = !1, onOpenChange: w, closeOnItemClick: T = !1, portalContainer: E, ariaLabel: D }) => {
|
|
12
|
+
let O = S != null, [k, A] = f(C), j = k;
|
|
13
|
+
O && (j = !!S);
|
|
14
|
+
let M = d(null), N = d(null), P = d(null), [F, I] = f(null), L = d([]), R = s((e) => {
|
|
15
|
+
O || A(e), w?.(e);
|
|
16
|
+
}, [O, w]), z = s(() => {
|
|
17
|
+
R(!j);
|
|
18
|
+
}, [j, R]), B = s(() => {
|
|
19
|
+
R(!1);
|
|
20
|
+
}, [R]), V = s(() => {
|
|
21
|
+
R(!0);
|
|
22
|
+
}, [R]), H = s(() => {
|
|
23
|
+
let e = N.current, t = P.current;
|
|
24
24
|
if (e == null || t == null) return;
|
|
25
25
|
let n = e.getBoundingClientRect(), r = 0, i = 0;
|
|
26
|
-
switch (
|
|
26
|
+
switch (y) {
|
|
27
27
|
case "bottom-start":
|
|
28
|
-
r = n.bottom +
|
|
28
|
+
r = n.bottom + b, i = n.left;
|
|
29
29
|
break;
|
|
30
30
|
case "bottom-end":
|
|
31
|
-
r = n.bottom +
|
|
31
|
+
r = n.bottom + b, i = n.right - t.offsetWidth;
|
|
32
32
|
break;
|
|
33
33
|
case "top-start":
|
|
34
|
-
r = n.top - t.offsetHeight -
|
|
34
|
+
r = n.top - t.offsetHeight - b, i = n.left;
|
|
35
35
|
break;
|
|
36
36
|
case "top-end":
|
|
37
|
-
r = n.top - t.offsetHeight -
|
|
37
|
+
r = n.top - t.offsetHeight - b, i = n.right - t.offsetWidth;
|
|
38
38
|
break;
|
|
39
|
-
default: r = n.bottom +
|
|
39
|
+
default: r = n.bottom + b, i = n.left;
|
|
40
40
|
}
|
|
41
41
|
let a = window.innerWidth, o = window.innerHeight, s;
|
|
42
|
-
|
|
42
|
+
x && (s = n.width);
|
|
43
43
|
let c = s ?? t.offsetWidth;
|
|
44
44
|
i + c > a - 4 && (i = Math.max(4, a - c - 4)), i < 4 && (i = 4);
|
|
45
45
|
let l = t.offsetHeight;
|
|
46
|
-
if (r + l > o - 4) if (
|
|
47
|
-
let e = n.top - l -
|
|
46
|
+
if (r + l > o - 4) if (y.startsWith("bottom")) {
|
|
47
|
+
let e = n.top - l - b;
|
|
48
48
|
r = e >= 4 ? e : Math.max(4, o - l - 4);
|
|
49
49
|
} else r = Math.max(4, o - l - 4);
|
|
50
|
-
r < 4 && (r = 4),
|
|
50
|
+
r < 4 && (r = 4), I({
|
|
51
51
|
top: r,
|
|
52
52
|
left: i,
|
|
53
53
|
width: s
|
|
54
54
|
});
|
|
55
55
|
}, [
|
|
56
|
+
y,
|
|
56
57
|
b,
|
|
57
|
-
x
|
|
58
|
-
S
|
|
58
|
+
x
|
|
59
59
|
]);
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
u(() => {
|
|
61
|
+
j && H();
|
|
62
62
|
}, [
|
|
63
|
-
|
|
63
|
+
j,
|
|
64
64
|
H,
|
|
65
|
-
|
|
66
|
-
]),
|
|
67
|
-
if (!
|
|
65
|
+
c
|
|
66
|
+
]), l(() => {
|
|
67
|
+
if (!j) return;
|
|
68
68
|
let e = () => {
|
|
69
69
|
H();
|
|
70
70
|
};
|
|
71
|
-
window.addEventListener("resize", e), window.addEventListener("scroll", e, !0),
|
|
71
|
+
window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), L.current.push(() => {
|
|
72
72
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
73
73
|
});
|
|
74
|
-
}, [
|
|
75
|
-
if (!
|
|
74
|
+
}, [j, H]), l(() => {
|
|
75
|
+
if (!j) return;
|
|
76
76
|
let e = (e) => {
|
|
77
77
|
let t = e.target;
|
|
78
|
-
|
|
78
|
+
M.current != null && P.current != null && !M.current.contains(t) && !P.current.contains(t) && B();
|
|
79
79
|
}, t = (e) => {
|
|
80
|
-
e.key === "Escape" && (
|
|
80
|
+
e.key === "Escape" && (B(), N.current?.focus());
|
|
81
81
|
};
|
|
82
|
-
document.addEventListener("mousedown", e), document.addEventListener("keydown", t),
|
|
82
|
+
document.addEventListener("mousedown", e), document.addEventListener("keydown", t), L.current.push(() => {
|
|
83
83
|
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
84
84
|
});
|
|
85
|
-
}, [
|
|
86
|
-
|
|
87
|
-
}, [
|
|
88
|
-
if (!
|
|
85
|
+
}, [j, B]), l(() => {
|
|
86
|
+
j && (P.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])"))?.focus();
|
|
87
|
+
}, [j]), l(() => {
|
|
88
|
+
if (!j || !T) return;
|
|
89
89
|
let e = (e) => {
|
|
90
|
-
|
|
90
|
+
P.current?.contains(e.target) && B();
|
|
91
91
|
};
|
|
92
|
-
document.addEventListener("click", e, { capture: !0 }),
|
|
92
|
+
document.addEventListener("click", e, { capture: !0 }), L.current.push(() => {
|
|
93
93
|
document.removeEventListener("click", e, { capture: !0 });
|
|
94
94
|
});
|
|
95
95
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
]),
|
|
100
|
-
|
|
96
|
+
j,
|
|
97
|
+
T,
|
|
98
|
+
B
|
|
99
|
+
]), l(() => () => {
|
|
100
|
+
L.current.forEach((e) => {
|
|
101
101
|
e();
|
|
102
|
-
}),
|
|
102
|
+
}), L.current = [];
|
|
103
103
|
}, []);
|
|
104
|
-
let U =
|
|
105
|
-
if (typeof
|
|
104
|
+
let U = a;
|
|
105
|
+
if (typeof a == "function" && (U = a(j)), !o(U)) throw Error("Dropdown trigger must be a React element.");
|
|
106
106
|
let W = typeof U.type == "string", G = W && U.type === "button";
|
|
107
|
-
if (!(W || typeof U.type == "function" ||
|
|
107
|
+
if (!(W || typeof U.type == "function" || _(U.type))) throw Error("Dropdown trigger must be a DOM element or component that accepts a ref.");
|
|
108
108
|
let K = U.props.ref ?? U.ref, q = (e) => {
|
|
109
|
-
|
|
109
|
+
N.current = e, typeof K == "function" ? K(e) : K != null && (K.current = e);
|
|
110
110
|
}, J = U.props, Y = (e) => {
|
|
111
|
-
J.onClick?.(e), !e.defaultPrevented &&
|
|
111
|
+
J.onClick?.(e), !e.defaultPrevented && z();
|
|
112
112
|
}, X = (e) => {
|
|
113
|
-
J.onKeyDown?.(e), !e.defaultPrevented && (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
113
|
+
J.onKeyDown?.(e), !e.defaultPrevented && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), z());
|
|
114
114
|
}, Z = {
|
|
115
115
|
onClick: Y,
|
|
116
116
|
"aria-haspopup": "menu",
|
|
117
|
-
"aria-expanded":
|
|
117
|
+
"aria-expanded": j
|
|
118
118
|
};
|
|
119
|
-
|
|
119
|
+
D != null && D !== "" && (Z["aria-label"] = D), G ? J.type ?? (Z.type = "button") : (Z.onKeyDown = X, J.role ?? (Z.role = "button"), J.tabIndex ?? (Z.tabIndex = 0)), Z.ref = q;
|
|
120
120
|
let Q = {};
|
|
121
|
-
|
|
122
|
-
top:
|
|
123
|
-
left:
|
|
124
|
-
width:
|
|
121
|
+
F != null && (Q = {
|
|
122
|
+
top: F.top,
|
|
123
|
+
left: F.left,
|
|
124
|
+
width: F.width
|
|
125
125
|
});
|
|
126
|
-
let te =
|
|
127
|
-
close:
|
|
128
|
-
open:
|
|
129
|
-
isOpen:
|
|
126
|
+
let te = E ?? document.body, ne = {
|
|
127
|
+
close: B,
|
|
128
|
+
open: V,
|
|
129
|
+
isOpen: j
|
|
130
130
|
}, $ = null;
|
|
131
|
-
return
|
|
132
|
-
ref:
|
|
131
|
+
return j && ($ = ee(/* @__PURE__ */ p("div", {
|
|
132
|
+
ref: P,
|
|
133
133
|
role: "menu",
|
|
134
|
-
className: e(n, r,
|
|
134
|
+
className: e(n, r, v),
|
|
135
135
|
style: Q,
|
|
136
|
-
children:
|
|
137
|
-
}), te)), /* @__PURE__ */
|
|
136
|
+
children: c
|
|
137
|
+
}), te)), /* @__PURE__ */ m(h.Provider, {
|
|
138
138
|
value: ne,
|
|
139
|
-
children: [/* @__PURE__ */
|
|
140
|
-
className: e(t,
|
|
141
|
-
ref:
|
|
142
|
-
children:
|
|
139
|
+
children: [/* @__PURE__ */ p("div", {
|
|
140
|
+
className: e(t, g),
|
|
141
|
+
ref: M,
|
|
142
|
+
children: i(U, Z)
|
|
143
143
|
}), $]
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
146
|
//#endregion
|
|
147
|
-
export {
|
|
147
|
+
export { v as Dropdown, g as useDropdown };
|
|
148
148
|
|
|
149
149
|
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../../../../src/atomic/molecules/dropdown/Dropdown.tsx"],"sourcesContent":["import {\n useState,\n useRef,\n useEffect,\n useLayoutEffect,\n useCallback,\n type ReactNode,\n type ReactElement,\n type JSX,\n type Ref,\n type MutableRefObject,\n type HTMLAttributes,\n type MouseEvent as ReactMouseEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n createContext,\n useContext,\n isValidElement,\n cloneElement,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport * as classes from './dropdown.css.js';\nimport { cx } from '../../../theme/tools.js';\n\n// Types\nexport type DropdownPlacement =\n | 'bottom-start'\n | 'bottom-end'\n | 'top-start'\n | 'top-end';\n\ninterface DropdownContextValue {\n close: () => void;\n open: () => void;\n isOpen: boolean;\n}\n\nconst DropdownContext = createContext<DropdownContextValue | null>(null);\n/**\n * Access the nearest Dropdown context. Throws if used outside a <Dropdown />.\n */\nexport const useDropdown = (): DropdownContextValue => {\n const ctx = useContext(DropdownContext);\n if (ctx == null) {\n throw new Error('useDropdown must be used within a <Dropdown />');\n }\n return ctx;\n};\n\nexport interface DropdownProps {\n trigger: ReactElement | ((isOpen: boolean) => ReactElement);\n children: ReactNode;\n className?: string;\n contentClassName?: string;\n placement?: DropdownPlacement;\n offset?: number;\n matchTriggerWidth?: boolean;\n open?: boolean; // controlled\n defaultOpen?: boolean; // uncontrolled\n onOpenChange?: (open: boolean) => void;\n closeOnItemClick?: boolean;\n portalContainer?: HTMLElement | null;\n // Accessible label if trigger is an icon only\n ariaLabel?: string;\n}\n\ninterface PositionState {\n top: number;\n left: number;\n width?: number;\n}\n\nconst isForwardRefComponent = (type: unknown): boolean => {\n if (type == null || typeof type !== 'object') {\n return false;\n }\n return (\n (type as { $$typeof?: symbol }).$$typeof === Symbol.for('react.forward_ref')\n );\n};\n\n/**\n * A scalable, portal-based dropdown component with basic collision handling,\n * controlled/uncontrolled modes, accessibility attributes, and optional\n * trigger width matching. Content is rendered in a React portal (default: document.body).\n */\nexport const Dropdown = ({\n trigger,\n children,\n className,\n contentClassName,\n placement = 'bottom-start',\n offset = 4,\n matchTriggerWidth = true,\n open,\n defaultOpen = false,\n onOpenChange,\n closeOnItemClick = false,\n portalContainer,\n ariaLabel,\n}: DropdownProps): JSX.Element => {\n const isControlled = open != null;\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n let isOpen = uncontrolledOpen;\n if (isControlled) {\n isOpen = Boolean(open);\n }\n\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<PositionState | null>(null);\n // Accumulate manual cleanups for effects where returning a function violates lint rules.\n const cleanupRef = useRef<(() => void)[]>([]);\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!isOpen);\n }, [isOpen, setOpen]);\n const close = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n const openFn = useCallback(() => {\n setOpen(true);\n }, [setOpen]);\n\n // Positioning logic\n const computePosition = useCallback(() => {\n const triggerEl = triggerRef.current;\n const contentEl = contentRef.current;\n if (triggerEl == null) {\n return;\n }\n if (contentEl == null) {\n return;\n }\n\n const rect = triggerEl.getBoundingClientRect();\n let top = 0;\n let left = 0;\n\n switch (placement) {\n case 'bottom-start':\n top = rect.bottom + offset;\n left = rect.left;\n break;\n case 'bottom-end':\n top = rect.bottom + offset;\n left = rect.right - contentEl.offsetWidth;\n break;\n case 'top-start':\n top = rect.top - contentEl.offsetHeight - offset;\n left = rect.left;\n break;\n case 'top-end':\n top = rect.top - contentEl.offsetHeight - offset;\n left = rect.right - contentEl.offsetWidth;\n break;\n default:\n top = rect.bottom + offset;\n left = rect.left;\n }\n\n // Keep within viewport (basic collision handling)\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n let width: number | undefined;\n if (matchTriggerWidth) {\n width = rect.width;\n }\n const contentWidth = width ?? contentEl.offsetWidth;\n\n if (left + contentWidth > vw - 4) {\n left = Math.max(4, vw - contentWidth - 4);\n }\n if (left < 4) left = 4;\n const contentHeight = contentEl.offsetHeight;\n if (top + contentHeight > vh - 4) {\n // Try flip to top if bottom overflows and initial was bottom\n if (placement.startsWith('bottom')) {\n const flippedTop = rect.top - contentHeight - offset;\n if (flippedTop >= 4) {\n top = flippedTop;\n } else {\n top = Math.max(4, vh - contentHeight - 4);\n }\n } else {\n top = Math.max(4, vh - contentHeight - 4);\n }\n }\n if (top < 4) top = 4;\n\n setPosition({ top, left, width });\n }, [placement, offset, matchTriggerWidth]);\n\n useLayoutEffect(() => {\n if (isOpen) computePosition();\n }, [isOpen, computePosition, children]);\n\n useEffect(() => {\n if (!isOpen) return;\n const handle = () => {\n computePosition();\n };\n window.addEventListener('resize', handle);\n window.addEventListener('scroll', handle, true);\n const cleanup = () => {\n window.removeEventListener('resize', handle);\n window.removeEventListener('scroll', handle, true);\n };\n cleanupRef.current.push(cleanup);\n }, [isOpen, computePosition]);\n\n // Outside click & Escape\n useEffect(() => {\n if (!isOpen) return;\n const onDocMouseDown = (e: globalThis.MouseEvent) => {\n const target = e.target as Node;\n if (\n containerRef.current != null &&\n contentRef.current != null &&\n !containerRef.current.contains(target) &&\n !contentRef.current.contains(target)\n ) {\n close();\n }\n };\n const onKey = (e: globalThis.KeyboardEvent) => {\n if (e.key === 'Escape') {\n close();\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('mousedown', onDocMouseDown);\n document.addEventListener('keydown', onKey);\n const cleanup = () => {\n document.removeEventListener('mousedown', onDocMouseDown);\n document.removeEventListener('keydown', onKey);\n };\n cleanupRef.current.push(cleanup);\n }, [isOpen, close]);\n\n // Keyboard navigation basic (ArrowDown focuses first focusable)\n useEffect(() => {\n if (!isOpen) return;\n const firstFocusable = contentRef.current?.querySelector<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n firstFocusable?.focus();\n }, [isOpen]);\n\n // Close on item click if enabled\n useEffect(() => {\n if (!isOpen || !closeOnItemClick) return;\n const handler = (e: globalThis.MouseEvent) => {\n if (contentRef.current?.contains(e.target as Node)) {\n close();\n }\n };\n document.addEventListener('click', handler, { capture: true });\n // Explicit cleanup without returning (lint rule forbids returning arrow fn)\n const cleanup = () => {\n document.removeEventListener('click', handler, { capture: true });\n };\n // Store in ref to run on unmount / dependency change\n cleanupRef.current.push(cleanup);\n }, [isOpen, closeOnItemClick, close]);\n // Run accumulated cleanups on unmount\n useEffect(() => {\n return () => {\n cleanupRef.current.forEach((fn) => {\n fn();\n });\n cleanupRef.current = [];\n };\n }, []);\n\n let triggerElement = trigger;\n if (typeof trigger === 'function') {\n triggerElement = trigger(isOpen);\n }\n\n if (!isValidElement(triggerElement)) {\n throw new Error('Dropdown trigger must be a React element.');\n }\n\n const isHostElement = typeof triggerElement.type === 'string';\n const isButtonElement = isHostElement && triggerElement.type === 'button';\n const canAttachRef =\n isHostElement ||\n typeof triggerElement.type === 'function' ||\n isForwardRefComponent(triggerElement.type);\n\n if (!canAttachRef) {\n throw new Error(\n 'Dropdown trigger must be a DOM element or component that accepts a ref.',\n );\n }\n\n const triggerElementRef =\n (triggerElement.props as { ref?: Ref<HTMLElement> }).ref ??\n (triggerElement as ReactElement & { ref?: Ref<HTMLElement> }).ref;\n const setTriggerRef = (node: HTMLElement | null) => {\n triggerRef.current = node;\n if (typeof triggerElementRef === 'function') {\n triggerElementRef(node);\n } else if (triggerElementRef != null) {\n (triggerElementRef as MutableRefObject<HTMLElement | null>).current =\n node;\n }\n };\n\n const triggerProps = triggerElement.props as HTMLAttributes<HTMLElement> & {\n type?: string;\n };\n\n const handleTriggerClick = (event: ReactMouseEvent<HTMLElement>) => {\n triggerProps.onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n toggle();\n };\n\n const handleTriggerKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n triggerProps.onKeyDown?.(event);\n if (event.defaultPrevented) {\n return;\n }\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n toggle();\n }\n };\n\n const mergedTriggerProps: Record<string, unknown> = {\n onClick: handleTriggerClick,\n 'aria-haspopup': 'menu',\n 'aria-expanded': isOpen,\n };\n\n if (ariaLabel != null && ariaLabel !== '') {\n mergedTriggerProps['aria-label'] = ariaLabel;\n }\n\n if (isButtonElement) {\n if (triggerProps.type == null) {\n mergedTriggerProps.type = 'button';\n }\n } else {\n mergedTriggerProps.onKeyDown = handleTriggerKeyDown;\n if (triggerProps.role == null) {\n mergedTriggerProps.role = 'button';\n }\n if (triggerProps.tabIndex == null) {\n mergedTriggerProps.tabIndex = 0;\n }\n }\n\n mergedTriggerProps.ref = setTriggerRef;\n\n let contentStyles: React.CSSProperties = {};\n if (position != null) {\n contentStyles = {\n top: position.top,\n left: position.left,\n width: position.width,\n };\n }\n\n const portalTarget = portalContainer ?? document.body;\n\n const contextValue: DropdownContextValue = {\n close,\n open: openFn,\n isOpen,\n };\n\n let dropdownContent: JSX.Element | null = null;\n if (isOpen) {\n dropdownContent = createPortal(\n <div\n ref={contentRef}\n role=\"menu\"\n className={cx(\n classes.content,\n classes.contentPositioned,\n contentClassName,\n )}\n style={contentStyles}\n >\n {children}\n </div>,\n portalTarget,\n );\n }\n\n return (\n <DropdownContext.Provider value={contextValue}>\n <div className={cx(classes.container, className)} ref={containerRef}>\n {cloneElement(triggerElement, mergedTriggerProps)}\n </div>\n {dropdownContent}\n </DropdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAqCA,IAAM,IAAkB,EAA2C,KAAK,EAI3D,UAA0C;CACrD,IAAM,IAAM,EAAW,EAAgB;AACvC,KAAI,KAAO,KACT,OAAU,MAAM,iDAAiD;AAEnE,QAAO;GA0BH,KAAyB,MACT,OAAO,KAAS,aAAhC,IACK,KAGN,EAA+B,aAAa,OAAO,IAAI,oBAAoB,EASnE,KAAY,EACvB,YACA,aACA,cACA,qBACA,eAAY,gBACZ,YAAS,GACT,uBAAoB,IACpB,SACA,iBAAc,IACd,iBACA,s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AAY,EAAM,EAC3B,GAAM,qBAGN,EAAM,QAAQ,WAAW,EAAM,QAAQ,SACzC,EAAM,gBAAgB,EACtB,GAAQ;IAIN,IAA8C;EAClD,SAAS;EACT,iBAAiB;EACjB,iBAAiB;EAClB;AAoBD,CAlBI,KAAa,QAAQ,MAAc,OACrC,EAAmB,gBAAgB,IAGjC,IACE,EAAa,SACf,EAAmB,OAAO,aAG5B,EAAmB,YAAY,GAC3B,EAAa,SACf,EAAmB,OAAO,WAExB,EAAa,aACf,EAAmB,WAAW,KAIlC,EAAmB,MAAM;CAEzB,IAAI,IAAqC,EAAE;AAC3C,CAAI,KAAY,SACd,IAAgB;EACd,KAAK,EAAS;EACd,MAAM,EAAS;EACf,OAAO,EAAS;EACjB;CAGH,IAAM,KAAe,KAAmB,SAAS,MAE3C,KAAqC;EACzC;EACA,MAAM;EACN;EACD,EAEG,IAAsC;AAmB1C,QAlBI,MACF,IAAkB,EAChB,kBAAC,OAAD;EACE,KAAK;EACL,MAAK;EACL,WAAW,EACT,GACA,GACA,EACD;EACD,OAAO;EAEN;EACG,CAAA,EACN,GACD,GAID,kBAAC,EAAgB,UAAjB;EAA0B,OAAO;YAAjC,CACE,kBAAC,OAAD;GAAK,WAAW,EAAG,GAAmB,EAAU;GAAE,KAAK;aACpD,EAAa,GAAgB,EAAmB;GAC7C,CAAA,EACL,EACwB"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../../../../src/atomic/molecules/dropdown/Dropdown.tsx"],"sourcesContent":["import {\n useState,\n useRef,\n useEffect,\n useLayoutEffect,\n useCallback,\n type ReactNode,\n type ReactElement,\n type JSX,\n type Ref,\n type MutableRefObject,\n type HTMLAttributes,\n type MouseEvent as ReactMouseEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n createContext,\n useContext,\n isValidElement,\n cloneElement,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport * as classes from './dropdown.css.js';\nimport { cx } from '../../../theme/tools.js';\n\n// Types\nexport type DropdownPlacement =\n | 'bottom-start'\n | 'bottom-end'\n | 'top-start'\n | 'top-end';\n\ninterface DropdownContextValue {\n close: () => void;\n open: () => void;\n isOpen: boolean;\n}\n\nconst DropdownContext = createContext<DropdownContextValue | null>(null);\n/**\n * Access the nearest Dropdown context. Throws if used outside a <Dropdown />.\n */\nexport const useDropdown = (): DropdownContextValue => {\n const ctx = useContext(DropdownContext);\n if (ctx == null) {\n throw new Error('useDropdown must be used within a <Dropdown />');\n }\n return ctx;\n};\n\nexport interface DropdownProps {\n trigger: ReactElement | ((isOpen: boolean) => ReactElement);\n children: ReactNode;\n className?: string;\n contentClassName?: string;\n placement?: DropdownPlacement;\n offset?: number;\n matchTriggerWidth?: boolean;\n open?: boolean; // controlled\n defaultOpen?: boolean; // uncontrolled\n onOpenChange?: (open: boolean) => void;\n closeOnItemClick?: boolean;\n portalContainer?: HTMLElement | null;\n // Accessible label if trigger is an icon only\n ariaLabel?: string;\n}\n\ninterface PositionState {\n top: number;\n left: number;\n width?: number;\n}\n\nconst isForwardRefComponent = (type: unknown): boolean => {\n if (type == null || typeof type !== 'object') {\n return false;\n }\n return (\n (type as { $$typeof?: symbol }).$$typeof === Symbol.for('react.forward_ref')\n );\n};\n\n/**\n * A scalable, portal-based dropdown component with basic collision handling,\n * controlled/uncontrolled modes, accessibility attributes, and optional\n * trigger width matching. Content is rendered in a React portal (default: document.body).\n */\nexport const Dropdown = ({\n trigger,\n children,\n className,\n contentClassName,\n placement = 'bottom-start',\n offset = 4,\n matchTriggerWidth = true,\n open,\n defaultOpen = false,\n onOpenChange,\n closeOnItemClick = false,\n portalContainer,\n ariaLabel,\n}: DropdownProps): JSX.Element => {\n const isControlled = open != null;\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n let isOpen = uncontrolledOpen;\n if (isControlled) {\n isOpen = Boolean(open);\n }\n\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<PositionState | null>(null);\n // Accumulate manual cleanups for effects where returning a function violates lint rules.\n const cleanupRef = useRef<(() => void)[]>([]);\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!isOpen);\n }, [isOpen, setOpen]);\n const close = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n const openFn = useCallback(() => {\n setOpen(true);\n }, [setOpen]);\n\n // Positioning logic\n const computePosition = useCallback(() => {\n const triggerEl = triggerRef.current;\n const contentEl = contentRef.current;\n if (triggerEl == null) {\n return;\n }\n if (contentEl == null) {\n return;\n }\n\n const rect = triggerEl.getBoundingClientRect();\n let top = 0;\n let left = 0;\n\n switch (placement) {\n case 'bottom-start':\n top = rect.bottom + offset;\n left = rect.left;\n break;\n case 'bottom-end':\n top = rect.bottom + offset;\n left = rect.right - contentEl.offsetWidth;\n break;\n case 'top-start':\n top = rect.top - contentEl.offsetHeight - offset;\n left = rect.left;\n break;\n case 'top-end':\n top = rect.top - contentEl.offsetHeight - offset;\n left = rect.right - contentEl.offsetWidth;\n break;\n default:\n top = rect.bottom + offset;\n left = rect.left;\n }\n\n // Keep within viewport (basic collision handling)\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n let width: number | undefined;\n if (matchTriggerWidth) {\n width = rect.width;\n }\n const contentWidth = width ?? contentEl.offsetWidth;\n\n if (left + contentWidth > vw - 4) {\n left = Math.max(4, vw - contentWidth - 4);\n }\n if (left < 4) left = 4;\n const contentHeight = contentEl.offsetHeight;\n if (top + contentHeight > vh - 4) {\n // Try flip to top if bottom overflows and initial was bottom\n if (placement.startsWith('bottom')) {\n const flippedTop = rect.top - contentHeight - offset;\n if (flippedTop >= 4) {\n top = flippedTop;\n } else {\n top = Math.max(4, vh - contentHeight - 4);\n }\n } else {\n top = Math.max(4, vh - contentHeight - 4);\n }\n }\n if (top < 4) top = 4;\n\n setPosition({ top, left, width });\n }, [placement, offset, matchTriggerWidth]);\n\n useLayoutEffect(() => {\n if (isOpen) computePosition();\n }, [isOpen, computePosition, children]);\n\n useEffect(() => {\n if (!isOpen) return;\n const handle = () => {\n computePosition();\n };\n window.addEventListener('resize', handle);\n window.addEventListener('scroll', handle, true);\n const cleanup = () => {\n window.removeEventListener('resize', handle);\n window.removeEventListener('scroll', handle, true);\n };\n cleanupRef.current.push(cleanup);\n }, [isOpen, computePosition]);\n\n // Outside click & Escape\n useEffect(() => {\n if (!isOpen) return;\n const onDocMouseDown = (e: globalThis.MouseEvent) => {\n const target = e.target as Node;\n if (\n containerRef.current != null &&\n contentRef.current != null &&\n !containerRef.current.contains(target) &&\n !contentRef.current.contains(target)\n ) {\n close();\n }\n };\n const onKey = (e: globalThis.KeyboardEvent) => {\n if (e.key === 'Escape') {\n close();\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('mousedown', onDocMouseDown);\n document.addEventListener('keydown', onKey);\n const cleanup = () => {\n document.removeEventListener('mousedown', onDocMouseDown);\n document.removeEventListener('keydown', onKey);\n };\n cleanupRef.current.push(cleanup);\n }, [isOpen, close]);\n\n // Keyboard navigation basic (ArrowDown focuses first focusable)\n useEffect(() => {\n if (!isOpen) return;\n const firstFocusable = contentRef.current?.querySelector<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n firstFocusable?.focus();\n }, [isOpen]);\n\n // Close on item click if enabled\n useEffect(() => {\n if (!isOpen || !closeOnItemClick) return;\n const handler = (e: globalThis.MouseEvent) => {\n if (contentRef.current?.contains(e.target as Node)) {\n close();\n }\n };\n document.addEventListener('click', handler, { capture: true });\n // Explicit cleanup without returning (lint rule forbids returning arrow fn)\n const cleanup = () => {\n document.removeEventListener('click', handler, { capture: true });\n };\n // Store in ref to run on unmount / dependency change\n cleanupRef.current.push(cleanup);\n }, [isOpen, closeOnItemClick, close]);\n // Run accumulated cleanups on unmount\n useEffect(() => {\n return () => {\n cleanupRef.current.forEach((fn) => {\n fn();\n });\n cleanupRef.current = [];\n };\n }, []);\n\n let triggerElement = trigger;\n if (typeof trigger === 'function') {\n triggerElement = trigger(isOpen);\n }\n\n if (!isValidElement(triggerElement)) {\n throw new Error('Dropdown trigger must be a React element.');\n }\n\n const isHostElement = typeof triggerElement.type === 'string';\n const isButtonElement = isHostElement && triggerElement.type === 'button';\n const canAttachRef =\n isHostElement ||\n typeof triggerElement.type === 'function' ||\n isForwardRefComponent(triggerElement.type);\n\n if (!canAttachRef) {\n throw new Error(\n 'Dropdown trigger must be a DOM element or component that accepts a ref.',\n );\n }\n\n const triggerElementRef =\n (triggerElement.props as { ref?: Ref<HTMLElement> }).ref ??\n (triggerElement as ReactElement & { ref?: Ref<HTMLElement> }).ref;\n const setTriggerRef = (node: HTMLElement | null) => {\n triggerRef.current = node;\n if (typeof triggerElementRef === 'function') {\n triggerElementRef(node);\n } else if (triggerElementRef != null) {\n (triggerElementRef as MutableRefObject<HTMLElement | null>).current =\n node;\n }\n };\n\n const triggerProps = triggerElement.props as HTMLAttributes<HTMLElement> & {\n type?: string;\n };\n\n const handleTriggerClick = (event: ReactMouseEvent<HTMLElement>) => {\n triggerProps.onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n toggle();\n };\n\n const handleTriggerKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n triggerProps.onKeyDown?.(event);\n if (event.defaultPrevented) {\n return;\n }\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n toggle();\n }\n };\n\n const mergedTriggerProps: Record<string, unknown> = {\n onClick: handleTriggerClick,\n 'aria-haspopup': 'menu',\n 'aria-expanded': isOpen,\n };\n\n if (ariaLabel != null && ariaLabel !== '') {\n mergedTriggerProps['aria-label'] = ariaLabel;\n }\n\n if (isButtonElement) {\n if (triggerProps.type == null) {\n mergedTriggerProps.type = 'button';\n }\n } else {\n mergedTriggerProps.onKeyDown = handleTriggerKeyDown;\n if (triggerProps.role == null) {\n mergedTriggerProps.role = 'button';\n }\n if (triggerProps.tabIndex == null) {\n mergedTriggerProps.tabIndex = 0;\n }\n }\n\n mergedTriggerProps.ref = setTriggerRef;\n\n let contentStyles: React.CSSProperties = {};\n if (position != null) {\n contentStyles = {\n top: position.top,\n left: position.left,\n width: position.width,\n };\n }\n\n const portalTarget = portalContainer ?? document.body;\n\n const contextValue: DropdownContextValue = {\n close,\n open: openFn,\n isOpen,\n };\n\n let dropdownContent: JSX.Element | null = null;\n if (isOpen) {\n dropdownContent = createPortal(\n <div\n ref={contentRef}\n role=\"menu\"\n className={cx(\n classes.content,\n classes.contentPositioned,\n contentClassName,\n )}\n style={contentStyles}\n >\n {children}\n </div>,\n portalTarget,\n );\n }\n\n return (\n <DropdownContext.Provider value={contextValue}>\n <div className={cx(classes.container, className)} ref={containerRef}>\n {cloneElement(triggerElement, mergedTriggerProps)}\n </div>\n {dropdownContent}\n </DropdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAqCA,IAAM,IAAkB,EAA2C,KAAK,EAI3D,UAA0C;CACrD,IAAM,IAAM,EAAW,EAAgB;AACvC,KAAI,KAAO,KACT,OAAU,MAAM,iDAAiD;AAEnE,QAAO;GA0BH,KAAyB,MACT,OAAO,KAAS,aAAhC,IACK,KAGN,EAA+B,aAAa,OAAO,IAAI,oBAAoB,EASnE,KAAY,EACvB,YACA,aACA,cACA,qBACA,eAAY,gBACZ,YAAS,GACT,uBAAoB,IACpB,SACA,iBAAc,IACd,iBACA,sBAAmB,IACnB,oBACA,mBACgC;CAChC,IAAM,IAAe,KAAQ,MACvB,CAAC,GAAkB,KAAuB,EAAS,EAAY,EACjE,IAAS;AACb,CAAI,MACF,IAAS,EAAQ;CAGnB,IAAM,IAAe,EAAuB,KAAK,EAC3C,IAAa,EAAoB,KAAK,EACtC,IAAa,EAAuB,KAAK,EACzC,CAAC,GAAU,KAAe,EAA+B,KAAK,EAE9D,IAAa,EAAuB,EAAE,CAAC,EAEvC,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,OAAO,WAExB,EAAa,aACf,EAAmB,WAAW,KAIlC,EAAmB,MAAM;CAEzB,IAAI,IAAqC,EAAE;AAC3C,CAAI,KAAY,SACd,IAAgB;EACd,KAAK,EAAS;EACd,MAAM,EAAS;EACf,OAAO,EAAS;EACjB;CAGH,IAAM,KAAe,KAAmB,SAAS,MAE3C,KAAqC;EACzC;EACA,MAAM;EACN;EACD,EAEG,IAAsC;AAmB1C,QAlBI,MACF,IAAkB,GAChB,kBAAC,OAAD;EACE,KAAK;EACL,MAAK;EACL,WAAW,EACT,GACA,GACA,EACD;EACD,OAAO;EAEN;EACG,CAAA,EACN,GACD,GAID,kBAAC,EAAgB,UAAjB;EAA0B,OAAO;YAAjC,CACE,kBAAC,OAAD;GAAK,WAAW,EAAG,GAAmB,EAAU;GAAE,KAAK;aACpD,EAAa,GAAgB,EAAmB;GAC7C,CAAA,EACL,EACwB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cx as e } from "../../../theme/tools.js";
|
|
2
2
|
import { form as t } from "./formStyles.css.js";
|
|
3
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
4
3
|
import "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
5
|
//#region src/atomic/molecules/form/Form.tsx
|
|
6
6
|
var r = (r) => {
|
|
7
7
|
let { onSubmit: i, className: a, children: o, ref: s, ...c } = r;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormErrorAlertSvg as e } from "../../../icons/FormErrorAlertSvg.js";
|
|
2
2
|
import { formError as t, icon as n, message as r } from "./formError.css.js";
|
|
3
|
-
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
3
|
import "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
5
|
//#region src/atomic/molecules/form_error/FormError.tsx
|
|
6
6
|
var o = ({ children: o, ...s }) => o == null ? null : /* @__PURE__ */ a("div", {
|
|
7
7
|
className: t,
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { cx as e } from "../../../theme/tools.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { MarkdownCodeCopyButton as t } from "../markdown/components/MarkdownCodeCopyButton.js";
|
|
3
|
+
import { badge as n, container as r, content as i, fallbackCode as a, placeholder as o, shikiPre as s, shikiWrapper as c, toolbar as l } from "./HighlightCode.css.js";
|
|
4
|
+
import { cloneElement as u, isValidElement as d } from "react";
|
|
5
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
6
|
//#region src/atomic/molecules/highlight/HighlightCode.tsx
|
|
7
7
|
var m = (t) => {
|
|
8
|
-
if (!
|
|
8
|
+
if (!d(t) || typeof t.type != "string" || t.type !== "pre") return t;
|
|
9
9
|
let n = t.props.className;
|
|
10
|
-
return
|
|
11
|
-
}, h = ({ badgeLabel: e, copyCode:
|
|
10
|
+
return u(t, { className: e(s, n) });
|
|
11
|
+
}, h = ({ badgeLabel: e, copyCode: s, highlighted: u, fallbackCodeText: d, placeholderText: h }) => {
|
|
12
12
|
let g;
|
|
13
|
-
g = h == null ?
|
|
14
|
-
className: i,
|
|
15
|
-
children: p ?? ""
|
|
16
|
-
}) : typeof f == "string" ? /* @__PURE__ */ u("pre", {
|
|
17
|
-
className: i,
|
|
18
|
-
dangerouslySetInnerHTML: { __html: f }
|
|
19
|
-
}) : /* @__PURE__ */ u("div", {
|
|
20
|
-
className: s,
|
|
21
|
-
children: m(f)
|
|
22
|
-
}) : /* @__PURE__ */ u("span", {
|
|
13
|
+
g = h == null ? u == null ? /* @__PURE__ */ f("pre", {
|
|
23
14
|
className: a,
|
|
15
|
+
children: d ?? ""
|
|
16
|
+
}) : typeof u == "string" ? /* @__PURE__ */ f("pre", {
|
|
17
|
+
className: a,
|
|
18
|
+
dangerouslySetInnerHTML: { __html: u }
|
|
19
|
+
}) : /* @__PURE__ */ f("div", {
|
|
20
|
+
className: c,
|
|
21
|
+
children: m(u)
|
|
22
|
+
}) : /* @__PURE__ */ f("span", {
|
|
23
|
+
className: o,
|
|
24
24
|
children: h
|
|
25
25
|
});
|
|
26
26
|
let _ = null;
|
|
27
|
-
return typeof
|
|
28
|
-
className:
|
|
29
|
-
children: [/* @__PURE__ */
|
|
30
|
-
className:
|
|
31
|
-
children: [/* @__PURE__ */
|
|
32
|
-
className:
|
|
27
|
+
return typeof s == "string" && s !== "" && (_ = /* @__PURE__ */ f(t, { code: s })), /* @__PURE__ */ p("div", {
|
|
28
|
+
className: r,
|
|
29
|
+
children: [/* @__PURE__ */ p("div", {
|
|
30
|
+
className: l,
|
|
31
|
+
children: [/* @__PURE__ */ f("span", {
|
|
32
|
+
className: n,
|
|
33
33
|
children: e
|
|
34
34
|
}), _]
|
|
35
|
-
}), /* @__PURE__ */
|
|
36
|
-
className:
|
|
35
|
+
}), /* @__PURE__ */ f("div", {
|
|
36
|
+
className: i,
|
|
37
37
|
children: g
|
|
38
38
|
})]
|
|
39
39
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fallback as e } from "./LazyMarkdownRenderer.css.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Suspense as t, lazy as n } from "react";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
4
|
//#region src/atomic/molecules/markdown/LazyMarkdownRenderer.tsx
|
|
5
|
-
var i =
|
|
5
|
+
var i = n(async () => ({ default: (await import("./MarkdownRenderer.js")).MarkdownRenderer })), a = ({ content: t }) => /* @__PURE__ */ r("div", {
|
|
6
6
|
className: e,
|
|
7
|
-
children:
|
|
8
|
-
}), o = ({ content: e }) => /* @__PURE__ */ t
|
|
9
|
-
fallback: /* @__PURE__ */
|
|
10
|
-
children: /* @__PURE__ */
|
|
7
|
+
children: t
|
|
8
|
+
}), o = ({ content: e }) => /* @__PURE__ */ r(t, {
|
|
9
|
+
fallback: /* @__PURE__ */ r(a, { content: e }),
|
|
10
|
+
children: /* @__PURE__ */ r(i, { content: e })
|
|
11
11
|
});
|
|
12
12
|
//#endregion
|
|
13
13
|
export { o as LazyMarkdownRenderer, o as default };
|
|
@@ -28,26 +28,26 @@ import { MarkdownTableRow as E } from "./components/MarkdownTableRow.js";
|
|
|
28
28
|
import { MarkdownTaskListItem as D } from "./components/MarkdownTaskListItem.js";
|
|
29
29
|
import { MarkdownText as O } from "./components/MarkdownText.js";
|
|
30
30
|
import { MarkdownThematicBreak as k } from "./components/MarkdownThematicBreak.js";
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
31
|
+
import { Fragment as A, useDeferredValue as j, useMemo as M } from "react";
|
|
32
|
+
import { jsx as N, jsxs as te } from "react/jsx-runtime";
|
|
33
33
|
//#region src/atomic/molecules/markdown/MarkdownRenderer.tsx
|
|
34
34
|
var P = (e) => e === "center" || e === "right" ? e : "left", F = (e, t, n) => t == null ? null : e(t, n), I = (e) => {
|
|
35
35
|
if ("children" in e) return e.children;
|
|
36
36
|
}, L = (t) => t.type === e.codeInline, R = (t) => t.type === e.codeBlock, z = (t) => t.type === e.footnoteReference, B = (t) => t.type === e.heading, V = (t) => t.type === e.htmlBlock, H = (t) => t.type === e.htmlSelfClosing, U = (t) => t.type === e.image, W = (t) => t.type === e.link, G = (t) => t.type === e.orderedList, K = (t) => t.type === e.paragraph, q = (t) => t.type === e.table, J = (t) => t.type === e.text, Y = (t) => t.type === e.textFormatted, X = (t) => t.type === e.unorderedList, Z = (t) => t.type === e.gfmTask, Q = {
|
|
37
|
-
[e.blockQuote]: (e, t, n, i) => /* @__PURE__ */
|
|
38
|
-
[e.breakLine]: (e, t, n, r) => /* @__PURE__ */
|
|
39
|
-
[e.breakThematic]: (e, t, n, r) => /* @__PURE__ */
|
|
40
|
-
[e.codeInline]: (e, t, n, r) => L(t) ? /* @__PURE__ */
|
|
41
|
-
[e.codeBlock]: (e, t, n, r) => R(t) ? /* @__PURE__ */
|
|
37
|
+
[e.blockQuote]: (e, t, n, i) => /* @__PURE__ */ N(r, { children: F(n, I(t), i) }, i.key),
|
|
38
|
+
[e.breakLine]: (e, t, n, r) => /* @__PURE__ */ N(m, {}, r.key),
|
|
39
|
+
[e.breakThematic]: (e, t, n, r) => /* @__PURE__ */ N(k, {}, r.key),
|
|
40
|
+
[e.codeInline]: (e, t, n, r) => L(t) ? /* @__PURE__ */ N(p, { text: t.text }, r.key) : null,
|
|
41
|
+
[e.codeBlock]: (e, t, n, r) => R(t) ? /* @__PURE__ */ N(i, {
|
|
42
42
|
code: t.text,
|
|
43
43
|
language: t.lang
|
|
44
44
|
}, r.key) : null,
|
|
45
|
-
[e.footnoteReference]: (e, t, n, r) => z(t) ? /* @__PURE__ */
|
|
45
|
+
[e.footnoteReference]: (e, t, n, r) => z(t) ? /* @__PURE__ */ N(c, {
|
|
46
46
|
href: t.target,
|
|
47
47
|
label: t.text
|
|
48
48
|
}, r.key) : null,
|
|
49
49
|
[e.gfmTask]: () => null,
|
|
50
|
-
[e.heading]: (e, t, n, r) => B(t) ? /* @__PURE__ */
|
|
50
|
+
[e.heading]: (e, t, n, r) => B(t) ? /* @__PURE__ */ N(u, {
|
|
51
51
|
id: t.id,
|
|
52
52
|
level: t.level,
|
|
53
53
|
children: F(n, t.children, r)
|
|
@@ -55,16 +55,16 @@ var P = (e) => e === "center" || e === "right" ? e : "left", F = (e, t, n) => t
|
|
|
55
55
|
[e.htmlBlock]: (e, t, n, r) => {
|
|
56
56
|
if (!V(t)) return null;
|
|
57
57
|
let i = t.text, a = "";
|
|
58
|
-
return typeof i == "string" && (a = i), /* @__PURE__ */
|
|
58
|
+
return typeof i == "string" && (a = i), /* @__PURE__ */ N(d, {
|
|
59
59
|
content: a,
|
|
60
60
|
title: "HTML non pris en charge"
|
|
61
61
|
}, r.key);
|
|
62
62
|
},
|
|
63
|
-
[e.htmlSelfClosing]: (e, t, n, r) => H(t) ? /* @__PURE__ */
|
|
63
|
+
[e.htmlSelfClosing]: (e, t, n, r) => H(t) ? /* @__PURE__ */ N(d, {
|
|
64
64
|
content: `<${t.tag} />`,
|
|
65
65
|
title: "HTML non pris en charge"
|
|
66
66
|
}, r.key) : null,
|
|
67
|
-
[e.image]: (e, t, n, r) => U(t) ? /* @__PURE__ */
|
|
67
|
+
[e.image]: (e, t, n, r) => U(t) ? /* @__PURE__ */ N(f, {
|
|
68
68
|
alt: t.alt,
|
|
69
69
|
src: t.target,
|
|
70
70
|
title: t.title
|
|
@@ -72,13 +72,13 @@ var P = (e) => e === "center" || e === "right" ? e : "left", F = (e, t, n) => t
|
|
|
72
72
|
[e.link]: (e, t, n, r) => {
|
|
73
73
|
if (!W(t)) return null;
|
|
74
74
|
let i = t.target;
|
|
75
|
-
return i == null ? /* @__PURE__ */ A
|
|
75
|
+
return i == null ? /* @__PURE__ */ N(A, { children: F(n, t.children, r) }, r.key) : /* @__PURE__ */ N(h, {
|
|
76
76
|
href: i,
|
|
77
77
|
title: t.title,
|
|
78
78
|
children: F(n, t.children, r)
|
|
79
79
|
}, r.key);
|
|
80
80
|
},
|
|
81
|
-
[e.orderedList]: (e, t, n, r) => G(t) ? /* @__PURE__ */
|
|
81
|
+
[e.orderedList]: (e, t, n, r) => G(t) ? /* @__PURE__ */ N(g, {
|
|
82
82
|
ordered: !0,
|
|
83
83
|
start: t.start,
|
|
84
84
|
children: t.items.map((e, t) => {
|
|
@@ -87,48 +87,48 @@ var P = (e) => e === "center" || e === "right" ? e : "left", F = (e, t, n) => t
|
|
|
87
87
|
let a = `${i}-${t}`, o = e[0];
|
|
88
88
|
if (o != null && Z(o)) {
|
|
89
89
|
let t = e.slice(1);
|
|
90
|
-
return /* @__PURE__ */
|
|
90
|
+
return /* @__PURE__ */ N(D, {
|
|
91
91
|
checked: o.completed,
|
|
92
92
|
children: F(n, t, r)
|
|
93
93
|
}, a);
|
|
94
94
|
}
|
|
95
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ N(_, { children: F(n, e, r) }, a);
|
|
96
96
|
})
|
|
97
97
|
}, r.key) : null,
|
|
98
|
-
[e.paragraph]: (e, t, n, r) => K(t) ? /* @__PURE__ */
|
|
98
|
+
[e.paragraph]: (e, t, n, r) => K(t) ? /* @__PURE__ */ N(v, { children: F(n, t.children, r) }, r.key) : null,
|
|
99
99
|
[e.table]: (e, t, n, r) => {
|
|
100
100
|
if (!q(t)) return null;
|
|
101
101
|
let i = null;
|
|
102
|
-
return Array.isArray(t.header) && t.header.length > 0 && (i = /* @__PURE__ */
|
|
102
|
+
return Array.isArray(t.header) && t.header.length > 0 && (i = /* @__PURE__ */ N(w, { children: /* @__PURE__ */ N(E, { children: t.header.map((e, i) => {
|
|
103
103
|
let a;
|
|
104
|
-
return Array.isArray(t.align) && (a = t.align[i]), /* @__PURE__ */
|
|
104
|
+
return Array.isArray(t.align) && (a = t.align[i]), /* @__PURE__ */ N(T, {
|
|
105
105
|
align: P(a),
|
|
106
106
|
children: F(n, e, r)
|
|
107
107
|
}, `header-${i}`);
|
|
108
|
-
}) }) })), /* @__PURE__ */
|
|
108
|
+
}) }) })), /* @__PURE__ */ te(x, { children: [i, /* @__PURE__ */ N(S, { children: t.cells.map((e, i) => /* @__PURE__ */ N(E, { children: e.map((e, a) => {
|
|
109
109
|
let o;
|
|
110
|
-
return Array.isArray(t.align) && (o = t.align[a]), /* @__PURE__ */
|
|
110
|
+
return Array.isArray(t.align) && (o = t.align[a]), /* @__PURE__ */ N(C, {
|
|
111
111
|
align: P(o),
|
|
112
112
|
children: F(n, e, r)
|
|
113
113
|
}, `cell-${i}-${a}`);
|
|
114
114
|
}) }, `row-${i}`)) })] }, r.key);
|
|
115
115
|
},
|
|
116
|
-
[e.text]: (e, t, n, r) => J(t) ? /* @__PURE__ */
|
|
116
|
+
[e.text]: (e, t, n, r) => J(t) ? /* @__PURE__ */ N(O, { text: t.text }, r.key) : null,
|
|
117
117
|
[e.textFormatted]: (e, t, n, r) => {
|
|
118
118
|
if (!Y(t)) return e();
|
|
119
119
|
let i = F(n, t.children, r);
|
|
120
120
|
switch (t.tag) {
|
|
121
121
|
case "strong":
|
|
122
|
-
case "b": return /* @__PURE__ */
|
|
122
|
+
case "b": return /* @__PURE__ */ N(y, { children: i }, r.key);
|
|
123
123
|
case "em":
|
|
124
|
-
case "i": return /* @__PURE__ */
|
|
125
|
-
case "mark": return /* @__PURE__ */
|
|
124
|
+
case "i": return /* @__PURE__ */ N(o, { children: i }, r.key);
|
|
125
|
+
case "mark": return /* @__PURE__ */ N(ee, { children: i }, r.key);
|
|
126
126
|
case "del":
|
|
127
|
-
case "s": return /* @__PURE__ */
|
|
127
|
+
case "s": return /* @__PURE__ */ N(a, { children: i }, r.key);
|
|
128
128
|
default: return e();
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
|
-
[e.unorderedList]: (e, t, n, r) => X(t) ? /* @__PURE__ */
|
|
131
|
+
[e.unorderedList]: (e, t, n, r) => X(t) ? /* @__PURE__ */ N(g, {
|
|
132
132
|
ordered: !1,
|
|
133
133
|
children: t.items.map((e, t) => {
|
|
134
134
|
let i = "ul";
|
|
@@ -136,18 +136,18 @@ var P = (e) => e === "center" || e === "right" ? e : "left", F = (e, t, n) => t
|
|
|
136
136
|
let a = `${i}-${t}`, o = e[0];
|
|
137
137
|
if (o != null && Z(o)) {
|
|
138
138
|
let t = e.slice(1);
|
|
139
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ N(D, {
|
|
140
140
|
checked: o.completed,
|
|
141
141
|
children: F(n, t, r)
|
|
142
142
|
}, a);
|
|
143
143
|
}
|
|
144
|
-
return /* @__PURE__ */
|
|
144
|
+
return /* @__PURE__ */ N(_, { children: F(n, e, r) }, a);
|
|
145
145
|
})
|
|
146
146
|
}, r.key) : null
|
|
147
147
|
}, ne = {
|
|
148
148
|
disableParsingRawHTML: !0,
|
|
149
149
|
forceBlock: !0,
|
|
150
|
-
wrapper:
|
|
150
|
+
wrapper: A,
|
|
151
151
|
overrides: {
|
|
152
152
|
footer: { component: l },
|
|
153
153
|
sup: { component: s },
|
|
@@ -158,10 +158,10 @@ var P = (e) => e === "center" || e === "right" ? e : "left", F = (e, t, n) => t
|
|
|
158
158
|
return i == null ? e() : i(e, t, n, r);
|
|
159
159
|
}
|
|
160
160
|
}, $ = ({ content: e }) => {
|
|
161
|
-
let r =
|
|
162
|
-
return /* @__PURE__ */
|
|
161
|
+
let r = j(e);
|
|
162
|
+
return /* @__PURE__ */ N(n, { children: /* @__PURE__ */ N(t, {
|
|
163
163
|
options: ne,
|
|
164
|
-
children:
|
|
164
|
+
children: M(() => r, [r])
|
|
165
165
|
}) });
|
|
166
166
|
};
|
|
167
167
|
//#endregion
|