@sproutsocial/seeds-react-panel 1.0.10 → 1.1.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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +29 -0
- package/dist/esm/index.js +445 -164
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +28 -7
- package/dist/index.d.ts +28 -7
- package/dist/index.js +449 -168
- package/dist/index.js.map +1 -1
- package/dist/panel.css +92 -0
- package/package.json +16 -8
- package/src/Panel.stories.tsx +33 -0
- package/src/Panel.tsx +13 -137
- package/src/PanelContent.tsx +67 -1
- package/src/PanelFooter.tsx +48 -1
- package/src/PanelHeader.tsx +66 -17
- package/src/PanelHybrid.tsx +52 -0
- package/src/PanelMobile.tsx +90 -0
- package/src/PanelMobileActionsHeader.tsx +8 -12
- package/src/PanelShared.tsx +189 -0
- package/src/PanelStyled.tsx +62 -0
- package/src/PanelTailwind.tsx +86 -0
- package/src/__tests__/Panel.test.tsx +47 -1
- package/src/css.d.ts +1 -0
- package/src/panel.css +92 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import
|
|
3
|
-
import Drawer2 from "@sproutsocial/seeds-react-drawer";
|
|
4
|
-
import { useIsMobile } from "@sproutsocial/seeds-react-hooks";
|
|
1
|
+
// src/PanelHybrid.tsx
|
|
2
|
+
import { needsStyledComponents as needsStyledComponents3 } from "@sproutsocial/seeds-react-system-props";
|
|
5
3
|
|
|
6
4
|
// src/PanelContext.tsx
|
|
7
5
|
import * as React from "react";
|
|
@@ -19,6 +17,7 @@ var usePanelContext = () => {
|
|
|
19
17
|
// src/PanelHeader.tsx
|
|
20
18
|
import Box from "@sproutsocial/seeds-react-box";
|
|
21
19
|
import Text from "@sproutsocial/seeds-react-text";
|
|
20
|
+
import { needsStyledComponents } from "@sproutsocial/seeds-react-system-props";
|
|
22
21
|
|
|
23
22
|
// src/PanelCloseButton.tsx
|
|
24
23
|
import "react";
|
|
@@ -43,41 +42,169 @@ var PanelCloseButton = (props) => {
|
|
|
43
42
|
};
|
|
44
43
|
PanelCloseButton.displayName = "Panel.CloseButton";
|
|
45
44
|
|
|
45
|
+
// src/PanelShared.tsx
|
|
46
|
+
import * as React3 from "react";
|
|
47
|
+
import { useIsMobile } from "@sproutsocial/seeds-react-hooks";
|
|
48
|
+
function cn(...inputs) {
|
|
49
|
+
const classes = [];
|
|
50
|
+
for (const input of inputs) {
|
|
51
|
+
if (!input) continue;
|
|
52
|
+
if (typeof input === "string") {
|
|
53
|
+
classes.push(input);
|
|
54
|
+
} else if (typeof input === "object") {
|
|
55
|
+
for (const [key, value] of Object.entries(input)) {
|
|
56
|
+
if (value) {
|
|
57
|
+
classes.push(key);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return classes.join(" ");
|
|
63
|
+
}
|
|
64
|
+
var getPanelContainerStyle = (direction, width, gap, isPanelOpen) => {
|
|
65
|
+
const gapValue = isPanelOpen && gap ? `${gap}px` : "0px";
|
|
66
|
+
const style = {
|
|
67
|
+
flexBasis: isPanelOpen ? `${width}px` : "0px"
|
|
68
|
+
};
|
|
69
|
+
if (direction === "bottom") {
|
|
70
|
+
style.width = "100%";
|
|
71
|
+
} else {
|
|
72
|
+
style.alignSelf = "stretch";
|
|
73
|
+
}
|
|
74
|
+
if (direction === "right") {
|
|
75
|
+
style.marginLeft = gapValue;
|
|
76
|
+
} else if (direction === "left") {
|
|
77
|
+
style.marginRight = gapValue;
|
|
78
|
+
} else {
|
|
79
|
+
style.marginTop = gapValue;
|
|
80
|
+
}
|
|
81
|
+
return style;
|
|
82
|
+
};
|
|
83
|
+
var getPanelInnerStyle = (direction, width) => direction === "bottom" ? { minHeight: `${width}px`, width: "100%" } : { minWidth: `${width}px`, height: "100%" };
|
|
84
|
+
var usePanelShell = (props) => {
|
|
85
|
+
const {
|
|
86
|
+
children,
|
|
87
|
+
closeButtonLabel,
|
|
88
|
+
header,
|
|
89
|
+
headerless = false,
|
|
90
|
+
footer,
|
|
91
|
+
title,
|
|
92
|
+
titleId,
|
|
93
|
+
direction = "right",
|
|
94
|
+
width = 384,
|
|
95
|
+
gap = 4,
|
|
96
|
+
mobileBreakpoint,
|
|
97
|
+
zIndex,
|
|
98
|
+
id,
|
|
99
|
+
snapPoints,
|
|
100
|
+
defaultSnapPoint,
|
|
101
|
+
snapPoint,
|
|
102
|
+
onSnapPointChange,
|
|
103
|
+
snapToSequentialPoints,
|
|
104
|
+
actions,
|
|
105
|
+
actionsInHeader,
|
|
106
|
+
"aria-labelledby": ariaLabelledByProp,
|
|
107
|
+
"aria-label": ariaLabel,
|
|
108
|
+
...rest
|
|
109
|
+
} = props;
|
|
110
|
+
const panelContext = usePanelContext();
|
|
111
|
+
const { isPanelOpen, closePanel } = panelContext;
|
|
112
|
+
const isMobile = useIsMobile(mobileBreakpoint);
|
|
113
|
+
const enrichedValue = React3.useMemo(
|
|
114
|
+
() => ({ ...panelContext, closeButtonLabel, headerless }),
|
|
115
|
+
[panelContext, closeButtonLabel, headerless]
|
|
116
|
+
);
|
|
117
|
+
const prevChildrenRef = React3.useRef(null);
|
|
118
|
+
if (isPanelOpen) {
|
|
119
|
+
prevChildrenRef.current = children;
|
|
120
|
+
}
|
|
121
|
+
const renderedChildren = isPanelOpen ? children : prevChildrenRef.current;
|
|
122
|
+
const effectiveAriaLabelledBy = ariaLabelledByProp ?? (!headerless && header == null ? titleId : void 0);
|
|
123
|
+
return {
|
|
124
|
+
rest,
|
|
125
|
+
children,
|
|
126
|
+
closeButtonLabel,
|
|
127
|
+
header,
|
|
128
|
+
headerless,
|
|
129
|
+
footer,
|
|
130
|
+
title,
|
|
131
|
+
titleId,
|
|
132
|
+
direction,
|
|
133
|
+
width,
|
|
134
|
+
gap,
|
|
135
|
+
zIndex,
|
|
136
|
+
id,
|
|
137
|
+
snapPoints,
|
|
138
|
+
defaultSnapPoint,
|
|
139
|
+
snapPoint,
|
|
140
|
+
onSnapPointChange,
|
|
141
|
+
snapToSequentialPoints,
|
|
142
|
+
actions,
|
|
143
|
+
actionsInHeader,
|
|
144
|
+
ariaLabel,
|
|
145
|
+
isPanelOpen,
|
|
146
|
+
closePanel,
|
|
147
|
+
isMobile,
|
|
148
|
+
enrichedValue,
|
|
149
|
+
renderedChildren,
|
|
150
|
+
effectiveAriaLabelledBy
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
46
154
|
// src/PanelHeader.tsx
|
|
47
155
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
48
|
-
var
|
|
156
|
+
var PanelHeaderStyled = ({
|
|
157
|
+
title = "",
|
|
158
|
+
id = void 0,
|
|
159
|
+
children,
|
|
160
|
+
render,
|
|
161
|
+
...rest
|
|
162
|
+
}) => /* @__PURE__ */ jsx2(
|
|
163
|
+
Box,
|
|
164
|
+
{
|
|
165
|
+
display: "flex",
|
|
166
|
+
flex: "0 0 auto",
|
|
167
|
+
justifyContent: "space-between",
|
|
168
|
+
alignItems: "center",
|
|
169
|
+
p: 400,
|
|
170
|
+
borderBottom: "1px solid",
|
|
171
|
+
borderColor: "container.border.base",
|
|
172
|
+
...rest,
|
|
173
|
+
children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ jsx2(Text.Headline, { id, children: title }),
|
|
175
|
+
/* @__PURE__ */ jsx2(PanelCloseButton, {})
|
|
176
|
+
] })
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
var PanelHeaderTailwind = ({
|
|
49
180
|
title = "",
|
|
50
181
|
id = void 0,
|
|
51
182
|
children,
|
|
52
183
|
render,
|
|
53
184
|
...rest
|
|
54
185
|
}) => {
|
|
186
|
+
const { className, ...domRest } = rest;
|
|
187
|
+
return /* @__PURE__ */ jsx2("div", { className: cn("seeds-panel-header", className), ...domRest, children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
188
|
+
/* @__PURE__ */ jsx2(Text.Headline, { id, children: title }),
|
|
189
|
+
/* @__PURE__ */ jsx2(PanelCloseButton, {})
|
|
190
|
+
] }) });
|
|
191
|
+
};
|
|
192
|
+
var PanelHeader = (props) => {
|
|
55
193
|
const panelContext = usePanelContext();
|
|
56
|
-
if (render) {
|
|
57
|
-
return render(panelContext);
|
|
194
|
+
if (props.render) {
|
|
195
|
+
return props.render(panelContext);
|
|
58
196
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
justifyContent: "space-between",
|
|
65
|
-
alignItems: "center",
|
|
66
|
-
p: 400,
|
|
67
|
-
borderBottom: "1px solid",
|
|
68
|
-
borderColor: "container.border.base",
|
|
69
|
-
...rest,
|
|
70
|
-
children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
-
/* @__PURE__ */ jsx2(Text.Headline, { id, children: title }),
|
|
72
|
-
/* @__PURE__ */ jsx2(PanelCloseButton, {})
|
|
73
|
-
] })
|
|
74
|
-
}
|
|
75
|
-
);
|
|
197
|
+
const { title, id, children, render, ...rest } = props;
|
|
198
|
+
if (needsStyledComponents(rest)) {
|
|
199
|
+
return /* @__PURE__ */ jsx2(PanelHeaderStyled, { ...props });
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ jsx2(PanelHeaderTailwind, { ...props });
|
|
76
202
|
};
|
|
77
203
|
PanelHeader.displayName = "Panel.Header";
|
|
78
204
|
|
|
79
205
|
// src/PanelContent.tsx
|
|
80
206
|
import "react";
|
|
207
|
+
import { needsStyledComponents as needsStyledComponents2 } from "@sproutsocial/seeds-react-system-props";
|
|
81
208
|
|
|
82
209
|
// src/styles.ts
|
|
83
210
|
import styled, { css } from "styled-components";
|
|
@@ -149,7 +276,7 @@ var Footer = styled(Box2)`
|
|
|
149
276
|
|
|
150
277
|
// src/PanelContent.tsx
|
|
151
278
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
152
|
-
var
|
|
279
|
+
var PanelContentStyled = ({ children, ...rest }) => {
|
|
153
280
|
const { headerless } = usePanelContext();
|
|
154
281
|
return /* @__PURE__ */ jsx3(
|
|
155
282
|
Content,
|
|
@@ -165,157 +292,191 @@ var PanelContent = ({ children, ...rest }) => {
|
|
|
165
292
|
}
|
|
166
293
|
);
|
|
167
294
|
};
|
|
295
|
+
var PanelContentTailwind = ({
|
|
296
|
+
children,
|
|
297
|
+
...rest
|
|
298
|
+
}) => {
|
|
299
|
+
const { headerless } = usePanelContext();
|
|
300
|
+
const scroll = !headerless;
|
|
301
|
+
const { className, style, ...domRest } = rest;
|
|
302
|
+
const contentStyle = {
|
|
303
|
+
overflowY: scroll ? "auto" : "hidden"
|
|
304
|
+
};
|
|
305
|
+
if (!scroll) {
|
|
306
|
+
contentStyle.display = "flex";
|
|
307
|
+
contentStyle.flexDirection = "column";
|
|
308
|
+
}
|
|
309
|
+
Object.assign(contentStyle, style);
|
|
310
|
+
return /* @__PURE__ */ jsx3(
|
|
311
|
+
"div",
|
|
312
|
+
{
|
|
313
|
+
className: cn(
|
|
314
|
+
"seeds-panel-content",
|
|
315
|
+
{ "seeds-panel-content--headerless": !!headerless },
|
|
316
|
+
className
|
|
317
|
+
),
|
|
318
|
+
style: contentStyle,
|
|
319
|
+
"data-panel-content": "",
|
|
320
|
+
...domRest,
|
|
321
|
+
children
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
};
|
|
325
|
+
var PanelContent = (props) => {
|
|
326
|
+
const { children, ...rest } = props;
|
|
327
|
+
if (needsStyledComponents2(rest)) {
|
|
328
|
+
return /* @__PURE__ */ jsx3(PanelContentStyled, { ...props });
|
|
329
|
+
}
|
|
330
|
+
return /* @__PURE__ */ jsx3(PanelContentTailwind, { ...props });
|
|
331
|
+
};
|
|
168
332
|
PanelContent.displayName = "Panel.Content";
|
|
169
333
|
|
|
170
|
-
// src/
|
|
334
|
+
// src/PanelMobile.tsx
|
|
171
335
|
import "react";
|
|
172
|
-
import
|
|
173
|
-
var PanelFooter = ({ children, ...rest }) => /* @__PURE__ */ jsx4(Footer, { p: 450, "data-panel-footer": "", ...rest, children });
|
|
174
|
-
PanelFooter.displayName = "Panel.Footer";
|
|
336
|
+
import Drawer2 from "@sproutsocial/seeds-react-drawer";
|
|
175
337
|
|
|
176
338
|
// src/PanelMobileActionsHeader.tsx
|
|
177
339
|
import "react";
|
|
178
|
-
import Box3 from "@sproutsocial/seeds-react-box";
|
|
179
340
|
import Button2 from "@sproutsocial/seeds-react-button";
|
|
180
341
|
import Drawer from "@sproutsocial/seeds-react-drawer";
|
|
181
342
|
import Icon2 from "@sproutsocial/seeds-react-icon";
|
|
182
343
|
import Text2 from "@sproutsocial/seeds-react-text";
|
|
183
|
-
import { jsx as
|
|
344
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
184
345
|
var PanelMobileActionsHeader = ({
|
|
185
346
|
title,
|
|
186
347
|
titleId,
|
|
187
348
|
actions
|
|
188
|
-
}) => /* @__PURE__ */
|
|
349
|
+
}) => /* @__PURE__ */ jsx4(
|
|
189
350
|
Drawer.Header,
|
|
190
351
|
{
|
|
191
|
-
render: (ctx) => /* @__PURE__ */ jsxs2(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
{
|
|
227
|
-
appearance: "pill",
|
|
228
|
-
"aria-label": ctx.closeButtonLabel,
|
|
229
|
-
onClick: ctx.onClose,
|
|
230
|
-
children: /* @__PURE__ */ jsx5(Icon2, { "aria-hidden": true, name: "x-outline" })
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
] })
|
|
234
|
-
]
|
|
235
|
-
}
|
|
236
|
-
)
|
|
352
|
+
render: (ctx) => /* @__PURE__ */ jsxs2("div", { className: "seeds-panel-mobile-actions-header", children: [
|
|
353
|
+
/* @__PURE__ */ jsx4(
|
|
354
|
+
Text2,
|
|
355
|
+
{
|
|
356
|
+
as: "h2",
|
|
357
|
+
fontSize: 400,
|
|
358
|
+
fontWeight: "semibold",
|
|
359
|
+
color: "text.headline",
|
|
360
|
+
id: titleId,
|
|
361
|
+
children: title
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ jsxs2("div", { className: "seeds-panel-mobile-actions-buttons", children: [
|
|
365
|
+
actions.map((action, i) => /* @__PURE__ */ jsx4(
|
|
366
|
+
Button2,
|
|
367
|
+
{
|
|
368
|
+
appearance: "pill",
|
|
369
|
+
"aria-label": action["aria-label"],
|
|
370
|
+
onClick: action.onClick,
|
|
371
|
+
disabled: action.disabled,
|
|
372
|
+
children: action.iconName && /* @__PURE__ */ jsx4(Icon2, { "aria-hidden": true, name: action.iconName })
|
|
373
|
+
},
|
|
374
|
+
i
|
|
375
|
+
)),
|
|
376
|
+
/* @__PURE__ */ jsx4(
|
|
377
|
+
Button2,
|
|
378
|
+
{
|
|
379
|
+
appearance: "pill",
|
|
380
|
+
"aria-label": ctx.closeButtonLabel,
|
|
381
|
+
onClick: ctx.onClose,
|
|
382
|
+
children: /* @__PURE__ */ jsx4(Icon2, { "aria-hidden": true, name: "x-outline" })
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
] })
|
|
386
|
+
] })
|
|
237
387
|
}
|
|
238
388
|
);
|
|
239
389
|
PanelMobileActionsHeader.displayName = "PanelMobileActionsHeader";
|
|
240
390
|
|
|
241
|
-
// src/
|
|
242
|
-
import { jsx as
|
|
243
|
-
var
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
() => ({ ...panelContext, closeButtonLabel, headerless }),
|
|
273
|
-
[panelContext, closeButtonLabel, headerless]
|
|
274
|
-
);
|
|
275
|
-
const prevChildrenRef = React6.useRef(null);
|
|
276
|
-
if (isPanelOpen) {
|
|
277
|
-
prevChildrenRef.current = children;
|
|
278
|
-
}
|
|
279
|
-
const renderedChildren = isPanelOpen ? children : prevChildrenRef.current;
|
|
280
|
-
const effectiveAriaLabelledBy = ariaLabelledByProp ?? (!headerless && header == null ? titleId : void 0);
|
|
281
|
-
if (isMobile) {
|
|
282
|
-
const shouldRenderActionsHeader = !headerless && header == null && actionsInHeader === true && !!actions && actions.length > 0;
|
|
283
|
-
let defaultMobileHeader = null;
|
|
284
|
-
if (!headerless) {
|
|
285
|
-
defaultMobileHeader = shouldRenderActionsHeader ? /* @__PURE__ */ jsx6(
|
|
286
|
-
PanelMobileActionsHeader,
|
|
287
|
-
{
|
|
288
|
-
title,
|
|
289
|
-
titleId,
|
|
290
|
-
actions
|
|
291
|
-
}
|
|
292
|
-
) : /* @__PURE__ */ jsx6(Drawer2.Header, { title, id: titleId });
|
|
293
|
-
}
|
|
294
|
-
return /* @__PURE__ */ jsx6(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsxs3(
|
|
295
|
-
Drawer2,
|
|
391
|
+
// src/PanelMobile.tsx
|
|
392
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
393
|
+
var PanelMobile = ({ shell }) => {
|
|
394
|
+
const {
|
|
395
|
+
rest,
|
|
396
|
+
children,
|
|
397
|
+
closeButtonLabel,
|
|
398
|
+
header,
|
|
399
|
+
headerless,
|
|
400
|
+
footer,
|
|
401
|
+
title,
|
|
402
|
+
titleId,
|
|
403
|
+
zIndex,
|
|
404
|
+
snapPoints,
|
|
405
|
+
defaultSnapPoint,
|
|
406
|
+
snapPoint,
|
|
407
|
+
onSnapPointChange,
|
|
408
|
+
snapToSequentialPoints,
|
|
409
|
+
actions,
|
|
410
|
+
actionsInHeader,
|
|
411
|
+
ariaLabel,
|
|
412
|
+
isPanelOpen,
|
|
413
|
+
closePanel,
|
|
414
|
+
enrichedValue,
|
|
415
|
+
effectiveAriaLabelledBy
|
|
416
|
+
} = shell;
|
|
417
|
+
const shouldRenderActionsHeader = !headerless && header == null && actionsInHeader === true && !!actions && actions.length > 0;
|
|
418
|
+
let defaultMobileHeader = null;
|
|
419
|
+
if (!headerless) {
|
|
420
|
+
defaultMobileHeader = shouldRenderActionsHeader ? /* @__PURE__ */ jsx5(
|
|
421
|
+
PanelMobileActionsHeader,
|
|
296
422
|
{
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
direction: "bottom",
|
|
301
|
-
closeButtonLabel,
|
|
302
|
-
zIndex,
|
|
303
|
-
snapPoints,
|
|
304
|
-
defaultSnapPoint,
|
|
305
|
-
snapPoint,
|
|
306
|
-
onSnapPointChange,
|
|
307
|
-
snapToSequentialPoints,
|
|
308
|
-
actions,
|
|
309
|
-
actionsInHeader,
|
|
310
|
-
"aria-labelledby": effectiveAriaLabelledBy,
|
|
311
|
-
"aria-label": ariaLabel,
|
|
312
|
-
children: [
|
|
313
|
-
header ?? defaultMobileHeader,
|
|
314
|
-
/* @__PURE__ */ jsx6(PanelContent, { children }),
|
|
315
|
-
footer
|
|
316
|
-
]
|
|
423
|
+
title,
|
|
424
|
+
titleId,
|
|
425
|
+
actions
|
|
317
426
|
}
|
|
318
|
-
) });
|
|
427
|
+
) : /* @__PURE__ */ jsx5(Drawer2.Header, { title, id: titleId });
|
|
428
|
+
}
|
|
429
|
+
return /* @__PURE__ */ jsx5(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsxs3(
|
|
430
|
+
Drawer2,
|
|
431
|
+
{
|
|
432
|
+
...rest,
|
|
433
|
+
open: isPanelOpen,
|
|
434
|
+
onClose: closePanel,
|
|
435
|
+
direction: "bottom",
|
|
436
|
+
closeButtonLabel,
|
|
437
|
+
zIndex,
|
|
438
|
+
snapPoints,
|
|
439
|
+
defaultSnapPoint,
|
|
440
|
+
snapPoint,
|
|
441
|
+
onSnapPointChange,
|
|
442
|
+
snapToSequentialPoints,
|
|
443
|
+
actions,
|
|
444
|
+
actionsInHeader,
|
|
445
|
+
"aria-labelledby": effectiveAriaLabelledBy,
|
|
446
|
+
"aria-label": ariaLabel,
|
|
447
|
+
children: [
|
|
448
|
+
header ?? defaultMobileHeader,
|
|
449
|
+
/* @__PURE__ */ jsx5(PanelContent, { children }),
|
|
450
|
+
footer
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
) });
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
// src/PanelStyled.tsx
|
|
457
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
458
|
+
var PanelStyled = (props) => {
|
|
459
|
+
const shell = usePanelShell(props);
|
|
460
|
+
const {
|
|
461
|
+
rest,
|
|
462
|
+
header,
|
|
463
|
+
headerless,
|
|
464
|
+
footer,
|
|
465
|
+
title,
|
|
466
|
+
titleId,
|
|
467
|
+
direction,
|
|
468
|
+
width,
|
|
469
|
+
gap,
|
|
470
|
+
id,
|
|
471
|
+
ariaLabel,
|
|
472
|
+
isPanelOpen,
|
|
473
|
+
isMobile,
|
|
474
|
+
enrichedValue,
|
|
475
|
+
renderedChildren,
|
|
476
|
+
effectiveAriaLabelledBy
|
|
477
|
+
} = shell;
|
|
478
|
+
if (isMobile) {
|
|
479
|
+
return /* @__PURE__ */ jsx6(PanelMobile, { shell });
|
|
319
480
|
}
|
|
320
481
|
return /* @__PURE__ */ jsx6(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsx6(
|
|
321
482
|
PanelContainer,
|
|
@@ -329,7 +490,7 @@ var PanelComponent = ({
|
|
|
329
490
|
"data-qa-panel-isopen": isPanelOpen,
|
|
330
491
|
"aria-labelledby": effectiveAriaLabelledBy,
|
|
331
492
|
"aria-label": ariaLabel,
|
|
332
|
-
children: /* @__PURE__ */
|
|
493
|
+
children: /* @__PURE__ */ jsxs4(PanelInner, { $direction: direction, $width: width, children: [
|
|
333
494
|
header ?? (headerless ? null : /* @__PURE__ */ jsx6(PanelHeader, { title, id: titleId })),
|
|
334
495
|
/* @__PURE__ */ jsx6(PanelContent, { children: renderedChildren }),
|
|
335
496
|
footer
|
|
@@ -337,6 +498,126 @@ var PanelComponent = ({
|
|
|
337
498
|
}
|
|
338
499
|
) });
|
|
339
500
|
};
|
|
501
|
+
|
|
502
|
+
// src/PanelTailwind.tsx
|
|
503
|
+
import "react";
|
|
504
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
505
|
+
var PanelTailwind = (props) => {
|
|
506
|
+
const shell = usePanelShell(props);
|
|
507
|
+
const {
|
|
508
|
+
rest,
|
|
509
|
+
header,
|
|
510
|
+
headerless,
|
|
511
|
+
footer,
|
|
512
|
+
title,
|
|
513
|
+
titleId,
|
|
514
|
+
direction,
|
|
515
|
+
width,
|
|
516
|
+
gap,
|
|
517
|
+
id,
|
|
518
|
+
ariaLabel,
|
|
519
|
+
isPanelOpen,
|
|
520
|
+
isMobile,
|
|
521
|
+
enrichedValue,
|
|
522
|
+
renderedChildren,
|
|
523
|
+
effectiveAriaLabelledBy
|
|
524
|
+
} = shell;
|
|
525
|
+
if (isMobile) {
|
|
526
|
+
return /* @__PURE__ */ jsx7(PanelMobile, { shell });
|
|
527
|
+
}
|
|
528
|
+
const { className, style, ...domRest } = rest;
|
|
529
|
+
const containerStyle = getPanelContainerStyle(
|
|
530
|
+
direction,
|
|
531
|
+
width,
|
|
532
|
+
gap,
|
|
533
|
+
isPanelOpen
|
|
534
|
+
);
|
|
535
|
+
const innerStyle = getPanelInnerStyle(direction, width);
|
|
536
|
+
return /* @__PURE__ */ jsx7(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsx7(
|
|
537
|
+
"aside",
|
|
538
|
+
{
|
|
539
|
+
...domRest,
|
|
540
|
+
className: cn("seeds-panel", className),
|
|
541
|
+
style: { ...containerStyle, ...style },
|
|
542
|
+
"data-qa-panel": id,
|
|
543
|
+
"data-qa-panel-isopen": isPanelOpen,
|
|
544
|
+
"aria-labelledby": effectiveAriaLabelledBy,
|
|
545
|
+
"aria-label": ariaLabel,
|
|
546
|
+
children: /* @__PURE__ */ jsxs5("div", { className: "seeds-panel-inner", style: innerStyle, children: [
|
|
547
|
+
header ?? (headerless ? null : /* @__PURE__ */ jsx7(PanelHeader, { title, id: titleId })),
|
|
548
|
+
/* @__PURE__ */ jsx7(PanelContent, { children: renderedChildren }),
|
|
549
|
+
footer
|
|
550
|
+
] })
|
|
551
|
+
}
|
|
552
|
+
) });
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// src/PanelHybrid.tsx
|
|
556
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
557
|
+
var PanelHybrid = (props) => {
|
|
558
|
+
const {
|
|
559
|
+
children,
|
|
560
|
+
closeButtonLabel,
|
|
561
|
+
header,
|
|
562
|
+
headerless,
|
|
563
|
+
footer,
|
|
564
|
+
title,
|
|
565
|
+
titleId,
|
|
566
|
+
direction,
|
|
567
|
+
width,
|
|
568
|
+
gap,
|
|
569
|
+
mobileBreakpoint,
|
|
570
|
+
zIndex,
|
|
571
|
+
id,
|
|
572
|
+
snapPoints,
|
|
573
|
+
defaultSnapPoint,
|
|
574
|
+
snapPoint,
|
|
575
|
+
onSnapPointChange,
|
|
576
|
+
snapToSequentialPoints,
|
|
577
|
+
actions,
|
|
578
|
+
actionsInHeader,
|
|
579
|
+
"aria-labelledby": ariaLabelledBy,
|
|
580
|
+
"aria-label": ariaLabel,
|
|
581
|
+
...rest
|
|
582
|
+
} = props;
|
|
583
|
+
if (needsStyledComponents3(rest)) {
|
|
584
|
+
return /* @__PURE__ */ jsx8(PanelStyled, { ...props });
|
|
585
|
+
}
|
|
586
|
+
return /* @__PURE__ */ jsx8(PanelTailwind, { ...props });
|
|
587
|
+
};
|
|
588
|
+
PanelHybrid.displayName = "Panel";
|
|
589
|
+
|
|
590
|
+
// src/PanelFooter.tsx
|
|
591
|
+
import "react";
|
|
592
|
+
import { needsStyledComponents as needsStyledComponents4 } from "@sproutsocial/seeds-react-system-props";
|
|
593
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
594
|
+
var PanelFooterStyled = ({ children, ...rest }) => /* @__PURE__ */ jsx9(Footer, { p: 450, "data-panel-footer": "", ...rest, children });
|
|
595
|
+
var PanelFooterTailwind = ({ children, ...rest }) => {
|
|
596
|
+
const { className, style, ...domRest } = rest;
|
|
597
|
+
return /* @__PURE__ */ jsx9(
|
|
598
|
+
"div",
|
|
599
|
+
{
|
|
600
|
+
className: cn("seeds-panel-footer", className),
|
|
601
|
+
style: { marginBottom: "var(--bleed, 0px)", ...style },
|
|
602
|
+
"data-panel-footer": "",
|
|
603
|
+
...domRest,
|
|
604
|
+
children
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
};
|
|
608
|
+
var PanelFooter = (props) => {
|
|
609
|
+
const { children, ...rest } = props;
|
|
610
|
+
if (needsStyledComponents4(rest)) {
|
|
611
|
+
return /* @__PURE__ */ jsx9(PanelFooterStyled, { ...props });
|
|
612
|
+
}
|
|
613
|
+
return /* @__PURE__ */ jsx9(PanelFooterTailwind, { ...props });
|
|
614
|
+
};
|
|
615
|
+
PanelFooter.displayName = "Panel.Footer";
|
|
616
|
+
|
|
617
|
+
// src/Panel.tsx
|
|
618
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
619
|
+
var PanelComponent = (props) => /* @__PURE__ */ jsx10(PanelHybrid, { ...props });
|
|
620
|
+
PanelComponent.displayName = "Panel";
|
|
340
621
|
PanelComponent.Header = PanelHeader;
|
|
341
622
|
PanelComponent.Content = PanelContent;
|
|
342
623
|
PanelComponent.CloseButton = PanelCloseButton;
|
|
@@ -344,35 +625,35 @@ PanelComponent.Footer = PanelFooter;
|
|
|
344
625
|
var Panel_default = PanelComponent;
|
|
345
626
|
|
|
346
627
|
// src/PanelProvider.tsx
|
|
347
|
-
import * as
|
|
348
|
-
import { jsx as
|
|
628
|
+
import * as React9 from "react";
|
|
629
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
349
630
|
var PanelProvider = ({
|
|
350
631
|
children,
|
|
351
632
|
defaultOpen = false,
|
|
352
633
|
open: controlledOpen,
|
|
353
634
|
onOpenChange
|
|
354
635
|
}) => {
|
|
355
|
-
const [internalOpen, setInternalOpen] =
|
|
636
|
+
const [internalOpen, setInternalOpen] = React9.useState(defaultOpen);
|
|
356
637
|
const isControlled = controlledOpen !== void 0;
|
|
357
638
|
const isPanelOpen = isControlled ? controlledOpen : internalOpen;
|
|
358
|
-
const setOpen =
|
|
639
|
+
const setOpen = React9.useCallback(
|
|
359
640
|
(next) => {
|
|
360
641
|
if (!isControlled) setInternalOpen(next);
|
|
361
642
|
onOpenChange?.(next);
|
|
362
643
|
},
|
|
363
644
|
[isControlled, onOpenChange]
|
|
364
645
|
);
|
|
365
|
-
const openPanel =
|
|
366
|
-
const closePanel =
|
|
367
|
-
const togglePanel =
|
|
646
|
+
const openPanel = React9.useCallback(() => setOpen(true), [setOpen]);
|
|
647
|
+
const closePanel = React9.useCallback(() => setOpen(false), [setOpen]);
|
|
648
|
+
const togglePanel = React9.useCallback(
|
|
368
649
|
() => setOpen(!isPanelOpen),
|
|
369
650
|
[setOpen, isPanelOpen]
|
|
370
651
|
);
|
|
371
|
-
const value =
|
|
652
|
+
const value = React9.useMemo(
|
|
372
653
|
() => ({ isPanelOpen, openPanel, closePanel, togglePanel }),
|
|
373
654
|
[isPanelOpen, openPanel, closePanel, togglePanel]
|
|
374
655
|
);
|
|
375
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ jsx11(PanelContext.Provider, { value, children });
|
|
376
657
|
};
|
|
377
658
|
|
|
378
659
|
// src/PanelTypes.ts
|