@stratakit/structures 0.4.5 → 0.5.1
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/CHANGELOG.md +74 -0
- package/dist/AccordionItem.d.ts +1 -1
- package/dist/AccordionItem.js +69 -124
- package/dist/Banner.js +149 -120
- package/dist/Chip.js +86 -58
- package/dist/DEV/AccordionItem.js +2 -0
- package/dist/DEV/Banner.js +3 -0
- package/dist/DEV/Chip.js +3 -0
- package/dist/DEV/Dialog.js +2 -0
- package/dist/DEV/DropdownMenu.js +2 -0
- package/dist/DEV/ErrorRegion.js +5 -11
- package/dist/DEV/NavigationList.js +130 -0
- package/dist/DEV/NavigationRail.js +6 -4
- package/dist/DEV/Popover.js +90 -0
- package/dist/DEV/Table.js +3 -0
- package/dist/DEV/Tabs.js +3 -1
- package/dist/DEV/Toolbar.js +2 -0
- package/dist/DEV/Tree.js +2 -0
- package/dist/DEV/TreeItem.js +7 -2
- package/dist/DEV/index.js +4 -0
- package/dist/DEV/styles.css.js +1 -1
- package/dist/DEV/~utils.ListItem.js +3 -3
- package/dist/DEV/~utils.useInit.js +16 -0
- package/dist/Dialog.js +142 -132
- package/dist/DropdownMenu.js +217 -234
- package/dist/ErrorRegion.d.ts +18 -8
- package/dist/ErrorRegion.js +129 -154
- package/dist/NavigationList.d.ts +110 -0
- package/dist/NavigationList.js +130 -0
- package/dist/NavigationRail.js +211 -188
- package/dist/Popover.d.ts +36 -0
- package/dist/Popover.js +99 -0
- package/dist/Table.js +119 -108
- package/dist/Tabs.js +100 -63
- package/dist/Toolbar.js +25 -43
- package/dist/Tree.js +15 -12
- package/dist/TreeItem.js +398 -314
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/styles.css.js +1 -1
- package/dist/~utils.ListItem.d.ts +3 -3
- package/dist/~utils.ListItem.js +21 -34
- package/dist/~utils.icons.js +26 -46
- package/dist/~utils.useInit.d.ts +8 -0
- package/dist/~utils.useInit.js +13 -0
- package/package.json +25 -18
package/dist/NavigationRail.js
CHANGED
|
@@ -1,218 +1,241 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { Button } from "@ariakit/react/button";
|
|
4
5
|
import { Role } from "@ariakit/react/role";
|
|
5
6
|
import { Tooltip, VisuallyHidden } from "@stratakit/bricks";
|
|
6
7
|
import { Icon } from "@stratakit/foundations";
|
|
7
|
-
import {
|
|
8
|
-
forwardRef,
|
|
9
|
-
useEventHandlers,
|
|
10
|
-
useSafeContext,
|
|
11
|
-
useUnreactiveCallback
|
|
12
|
-
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
import { forwardRef, useEventHandlers, useSafeContext, useUnreactiveCallback } from "@stratakit/foundations/secret-internals";
|
|
13
9
|
import cx from "classnames";
|
|
14
10
|
import { createStore, useStore } from "zustand";
|
|
15
11
|
import { combine } from "zustand/middleware";
|
|
12
|
+
import { useInit } from "./~utils.useInit.js";
|
|
16
13
|
function createNavigationRailStore(initialState) {
|
|
17
|
-
return createStore(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
);
|
|
14
|
+
return createStore(combine(initialState, (set) => ({
|
|
15
|
+
setExpanded: (expanded) => set({
|
|
16
|
+
expanded
|
|
17
|
+
})
|
|
18
|
+
})));
|
|
22
19
|
}
|
|
23
20
|
const NavigationRailContext = React.createContext(void 0);
|
|
24
21
|
function NavigationRailProvider(props) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
const $ = _c(11);
|
|
23
|
+
const {
|
|
24
|
+
defaultExpanded,
|
|
25
|
+
expanded,
|
|
26
|
+
setExpanded: setExpandedProp
|
|
27
|
+
} = props;
|
|
28
|
+
let t0;
|
|
29
|
+
if ($[0] !== defaultExpanded || $[1] !== expanded) {
|
|
30
|
+
t0 = () => createNavigationRailStore({
|
|
31
|
+
expanded: expanded ?? defaultExpanded
|
|
32
|
+
});
|
|
33
|
+
$[0] = defaultExpanded;
|
|
34
|
+
$[1] = expanded;
|
|
35
|
+
$[2] = t0;
|
|
36
|
+
} else {
|
|
37
|
+
t0 = $[2];
|
|
38
|
+
}
|
|
39
|
+
const [store] = React.useState(t0);
|
|
40
|
+
const setExpanded = useUnreactiveCallback(setExpandedProp ?? _temp);
|
|
41
|
+
let t1;
|
|
42
|
+
let t2;
|
|
43
|
+
if ($[3] !== expanded || $[4] !== setExpanded || $[5] !== store) {
|
|
44
|
+
t1 = function synchronizeWithProps() {
|
|
45
|
+
if (expanded === void 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
store.setState({
|
|
49
|
+
expanded,
|
|
50
|
+
setExpanded
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
t2 = [store, expanded, setExpanded];
|
|
54
|
+
$[3] = expanded;
|
|
55
|
+
$[4] = setExpanded;
|
|
56
|
+
$[5] = store;
|
|
57
|
+
$[6] = t1;
|
|
58
|
+
$[7] = t2;
|
|
59
|
+
} else {
|
|
60
|
+
t1 = $[6];
|
|
61
|
+
t2 = $[7];
|
|
62
|
+
}
|
|
63
|
+
React.useEffect(t1, t2);
|
|
64
|
+
let t3;
|
|
65
|
+
if ($[8] !== props.children || $[9] !== store) {
|
|
66
|
+
t3 = jsx(NavigationRailContext.Provider, {
|
|
67
|
+
value: store,
|
|
68
|
+
children: props.children
|
|
69
|
+
});
|
|
70
|
+
$[8] = props.children;
|
|
71
|
+
$[9] = store;
|
|
72
|
+
$[10] = t3;
|
|
73
|
+
} else {
|
|
74
|
+
t3 = $[10];
|
|
75
|
+
}
|
|
76
|
+
return t3;
|
|
77
|
+
}
|
|
78
|
+
function _temp() {
|
|
39
79
|
}
|
|
40
80
|
function useNavigationRailState(selectorFn) {
|
|
41
81
|
const store = useSafeContext(NavigationRailContext);
|
|
42
82
|
return useStore(store, selectorFn);
|
|
43
83
|
}
|
|
44
|
-
const NavigationRailRoot = forwardRef(
|
|
45
|
-
(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
const
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"data-_sk-expanded": expanded ? "true" : void 0,
|
|
81
|
-
ref: forwardedRef
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
);
|
|
84
|
+
const NavigationRailRoot = forwardRef((props, forwardedRef) => {
|
|
85
|
+
useInit();
|
|
86
|
+
const {
|
|
87
|
+
defaultExpanded = false,
|
|
88
|
+
expanded,
|
|
89
|
+
setExpanded,
|
|
90
|
+
...rest
|
|
91
|
+
} = props;
|
|
92
|
+
return /* @__PURE__ */ jsx(NavigationRailProvider, {
|
|
93
|
+
defaultExpanded,
|
|
94
|
+
expanded,
|
|
95
|
+
setExpanded,
|
|
96
|
+
children: /* @__PURE__ */ jsx(NavigationRailRootInner, {
|
|
97
|
+
...rest,
|
|
98
|
+
ref: forwardedRef
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const NavigationRailRootInner = forwardRef((props, forwardedRef) => {
|
|
103
|
+
const expanded = useNavigationRailState((state) => state.expanded);
|
|
104
|
+
return /* @__PURE__ */ jsx(Role.nav, {
|
|
105
|
+
...props,
|
|
106
|
+
className: cx("\u{1F95D}NavigationRail", props.className),
|
|
107
|
+
"data-_sk-expanded": expanded ? "true" : void 0,
|
|
108
|
+
ref: forwardedRef
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const NavigationRailHeader = forwardRef((props, forwardedRef) => {
|
|
112
|
+
const expanded = useNavigationRailState((state) => state.expanded);
|
|
113
|
+
return /* @__PURE__ */ jsx(Role.header, {
|
|
114
|
+
...props,
|
|
115
|
+
className: cx("\u{1F95D}NavigationRailHeader", props.className),
|
|
116
|
+
"data-_sk-expanded": expanded ? "true" : void 0,
|
|
117
|
+
ref: forwardedRef
|
|
118
|
+
});
|
|
119
|
+
});
|
|
86
120
|
const NavigationRailToggleButton = forwardRef((props, forwardedRef) => {
|
|
87
|
-
const {
|
|
121
|
+
const {
|
|
122
|
+
label = "Expand navigation",
|
|
123
|
+
...rest
|
|
124
|
+
} = props;
|
|
88
125
|
const expanded = useNavigationRailState((state) => state.expanded);
|
|
89
|
-
const setExpanded = useNavigationRailState((
|
|
90
|
-
return /* @__PURE__ */ jsxs(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
const setExpanded = useNavigationRailState((state_0) => state_0.setExpanded);
|
|
127
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
128
|
+
"aria-expanded": expanded ? "true" : "false",
|
|
129
|
+
...rest,
|
|
130
|
+
className: cx("\u{1F95D}NavigationRailToggleButton", props.className),
|
|
131
|
+
ref: forwardedRef,
|
|
132
|
+
onClick: useEventHandlers(props.onClick, () => setExpanded(!expanded)),
|
|
133
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
134
|
+
width: "12",
|
|
135
|
+
height: "12",
|
|
136
|
+
fill: "none",
|
|
137
|
+
"aria-hidden": "true",
|
|
138
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
139
|
+
fill: "currentColor",
|
|
140
|
+
d: "M5.405 2.845a.75.75 0 1 0-1.06 1.06L6.439 6 4.345 8.095a.75.75 0 0 0 1.06 1.06L8.03 6.53a.75.75 0 0 0 0-1.06L5.405 2.845Z"
|
|
141
|
+
})
|
|
142
|
+
}), /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
143
|
+
children: label
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
const NavigationRailContent = forwardRef((props, forwardedRef) => {
|
|
148
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
149
|
+
...props,
|
|
150
|
+
className: cx("\u{1F95D}NavigationRailContent", props.className),
|
|
151
|
+
ref: forwardedRef
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
const NavigationRailList = forwardRef((props, forwardedRef) => {
|
|
155
|
+
return /* @__PURE__ */ jsx(Role, {
|
|
156
|
+
role: "list",
|
|
157
|
+
...props,
|
|
158
|
+
className: cx("\u{1F95D}NavigationRailList", props.className),
|
|
159
|
+
ref: forwardedRef
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
const NavigationRailListItem = forwardRef((props, forwardedRef) => {
|
|
163
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
164
|
+
role: "listitem",
|
|
165
|
+
...props,
|
|
166
|
+
className: cx("\u{1F95D}NavigationRailListItem", props.className),
|
|
167
|
+
ref: forwardedRef
|
|
168
|
+
});
|
|
110
169
|
});
|
|
111
|
-
const NavigationRailContent = forwardRef(
|
|
112
|
-
(props, forwardedRef) => {
|
|
113
|
-
return /* @__PURE__ */ jsx(
|
|
114
|
-
Role.div,
|
|
115
|
-
{
|
|
116
|
-
...props,
|
|
117
|
-
className: cx("\u{1F95D}NavigationRailContent", props.className),
|
|
118
|
-
ref: forwardedRef
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
const NavigationRailList = forwardRef(
|
|
124
|
-
(props, forwardedRef) => {
|
|
125
|
-
return /* @__PURE__ */ jsx(
|
|
126
|
-
Role,
|
|
127
|
-
{
|
|
128
|
-
role: "list",
|
|
129
|
-
...props,
|
|
130
|
-
className: cx("\u{1F95D}NavigationRailList", props.className),
|
|
131
|
-
ref: forwardedRef
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
const NavigationRailListItem = forwardRef(
|
|
137
|
-
(props, forwardedRef) => {
|
|
138
|
-
return /* @__PURE__ */ jsx(
|
|
139
|
-
Role.div,
|
|
140
|
-
{
|
|
141
|
-
role: "listitem",
|
|
142
|
-
...props,
|
|
143
|
-
className: cx("\u{1F95D}NavigationRailListItem", props.className),
|
|
144
|
-
ref: forwardedRef
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
170
|
const NavigationRailItemAction = forwardRef((props, forwardedRef) => {
|
|
150
171
|
const expanded = useNavigationRailState((state) => state.expanded);
|
|
151
|
-
const {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
);
|
|
172
|
+
const {
|
|
173
|
+
label,
|
|
174
|
+
icon,
|
|
175
|
+
...rest
|
|
176
|
+
} = props;
|
|
177
|
+
const action = /* @__PURE__ */ jsxs(Role, {
|
|
178
|
+
...rest,
|
|
179
|
+
className: cx("\u{1F95D}NavigationRailItemAction", props.className),
|
|
180
|
+
ref: forwardedRef,
|
|
181
|
+
children: [typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, {
|
|
182
|
+
href: icon
|
|
183
|
+
}) : icon, /* @__PURE__ */ jsx(Role.span, {
|
|
184
|
+
className: "\u{1F95D}NavigationRailItemActionLabel",
|
|
185
|
+
render: !expanded ? /* @__PURE__ */ jsx(VisuallyHidden, {}) : void 0,
|
|
186
|
+
children: label
|
|
187
|
+
})]
|
|
188
|
+
});
|
|
171
189
|
if (!expanded) {
|
|
172
|
-
return /* @__PURE__ */ jsx(Tooltip, {
|
|
190
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
191
|
+
content: label,
|
|
192
|
+
placement: "right",
|
|
193
|
+
type: "none",
|
|
194
|
+
children: action
|
|
195
|
+
});
|
|
173
196
|
}
|
|
174
197
|
return action;
|
|
175
198
|
});
|
|
176
|
-
const NavigationRailAnchor = forwardRef(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
);
|
|
199
|
+
const NavigationRailAnchor = forwardRef((props, forwardedRef) => {
|
|
200
|
+
const {
|
|
201
|
+
label,
|
|
202
|
+
icon,
|
|
203
|
+
active,
|
|
204
|
+
...rest
|
|
205
|
+
} = props;
|
|
206
|
+
return /* @__PURE__ */ jsx(NavigationRailItemAction, {
|
|
207
|
+
label,
|
|
208
|
+
icon,
|
|
209
|
+
"aria-current": active ? "true" : void 0,
|
|
210
|
+
render: /* @__PURE__ */ jsx(Role.a, {
|
|
211
|
+
...rest,
|
|
212
|
+
ref: forwardedRef
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
const NavigationRailButton = forwardRef((props, forwardedRef) => {
|
|
217
|
+
const {
|
|
218
|
+
label,
|
|
219
|
+
icon,
|
|
220
|
+
...rest
|
|
221
|
+
} = props;
|
|
222
|
+
return /* @__PURE__ */ jsx(NavigationRailItemAction, {
|
|
223
|
+
label,
|
|
224
|
+
icon,
|
|
225
|
+
render: /* @__PURE__ */ jsx(Role.button, {
|
|
226
|
+
...rest,
|
|
227
|
+
ref: forwardedRef
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
const NavigationRailFooter = forwardRef((props, forwardedRef) => {
|
|
232
|
+
return /* @__PURE__ */ jsx(Role, {
|
|
233
|
+
render: /* @__PURE__ */ jsx("footer", {}),
|
|
234
|
+
...props,
|
|
235
|
+
className: cx("\u{1F95D}NavigationRailFooter", props.className),
|
|
236
|
+
ref: forwardedRef
|
|
237
|
+
});
|
|
238
|
+
});
|
|
216
239
|
export {
|
|
217
240
|
NavigationRailAnchor as Anchor,
|
|
218
241
|
NavigationRailButton as Button,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as AkPopover from "@ariakit/react/popover";
|
|
3
|
+
import type { BaseProps } from "@stratakit/foundations/secret-internals";
|
|
4
|
+
interface PopoverProviderProps extends Pick<AkPopover.PopoverProviderProps, "children" | "open" | "setOpen" | "placement"> {
|
|
5
|
+
}
|
|
6
|
+
interface PopoverRootProps extends BaseProps, Pick<AkPopover.PopoverProps, "unmountOnHide"> {
|
|
7
|
+
}
|
|
8
|
+
interface PopoverProps extends Omit<BaseProps, "content">, Pick<PopoverProviderProps, "open" | "setOpen" | "placement">, Pick<PopoverRootProps, "unmountOnHide"> {
|
|
9
|
+
/**
|
|
10
|
+
* The element that will trigger the popover when clicked.
|
|
11
|
+
* Common examples include buttons, links, or form controls.
|
|
12
|
+
*
|
|
13
|
+
* **Note**: The trigger must be a single interactive element. Do not add a
|
|
14
|
+
* popover to a non-interactive static element (such as a `<div>` or `<svg>`). Also,
|
|
15
|
+
* the trigger element must forward its ref and spread its props.
|
|
16
|
+
*/
|
|
17
|
+
children: React.ReactElement;
|
|
18
|
+
/**
|
|
19
|
+
* The content to be displayed inside the popover when the trigger element is hovered or focused.
|
|
20
|
+
*/
|
|
21
|
+
content: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A component used to display content in a non-modal window overlay that is placed relative to a trigger element.
|
|
25
|
+
*
|
|
26
|
+
* Example:
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Popover
|
|
29
|
+
* content={<>Content</>}
|
|
30
|
+
* >
|
|
31
|
+
* <Button>Open</Button>
|
|
32
|
+
* </Popover>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
|
|
36
|
+
export default Popover;
|
package/dist/Popover.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as AkPopover from "@ariakit/react/popover";
|
|
4
|
+
import { PortalContext } from "@ariakit/react/portal";
|
|
5
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
6
|
+
import { Button } from "@stratakit/bricks";
|
|
7
|
+
import { forwardRef, usePopoverApi } from "@stratakit/foundations/secret-internals";
|
|
8
|
+
import cx from "classnames";
|
|
9
|
+
import { useInit } from "./~utils.useInit.js";
|
|
10
|
+
function PopoverProvider(props) {
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
open,
|
|
14
|
+
setOpen,
|
|
15
|
+
placement = "bottom-start"
|
|
16
|
+
} = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(AkPopover.PopoverProvider, {
|
|
18
|
+
open,
|
|
19
|
+
setOpen,
|
|
20
|
+
placement,
|
|
21
|
+
children
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const PopoverDisclosure = forwardRef((props, forwardedRef) => {
|
|
25
|
+
const store = AkPopover.usePopoverContext();
|
|
26
|
+
const open = useStoreState(store, "open");
|
|
27
|
+
const defaultId = React.useId();
|
|
28
|
+
return /* @__PURE__ */ jsx(AkPopover.PopoverDisclosure, {
|
|
29
|
+
id: defaultId,
|
|
30
|
+
render: /* @__PURE__ */ jsx(Button, {}),
|
|
31
|
+
...props,
|
|
32
|
+
"data-has-popover-open": open || void 0,
|
|
33
|
+
ref: forwardedRef
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const PopoverRoot = forwardRef((props, forwardedRef) => {
|
|
37
|
+
const {
|
|
38
|
+
children,
|
|
39
|
+
unmountOnHide,
|
|
40
|
+
...rest
|
|
41
|
+
} = props;
|
|
42
|
+
const store = AkPopover.usePopoverContext();
|
|
43
|
+
const popoverElement = useStoreState(store, "popoverElement");
|
|
44
|
+
const open = useStoreState(store, "open");
|
|
45
|
+
const popoverProps = usePopoverApi({
|
|
46
|
+
element: popoverElement,
|
|
47
|
+
open
|
|
48
|
+
});
|
|
49
|
+
const contentElement = useStoreState(store, "contentElement");
|
|
50
|
+
const triggerId = useStoreState(store, (state) => state?.disclosureElement?.id);
|
|
51
|
+
const labelledBy = props["aria-label"] ? void 0 : triggerId;
|
|
52
|
+
return /* @__PURE__ */ jsx(AkPopover.Popover, {
|
|
53
|
+
"aria-labelledby": labelledBy,
|
|
54
|
+
portal: true,
|
|
55
|
+
unmountOnHide,
|
|
56
|
+
...rest,
|
|
57
|
+
gutter: 8,
|
|
58
|
+
style: {
|
|
59
|
+
...popoverProps.style,
|
|
60
|
+
...props.style
|
|
61
|
+
},
|
|
62
|
+
wrapperProps: {
|
|
63
|
+
popover: popoverProps.popover
|
|
64
|
+
},
|
|
65
|
+
className: cx("\u{1F95D}Popover", props.className),
|
|
66
|
+
ref: forwardedRef,
|
|
67
|
+
children: /* @__PURE__ */ jsx(PortalContext.Provider, {
|
|
68
|
+
value: contentElement ?? null,
|
|
69
|
+
children
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
const Popover = forwardRef((props, forwardedRef) => {
|
|
74
|
+
useInit();
|
|
75
|
+
const {
|
|
76
|
+
children,
|
|
77
|
+
content,
|
|
78
|
+
open,
|
|
79
|
+
setOpen,
|
|
80
|
+
placement,
|
|
81
|
+
...rest
|
|
82
|
+
} = props;
|
|
83
|
+
return /* @__PURE__ */ jsxs(PopoverProvider, {
|
|
84
|
+
open,
|
|
85
|
+
setOpen,
|
|
86
|
+
placement,
|
|
87
|
+
children: [/* @__PURE__ */ jsx(PopoverDisclosure, {
|
|
88
|
+
render: children
|
|
89
|
+
}), /* @__PURE__ */ jsx(PopoverRoot, {
|
|
90
|
+
...rest,
|
|
91
|
+
ref: forwardedRef,
|
|
92
|
+
children: content
|
|
93
|
+
})]
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
var Popover_default = Popover;
|
|
97
|
+
export {
|
|
98
|
+
Popover_default as default
|
|
99
|
+
};
|