@sproutsocial/seeds-react-panel 1.0.11 → 1.1.2
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 +46 -0
- package/dist/esm/index.js +442 -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 +446 -168
- package/dist/index.js.map +1 -1
- package/dist/panel.css +92 -0
- package/package.json +17 -9
- package/src/Panel.stories.tsx +33 -0
- package/src/Panel.tsx +13 -137
- package/src/PanelContent.tsx +64 -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,188 @@ var PanelContent = ({ children, ...rest }) => {
|
|
|
165
292
|
}
|
|
166
293
|
);
|
|
167
294
|
};
|
|
295
|
+
var PanelContentTailwind = ({ children, ...rest }) => {
|
|
296
|
+
const { headerless } = usePanelContext();
|
|
297
|
+
const scroll = !headerless;
|
|
298
|
+
const { className, style, ...domRest } = rest;
|
|
299
|
+
const contentStyle = {
|
|
300
|
+
overflowY: scroll ? "auto" : "hidden"
|
|
301
|
+
};
|
|
302
|
+
if (!scroll) {
|
|
303
|
+
contentStyle.display = "flex";
|
|
304
|
+
contentStyle.flexDirection = "column";
|
|
305
|
+
}
|
|
306
|
+
Object.assign(contentStyle, style);
|
|
307
|
+
return /* @__PURE__ */ jsx3(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
className: cn(
|
|
311
|
+
"seeds-panel-content",
|
|
312
|
+
{ "seeds-panel-content--headerless": !!headerless },
|
|
313
|
+
className
|
|
314
|
+
),
|
|
315
|
+
style: contentStyle,
|
|
316
|
+
"data-panel-content": "",
|
|
317
|
+
...domRest,
|
|
318
|
+
children
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
var PanelContent = (props) => {
|
|
323
|
+
const { children, ...rest } = props;
|
|
324
|
+
if (needsStyledComponents2(rest)) {
|
|
325
|
+
return /* @__PURE__ */ jsx3(PanelContentStyled, { ...props });
|
|
326
|
+
}
|
|
327
|
+
return /* @__PURE__ */ jsx3(PanelContentTailwind, { ...props });
|
|
328
|
+
};
|
|
168
329
|
PanelContent.displayName = "Panel.Content";
|
|
169
330
|
|
|
170
|
-
// src/
|
|
331
|
+
// src/PanelMobile.tsx
|
|
171
332
|
import "react";
|
|
172
|
-
import
|
|
173
|
-
var PanelFooter = ({ children, ...rest }) => /* @__PURE__ */ jsx4(Footer, { p: 450, "data-panel-footer": "", ...rest, children });
|
|
174
|
-
PanelFooter.displayName = "Panel.Footer";
|
|
333
|
+
import Drawer2 from "@sproutsocial/seeds-react-drawer";
|
|
175
334
|
|
|
176
335
|
// src/PanelMobileActionsHeader.tsx
|
|
177
336
|
import "react";
|
|
178
|
-
import Box3 from "@sproutsocial/seeds-react-box";
|
|
179
337
|
import Button2 from "@sproutsocial/seeds-react-button";
|
|
180
338
|
import Drawer from "@sproutsocial/seeds-react-drawer";
|
|
181
339
|
import Icon2 from "@sproutsocial/seeds-react-icon";
|
|
182
340
|
import Text2 from "@sproutsocial/seeds-react-text";
|
|
183
|
-
import { jsx as
|
|
341
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
184
342
|
var PanelMobileActionsHeader = ({
|
|
185
343
|
title,
|
|
186
344
|
titleId,
|
|
187
345
|
actions
|
|
188
|
-
}) => /* @__PURE__ */
|
|
346
|
+
}) => /* @__PURE__ */ jsx4(
|
|
189
347
|
Drawer.Header,
|
|
190
348
|
{
|
|
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
|
-
)
|
|
349
|
+
render: (ctx) => /* @__PURE__ */ jsxs2("div", { className: "seeds-panel-mobile-actions-header", children: [
|
|
350
|
+
/* @__PURE__ */ jsx4(
|
|
351
|
+
Text2,
|
|
352
|
+
{
|
|
353
|
+
as: "h2",
|
|
354
|
+
fontSize: 400,
|
|
355
|
+
fontWeight: "semibold",
|
|
356
|
+
color: "text.headline",
|
|
357
|
+
id: titleId,
|
|
358
|
+
children: title
|
|
359
|
+
}
|
|
360
|
+
),
|
|
361
|
+
/* @__PURE__ */ jsxs2("div", { className: "seeds-panel-mobile-actions-buttons", children: [
|
|
362
|
+
actions.map((action, i) => /* @__PURE__ */ jsx4(
|
|
363
|
+
Button2,
|
|
364
|
+
{
|
|
365
|
+
appearance: "pill",
|
|
366
|
+
"aria-label": action["aria-label"],
|
|
367
|
+
onClick: action.onClick,
|
|
368
|
+
disabled: action.disabled,
|
|
369
|
+
children: action.iconName && /* @__PURE__ */ jsx4(Icon2, { "aria-hidden": true, name: action.iconName })
|
|
370
|
+
},
|
|
371
|
+
i
|
|
372
|
+
)),
|
|
373
|
+
/* @__PURE__ */ jsx4(
|
|
374
|
+
Button2,
|
|
375
|
+
{
|
|
376
|
+
appearance: "pill",
|
|
377
|
+
"aria-label": ctx.closeButtonLabel,
|
|
378
|
+
onClick: ctx.onClose,
|
|
379
|
+
children: /* @__PURE__ */ jsx4(Icon2, { "aria-hidden": true, name: "x-outline" })
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
] })
|
|
383
|
+
] })
|
|
237
384
|
}
|
|
238
385
|
);
|
|
239
386
|
PanelMobileActionsHeader.displayName = "PanelMobileActionsHeader";
|
|
240
387
|
|
|
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,
|
|
388
|
+
// src/PanelMobile.tsx
|
|
389
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
390
|
+
var PanelMobile = ({ shell }) => {
|
|
391
|
+
const {
|
|
392
|
+
rest,
|
|
393
|
+
children,
|
|
394
|
+
closeButtonLabel,
|
|
395
|
+
header,
|
|
396
|
+
headerless,
|
|
397
|
+
footer,
|
|
398
|
+
title,
|
|
399
|
+
titleId,
|
|
400
|
+
zIndex,
|
|
401
|
+
snapPoints,
|
|
402
|
+
defaultSnapPoint,
|
|
403
|
+
snapPoint,
|
|
404
|
+
onSnapPointChange,
|
|
405
|
+
snapToSequentialPoints,
|
|
406
|
+
actions,
|
|
407
|
+
actionsInHeader,
|
|
408
|
+
ariaLabel,
|
|
409
|
+
isPanelOpen,
|
|
410
|
+
closePanel,
|
|
411
|
+
enrichedValue,
|
|
412
|
+
effectiveAriaLabelledBy
|
|
413
|
+
} = shell;
|
|
414
|
+
const shouldRenderActionsHeader = !headerless && header == null && actionsInHeader === true && !!actions && actions.length > 0;
|
|
415
|
+
let defaultMobileHeader = null;
|
|
416
|
+
if (!headerless) {
|
|
417
|
+
defaultMobileHeader = shouldRenderActionsHeader ? /* @__PURE__ */ jsx5(
|
|
418
|
+
PanelMobileActionsHeader,
|
|
296
419
|
{
|
|
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
|
-
]
|
|
420
|
+
title,
|
|
421
|
+
titleId,
|
|
422
|
+
actions
|
|
317
423
|
}
|
|
318
|
-
) });
|
|
424
|
+
) : /* @__PURE__ */ jsx5(Drawer2.Header, { title, id: titleId });
|
|
425
|
+
}
|
|
426
|
+
return /* @__PURE__ */ jsx5(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsxs3(
|
|
427
|
+
Drawer2,
|
|
428
|
+
{
|
|
429
|
+
...rest,
|
|
430
|
+
open: isPanelOpen,
|
|
431
|
+
onClose: closePanel,
|
|
432
|
+
direction: "bottom",
|
|
433
|
+
closeButtonLabel,
|
|
434
|
+
zIndex,
|
|
435
|
+
snapPoints,
|
|
436
|
+
defaultSnapPoint,
|
|
437
|
+
snapPoint,
|
|
438
|
+
onSnapPointChange,
|
|
439
|
+
snapToSequentialPoints,
|
|
440
|
+
actions,
|
|
441
|
+
actionsInHeader,
|
|
442
|
+
"aria-labelledby": effectiveAriaLabelledBy,
|
|
443
|
+
"aria-label": ariaLabel,
|
|
444
|
+
children: [
|
|
445
|
+
header ?? defaultMobileHeader,
|
|
446
|
+
/* @__PURE__ */ jsx5(PanelContent, { children }),
|
|
447
|
+
footer
|
|
448
|
+
]
|
|
449
|
+
}
|
|
450
|
+
) });
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
// src/PanelStyled.tsx
|
|
454
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
455
|
+
var PanelStyled = (props) => {
|
|
456
|
+
const shell = usePanelShell(props);
|
|
457
|
+
const {
|
|
458
|
+
rest,
|
|
459
|
+
header,
|
|
460
|
+
headerless,
|
|
461
|
+
footer,
|
|
462
|
+
title,
|
|
463
|
+
titleId,
|
|
464
|
+
direction,
|
|
465
|
+
width,
|
|
466
|
+
gap,
|
|
467
|
+
id,
|
|
468
|
+
ariaLabel,
|
|
469
|
+
isPanelOpen,
|
|
470
|
+
isMobile,
|
|
471
|
+
enrichedValue,
|
|
472
|
+
renderedChildren,
|
|
473
|
+
effectiveAriaLabelledBy
|
|
474
|
+
} = shell;
|
|
475
|
+
if (isMobile) {
|
|
476
|
+
return /* @__PURE__ */ jsx6(PanelMobile, { shell });
|
|
319
477
|
}
|
|
320
478
|
return /* @__PURE__ */ jsx6(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsx6(
|
|
321
479
|
PanelContainer,
|
|
@@ -329,7 +487,7 @@ var PanelComponent = ({
|
|
|
329
487
|
"data-qa-panel-isopen": isPanelOpen,
|
|
330
488
|
"aria-labelledby": effectiveAriaLabelledBy,
|
|
331
489
|
"aria-label": ariaLabel,
|
|
332
|
-
children: /* @__PURE__ */
|
|
490
|
+
children: /* @__PURE__ */ jsxs4(PanelInner, { $direction: direction, $width: width, children: [
|
|
333
491
|
header ?? (headerless ? null : /* @__PURE__ */ jsx6(PanelHeader, { title, id: titleId })),
|
|
334
492
|
/* @__PURE__ */ jsx6(PanelContent, { children: renderedChildren }),
|
|
335
493
|
footer
|
|
@@ -337,6 +495,126 @@ var PanelComponent = ({
|
|
|
337
495
|
}
|
|
338
496
|
) });
|
|
339
497
|
};
|
|
498
|
+
|
|
499
|
+
// src/PanelTailwind.tsx
|
|
500
|
+
import "react";
|
|
501
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
502
|
+
var PanelTailwind = (props) => {
|
|
503
|
+
const shell = usePanelShell(props);
|
|
504
|
+
const {
|
|
505
|
+
rest,
|
|
506
|
+
header,
|
|
507
|
+
headerless,
|
|
508
|
+
footer,
|
|
509
|
+
title,
|
|
510
|
+
titleId,
|
|
511
|
+
direction,
|
|
512
|
+
width,
|
|
513
|
+
gap,
|
|
514
|
+
id,
|
|
515
|
+
ariaLabel,
|
|
516
|
+
isPanelOpen,
|
|
517
|
+
isMobile,
|
|
518
|
+
enrichedValue,
|
|
519
|
+
renderedChildren,
|
|
520
|
+
effectiveAriaLabelledBy
|
|
521
|
+
} = shell;
|
|
522
|
+
if (isMobile) {
|
|
523
|
+
return /* @__PURE__ */ jsx7(PanelMobile, { shell });
|
|
524
|
+
}
|
|
525
|
+
const { className, style, ...domRest } = rest;
|
|
526
|
+
const containerStyle = getPanelContainerStyle(
|
|
527
|
+
direction,
|
|
528
|
+
width,
|
|
529
|
+
gap,
|
|
530
|
+
isPanelOpen
|
|
531
|
+
);
|
|
532
|
+
const innerStyle = getPanelInnerStyle(direction, width);
|
|
533
|
+
return /* @__PURE__ */ jsx7(PanelContext.Provider, { value: enrichedValue, children: /* @__PURE__ */ jsx7(
|
|
534
|
+
"aside",
|
|
535
|
+
{
|
|
536
|
+
...domRest,
|
|
537
|
+
className: cn("seeds-panel", className),
|
|
538
|
+
style: { ...containerStyle, ...style },
|
|
539
|
+
"data-qa-panel": id,
|
|
540
|
+
"data-qa-panel-isopen": isPanelOpen,
|
|
541
|
+
"aria-labelledby": effectiveAriaLabelledBy,
|
|
542
|
+
"aria-label": ariaLabel,
|
|
543
|
+
children: /* @__PURE__ */ jsxs5("div", { className: "seeds-panel-inner", style: innerStyle, children: [
|
|
544
|
+
header ?? (headerless ? null : /* @__PURE__ */ jsx7(PanelHeader, { title, id: titleId })),
|
|
545
|
+
/* @__PURE__ */ jsx7(PanelContent, { children: renderedChildren }),
|
|
546
|
+
footer
|
|
547
|
+
] })
|
|
548
|
+
}
|
|
549
|
+
) });
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// src/PanelHybrid.tsx
|
|
553
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
554
|
+
var PanelHybrid = (props) => {
|
|
555
|
+
const {
|
|
556
|
+
children,
|
|
557
|
+
closeButtonLabel,
|
|
558
|
+
header,
|
|
559
|
+
headerless,
|
|
560
|
+
footer,
|
|
561
|
+
title,
|
|
562
|
+
titleId,
|
|
563
|
+
direction,
|
|
564
|
+
width,
|
|
565
|
+
gap,
|
|
566
|
+
mobileBreakpoint,
|
|
567
|
+
zIndex,
|
|
568
|
+
id,
|
|
569
|
+
snapPoints,
|
|
570
|
+
defaultSnapPoint,
|
|
571
|
+
snapPoint,
|
|
572
|
+
onSnapPointChange,
|
|
573
|
+
snapToSequentialPoints,
|
|
574
|
+
actions,
|
|
575
|
+
actionsInHeader,
|
|
576
|
+
"aria-labelledby": ariaLabelledBy,
|
|
577
|
+
"aria-label": ariaLabel,
|
|
578
|
+
...rest
|
|
579
|
+
} = props;
|
|
580
|
+
if (needsStyledComponents3(rest)) {
|
|
581
|
+
return /* @__PURE__ */ jsx8(PanelStyled, { ...props });
|
|
582
|
+
}
|
|
583
|
+
return /* @__PURE__ */ jsx8(PanelTailwind, { ...props });
|
|
584
|
+
};
|
|
585
|
+
PanelHybrid.displayName = "Panel";
|
|
586
|
+
|
|
587
|
+
// src/PanelFooter.tsx
|
|
588
|
+
import "react";
|
|
589
|
+
import { needsStyledComponents as needsStyledComponents4 } from "@sproutsocial/seeds-react-system-props";
|
|
590
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
591
|
+
var PanelFooterStyled = ({ children, ...rest }) => /* @__PURE__ */ jsx9(Footer, { p: 450, "data-panel-footer": "", ...rest, children });
|
|
592
|
+
var PanelFooterTailwind = ({ children, ...rest }) => {
|
|
593
|
+
const { className, style, ...domRest } = rest;
|
|
594
|
+
return /* @__PURE__ */ jsx9(
|
|
595
|
+
"div",
|
|
596
|
+
{
|
|
597
|
+
className: cn("seeds-panel-footer", className),
|
|
598
|
+
style: { marginBottom: "var(--bleed, 0px)", ...style },
|
|
599
|
+
"data-panel-footer": "",
|
|
600
|
+
...domRest,
|
|
601
|
+
children
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
};
|
|
605
|
+
var PanelFooter = (props) => {
|
|
606
|
+
const { children, ...rest } = props;
|
|
607
|
+
if (needsStyledComponents4(rest)) {
|
|
608
|
+
return /* @__PURE__ */ jsx9(PanelFooterStyled, { ...props });
|
|
609
|
+
}
|
|
610
|
+
return /* @__PURE__ */ jsx9(PanelFooterTailwind, { ...props });
|
|
611
|
+
};
|
|
612
|
+
PanelFooter.displayName = "Panel.Footer";
|
|
613
|
+
|
|
614
|
+
// src/Panel.tsx
|
|
615
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
616
|
+
var PanelComponent = (props) => /* @__PURE__ */ jsx10(PanelHybrid, { ...props });
|
|
617
|
+
PanelComponent.displayName = "Panel";
|
|
340
618
|
PanelComponent.Header = PanelHeader;
|
|
341
619
|
PanelComponent.Content = PanelContent;
|
|
342
620
|
PanelComponent.CloseButton = PanelCloseButton;
|
|
@@ -344,35 +622,35 @@ PanelComponent.Footer = PanelFooter;
|
|
|
344
622
|
var Panel_default = PanelComponent;
|
|
345
623
|
|
|
346
624
|
// src/PanelProvider.tsx
|
|
347
|
-
import * as
|
|
348
|
-
import { jsx as
|
|
625
|
+
import * as React9 from "react";
|
|
626
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
349
627
|
var PanelProvider = ({
|
|
350
628
|
children,
|
|
351
629
|
defaultOpen = false,
|
|
352
630
|
open: controlledOpen,
|
|
353
631
|
onOpenChange
|
|
354
632
|
}) => {
|
|
355
|
-
const [internalOpen, setInternalOpen] =
|
|
633
|
+
const [internalOpen, setInternalOpen] = React9.useState(defaultOpen);
|
|
356
634
|
const isControlled = controlledOpen !== void 0;
|
|
357
635
|
const isPanelOpen = isControlled ? controlledOpen : internalOpen;
|
|
358
|
-
const setOpen =
|
|
636
|
+
const setOpen = React9.useCallback(
|
|
359
637
|
(next) => {
|
|
360
638
|
if (!isControlled) setInternalOpen(next);
|
|
361
639
|
onOpenChange?.(next);
|
|
362
640
|
},
|
|
363
641
|
[isControlled, onOpenChange]
|
|
364
642
|
);
|
|
365
|
-
const openPanel =
|
|
366
|
-
const closePanel =
|
|
367
|
-
const togglePanel =
|
|
643
|
+
const openPanel = React9.useCallback(() => setOpen(true), [setOpen]);
|
|
644
|
+
const closePanel = React9.useCallback(() => setOpen(false), [setOpen]);
|
|
645
|
+
const togglePanel = React9.useCallback(
|
|
368
646
|
() => setOpen(!isPanelOpen),
|
|
369
647
|
[setOpen, isPanelOpen]
|
|
370
648
|
);
|
|
371
|
-
const value =
|
|
649
|
+
const value = React9.useMemo(
|
|
372
650
|
() => ({ isPanelOpen, openPanel, closePanel, togglePanel }),
|
|
373
651
|
[isPanelOpen, openPanel, closePanel, togglePanel]
|
|
374
652
|
);
|
|
375
|
-
return /* @__PURE__ */
|
|
653
|
+
return /* @__PURE__ */ jsx11(PanelContext.Provider, { value, children });
|
|
376
654
|
};
|
|
377
655
|
|
|
378
656
|
// src/PanelTypes.ts
|