@overmap-ai/blocks 1.0.34-command-menu.3 → 1.0.34-command-menu.5
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/Item.d.ts +3 -1
- package/dist/CommandMenu/MultiSelectGroup.d.ts +3 -5
- package/dist/CommandMenu/MultiSelectItem.d.ts +3 -3
- package/dist/CommandMenu/RadioGroup.d.ts +3 -6
- package/dist/CommandMenu/RadioItem.d.ts +3 -3
- package/dist/CommandMenu/SelectAllItem.d.ts +1 -1
- package/dist/CommandMenu/SelectedIndicator.d.ts +1 -2
- package/dist/CommandMenu/context.d.ts +1 -13
- package/dist/CommandMenu/index.d.ts +7 -7
- package/dist/CommandMenu/utils.d.ts +1 -1
- package/dist/Menu/CheckboxItem/CheckboxItem.d.ts +1 -1
- package/dist/Menu/CheckboxItemIndicator/CheckboxItemIndicator.d.ts +1 -1
- package/dist/Menu/Group/Group.d.ts +1 -1
- package/dist/Menu/Item/Item.d.ts +1 -1
- package/dist/Menu/MultiSelectGroup/MultiSelectGroup.d.ts +1 -2
- package/dist/Menu/MultiSelectItem/MultiSelectItem.d.ts +1 -2
- package/dist/Menu/PageTrigger/PageTrigger.d.ts +1 -1
- package/dist/Menu/SelectAll/SelectAllItem.d.ts +1 -2
- package/dist/Menu/SelectAll/index.d.ts +0 -1
- package/dist/Menu/SelectGroup/SelectGroup.d.ts +1 -2
- package/dist/Menu/SelectItem/SelectItem.d.ts +1 -2
- package/dist/Menu/SelectedIndicator/SelectedIndicator.d.ts +1 -1
- package/dist/Menu/SelectedIndicator/context.d.ts +2 -6
- package/dist/Menu/SubTrigger/SubTrigger.d.ts +1 -1
- package/dist/Menu/cva.d.ts +0 -3
- package/dist/Menu/index.d.ts +12 -13
- package/dist/Menu/typings.d.ts +8 -16
- 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 +14 -4
- package/dist/SelectContext/index.d.ts +2 -2
- package/dist/SelectContext/typings.d.ts +16 -8
- package/dist/blocks.js +403 -397
- package/dist/blocks.js.map +1 -1
- package/dist/blocks.umd.cjs +402 -396
- package/dist/blocks.umd.cjs.map +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
|
[
|
|
@@ -1255,24 +1262,22 @@ const commandMenuGroupCva = cva(
|
|
|
1255
1262
|
}
|
|
1256
1263
|
);
|
|
1257
1264
|
const CommandMenuItem = memo((props) => {
|
|
1258
|
-
const { className, ref, closeOnSelect = true, onSelect, ...rest } = props;
|
|
1265
|
+
const { className, ref, closeOnSelect = true, onSelect, filterValue, ...rest } = props;
|
|
1259
1266
|
const { size: size2, variant, radius } = use(CommandMenuContext);
|
|
1260
1267
|
const { setOpen } = use(CommandMenuDialogContext);
|
|
1261
|
-
const handleSelect = useCallback(
|
|
1262
|
-
(
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
},
|
|
1268
|
-
[closeOnSelect, onSelect, setOpen]
|
|
1269
|
-
);
|
|
1268
|
+
const handleSelect = useCallback(() => {
|
|
1269
|
+
onSelect == null ? void 0 : onSelect();
|
|
1270
|
+
if (closeOnSelect) {
|
|
1271
|
+
setOpen(false);
|
|
1272
|
+
}
|
|
1273
|
+
}, [closeOnSelect, onSelect, setOpen]);
|
|
1270
1274
|
return /* @__PURE__ */ jsx(
|
|
1271
1275
|
CommandItem,
|
|
1272
1276
|
{
|
|
1273
1277
|
className: cx(className, commandMenuItemCva({ size: size2, variant, radius })),
|
|
1274
1278
|
ref,
|
|
1275
1279
|
onSelect: handleSelect,
|
|
1280
|
+
value: filterValue,
|
|
1276
1281
|
...rest
|
|
1277
1282
|
}
|
|
1278
1283
|
);
|
|
@@ -1280,14 +1285,11 @@ const CommandMenuItem = memo((props) => {
|
|
|
1280
1285
|
CommandMenuItem.displayName = "CommandMenuItem";
|
|
1281
1286
|
const CommandMenuCheckboxItem = (props) => {
|
|
1282
1287
|
const { children, ref, checked, onCheckedChange, onSelect, ...rest } = props;
|
|
1283
|
-
const handleSelect = useCallback(
|
|
1284
|
-
(
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
[checked, onCheckedChange, onSelect]
|
|
1289
|
-
);
|
|
1290
|
-
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState(checked), ...rest, children }) });
|
|
1288
|
+
const handleSelect = useCallback(() => {
|
|
1289
|
+
onSelect == null ? void 0 : onSelect();
|
|
1290
|
+
onCheckedChange(checked !== true);
|
|
1291
|
+
}, [checked, onCheckedChange, onSelect]);
|
|
1292
|
+
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState$1(checked), ...rest, children }) });
|
|
1291
1293
|
};
|
|
1292
1294
|
const CommandMenuContent = memo((props) => {
|
|
1293
1295
|
const providerContext = useProvider();
|
|
@@ -1378,10 +1380,26 @@ const CommandMenuList = memo((props) => {
|
|
|
1378
1380
|
);
|
|
1379
1381
|
});
|
|
1380
1382
|
CommandMenuList.displayName = "CommandMenuList";
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
const
|
|
1383
|
+
const SelectContext = createContext({});
|
|
1384
|
+
const MultiSelectContext = createContext({});
|
|
1385
|
+
const MultiSelectProvider = genericMemo(function MultiSelectProvider2(props) {
|
|
1386
|
+
const { children, defaultValues, values: controlledValues, onValuesChange } = props;
|
|
1387
|
+
const [itemValueMapping, setItemValueMapping] = useState(/* @__PURE__ */ new Set());
|
|
1388
|
+
const [values, setValues] = useControlledState(defaultValues ?? [], controlledValues, onValuesChange);
|
|
1389
|
+
const registerValue = useCallback((value) => {
|
|
1390
|
+
setItemValueMapping((prev) => {
|
|
1391
|
+
const newSet = new Set(prev);
|
|
1392
|
+
newSet.add(value);
|
|
1393
|
+
return newSet;
|
|
1394
|
+
});
|
|
1395
|
+
return () => {
|
|
1396
|
+
setItemValueMapping((prev) => {
|
|
1397
|
+
const newSet = new Set(prev);
|
|
1398
|
+
newSet.delete(value);
|
|
1399
|
+
return newSet;
|
|
1400
|
+
});
|
|
1401
|
+
};
|
|
1402
|
+
}, []);
|
|
1385
1403
|
const selected = useCallback((value) => values.includes(value), [values]);
|
|
1386
1404
|
const selectValue = useCallback(
|
|
1387
1405
|
(value) => {
|
|
@@ -1393,59 +1411,84 @@ const CommandMenuMultiSelectGroup = (props) => {
|
|
|
1393
1411
|
},
|
|
1394
1412
|
[selected, setValues, values]
|
|
1395
1413
|
);
|
|
1396
|
-
const
|
|
1397
|
-
return
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
}, [
|
|
1402
|
-
const
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
values
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
const {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}, [
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1414
|
+
const allSelected = useMemo(() => {
|
|
1415
|
+
return Array.from(itemValueMapping.values()).every((value) => values.includes(value));
|
|
1416
|
+
}, [itemValueMapping, values]);
|
|
1417
|
+
const someSelected = useMemo(() => {
|
|
1418
|
+
return Array.from(itemValueMapping.values()).some((value) => values.includes(value));
|
|
1419
|
+
}, [itemValueMapping, values]);
|
|
1420
|
+
const toggleSelectAll = useCallback(() => {
|
|
1421
|
+
if (allSelected) {
|
|
1422
|
+
setValues([]);
|
|
1423
|
+
} else {
|
|
1424
|
+
setValues(Array.from(itemValueMapping.values()));
|
|
1425
|
+
}
|
|
1426
|
+
}, [allSelected, itemValueMapping, setValues]);
|
|
1427
|
+
const contextValue = useMemo(
|
|
1428
|
+
() => ({ selected, selectValue, allSelected, someSelected, toggleSelectAll, registerValue }),
|
|
1429
|
+
[allSelected, registerValue, selectValue, selected, someSelected, toggleSelectAll]
|
|
1430
|
+
);
|
|
1431
|
+
return /* @__PURE__ */ jsx(MultiSelectContext, { value: contextValue, children });
|
|
1432
|
+
});
|
|
1433
|
+
const SingleSelectRequiredProvider = genericMemo(function SingleSelectRequiredProvider2(props) {
|
|
1434
|
+
const { children, defaultValue, value, onValueChange } = props;
|
|
1435
|
+
const [controlledValue, setControlledValue] = useControlledState(defaultValue, value, onValueChange);
|
|
1436
|
+
const selected = useCallback((v) => v === controlledValue, [controlledValue]);
|
|
1437
|
+
const selectValue = useCallback(
|
|
1438
|
+
(v) => {
|
|
1439
|
+
if (selected(v)) return;
|
|
1440
|
+
setControlledValue(v);
|
|
1441
|
+
},
|
|
1442
|
+
[selected, setControlledValue]
|
|
1443
|
+
);
|
|
1444
|
+
const contextValue = useMemo(() => ({ selected, selectValue }), [selectValue, selected]);
|
|
1445
|
+
return /* @__PURE__ */ jsx(SelectContext, { value: contextValue, children });
|
|
1446
|
+
});
|
|
1447
|
+
const SingleSelectNotRequiredProvider = genericMemo(function SingleSelectNotRequiredProvider2(props) {
|
|
1448
|
+
const { children, defaultValue = null, value: controlledValue, onValueChange } = props;
|
|
1449
|
+
const [value, setValue] = useControlledState(defaultValue, controlledValue, onValueChange);
|
|
1450
|
+
const selected = useCallback((v) => v === value, [value]);
|
|
1451
|
+
const selectValue = useCallback(
|
|
1452
|
+
(v) => {
|
|
1453
|
+
setValue(selected(v) ? null : v);
|
|
1431
1454
|
},
|
|
1432
|
-
[
|
|
1455
|
+
[selected, setValue]
|
|
1433
1456
|
);
|
|
1457
|
+
const contextValue = useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1458
|
+
return /* @__PURE__ */ jsx(SelectContext, { value: contextValue, children });
|
|
1459
|
+
});
|
|
1460
|
+
const CommandMenuMultiSelectGroup = genericMemo(function CommandMenuMultiSelectGroup2(props) {
|
|
1461
|
+
const { children, ref, defaultValues, values, onValuesChange, ...rest } = props;
|
|
1462
|
+
return /* @__PURE__ */ jsx(MultiSelectProvider, { values, onValuesChange, defaultValues, children: /* @__PURE__ */ jsx(CommandMenuGroup, { ref, "aria-multiselectable": true, ...rest, children }) });
|
|
1463
|
+
});
|
|
1464
|
+
const CommandMenuMultiSelectItem = genericMemo(function(props) {
|
|
1465
|
+
const { children, ref, value, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1466
|
+
const {
|
|
1467
|
+
selected,
|
|
1468
|
+
selectValue: handleSelectValue,
|
|
1469
|
+
registerValue
|
|
1470
|
+
} = use(MultiSelectContext);
|
|
1471
|
+
useLayoutEffect(() => {
|
|
1472
|
+
return registerValue(value);
|
|
1473
|
+
}, [registerValue, value]);
|
|
1474
|
+
const handleSelect = useCallback(() => {
|
|
1475
|
+
onSelect == null ? void 0 : onSelect();
|
|
1476
|
+
handleSelectValue(value);
|
|
1477
|
+
}, [handleSelectValue, onSelect, value]);
|
|
1434
1478
|
const isSelected = selected(value);
|
|
1435
1479
|
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
1436
1480
|
CommandMenuItem,
|
|
1437
1481
|
{
|
|
1438
1482
|
ref,
|
|
1439
1483
|
onSelect: handleSelect,
|
|
1440
|
-
"data-state": getSelectedState(isSelected),
|
|
1484
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1441
1485
|
"aria-selected": isSelected,
|
|
1442
|
-
value,
|
|
1443
1486
|
closeOnSelect,
|
|
1444
1487
|
...rest,
|
|
1445
1488
|
children
|
|
1446
1489
|
}
|
|
1447
1490
|
) });
|
|
1448
|
-
};
|
|
1491
|
+
});
|
|
1449
1492
|
const CommandMenuOverlay = memo((props) => {
|
|
1450
1493
|
const { container, className, ...rest } = props;
|
|
1451
1494
|
return /* @__PURE__ */ jsx(DialogPortal, { container, children: /* @__PURE__ */ jsx(DialogOverlay$1, { className: cx(className, commandMenuOverlayCva()), "data-floating-content": "", ...rest }) });
|
|
@@ -1466,13 +1509,10 @@ const CommandMenuPageTriggerItem = (props) => {
|
|
|
1466
1509
|
const { ref, page, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1467
1510
|
const { page: activePage, setPage } = use(CommandMenuPageContext);
|
|
1468
1511
|
const isActive = useMemo(() => page === activePage, [page, activePage]);
|
|
1469
|
-
const handleSelect = useCallback(
|
|
1470
|
-
(
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
},
|
|
1474
|
-
[onSelect, page, setPage]
|
|
1475
|
-
);
|
|
1512
|
+
const handleSelect = useCallback(() => {
|
|
1513
|
+
onSelect == null ? void 0 : onSelect();
|
|
1514
|
+
setPage(page);
|
|
1515
|
+
}, [onSelect, page, setPage]);
|
|
1476
1516
|
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isActive, children: /* @__PURE__ */ jsx(
|
|
1477
1517
|
CommandMenuItem,
|
|
1478
1518
|
{
|
|
@@ -1484,42 +1524,36 @@ const CommandMenuPageTriggerItem = (props) => {
|
|
|
1484
1524
|
}
|
|
1485
1525
|
) });
|
|
1486
1526
|
};
|
|
1487
|
-
const CommandMenuRadioGroup = (props)
|
|
1488
|
-
const { children, ref, defaultValue
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
const selectValue = useCallback(
|
|
1492
|
-
(v) => {
|
|
1493
|
-
setValue(selected(v) ? null : v);
|
|
1494
|
-
},
|
|
1495
|
-
[selected, setValue]
|
|
1496
|
-
);
|
|
1497
|
-
const contextValue = useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1498
|
-
return /* @__PURE__ */ jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: /* @__PURE__ */ jsx(SelectContext$1, { value: contextValue, children }) });
|
|
1499
|
-
};
|
|
1500
|
-
const CommandMenuRadioItem = (props) => {
|
|
1501
|
-
const { children, ref, value, onSelect, ...rest } = props;
|
|
1502
|
-
const { selected, selectValue } = use(SelectContext$1);
|
|
1503
|
-
const handleSelect = useCallback(
|
|
1504
|
-
(value2) => {
|
|
1505
|
-
onSelect == null ? void 0 : onSelect(value2);
|
|
1506
|
-
selectValue(value2);
|
|
1507
|
-
},
|
|
1508
|
-
[onSelect, selectValue]
|
|
1509
|
-
);
|
|
1510
|
-
const isSelected = selected(value);
|
|
1511
|
-
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
1512
|
-
CommandMenuItem,
|
|
1527
|
+
const CommandMenuRadioGroup = genericMemo(function CommandMenuRadioGroup2(props) {
|
|
1528
|
+
const { children, ref, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
1529
|
+
return /* @__PURE__ */ jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: required ? /* @__PURE__ */ jsx(
|
|
1530
|
+
SingleSelectRequiredProvider,
|
|
1513
1531
|
{
|
|
1514
|
-
|
|
1515
|
-
onSelect: handleSelect,
|
|
1516
|
-
"data-state": getSelectedState(isSelected),
|
|
1532
|
+
defaultValue,
|
|
1517
1533
|
value,
|
|
1518
|
-
|
|
1534
|
+
onValueChange,
|
|
1535
|
+
children
|
|
1536
|
+
}
|
|
1537
|
+
) : /* @__PURE__ */ jsx(
|
|
1538
|
+
SingleSelectNotRequiredProvider,
|
|
1539
|
+
{
|
|
1540
|
+
defaultValue,
|
|
1541
|
+
value,
|
|
1542
|
+
onValueChange,
|
|
1519
1543
|
children
|
|
1520
1544
|
}
|
|
1521
1545
|
) });
|
|
1522
|
-
};
|
|
1546
|
+
});
|
|
1547
|
+
const CommandMenuRadioItem = genericMemo(function(props) {
|
|
1548
|
+
const { children, ref, value, onSelect, ...rest } = props;
|
|
1549
|
+
const { selected, selectValue } = use(SelectContext);
|
|
1550
|
+
const handleSelect = useCallback(() => {
|
|
1551
|
+
onSelect == null ? void 0 : onSelect();
|
|
1552
|
+
selectValue(value);
|
|
1553
|
+
}, [onSelect, selectValue, value]);
|
|
1554
|
+
const isSelected = selected(value);
|
|
1555
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getSelectedState$1(isSelected), ...rest, children }) });
|
|
1556
|
+
});
|
|
1523
1557
|
const CommandMenuRoot = memo((props) => {
|
|
1524
1558
|
const { children, defaultOpen, open: controlledOpen, onOpenChange } = props;
|
|
1525
1559
|
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
@@ -1532,43 +1566,44 @@ const CommandMenuRoot = memo((props) => {
|
|
|
1532
1566
|
return /* @__PURE__ */ jsx(Dialog$1, { open, onOpenChange: setOpen, ...props, children: /* @__PURE__ */ jsx(CommandMenuDialogContext, { value: contextValue, children }) });
|
|
1533
1567
|
});
|
|
1534
1568
|
CommandMenuRoot.displayName = "CommandMenuRoot";
|
|
1535
|
-
const CommandMenuSelectAllItem = (props)
|
|
1569
|
+
const CommandMenuSelectAllItem = genericMemo(function(props) {
|
|
1536
1570
|
const { ref, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1537
|
-
const {
|
|
1538
|
-
const
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
}, [itemValueMapping, values]);
|
|
1544
|
-
const handleSelect = useCallback(
|
|
1545
|
-
(value) => {
|
|
1546
|
-
onSelect == null ? void 0 : onSelect(value);
|
|
1547
|
-
setValues(selectedState !== true ? Array.from(itemValueMapping.values()) : []);
|
|
1548
|
-
},
|
|
1549
|
-
[itemValueMapping, onSelect, selectedState, setValues]
|
|
1550
|
-
);
|
|
1571
|
+
const { allSelected, someSelected, toggleSelectAll } = use(MultiSelectContext);
|
|
1572
|
+
const handleSelect = useCallback(() => {
|
|
1573
|
+
onSelect == null ? void 0 : onSelect();
|
|
1574
|
+
toggleSelectAll();
|
|
1575
|
+
}, [onSelect, toggleSelectAll]);
|
|
1576
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
1551
1577
|
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsx(
|
|
1552
1578
|
CommandMenuItem,
|
|
1553
1579
|
{
|
|
1554
1580
|
ref,
|
|
1555
1581
|
role: "menuitemcheckbox",
|
|
1556
1582
|
onSelect: handleSelect,
|
|
1557
|
-
"data-state": getCheckedState(selectedState),
|
|
1583
|
+
"data-state": getCheckedState$1(selectedState),
|
|
1558
1584
|
closeOnSelect,
|
|
1559
1585
|
...rest
|
|
1560
1586
|
}
|
|
1561
1587
|
) });
|
|
1562
|
-
};
|
|
1588
|
+
});
|
|
1563
1589
|
const CommandMenuSelectedIndicator = (props) => {
|
|
1564
|
-
const { ref,
|
|
1590
|
+
const { ref, className, children, ...rest } = props;
|
|
1565
1591
|
const isSelected = use(SelectedIndicatorContext$1);
|
|
1566
1592
|
const computedChildren = useMemo(() => {
|
|
1567
1593
|
return typeof children === "function" ? children(isSelected) : children;
|
|
1568
1594
|
}, [isSelected, children]);
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1595
|
+
return /* @__PURE__ */ jsx(
|
|
1596
|
+
"span",
|
|
1597
|
+
{
|
|
1598
|
+
ref,
|
|
1599
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1600
|
+
className: cx(className, "inline-block size-max", {
|
|
1601
|
+
invisible: !isSelected
|
|
1602
|
+
}),
|
|
1603
|
+
...rest,
|
|
1604
|
+
children: computedChildren
|
|
1605
|
+
}
|
|
1606
|
+
);
|
|
1572
1607
|
};
|
|
1573
1608
|
const CommandMenuSeparator = memo((props) => {
|
|
1574
1609
|
const { className, ref, spacing = false, ...rest } = props;
|
|
@@ -2621,29 +2656,53 @@ const Link = forwardRef((props, ref) => {
|
|
|
2621
2656
|
Link.displayName = "Link";
|
|
2622
2657
|
const CheckedIndicatorContext = createContext({});
|
|
2623
2658
|
const CheckedIndicator = (props) => {
|
|
2624
|
-
const { children } = props;
|
|
2659
|
+
const { children, ref, className, ...rest } = props;
|
|
2625
2660
|
const checked = useContext(CheckedIndicatorContext);
|
|
2626
2661
|
const computedChildren = typeof children === "function" ? children(checked === "indeterminate") : children;
|
|
2627
|
-
return
|
|
2662
|
+
return /* @__PURE__ */ jsx(
|
|
2663
|
+
"span",
|
|
2664
|
+
{
|
|
2665
|
+
ref,
|
|
2666
|
+
className: cx(className, {
|
|
2667
|
+
invisible: checked === false
|
|
2668
|
+
}),
|
|
2669
|
+
"data-state": getCheckedState$1(checked),
|
|
2670
|
+
...rest,
|
|
2671
|
+
children: computedChildren
|
|
2672
|
+
}
|
|
2673
|
+
);
|
|
2628
2674
|
};
|
|
2629
2675
|
const menuItem = cva(
|
|
2630
|
-
[
|
|
2676
|
+
[
|
|
2677
|
+
"select-none",
|
|
2678
|
+
"relative",
|
|
2679
|
+
"flex",
|
|
2680
|
+
"items-center",
|
|
2681
|
+
"rounded",
|
|
2682
|
+
"outline-none",
|
|
2683
|
+
"data-[disabled=true]:text-(--base-a8)"
|
|
2684
|
+
],
|
|
2631
2685
|
{
|
|
2632
2686
|
variants: {
|
|
2633
2687
|
size: {
|
|
2634
|
-
xs: ["h-5", "
|
|
2635
|
-
sm: ["h-6", "
|
|
2636
|
-
md: ["h-7", "
|
|
2637
|
-
lg: ["h-8", "
|
|
2638
|
-
xl: ["h-9", "
|
|
2688
|
+
xs: ["h-5", "gap-1.5", "px-1.5"],
|
|
2689
|
+
sm: ["h-6", "gap-2.25", "px-2.25"],
|
|
2690
|
+
md: ["h-7", "gap-3", "px-3"],
|
|
2691
|
+
lg: ["h-8", "gap-3.75", "px-3.75"],
|
|
2692
|
+
xl: ["h-9", "gap-4.5", "px-4.5"]
|
|
2639
2693
|
},
|
|
2640
2694
|
variant: {
|
|
2641
2695
|
solid: [
|
|
2642
2696
|
"text-(--base-12)",
|
|
2643
|
-
"data-highlighted:not-data-disabled:text-(--accent-contrast)",
|
|
2644
|
-
"data-highlighted:not-data-disabled:bg-(--accent-a9)"
|
|
2697
|
+
"data-highlighted:not-data-[disabled=true]:text-(--accent-contrast)",
|
|
2698
|
+
"data-highlighted:not-data-[disabled=true]:bg-(--accent-a9)",
|
|
2699
|
+
"data-highlighted:not-data-[disabled=true]:active:brightness-110"
|
|
2645
2700
|
],
|
|
2646
|
-
soft: [
|
|
2701
|
+
soft: [
|
|
2702
|
+
"text-(--base-12)",
|
|
2703
|
+
"data-highlighted:not-data-[disabled=true]:bg-(--accent-a3)",
|
|
2704
|
+
"data-highlighted:not-data-[disabled=true]:active:bg-(--accent-a4)"
|
|
2705
|
+
]
|
|
2647
2706
|
}
|
|
2648
2707
|
},
|
|
2649
2708
|
defaultVariants: {
|
|
@@ -2666,20 +2725,6 @@ const menuSeparator = cva(["h-px", "bg-(--base-a6)", "w-auto", "shrink-0"], {
|
|
|
2666
2725
|
size: "md"
|
|
2667
2726
|
}
|
|
2668
2727
|
});
|
|
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
2728
|
const menuContent = cva(
|
|
2684
2729
|
[
|
|
2685
2730
|
"flex",
|
|
@@ -2692,8 +2737,6 @@ const menuContent = cva(
|
|
|
2692
2737
|
"ring-1",
|
|
2693
2738
|
"ring-(--base-6)",
|
|
2694
2739
|
"overflow-hidden"
|
|
2695
|
-
// "[scrollbar-width:thin]",
|
|
2696
|
-
// "[scrollbar-color:var(--base-6)_transparent]",
|
|
2697
2740
|
],
|
|
2698
2741
|
{
|
|
2699
2742
|
variants: {
|
|
@@ -2735,8 +2778,8 @@ const inputRoot = cva(
|
|
|
2735
2778
|
"flex",
|
|
2736
2779
|
"items-stretch",
|
|
2737
2780
|
"transition-colors",
|
|
2738
|
-
"
|
|
2739
|
-
"
|
|
2781
|
+
"data-[disabled=true]:opacity-50",
|
|
2782
|
+
"data-[disabled=true]:pointer-events-none",
|
|
2740
2783
|
"box-border",
|
|
2741
2784
|
"bg-transparent",
|
|
2742
2785
|
"text-(--base-12)"
|
|
@@ -2851,6 +2894,37 @@ const MenuRoot = (props) => {
|
|
|
2851
2894
|
) });
|
|
2852
2895
|
};
|
|
2853
2896
|
MenuRoot.displayName = "Root";
|
|
2897
|
+
const computeOffsets = (side, alignment) => {
|
|
2898
|
+
switch (side) {
|
|
2899
|
+
case "right":
|
|
2900
|
+
if (alignment === "start") {
|
|
2901
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2902
|
+
} else if (alignment === "end") {
|
|
2903
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2904
|
+
}
|
|
2905
|
+
break;
|
|
2906
|
+
case "left":
|
|
2907
|
+
if (alignment === "start") {
|
|
2908
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2909
|
+
} else if (alignment === "end") {
|
|
2910
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2911
|
+
}
|
|
2912
|
+
break;
|
|
2913
|
+
}
|
|
2914
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
2915
|
+
};
|
|
2916
|
+
function getSelectedState(selected) {
|
|
2917
|
+
return selected ? "selected" : "unselected";
|
|
2918
|
+
}
|
|
2919
|
+
function getCheckedState(checked) {
|
|
2920
|
+
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
2921
|
+
}
|
|
2922
|
+
function getBooleanState(value) {
|
|
2923
|
+
return value ? "true" : "false";
|
|
2924
|
+
}
|
|
2925
|
+
function getOpenState(open) {
|
|
2926
|
+
return open ? "open" : "closed";
|
|
2927
|
+
}
|
|
2854
2928
|
const MenuContentContext = createContext({});
|
|
2855
2929
|
const useMenuContentContext = () => useContext(MenuContentContext);
|
|
2856
2930
|
const MenuContent = memo(
|
|
@@ -2938,7 +3012,7 @@ const MenuContent = memo(
|
|
|
2938
3012
|
"max-h-(--overmap-menu-available-height)"
|
|
2939
3013
|
),
|
|
2940
3014
|
ref: forwardedRef,
|
|
2941
|
-
"data-state": open
|
|
3015
|
+
"data-state": getOpenState(open),
|
|
2942
3016
|
"data-side": side,
|
|
2943
3017
|
"data-accent-color": accentColor,
|
|
2944
3018
|
...rest,
|
|
@@ -2955,25 +3029,6 @@ const MenuContent = memo(
|
|
|
2955
3029
|
);
|
|
2956
3030
|
const SubContext = createContext({});
|
|
2957
3031
|
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
3032
|
const MenuSub = (props) => {
|
|
2978
3033
|
const {
|
|
2979
3034
|
children,
|
|
@@ -3073,69 +3128,69 @@ const MenuSub = (props) => {
|
|
|
3073
3128
|
};
|
|
3074
3129
|
MenuSub.displayName = "SubMenu";
|
|
3075
3130
|
const TRIGGER_SELECT_KEYS = ["Enter", " "];
|
|
3076
|
-
const MenuItem = memo(
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3131
|
+
const MenuItem = memo((props) => {
|
|
3132
|
+
const rootMenuContext = useMenuContext();
|
|
3133
|
+
const { getItemProps, activeIndex, setOpen, size: size2, variant, radius } = useMenuContentContext();
|
|
3134
|
+
const { closeRoot } = useSubContext();
|
|
3135
|
+
const {
|
|
3136
|
+
ref: forwardedRef,
|
|
3137
|
+
className,
|
|
3138
|
+
children,
|
|
3139
|
+
onSelect,
|
|
3140
|
+
onClick,
|
|
3141
|
+
onKeyDown,
|
|
3142
|
+
closeOnSelect = true,
|
|
3143
|
+
disabled = false,
|
|
3144
|
+
...rest
|
|
3145
|
+
} = props;
|
|
3146
|
+
const { ref, index } = useListItem();
|
|
3147
|
+
const mergeRefs2 = useMergeRefs([ref, forwardedRef]);
|
|
3148
|
+
const handleClick = useCallback(
|
|
3149
|
+
(e) => {
|
|
3150
|
+
e.stopPropagation();
|
|
3151
|
+
if (disabled) return;
|
|
3152
|
+
if (onClick) onClick(e);
|
|
3153
|
+
if (onSelect) onSelect();
|
|
3154
|
+
if (closeOnSelect) setOpen(false);
|
|
3155
|
+
if (closeRoot) rootMenuContext.setOpen(false);
|
|
3156
|
+
},
|
|
3157
|
+
[closeOnSelect, closeRoot, disabled, rootMenuContext, onClick, onSelect, setOpen]
|
|
3158
|
+
);
|
|
3159
|
+
const handleKeyDown = useCallback(
|
|
3160
|
+
(e) => {
|
|
3161
|
+
if (disabled) return;
|
|
3162
|
+
if (onKeyDown) onKeyDown(e);
|
|
3163
|
+
if (TRIGGER_SELECT_KEYS.includes(e.key)) {
|
|
3098
3164
|
if (onSelect) onSelect();
|
|
3099
3165
|
if (closeOnSelect) setOpen(false);
|
|
3100
|
-
if (closeRoot) rootMenuContext.setOpen(false);
|
|
3101
|
-
},
|
|
3102
|
-
[closeOnSelect, closeRoot, disabled, rootMenuContext, onClick, onSelect, setOpen]
|
|
3103
|
-
);
|
|
3104
|
-
const handleKeyDown = useCallback(
|
|
3105
|
-
(e) => {
|
|
3106
|
-
if (disabled) return;
|
|
3107
|
-
if (onKeyDown) onKeyDown(e);
|
|
3108
|
-
if (TRIGGER_SELECT_KEYS.includes(e.key)) {
|
|
3109
|
-
if (onSelect) onSelect();
|
|
3110
|
-
if (closeOnSelect) setOpen(false);
|
|
3111
|
-
}
|
|
3112
|
-
},
|
|
3113
|
-
[closeOnSelect, disabled, onKeyDown, onSelect, setOpen]
|
|
3114
|
-
);
|
|
3115
|
-
const isActive = useMemo(() => index === activeIndex, [activeIndex, index]);
|
|
3116
|
-
const computedChildren = useMemo(() => {
|
|
3117
|
-
return typeof children === "function" ? children({ active: isActive, selected: false }) : children;
|
|
3118
|
-
}, [children, isActive]);
|
|
3119
|
-
return /* @__PURE__ */ jsx(
|
|
3120
|
-
"div",
|
|
3121
|
-
{
|
|
3122
|
-
className: cx(className, menuItem({ size: size2, variant }), radiusCva({ radius, maxLarge: true })),
|
|
3123
|
-
ref: mergeRefs2,
|
|
3124
|
-
role: "menuitem",
|
|
3125
|
-
"data-disabled": disabled ? "" : void 0,
|
|
3126
|
-
"aria-disabled": disabled,
|
|
3127
|
-
"data-highlighted": isActive ? "" : void 0,
|
|
3128
|
-
...getItemProps({
|
|
3129
|
-
onClick: handleClick,
|
|
3130
|
-
onKeyDown: handleKeyDown,
|
|
3131
|
-
tabIndex: isActive ? 0 : -1,
|
|
3132
|
-
...rest
|
|
3133
|
-
}),
|
|
3134
|
-
children: computedChildren
|
|
3135
3166
|
}
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
);
|
|
3167
|
+
},
|
|
3168
|
+
[closeOnSelect, disabled, onKeyDown, onSelect, setOpen]
|
|
3169
|
+
);
|
|
3170
|
+
const isActive = useMemo(() => index === activeIndex, [activeIndex, index]);
|
|
3171
|
+
const computedChildren = useMemo(() => {
|
|
3172
|
+
return typeof children === "function" ? children({ active: isActive, selected: false }) : children;
|
|
3173
|
+
}, [children, isActive]);
|
|
3174
|
+
return /* @__PURE__ */ jsx(
|
|
3175
|
+
"div",
|
|
3176
|
+
{
|
|
3177
|
+
className: cx(className, menuItem({ size: size2, variant }), radiusCva({ radius, maxLarge: true })),
|
|
3178
|
+
ref: mergeRefs2,
|
|
3179
|
+
role: "menuitem",
|
|
3180
|
+
"data-disabled": getBooleanState(disabled),
|
|
3181
|
+
"aria-disabled": disabled,
|
|
3182
|
+
"data-highlighted": isActive ? "" : void 0,
|
|
3183
|
+
...getItemProps({
|
|
3184
|
+
onClick: handleClick,
|
|
3185
|
+
onKeyDown: handleKeyDown,
|
|
3186
|
+
tabIndex: isActive ? 0 : -1,
|
|
3187
|
+
...rest
|
|
3188
|
+
}),
|
|
3189
|
+
children: computedChildren
|
|
3190
|
+
}
|
|
3191
|
+
);
|
|
3192
|
+
});
|
|
3193
|
+
MenuItem.displayName = "MenuItem";
|
|
3139
3194
|
const MenuCheckboxItem = forwardRef((props, ref) => {
|
|
3140
3195
|
const { checked, onCheckedChange, onSelect, ...rest } = props;
|
|
3141
3196
|
const handleSelect = useCallback(() => {
|
|
@@ -3154,9 +3209,8 @@ const MenuCheckboxItem = forwardRef((props, ref) => {
|
|
|
3154
3209
|
});
|
|
3155
3210
|
MenuCheckboxItem.displayName = "MenuCheckboxItem";
|
|
3156
3211
|
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 }) });
|
|
3212
|
+
const { children, ...rest } = props;
|
|
3213
|
+
return /* @__PURE__ */ jsx(CheckedIndicator, { ref, ...rest, children });
|
|
3160
3214
|
});
|
|
3161
3215
|
MenuCheckboxItemIndicator.displayName = "MenuCheckboxItemIndicator";
|
|
3162
3216
|
const MenuClickTrigger = memo(
|
|
@@ -3172,8 +3226,8 @@ const MenuClickTrigger = memo(
|
|
|
3172
3226
|
{
|
|
3173
3227
|
ref: mergedRefs,
|
|
3174
3228
|
"aria-disabled": disabled,
|
|
3175
|
-
"data-disabled": disabled
|
|
3176
|
-
"data-state": open
|
|
3229
|
+
"data-disabled": getBooleanState(disabled),
|
|
3230
|
+
"data-state": getOpenState(open),
|
|
3177
3231
|
...getReferenceProps({ disabled }),
|
|
3178
3232
|
children
|
|
3179
3233
|
}
|
|
@@ -3182,9 +3236,9 @@ const MenuClickTrigger = memo(
|
|
|
3182
3236
|
);
|
|
3183
3237
|
const MenuContextTrigger = memo(
|
|
3184
3238
|
forwardRef((props, forwardedRef) => {
|
|
3185
|
-
const { children, disabled } = props;
|
|
3239
|
+
const { children, disabled = false } = props;
|
|
3186
3240
|
const ref = useRef(null);
|
|
3187
|
-
const { setOpen, refs, setTriggerType } = useMenuContext();
|
|
3241
|
+
const { setOpen, refs, setTriggerType, open } = useMenuContext();
|
|
3188
3242
|
const mergedRefs = useMergeRefs([forwardedRef, ref]);
|
|
3189
3243
|
useEffect(() => {
|
|
3190
3244
|
setTriggerType("context");
|
|
@@ -3220,7 +3274,8 @@ const MenuContextTrigger = memo(
|
|
|
3220
3274
|
ref: mergedRefs,
|
|
3221
3275
|
style: { WebkitTouchCallout: disabled ? "none" : "unset" },
|
|
3222
3276
|
"aria-disabled": disabled,
|
|
3223
|
-
"data-disabled": disabled
|
|
3277
|
+
"data-disabled": getBooleanState(disabled),
|
|
3278
|
+
"data-state": getOpenState(open),
|
|
3224
3279
|
onContextMenu: handleContextMenu,
|
|
3225
3280
|
children
|
|
3226
3281
|
}
|
|
@@ -3235,7 +3290,7 @@ const MenuGroup = memo(
|
|
|
3235
3290
|
);
|
|
3236
3291
|
const MenuInputField = memo(
|
|
3237
3292
|
forwardRef((props, forwardedRef) => {
|
|
3238
|
-
const { className, onValueChange, onChange, ...rest } = props;
|
|
3293
|
+
const { className, onValueChange, onChange, disabled = false, ...rest } = props;
|
|
3239
3294
|
const { activeIndex, getItemProps } = useMenuContentContext();
|
|
3240
3295
|
const { index, ref } = useListItem();
|
|
3241
3296
|
const mergedRefs = useMergeRefs([ref, forwardedRef]);
|
|
@@ -3256,6 +3311,8 @@ const MenuInputField = memo(
|
|
|
3256
3311
|
{
|
|
3257
3312
|
className: cx(className, "placeholder-(--base-a9)", "selection:bg-(--accent-a5)", "outline-none"),
|
|
3258
3313
|
ref: mergedRefs,
|
|
3314
|
+
disabled,
|
|
3315
|
+
"data-disabled": getBooleanState(disabled),
|
|
3259
3316
|
...getItemProps({
|
|
3260
3317
|
...rest,
|
|
3261
3318
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
@@ -3278,92 +3335,55 @@ const MenuInputSlot = memo(
|
|
|
3278
3335
|
return /* @__PURE__ */ jsx("div", { className: cx(className, "flex", "items-center", "text-(--base-a11)"), ref, ...rest });
|
|
3279
3336
|
})
|
|
3280
3337
|
);
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3283
|
-
return
|
|
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 });
|
|
3338
|
+
const MenuMultiSelectGroup = genericMemo(function MenuMultiSelectGroup2(props) {
|
|
3339
|
+
const { ref, children, defaultValues, values, onValuesChange, ...rest } = props;
|
|
3340
|
+
return /* @__PURE__ */ jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsx(MultiSelectProvider, { defaultValues, values, onValuesChange, children }) });
|
|
3320
3341
|
});
|
|
3321
|
-
|
|
3322
|
-
const MenuMultiSelectGroup = memo(
|
|
3323
|
-
forwardRef((props, ref) => {
|
|
3324
|
-
const { children, values, onValuesChange, ...rest } = props;
|
|
3325
|
-
return /* @__PURE__ */ jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsx(SelectContextProvider, { type: "multi", values, onValuesChange, children }) });
|
|
3326
|
-
})
|
|
3327
|
-
);
|
|
3328
|
-
const SelectedIndicatorContext = createContext({});
|
|
3342
|
+
const SelectedIndicatorContext = createContext(false);
|
|
3329
3343
|
const useSelectedIndicatorContext = () => useContext(SelectedIndicatorContext);
|
|
3330
3344
|
const MenuSelectedIndicator = forwardRef((props, ref) => {
|
|
3331
3345
|
const { children } = props;
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
|
|
3346
|
+
const isSelected = useSelectedIndicatorContext();
|
|
3347
|
+
return /* @__PURE__ */ jsx(
|
|
3348
|
+
"span",
|
|
3349
|
+
{
|
|
3350
|
+
ref,
|
|
3351
|
+
className: cx({
|
|
3352
|
+
invisible: !isSelected
|
|
3353
|
+
}),
|
|
3354
|
+
"data-state": getSelectedState(isSelected),
|
|
3355
|
+
children
|
|
3356
|
+
}
|
|
3357
|
+
);
|
|
3335
3358
|
});
|
|
3336
3359
|
MenuSelectedIndicator.displayName = "SelectedIndicator";
|
|
3337
|
-
const MenuMultiSelectItem =
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
}
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
) });
|
|
3365
|
-
})
|
|
3366
|
-
);
|
|
3360
|
+
const MenuMultiSelectItem = genericMemo(function(props) {
|
|
3361
|
+
const { ref, onSelect, children, closeOnSelect = false, value, ...rest } = props;
|
|
3362
|
+
const { selected, selectValue, registerValue } = use(MultiSelectContext);
|
|
3363
|
+
useLayoutEffect(() => {
|
|
3364
|
+
return registerValue(value);
|
|
3365
|
+
}, [registerValue, value]);
|
|
3366
|
+
const isSelected = selected(value);
|
|
3367
|
+
const handleSelect = useCallback(() => {
|
|
3368
|
+
if (onSelect) onSelect();
|
|
3369
|
+
selectValue(value);
|
|
3370
|
+
}, [onSelect, selectValue, value]);
|
|
3371
|
+
const computedChildren = useMemo(() => {
|
|
3372
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3373
|
+
}, [children, isSelected]);
|
|
3374
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
3375
|
+
MenuItem,
|
|
3376
|
+
{
|
|
3377
|
+
ref,
|
|
3378
|
+
role: "menuitemcheckbox",
|
|
3379
|
+
onSelect: handleSelect,
|
|
3380
|
+
closeOnSelect,
|
|
3381
|
+
"data-state": getSelectedState(isSelected),
|
|
3382
|
+
...rest,
|
|
3383
|
+
children: computedChildren
|
|
3384
|
+
}
|
|
3385
|
+
) });
|
|
3386
|
+
});
|
|
3367
3387
|
const PagesContext = createContext({});
|
|
3368
3388
|
const usePagesContext = () => useContext(PagesContext);
|
|
3369
3389
|
const MenuPages = (props) => {
|
|
@@ -3407,77 +3427,65 @@ const MenuScroll = forwardRef((props, ref) => {
|
|
|
3407
3427
|
);
|
|
3408
3428
|
});
|
|
3409
3429
|
MenuScroll.displayName = "MenuScroll";
|
|
3410
|
-
const
|
|
3411
|
-
const
|
|
3412
|
-
const {
|
|
3413
|
-
const
|
|
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
|
-
const MenuSelectAllItem = forwardRef((props, ref) => {
|
|
3422
|
-
const { children, allValues, onSelect, closeOnSelect = false, ...rest } = props;
|
|
3423
|
-
const { values, handleValuesChange } = useSelectContext();
|
|
3424
|
-
const selected = useMemo(() => {
|
|
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]);
|
|
3430
|
+
const MenuSelectAllItem = genericMemo((props) => {
|
|
3431
|
+
const { ref, children, onSelect, closeOnSelect = false, ...rest } = props;
|
|
3432
|
+
const { allSelected, someSelected, toggleSelectAll } = use(MultiSelectContext);
|
|
3433
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
3430
3434
|
const handleSelect = useCallback(() => {
|
|
3431
3435
|
onSelect == null ? void 0 : onSelect();
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3436
|
+
toggleSelectAll();
|
|
3437
|
+
}, [onSelect, toggleSelectAll]);
|
|
3438
|
+
const computedChildren = useMemo(() => {
|
|
3439
|
+
return typeof children === "function" ? ({ active }) => children({ selected: selectedState, active }) : children;
|
|
3440
|
+
}, [children, selectedState]);
|
|
3441
|
+
return /* @__PURE__ */ jsx(CheckedIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsx(
|
|
3442
|
+
MenuItem,
|
|
3443
|
+
{
|
|
3444
|
+
onSelect: handleSelect,
|
|
3445
|
+
ref,
|
|
3446
|
+
"data-state": getCheckedState(selectedState),
|
|
3447
|
+
closeOnSelect,
|
|
3448
|
+
...rest,
|
|
3449
|
+
children: computedChildren
|
|
3441
3450
|
}
|
|
3442
|
-
}
|
|
3451
|
+
) });
|
|
3452
|
+
});
|
|
3453
|
+
const MenuSelectGroup = genericMemo(function MenuSelectGroup2(props) {
|
|
3454
|
+
const { ref, children, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
3455
|
+
return /* @__PURE__ */ jsx(MenuGroup, { ref, ...rest, children: required ? /* @__PURE__ */ jsx(SingleSelectRequiredProvider, { defaultValue, value, onValueChange, children }) : /* @__PURE__ */ jsx(
|
|
3456
|
+
SingleSelectNotRequiredProvider,
|
|
3457
|
+
{
|
|
3458
|
+
defaultValue,
|
|
3459
|
+
value,
|
|
3460
|
+
onValueChange,
|
|
3461
|
+
children
|
|
3462
|
+
}
|
|
3463
|
+
) });
|
|
3464
|
+
});
|
|
3465
|
+
const MenuSelectItem = genericMemo(function(props) {
|
|
3466
|
+
const { ref, value, onSelect, children, closeOnSelect = true, ...rest } = props;
|
|
3467
|
+
const { selected, selectValue } = use(SelectContext);
|
|
3468
|
+
const isSelected = useMemo(() => selected(value), [selected, value]);
|
|
3469
|
+
const handleSelect = useCallback(() => {
|
|
3470
|
+
if (onSelect) onSelect();
|
|
3471
|
+
selectValue(value);
|
|
3472
|
+
}, [onSelect, selectValue, value]);
|
|
3443
3473
|
const computedChildren = useMemo(() => {
|
|
3444
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3445
|
-
}, [children,
|
|
3446
|
-
return /* @__PURE__ */ jsx(
|
|
3474
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3475
|
+
}, [children, isSelected]);
|
|
3476
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
3477
|
+
MenuItem,
|
|
3478
|
+
{
|
|
3479
|
+
ref,
|
|
3480
|
+
role: "menuitemcheckbox",
|
|
3481
|
+
onSelect: handleSelect,
|
|
3482
|
+
closeOnSelect,
|
|
3483
|
+
"data-state": getSelectedState(isSelected),
|
|
3484
|
+
...rest,
|
|
3485
|
+
children: computedChildren
|
|
3486
|
+
}
|
|
3487
|
+
) });
|
|
3447
3488
|
});
|
|
3448
|
-
MenuSelectAllItem.displayName = "SelectAllItem";
|
|
3449
|
-
const MenuSelectGroup = memo(
|
|
3450
|
-
forwardRef((props, ref) => {
|
|
3451
|
-
const { children, value, onValueChange } = props;
|
|
3452
|
-
return /* @__PURE__ */ jsx(SelectContextProvider, { type: "single", value, onValueChange, children: /* @__PURE__ */ jsx(MenuGroup, { ref, children }) });
|
|
3453
|
-
})
|
|
3454
|
-
);
|
|
3455
|
-
const MenuSelectItem = memo(
|
|
3456
|
-
forwardRef((props, ref) => {
|
|
3457
|
-
const { value, onSelect, children, closeOnSelect = true, ...rest } = props;
|
|
3458
|
-
const { value: currentValue, handleValueChange } = useSelectContext();
|
|
3459
|
-
const selected = useMemo(() => value === currentValue, [currentValue, value]);
|
|
3460
|
-
const handleSelect = useCallback(() => {
|
|
3461
|
-
handleValueChange(!selected ? value : null);
|
|
3462
|
-
if (onSelect) onSelect();
|
|
3463
|
-
}, [handleValueChange, onSelect, selected, value]);
|
|
3464
|
-
const computedChildren = useMemo(() => {
|
|
3465
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3466
|
-
}, [children, selected]);
|
|
3467
|
-
return /* @__PURE__ */ jsx(SelectedIndicatorContext.Provider, { value: { selected }, children: /* @__PURE__ */ jsx(
|
|
3468
|
-
MenuItem,
|
|
3469
|
-
{
|
|
3470
|
-
ref,
|
|
3471
|
-
role: "menuitemcheckbox",
|
|
3472
|
-
onSelect: handleSelect,
|
|
3473
|
-
closeOnSelect,
|
|
3474
|
-
"data-selected": selected ? "" : void 0,
|
|
3475
|
-
...rest,
|
|
3476
|
-
children: computedChildren
|
|
3477
|
-
}
|
|
3478
|
-
) });
|
|
3479
|
-
})
|
|
3480
|
-
);
|
|
3481
3489
|
const MenuSeparator = memo(
|
|
3482
3490
|
forwardRef((props, ref) => {
|
|
3483
3491
|
const { className, ...rest } = props;
|
|
@@ -3548,7 +3556,7 @@ const MenuSubContent = memo(
|
|
|
3548
3556
|
"max-h-(--overmap-menu-available-height)"
|
|
3549
3557
|
),
|
|
3550
3558
|
ref: forwardedRef,
|
|
3551
|
-
"data-state": open
|
|
3559
|
+
"data-state": getOpenState(open),
|
|
3552
3560
|
"data-side": side,
|
|
3553
3561
|
"data-accent-color": accentColor,
|
|
3554
3562
|
...rest,
|
|
@@ -3572,7 +3580,7 @@ const MenuSubTrigger = memo(
|
|
|
3572
3580
|
ref: mergedRefs,
|
|
3573
3581
|
closeOnSelect: false,
|
|
3574
3582
|
"aria-haspopup": "menu",
|
|
3575
|
-
"data-
|
|
3583
|
+
"data-state": getOpenState(open),
|
|
3576
3584
|
disabled,
|
|
3577
3585
|
...getReferenceProps(rest),
|
|
3578
3586
|
children
|
|
@@ -3624,7 +3632,6 @@ const Menu = {
|
|
|
3624
3632
|
SelectAllItem: MenuSelectAllItem,
|
|
3625
3633
|
CheckboxItem: MenuCheckboxItem,
|
|
3626
3634
|
// indicators
|
|
3627
|
-
SelectAllIndicator: MenuSelectAllIndicator,
|
|
3628
3635
|
SelectedIndicator: MenuSelectedIndicator,
|
|
3629
3636
|
CheckboxItemIndicator: MenuCheckboxItemIndicator,
|
|
3630
3637
|
// input
|
|
@@ -5006,7 +5013,6 @@ export {
|
|
|
5006
5013
|
MenuPages,
|
|
5007
5014
|
MenuRoot,
|
|
5008
5015
|
MenuScroll,
|
|
5009
|
-
MenuSelectAllIndicator,
|
|
5010
5016
|
MenuSelectAllItem,
|
|
5011
5017
|
MenuSelectGroup,
|
|
5012
5018
|
MenuSelectItem,
|