@rio-cloud/rio-uikit 2.3.0-beta.3 → 2.4.0
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/MapPreviousViewportButton.d.ts +2 -0
- package/MapPreviousViewportButton.js +5 -0
- package/MapPreviousViewportButton.js.map +1 -0
- package/Table.js +16 -14
- package/TableNext.js +16 -14
- package/TableRowActionsDropdown.d.ts +2 -0
- package/TableRowActionsDropdown.js +5 -0
- package/TableRowActionsDropdown.js.map +1 -0
- package/components/dropdown/ButtonDropdown.d.ts +4 -0
- package/components/dropdown/ButtonDropdown.js +82 -80
- package/components/dropdown/ButtonDropdown.js.map +1 -1
- package/components/map/components/Map.js +219 -182
- package/components/map/components/Map.js.map +1 -1
- package/components/map/components/MapContext.d.ts +4 -0
- package/components/map/components/MapContext.js +11 -7
- package/components/map/components/MapContext.js.map +1 -1
- package/components/map/components/MapPosition.d.ts +1 -1
- package/components/map/components/MapPosition.js +20 -13
- package/components/map/components/MapPosition.js.map +1 -1
- package/components/map/components/features/MapZoom.d.ts +0 -1
- package/components/map/components/features/MapZoom.js +12 -20
- package/components/map/components/features/MapZoom.js.map +1 -1
- package/components/map/components/features/settings/MapSettingsTile.d.ts +27 -0
- package/components/map/components/features/settings/MapSettingsTile.js +17 -17
- package/components/map/components/features/settings/MapSettingsTile.js.map +1 -1
- package/components/map/components/features/settings/buttons/MapPreviousViewportButton.d.ts +10 -0
- package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js +23 -0
- package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js.map +1 -0
- package/components/map/hooks/useMapViewportHistory.d.ts +19 -0
- package/components/map/hooks/useMapViewportHistory.js +116 -0
- package/components/map/hooks/useMapViewportHistory.js.map +1 -0
- package/components/map/icons/MapIcon.d.ts +1 -0
- package/components/map/icons/MapIcon.js +46 -37
- package/components/map/icons/MapIcon.js.map +1 -1
- package/components/map/utils/mapTypes.d.ts +12 -0
- package/components/map/utils/mapTypes.js.map +1 -1
- package/components/map/utils/mapUtils.d.ts +2 -0
- package/components/map/utils/mapUtils.js +4 -0
- package/components/map/utils/mapUtils.js.map +1 -1
- package/components/selects/Multiselect.d.ts +6 -0
- package/components/selects/Multiselect.js +85 -83
- package/components/selects/Multiselect.js.map +1 -1
- package/components/selects/Select.d.ts +6 -0
- package/components/selects/Select.js +79 -71
- package/components/selects/Select.js.map +1 -1
- package/components/table/Table.d.ts +5 -1
- package/components/table/Table.js +234 -210
- package/components/table/Table.js.map +1 -1
- package/components/table/Table.types.d.ts +55 -0
- package/components/table/TableExpandAllGroupsButton.d.ts +25 -0
- package/components/table/TableExpandAllGroupsButton.js +27 -0
- package/components/table/TableExpandAllGroupsButton.js.map +1 -0
- package/components/table/TableExpandedRow.d.ts +4 -0
- package/components/table/TableExpandedRow.js +101 -84
- package/components/table/TableExpandedRow.js.map +1 -1
- package/components/table/TableExpanderButton.js +11 -11
- package/components/table/TableExpanderButton.js.map +1 -1
- package/components/table/TableGroupRow.d.ts +16 -2
- package/components/table/TableGroupRow.js +57 -22
- package/components/table/TableGroupRow.js.map +1 -1
- package/components/table/TableHeader.d.ts +1 -9
- package/components/table/TableHeader.js +82 -65
- package/components/table/TableHeader.js.map +1 -1
- package/components/table/TableRow.d.ts +7 -1
- package/components/table/TableRow.js +89 -72
- package/components/table/TableRow.js.map +1 -1
- package/components/table/TableRowActionsDropdown.d.ts +11 -0
- package/components/table/TableRowActionsDropdown.js +22 -0
- package/components/table/TableRowActionsDropdown.js.map +1 -0
- package/components/table/TableStickyRowButton.d.ts +25 -0
- package/components/table/TableStickyRowButton.js +32 -0
- package/components/table/TableStickyRowButton.js.map +1 -0
- package/components/table/TableToolbar.d.ts +24 -3
- package/components/table/TableToolbar.js +78 -37
- package/components/table/TableToolbar.js.map +1 -1
- package/components/table/TableViewToggles.js +5 -5
- package/components/table/TableViewToggles.js.map +1 -1
- package/components/table/context/TableInteractionContext.d.ts +3 -0
- package/components/table/context/TableInteractionContext.js.map +1 -1
- package/components/table/context/TableRenderConfigContext.d.ts +2 -1
- package/components/table/context/TableRenderConfigContext.js.map +1 -1
- package/components/table/context/TableRenderContext.d.ts +1 -0
- package/components/table/context/TableRenderContext.js.map +1 -1
- package/components/table/layout/useMeasuredColumnMaxWidths.js +52 -54
- package/components/table/layout/useMeasuredColumnMaxWidths.js.map +1 -1
- package/components/table/layout/useTableLayout.d.ts +4 -1
- package/components/table/layout/useTableLayout.js +54 -48
- package/components/table/layout/useTableLayout.js.map +1 -1
- package/components/table/layout/useTableVirtualization.js +51 -56
- package/components/table/layout/useTableVirtualization.js.map +1 -1
- package/components/table/model/resolveResponsiveViewType.d.ts +2 -0
- package/components/table/model/resolveResponsiveViewType.js +27 -0
- package/components/table/model/resolveResponsiveViewType.js.map +1 -0
- package/components/table/render/header/TableHeaderCellContent.js +4 -4
- package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
- package/components/table/render/header/TableHeaderSelectionCell.d.ts +3 -0
- package/components/table/render/header/TableHeaderSelectionCell.js +25 -14
- package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
- package/components/table/runtime/useRenderDraftState.js +1 -0
- package/components/table/runtime/useRenderDraftState.js.map +1 -1
- package/components/table/runtime/useResponsiveResolvedViewType.d.ts +23 -0
- package/components/table/runtime/useResponsiveResolvedViewType.js +22 -0
- package/components/table/runtime/useResponsiveResolvedViewType.js.map +1 -0
- package/components/table/selection/useInternalTableSelectionState.d.ts +2 -0
- package/components/table/selection/useInternalTableSelectionState.js +29 -17
- package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
- package/components/table/selection/useTableSelection.d.ts +5 -1
- package/components/table/selection/useTableSelection.js +37 -26
- package/components/table/selection/useTableSelection.js.map +1 -1
- package/components/table/shared/parsePixelSize.d.ts +2 -0
- package/components/table/shared/parsePixelSize.js +13 -0
- package/components/table/shared/parsePixelSize.js.map +1 -0
- package/hooks/useResizeObserver.d.ts +25 -6
- package/hooks/useResizeObserver.js +20 -18
- package/hooks/useResizeObserver.js.map +1 -1
- package/package.json +10 -10
- package/version.d.ts +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapPreviousViewportButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/Table.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { TableBatchDropdown as a, TableBody as l, TableColumn as b, TableColumnFilter as T, TableColumnsDropdown as r, TableExpandedContentRow as
|
|
2
|
-
import { default as
|
|
1
|
+
import { TableBatchDropdown as a, TableBody as l, TableColumn as b, TableColumnFilter as T, TableColumnsDropdown as t, TableExpandAllGroupsButton as r, TableExpandedContentRow as n, TableExpandedRow as d, TableExpanderButton as u, TableFooter as p, TableGroupFooterRow as w, TableGroupRow as R, TableHeader as m, TableHeaderColumn as x, TableHeaderRow as B, TableRow as C, TableSpacerRow as c, TableStickyRowButton as f, default as s } from "./components/table/Table.js";
|
|
2
|
+
import { default as i } from "./components/table/selection/useTableSelection.js";
|
|
3
3
|
export {
|
|
4
4
|
a as TableBatchDropdown,
|
|
5
5
|
l as TableBody,
|
|
6
6
|
b as TableColumn,
|
|
7
7
|
T as TableColumnFilter,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
n as
|
|
11
|
-
|
|
8
|
+
t as TableColumnsDropdown,
|
|
9
|
+
r as TableExpandAllGroupsButton,
|
|
10
|
+
n as TableExpandedContentRow,
|
|
11
|
+
d as TableExpandedRow,
|
|
12
|
+
u as TableExpanderButton,
|
|
12
13
|
p as TableFooter,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
w as TableGroupFooterRow,
|
|
15
|
+
R as TableGroupRow,
|
|
16
|
+
m as TableHeader,
|
|
17
|
+
x as TableHeaderColumn,
|
|
18
|
+
B as TableHeaderRow,
|
|
18
19
|
C as TableRow,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
c as TableSpacerRow,
|
|
21
|
+
f as TableStickyRowButton,
|
|
22
|
+
s as default,
|
|
23
|
+
i as useTableSelection
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=Table.js.map
|
package/TableNext.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { TableBatchDropdown as a, TableBody as l, TableColumn as b, TableColumnFilter as T, TableColumnsDropdown as r, TableExpandedContentRow as
|
|
2
|
-
import { default as
|
|
1
|
+
import { TableBatchDropdown as a, TableBody as l, TableColumn as b, TableColumnFilter as T, TableColumnsDropdown as t, TableExpandAllGroupsButton as r, TableExpandedContentRow as n, TableExpandedRow as d, TableExpanderButton as u, TableFooter as p, TableGroupFooterRow as w, TableGroupRow as R, TableHeader as m, TableHeaderColumn as x, TableHeaderRow as B, TableRow as C, TableSpacerRow as c, TableStickyRowButton as f, default as s } from "./components/table/Table.js";
|
|
2
|
+
import { default as i } from "./components/table/selection/useTableSelection.js";
|
|
3
3
|
export {
|
|
4
4
|
a as TableBatchDropdown,
|
|
5
5
|
l as TableBody,
|
|
6
6
|
b as TableColumn,
|
|
7
7
|
T as TableColumnFilter,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
n as
|
|
11
|
-
|
|
8
|
+
t as TableColumnsDropdown,
|
|
9
|
+
r as TableExpandAllGroupsButton,
|
|
10
|
+
n as TableExpandedContentRow,
|
|
11
|
+
d as TableExpandedRow,
|
|
12
|
+
u as TableExpanderButton,
|
|
12
13
|
p as TableFooter,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
w as TableGroupFooterRow,
|
|
15
|
+
R as TableGroupRow,
|
|
16
|
+
m as TableHeader,
|
|
17
|
+
x as TableHeaderColumn,
|
|
18
|
+
B as TableHeaderRow,
|
|
18
19
|
C as TableRow,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
c as TableSpacerRow,
|
|
21
|
+
f as TableStickyRowButton,
|
|
22
|
+
s as default,
|
|
23
|
+
i as useTableSelection
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=TableNext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRowActionsDropdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -7,6 +7,10 @@ export type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> =
|
|
|
7
7
|
* Unique button id. If not present a random id is generated.
|
|
8
8
|
*/
|
|
9
9
|
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Accessible label applied to the dropdown toggle button.
|
|
12
|
+
*/
|
|
13
|
+
'aria-label'?: string;
|
|
10
14
|
/**
|
|
11
15
|
* The button title. This may be also a node, like a <span> or a <FormattedMessage>.
|
|
12
16
|
*/
|
|
@@ -1,124 +1,126 @@
|
|
|
1
1
|
import { jsx as i, jsxs as h } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as lo, useState as c, useEffect as ao } from "react";
|
|
3
3
|
import po from "react-dom";
|
|
4
|
-
import { usePopper as
|
|
4
|
+
import { usePopper as io } from "react-popper";
|
|
5
5
|
import { noop as u } from "es-toolkit/function";
|
|
6
|
-
import { isNil as
|
|
6
|
+
import { isNil as co } from "es-toolkit/predicate";
|
|
7
7
|
import P from "../../utils/classNames.js";
|
|
8
|
-
import { getOrCreatePortalRoot as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
8
|
+
import { getOrCreatePortalRoot as fo } from "../../utils/portalRoot.js";
|
|
9
|
+
import mo, { DEFAULT_EVENT_TYPES as uo } from "../../hooks/useClickOutside.js";
|
|
10
|
+
import go from "../menuItems/MenuItems.js";
|
|
11
|
+
import wo from "../menuItems/MenuItemList.js";
|
|
12
|
+
import Co from "./DropdownToggleButton.js";
|
|
13
|
+
import bo from "./SplitCaretButton.js";
|
|
14
14
|
import Bo from "./Caret.js";
|
|
15
|
-
const Do = (r, s) => r && s ? "top-end" : !r && s ? "top-start" : r && !s ? "bottom-end" : "bottom-start", No = () =>
|
|
15
|
+
const Do = (r, s) => r && s ? "top-end" : !r && s ? "top-start" : r && !s ? "bottom-end" : "bottom-start", No = () => lo((r, s) => {
|
|
16
16
|
const {
|
|
17
17
|
id: g = Math.random().toString(36).slice(2, 16),
|
|
18
|
-
|
|
18
|
+
"aria-label": R,
|
|
19
|
+
items: T = [],
|
|
19
20
|
bsSize: w = "md",
|
|
20
21
|
bsStyle: C = "default",
|
|
21
|
-
variant:
|
|
22
|
-
disabled:
|
|
23
|
-
iconName:
|
|
24
|
-
iconOnly:
|
|
25
|
-
title:
|
|
26
|
-
splitButton:
|
|
27
|
-
customDropdown:
|
|
28
|
-
open:
|
|
29
|
-
dropup:
|
|
22
|
+
variant: k,
|
|
23
|
+
disabled: b = !1,
|
|
24
|
+
iconName: y,
|
|
25
|
+
iconOnly: B = !1,
|
|
26
|
+
title: E,
|
|
27
|
+
splitButton: e = !1,
|
|
28
|
+
customDropdown: D,
|
|
29
|
+
open: t,
|
|
30
|
+
dropup: L = !1,
|
|
30
31
|
pullRight: f = !1,
|
|
31
|
-
noCaret:
|
|
32
|
-
onOpen:
|
|
33
|
-
onClose:
|
|
34
|
-
onLabelButtonClick:
|
|
32
|
+
noCaret: x = !1,
|
|
33
|
+
onOpen: I = u,
|
|
34
|
+
onClose: j = u,
|
|
35
|
+
onLabelButtonClick: U = u,
|
|
35
36
|
usePortal: l = !1,
|
|
36
|
-
popperConfig:
|
|
37
|
-
toggleButtonType:
|
|
38
|
-
toggleClassName:
|
|
39
|
-
dropdownClassName:
|
|
40
|
-
className:
|
|
41
|
-
...
|
|
42
|
-
} = r, [
|
|
43
|
-
placement: Do(f,
|
|
37
|
+
popperConfig: _,
|
|
38
|
+
toggleButtonType: v = "button",
|
|
39
|
+
toggleClassName: N = "",
|
|
40
|
+
dropdownClassName: z,
|
|
41
|
+
className: A = "",
|
|
42
|
+
...F
|
|
43
|
+
} = r, [O, m] = c(t), [V, Y] = c(null), [S, q] = c(null), [G, H] = c(null), J = {
|
|
44
|
+
placement: Do(f, L),
|
|
44
45
|
modifiers: []
|
|
45
|
-
},
|
|
46
|
+
}, K = e && f ? G : V, { styles: Q, attributes: W } = io(K, S, _ || J), n = co(t), a = n ? O : t, X = mo(
|
|
46
47
|
(o) => {
|
|
47
|
-
l &&
|
|
48
|
+
l && S?.contains(o.target) || p();
|
|
48
49
|
},
|
|
49
|
-
|
|
50
|
-
!!
|
|
50
|
+
uo,
|
|
51
|
+
!!a
|
|
51
52
|
// only listen to clicks outside when the dropdown is open
|
|
52
|
-
),
|
|
53
|
-
|
|
54
|
-
n || m(
|
|
55
|
-
}, [n,
|
|
53
|
+
), Z = fo(), $ = !x && !e && !B;
|
|
54
|
+
ao(() => {
|
|
55
|
+
n || m(t);
|
|
56
|
+
}, [n, t]);
|
|
56
57
|
const d = (o) => {
|
|
57
|
-
(n ?
|
|
58
|
-
},
|
|
59
|
-
n && m(!0), o &&
|
|
60
|
-
},
|
|
61
|
-
n && m(!1),
|
|
62
|
-
},
|
|
63
|
-
|
|
58
|
+
(n ? O : t) ? p() : oo(o);
|
|
59
|
+
}, oo = (o) => {
|
|
60
|
+
n && m(!0), o && I(o);
|
|
61
|
+
}, p = () => {
|
|
62
|
+
n && m(!1), j();
|
|
63
|
+
}, eo = () => {
|
|
64
|
+
p(), U();
|
|
64
65
|
}, to = (o) => {
|
|
65
66
|
d(o);
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
67
|
+
}, no = (o) => {
|
|
68
|
+
e ? eo() : d(o);
|
|
69
|
+
}, ro = P("dropdown", "btn-group", a && "open", A), so = P(
|
|
69
70
|
l && "dropdown-portal",
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
e && f && "pull-right",
|
|
72
|
+
z
|
|
72
73
|
), M = /* @__PURE__ */ i(
|
|
73
|
-
|
|
74
|
+
wo,
|
|
74
75
|
{
|
|
75
|
-
className:
|
|
76
|
-
ref:
|
|
77
|
-
style:
|
|
78
|
-
...
|
|
79
|
-
children:
|
|
76
|
+
className: so,
|
|
77
|
+
ref: q,
|
|
78
|
+
style: Q.popper,
|
|
79
|
+
...W.popper,
|
|
80
|
+
children: D || /* @__PURE__ */ i(go, { items: T, closeMenu: d })
|
|
80
81
|
}
|
|
81
82
|
);
|
|
82
|
-
return /* @__PURE__ */ h("div", { ...
|
|
83
|
+
return /* @__PURE__ */ h("div", { ...F, className: ro, ref: X, children: [
|
|
83
84
|
/* @__PURE__ */ h(
|
|
84
|
-
|
|
85
|
+
Co,
|
|
85
86
|
{
|
|
86
87
|
id: g,
|
|
87
|
-
|
|
88
|
+
"aria-label": R,
|
|
89
|
+
splitButton: e,
|
|
88
90
|
bsStyle: C,
|
|
89
91
|
bsSize: w,
|
|
90
|
-
variant:
|
|
91
|
-
iconOnly:
|
|
92
|
-
iconName:
|
|
93
|
-
disabled:
|
|
94
|
-
ref:
|
|
95
|
-
onClick:
|
|
92
|
+
variant: k,
|
|
93
|
+
iconOnly: B,
|
|
94
|
+
iconName: y,
|
|
95
|
+
disabled: b,
|
|
96
|
+
ref: Y,
|
|
97
|
+
onClick: no,
|
|
96
98
|
outerRef: s,
|
|
97
|
-
toggleButtonType:
|
|
98
|
-
className:
|
|
99
|
+
toggleButtonType: v,
|
|
100
|
+
className: N,
|
|
99
101
|
children: [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
E,
|
|
103
|
+
$ && /* @__PURE__ */ i(Bo, {})
|
|
102
104
|
]
|
|
103
105
|
}
|
|
104
106
|
),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
e && /* @__PURE__ */ i(
|
|
108
|
+
bo,
|
|
107
109
|
{
|
|
108
110
|
id: g,
|
|
109
111
|
bsStyle: C,
|
|
110
112
|
bsSize: w,
|
|
111
|
-
disabled:
|
|
112
|
-
className:
|
|
113
|
+
disabled: b,
|
|
114
|
+
className: N,
|
|
113
115
|
onClick: to,
|
|
114
|
-
ref:
|
|
116
|
+
ref: H
|
|
115
117
|
}
|
|
116
118
|
),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
a && l && po.createPortal(M, Z),
|
|
120
|
+
a && !l && M
|
|
119
121
|
] });
|
|
120
|
-
}),
|
|
122
|
+
}), _o = No();
|
|
121
123
|
export {
|
|
122
|
-
|
|
124
|
+
_o as default
|
|
123
125
|
};
|
|
124
126
|
//# sourceMappingURL=ButtonDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonDropdown.js","sources":["../../../src/components/dropdown/ButtonDropdown.tsx"],"sourcesContent":["import React, { useState, useEffect, forwardRef, type PropsWithChildren } from 'react';\nimport ReactDOM from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport { noop } from 'es-toolkit/function';\nimport { isNil } from 'es-toolkit/predicate';\n\nimport classNames from '../../utils/classNames';\nimport { getOrCreatePortalRoot } from '../../utils/portalRoot';\nimport useClickOutside, { DEFAULT_EVENT_TYPES } from '../../hooks/useClickOutside';\nimport MenuItems from '../menuItems/MenuItems';\nimport MenuItemList from '../menuItems/MenuItemList';\nimport DropdownToggleButton, { type DropdownToggleEvent, type DropdownToggleButtonType } from './DropdownToggleButton';\nimport SplitCaretButton from './SplitCaretButton';\nimport Caret from './Caret';\nimport type { MenuItemProps as MenuItem } from '../menuItems/MenuItem';\nimport type { BUTTON_SIZE, BUTTON_STYLE, BUTTON_VARIANT } from '../button/Button';\n\nconst getPlacement = (pullRight: boolean, dropup: boolean) => {\n if (pullRight && dropup) {\n return 'top-end';\n }\n if (!pullRight && dropup) {\n return 'top-start';\n }\n if (pullRight && !dropup) {\n return 'bottom-end';\n }\n return 'bottom-start';\n};\n\nexport type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> = {\n /**\n * Unique button id. If not present a random id is generated.\n */\n id?: string;\n\n /**\n * The button title. This may be also a node, like a <span> or a <FormattedMessage>.\n */\n title: string | React.ReactNode;\n\n /**\n * Defined weather or not the menu is rendered.\n * Use this to control the component from the outside.\n *\n * @default undefined\n */\n open?: boolean;\n\n /**\n * Defines whether the dropdown opens above or below.\n * Set it to \"true\" additionally disables the automatic position feature.\n *\n * @default false\n */\n dropup?: boolean;\n\n /**\n * Defines whether the dropdown opens right aligned to the dropdown or not.\n */\n pullRight?: boolean;\n\n /**\n * Defines how large the button will be rendered.\n *\n * Possible values are: `xs`, `sm`, `md`, `lg`\n *\n * @default 'md'\n */\n bsSize?: BUTTON_SIZE;\n\n /**\n * Defines the button color.\n *\n * Possible values are: `default`, `primary`, `secondary`, `info`, `warning`, `danger`, `success`, `muted`\n *\n * @default 'default'\n */\n bsStyle?: BUTTON_STYLE;\n\n /**\n * Defines the variation of the button design.\n *\n * Possible values are: `link`, `link-inline`, `outline`, `action`\n */\n variant?: BUTTON_VARIANT;\n\n /**\n * Specify the toggle element type.\n * It supports the following types: \"button\" | \"tag\" | \"label\"\n *\n * @default 'button'\n */\n toggleButtonType?: DropdownToggleButtonType;\n\n /**\n * Optional prop to defines whether the dropdown title is icon only which\n * applies different padding so the button is a square.\n *\n * @default false\n */\n iconOnly?: boolean;\n\n /**\n * Optional rioglyph icon name forwarded to the underlying button toggle.\n */\n iconName?: string;\n\n /**\n * Defines whether the caret is shown or not.\n *\n * @default false\n */\n noCaret?: boolean;\n\n /**\n * Defines whether the dropdown-toggle (with caret) should be in a separate button.\n *\n * @default false\n */\n splitButton?: boolean;\n\n /**\n * Renders the dropdown into a dedicated react portal\n *\n * @default false\n */\n usePortal?: boolean;\n\n /**\n * Items to display in the dropdown menu. If you use a custom dropdown you can skip this prop.\n */\n items?: MenuItem[];\n\n /**\n * Disables the dropdown button.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Callback for splitButton label button click.\n */\n onLabelButtonClick?: () => void;\n\n /**\n * Callback for when the toggle button was clicked to open it.\n * @param event\n * @returns\n */\n onOpen?: (event: DropdownToggleEvent<T>) => void;\n\n /**\n * Callback for when the toggle button was clicked to close it.\n * @returns\n */\n onClose?: () => void;\n\n /**\n * Allows to pass in custom dropdown menu content.\n */\n customDropdown?: React.ReactNode;\n\n /**\n * Define custom popper.js configuration for dropdown placement and modifiers.\n */\n popperConfig?: object;\n\n /**\n * Additional classes to be set on the dropdown-toggle button.\n */\n toggleClassName?: string;\n\n /**\n * Additional classes to be set on the dropdown.\n */\n dropdownClassName?: string;\n\n /**\n * Additional classes to be set to the wrapper element.\n */\n className?: string;\n};\n\nconst createButtonDropdown = <T extends DropdownToggleButtonType = 'button'>() => {\n return forwardRef<\n T extends 'button' ? HTMLButtonElement : HTMLDivElement,\n PropsWithChildren<ButtonDropdownProps<T>>\n >((props, ref) => {\n const {\n id = Math.random().toString(36).slice(2, 16),\n items = [],\n bsSize = 'md',\n bsStyle = 'default',\n variant,\n disabled = false,\n iconName,\n iconOnly = false,\n title,\n splitButton = false,\n customDropdown,\n open,\n dropup = false,\n pullRight = false,\n noCaret = false,\n onOpen = noop,\n onClose = noop,\n onLabelButtonClick = noop,\n usePortal = false,\n popperConfig,\n toggleButtonType = 'button',\n toggleClassName = '',\n dropdownClassName,\n className = '',\n ...remainingProps\n } = props;\n\n const [internalOpen, setInternalOpen] = useState(open);\n\n const [refDropdownToggle, setRefDropdownToggle] = useState<HTMLButtonElement | HTMLDivElement | null>(null);\n const [refDropdownMenu, setRefDropdownMenu] = useState<HTMLUListElement | null>(null);\n const [refSplitButtonToggle, setRefSplitButtonToggle] = useState<HTMLButtonElement | null>(null);\n\n const defaultPopperConfig = {\n placement: getPlacement(pullRight, dropup),\n modifiers: [],\n };\n\n const popperParentRef = splitButton && pullRight ? refSplitButtonToggle : refDropdownToggle;\n\n const { styles, attributes } = usePopper(popperParentRef, refDropdownMenu, popperConfig || defaultPopperConfig);\n\n const isUncontrolled = isNil(open);\n const isOpen = isUncontrolled ? internalOpen : open;\n\n const wrapperRef = useClickOutside(\n event => {\n if (usePortal) {\n // In case the dropdown is rendered via portal the clickOutside the toggle button element is\n // triggered since the dropdown is not a child of the wrapper element.\n // In this case we need to check if the event target is inside the dropdown-menu and prevent closing\n // the dropdown\n if (!refDropdownMenu?.contains(event.target as Node)) {\n closeMenu();\n }\n } else {\n closeMenu();\n }\n },\n DEFAULT_EVENT_TYPES,\n Boolean(isOpen) // only listen to clicks outside when the dropdown is open\n );\n\n const dropdownRoot = getOrCreatePortalRoot();\n\n const shouldShowCaret = !noCaret && !splitButton && !iconOnly;\n\n useEffect(() => {\n if (!isUncontrolled) {\n setInternalOpen(open);\n }\n }, [isUncontrolled, open]);\n\n const toggleOpen = (event?: DropdownToggleEvent<T>) => {\n const isDropdownOpen = isUncontrolled ? internalOpen : open;\n\n if (isDropdownOpen) {\n closeMenu();\n } else {\n openMenu(event);\n }\n };\n\n const openMenu = (event?: DropdownToggleEvent<T>) => {\n if (isUncontrolled) {\n setInternalOpen(true);\n }\n if (event) {\n onOpen(event);\n }\n };\n\n const closeMenu = () => {\n if (isUncontrolled) {\n setInternalOpen(false);\n }\n onClose();\n };\n\n const handleSplitLabelButtonClick = () => {\n closeMenu();\n onLabelButtonClick();\n };\n\n const handleSplitCaretButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n toggleOpen(event as DropdownToggleEvent<T>);\n };\n\n const handleDropdownButtonClick = (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => {\n if (splitButton) {\n handleSplitLabelButtonClick();\n } else {\n toggleOpen(event as DropdownToggleEvent<T>);\n }\n };\n\n const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);\n\n const dropdownClasses = classNames(\n usePortal && 'dropdown-portal',\n splitButton && pullRight && 'pull-right',\n dropdownClassName\n );\n\n const dropdownMenu = (\n <MenuItemList\n className={dropdownClasses}\n ref={setRefDropdownMenu}\n style={styles.popper}\n {...attributes.popper}\n >\n {customDropdown ? customDropdown : <MenuItems items={items} closeMenu={toggleOpen} />}\n </MenuItemList>\n );\n\n return (\n <div {...remainingProps} className={wrapperClasses} ref={wrapperRef}>\n <DropdownToggleButton\n id={id}\n splitButton={splitButton}\n bsStyle={bsStyle}\n bsSize={bsSize}\n variant={variant}\n iconOnly={iconOnly}\n iconName={iconName}\n disabled={disabled}\n ref={setRefDropdownToggle}\n onClick={handleDropdownButtonClick}\n outerRef={ref}\n toggleButtonType={toggleButtonType}\n className={toggleClassName}\n >\n {title}\n {shouldShowCaret && <Caret />}\n </DropdownToggleButton>\n {splitButton && (\n <SplitCaretButton\n id={id}\n bsStyle={bsStyle}\n bsSize={bsSize}\n disabled={disabled}\n className={toggleClassName}\n onClick={handleSplitCaretButtonClick}\n ref={setRefSplitButtonToggle}\n />\n )}\n {isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot)}\n {isOpen && !usePortal && dropdownMenu}\n </div>\n );\n });\n};\n\nconst ButtonDropdown = createButtonDropdown();\n\nexport default ButtonDropdown;\n"],"names":["getPlacement","pullRight","dropup","createButtonDropdown","forwardRef","props","ref","id","items","bsSize","bsStyle","variant","disabled","iconName","iconOnly","title","splitButton","customDropdown","open","noCaret","onOpen","noop","onClose","onLabelButtonClick","usePortal","popperConfig","toggleButtonType","toggleClassName","dropdownClassName","className","remainingProps","internalOpen","setInternalOpen","useState","refDropdownToggle","setRefDropdownToggle","refDropdownMenu","setRefDropdownMenu","refSplitButtonToggle","setRefSplitButtonToggle","defaultPopperConfig","popperParentRef","styles","attributes","usePopper","isUncontrolled","isNil","isOpen","wrapperRef","useClickOutside","event","closeMenu","DEFAULT_EVENT_TYPES","dropdownRoot","getOrCreatePortalRoot","shouldShowCaret","useEffect","toggleOpen","openMenu","handleSplitLabelButtonClick","handleSplitCaretButtonClick","handleDropdownButtonClick","wrapperClasses","classNames","dropdownClasses","dropdownMenu","jsx","MenuItemList","MenuItems","jsxs","DropdownToggleButton","Caret","SplitCaretButton","ReactDOM","ButtonDropdown"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,KAAe,CAACC,GAAoBC,MAClCD,KAAaC,IACN,YAEP,CAACD,KAAaC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EAAA;AAI3F,2BACK,OAAA,EAAK,GAAG3B,GAAgB,WAAWgC,IAAgB,KAAKd,GACrD,UAAA;AAAA,IAAA,gBAAAqB;AAAA,MAACC;AAAA,MAAA;AAAA,QACG,IAAA/D;AAAA,QACA,aAAAS;AAAA,QACA,SAAAN;AAAA,QACA,QAAAD;AAAA,QACA,SAAAE;AAAA,QACA,UAAAG;AAAA,QACA,UAAAD;AAAA,QACA,UAAAD;AAAA,QACA,KAAKuB;AAAA,QACL,SAAS0B;AAAA,QACT,UAAUvD;AAAA,QACV,kBAAAoB;AAAA,QACA,WAAWC;AAAA,QAEV,UAAA;AAAA,UAAAZ;AAAA,UACAwC,uBAAoBgB,IAAA,CAAA,CAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAE9BvD,KACG,gBAAAkD;AAAA,MAACM;AAAA,MAAA;AAAA,QACG,IAAAjE;AAAA,QACA,SAAAG;AAAA,QACA,QAAAD;AAAA,QACA,UAAAG;AAAA,QACA,WAAWe;AAAA,QACX,SAASiC;AAAA,QACT,KAAKrB;AAAA,MAAA;AAAA,IAAA;AAAA,IAGZQ,KAAUvB,KAAaiD,GAAS,aAAaR,GAAcZ,CAAY;AAAA,IACvEN,KAAU,CAACvB,KAAayC;AAAA,EAAA,GAC7B;AAER,CAAC,GAGCS,KAAiBvE,GAAA;"}
|
|
1
|
+
{"version":3,"file":"ButtonDropdown.js","sources":["../../../src/components/dropdown/ButtonDropdown.tsx"],"sourcesContent":["import React, { useState, useEffect, forwardRef, type PropsWithChildren } from 'react';\nimport ReactDOM from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport { noop } from 'es-toolkit/function';\nimport { isNil } from 'es-toolkit/predicate';\n\nimport classNames from '../../utils/classNames';\nimport { getOrCreatePortalRoot } from '../../utils/portalRoot';\nimport useClickOutside, { DEFAULT_EVENT_TYPES } from '../../hooks/useClickOutside';\nimport MenuItems from '../menuItems/MenuItems';\nimport MenuItemList from '../menuItems/MenuItemList';\nimport DropdownToggleButton, { type DropdownToggleEvent, type DropdownToggleButtonType } from './DropdownToggleButton';\nimport SplitCaretButton from './SplitCaretButton';\nimport Caret from './Caret';\nimport type { MenuItemProps as MenuItem } from '../menuItems/MenuItem';\nimport type { BUTTON_SIZE, BUTTON_STYLE, BUTTON_VARIANT } from '../button/Button';\n\nconst getPlacement = (pullRight: boolean, dropup: boolean) => {\n if (pullRight && dropup) {\n return 'top-end';\n }\n if (!pullRight && dropup) {\n return 'top-start';\n }\n if (pullRight && !dropup) {\n return 'bottom-end';\n }\n return 'bottom-start';\n};\n\nexport type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> = {\n /**\n * Unique button id. If not present a random id is generated.\n */\n id?: string;\n\n /**\n * Accessible label applied to the dropdown toggle button.\n */\n 'aria-label'?: string;\n\n /**\n * The button title. This may be also a node, like a <span> or a <FormattedMessage>.\n */\n title: string | React.ReactNode;\n\n /**\n * Defined weather or not the menu is rendered.\n * Use this to control the component from the outside.\n *\n * @default undefined\n */\n open?: boolean;\n\n /**\n * Defines whether the dropdown opens above or below.\n * Set it to \"true\" additionally disables the automatic position feature.\n *\n * @default false\n */\n dropup?: boolean;\n\n /**\n * Defines whether the dropdown opens right aligned to the dropdown or not.\n */\n pullRight?: boolean;\n\n /**\n * Defines how large the button will be rendered.\n *\n * Possible values are: `xs`, `sm`, `md`, `lg`\n *\n * @default 'md'\n */\n bsSize?: BUTTON_SIZE;\n\n /**\n * Defines the button color.\n *\n * Possible values are: `default`, `primary`, `secondary`, `info`, `warning`, `danger`, `success`, `muted`\n *\n * @default 'default'\n */\n bsStyle?: BUTTON_STYLE;\n\n /**\n * Defines the variation of the button design.\n *\n * Possible values are: `link`, `link-inline`, `outline`, `action`\n */\n variant?: BUTTON_VARIANT;\n\n /**\n * Specify the toggle element type.\n * It supports the following types: \"button\" | \"tag\" | \"label\"\n *\n * @default 'button'\n */\n toggleButtonType?: DropdownToggleButtonType;\n\n /**\n * Optional prop to defines whether the dropdown title is icon only which\n * applies different padding so the button is a square.\n *\n * @default false\n */\n iconOnly?: boolean;\n\n /**\n * Optional rioglyph icon name forwarded to the underlying button toggle.\n */\n iconName?: string;\n\n /**\n * Defines whether the caret is shown or not.\n *\n * @default false\n */\n noCaret?: boolean;\n\n /**\n * Defines whether the dropdown-toggle (with caret) should be in a separate button.\n *\n * @default false\n */\n splitButton?: boolean;\n\n /**\n * Renders the dropdown into a dedicated react portal\n *\n * @default false\n */\n usePortal?: boolean;\n\n /**\n * Items to display in the dropdown menu. If you use a custom dropdown you can skip this prop.\n */\n items?: MenuItem[];\n\n /**\n * Disables the dropdown button.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Callback for splitButton label button click.\n */\n onLabelButtonClick?: () => void;\n\n /**\n * Callback for when the toggle button was clicked to open it.\n * @param event\n * @returns\n */\n onOpen?: (event: DropdownToggleEvent<T>) => void;\n\n /**\n * Callback for when the toggle button was clicked to close it.\n * @returns\n */\n onClose?: () => void;\n\n /**\n * Allows to pass in custom dropdown menu content.\n */\n customDropdown?: React.ReactNode;\n\n /**\n * Define custom popper.js configuration for dropdown placement and modifiers.\n */\n popperConfig?: object;\n\n /**\n * Additional classes to be set on the dropdown-toggle button.\n */\n toggleClassName?: string;\n\n /**\n * Additional classes to be set on the dropdown.\n */\n dropdownClassName?: string;\n\n /**\n * Additional classes to be set to the wrapper element.\n */\n className?: string;\n};\n\nconst createButtonDropdown = <T extends DropdownToggleButtonType = 'button'>() => {\n return forwardRef<\n T extends 'button' ? HTMLButtonElement : HTMLDivElement,\n PropsWithChildren<ButtonDropdownProps<T>>\n >((props, ref) => {\n const {\n id = Math.random().toString(36).slice(2, 16),\n 'aria-label': ariaLabel,\n items = [],\n bsSize = 'md',\n bsStyle = 'default',\n variant,\n disabled = false,\n iconName,\n iconOnly = false,\n title,\n splitButton = false,\n customDropdown,\n open,\n dropup = false,\n pullRight = false,\n noCaret = false,\n onOpen = noop,\n onClose = noop,\n onLabelButtonClick = noop,\n usePortal = false,\n popperConfig,\n toggleButtonType = 'button',\n toggleClassName = '',\n dropdownClassName,\n className = '',\n ...remainingProps\n } = props;\n\n const [internalOpen, setInternalOpen] = useState(open);\n\n const [refDropdownToggle, setRefDropdownToggle] = useState<HTMLButtonElement | HTMLDivElement | null>(null);\n const [refDropdownMenu, setRefDropdownMenu] = useState<HTMLUListElement | null>(null);\n const [refSplitButtonToggle, setRefSplitButtonToggle] = useState<HTMLButtonElement | null>(null);\n\n const defaultPopperConfig = {\n placement: getPlacement(pullRight, dropup),\n modifiers: [],\n };\n\n const popperParentRef = splitButton && pullRight ? refSplitButtonToggle : refDropdownToggle;\n\n const { styles, attributes } = usePopper(popperParentRef, refDropdownMenu, popperConfig || defaultPopperConfig);\n\n const isUncontrolled = isNil(open);\n const isOpen = isUncontrolled ? internalOpen : open;\n\n const wrapperRef = useClickOutside(\n event => {\n if (usePortal) {\n // In case the dropdown is rendered via portal the clickOutside the toggle button element is\n // triggered since the dropdown is not a child of the wrapper element.\n // In this case we need to check if the event target is inside the dropdown-menu and prevent closing\n // the dropdown\n if (!refDropdownMenu?.contains(event.target as Node)) {\n closeMenu();\n }\n } else {\n closeMenu();\n }\n },\n DEFAULT_EVENT_TYPES,\n Boolean(isOpen) // only listen to clicks outside when the dropdown is open\n );\n\n const dropdownRoot = getOrCreatePortalRoot();\n\n const shouldShowCaret = !noCaret && !splitButton && !iconOnly;\n\n useEffect(() => {\n if (!isUncontrolled) {\n setInternalOpen(open);\n }\n }, [isUncontrolled, open]);\n\n const toggleOpen = (event?: DropdownToggleEvent<T>) => {\n const isDropdownOpen = isUncontrolled ? internalOpen : open;\n\n if (isDropdownOpen) {\n closeMenu();\n } else {\n openMenu(event);\n }\n };\n\n const openMenu = (event?: DropdownToggleEvent<T>) => {\n if (isUncontrolled) {\n setInternalOpen(true);\n }\n if (event) {\n onOpen(event);\n }\n };\n\n const closeMenu = () => {\n if (isUncontrolled) {\n setInternalOpen(false);\n }\n onClose();\n };\n\n const handleSplitLabelButtonClick = () => {\n closeMenu();\n onLabelButtonClick();\n };\n\n const handleSplitCaretButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n toggleOpen(event as DropdownToggleEvent<T>);\n };\n\n const handleDropdownButtonClick = (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => {\n if (splitButton) {\n handleSplitLabelButtonClick();\n } else {\n toggleOpen(event as DropdownToggleEvent<T>);\n }\n };\n\n const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);\n\n const dropdownClasses = classNames(\n usePortal && 'dropdown-portal',\n splitButton && pullRight && 'pull-right',\n dropdownClassName\n );\n\n const dropdownMenu = (\n <MenuItemList\n className={dropdownClasses}\n ref={setRefDropdownMenu}\n style={styles.popper}\n {...attributes.popper}\n >\n {customDropdown ? customDropdown : <MenuItems items={items} closeMenu={toggleOpen} />}\n </MenuItemList>\n );\n\n return (\n <div {...remainingProps} className={wrapperClasses} ref={wrapperRef}>\n <DropdownToggleButton\n id={id}\n aria-label={ariaLabel}\n splitButton={splitButton}\n bsStyle={bsStyle}\n bsSize={bsSize}\n variant={variant}\n iconOnly={iconOnly}\n iconName={iconName}\n disabled={disabled}\n ref={setRefDropdownToggle}\n onClick={handleDropdownButtonClick}\n outerRef={ref}\n toggleButtonType={toggleButtonType}\n className={toggleClassName}\n >\n {title}\n {shouldShowCaret && <Caret />}\n </DropdownToggleButton>\n {splitButton && (\n <SplitCaretButton\n id={id}\n bsStyle={bsStyle}\n bsSize={bsSize}\n disabled={disabled}\n className={toggleClassName}\n onClick={handleSplitCaretButtonClick}\n ref={setRefSplitButtonToggle}\n />\n )}\n {isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot)}\n {isOpen && !usePortal && dropdownMenu}\n </div>\n );\n });\n};\n\nconst ButtonDropdown = createButtonDropdown();\n\nexport default ButtonDropdown;\n"],"names":["getPlacement","pullRight","dropup","createButtonDropdown","forwardRef","props","ref","id","ariaLabel","items","bsSize","bsStyle","variant","disabled","iconName","iconOnly","title","splitButton","customDropdown","open","noCaret","onOpen","noop","onClose","onLabelButtonClick","usePortal","popperConfig","toggleButtonType","toggleClassName","dropdownClassName","className","remainingProps","internalOpen","setInternalOpen","useState","refDropdownToggle","setRefDropdownToggle","refDropdownMenu","setRefDropdownMenu","refSplitButtonToggle","setRefSplitButtonToggle","defaultPopperConfig","popperParentRef","styles","attributes","usePopper","isUncontrolled","isNil","isOpen","wrapperRef","useClickOutside","event","closeMenu","DEFAULT_EVENT_TYPES","dropdownRoot","getOrCreatePortalRoot","shouldShowCaret","useEffect","toggleOpen","openMenu","handleSplitLabelButtonClick","handleSplitCaretButtonClick","handleDropdownButtonClick","wrapperClasses","classNames","dropdownClasses","dropdownMenu","jsx","MenuItemList","MenuItems","jsxs","DropdownToggleButton","Caret","SplitCaretButton","ReactDOM","ButtonDropdown"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,KAAe,CAACC,GAAoBC,MAClCD,KAAaC,IACN,YAEP,CAACD,KAAaC,IACP,cAEPD,KAAa,CAACC,IACP,eAEJ,gBAmKLC,KAAuB,MAClBC,GAGL,CAACC,GAAOC,MAAQ;AACd,QAAM;AAAA,IACF,IAAAC,IAAK,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE;AAAA,IAC3C,cAAcC;AAAA,IACd,OAAAC,IAAQ,CAAA;AAAA,IACR,QAAAC,IAAS;AAAA,IACT,SAAAC,IAAU;AAAA,IACV,SAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,gBAAAC;AAAA,IACA,MAAAC;AAAA,IACA,QAAAjB,IAAS;AAAA,IACT,WAAAD,IAAY;AAAA,IACZ,SAAAmB,IAAU;AAAA,IACV,QAAAC,IAASC;AAAA,IACT,SAAAC,IAAUD;AAAA,IACV,oBAAAE,IAAqBF;AAAA,IACrB,WAAAG,IAAY;AAAA,IACZ,c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