@sproutsocial/seeds-react-menu 1.2.2 → 1.3.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 +10 -10
- package/CHANGELOG.md +16 -0
- package/dist/esm/index.js +179 -133
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +217 -171
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Autocomplete/MultiAutocomplete.tsx +29 -18
- package/src/Autocomplete/SingleAutocomplete.tsx +14 -6
- package/src/Autocomplete/__tests__/Autocomplete.test.tsx +21 -0
- package/src/MenuContent/DefaultMenuEmptyState.tsx +17 -0
- package/src/MenuContent/MenuContent.tsx +14 -2
- package/src/MenuContent/MenuContentTypes.ts +2 -0
- package/src/MenuContent/__tests__/MenuContent.test.tsx +38 -17
- package/src/MenuContext.tsx +13 -0
- package/src/MenuItem/__tests__/MenuItem.test.tsx +11 -14
- package/src/MenuRoot/MenuRoot.tsx +9 -9
- package/src/SingleSelectMenu/SingleSelectMenu.stories.tsx +44 -0
- package/src/menuTestingUtils.tsx +12 -7
package/dist/esm/index.js
CHANGED
|
@@ -101,7 +101,8 @@ var defaultMenuContext = {
|
|
|
101
101
|
items: [],
|
|
102
102
|
itemsMap: {},
|
|
103
103
|
isItemSelected: () => false,
|
|
104
|
-
getInputComponentProps: () => ({})
|
|
104
|
+
getInputComponentProps: () => ({}),
|
|
105
|
+
hasVisibleItems: false
|
|
105
106
|
};
|
|
106
107
|
var getSelectedItemIds = (selectedItems) => selectedItems?.reduce(
|
|
107
108
|
(selected, item) => ({ ...selected, [item.id]: true }),
|
|
@@ -122,6 +123,8 @@ var useMenu = ({
|
|
|
122
123
|
selectedItems,
|
|
123
124
|
getInputProps,
|
|
124
125
|
contentRef: contentRefFromProps,
|
|
126
|
+
autoCloseOnEmpty,
|
|
127
|
+
hiddenItemsCount,
|
|
125
128
|
...rest
|
|
126
129
|
} = {}) => {
|
|
127
130
|
const contentRef = contentRefFromProps || React.createRef();
|
|
@@ -176,6 +179,9 @@ var useMenu = ({
|
|
|
176
179
|
},
|
|
177
180
|
[getInputProps]
|
|
178
181
|
);
|
|
182
|
+
const hasVisibleItems = useMemo(() => {
|
|
183
|
+
return (hiddenItemsCount ?? 0) < items.length;
|
|
184
|
+
}, [items, hiddenItemsCount]);
|
|
179
185
|
return {
|
|
180
186
|
isOpen,
|
|
181
187
|
isListbox,
|
|
@@ -188,6 +194,8 @@ var useMenu = ({
|
|
|
188
194
|
getInputProps,
|
|
189
195
|
getInputComponentProps,
|
|
190
196
|
contentRef,
|
|
197
|
+
hasVisibleItems,
|
|
198
|
+
autoCloseOnEmpty,
|
|
191
199
|
...menuProps
|
|
192
200
|
};
|
|
193
201
|
};
|
|
@@ -2301,7 +2309,23 @@ var useMenuChildren = ({
|
|
|
2301
2309
|
|
|
2302
2310
|
// src/MenuContent/MenuContent.tsx
|
|
2303
2311
|
import { useCallback } from "react";
|
|
2312
|
+
|
|
2313
|
+
// src/MenuContent/DefaultMenuEmptyState.tsx
|
|
2314
|
+
import styled4 from "styled-components";
|
|
2304
2315
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2316
|
+
var StyledEmptyState = styled4.div`
|
|
2317
|
+
padding: ${({ theme: theme2 }) => theme2.space[350]};
|
|
2318
|
+
text-align: center;
|
|
2319
|
+
font-size: ${({ theme: theme2 }) => theme2.typography[200].fontSize};
|
|
2320
|
+
`;
|
|
2321
|
+
var DefaultMenuEmptyState = ({
|
|
2322
|
+
children
|
|
2323
|
+
}) => {
|
|
2324
|
+
return /* @__PURE__ */ jsx6(StyledEmptyState, { children: children || "No results found." });
|
|
2325
|
+
};
|
|
2326
|
+
|
|
2327
|
+
// src/MenuContent/MenuContent.tsx
|
|
2328
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2305
2329
|
var MenuContent = ({
|
|
2306
2330
|
id = "menu_content",
|
|
2307
2331
|
children: childrenProp,
|
|
@@ -2309,11 +2333,21 @@ var MenuContent = ({
|
|
|
2309
2333
|
MenuItemComponent,
|
|
2310
2334
|
onKeyDown,
|
|
2311
2335
|
innerRef = null,
|
|
2336
|
+
emptyStateElement,
|
|
2312
2337
|
...rest
|
|
2313
2338
|
}) => {
|
|
2314
|
-
const {
|
|
2339
|
+
const {
|
|
2340
|
+
getToggleButtonProps,
|
|
2341
|
+
getMenuProps,
|
|
2342
|
+
isListbox,
|
|
2343
|
+
hasVisibleItems,
|
|
2344
|
+
autoCloseOnEmpty
|
|
2345
|
+
} = useMenuContentContext();
|
|
2315
2346
|
const toggleButtonProps = getToggleButtonProps?.();
|
|
2316
2347
|
const children = childrenProp || !menuItems || !menuItems.length ? childrenProp : mapMenuItems({ menuItems, MenuItemComponent });
|
|
2348
|
+
if (!hasVisibleItems && !autoCloseOnEmpty) {
|
|
2349
|
+
return emptyStateElement ?? /* @__PURE__ */ jsx7(DefaultMenuEmptyState, {});
|
|
2350
|
+
}
|
|
2317
2351
|
if (!children) {
|
|
2318
2352
|
return null;
|
|
2319
2353
|
}
|
|
@@ -2324,7 +2358,7 @@ var MenuContent = ({
|
|
|
2324
2358
|
},
|
|
2325
2359
|
[onKeyDown, toggleButtonProps?.["onKeyDown"]]
|
|
2326
2360
|
);
|
|
2327
|
-
return /* @__PURE__ */
|
|
2361
|
+
return /* @__PURE__ */ jsx7(
|
|
2328
2362
|
StyledMenuContent,
|
|
2329
2363
|
{
|
|
2330
2364
|
autoFocus: true,
|
|
@@ -2350,29 +2384,29 @@ MenuContent.__MENU_PRIMITIVE_TYPE = "MenuContent";
|
|
|
2350
2384
|
import "react";
|
|
2351
2385
|
|
|
2352
2386
|
// src/MenuFooter/styles.tsx
|
|
2353
|
-
import
|
|
2387
|
+
import styled5 from "styled-components";
|
|
2354
2388
|
import { Box as Box2 } from "@sproutsocial/seeds-react-box";
|
|
2355
|
-
var StyledMenuFooterBox =
|
|
2389
|
+
var StyledMenuFooterBox = styled5(Box2)`
|
|
2356
2390
|
padding: ${({ theme: theme2 }) => theme2.space[350]} ${({ theme: theme2 }) => theme2.space[400]};
|
|
2357
2391
|
border-top: 1px solid ${(p) => p.theme.colors.container.border.base};
|
|
2358
2392
|
`;
|
|
2359
2393
|
|
|
2360
2394
|
// src/MenuFooter/MenuFooter.tsx
|
|
2361
|
-
import { jsx as
|
|
2395
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
2362
2396
|
var MenuFooter = ({ children, ...rest }) => {
|
|
2363
|
-
return /* @__PURE__ */
|
|
2397
|
+
return /* @__PURE__ */ jsx8(StyledMenuFooterBox, { ...rest, children });
|
|
2364
2398
|
};
|
|
2365
2399
|
|
|
2366
2400
|
// src/MenuGroup/MenuGroup.tsx
|
|
2367
2401
|
import "react";
|
|
2368
2402
|
|
|
2369
2403
|
// src/MenuGroup/styles.tsx
|
|
2370
|
-
import
|
|
2404
|
+
import styled7 from "styled-components";
|
|
2371
2405
|
|
|
2372
2406
|
// ../seeds-react-text/dist/esm/index.js
|
|
2373
2407
|
import "react";
|
|
2374
2408
|
import styled22 from "styled-components";
|
|
2375
|
-
import
|
|
2409
|
+
import styled6, { css as css5 } from "styled-components";
|
|
2376
2410
|
import {
|
|
2377
2411
|
COMMON,
|
|
2378
2412
|
LAYOUT,
|
|
@@ -2380,9 +2414,9 @@ import {
|
|
|
2380
2414
|
GRID,
|
|
2381
2415
|
TYPOGRAPHY
|
|
2382
2416
|
} from "@sproutsocial/seeds-react-system-props";
|
|
2383
|
-
import { jsx as
|
|
2417
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2384
2418
|
import "react";
|
|
2385
|
-
var Container =
|
|
2419
|
+
var Container = styled6.span`
|
|
2386
2420
|
margin: 0;
|
|
2387
2421
|
padding-left: 0;
|
|
2388
2422
|
padding-right: 0;
|
|
@@ -2441,7 +2475,7 @@ var SmallBodyCopy = styled22(styles_default)`
|
|
|
2441
2475
|
`;
|
|
2442
2476
|
var Text = ({ fontSize: fontSize2, children, qa, color: color2, ...rest }) => {
|
|
2443
2477
|
const qaText = typeof children === "string" ? children : void 0;
|
|
2444
|
-
return /* @__PURE__ */
|
|
2478
|
+
return /* @__PURE__ */ jsx9(
|
|
2445
2479
|
styles_default,
|
|
2446
2480
|
{
|
|
2447
2481
|
typeScale: fontSize2,
|
|
@@ -2456,7 +2490,7 @@ var Text = ({ fontSize: fontSize2, children, qa, color: color2, ...rest }) => {
|
|
|
2456
2490
|
var withTextLogic = (Component) => {
|
|
2457
2491
|
return ({ children, ...props }) => {
|
|
2458
2492
|
const qaText = typeof children === "string" ? children : void 0;
|
|
2459
|
-
return /* @__PURE__ */
|
|
2493
|
+
return /* @__PURE__ */ jsx9(Component, { "data-qa-text": qaText, ...props, children });
|
|
2460
2494
|
};
|
|
2461
2495
|
};
|
|
2462
2496
|
var HeadlineWithLogic = withTextLogic(Headline);
|
|
@@ -2484,7 +2518,7 @@ var Text_default = Text;
|
|
|
2484
2518
|
var index_default = Text_default;
|
|
2485
2519
|
|
|
2486
2520
|
// src/MenuGroup/styles.tsx
|
|
2487
|
-
var StyledMenuGroup =
|
|
2521
|
+
var StyledMenuGroup = styled7.li`
|
|
2488
2522
|
&:not(:last-child) {
|
|
2489
2523
|
border-bottom: 1px solid
|
|
2490
2524
|
${({ theme: theme2 }) => theme2.colors.container.border.base};
|
|
@@ -2500,18 +2534,18 @@ var StyledMenuGroup = styled6.li`
|
|
|
2500
2534
|
${layout}
|
|
2501
2535
|
${space}
|
|
2502
2536
|
`;
|
|
2503
|
-
var StyledTitle =
|
|
2537
|
+
var StyledTitle = styled7(index_default.SmallSubHeadline)`
|
|
2504
2538
|
font-size: ${({ theme: theme2 }) => theme2.typography[100].fontSize};
|
|
2505
2539
|
margin: ${({ theme: theme2 }) => theme2.space[400]} ${({ theme: theme2 }) => theme2.space[400]}
|
|
2506
2540
|
0px ${({ theme: theme2 }) => theme2.space[400]};
|
|
2507
2541
|
`;
|
|
2508
|
-
var StyledMenuGroupUl =
|
|
2542
|
+
var StyledMenuGroupUl = styled7.ul`
|
|
2509
2543
|
margin: 0;
|
|
2510
2544
|
padding: 0;
|
|
2511
2545
|
`;
|
|
2512
2546
|
|
|
2513
2547
|
// src/MenuGroup/MenuGroup.tsx
|
|
2514
|
-
import { jsx as
|
|
2548
|
+
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2515
2549
|
var MenuGroup = ({
|
|
2516
2550
|
titleAs = "h3",
|
|
2517
2551
|
children: childrenProp,
|
|
@@ -2538,8 +2572,8 @@ var MenuGroup = ({
|
|
|
2538
2572
|
color: color2,
|
|
2539
2573
|
...rest,
|
|
2540
2574
|
children: [
|
|
2541
|
-
title && /* @__PURE__ */
|
|
2542
|
-
/* @__PURE__ */
|
|
2575
|
+
title && /* @__PURE__ */ jsx10(StyledTitle, { role: "heading", as: titleAs, id: titleId, children: title }),
|
|
2576
|
+
/* @__PURE__ */ jsx10(StyledMenuGroupUl, { children })
|
|
2543
2577
|
]
|
|
2544
2578
|
}
|
|
2545
2579
|
);
|
|
@@ -2552,7 +2586,7 @@ import React7, {
|
|
|
2552
2586
|
useEffect,
|
|
2553
2587
|
useLayoutEffect
|
|
2554
2588
|
} from "react";
|
|
2555
|
-
import
|
|
2589
|
+
import styled8 from "styled-components";
|
|
2556
2590
|
import { Popout } from "@sproutsocial/seeds-react-popout";
|
|
2557
2591
|
import { mergeRefs } from "@sproutsocial/seeds-react-utilities";
|
|
2558
2592
|
|
|
@@ -2560,8 +2594,8 @@ import { mergeRefs } from "@sproutsocial/seeds-react-utilities";
|
|
|
2560
2594
|
var MOTION_DURATION_FAST = 0.15;
|
|
2561
2595
|
|
|
2562
2596
|
// src/MenuRoot/MenuRoot.tsx
|
|
2563
|
-
import { jsx as
|
|
2564
|
-
var CustomPopoutContent =
|
|
2597
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2598
|
+
var CustomPopoutContent = styled8(Popout.Content)`
|
|
2565
2599
|
padding: 0;
|
|
2566
2600
|
margin-left: 0;
|
|
2567
2601
|
margin-right: 0;
|
|
@@ -2609,12 +2643,12 @@ var MenuPopout = ({
|
|
|
2609
2643
|
},
|
|
2610
2644
|
[openMenu, closeMenu]
|
|
2611
2645
|
);
|
|
2612
|
-
return /* @__PURE__ */
|
|
2646
|
+
return /* @__PURE__ */ jsx11(
|
|
2613
2647
|
Popout,
|
|
2614
2648
|
{
|
|
2615
2649
|
isOpen: !!isOpen,
|
|
2616
2650
|
setIsOpen,
|
|
2617
|
-
content: (props) => /* @__PURE__ */
|
|
2651
|
+
content: (props) => /* @__PURE__ */ jsx11(CustomPopoutContent, { width: popoutProps.fullWidth ? "initial" : width2, children: typeof content === "function" ? content(props) : content }),
|
|
2618
2652
|
focusLockProps: {
|
|
2619
2653
|
// correct jerking motion when scrolling while the Popout is open
|
|
2620
2654
|
// returnFocus: false,
|
|
@@ -2639,9 +2673,8 @@ var MenuRoot = ({
|
|
|
2639
2673
|
openMenu,
|
|
2640
2674
|
closeMenu,
|
|
2641
2675
|
inputValue,
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
getMenuProps
|
|
2676
|
+
getMenuProps,
|
|
2677
|
+
autoCloseOnEmpty = false
|
|
2645
2678
|
} = contextProps;
|
|
2646
2679
|
const toggleElementRef = React7.useRef(null);
|
|
2647
2680
|
const [finalWidth, setFinalWidth] = React7.useState();
|
|
@@ -2656,25 +2689,25 @@ var MenuRoot = ({
|
|
|
2656
2689
|
setFinalWidth(min_width);
|
|
2657
2690
|
}
|
|
2658
2691
|
}, [width2, toggleElementRef.current?.offsetWidth]);
|
|
2692
|
+
const menuContext = useMenu(contextProps);
|
|
2693
|
+
getMenuProps?.({}, { suppressRefError: true });
|
|
2659
2694
|
useEffect(() => {
|
|
2660
|
-
if (!inputValue) return;
|
|
2661
|
-
if (
|
|
2695
|
+
if (!inputValue || !autoCloseOnEmpty) return;
|
|
2696
|
+
if (!menuContext.hasVisibleItems && isOpen) {
|
|
2662
2697
|
closeMenu?.();
|
|
2663
2698
|
}
|
|
2664
|
-
}, [
|
|
2665
|
-
|
|
2666
|
-
getMenuProps?.({}, { suppressRefError: true });
|
|
2667
|
-
return /* @__PURE__ */ jsx10(
|
|
2699
|
+
}, [menuContext.hasVisibleItems, isOpen, inputValue, autoCloseOnEmpty]);
|
|
2700
|
+
return /* @__PURE__ */ jsx11(
|
|
2668
2701
|
MenuPopout,
|
|
2669
2702
|
{
|
|
2670
2703
|
placement,
|
|
2671
2704
|
isOpen: !!isOpen,
|
|
2672
2705
|
openMenu,
|
|
2673
2706
|
closeMenu,
|
|
2674
|
-
content: /* @__PURE__ */
|
|
2707
|
+
content: /* @__PURE__ */ jsx11(MenuContentProvider, { menuContext, children }),
|
|
2675
2708
|
width: finalWidth,
|
|
2676
2709
|
...popoutProps,
|
|
2677
|
-
children: (toggleProps) => /* @__PURE__ */
|
|
2710
|
+
children: (toggleProps) => /* @__PURE__ */ jsx11(
|
|
2678
2711
|
MenuToggleProvider,
|
|
2679
2712
|
{
|
|
2680
2713
|
menuContext: {
|
|
@@ -2695,7 +2728,7 @@ var MenuRoot = ({
|
|
|
2695
2728
|
// src/MenuLabel.tsx
|
|
2696
2729
|
import "react";
|
|
2697
2730
|
import { Label } from "@sproutsocial/seeds-react-label";
|
|
2698
|
-
import { jsx as
|
|
2731
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2699
2732
|
var MenuLabel = ({
|
|
2700
2733
|
children,
|
|
2701
2734
|
required = false,
|
|
@@ -2704,7 +2737,7 @@ var MenuLabel = ({
|
|
|
2704
2737
|
const { getLabelProps } = useMenuToggleContext();
|
|
2705
2738
|
return (
|
|
2706
2739
|
// This fallback id should never be used, but it is here to satisfy TypeScript since getLabelProps could be undefined.
|
|
2707
|
-
/* @__PURE__ */
|
|
2740
|
+
/* @__PURE__ */ jsx12(
|
|
2708
2741
|
Label,
|
|
2709
2742
|
{
|
|
2710
2743
|
htmlFor: "fallback_menu_label",
|
|
@@ -2719,10 +2752,10 @@ var MenuLabel = ({
|
|
|
2719
2752
|
|
|
2720
2753
|
// src/MenuToggleButton/MenuToggleButton.tsx
|
|
2721
2754
|
import { Button } from "@sproutsocial/seeds-react-button";
|
|
2722
|
-
import { jsx as
|
|
2755
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2723
2756
|
var MenuToggleButton = (props) => {
|
|
2724
2757
|
const { getToggleButtonProps, isListbox, getDropdownProps, ref, ariaProps } = useMenuToggleContext();
|
|
2725
|
-
return /* @__PURE__ */
|
|
2758
|
+
return /* @__PURE__ */ jsx13(
|
|
2726
2759
|
Button,
|
|
2727
2760
|
{
|
|
2728
2761
|
appearance: "secondary",
|
|
@@ -2782,7 +2815,7 @@ var useItemFiltering = ({
|
|
|
2782
2815
|
};
|
|
2783
2816
|
|
|
2784
2817
|
// src/MenuSearchInput/MenuSearchInput.tsx
|
|
2785
|
-
import { jsx as
|
|
2818
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
2786
2819
|
var MenuSearchInput = ({
|
|
2787
2820
|
getIsItemVisible,
|
|
2788
2821
|
inputProps,
|
|
@@ -2812,7 +2845,7 @@ var MenuSearchInput = ({
|
|
|
2812
2845
|
},
|
|
2813
2846
|
[toggleButtonProps.onKeyDown]
|
|
2814
2847
|
);
|
|
2815
|
-
return /* @__PURE__ */
|
|
2848
|
+
return /* @__PURE__ */ jsx14(
|
|
2816
2849
|
Input,
|
|
2817
2850
|
{
|
|
2818
2851
|
onChange: (e, value) => {
|
|
@@ -2833,12 +2866,12 @@ var MenuSearchInput = ({
|
|
|
2833
2866
|
|
|
2834
2867
|
// src/MenuTokenInput.tsx
|
|
2835
2868
|
import React11 from "react";
|
|
2836
|
-
import
|
|
2869
|
+
import styled9 from "styled-components";
|
|
2837
2870
|
import {
|
|
2838
2871
|
TokenInput
|
|
2839
2872
|
} from "@sproutsocial/seeds-react-token-input";
|
|
2840
|
-
import { jsx as
|
|
2841
|
-
var StyledTokenInputWrapper =
|
|
2873
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2874
|
+
var StyledTokenInputWrapper = styled9.div`
|
|
2842
2875
|
> div {
|
|
2843
2876
|
padding: 4px;
|
|
2844
2877
|
}
|
|
@@ -2872,7 +2905,7 @@ var MenuTokenInput = ({
|
|
|
2872
2905
|
const tokenToRemove = selectedItems?.find((item) => item.id === tokenId);
|
|
2873
2906
|
tokenToRemove && removeSelectedItem?.(tokenToRemove);
|
|
2874
2907
|
};
|
|
2875
|
-
return /* @__PURE__ */
|
|
2908
|
+
return /* @__PURE__ */ jsx15(StyledTokenInputWrapper, { children: /* @__PURE__ */ jsx15(
|
|
2876
2909
|
TokenInput,
|
|
2877
2910
|
{
|
|
2878
2911
|
onKeyDown: (e, value) => {
|
|
@@ -2922,7 +2955,7 @@ var MenuTokenInput = ({
|
|
|
2922
2955
|
|
|
2923
2956
|
// src/MenuSearchTokenInput/MenuSearchTokenInput.tsx
|
|
2924
2957
|
import React12 from "react";
|
|
2925
|
-
import { jsx as
|
|
2958
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
2926
2959
|
var MenuSearchTokenInput = ({
|
|
2927
2960
|
getIsItemVisible,
|
|
2928
2961
|
getTokenProps,
|
|
@@ -2970,7 +3003,7 @@ var MenuSearchTokenInput = ({
|
|
|
2970
3003
|
},
|
|
2971
3004
|
[toggleButtonProps.onKeyDown]
|
|
2972
3005
|
);
|
|
2973
|
-
return /* @__PURE__ */
|
|
3006
|
+
return /* @__PURE__ */ jsx16(
|
|
2974
3007
|
MenuTokenInput,
|
|
2975
3008
|
{
|
|
2976
3009
|
onChange: (e, value2) => {
|
|
@@ -2995,7 +3028,7 @@ import React13 from "react";
|
|
|
2995
3028
|
import { Icon as Icon2 } from "@sproutsocial/seeds-react-icon";
|
|
2996
3029
|
import { Box as Box3 } from "@sproutsocial/seeds-react-box";
|
|
2997
3030
|
import { mergeRefs as mergeRefs2 } from "@sproutsocial/seeds-react-utilities";
|
|
2998
|
-
import { jsx as
|
|
3031
|
+
import { jsx as jsx17, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2999
3032
|
var SubmenuItemTrigger = ({
|
|
3000
3033
|
id,
|
|
3001
3034
|
children,
|
|
@@ -3004,7 +3037,7 @@ var SubmenuItemTrigger = ({
|
|
|
3004
3037
|
}) => {
|
|
3005
3038
|
const { getToggleButtonProps, getDropdownProps, ref, ariaProps } = useMenuToggleContext();
|
|
3006
3039
|
const toggleRef = ref && innerRef ? mergeRefs2([ref, innerRef].filter(Boolean)) : ref || innerRef;
|
|
3007
|
-
return /* @__PURE__ */
|
|
3040
|
+
return /* @__PURE__ */ jsx17(
|
|
3008
3041
|
MenuItem,
|
|
3009
3042
|
{
|
|
3010
3043
|
...rest,
|
|
@@ -3023,7 +3056,7 @@ var SubmenuItemTrigger = ({
|
|
|
3023
3056
|
id,
|
|
3024
3057
|
children: /* @__PURE__ */ jsxs4(Box3, { display: "flex", justifyContent: "space-between", children: [
|
|
3025
3058
|
children,
|
|
3026
|
-
/* @__PURE__ */
|
|
3059
|
+
/* @__PURE__ */ jsx17(MenuItemActionRight, { children: /* @__PURE__ */ jsx17(Icon2, { name: "chevron-right-outline" }) })
|
|
3027
3060
|
] })
|
|
3028
3061
|
}
|
|
3029
3062
|
);
|
|
@@ -3133,7 +3166,7 @@ var SubmenuItem = ({
|
|
|
3133
3166
|
};
|
|
3134
3167
|
}
|
|
3135
3168
|
}, [document, onSubmenuKeydown]);
|
|
3136
|
-
const subMenuContent = /* @__PURE__ */
|
|
3169
|
+
const subMenuContent = /* @__PURE__ */ jsx17(
|
|
3137
3170
|
"div",
|
|
3138
3171
|
{
|
|
3139
3172
|
ref: submenuRef,
|
|
@@ -3144,13 +3177,13 @@ var SubmenuItem = ({
|
|
|
3144
3177
|
children: menuContent
|
|
3145
3178
|
}
|
|
3146
3179
|
);
|
|
3147
|
-
return /* @__PURE__ */
|
|
3180
|
+
return /* @__PURE__ */ jsx17(
|
|
3148
3181
|
MenuComponent,
|
|
3149
3182
|
{
|
|
3150
3183
|
...{
|
|
3151
3184
|
...menuProps,
|
|
3152
3185
|
children: subMenuContent,
|
|
3153
|
-
menuToggleElement: /* @__PURE__ */
|
|
3186
|
+
menuToggleElement: /* @__PURE__ */ jsx17(
|
|
3154
3187
|
SubmenuItemTrigger,
|
|
3155
3188
|
{
|
|
3156
3189
|
innerRef: submenuItemRef,
|
|
@@ -3182,17 +3215,17 @@ var SubmenuItem = ({
|
|
|
3182
3215
|
SubmenuItem.__MENU_PRIMITIVE_TYPE = "MenuItem";
|
|
3183
3216
|
|
|
3184
3217
|
// src/ListboxToggleButton.tsx
|
|
3185
|
-
import
|
|
3218
|
+
import styled10, { css as css6 } from "styled-components";
|
|
3186
3219
|
import { Icon as Icon3 } from "@sproutsocial/seeds-react-icon";
|
|
3187
|
-
import { jsx as
|
|
3188
|
-
var StyledListboxToggleButton =
|
|
3220
|
+
import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3221
|
+
var StyledListboxToggleButton = styled10(
|
|
3189
3222
|
MenuToggleButton
|
|
3190
3223
|
)`
|
|
3191
3224
|
${(props) => props.invalid && css6`
|
|
3192
3225
|
border-color: ${(props2) => props2.theme.colors.form.border.error};
|
|
3193
3226
|
`}
|
|
3194
3227
|
`;
|
|
3195
|
-
var StyledChevron =
|
|
3228
|
+
var StyledChevron = styled10.div`
|
|
3196
3229
|
margin-left: ${({ theme: theme2 }) => theme2.space[300]};
|
|
3197
3230
|
${({ $isOpen }) => $isOpen && `
|
|
3198
3231
|
transform: rotate(-180deg);
|
|
@@ -3203,7 +3236,7 @@ var StyledChevron = styled9.div`
|
|
|
3203
3236
|
color: ${(props) => props.theme.colors.icon.error};
|
|
3204
3237
|
`}
|
|
3205
3238
|
`;
|
|
3206
|
-
var StyledInnerButton =
|
|
3239
|
+
var StyledInnerButton = styled10.div`
|
|
3207
3240
|
display: flex;
|
|
3208
3241
|
justify-content: space-between;
|
|
3209
3242
|
`;
|
|
@@ -3212,9 +3245,9 @@ var ListboxToggleButton = ({
|
|
|
3212
3245
|
...buttonProps
|
|
3213
3246
|
}) => {
|
|
3214
3247
|
const { isOpen } = useMenuToggleContext();
|
|
3215
|
-
return /* @__PURE__ */
|
|
3248
|
+
return /* @__PURE__ */ jsx18(StyledListboxToggleButton, { appearance: "secondary", ...buttonProps, children: /* @__PURE__ */ jsxs5(StyledInnerButton, { children: [
|
|
3216
3249
|
children,
|
|
3217
|
-
/* @__PURE__ */
|
|
3250
|
+
/* @__PURE__ */ jsx18(StyledChevron, { $isOpen: isOpen, invalid: buttonProps.invalid, children: /* @__PURE__ */ jsx18(Icon3, { name: "chevron-down-outline", fixedWidth: true, "aria-hidden": true }) })
|
|
3218
3251
|
] }) });
|
|
3219
3252
|
};
|
|
3220
3253
|
|
|
@@ -3385,7 +3418,7 @@ var useDownshiftDefaults = ({
|
|
|
3385
3418
|
};
|
|
3386
3419
|
|
|
3387
3420
|
// src/ActionMenu/ActionMenu.tsx
|
|
3388
|
-
import { jsx as
|
|
3421
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
3389
3422
|
var handleStateChange = (changes, currentSelectedItem) => {
|
|
3390
3423
|
if (!(changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownEnter || changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownSpaceButton)) {
|
|
3391
3424
|
return;
|
|
@@ -3448,7 +3481,7 @@ var ActionMenu = ({
|
|
|
3448
3481
|
useEffect2(() => {
|
|
3449
3482
|
setCurrentSelectedItem(useSelectReturnProps.selectedItem);
|
|
3450
3483
|
}, [useSelectReturnProps.selectedItem]);
|
|
3451
|
-
return /* @__PURE__ */
|
|
3484
|
+
return /* @__PURE__ */ jsx19(
|
|
3452
3485
|
MenuRootComponent,
|
|
3453
3486
|
{
|
|
3454
3487
|
...{
|
|
@@ -3469,7 +3502,7 @@ var ActionMenu = ({
|
|
|
3469
3502
|
// src/SingleSelectMenu/SingleSelectMenu.tsx
|
|
3470
3503
|
import "react";
|
|
3471
3504
|
import { useSelect as useSelect3 } from "downshift";
|
|
3472
|
-
import { jsx as
|
|
3505
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
3473
3506
|
var SingleSelectMenu = ({
|
|
3474
3507
|
children: childrenProp,
|
|
3475
3508
|
stateReducer: externalStateReducer,
|
|
@@ -3496,7 +3529,7 @@ var SingleSelectMenu = ({
|
|
|
3496
3529
|
),
|
|
3497
3530
|
...useSelectProps
|
|
3498
3531
|
});
|
|
3499
|
-
return /* @__PURE__ */
|
|
3532
|
+
return /* @__PURE__ */ jsx20(
|
|
3500
3533
|
MenuRootComponent,
|
|
3501
3534
|
{
|
|
3502
3535
|
...{
|
|
@@ -3517,7 +3550,7 @@ var SingleSelectMenu = ({
|
|
|
3517
3550
|
// src/MultiSelectMenu/MultiSelectMenu.tsx
|
|
3518
3551
|
import "react";
|
|
3519
3552
|
import { useSelect as useSelect4, useMultipleSelection } from "downshift";
|
|
3520
|
-
import { jsx as
|
|
3553
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
3521
3554
|
var MultiSelectMenu = ({
|
|
3522
3555
|
children: childrenProp,
|
|
3523
3556
|
menuItems,
|
|
@@ -3590,7 +3623,7 @@ var MultiSelectMenu = ({
|
|
|
3590
3623
|
},
|
|
3591
3624
|
...useSelectProps
|
|
3592
3625
|
});
|
|
3593
|
-
return /* @__PURE__ */
|
|
3626
|
+
return /* @__PURE__ */ jsx21(
|
|
3594
3627
|
MenuRootComponent,
|
|
3595
3628
|
{
|
|
3596
3629
|
...{
|
|
@@ -3621,8 +3654,9 @@ var MultiSelectMenu = ({
|
|
|
3621
3654
|
import "react";
|
|
3622
3655
|
|
|
3623
3656
|
// src/Autocomplete/SingleAutocomplete.tsx
|
|
3657
|
+
import "react";
|
|
3624
3658
|
import { useCombobox as useCombobox2 } from "downshift";
|
|
3625
|
-
import { jsx as
|
|
3659
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3626
3660
|
var SingleAutocomplete = ({
|
|
3627
3661
|
children: childrenProp,
|
|
3628
3662
|
stateReducer: externalStateReducer,
|
|
@@ -3638,14 +3672,15 @@ var SingleAutocomplete = ({
|
|
|
3638
3672
|
menuItems,
|
|
3639
3673
|
MenuItemComponent
|
|
3640
3674
|
});
|
|
3641
|
-
const
|
|
3675
|
+
const downshiftDefaults = useDownshiftDefaults({ isCombobox: true });
|
|
3676
|
+
const { setHiddenItemsMap, defaultDownshiftProps, hiddenItemsCount } = downshiftDefaults;
|
|
3642
3677
|
const { updateFilteredItems } = useItemFiltering({
|
|
3643
3678
|
allMenuItems,
|
|
3644
3679
|
itemToString: itemToString2,
|
|
3645
3680
|
getIsItemVisible,
|
|
3646
3681
|
setHiddenItemsMap
|
|
3647
3682
|
});
|
|
3648
|
-
const
|
|
3683
|
+
const useComboboxReturnProps = useCombobox2({
|
|
3649
3684
|
...defaultDownshiftProps.combobox,
|
|
3650
3685
|
items: allMenuItems,
|
|
3651
3686
|
itemToString: itemToString2,
|
|
@@ -3656,31 +3691,33 @@ var SingleAutocomplete = ({
|
|
|
3656
3691
|
),
|
|
3657
3692
|
...useComboboxProps
|
|
3658
3693
|
});
|
|
3659
|
-
|
|
3694
|
+
const { isOpen, closeMenu, inputValue } = useComboboxReturnProps;
|
|
3695
|
+
const { popoutProps: userPopoutProps } = useComboboxProps;
|
|
3696
|
+
return /* @__PURE__ */ jsx22(
|
|
3660
3697
|
MenuRootComponent,
|
|
3661
3698
|
{
|
|
3662
3699
|
...{
|
|
3663
3700
|
isListbox: true,
|
|
3664
3701
|
items: allMenuItems,
|
|
3665
3702
|
itemToString: itemToString2,
|
|
3666
|
-
isOpen,
|
|
3667
|
-
setHiddenItemsMap,
|
|
3668
3703
|
...useComboboxProps,
|
|
3669
3704
|
...useComboboxReturnProps,
|
|
3670
|
-
...
|
|
3705
|
+
...downshiftDefaults
|
|
3671
3706
|
},
|
|
3672
3707
|
popoutProps: {
|
|
3673
|
-
focusOnContent: false
|
|
3708
|
+
focusOnContent: false,
|
|
3709
|
+
...userPopoutProps
|
|
3674
3710
|
},
|
|
3711
|
+
autoCloseOnEmpty: true,
|
|
3675
3712
|
children
|
|
3676
3713
|
}
|
|
3677
3714
|
);
|
|
3678
3715
|
};
|
|
3679
3716
|
|
|
3680
3717
|
// src/Autocomplete/MultiAutocomplete.tsx
|
|
3681
|
-
import
|
|
3718
|
+
import React19 from "react";
|
|
3682
3719
|
import { useCombobox as useCombobox3, useMultipleSelection as useMultipleSelection2 } from "downshift";
|
|
3683
|
-
import { jsx as
|
|
3720
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3684
3721
|
var MultiAutocomplete = ({
|
|
3685
3722
|
children: childrenProp,
|
|
3686
3723
|
stateReducer: externalStateReducer,
|
|
@@ -3704,21 +3741,21 @@ var MultiAutocomplete = ({
|
|
|
3704
3741
|
menuItems,
|
|
3705
3742
|
MenuItemComponent
|
|
3706
3743
|
});
|
|
3707
|
-
const [selectedItems, setSelectedItems] =
|
|
3708
|
-
const [selectedItemIds, setSelectedItemIds] =
|
|
3709
|
-
const getIsItemVisibleMulti =
|
|
3710
|
-
(item,
|
|
3711
|
-
return (showSelectedItemsInDropdown || !selectedItemIds[item.id]) && getIsItemVisible(item,
|
|
3744
|
+
const [selectedItems, setSelectedItems] = React19.useState(initialSelectedItems);
|
|
3745
|
+
const [selectedItemIds, setSelectedItemIds] = React19.useState(getSelectedItemIds(initialSelectedItems));
|
|
3746
|
+
const getIsItemVisibleMulti = React19.useCallback(
|
|
3747
|
+
(item, inputValue2) => {
|
|
3748
|
+
return (showSelectedItemsInDropdown || !selectedItemIds[item.id]) && getIsItemVisible(item, inputValue2);
|
|
3712
3749
|
},
|
|
3713
3750
|
[selectedItemIds, showSelectedItemsInDropdown, getIsItemVisible]
|
|
3714
3751
|
);
|
|
3715
|
-
const getShouldFilterMulti =
|
|
3752
|
+
const getShouldFilterMulti = React19.useCallback(
|
|
3716
3753
|
(args) => {
|
|
3717
3754
|
return !showSelectedItemsInDropdown && Object.keys(selectedItemIds).length > 0 || defaultGetShouldFilter(args);
|
|
3718
3755
|
},
|
|
3719
3756
|
[selectedItemIds, showSelectedItemsInDropdown, getIsItemVisible]
|
|
3720
3757
|
);
|
|
3721
|
-
const
|
|
3758
|
+
const downshiftDefaults = useDownshiftDefaults({
|
|
3722
3759
|
isCombobox: true,
|
|
3723
3760
|
isMulti: true,
|
|
3724
3761
|
// handles the prop name mapping for multi select
|
|
@@ -3729,6 +3766,7 @@ var MultiAutocomplete = ({
|
|
|
3729
3766
|
...useComboboxProps
|
|
3730
3767
|
}
|
|
3731
3768
|
});
|
|
3769
|
+
const { setHiddenItemsMap, defaultDownshiftProps, hiddenItemsCount } = downshiftDefaults;
|
|
3732
3770
|
const { updateFilteredItems } = useItemFiltering({
|
|
3733
3771
|
allMenuItems,
|
|
3734
3772
|
itemToString: itemToString2,
|
|
@@ -3736,7 +3774,7 @@ var MultiAutocomplete = ({
|
|
|
3736
3774
|
getShouldFilter: getShouldFilterMulti,
|
|
3737
3775
|
setHiddenItemsMap
|
|
3738
3776
|
});
|
|
3739
|
-
|
|
3777
|
+
React19.useEffect(() => {
|
|
3740
3778
|
updateFilteredItems({ inputValue: "" });
|
|
3741
3779
|
}, [selectedItemIds]);
|
|
3742
3780
|
const useMultipleSelectionReturnProps = useMultipleSelection2({
|
|
@@ -3749,7 +3787,7 @@ var MultiAutocomplete = ({
|
|
|
3749
3787
|
onSelectedItemsChange && onSelectedItemsChange({ selectedItems: selectedItems2, ...changes });
|
|
3750
3788
|
}
|
|
3751
3789
|
});
|
|
3752
|
-
const
|
|
3790
|
+
const useComboboxReturnProps = useCombobox3({
|
|
3753
3791
|
...defaultDownshiftProps.combobox,
|
|
3754
3792
|
items: allMenuItems,
|
|
3755
3793
|
itemToString: itemToString2,
|
|
@@ -3759,7 +3797,7 @@ var MultiAutocomplete = ({
|
|
|
3759
3797
|
externalStateReducer
|
|
3760
3798
|
),
|
|
3761
3799
|
onStateChange(changes) {
|
|
3762
|
-
const { type, selectedItem: newSelectedItem, inputValue } = changes;
|
|
3800
|
+
const { type, selectedItem: newSelectedItem, inputValue: inputValue2 } = changes;
|
|
3763
3801
|
switch (type) {
|
|
3764
3802
|
// Add the selected item to the selected items list
|
|
3765
3803
|
case useCombobox3.stateChangeTypes.InputKeyDownEnter:
|
|
@@ -3780,55 +3818,63 @@ var MultiAutocomplete = ({
|
|
|
3780
3818
|
default:
|
|
3781
3819
|
break;
|
|
3782
3820
|
}
|
|
3783
|
-
if (
|
|
3821
|
+
if (inputValue2 !== void 0) updateFilteredItems({ inputValue: inputValue2 });
|
|
3784
3822
|
onStateChange && onStateChange(changes);
|
|
3785
3823
|
},
|
|
3786
3824
|
...useComboboxProps
|
|
3787
3825
|
});
|
|
3788
|
-
|
|
3826
|
+
const { isOpen, closeMenu, inputValue } = useComboboxReturnProps;
|
|
3827
|
+
const { popoutProps: userPopoutProps } = useComboboxProps;
|
|
3828
|
+
React19.useEffect(() => {
|
|
3829
|
+
if (!inputValue) return;
|
|
3830
|
+
if (allMenuItems && hiddenItemsCount >= allMenuItems.length && isOpen) {
|
|
3831
|
+
closeMenu?.();
|
|
3832
|
+
}
|
|
3833
|
+
}, [hiddenItemsCount, allMenuItems?.length, isOpen, inputValue]);
|
|
3834
|
+
return /* @__PURE__ */ jsx23(
|
|
3789
3835
|
MenuRootComponent,
|
|
3790
3836
|
{
|
|
3791
3837
|
...{
|
|
3792
3838
|
isListbox: true,
|
|
3793
3839
|
items: allMenuItems,
|
|
3794
3840
|
itemToString: itemToString2,
|
|
3795
|
-
isOpen,
|
|
3796
3841
|
initialSelectedItems,
|
|
3797
3842
|
onStateChange,
|
|
3798
3843
|
onSelectedItemsChange,
|
|
3799
3844
|
getA11yMultiStatusMessage,
|
|
3800
3845
|
onMultiSelectStateChange,
|
|
3801
3846
|
multiSelectStateReducer,
|
|
3802
|
-
setHiddenItemsMap,
|
|
3803
3847
|
...useComboboxProps,
|
|
3804
3848
|
...useComboboxReturnProps,
|
|
3805
3849
|
...useMultipleSelectionReturnProps,
|
|
3806
|
-
...
|
|
3850
|
+
...downshiftDefaults
|
|
3807
3851
|
},
|
|
3808
3852
|
popoutProps: {
|
|
3809
|
-
focusOnContent: false
|
|
3853
|
+
focusOnContent: false,
|
|
3854
|
+
...userPopoutProps
|
|
3810
3855
|
},
|
|
3856
|
+
autoCloseOnEmpty: true,
|
|
3811
3857
|
children
|
|
3812
3858
|
}
|
|
3813
3859
|
);
|
|
3814
3860
|
};
|
|
3815
3861
|
|
|
3816
3862
|
// src/Autocomplete/Autocomplete.tsx
|
|
3817
|
-
import { jsx as
|
|
3863
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
3818
3864
|
var Autocomplete = ({
|
|
3819
3865
|
multiSelect = false,
|
|
3820
3866
|
...rest
|
|
3821
3867
|
}) => {
|
|
3822
3868
|
if (multiSelect) {
|
|
3823
|
-
return /* @__PURE__ */
|
|
3869
|
+
return /* @__PURE__ */ jsx24(MultiAutocomplete, { ...rest });
|
|
3824
3870
|
}
|
|
3825
|
-
return /* @__PURE__ */
|
|
3871
|
+
return /* @__PURE__ */ jsx24(SingleAutocomplete, { ...rest });
|
|
3826
3872
|
};
|
|
3827
3873
|
|
|
3828
3874
|
// src/Autocomplete/AutocompleteInput.tsx
|
|
3829
3875
|
import "react";
|
|
3830
3876
|
import { Input as Input2 } from "@sproutsocial/seeds-react-input";
|
|
3831
|
-
import { jsx as
|
|
3877
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
3832
3878
|
var AutocompleteInput = ({
|
|
3833
3879
|
onKeyDown,
|
|
3834
3880
|
onChange,
|
|
@@ -3839,7 +3885,7 @@ var AutocompleteInput = ({
|
|
|
3839
3885
|
...rest
|
|
3840
3886
|
}) => {
|
|
3841
3887
|
const { getInputComponentProps, inputValue, ref, ariaProps } = useMenuToggleContext();
|
|
3842
|
-
return /* @__PURE__ */
|
|
3888
|
+
return /* @__PURE__ */ jsx25(
|
|
3843
3889
|
Input2,
|
|
3844
3890
|
{
|
|
3845
3891
|
id: "autocomplete_input",
|
|
@@ -3865,7 +3911,7 @@ var AutocompleteInput = ({
|
|
|
3865
3911
|
|
|
3866
3912
|
// src/Autocomplete/AutocompleteTokenInput.tsx
|
|
3867
3913
|
import "react";
|
|
3868
|
-
import { jsx as
|
|
3914
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3869
3915
|
var AutocompleteTokenInput = ({
|
|
3870
3916
|
onKeyDown,
|
|
3871
3917
|
onChange,
|
|
@@ -3884,7 +3930,7 @@ var AutocompleteTokenInput = ({
|
|
|
3884
3930
|
ref,
|
|
3885
3931
|
ariaProps
|
|
3886
3932
|
} = useMenuToggleContext();
|
|
3887
|
-
return /* @__PURE__ */
|
|
3933
|
+
return /* @__PURE__ */ jsx26(
|
|
3888
3934
|
MenuTokenInput,
|
|
3889
3935
|
{
|
|
3890
3936
|
id: "autocomplete_input",
|
|
@@ -3909,19 +3955,19 @@ var AutocompleteTokenInput = ({
|
|
|
3909
3955
|
// src/Autocomplete/AutocompleteSelect.tsx
|
|
3910
3956
|
import Icon4 from "@sproutsocial/seeds-react-icon";
|
|
3911
3957
|
import "react";
|
|
3912
|
-
import
|
|
3958
|
+
import styled11 from "styled-components";
|
|
3913
3959
|
import { Accessory } from "@sproutsocial/seeds-react-input";
|
|
3914
|
-
import { jsx as
|
|
3915
|
-
var StyledAutocompleteInput =
|
|
3960
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
3961
|
+
var StyledAutocompleteInput = styled11(AutocompleteInput)`
|
|
3916
3962
|
${Accessory} {
|
|
3917
3963
|
pointer-events: none;
|
|
3918
3964
|
}
|
|
3919
3965
|
`;
|
|
3920
3966
|
var AutocompleteSelect = (props) => {
|
|
3921
|
-
return /* @__PURE__ */
|
|
3967
|
+
return /* @__PURE__ */ jsx27(
|
|
3922
3968
|
StyledAutocompleteInput,
|
|
3923
3969
|
{
|
|
3924
|
-
elemAfter: /* @__PURE__ */
|
|
3970
|
+
elemAfter: /* @__PURE__ */ jsx27(Icon4, { name: "chevron-down" }),
|
|
3925
3971
|
...props
|
|
3926
3972
|
}
|
|
3927
3973
|
);
|
|
@@ -3958,7 +4004,7 @@ var nestedMenuStateReducer = (_state, actionAndChanges) => {
|
|
|
3958
4004
|
|
|
3959
4005
|
// src/NestedMenu/NestedMenuContext.tsx
|
|
3960
4006
|
import { createContext as createContext2, useContext as useContext5 } from "react";
|
|
3961
|
-
import { jsx as
|
|
4007
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3962
4008
|
var defaultNestedMenuContext = {
|
|
3963
4009
|
selectedMenuPath: [],
|
|
3964
4010
|
setSelectedMenuId: () => {
|
|
@@ -3982,7 +4028,7 @@ var NestedMenuProvider = ({
|
|
|
3982
4028
|
children,
|
|
3983
4029
|
...nestedMenuProps
|
|
3984
4030
|
}) => {
|
|
3985
|
-
return /* @__PURE__ */
|
|
4031
|
+
return /* @__PURE__ */ jsx28(NestedMenuContext.Provider, { value: nestedMenuProps, children });
|
|
3986
4032
|
};
|
|
3987
4033
|
var useNestedMenuContext = () => {
|
|
3988
4034
|
const nestedMenuContextValue = useContext5(NestedMenuContext);
|
|
@@ -4001,7 +4047,7 @@ import { mergeRefs as mergeRefs3 } from "@sproutsocial/seeds-react-utilities";
|
|
|
4001
4047
|
// src/NestedMenu/NestedMenuItem.tsx
|
|
4002
4048
|
import { Icon as Icon5 } from "@sproutsocial/seeds-react-icon";
|
|
4003
4049
|
import { Box as Box4 } from "@sproutsocial/seeds-react-box";
|
|
4004
|
-
import { jsx as
|
|
4050
|
+
import { jsx as jsx29, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
4005
4051
|
var NestedMenuItem = ({
|
|
4006
4052
|
children,
|
|
4007
4053
|
childMenuId,
|
|
@@ -4017,15 +4063,15 @@ var NestedMenuItem = ({
|
|
|
4017
4063
|
}
|
|
4018
4064
|
}
|
|
4019
4065
|
} : {};
|
|
4020
|
-
return /* @__PURE__ */
|
|
4066
|
+
return /* @__PURE__ */ jsx29(MenuItem, { ...onClickProps, ...rest, children: /* @__PURE__ */ jsxs6(Box4, { display: "flex", justifyContent: "space-between", children: [
|
|
4021
4067
|
children,
|
|
4022
|
-
childMenuId && /* @__PURE__ */
|
|
4068
|
+
childMenuId && /* @__PURE__ */ jsx29(MenuItemActionRight, { children: /* @__PURE__ */ jsx29(Icon5, { name: "arrow-right-outline" }) })
|
|
4023
4069
|
] }) });
|
|
4024
4070
|
};
|
|
4025
4071
|
NestedMenuItem.__MENU_PRIMITIVE_TYPE = "MenuItem";
|
|
4026
4072
|
|
|
4027
4073
|
// src/NestedMenu/NestedMenuContent.tsx
|
|
4028
|
-
import { jsx as
|
|
4074
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
4029
4075
|
var NestedMenuContent = ({
|
|
4030
4076
|
innerRef: innerRefProp = null,
|
|
4031
4077
|
onKeyDown: onKeyDownProp,
|
|
@@ -4062,7 +4108,7 @@ var NestedMenuContent = ({
|
|
|
4062
4108
|
break;
|
|
4063
4109
|
}
|
|
4064
4110
|
};
|
|
4065
|
-
return /* @__PURE__ */
|
|
4111
|
+
return /* @__PURE__ */ jsx30(
|
|
4066
4112
|
MenuContent,
|
|
4067
4113
|
{
|
|
4068
4114
|
onKeyDown,
|
|
@@ -4078,17 +4124,17 @@ NestedMenuContent.__MENU_PRIMITIVE_TYPE = "MenuContent";
|
|
|
4078
4124
|
import { Button as Button2 } from "@sproutsocial/seeds-react-button";
|
|
4079
4125
|
import { Icon as Icon6 } from "@sproutsocial/seeds-react-icon";
|
|
4080
4126
|
import { AnimatePresence, motion } from "motion/react";
|
|
4081
|
-
import { jsx as
|
|
4127
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
4082
4128
|
var NestedMenuHeader = ({
|
|
4083
4129
|
backArrowLabel,
|
|
4084
4130
|
...props
|
|
4085
4131
|
}) => {
|
|
4086
4132
|
const { goBack, selectedMenuPath, animationSpeed } = useNestedMenuContext();
|
|
4087
4133
|
const showBackArrow = selectedMenuPath.length > 1;
|
|
4088
|
-
return /* @__PURE__ */
|
|
4134
|
+
return /* @__PURE__ */ jsx31(
|
|
4089
4135
|
MenuHeader,
|
|
4090
4136
|
{
|
|
4091
|
-
leftAction: /* @__PURE__ */
|
|
4137
|
+
leftAction: /* @__PURE__ */ jsx31(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx31(
|
|
4092
4138
|
motion.div,
|
|
4093
4139
|
{
|
|
4094
4140
|
initial: { opacity: 0 },
|
|
@@ -4097,7 +4143,7 @@ var NestedMenuHeader = ({
|
|
|
4097
4143
|
opacity: 0,
|
|
4098
4144
|
transition: { duration: animationSpeed }
|
|
4099
4145
|
},
|
|
4100
|
-
children: showBackArrow ? /* @__PURE__ */
|
|
4146
|
+
children: showBackArrow ? /* @__PURE__ */ jsx31(Button2, { onClick: goBack, ariaLabel: backArrowLabel, children: /* @__PURE__ */ jsx31(Icon6, { name: "arrow-left" }) }) : void 0
|
|
4101
4147
|
},
|
|
4102
4148
|
`${selectedMenuPath}-header--button`
|
|
4103
4149
|
) }),
|
|
@@ -4107,8 +4153,8 @@ var NestedMenuHeader = ({
|
|
|
4107
4153
|
};
|
|
4108
4154
|
|
|
4109
4155
|
// src/NestedMenu/NestedMenuRoot.tsx
|
|
4110
|
-
import
|
|
4111
|
-
import { jsx as
|
|
4156
|
+
import React24 from "react";
|
|
4157
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
4112
4158
|
var NestedMenuRoot = ({
|
|
4113
4159
|
children,
|
|
4114
4160
|
menuToggleElement,
|
|
@@ -4116,21 +4162,21 @@ var NestedMenuRoot = ({
|
|
|
4116
4162
|
}) => {
|
|
4117
4163
|
const menuContext = useMenu(contextProps);
|
|
4118
4164
|
const { setActiveMenuContext, selectedMenuPath } = useNestedMenuContext();
|
|
4119
|
-
|
|
4165
|
+
React24.useEffect(() => {
|
|
4120
4166
|
setActiveMenuContext(menuContext);
|
|
4121
4167
|
}, [
|
|
4122
4168
|
selectedMenuPath[selectedMenuPath.length - 1],
|
|
4123
4169
|
menuContext.selectedItem,
|
|
4124
4170
|
menuContext.selectedItems?.length
|
|
4125
4171
|
]);
|
|
4126
|
-
return /* @__PURE__ */
|
|
4172
|
+
return /* @__PURE__ */ jsx32(MenuContentProvider, { menuContext, children });
|
|
4127
4173
|
};
|
|
4128
4174
|
|
|
4129
4175
|
// src/NestedMenu/NestedMenuPopout.tsx
|
|
4130
4176
|
import { motion as motion2 } from "motion/react";
|
|
4131
|
-
import
|
|
4132
|
-
import { jsx as
|
|
4133
|
-
var StyledDiv =
|
|
4177
|
+
import styled12 from "styled-components";
|
|
4178
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
4179
|
+
var StyledDiv = styled12(motion2.div)`
|
|
4134
4180
|
overflow: hidden;
|
|
4135
4181
|
`;
|
|
4136
4182
|
var NestedMenuPopout = ({
|
|
@@ -4140,7 +4186,7 @@ var NestedMenuPopout = ({
|
|
|
4140
4186
|
...popoutProps
|
|
4141
4187
|
}) => {
|
|
4142
4188
|
const { activeMenuContext, rootMenuContextProps, resetSelectedMenuPath } = useNestedMenuContext();
|
|
4143
|
-
return /* @__PURE__ */
|
|
4189
|
+
return /* @__PURE__ */ jsx33(
|
|
4144
4190
|
MenuPopout,
|
|
4145
4191
|
{
|
|
4146
4192
|
...popoutProps,
|
|
@@ -4149,8 +4195,8 @@ var NestedMenuPopout = ({
|
|
|
4149
4195
|
openMenu: rootMenuContextProps.openMenu,
|
|
4150
4196
|
closeMenu: rootMenuContextProps.closeMenu,
|
|
4151
4197
|
width: width2,
|
|
4152
|
-
content: (props) => /* @__PURE__ */
|
|
4153
|
-
children: (toggleProps) => /* @__PURE__ */
|
|
4198
|
+
content: (props) => /* @__PURE__ */ jsx33(StyledDiv, { layout: "position", children: typeof content === "function" ? content(props) : content }),
|
|
4199
|
+
children: (toggleProps) => /* @__PURE__ */ jsx33(
|
|
4154
4200
|
MenuToggleProvider,
|
|
4155
4201
|
{
|
|
4156
4202
|
menuContext: {
|
|
@@ -4166,7 +4212,7 @@ var NestedMenuPopout = ({
|
|
|
4166
4212
|
};
|
|
4167
4213
|
|
|
4168
4214
|
// src/NestedMenu/NestedMenu.tsx
|
|
4169
|
-
import { jsx as
|
|
4215
|
+
import { jsx as jsx34, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4170
4216
|
var NestedMenu = ({
|
|
4171
4217
|
initialMenuId,
|
|
4172
4218
|
menus,
|
|
@@ -4320,7 +4366,7 @@ var NestedMenu = ({
|
|
|
4320
4366
|
initialIsOpen: true,
|
|
4321
4367
|
children: (
|
|
4322
4368
|
// Handles the smooth animating of the content
|
|
4323
|
-
/* @__PURE__ */
|
|
4369
|
+
/* @__PURE__ */ jsx34(AnimatePresence2, { mode: "wait", children: /* @__PURE__ */ jsxs7(
|
|
4324
4370
|
motion3.div,
|
|
4325
4371
|
{
|
|
4326
4372
|
variants: contentVariants,
|
|
@@ -4329,7 +4375,7 @@ var NestedMenu = ({
|
|
|
4329
4375
|
exit: "leave",
|
|
4330
4376
|
custom: { isAdding, hasLoadedOnce },
|
|
4331
4377
|
children: [
|
|
4332
|
-
MenuHeaderComponent && /* @__PURE__ */
|
|
4378
|
+
MenuHeaderComponent && /* @__PURE__ */ jsx34(
|
|
4333
4379
|
MenuHeaderComponent,
|
|
4334
4380
|
{
|
|
4335
4381
|
backArrowLabel,
|
|
@@ -4337,7 +4383,7 @@ var NestedMenu = ({
|
|
|
4337
4383
|
}
|
|
4338
4384
|
),
|
|
4339
4385
|
children && children,
|
|
4340
|
-
menuItems && !children && /* @__PURE__ */
|
|
4386
|
+
menuItems && !children && /* @__PURE__ */ jsx34(
|
|
4341
4387
|
NestedMenuContent,
|
|
4342
4388
|
{
|
|
4343
4389
|
menuItems,
|
|
@@ -4351,7 +4397,7 @@ var NestedMenu = ({
|
|
|
4351
4397
|
),
|
|
4352
4398
|
...restMenuProps
|
|
4353
4399
|
};
|
|
4354
|
-
return /* @__PURE__ */
|
|
4400
|
+
return /* @__PURE__ */ jsx34(
|
|
4355
4401
|
NestedMenuProvider,
|
|
4356
4402
|
{
|
|
4357
4403
|
...{
|
|
@@ -4365,11 +4411,11 @@ var NestedMenu = ({
|
|
|
4365
4411
|
setActiveMenuContext,
|
|
4366
4412
|
animationSpeed
|
|
4367
4413
|
},
|
|
4368
|
-
children: /* @__PURE__ */
|
|
4414
|
+
children: /* @__PURE__ */ jsx34(
|
|
4369
4415
|
NestedMenuPopout,
|
|
4370
4416
|
{
|
|
4371
4417
|
content: MenuComponent && // Handles the rerender of the component
|
|
4372
|
-
/* @__PURE__ */
|
|
4418
|
+
/* @__PURE__ */ jsx34(AnimatePresence2, { mode: "wait", children: /* @__PURE__ */ jsx34(
|
|
4373
4419
|
motion3.div,
|
|
4374
4420
|
{
|
|
4375
4421
|
variants: menuVariants,
|
|
@@ -4377,7 +4423,7 @@ var NestedMenu = ({
|
|
|
4377
4423
|
animate: "enter",
|
|
4378
4424
|
exit: "leave",
|
|
4379
4425
|
custom: { isAdding, hasLoadedOnce },
|
|
4380
|
-
children: /* @__PURE__ */
|
|
4426
|
+
children: /* @__PURE__ */ jsx34(MenuComponent, { ...nestedMenuProps })
|
|
4381
4427
|
},
|
|
4382
4428
|
`${currentMenuId}-content`
|
|
4383
4429
|
) }),
|