@overmap-ai/blocks 1.0.34-command-menu.2 → 1.0.34-command-menu.4
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/dist/CheckedIndicator/CheckedIndicator.d.ts +2 -2
- package/dist/CommandMenu/CheckboxIndicator.d.ts +1 -2
- package/dist/CommandMenu/MultiSelectGroup.d.ts +2 -4
- package/dist/CommandMenu/RadioGroup.d.ts +2 -5
- package/dist/CommandMenu/SelectedIndicator.d.ts +1 -2
- package/dist/CommandMenu/context.d.ts +1 -13
- package/dist/CommandMenu/index.d.ts +2 -2
- package/dist/CommandMenu/utils.d.ts +1 -1
- package/dist/Menu/CheckboxItemIndicator/CheckboxItemIndicator.d.ts +1 -1
- package/dist/Menu/SelectAll/index.d.ts +0 -1
- package/dist/Menu/SelectedIndicator/SelectedIndicator.d.ts +1 -1
- package/dist/Menu/SelectedIndicator/context.d.ts +2 -6
- package/dist/Menu/cva.d.ts +0 -3
- package/dist/Menu/index.d.ts +2 -3
- package/dist/Menu/typings.d.ts +3 -9
- package/dist/Menu/utils.d.ts +7 -1
- package/dist/SelectContext/MultiSelectProvider.d.ts +3 -0
- package/dist/SelectContext/SingleSelectProvider.d.ts +4 -0
- package/dist/SelectContext/context.d.ts +13 -3
- package/dist/SelectContext/index.d.ts +2 -2
- package/dist/SelectContext/typings.d.ts +16 -8
- package/dist/blocks.js +278 -235
- package/dist/blocks.js.map +1 -1
- package/dist/blocks.umd.cjs +277 -234
- package/dist/blocks.umd.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/Menu/SelectAll/SelectAllIndicator.d.ts +0 -3
- package/dist/Menu/SelectAll/context.d.ts +0 -6
- package/dist/SelectContext/Provider.d.ts +0 -14
package/dist/blocks.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as RadixAlertDialog from "@radix-ui/react-alert-dialog";
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { cva, cx } from "class-variance-authority";
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import React__default, { createContext, useContext, useMemo, forwardRef, memo, useState, useCallback, useLayoutEffect, useEffect, use,
|
|
5
|
+
import React__default, { createContext, useContext, useMemo, forwardRef, memo, useState, useCallback, useLayoutEffect, useEffect, use, useRef } from "react";
|
|
6
6
|
import * as RadixAvatar from "@radix-ui/react-avatar";
|
|
7
7
|
import * as RadixCheckbox from "@radix-ui/react-checkbox";
|
|
8
8
|
import * as RadixPrimitiveCollapsible from "@radix-ui/react-collapsible";
|
|
@@ -1021,30 +1021,37 @@ const CollapsibleTree = genericMemo(function(props) {
|
|
|
1021
1021
|
);
|
|
1022
1022
|
});
|
|
1023
1023
|
const CommandMenuContext = createContext({});
|
|
1024
|
-
const SelectContext$1 = createContext({});
|
|
1025
|
-
const MultiSelectGroupContext = createContext({});
|
|
1026
1024
|
const SelectedIndicatorContext$1 = createContext(false);
|
|
1027
1025
|
const CheckboxIndicatorContext = createContext(false);
|
|
1028
1026
|
const CommandMenuPageContext = createContext({});
|
|
1029
1027
|
const CommandMenuDialogContext = createContext({});
|
|
1030
|
-
function getSelectedState(selected) {
|
|
1028
|
+
function getSelectedState$1(selected) {
|
|
1031
1029
|
return selected ? "selected" : "unselected";
|
|
1032
1030
|
}
|
|
1033
|
-
function getCheckedState(checked) {
|
|
1031
|
+
function getCheckedState$1(checked) {
|
|
1034
1032
|
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
1035
1033
|
}
|
|
1036
1034
|
function getActiveState(active) {
|
|
1037
1035
|
return active ? "active" : "inactive";
|
|
1038
1036
|
}
|
|
1039
1037
|
const CommandMenuCheckboxIndicator = (props) => {
|
|
1040
|
-
const { ref,
|
|
1038
|
+
const { ref, className, children, ...rest } = props;
|
|
1041
1039
|
const checkedState = use(CheckboxIndicatorContext);
|
|
1042
1040
|
const computedChildren = useMemo(() => {
|
|
1043
1041
|
return typeof children === "function" ? children(checkedState) : children;
|
|
1044
1042
|
}, [checkedState, children]);
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1043
|
+
return /* @__PURE__ */ jsx(
|
|
1044
|
+
"span",
|
|
1045
|
+
{
|
|
1046
|
+
ref,
|
|
1047
|
+
"data-state": getCheckedState$1(checkedState),
|
|
1048
|
+
className: cx(className, "inline-block size-max", {
|
|
1049
|
+
invisible: checkedState === false
|
|
1050
|
+
}),
|
|
1051
|
+
...rest,
|
|
1052
|
+
children: computedChildren
|
|
1053
|
+
}
|
|
1054
|
+
);
|
|
1048
1055
|
};
|
|
1049
1056
|
const commandMenuContentCva = cva(
|
|
1050
1057
|
[
|
|
@@ -1287,7 +1294,7 @@ const CommandMenuCheckboxItem = (props) => {
|
|
|
1287
1294
|
},
|
|
1288
1295
|
[checked, onCheckedChange, onSelect]
|
|
1289
1296
|
);
|
|
1290
|
-
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState(checked), ...rest, children }) });
|
|
1297
|
+
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState$1(checked), ...rest, children }) });
|
|
1291
1298
|
};
|
|
1292
1299
|
const CommandMenuContent = memo((props) => {
|
|
1293
1300
|
const providerContext = useProvider();
|
|
@@ -1378,10 +1385,26 @@ const CommandMenuList = memo((props) => {
|
|
|
1378
1385
|
);
|
|
1379
1386
|
});
|
|
1380
1387
|
CommandMenuList.displayName = "CommandMenuList";
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
const
|
|
1388
|
+
const SelectContext = createContext({});
|
|
1389
|
+
const MultiSelectContext = createContext({});
|
|
1390
|
+
const MultiSelectProvider = memo((props) => {
|
|
1391
|
+
const { children, defaultValues, values: controlledValues, onValuesChange } = props;
|
|
1392
|
+
const [itemValueMapping, setItemValueMapping] = useState(/* @__PURE__ */ new Set());
|
|
1393
|
+
const [values, setValues] = useControlledState(defaultValues ?? [], controlledValues, onValuesChange);
|
|
1394
|
+
const registerValue = useCallback((value) => {
|
|
1395
|
+
setItemValueMapping((prev) => {
|
|
1396
|
+
const newSet = new Set(prev);
|
|
1397
|
+
newSet.add(value);
|
|
1398
|
+
return newSet;
|
|
1399
|
+
});
|
|
1400
|
+
return () => {
|
|
1401
|
+
setItemValueMapping((prev) => {
|
|
1402
|
+
const newSet = new Set(prev);
|
|
1403
|
+
newSet.delete(value);
|
|
1404
|
+
return newSet;
|
|
1405
|
+
});
|
|
1406
|
+
};
|
|
1407
|
+
}, []);
|
|
1385
1408
|
const selected = useCallback((value) => values.includes(value), [values]);
|
|
1386
1409
|
const selectValue = useCallback(
|
|
1387
1410
|
(value) => {
|
|
@@ -1393,37 +1416,65 @@ const CommandMenuMultiSelectGroup = (props) => {
|
|
|
1393
1416
|
},
|
|
1394
1417
|
[selected, setValues, values]
|
|
1395
1418
|
);
|
|
1396
|
-
const
|
|
1397
|
-
return
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
}, [
|
|
1402
|
-
const
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
values
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1419
|
+
const allSelected = useMemo(() => {
|
|
1420
|
+
return Array.from(itemValueMapping.values()).every((value) => values.includes(value));
|
|
1421
|
+
}, [itemValueMapping, values]);
|
|
1422
|
+
const someSelected = useMemo(() => {
|
|
1423
|
+
return Array.from(itemValueMapping.values()).some((value) => values.includes(value));
|
|
1424
|
+
}, [itemValueMapping, values]);
|
|
1425
|
+
const toggleSelectAll = useCallback(() => {
|
|
1426
|
+
if (allSelected) {
|
|
1427
|
+
setValues([]);
|
|
1428
|
+
} else {
|
|
1429
|
+
setValues(Array.from(itemValueMapping.values()));
|
|
1430
|
+
}
|
|
1431
|
+
}, [allSelected, itemValueMapping, setValues]);
|
|
1432
|
+
const contextValue = useMemo(
|
|
1433
|
+
() => ({ selected, selectValue, allSelected, someSelected, toggleSelectAll, registerValue }),
|
|
1434
|
+
[allSelected, registerValue, selectValue, selected, someSelected, toggleSelectAll]
|
|
1435
|
+
);
|
|
1436
|
+
return /* @__PURE__ */ jsx(MultiSelectContext, { value: contextValue, children });
|
|
1437
|
+
});
|
|
1438
|
+
MultiSelectProvider.displayName = "MultiSelectProvider";
|
|
1439
|
+
const SingleSelectRequiredProvider = memo((props) => {
|
|
1440
|
+
const { children, defaultValue, value, onValueChange } = props;
|
|
1441
|
+
const [controlledValue, setControlledValue] = useControlledState(defaultValue ?? "", value, onValueChange);
|
|
1442
|
+
const selected = useCallback((v) => v === controlledValue, [controlledValue]);
|
|
1443
|
+
const selectValue = useCallback(
|
|
1444
|
+
(v) => {
|
|
1445
|
+
if (selected(v)) return;
|
|
1446
|
+
setControlledValue(v);
|
|
1447
|
+
},
|
|
1448
|
+
[selected, setControlledValue]
|
|
1449
|
+
);
|
|
1450
|
+
const contextValue = useMemo(() => ({ selected, selectValue }), [selectValue, selected]);
|
|
1451
|
+
return /* @__PURE__ */ jsx(SelectContext, { value: contextValue, children });
|
|
1452
|
+
});
|
|
1453
|
+
SingleSelectRequiredProvider.displayName = "SingleSelectRequiredProvider";
|
|
1454
|
+
const SingleSelectNotRequiredProvider = memo((props) => {
|
|
1455
|
+
const { children, defaultValue = null, value: controlledValue, onValueChange } = props;
|
|
1456
|
+
const [value, setValue] = useControlledState(defaultValue, controlledValue, onValueChange);
|
|
1457
|
+
const selected = useCallback((v) => v === value, [value]);
|
|
1458
|
+
const selectValue = useCallback(
|
|
1459
|
+
(v) => {
|
|
1460
|
+
setValue(selected(v) ? null : v);
|
|
1461
|
+
},
|
|
1462
|
+
[selected, setValue]
|
|
1463
|
+
);
|
|
1464
|
+
const contextValue = useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1465
|
+
return /* @__PURE__ */ jsx(SelectContext, { value: contextValue, children });
|
|
1466
|
+
});
|
|
1467
|
+
SingleSelectNotRequiredProvider.displayName = "SingleSelectNotRequiredProvider";
|
|
1468
|
+
const CommandMenuMultiSelectGroup = (props) => {
|
|
1469
|
+
const { children, ref, defaultValues, values, onValuesChange, ...rest } = props;
|
|
1470
|
+
return /* @__PURE__ */ jsx(MultiSelectProvider, { values, onValuesChange, defaultValues, children: /* @__PURE__ */ jsx(CommandMenuGroup, { ref, "aria-multiselectable": true, ...rest, children }) });
|
|
1411
1471
|
};
|
|
1412
1472
|
const CommandMenuMultiSelectItem = (props) => {
|
|
1413
1473
|
const { children, ref, value, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1414
|
-
const { selected, selectValue: handleSelectValue } = use(
|
|
1415
|
-
const itemValueId = useId();
|
|
1416
|
-
const { setItemValueMapping } = use(MultiSelectGroupContext);
|
|
1474
|
+
const { selected, selectValue: handleSelectValue, registerValue } = use(MultiSelectContext);
|
|
1417
1475
|
useLayoutEffect(() => {
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
setItemValueMapping((prev) => {
|
|
1421
|
-
const next = new Map(prev);
|
|
1422
|
-
next.delete(itemValueId);
|
|
1423
|
-
return next;
|
|
1424
|
-
});
|
|
1425
|
-
};
|
|
1426
|
-
}, [itemValueId, setItemValueMapping, value]);
|
|
1476
|
+
return registerValue(value);
|
|
1477
|
+
}, [registerValue, value]);
|
|
1427
1478
|
const handleSelect = useCallback(
|
|
1428
1479
|
(value2) => {
|
|
1429
1480
|
onSelect == null ? void 0 : onSelect(value2);
|
|
@@ -1437,7 +1488,7 @@ const CommandMenuMultiSelectItem = (props) => {
|
|
|
1437
1488
|
{
|
|
1438
1489
|
ref,
|
|
1439
1490
|
onSelect: handleSelect,
|
|
1440
|
-
"data-state": getSelectedState(isSelected),
|
|
1491
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1441
1492
|
"aria-selected": isSelected,
|
|
1442
1493
|
value,
|
|
1443
1494
|
closeOnSelect,
|
|
@@ -1485,21 +1536,20 @@ const CommandMenuPageTriggerItem = (props) => {
|
|
|
1485
1536
|
) });
|
|
1486
1537
|
};
|
|
1487
1538
|
const CommandMenuRadioGroup = (props) => {
|
|
1488
|
-
const { children, ref, defaultValue
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
return /* @__PURE__ */ jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: /* @__PURE__ */ jsx(SelectContext$1, { value: contextValue, children }) });
|
|
1539
|
+
const { children, ref, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
1540
|
+
return /* @__PURE__ */ jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: required ? /* @__PURE__ */ jsx(SingleSelectRequiredProvider, { defaultValue, value, onValueChange, children }) : /* @__PURE__ */ jsx(
|
|
1541
|
+
SingleSelectNotRequiredProvider,
|
|
1542
|
+
{
|
|
1543
|
+
defaultValue,
|
|
1544
|
+
value,
|
|
1545
|
+
onValueChange,
|
|
1546
|
+
children
|
|
1547
|
+
}
|
|
1548
|
+
) });
|
|
1499
1549
|
};
|
|
1500
1550
|
const CommandMenuRadioItem = (props) => {
|
|
1501
1551
|
const { children, ref, value, onSelect, ...rest } = props;
|
|
1502
|
-
const { selected, selectValue } = use(SelectContext
|
|
1552
|
+
const { selected, selectValue } = use(SelectContext);
|
|
1503
1553
|
const handleSelect = useCallback(
|
|
1504
1554
|
(value2) => {
|
|
1505
1555
|
onSelect == null ? void 0 : onSelect(value2);
|
|
@@ -1513,7 +1563,7 @@ const CommandMenuRadioItem = (props) => {
|
|
|
1513
1563
|
{
|
|
1514
1564
|
ref,
|
|
1515
1565
|
onSelect: handleSelect,
|
|
1516
|
-
"data-state": getSelectedState(isSelected),
|
|
1566
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1517
1567
|
value,
|
|
1518
1568
|
...rest,
|
|
1519
1569
|
children
|
|
@@ -1534,41 +1584,45 @@ const CommandMenuRoot = memo((props) => {
|
|
|
1534
1584
|
CommandMenuRoot.displayName = "CommandMenuRoot";
|
|
1535
1585
|
const CommandMenuSelectAllItem = (props) => {
|
|
1536
1586
|
const { ref, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1537
|
-
const {
|
|
1538
|
-
const selectedState = useMemo(() => {
|
|
1539
|
-
const allValues = Array.from(itemValueMapping.values());
|
|
1540
|
-
if (allValues.every((value) => values.includes(value))) return true;
|
|
1541
|
-
if (allValues.some((value) => values.includes(value))) return "indeterminate";
|
|
1542
|
-
return false;
|
|
1543
|
-
}, [itemValueMapping, values]);
|
|
1587
|
+
const { allSelected, someSelected, toggleSelectAll } = use(MultiSelectContext);
|
|
1544
1588
|
const handleSelect = useCallback(
|
|
1545
1589
|
(value) => {
|
|
1546
1590
|
onSelect == null ? void 0 : onSelect(value);
|
|
1547
|
-
|
|
1591
|
+
toggleSelectAll();
|
|
1548
1592
|
},
|
|
1549
|
-
[
|
|
1593
|
+
[onSelect, toggleSelectAll]
|
|
1550
1594
|
);
|
|
1595
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
1551
1596
|
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsx(
|
|
1552
1597
|
CommandMenuItem,
|
|
1553
1598
|
{
|
|
1554
1599
|
ref,
|
|
1555
1600
|
role: "menuitemcheckbox",
|
|
1556
1601
|
onSelect: handleSelect,
|
|
1557
|
-
"data-state": getCheckedState(selectedState),
|
|
1602
|
+
"data-state": getCheckedState$1(selectedState),
|
|
1558
1603
|
closeOnSelect,
|
|
1559
1604
|
...rest
|
|
1560
1605
|
}
|
|
1561
1606
|
) });
|
|
1562
1607
|
};
|
|
1563
1608
|
const CommandMenuSelectedIndicator = (props) => {
|
|
1564
|
-
const { ref,
|
|
1609
|
+
const { ref, className, children, ...rest } = props;
|
|
1565
1610
|
const isSelected = use(SelectedIndicatorContext$1);
|
|
1566
1611
|
const computedChildren = useMemo(() => {
|
|
1567
1612
|
return typeof children === "function" ? children(isSelected) : children;
|
|
1568
1613
|
}, [isSelected, children]);
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1614
|
+
return /* @__PURE__ */ jsx(
|
|
1615
|
+
"span",
|
|
1616
|
+
{
|
|
1617
|
+
ref,
|
|
1618
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1619
|
+
className: cx(className, "inline-block size-max", {
|
|
1620
|
+
invisible: !isSelected
|
|
1621
|
+
}),
|
|
1622
|
+
...rest,
|
|
1623
|
+
children: computedChildren
|
|
1624
|
+
}
|
|
1625
|
+
);
|
|
1572
1626
|
};
|
|
1573
1627
|
const CommandMenuSeparator = memo((props) => {
|
|
1574
1628
|
const { className, ref, spacing = false, ...rest } = props;
|
|
@@ -2621,29 +2675,53 @@ const Link = forwardRef((props, ref) => {
|
|
|
2621
2675
|
Link.displayName = "Link";
|
|
2622
2676
|
const CheckedIndicatorContext = createContext({});
|
|
2623
2677
|
const CheckedIndicator = (props) => {
|
|
2624
|
-
const { children } = props;
|
|
2678
|
+
const { children, ref, className, ...rest } = props;
|
|
2625
2679
|
const checked = useContext(CheckedIndicatorContext);
|
|
2626
2680
|
const computedChildren = typeof children === "function" ? children(checked === "indeterminate") : children;
|
|
2627
|
-
return
|
|
2681
|
+
return /* @__PURE__ */ jsx(
|
|
2682
|
+
"span",
|
|
2683
|
+
{
|
|
2684
|
+
ref,
|
|
2685
|
+
className: cx(className, {
|
|
2686
|
+
invisible: checked === false
|
|
2687
|
+
}),
|
|
2688
|
+
"data-state": getCheckedState$1(checked),
|
|
2689
|
+
...rest,
|
|
2690
|
+
children: computedChildren
|
|
2691
|
+
}
|
|
2692
|
+
);
|
|
2628
2693
|
};
|
|
2629
2694
|
const menuItem = cva(
|
|
2630
|
-
[
|
|
2695
|
+
[
|
|
2696
|
+
"select-none",
|
|
2697
|
+
"relative",
|
|
2698
|
+
"flex",
|
|
2699
|
+
"items-center",
|
|
2700
|
+
"rounded",
|
|
2701
|
+
"outline-none",
|
|
2702
|
+
"data-[disabled=true]:text-(--base-a8)"
|
|
2703
|
+
],
|
|
2631
2704
|
{
|
|
2632
2705
|
variants: {
|
|
2633
2706
|
size: {
|
|
2634
|
-
xs: ["h-5", "
|
|
2635
|
-
sm: ["h-6", "
|
|
2636
|
-
md: ["h-7", "
|
|
2637
|
-
lg: ["h-8", "
|
|
2638
|
-
xl: ["h-9", "
|
|
2707
|
+
xs: ["h-5", "gap-1.5", "px-1.5"],
|
|
2708
|
+
sm: ["h-6", "gap-2.25", "px-2.25"],
|
|
2709
|
+
md: ["h-7", "gap-3", "px-3"],
|
|
2710
|
+
lg: ["h-8", "gap-3.75", "px-3.75"],
|
|
2711
|
+
xl: ["h-9", "gap-4.5", "px-4.5"]
|
|
2639
2712
|
},
|
|
2640
2713
|
variant: {
|
|
2641
2714
|
solid: [
|
|
2642
2715
|
"text-(--base-12)",
|
|
2643
|
-
"data-highlighted:not-data-disabled:text-(--accent-contrast)",
|
|
2644
|
-
"data-highlighted:not-data-disabled:bg-(--accent-a9)"
|
|
2716
|
+
"data-highlighted:not-data-[disabled=true]:text-(--accent-contrast)",
|
|
2717
|
+
"data-highlighted:not-data-[disabled=true]:bg-(--accent-a9)",
|
|
2718
|
+
"data-highlighted:not-data-[disabled=true]:active:brightness-110"
|
|
2645
2719
|
],
|
|
2646
|
-
soft: [
|
|
2720
|
+
soft: [
|
|
2721
|
+
"text-(--base-12)",
|
|
2722
|
+
"data-highlighted:not-data-[disabled=true]:bg-(--accent-a3)",
|
|
2723
|
+
"data-highlighted:not-data-[disabled=true]:active:bg-(--accent-a4)"
|
|
2724
|
+
]
|
|
2647
2725
|
}
|
|
2648
2726
|
},
|
|
2649
2727
|
defaultVariants: {
|
|
@@ -2666,20 +2744,6 @@ const menuSeparator = cva(["h-px", "bg-(--base-a6)", "w-auto", "shrink-0"], {
|
|
|
2666
2744
|
size: "md"
|
|
2667
2745
|
}
|
|
2668
2746
|
});
|
|
2669
|
-
const menuSelectedIndicator = cva(["flex", "items-center", "justify-center"], {
|
|
2670
|
-
variants: {
|
|
2671
|
-
size: {
|
|
2672
|
-
xs: ["w-4", "h-4"],
|
|
2673
|
-
sm: ["w-5", "h-5"],
|
|
2674
|
-
md: ["w-6", "h-6"],
|
|
2675
|
-
lg: ["w-7", "h-7"],
|
|
2676
|
-
xl: ["w-8", "h-8"]
|
|
2677
|
-
}
|
|
2678
|
-
},
|
|
2679
|
-
defaultVariants: {
|
|
2680
|
-
size: "md"
|
|
2681
|
-
}
|
|
2682
|
-
});
|
|
2683
2747
|
const menuContent = cva(
|
|
2684
2748
|
[
|
|
2685
2749
|
"flex",
|
|
@@ -2692,8 +2756,6 @@ const menuContent = cva(
|
|
|
2692
2756
|
"ring-1",
|
|
2693
2757
|
"ring-(--base-6)",
|
|
2694
2758
|
"overflow-hidden"
|
|
2695
|
-
// "[scrollbar-width:thin]",
|
|
2696
|
-
// "[scrollbar-color:var(--base-6)_transparent]",
|
|
2697
2759
|
],
|
|
2698
2760
|
{
|
|
2699
2761
|
variants: {
|
|
@@ -2735,8 +2797,8 @@ const inputRoot = cva(
|
|
|
2735
2797
|
"flex",
|
|
2736
2798
|
"items-stretch",
|
|
2737
2799
|
"transition-colors",
|
|
2738
|
-
"
|
|
2739
|
-
"
|
|
2800
|
+
"data-[disabled=true]:opacity-50",
|
|
2801
|
+
"data-[disabled=true]:pointer-events-none",
|
|
2740
2802
|
"box-border",
|
|
2741
2803
|
"bg-transparent",
|
|
2742
2804
|
"text-(--base-12)"
|
|
@@ -2851,6 +2913,37 @@ const MenuRoot = (props) => {
|
|
|
2851
2913
|
) });
|
|
2852
2914
|
};
|
|
2853
2915
|
MenuRoot.displayName = "Root";
|
|
2916
|
+
const computeOffsets = (side, alignment) => {
|
|
2917
|
+
switch (side) {
|
|
2918
|
+
case "right":
|
|
2919
|
+
if (alignment === "start") {
|
|
2920
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2921
|
+
} else if (alignment === "end") {
|
|
2922
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2923
|
+
}
|
|
2924
|
+
break;
|
|
2925
|
+
case "left":
|
|
2926
|
+
if (alignment === "start") {
|
|
2927
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2928
|
+
} else if (alignment === "end") {
|
|
2929
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2930
|
+
}
|
|
2931
|
+
break;
|
|
2932
|
+
}
|
|
2933
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
2934
|
+
};
|
|
2935
|
+
function getSelectedState(selected) {
|
|
2936
|
+
return selected ? "selected" : "unselected";
|
|
2937
|
+
}
|
|
2938
|
+
function getCheckedState(checked) {
|
|
2939
|
+
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
2940
|
+
}
|
|
2941
|
+
function getBooleanState(value) {
|
|
2942
|
+
return value ? "true" : "false";
|
|
2943
|
+
}
|
|
2944
|
+
function getOpenState(open) {
|
|
2945
|
+
return open ? "open" : "closed";
|
|
2946
|
+
}
|
|
2854
2947
|
const MenuContentContext = createContext({});
|
|
2855
2948
|
const useMenuContentContext = () => useContext(MenuContentContext);
|
|
2856
2949
|
const MenuContent = memo(
|
|
@@ -2938,7 +3031,7 @@ const MenuContent = memo(
|
|
|
2938
3031
|
"max-h-(--overmap-menu-available-height)"
|
|
2939
3032
|
),
|
|
2940
3033
|
ref: forwardedRef,
|
|
2941
|
-
"data-state": open
|
|
3034
|
+
"data-state": getOpenState(open),
|
|
2942
3035
|
"data-side": side,
|
|
2943
3036
|
"data-accent-color": accentColor,
|
|
2944
3037
|
...rest,
|
|
@@ -2955,25 +3048,6 @@ const MenuContent = memo(
|
|
|
2955
3048
|
);
|
|
2956
3049
|
const SubContext = createContext({});
|
|
2957
3050
|
const useSubContext = () => useContext(SubContext);
|
|
2958
|
-
const computeOffsets = (side, alignment) => {
|
|
2959
|
-
switch (side) {
|
|
2960
|
-
case "right":
|
|
2961
|
-
if (alignment === "start") {
|
|
2962
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2963
|
-
} else if (alignment === "end") {
|
|
2964
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2965
|
-
}
|
|
2966
|
-
break;
|
|
2967
|
-
case "left":
|
|
2968
|
-
if (alignment === "start") {
|
|
2969
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2970
|
-
} else if (alignment === "end") {
|
|
2971
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2972
|
-
}
|
|
2973
|
-
break;
|
|
2974
|
-
}
|
|
2975
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
2976
|
-
};
|
|
2977
3051
|
const MenuSub = (props) => {
|
|
2978
3052
|
const {
|
|
2979
3053
|
children,
|
|
@@ -3085,7 +3159,7 @@ const MenuItem = memo(
|
|
|
3085
3159
|
onClick,
|
|
3086
3160
|
onKeyDown,
|
|
3087
3161
|
closeOnSelect = true,
|
|
3088
|
-
disabled,
|
|
3162
|
+
disabled = false,
|
|
3089
3163
|
...rest
|
|
3090
3164
|
} = props;
|
|
3091
3165
|
const { ref, index } = useListItem();
|
|
@@ -3122,7 +3196,7 @@ const MenuItem = memo(
|
|
|
3122
3196
|
className: cx(className, menuItem({ size: size2, variant }), radiusCva({ radius, maxLarge: true })),
|
|
3123
3197
|
ref: mergeRefs2,
|
|
3124
3198
|
role: "menuitem",
|
|
3125
|
-
"data-disabled": disabled
|
|
3199
|
+
"data-disabled": getBooleanState(disabled),
|
|
3126
3200
|
"aria-disabled": disabled,
|
|
3127
3201
|
"data-highlighted": isActive ? "" : void 0,
|
|
3128
3202
|
...getItemProps({
|
|
@@ -3154,9 +3228,8 @@ const MenuCheckboxItem = forwardRef((props, ref) => {
|
|
|
3154
3228
|
});
|
|
3155
3229
|
MenuCheckboxItem.displayName = "MenuCheckboxItem";
|
|
3156
3230
|
const MenuCheckboxItemIndicator = forwardRef((props, ref) => {
|
|
3157
|
-
const {
|
|
3158
|
-
|
|
3159
|
-
return /* @__PURE__ */ jsx("span", { ref, className: cx(className, menuSelectedIndicator({ size: size2 })), ...rest, children: /* @__PURE__ */ jsx(CheckedIndicator, { children }) });
|
|
3231
|
+
const { children, ...rest } = props;
|
|
3232
|
+
return /* @__PURE__ */ jsx(CheckedIndicator, { ref, ...rest, children });
|
|
3160
3233
|
});
|
|
3161
3234
|
MenuCheckboxItemIndicator.displayName = "MenuCheckboxItemIndicator";
|
|
3162
3235
|
const MenuClickTrigger = memo(
|
|
@@ -3172,8 +3245,8 @@ const MenuClickTrigger = memo(
|
|
|
3172
3245
|
{
|
|
3173
3246
|
ref: mergedRefs,
|
|
3174
3247
|
"aria-disabled": disabled,
|
|
3175
|
-
"data-disabled": disabled
|
|
3176
|
-
"data-state": open
|
|
3248
|
+
"data-disabled": getBooleanState(disabled),
|
|
3249
|
+
"data-state": getOpenState(open),
|
|
3177
3250
|
...getReferenceProps({ disabled }),
|
|
3178
3251
|
children
|
|
3179
3252
|
}
|
|
@@ -3182,9 +3255,9 @@ const MenuClickTrigger = memo(
|
|
|
3182
3255
|
);
|
|
3183
3256
|
const MenuContextTrigger = memo(
|
|
3184
3257
|
forwardRef((props, forwardedRef) => {
|
|
3185
|
-
const { children, disabled } = props;
|
|
3258
|
+
const { children, disabled = false } = props;
|
|
3186
3259
|
const ref = useRef(null);
|
|
3187
|
-
const { setOpen, refs, setTriggerType } = useMenuContext();
|
|
3260
|
+
const { setOpen, refs, setTriggerType, open } = useMenuContext();
|
|
3188
3261
|
const mergedRefs = useMergeRefs([forwardedRef, ref]);
|
|
3189
3262
|
useEffect(() => {
|
|
3190
3263
|
setTriggerType("context");
|
|
@@ -3220,7 +3293,8 @@ const MenuContextTrigger = memo(
|
|
|
3220
3293
|
ref: mergedRefs,
|
|
3221
3294
|
style: { WebkitTouchCallout: disabled ? "none" : "unset" },
|
|
3222
3295
|
"aria-disabled": disabled,
|
|
3223
|
-
"data-disabled": disabled
|
|
3296
|
+
"data-disabled": getBooleanState(disabled),
|
|
3297
|
+
"data-state": getOpenState(open),
|
|
3224
3298
|
onContextMenu: handleContextMenu,
|
|
3225
3299
|
children
|
|
3226
3300
|
}
|
|
@@ -3235,7 +3309,7 @@ const MenuGroup = memo(
|
|
|
3235
3309
|
);
|
|
3236
3310
|
const MenuInputField = memo(
|
|
3237
3311
|
forwardRef((props, forwardedRef) => {
|
|
3238
|
-
const { className, onValueChange, onChange, ...rest } = props;
|
|
3312
|
+
const { className, onValueChange, onChange, disabled = false, ...rest } = props;
|
|
3239
3313
|
const { activeIndex, getItemProps } = useMenuContentContext();
|
|
3240
3314
|
const { index, ref } = useListItem();
|
|
3241
3315
|
const mergedRefs = useMergeRefs([ref, forwardedRef]);
|
|
@@ -3256,6 +3330,8 @@ const MenuInputField = memo(
|
|
|
3256
3330
|
{
|
|
3257
3331
|
className: cx(className, "placeholder-(--base-a9)", "selection:bg-(--accent-a5)", "outline-none"),
|
|
3258
3332
|
ref: mergedRefs,
|
|
3333
|
+
disabled,
|
|
3334
|
+
"data-disabled": getBooleanState(disabled),
|
|
3259
3335
|
...getItemProps({
|
|
3260
3336
|
...rest,
|
|
3261
3337
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
@@ -3278,86 +3354,53 @@ const MenuInputSlot = memo(
|
|
|
3278
3354
|
return /* @__PURE__ */ jsx("div", { className: cx(className, "flex", "items-center", "text-(--base-a11)"), ref, ...rest });
|
|
3279
3355
|
})
|
|
3280
3356
|
);
|
|
3281
|
-
const SelectContext = createContext({});
|
|
3282
|
-
function useSelectContext() {
|
|
3283
|
-
return useContext(SelectContext);
|
|
3284
|
-
}
|
|
3285
|
-
const SelectContextProvider = memo((props) => {
|
|
3286
|
-
const { type, children } = props;
|
|
3287
|
-
const [controlledValue, setControlledValue] = useState(
|
|
3288
|
-
type === "single" ? (props == null ? void 0 : props.defaultValue) ?? null : null
|
|
3289
|
-
);
|
|
3290
|
-
const [controlledValues, setControlledValues] = useState(
|
|
3291
|
-
type === "multi" ? (props == null ? void 0 : props.defaultValues) ?? [] : []
|
|
3292
|
-
);
|
|
3293
|
-
const onValuesChange = useCallback(
|
|
3294
|
-
(values) => {
|
|
3295
|
-
setControlledValues(values);
|
|
3296
|
-
if (type === "multi" && (props == null ? void 0 : props.onValuesChange)) props.onValuesChange(values);
|
|
3297
|
-
},
|
|
3298
|
-
[props, type]
|
|
3299
|
-
);
|
|
3300
|
-
const onValueChange = useCallback(
|
|
3301
|
-
(value2) => {
|
|
3302
|
-
setControlledValue(value2);
|
|
3303
|
-
if (type === "single" && (props == null ? void 0 : props.onValueChange)) props.onValueChange(value2);
|
|
3304
|
-
},
|
|
3305
|
-
[props, type]
|
|
3306
|
-
);
|
|
3307
|
-
const value = useMemo(
|
|
3308
|
-
() => type === "multi" ? {
|
|
3309
|
-
type,
|
|
3310
|
-
values: (props == null ? void 0 : props.values) ?? controlledValues,
|
|
3311
|
-
handleValuesChange: onValuesChange
|
|
3312
|
-
} : {
|
|
3313
|
-
type,
|
|
3314
|
-
value: props.value ?? controlledValue,
|
|
3315
|
-
handleValueChange: onValueChange
|
|
3316
|
-
},
|
|
3317
|
-
[controlledValue, controlledValues, onValueChange, onValuesChange, props, type]
|
|
3318
|
-
);
|
|
3319
|
-
return /* @__PURE__ */ jsx(SelectContext.Provider, { value, children });
|
|
3320
|
-
});
|
|
3321
|
-
SelectContextProvider.displayName = "SelectContextProvider";
|
|
3322
3357
|
const MenuMultiSelectGroup = memo(
|
|
3323
3358
|
forwardRef((props, ref) => {
|
|
3324
|
-
const { children, values, onValuesChange, ...rest } = props;
|
|
3325
|
-
return /* @__PURE__ */ jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsx(
|
|
3359
|
+
const { children, defaultValues, values, onValuesChange, ...rest } = props;
|
|
3360
|
+
return /* @__PURE__ */ jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsx(MultiSelectProvider, { defaultValues, values, onValuesChange, children }) });
|
|
3326
3361
|
})
|
|
3327
3362
|
);
|
|
3328
|
-
const SelectedIndicatorContext = createContext(
|
|
3363
|
+
const SelectedIndicatorContext = createContext(false);
|
|
3329
3364
|
const useSelectedIndicatorContext = () => useContext(SelectedIndicatorContext);
|
|
3330
3365
|
const MenuSelectedIndicator = forwardRef((props, ref) => {
|
|
3331
3366
|
const { children } = props;
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
|
|
3367
|
+
const isSelected = useSelectedIndicatorContext();
|
|
3368
|
+
return /* @__PURE__ */ jsx(
|
|
3369
|
+
"span",
|
|
3370
|
+
{
|
|
3371
|
+
ref,
|
|
3372
|
+
className: cx({
|
|
3373
|
+
invisible: !isSelected
|
|
3374
|
+
}),
|
|
3375
|
+
"data-state": getSelectedState(isSelected),
|
|
3376
|
+
children
|
|
3377
|
+
}
|
|
3378
|
+
);
|
|
3335
3379
|
});
|
|
3336
3380
|
MenuSelectedIndicator.displayName = "SelectedIndicator";
|
|
3337
3381
|
const MenuMultiSelectItem = memo(
|
|
3338
3382
|
forwardRef((props, ref) => {
|
|
3339
3383
|
const { onSelect, children, closeOnSelect = false, value, ...rest } = props;
|
|
3340
|
-
const {
|
|
3341
|
-
|
|
3384
|
+
const { selected, selectValue, registerValue } = use(MultiSelectContext);
|
|
3385
|
+
useLayoutEffect(() => {
|
|
3386
|
+
return registerValue(value);
|
|
3387
|
+
}, [registerValue, value]);
|
|
3388
|
+
const isSelected = selected(value);
|
|
3342
3389
|
const handleSelect = useCallback(() => {
|
|
3343
|
-
if (!selected) {
|
|
3344
|
-
handleValuesChange([...values, value]);
|
|
3345
|
-
} else {
|
|
3346
|
-
handleValuesChange(values.filter((currentValue) => currentValue !== value));
|
|
3347
|
-
}
|
|
3348
3390
|
if (onSelect) onSelect();
|
|
3349
|
-
|
|
3391
|
+
selectValue(value);
|
|
3392
|
+
}, [onSelect, selectValue, value]);
|
|
3350
3393
|
const computedChildren = useMemo(() => {
|
|
3351
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3352
|
-
}, [children,
|
|
3353
|
-
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value:
|
|
3394
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3395
|
+
}, [children, isSelected]);
|
|
3396
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
3354
3397
|
MenuItem,
|
|
3355
3398
|
{
|
|
3356
3399
|
ref,
|
|
3357
3400
|
role: "menuitemcheckbox",
|
|
3358
3401
|
onSelect: handleSelect,
|
|
3359
3402
|
closeOnSelect,
|
|
3360
|
-
"data-
|
|
3403
|
+
"data-state": getSelectedState(isSelected),
|
|
3361
3404
|
...rest,
|
|
3362
3405
|
children: computedChildren
|
|
3363
3406
|
}
|
|
@@ -3407,71 +3450,72 @@ const MenuScroll = forwardRef((props, ref) => {
|
|
|
3407
3450
|
);
|
|
3408
3451
|
});
|
|
3409
3452
|
MenuScroll.displayName = "MenuScroll";
|
|
3410
|
-
const SelectAllContext = createContext({});
|
|
3411
|
-
const MenuSelectAllIndicator = forwardRef((props, ref) => {
|
|
3412
|
-
const { className, children, ...rest } = props;
|
|
3413
|
-
const { size: size2 } = useMenuContentContext();
|
|
3414
|
-
const { selected } = useContext(SelectAllContext);
|
|
3415
|
-
const computedChildren = useMemo(() => {
|
|
3416
|
-
return typeof children === "function" ? children(selected === "indeterminate") : children;
|
|
3417
|
-
}, [children, selected]);
|
|
3418
|
-
return /* @__PURE__ */ jsx("span", { ref, className: cx(className, menuSelectedIndicator({ size: size2 })), ...rest, children: selected ? computedChildren : null });
|
|
3419
|
-
});
|
|
3420
|
-
MenuSelectAllIndicator.displayName = "SelectAllIndicator";
|
|
3421
3453
|
const MenuSelectAllItem = forwardRef((props, ref) => {
|
|
3422
|
-
const { children,
|
|
3423
|
-
const {
|
|
3424
|
-
const
|
|
3425
|
-
const selectValuesSet = new Set(values);
|
|
3426
|
-
if (allValues.every((value) => selectValuesSet.has(value))) return true;
|
|
3427
|
-
if (values.length > 0) return "indeterminate";
|
|
3428
|
-
return false;
|
|
3429
|
-
}, [allValues, values]);
|
|
3454
|
+
const { children, onSelect, closeOnSelect = false, ...rest } = props;
|
|
3455
|
+
const { allSelected, someSelected, toggleSelectAll } = use(MultiSelectContext);
|
|
3456
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
3430
3457
|
const handleSelect = useCallback(() => {
|
|
3431
3458
|
onSelect == null ? void 0 : onSelect();
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
handleValuesChange([]);
|
|
3435
|
-
break;
|
|
3436
|
-
case "indeterminate":
|
|
3437
|
-
case false: {
|
|
3438
|
-
handleValuesChange(allValues);
|
|
3439
|
-
break;
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
}, [allValues, handleValuesChange, onSelect, selected]);
|
|
3459
|
+
toggleSelectAll();
|
|
3460
|
+
}, [onSelect, toggleSelectAll]);
|
|
3443
3461
|
const computedChildren = useMemo(() => {
|
|
3444
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3445
|
-
}, [children,
|
|
3446
|
-
return /* @__PURE__ */ jsx(
|
|
3462
|
+
return typeof children === "function" ? ({ active }) => children({ selected: selectedState, active }) : children;
|
|
3463
|
+
}, [children, selectedState]);
|
|
3464
|
+
return /* @__PURE__ */ jsx(CheckedIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsx(
|
|
3465
|
+
MenuItem,
|
|
3466
|
+
{
|
|
3467
|
+
onSelect: handleSelect,
|
|
3468
|
+
ref,
|
|
3469
|
+
"data-state": getCheckedState(selectedState),
|
|
3470
|
+
closeOnSelect,
|
|
3471
|
+
...rest,
|
|
3472
|
+
children: computedChildren
|
|
3473
|
+
}
|
|
3474
|
+
) });
|
|
3447
3475
|
});
|
|
3448
3476
|
MenuSelectAllItem.displayName = "SelectAllItem";
|
|
3449
3477
|
const MenuSelectGroup = memo(
|
|
3450
3478
|
forwardRef((props, ref) => {
|
|
3451
|
-
const { children, value, onValueChange } = props;
|
|
3452
|
-
return /* @__PURE__ */ jsx(
|
|
3479
|
+
const { children, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
3480
|
+
return /* @__PURE__ */ jsx(MenuGroup, { ref, ...rest, children: required ? /* @__PURE__ */ jsx(
|
|
3481
|
+
SingleSelectRequiredProvider,
|
|
3482
|
+
{
|
|
3483
|
+
defaultValue,
|
|
3484
|
+
value,
|
|
3485
|
+
onValueChange,
|
|
3486
|
+
children
|
|
3487
|
+
}
|
|
3488
|
+
) : /* @__PURE__ */ jsx(
|
|
3489
|
+
SingleSelectNotRequiredProvider,
|
|
3490
|
+
{
|
|
3491
|
+
defaultValue,
|
|
3492
|
+
value,
|
|
3493
|
+
onValueChange,
|
|
3494
|
+
children
|
|
3495
|
+
}
|
|
3496
|
+
) });
|
|
3453
3497
|
})
|
|
3454
3498
|
);
|
|
3455
3499
|
const MenuSelectItem = memo(
|
|
3456
3500
|
forwardRef((props, ref) => {
|
|
3457
3501
|
const { value, onSelect, children, closeOnSelect = true, ...rest } = props;
|
|
3458
|
-
const {
|
|
3459
|
-
const
|
|
3502
|
+
const { selected, selectValue } = use(SelectContext);
|
|
3503
|
+
const isSelected = useMemo(() => selected(value), [selected, value]);
|
|
3460
3504
|
const handleSelect = useCallback(() => {
|
|
3461
|
-
handleValueChange(!selected ? value : null);
|
|
3462
3505
|
if (onSelect) onSelect();
|
|
3463
|
-
|
|
3506
|
+
selectValue(value);
|
|
3507
|
+
}, [onSelect, selectValue, value]);
|
|
3464
3508
|
const computedChildren = useMemo(() => {
|
|
3465
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3466
|
-
}, [children,
|
|
3467
|
-
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value:
|
|
3509
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3510
|
+
}, [children, isSelected]);
|
|
3511
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
3468
3512
|
MenuItem,
|
|
3469
3513
|
{
|
|
3470
3514
|
ref,
|
|
3471
3515
|
role: "menuitemcheckbox",
|
|
3472
3516
|
onSelect: handleSelect,
|
|
3473
3517
|
closeOnSelect,
|
|
3474
|
-
"data-
|
|
3518
|
+
"data-state": getSelectedState(isSelected),
|
|
3475
3519
|
...rest,
|
|
3476
3520
|
children: computedChildren
|
|
3477
3521
|
}
|
|
@@ -3548,7 +3592,7 @@ const MenuSubContent = memo(
|
|
|
3548
3592
|
"max-h-(--overmap-menu-available-height)"
|
|
3549
3593
|
),
|
|
3550
3594
|
ref: forwardedRef,
|
|
3551
|
-
"data-state": open
|
|
3595
|
+
"data-state": getOpenState(open),
|
|
3552
3596
|
"data-side": side,
|
|
3553
3597
|
"data-accent-color": accentColor,
|
|
3554
3598
|
...rest,
|
|
@@ -3572,7 +3616,7 @@ const MenuSubTrigger = memo(
|
|
|
3572
3616
|
ref: mergedRefs,
|
|
3573
3617
|
closeOnSelect: false,
|
|
3574
3618
|
"aria-haspopup": "menu",
|
|
3575
|
-
"data-
|
|
3619
|
+
"data-state": getOpenState(open),
|
|
3576
3620
|
disabled,
|
|
3577
3621
|
...getReferenceProps(rest),
|
|
3578
3622
|
children
|
|
@@ -3624,7 +3668,6 @@ const Menu = {
|
|
|
3624
3668
|
SelectAllItem: MenuSelectAllItem,
|
|
3625
3669
|
CheckboxItem: MenuCheckboxItem,
|
|
3626
3670
|
// indicators
|
|
3627
|
-
SelectAllIndicator: MenuSelectAllIndicator,
|
|
3628
3671
|
SelectedIndicator: MenuSelectedIndicator,
|
|
3629
3672
|
CheckboxItemIndicator: MenuCheckboxItemIndicator,
|
|
3630
3673
|
// input
|
|
@@ -5006,7 +5049,6 @@ export {
|
|
|
5006
5049
|
MenuPages,
|
|
5007
5050
|
MenuRoot,
|
|
5008
5051
|
MenuScroll,
|
|
5009
|
-
MenuSelectAllIndicator,
|
|
5010
5052
|
MenuSelectAllItem,
|
|
5011
5053
|
MenuSelectGroup,
|
|
5012
5054
|
MenuSelectItem,
|
|
@@ -5065,6 +5107,7 @@ export {
|
|
|
5065
5107
|
unsafeShowToast,
|
|
5066
5108
|
useAlertDialog,
|
|
5067
5109
|
useButtonGroup,
|
|
5110
|
+
useControlledState,
|
|
5068
5111
|
useLayoutContext,
|
|
5069
5112
|
useMenuContentContext,
|
|
5070
5113
|
useMenuContext,
|