@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.umd.cjs
CHANGED
|
@@ -1026,30 +1026,37 @@
|
|
|
1026
1026
|
);
|
|
1027
1027
|
});
|
|
1028
1028
|
const CommandMenuContext = React.createContext({});
|
|
1029
|
-
const SelectContext$1 = React.createContext({});
|
|
1030
|
-
const MultiSelectGroupContext = React.createContext({});
|
|
1031
1029
|
const SelectedIndicatorContext$1 = React.createContext(false);
|
|
1032
1030
|
const CheckboxIndicatorContext = React.createContext(false);
|
|
1033
1031
|
const CommandMenuPageContext = React.createContext({});
|
|
1034
1032
|
const CommandMenuDialogContext = React.createContext({});
|
|
1035
|
-
function getSelectedState(selected) {
|
|
1033
|
+
function getSelectedState$1(selected) {
|
|
1036
1034
|
return selected ? "selected" : "unselected";
|
|
1037
1035
|
}
|
|
1038
|
-
function getCheckedState(checked) {
|
|
1036
|
+
function getCheckedState$1(checked) {
|
|
1039
1037
|
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
1040
1038
|
}
|
|
1041
1039
|
function getActiveState(active) {
|
|
1042
1040
|
return active ? "active" : "inactive";
|
|
1043
1041
|
}
|
|
1044
1042
|
const CommandMenuCheckboxIndicator = (props) => {
|
|
1045
|
-
const { ref,
|
|
1043
|
+
const { ref, className, children, ...rest } = props;
|
|
1046
1044
|
const checkedState = React.use(CheckboxIndicatorContext);
|
|
1047
1045
|
const computedChildren = React.useMemo(() => {
|
|
1048
1046
|
return typeof children === "function" ? children(checkedState) : children;
|
|
1049
1047
|
}, [checkedState, children]);
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1048
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1049
|
+
"span",
|
|
1050
|
+
{
|
|
1051
|
+
ref,
|
|
1052
|
+
"data-state": getCheckedState$1(checkedState),
|
|
1053
|
+
className: classVarianceAuthority.cx(className, "inline-block size-max", {
|
|
1054
|
+
invisible: checkedState === false
|
|
1055
|
+
}),
|
|
1056
|
+
...rest,
|
|
1057
|
+
children: computedChildren
|
|
1058
|
+
}
|
|
1059
|
+
);
|
|
1053
1060
|
};
|
|
1054
1061
|
const commandMenuContentCva = classVarianceAuthority.cva(
|
|
1055
1062
|
[
|
|
@@ -1260,24 +1267,22 @@
|
|
|
1260
1267
|
}
|
|
1261
1268
|
);
|
|
1262
1269
|
const CommandMenuItem = React.memo((props) => {
|
|
1263
|
-
const { className, ref, closeOnSelect = true, onSelect, ...rest } = props;
|
|
1270
|
+
const { className, ref, closeOnSelect = true, onSelect, filterValue, ...rest } = props;
|
|
1264
1271
|
const { size, variant, radius } = React.use(CommandMenuContext);
|
|
1265
1272
|
const { setOpen } = React.use(CommandMenuDialogContext);
|
|
1266
|
-
const handleSelect = React.useCallback(
|
|
1267
|
-
(
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
},
|
|
1273
|
-
[closeOnSelect, onSelect, setOpen]
|
|
1274
|
-
);
|
|
1273
|
+
const handleSelect = React.useCallback(() => {
|
|
1274
|
+
onSelect == null ? void 0 : onSelect();
|
|
1275
|
+
if (closeOnSelect) {
|
|
1276
|
+
setOpen(false);
|
|
1277
|
+
}
|
|
1278
|
+
}, [closeOnSelect, onSelect, setOpen]);
|
|
1275
1279
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1276
1280
|
cmdk.CommandItem,
|
|
1277
1281
|
{
|
|
1278
1282
|
className: classVarianceAuthority.cx(className, commandMenuItemCva({ size, variant, radius })),
|
|
1279
1283
|
ref,
|
|
1280
1284
|
onSelect: handleSelect,
|
|
1285
|
+
value: filterValue,
|
|
1281
1286
|
...rest
|
|
1282
1287
|
}
|
|
1283
1288
|
);
|
|
@@ -1285,14 +1290,11 @@
|
|
|
1285
1290
|
CommandMenuItem.displayName = "CommandMenuItem";
|
|
1286
1291
|
const CommandMenuCheckboxItem = (props) => {
|
|
1287
1292
|
const { children, ref, checked, onCheckedChange, onSelect, ...rest } = props;
|
|
1288
|
-
const handleSelect = React.useCallback(
|
|
1289
|
-
(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
[checked, onCheckedChange, onSelect]
|
|
1294
|
-
);
|
|
1295
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState(checked), ...rest, children }) });
|
|
1293
|
+
const handleSelect = React.useCallback(() => {
|
|
1294
|
+
onSelect == null ? void 0 : onSelect();
|
|
1295
|
+
onCheckedChange(checked !== true);
|
|
1296
|
+
}, [checked, onCheckedChange, onSelect]);
|
|
1297
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxIndicatorContext, { value: checked, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getCheckedState$1(checked), ...rest, children }) });
|
|
1296
1298
|
};
|
|
1297
1299
|
const CommandMenuContent = React.memo((props) => {
|
|
1298
1300
|
const providerContext = useProvider();
|
|
@@ -1383,10 +1385,26 @@
|
|
|
1383
1385
|
);
|
|
1384
1386
|
});
|
|
1385
1387
|
CommandMenuList.displayName = "CommandMenuList";
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
const
|
|
1388
|
+
const SelectContext = React.createContext({});
|
|
1389
|
+
const MultiSelectContext = React.createContext({});
|
|
1390
|
+
const MultiSelectProvider = genericMemo(function MultiSelectProvider2(props) {
|
|
1391
|
+
const { children, defaultValues, values: controlledValues, onValuesChange } = props;
|
|
1392
|
+
const [itemValueMapping, setItemValueMapping] = React.useState(/* @__PURE__ */ new Set());
|
|
1393
|
+
const [values, setValues] = useControlledState(defaultValues ?? [], controlledValues, onValuesChange);
|
|
1394
|
+
const registerValue = React.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
|
+
}, []);
|
|
1390
1408
|
const selected = React.useCallback((value) => values.includes(value), [values]);
|
|
1391
1409
|
const selectValue = React.useCallback(
|
|
1392
1410
|
(value) => {
|
|
@@ -1398,59 +1416,84 @@
|
|
|
1398
1416
|
},
|
|
1399
1417
|
[selected, setValues, values]
|
|
1400
1418
|
);
|
|
1401
|
-
const
|
|
1402
|
-
return
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}, [
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
values
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
const {
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
}, [
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1419
|
+
const allSelected = React.useMemo(() => {
|
|
1420
|
+
return Array.from(itemValueMapping.values()).every((value) => values.includes(value));
|
|
1421
|
+
}, [itemValueMapping, values]);
|
|
1422
|
+
const someSelected = React.useMemo(() => {
|
|
1423
|
+
return Array.from(itemValueMapping.values()).some((value) => values.includes(value));
|
|
1424
|
+
}, [itemValueMapping, values]);
|
|
1425
|
+
const toggleSelectAll = React.useCallback(() => {
|
|
1426
|
+
if (allSelected) {
|
|
1427
|
+
setValues([]);
|
|
1428
|
+
} else {
|
|
1429
|
+
setValues(Array.from(itemValueMapping.values()));
|
|
1430
|
+
}
|
|
1431
|
+
}, [allSelected, itemValueMapping, setValues]);
|
|
1432
|
+
const contextValue = React.useMemo(
|
|
1433
|
+
() => ({ selected, selectValue, allSelected, someSelected, toggleSelectAll, registerValue }),
|
|
1434
|
+
[allSelected, registerValue, selectValue, selected, someSelected, toggleSelectAll]
|
|
1435
|
+
);
|
|
1436
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectContext, { value: contextValue, children });
|
|
1437
|
+
});
|
|
1438
|
+
const SingleSelectRequiredProvider = genericMemo(function SingleSelectRequiredProvider2(props) {
|
|
1439
|
+
const { children, defaultValue, value, onValueChange } = props;
|
|
1440
|
+
const [controlledValue, setControlledValue] = useControlledState(defaultValue, value, onValueChange);
|
|
1441
|
+
const selected = React.useCallback((v) => v === controlledValue, [controlledValue]);
|
|
1442
|
+
const selectValue = React.useCallback(
|
|
1443
|
+
(v) => {
|
|
1444
|
+
if (selected(v)) return;
|
|
1445
|
+
setControlledValue(v);
|
|
1446
|
+
},
|
|
1447
|
+
[selected, setControlledValue]
|
|
1448
|
+
);
|
|
1449
|
+
const contextValue = React.useMemo(() => ({ selected, selectValue }), [selectValue, selected]);
|
|
1450
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext, { value: contextValue, children });
|
|
1451
|
+
});
|
|
1452
|
+
const SingleSelectNotRequiredProvider = genericMemo(function SingleSelectNotRequiredProvider2(props) {
|
|
1453
|
+
const { children, defaultValue = null, value: controlledValue, onValueChange } = props;
|
|
1454
|
+
const [value, setValue] = useControlledState(defaultValue, controlledValue, onValueChange);
|
|
1455
|
+
const selected = React.useCallback((v) => v === value, [value]);
|
|
1456
|
+
const selectValue = React.useCallback(
|
|
1457
|
+
(v) => {
|
|
1458
|
+
setValue(selected(v) ? null : v);
|
|
1436
1459
|
},
|
|
1437
|
-
[
|
|
1460
|
+
[selected, setValue]
|
|
1438
1461
|
);
|
|
1462
|
+
const contextValue = React.useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1463
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext, { value: contextValue, children });
|
|
1464
|
+
});
|
|
1465
|
+
const CommandMenuMultiSelectGroup = genericMemo(function CommandMenuMultiSelectGroup2(props) {
|
|
1466
|
+
const { children, ref, defaultValues, values, onValuesChange, ...rest } = props;
|
|
1467
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectProvider, { values, onValuesChange, defaultValues, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuGroup, { ref, "aria-multiselectable": true, ...rest, children }) });
|
|
1468
|
+
});
|
|
1469
|
+
const CommandMenuMultiSelectItem = genericMemo(function(props) {
|
|
1470
|
+
const { children, ref, value, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1471
|
+
const {
|
|
1472
|
+
selected,
|
|
1473
|
+
selectValue: handleSelectValue,
|
|
1474
|
+
registerValue
|
|
1475
|
+
} = React.use(MultiSelectContext);
|
|
1476
|
+
React.useLayoutEffect(() => {
|
|
1477
|
+
return registerValue(value);
|
|
1478
|
+
}, [registerValue, value]);
|
|
1479
|
+
const handleSelect = React.useCallback(() => {
|
|
1480
|
+
onSelect == null ? void 0 : onSelect();
|
|
1481
|
+
handleSelectValue(value);
|
|
1482
|
+
}, [handleSelectValue, onSelect, value]);
|
|
1439
1483
|
const isSelected = selected(value);
|
|
1440
1484
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1441
1485
|
CommandMenuItem,
|
|
1442
1486
|
{
|
|
1443
1487
|
ref,
|
|
1444
1488
|
onSelect: handleSelect,
|
|
1445
|
-
"data-state": getSelectedState(isSelected),
|
|
1489
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1446
1490
|
"aria-selected": isSelected,
|
|
1447
|
-
value,
|
|
1448
1491
|
closeOnSelect,
|
|
1449
1492
|
...rest,
|
|
1450
1493
|
children
|
|
1451
1494
|
}
|
|
1452
1495
|
) });
|
|
1453
|
-
};
|
|
1496
|
+
});
|
|
1454
1497
|
const CommandMenuOverlay = React.memo((props) => {
|
|
1455
1498
|
const { container, className, ...rest } = props;
|
|
1456
1499
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.DialogPortal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.DialogOverlay, { className: classVarianceAuthority.cx(className, commandMenuOverlayCva()), "data-floating-content": "", ...rest }) });
|
|
@@ -1471,13 +1514,10 @@
|
|
|
1471
1514
|
const { ref, page, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1472
1515
|
const { page: activePage, setPage } = React.use(CommandMenuPageContext);
|
|
1473
1516
|
const isActive = React.useMemo(() => page === activePage, [page, activePage]);
|
|
1474
|
-
const handleSelect = React.useCallback(
|
|
1475
|
-
(
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
},
|
|
1479
|
-
[onSelect, page, setPage]
|
|
1480
|
-
);
|
|
1517
|
+
const handleSelect = React.useCallback(() => {
|
|
1518
|
+
onSelect == null ? void 0 : onSelect();
|
|
1519
|
+
setPage(page);
|
|
1520
|
+
}, [onSelect, page, setPage]);
|
|
1481
1521
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext$1, { value: isActive, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1482
1522
|
CommandMenuItem,
|
|
1483
1523
|
{
|
|
@@ -1489,42 +1529,36 @@
|
|
|
1489
1529
|
}
|
|
1490
1530
|
) });
|
|
1491
1531
|
};
|
|
1492
|
-
const CommandMenuRadioGroup = (props)
|
|
1493
|
-
const { children, ref, defaultValue
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
const selectValue = React.useCallback(
|
|
1497
|
-
(v) => {
|
|
1498
|
-
setValue(selected(v) ? null : v);
|
|
1499
|
-
},
|
|
1500
|
-
[selected, setValue]
|
|
1501
|
-
);
|
|
1502
|
-
const contextValue = React.useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1503
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(SelectContext$1, { value: contextValue, children }) });
|
|
1504
|
-
};
|
|
1505
|
-
const CommandMenuRadioItem = (props) => {
|
|
1506
|
-
const { children, ref, value, onSelect, ...rest } = props;
|
|
1507
|
-
const { selected, selectValue } = React.use(SelectContext$1);
|
|
1508
|
-
const handleSelect = React.useCallback(
|
|
1509
|
-
(value2) => {
|
|
1510
|
-
onSelect == null ? void 0 : onSelect(value2);
|
|
1511
|
-
selectValue(value2);
|
|
1512
|
-
},
|
|
1513
|
-
[onSelect, selectValue]
|
|
1514
|
-
);
|
|
1515
|
-
const isSelected = selected(value);
|
|
1516
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1517
|
-
CommandMenuItem,
|
|
1532
|
+
const CommandMenuRadioGroup = genericMemo(function CommandMenuRadioGroup2(props) {
|
|
1533
|
+
const { children, ref, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
1534
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: required ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1535
|
+
SingleSelectRequiredProvider,
|
|
1518
1536
|
{
|
|
1519
|
-
|
|
1520
|
-
onSelect: handleSelect,
|
|
1521
|
-
"data-state": getSelectedState(isSelected),
|
|
1537
|
+
defaultValue,
|
|
1522
1538
|
value,
|
|
1523
|
-
|
|
1539
|
+
onValueChange,
|
|
1540
|
+
children
|
|
1541
|
+
}
|
|
1542
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1543
|
+
SingleSelectNotRequiredProvider,
|
|
1544
|
+
{
|
|
1545
|
+
defaultValue,
|
|
1546
|
+
value,
|
|
1547
|
+
onValueChange,
|
|
1524
1548
|
children
|
|
1525
1549
|
}
|
|
1526
1550
|
) });
|
|
1527
|
-
};
|
|
1551
|
+
});
|
|
1552
|
+
const CommandMenuRadioItem = genericMemo(function(props) {
|
|
1553
|
+
const { children, ref, value, onSelect, ...rest } = props;
|
|
1554
|
+
const { selected, selectValue } = React.use(SelectContext);
|
|
1555
|
+
const handleSelect = React.useCallback(() => {
|
|
1556
|
+
onSelect == null ? void 0 : onSelect();
|
|
1557
|
+
selectValue(value);
|
|
1558
|
+
}, [onSelect, selectValue, value]);
|
|
1559
|
+
const isSelected = selected(value);
|
|
1560
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuItem, { ref, onSelect: handleSelect, "data-state": getSelectedState$1(isSelected), ...rest, children }) });
|
|
1561
|
+
});
|
|
1528
1562
|
const CommandMenuRoot = React.memo((props) => {
|
|
1529
1563
|
const { children, defaultOpen, open: controlledOpen, onOpenChange } = props;
|
|
1530
1564
|
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
@@ -1537,43 +1571,44 @@
|
|
|
1537
1571
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog.Dialog, { open, onOpenChange: setOpen, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(CommandMenuDialogContext, { value: contextValue, children }) });
|
|
1538
1572
|
});
|
|
1539
1573
|
CommandMenuRoot.displayName = "CommandMenuRoot";
|
|
1540
|
-
const CommandMenuSelectAllItem = (props)
|
|
1574
|
+
const CommandMenuSelectAllItem = genericMemo(function(props) {
|
|
1541
1575
|
const { ref, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1542
|
-
const {
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
}, [itemValueMapping, values]);
|
|
1549
|
-
const handleSelect = React.useCallback(
|
|
1550
|
-
(value) => {
|
|
1551
|
-
onSelect == null ? void 0 : onSelect(value);
|
|
1552
|
-
setValues(selectedState !== true ? Array.from(itemValueMapping.values()) : []);
|
|
1553
|
-
},
|
|
1554
|
-
[itemValueMapping, onSelect, selectedState, setValues]
|
|
1555
|
-
);
|
|
1576
|
+
const { allSelected, someSelected, toggleSelectAll } = React.use(MultiSelectContext);
|
|
1577
|
+
const handleSelect = React.useCallback(() => {
|
|
1578
|
+
onSelect == null ? void 0 : onSelect();
|
|
1579
|
+
toggleSelectAll();
|
|
1580
|
+
}, [onSelect, toggleSelectAll]);
|
|
1581
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
1556
1582
|
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1557
1583
|
CommandMenuItem,
|
|
1558
1584
|
{
|
|
1559
1585
|
ref,
|
|
1560
1586
|
role: "menuitemcheckbox",
|
|
1561
1587
|
onSelect: handleSelect,
|
|
1562
|
-
"data-state": getCheckedState(selectedState),
|
|
1588
|
+
"data-state": getCheckedState$1(selectedState),
|
|
1563
1589
|
closeOnSelect,
|
|
1564
1590
|
...rest
|
|
1565
1591
|
}
|
|
1566
1592
|
) });
|
|
1567
|
-
};
|
|
1593
|
+
});
|
|
1568
1594
|
const CommandMenuSelectedIndicator = (props) => {
|
|
1569
|
-
const { ref,
|
|
1595
|
+
const { ref, className, children, ...rest } = props;
|
|
1570
1596
|
const isSelected = React.use(SelectedIndicatorContext$1);
|
|
1571
1597
|
const computedChildren = React.useMemo(() => {
|
|
1572
1598
|
return typeof children === "function" ? children(isSelected) : children;
|
|
1573
1599
|
}, [isSelected, children]);
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1600
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1601
|
+
"span",
|
|
1602
|
+
{
|
|
1603
|
+
ref,
|
|
1604
|
+
"data-state": getSelectedState$1(isSelected),
|
|
1605
|
+
className: classVarianceAuthority.cx(className, "inline-block size-max", {
|
|
1606
|
+
invisible: !isSelected
|
|
1607
|
+
}),
|
|
1608
|
+
...rest,
|
|
1609
|
+
children: computedChildren
|
|
1610
|
+
}
|
|
1611
|
+
);
|
|
1577
1612
|
};
|
|
1578
1613
|
const CommandMenuSeparator = React.memo((props) => {
|
|
1579
1614
|
const { className, ref, spacing = false, ...rest } = props;
|
|
@@ -2626,29 +2661,53 @@
|
|
|
2626
2661
|
Link.displayName = "Link";
|
|
2627
2662
|
const CheckedIndicatorContext = React.createContext({});
|
|
2628
2663
|
const CheckedIndicator = (props) => {
|
|
2629
|
-
const { children } = props;
|
|
2664
|
+
const { children, ref, className, ...rest } = props;
|
|
2630
2665
|
const checked = React.useContext(CheckedIndicatorContext);
|
|
2631
2666
|
const computedChildren = typeof children === "function" ? children(checked === "indeterminate") : children;
|
|
2632
|
-
return
|
|
2667
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2668
|
+
"span",
|
|
2669
|
+
{
|
|
2670
|
+
ref,
|
|
2671
|
+
className: classVarianceAuthority.cx(className, {
|
|
2672
|
+
invisible: checked === false
|
|
2673
|
+
}),
|
|
2674
|
+
"data-state": getCheckedState$1(checked),
|
|
2675
|
+
...rest,
|
|
2676
|
+
children: computedChildren
|
|
2677
|
+
}
|
|
2678
|
+
);
|
|
2633
2679
|
};
|
|
2634
2680
|
const menuItem = classVarianceAuthority.cva(
|
|
2635
|
-
[
|
|
2681
|
+
[
|
|
2682
|
+
"select-none",
|
|
2683
|
+
"relative",
|
|
2684
|
+
"flex",
|
|
2685
|
+
"items-center",
|
|
2686
|
+
"rounded",
|
|
2687
|
+
"outline-none",
|
|
2688
|
+
"data-[disabled=true]:text-(--base-a8)"
|
|
2689
|
+
],
|
|
2636
2690
|
{
|
|
2637
2691
|
variants: {
|
|
2638
2692
|
size: {
|
|
2639
|
-
xs: ["h-5", "
|
|
2640
|
-
sm: ["h-6", "
|
|
2641
|
-
md: ["h-7", "
|
|
2642
|
-
lg: ["h-8", "
|
|
2643
|
-
xl: ["h-9", "
|
|
2693
|
+
xs: ["h-5", "gap-1.5", "px-1.5"],
|
|
2694
|
+
sm: ["h-6", "gap-2.25", "px-2.25"],
|
|
2695
|
+
md: ["h-7", "gap-3", "px-3"],
|
|
2696
|
+
lg: ["h-8", "gap-3.75", "px-3.75"],
|
|
2697
|
+
xl: ["h-9", "gap-4.5", "px-4.5"]
|
|
2644
2698
|
},
|
|
2645
2699
|
variant: {
|
|
2646
2700
|
solid: [
|
|
2647
2701
|
"text-(--base-12)",
|
|
2648
|
-
"data-highlighted:not-data-disabled:text-(--accent-contrast)",
|
|
2649
|
-
"data-highlighted:not-data-disabled:bg-(--accent-a9)"
|
|
2702
|
+
"data-highlighted:not-data-[disabled=true]:text-(--accent-contrast)",
|
|
2703
|
+
"data-highlighted:not-data-[disabled=true]:bg-(--accent-a9)",
|
|
2704
|
+
"data-highlighted:not-data-[disabled=true]:active:brightness-110"
|
|
2650
2705
|
],
|
|
2651
|
-
soft: [
|
|
2706
|
+
soft: [
|
|
2707
|
+
"text-(--base-12)",
|
|
2708
|
+
"data-highlighted:not-data-[disabled=true]:bg-(--accent-a3)",
|
|
2709
|
+
"data-highlighted:not-data-[disabled=true]:active:bg-(--accent-a4)"
|
|
2710
|
+
]
|
|
2652
2711
|
}
|
|
2653
2712
|
},
|
|
2654
2713
|
defaultVariants: {
|
|
@@ -2671,20 +2730,6 @@
|
|
|
2671
2730
|
size: "md"
|
|
2672
2731
|
}
|
|
2673
2732
|
});
|
|
2674
|
-
const menuSelectedIndicator = classVarianceAuthority.cva(["flex", "items-center", "justify-center"], {
|
|
2675
|
-
variants: {
|
|
2676
|
-
size: {
|
|
2677
|
-
xs: ["w-4", "h-4"],
|
|
2678
|
-
sm: ["w-5", "h-5"],
|
|
2679
|
-
md: ["w-6", "h-6"],
|
|
2680
|
-
lg: ["w-7", "h-7"],
|
|
2681
|
-
xl: ["w-8", "h-8"]
|
|
2682
|
-
}
|
|
2683
|
-
},
|
|
2684
|
-
defaultVariants: {
|
|
2685
|
-
size: "md"
|
|
2686
|
-
}
|
|
2687
|
-
});
|
|
2688
2733
|
const menuContent = classVarianceAuthority.cva(
|
|
2689
2734
|
[
|
|
2690
2735
|
"flex",
|
|
@@ -2697,8 +2742,6 @@
|
|
|
2697
2742
|
"ring-1",
|
|
2698
2743
|
"ring-(--base-6)",
|
|
2699
2744
|
"overflow-hidden"
|
|
2700
|
-
// "[scrollbar-width:thin]",
|
|
2701
|
-
// "[scrollbar-color:var(--base-6)_transparent]",
|
|
2702
2745
|
],
|
|
2703
2746
|
{
|
|
2704
2747
|
variants: {
|
|
@@ -2740,8 +2783,8 @@
|
|
|
2740
2783
|
"flex",
|
|
2741
2784
|
"items-stretch",
|
|
2742
2785
|
"transition-colors",
|
|
2743
|
-
"
|
|
2744
|
-
"
|
|
2786
|
+
"data-[disabled=true]:opacity-50",
|
|
2787
|
+
"data-[disabled=true]:pointer-events-none",
|
|
2745
2788
|
"box-border",
|
|
2746
2789
|
"bg-transparent",
|
|
2747
2790
|
"text-(--base-12)"
|
|
@@ -2856,6 +2899,37 @@
|
|
|
2856
2899
|
) });
|
|
2857
2900
|
};
|
|
2858
2901
|
MenuRoot.displayName = "Root";
|
|
2902
|
+
const computeOffsets = (side, alignment) => {
|
|
2903
|
+
switch (side) {
|
|
2904
|
+
case "right":
|
|
2905
|
+
if (alignment === "start") {
|
|
2906
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2907
|
+
} else if (alignment === "end") {
|
|
2908
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2909
|
+
}
|
|
2910
|
+
break;
|
|
2911
|
+
case "left":
|
|
2912
|
+
if (alignment === "start") {
|
|
2913
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2914
|
+
} else if (alignment === "end") {
|
|
2915
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2916
|
+
}
|
|
2917
|
+
break;
|
|
2918
|
+
}
|
|
2919
|
+
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
2920
|
+
};
|
|
2921
|
+
function getSelectedState(selected) {
|
|
2922
|
+
return selected ? "selected" : "unselected";
|
|
2923
|
+
}
|
|
2924
|
+
function getCheckedState(checked) {
|
|
2925
|
+
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
2926
|
+
}
|
|
2927
|
+
function getBooleanState(value) {
|
|
2928
|
+
return value ? "true" : "false";
|
|
2929
|
+
}
|
|
2930
|
+
function getOpenState(open) {
|
|
2931
|
+
return open ? "open" : "closed";
|
|
2932
|
+
}
|
|
2859
2933
|
const MenuContentContext = React.createContext({});
|
|
2860
2934
|
const useMenuContentContext = () => React.useContext(MenuContentContext);
|
|
2861
2935
|
const MenuContent = React.memo(
|
|
@@ -2943,7 +3017,7 @@
|
|
|
2943
3017
|
"max-h-(--overmap-menu-available-height)"
|
|
2944
3018
|
),
|
|
2945
3019
|
ref: forwardedRef,
|
|
2946
|
-
"data-state": open
|
|
3020
|
+
"data-state": getOpenState(open),
|
|
2947
3021
|
"data-side": side,
|
|
2948
3022
|
"data-accent-color": accentColor,
|
|
2949
3023
|
...rest,
|
|
@@ -2960,25 +3034,6 @@
|
|
|
2960
3034
|
);
|
|
2961
3035
|
const SubContext = React.createContext({});
|
|
2962
3036
|
const useSubContext = () => React.useContext(SubContext);
|
|
2963
|
-
const computeOffsets = (side, alignment) => {
|
|
2964
|
-
switch (side) {
|
|
2965
|
-
case "right":
|
|
2966
|
-
if (alignment === "start") {
|
|
2967
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2968
|
-
} else if (alignment === "end") {
|
|
2969
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2970
|
-
}
|
|
2971
|
-
break;
|
|
2972
|
-
case "left":
|
|
2973
|
-
if (alignment === "start") {
|
|
2974
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: -8 };
|
|
2975
|
-
} else if (alignment === "end") {
|
|
2976
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: MENU_CONTENT_PADDING };
|
|
2977
|
-
}
|
|
2978
|
-
break;
|
|
2979
|
-
}
|
|
2980
|
-
return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
|
|
2981
|
-
};
|
|
2982
3037
|
const MenuSub = (props) => {
|
|
2983
3038
|
const {
|
|
2984
3039
|
children,
|
|
@@ -3078,69 +3133,69 @@
|
|
|
3078
3133
|
};
|
|
3079
3134
|
MenuSub.displayName = "SubMenu";
|
|
3080
3135
|
const TRIGGER_SELECT_KEYS = ["Enter", " "];
|
|
3081
|
-
const MenuItem = React.memo(
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3136
|
+
const MenuItem = React.memo((props) => {
|
|
3137
|
+
const rootMenuContext = useMenuContext();
|
|
3138
|
+
const { getItemProps, activeIndex, setOpen, size, variant, radius } = useMenuContentContext();
|
|
3139
|
+
const { closeRoot } = useSubContext();
|
|
3140
|
+
const {
|
|
3141
|
+
ref: forwardedRef,
|
|
3142
|
+
className,
|
|
3143
|
+
children,
|
|
3144
|
+
onSelect,
|
|
3145
|
+
onClick,
|
|
3146
|
+
onKeyDown,
|
|
3147
|
+
closeOnSelect = true,
|
|
3148
|
+
disabled = false,
|
|
3149
|
+
...rest
|
|
3150
|
+
} = props;
|
|
3151
|
+
const { ref, index } = react.useListItem();
|
|
3152
|
+
const mergeRefs2 = react.useMergeRefs([ref, forwardedRef]);
|
|
3153
|
+
const handleClick = React.useCallback(
|
|
3154
|
+
(e) => {
|
|
3155
|
+
e.stopPropagation();
|
|
3156
|
+
if (disabled) return;
|
|
3157
|
+
if (onClick) onClick(e);
|
|
3158
|
+
if (onSelect) onSelect();
|
|
3159
|
+
if (closeOnSelect) setOpen(false);
|
|
3160
|
+
if (closeRoot) rootMenuContext.setOpen(false);
|
|
3161
|
+
},
|
|
3162
|
+
[closeOnSelect, closeRoot, disabled, rootMenuContext, onClick, onSelect, setOpen]
|
|
3163
|
+
);
|
|
3164
|
+
const handleKeyDown = React.useCallback(
|
|
3165
|
+
(e) => {
|
|
3166
|
+
if (disabled) return;
|
|
3167
|
+
if (onKeyDown) onKeyDown(e);
|
|
3168
|
+
if (TRIGGER_SELECT_KEYS.includes(e.key)) {
|
|
3103
3169
|
if (onSelect) onSelect();
|
|
3104
3170
|
if (closeOnSelect) setOpen(false);
|
|
3105
|
-
if (closeRoot) rootMenuContext.setOpen(false);
|
|
3106
|
-
},
|
|
3107
|
-
[closeOnSelect, closeRoot, disabled, rootMenuContext, onClick, onSelect, setOpen]
|
|
3108
|
-
);
|
|
3109
|
-
const handleKeyDown = React.useCallback(
|
|
3110
|
-
(e) => {
|
|
3111
|
-
if (disabled) return;
|
|
3112
|
-
if (onKeyDown) onKeyDown(e);
|
|
3113
|
-
if (TRIGGER_SELECT_KEYS.includes(e.key)) {
|
|
3114
|
-
if (onSelect) onSelect();
|
|
3115
|
-
if (closeOnSelect) setOpen(false);
|
|
3116
|
-
}
|
|
3117
|
-
},
|
|
3118
|
-
[closeOnSelect, disabled, onKeyDown, onSelect, setOpen]
|
|
3119
|
-
);
|
|
3120
|
-
const isActive = React.useMemo(() => index === activeIndex, [activeIndex, index]);
|
|
3121
|
-
const computedChildren = React.useMemo(() => {
|
|
3122
|
-
return typeof children === "function" ? children({ active: isActive, selected: false }) : children;
|
|
3123
|
-
}, [children, isActive]);
|
|
3124
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3125
|
-
"div",
|
|
3126
|
-
{
|
|
3127
|
-
className: classVarianceAuthority.cx(className, menuItem({ size, variant }), radiusCva({ radius, maxLarge: true })),
|
|
3128
|
-
ref: mergeRefs2,
|
|
3129
|
-
role: "menuitem",
|
|
3130
|
-
"data-disabled": disabled ? "" : void 0,
|
|
3131
|
-
"aria-disabled": disabled,
|
|
3132
|
-
"data-highlighted": isActive ? "" : void 0,
|
|
3133
|
-
...getItemProps({
|
|
3134
|
-
onClick: handleClick,
|
|
3135
|
-
onKeyDown: handleKeyDown,
|
|
3136
|
-
tabIndex: isActive ? 0 : -1,
|
|
3137
|
-
...rest
|
|
3138
|
-
}),
|
|
3139
|
-
children: computedChildren
|
|
3140
3171
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3172
|
+
},
|
|
3173
|
+
[closeOnSelect, disabled, onKeyDown, onSelect, setOpen]
|
|
3174
|
+
);
|
|
3175
|
+
const isActive = React.useMemo(() => index === activeIndex, [activeIndex, index]);
|
|
3176
|
+
const computedChildren = React.useMemo(() => {
|
|
3177
|
+
return typeof children === "function" ? children({ active: isActive, selected: false }) : children;
|
|
3178
|
+
}, [children, isActive]);
|
|
3179
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3180
|
+
"div",
|
|
3181
|
+
{
|
|
3182
|
+
className: classVarianceAuthority.cx(className, menuItem({ size, variant }), radiusCva({ radius, maxLarge: true })),
|
|
3183
|
+
ref: mergeRefs2,
|
|
3184
|
+
role: "menuitem",
|
|
3185
|
+
"data-disabled": getBooleanState(disabled),
|
|
3186
|
+
"aria-disabled": disabled,
|
|
3187
|
+
"data-highlighted": isActive ? "" : void 0,
|
|
3188
|
+
...getItemProps({
|
|
3189
|
+
onClick: handleClick,
|
|
3190
|
+
onKeyDown: handleKeyDown,
|
|
3191
|
+
tabIndex: isActive ? 0 : -1,
|
|
3192
|
+
...rest
|
|
3193
|
+
}),
|
|
3194
|
+
children: computedChildren
|
|
3195
|
+
}
|
|
3196
|
+
);
|
|
3197
|
+
});
|
|
3198
|
+
MenuItem.displayName = "MenuItem";
|
|
3144
3199
|
const MenuCheckboxItem = React.forwardRef((props, ref) => {
|
|
3145
3200
|
const { checked, onCheckedChange, onSelect, ...rest } = props;
|
|
3146
3201
|
const handleSelect = React.useCallback(() => {
|
|
@@ -3159,9 +3214,8 @@
|
|
|
3159
3214
|
});
|
|
3160
3215
|
MenuCheckboxItem.displayName = "MenuCheckboxItem";
|
|
3161
3216
|
const MenuCheckboxItemIndicator = React.forwardRef((props, ref) => {
|
|
3162
|
-
const {
|
|
3163
|
-
|
|
3164
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { ref, className: classVarianceAuthority.cx(className, menuSelectedIndicator({ size })), ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicator, { children }) });
|
|
3217
|
+
const { children, ...rest } = props;
|
|
3218
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicator, { ref, ...rest, children });
|
|
3165
3219
|
});
|
|
3166
3220
|
MenuCheckboxItemIndicator.displayName = "MenuCheckboxItemIndicator";
|
|
3167
3221
|
const MenuClickTrigger = React.memo(
|
|
@@ -3177,8 +3231,8 @@
|
|
|
3177
3231
|
{
|
|
3178
3232
|
ref: mergedRefs,
|
|
3179
3233
|
"aria-disabled": disabled,
|
|
3180
|
-
"data-disabled": disabled
|
|
3181
|
-
"data-state": open
|
|
3234
|
+
"data-disabled": getBooleanState(disabled),
|
|
3235
|
+
"data-state": getOpenState(open),
|
|
3182
3236
|
...getReferenceProps({ disabled }),
|
|
3183
3237
|
children
|
|
3184
3238
|
}
|
|
@@ -3187,9 +3241,9 @@
|
|
|
3187
3241
|
);
|
|
3188
3242
|
const MenuContextTrigger = React.memo(
|
|
3189
3243
|
React.forwardRef((props, forwardedRef) => {
|
|
3190
|
-
const { children, disabled } = props;
|
|
3244
|
+
const { children, disabled = false } = props;
|
|
3191
3245
|
const ref = React.useRef(null);
|
|
3192
|
-
const { setOpen, refs, setTriggerType } = useMenuContext();
|
|
3246
|
+
const { setOpen, refs, setTriggerType, open } = useMenuContext();
|
|
3193
3247
|
const mergedRefs = react.useMergeRefs([forwardedRef, ref]);
|
|
3194
3248
|
React.useEffect(() => {
|
|
3195
3249
|
setTriggerType("context");
|
|
@@ -3225,7 +3279,8 @@
|
|
|
3225
3279
|
ref: mergedRefs,
|
|
3226
3280
|
style: { WebkitTouchCallout: disabled ? "none" : "unset" },
|
|
3227
3281
|
"aria-disabled": disabled,
|
|
3228
|
-
"data-disabled": disabled
|
|
3282
|
+
"data-disabled": getBooleanState(disabled),
|
|
3283
|
+
"data-state": getOpenState(open),
|
|
3229
3284
|
onContextMenu: handleContextMenu,
|
|
3230
3285
|
children
|
|
3231
3286
|
}
|
|
@@ -3240,7 +3295,7 @@
|
|
|
3240
3295
|
);
|
|
3241
3296
|
const MenuInputField = React.memo(
|
|
3242
3297
|
React.forwardRef((props, forwardedRef) => {
|
|
3243
|
-
const { className, onValueChange, onChange, ...rest } = props;
|
|
3298
|
+
const { className, onValueChange, onChange, disabled = false, ...rest } = props;
|
|
3244
3299
|
const { activeIndex, getItemProps } = useMenuContentContext();
|
|
3245
3300
|
const { index, ref } = react.useListItem();
|
|
3246
3301
|
const mergedRefs = react.useMergeRefs([ref, forwardedRef]);
|
|
@@ -3261,6 +3316,8 @@
|
|
|
3261
3316
|
{
|
|
3262
3317
|
className: classVarianceAuthority.cx(className, "placeholder-(--base-a9)", "selection:bg-(--accent-a5)", "outline-none"),
|
|
3263
3318
|
ref: mergedRefs,
|
|
3319
|
+
disabled,
|
|
3320
|
+
"data-disabled": getBooleanState(disabled),
|
|
3264
3321
|
...getItemProps({
|
|
3265
3322
|
...rest,
|
|
3266
3323
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
@@ -3283,92 +3340,55 @@
|
|
|
3283
3340
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classVarianceAuthority.cx(className, "flex", "items-center", "text-(--base-a11)"), ref, ...rest });
|
|
3284
3341
|
})
|
|
3285
3342
|
);
|
|
3286
|
-
const
|
|
3287
|
-
|
|
3288
|
-
return
|
|
3289
|
-
}
|
|
3290
|
-
const SelectContextProvider = React.memo((props) => {
|
|
3291
|
-
const { type, children } = props;
|
|
3292
|
-
const [controlledValue, setControlledValue] = React.useState(
|
|
3293
|
-
type === "single" ? (props == null ? void 0 : props.defaultValue) ?? null : null
|
|
3294
|
-
);
|
|
3295
|
-
const [controlledValues, setControlledValues] = React.useState(
|
|
3296
|
-
type === "multi" ? (props == null ? void 0 : props.defaultValues) ?? [] : []
|
|
3297
|
-
);
|
|
3298
|
-
const onValuesChange = React.useCallback(
|
|
3299
|
-
(values) => {
|
|
3300
|
-
setControlledValues(values);
|
|
3301
|
-
if (type === "multi" && (props == null ? void 0 : props.onValuesChange)) props.onValuesChange(values);
|
|
3302
|
-
},
|
|
3303
|
-
[props, type]
|
|
3304
|
-
);
|
|
3305
|
-
const onValueChange = React.useCallback(
|
|
3306
|
-
(value2) => {
|
|
3307
|
-
setControlledValue(value2);
|
|
3308
|
-
if (type === "single" && (props == null ? void 0 : props.onValueChange)) props.onValueChange(value2);
|
|
3309
|
-
},
|
|
3310
|
-
[props, type]
|
|
3311
|
-
);
|
|
3312
|
-
const value = React.useMemo(
|
|
3313
|
-
() => type === "multi" ? {
|
|
3314
|
-
type,
|
|
3315
|
-
values: (props == null ? void 0 : props.values) ?? controlledValues,
|
|
3316
|
-
handleValuesChange: onValuesChange
|
|
3317
|
-
} : {
|
|
3318
|
-
type,
|
|
3319
|
-
value: props.value ?? controlledValue,
|
|
3320
|
-
handleValueChange: onValueChange
|
|
3321
|
-
},
|
|
3322
|
-
[controlledValue, controlledValues, onValueChange, onValuesChange, props, type]
|
|
3323
|
-
);
|
|
3324
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext.Provider, { value, children });
|
|
3343
|
+
const MenuMultiSelectGroup = genericMemo(function MenuMultiSelectGroup2(props) {
|
|
3344
|
+
const { ref, children, defaultValues, values, onValuesChange, ...rest } = props;
|
|
3345
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(MultiSelectProvider, { defaultValues, values, onValuesChange, children }) });
|
|
3325
3346
|
});
|
|
3326
|
-
|
|
3327
|
-
const MenuMultiSelectGroup = React.memo(
|
|
3328
|
-
React.forwardRef((props, ref) => {
|
|
3329
|
-
const { children, values, onValuesChange, ...rest } = props;
|
|
3330
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MenuGroup, { ref, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(SelectContextProvider, { type: "multi", values, onValuesChange, children }) });
|
|
3331
|
-
})
|
|
3332
|
-
);
|
|
3333
|
-
const SelectedIndicatorContext = React.createContext({});
|
|
3347
|
+
const SelectedIndicatorContext = React.createContext(false);
|
|
3334
3348
|
const useSelectedIndicatorContext = () => React.useContext(SelectedIndicatorContext);
|
|
3335
3349
|
const MenuSelectedIndicator = React.forwardRef((props, ref) => {
|
|
3336
3350
|
const { children } = props;
|
|
3337
|
-
const
|
|
3338
|
-
|
|
3339
|
-
|
|
3351
|
+
const isSelected = useSelectedIndicatorContext();
|
|
3352
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3353
|
+
"span",
|
|
3354
|
+
{
|
|
3355
|
+
ref,
|
|
3356
|
+
className: classVarianceAuthority.cx({
|
|
3357
|
+
invisible: !isSelected
|
|
3358
|
+
}),
|
|
3359
|
+
"data-state": getSelectedState(isSelected),
|
|
3360
|
+
children
|
|
3361
|
+
}
|
|
3362
|
+
);
|
|
3340
3363
|
});
|
|
3341
3364
|
MenuSelectedIndicator.displayName = "SelectedIndicator";
|
|
3342
|
-
const MenuMultiSelectItem =
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
}
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
) });
|
|
3370
|
-
})
|
|
3371
|
-
);
|
|
3365
|
+
const MenuMultiSelectItem = genericMemo(function(props) {
|
|
3366
|
+
const { ref, onSelect, children, closeOnSelect = false, value, ...rest } = props;
|
|
3367
|
+
const { selected, selectValue, registerValue } = React.use(MultiSelectContext);
|
|
3368
|
+
React.useLayoutEffect(() => {
|
|
3369
|
+
return registerValue(value);
|
|
3370
|
+
}, [registerValue, value]);
|
|
3371
|
+
const isSelected = selected(value);
|
|
3372
|
+
const handleSelect = React.useCallback(() => {
|
|
3373
|
+
if (onSelect) onSelect();
|
|
3374
|
+
selectValue(value);
|
|
3375
|
+
}, [onSelect, selectValue, value]);
|
|
3376
|
+
const computedChildren = React.useMemo(() => {
|
|
3377
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3378
|
+
}, [children, isSelected]);
|
|
3379
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3380
|
+
MenuItem,
|
|
3381
|
+
{
|
|
3382
|
+
ref,
|
|
3383
|
+
role: "menuitemcheckbox",
|
|
3384
|
+
onSelect: handleSelect,
|
|
3385
|
+
closeOnSelect,
|
|
3386
|
+
"data-state": getSelectedState(isSelected),
|
|
3387
|
+
...rest,
|
|
3388
|
+
children: computedChildren
|
|
3389
|
+
}
|
|
3390
|
+
) });
|
|
3391
|
+
});
|
|
3372
3392
|
const PagesContext = React.createContext({});
|
|
3373
3393
|
const usePagesContext = () => React.useContext(PagesContext);
|
|
3374
3394
|
const MenuPages = (props) => {
|
|
@@ -3412,77 +3432,65 @@
|
|
|
3412
3432
|
);
|
|
3413
3433
|
});
|
|
3414
3434
|
MenuScroll.displayName = "MenuScroll";
|
|
3415
|
-
const
|
|
3416
|
-
|
|
3417
|
-
const {
|
|
3418
|
-
const
|
|
3419
|
-
const { selected } = React.useContext(SelectAllContext);
|
|
3420
|
-
const computedChildren = React.useMemo(() => {
|
|
3421
|
-
return typeof children === "function" ? children(selected === "indeterminate") : children;
|
|
3422
|
-
}, [children, selected]);
|
|
3423
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { ref, className: classVarianceAuthority.cx(className, menuSelectedIndicator({ size })), ...rest, children: selected ? computedChildren : null });
|
|
3424
|
-
});
|
|
3425
|
-
MenuSelectAllIndicator.displayName = "SelectAllIndicator";
|
|
3426
|
-
const MenuSelectAllItem = React.forwardRef((props, ref) => {
|
|
3427
|
-
const { children, allValues, onSelect, closeOnSelect = false, ...rest } = props;
|
|
3428
|
-
const { values, handleValuesChange } = useSelectContext();
|
|
3429
|
-
const selected = React.useMemo(() => {
|
|
3430
|
-
const selectValuesSet = new Set(values);
|
|
3431
|
-
if (allValues.every((value) => selectValuesSet.has(value))) return true;
|
|
3432
|
-
if (values.length > 0) return "indeterminate";
|
|
3433
|
-
return false;
|
|
3434
|
-
}, [allValues, values]);
|
|
3435
|
+
const MenuSelectAllItem = genericMemo((props) => {
|
|
3436
|
+
const { ref, children, onSelect, closeOnSelect = false, ...rest } = props;
|
|
3437
|
+
const { allSelected, someSelected, toggleSelectAll } = React.use(MultiSelectContext);
|
|
3438
|
+
const selectedState = allSelected ? true : someSelected ? "indeterminate" : false;
|
|
3435
3439
|
const handleSelect = React.useCallback(() => {
|
|
3436
3440
|
onSelect == null ? void 0 : onSelect();
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3441
|
+
toggleSelectAll();
|
|
3442
|
+
}, [onSelect, toggleSelectAll]);
|
|
3443
|
+
const computedChildren = React.useMemo(() => {
|
|
3444
|
+
return typeof children === "function" ? ({ active }) => children({ selected: selectedState, active }) : children;
|
|
3445
|
+
}, [children, selectedState]);
|
|
3446
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckedIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3447
|
+
MenuItem,
|
|
3448
|
+
{
|
|
3449
|
+
onSelect: handleSelect,
|
|
3450
|
+
ref,
|
|
3451
|
+
"data-state": getCheckedState(selectedState),
|
|
3452
|
+
closeOnSelect,
|
|
3453
|
+
...rest,
|
|
3454
|
+
children: computedChildren
|
|
3446
3455
|
}
|
|
3447
|
-
}
|
|
3456
|
+
) });
|
|
3457
|
+
});
|
|
3458
|
+
const MenuSelectGroup = genericMemo(function MenuSelectGroup2(props) {
|
|
3459
|
+
const { ref, children, required, defaultValue, value, onValueChange, ...rest } = props;
|
|
3460
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuGroup, { ref, ...rest, children: required ? /* @__PURE__ */ jsxRuntime.jsx(SingleSelectRequiredProvider, { defaultValue, value, onValueChange, children }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3461
|
+
SingleSelectNotRequiredProvider,
|
|
3462
|
+
{
|
|
3463
|
+
defaultValue,
|
|
3464
|
+
value,
|
|
3465
|
+
onValueChange,
|
|
3466
|
+
children
|
|
3467
|
+
}
|
|
3468
|
+
) });
|
|
3469
|
+
});
|
|
3470
|
+
const MenuSelectItem = genericMemo(function(props) {
|
|
3471
|
+
const { ref, value, onSelect, children, closeOnSelect = true, ...rest } = props;
|
|
3472
|
+
const { selected, selectValue } = React.use(SelectContext);
|
|
3473
|
+
const isSelected = React.useMemo(() => selected(value), [selected, value]);
|
|
3474
|
+
const handleSelect = React.useCallback(() => {
|
|
3475
|
+
if (onSelect) onSelect();
|
|
3476
|
+
selectValue(value);
|
|
3477
|
+
}, [onSelect, selectValue, value]);
|
|
3448
3478
|
const computedChildren = React.useMemo(() => {
|
|
3449
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3450
|
-
}, [children,
|
|
3451
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3479
|
+
return typeof children === "function" ? ({ active }) => children({ selected: isSelected, active }) : children;
|
|
3480
|
+
}, [children, isSelected]);
|
|
3481
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext.Provider, { value: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3482
|
+
MenuItem,
|
|
3483
|
+
{
|
|
3484
|
+
ref,
|
|
3485
|
+
role: "menuitemcheckbox",
|
|
3486
|
+
onSelect: handleSelect,
|
|
3487
|
+
closeOnSelect,
|
|
3488
|
+
"data-state": getSelectedState(isSelected),
|
|
3489
|
+
...rest,
|
|
3490
|
+
children: computedChildren
|
|
3491
|
+
}
|
|
3492
|
+
) });
|
|
3452
3493
|
});
|
|
3453
|
-
MenuSelectAllItem.displayName = "SelectAllItem";
|
|
3454
|
-
const MenuSelectGroup = React.memo(
|
|
3455
|
-
React.forwardRef((props, ref) => {
|
|
3456
|
-
const { children, value, onValueChange } = props;
|
|
3457
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectContextProvider, { type: "single", value, onValueChange, children: /* @__PURE__ */ jsxRuntime.jsx(MenuGroup, { ref, children }) });
|
|
3458
|
-
})
|
|
3459
|
-
);
|
|
3460
|
-
const MenuSelectItem = React.memo(
|
|
3461
|
-
React.forwardRef((props, ref) => {
|
|
3462
|
-
const { value, onSelect, children, closeOnSelect = true, ...rest } = props;
|
|
3463
|
-
const { value: currentValue, handleValueChange } = useSelectContext();
|
|
3464
|
-
const selected = React.useMemo(() => value === currentValue, [currentValue, value]);
|
|
3465
|
-
const handleSelect = React.useCallback(() => {
|
|
3466
|
-
handleValueChange(!selected ? value : null);
|
|
3467
|
-
if (onSelect) onSelect();
|
|
3468
|
-
}, [handleValueChange, onSelect, selected, value]);
|
|
3469
|
-
const computedChildren = React.useMemo(() => {
|
|
3470
|
-
return typeof children === "function" ? ({ active }) => children({ selected, active }) : children;
|
|
3471
|
-
}, [children, selected]);
|
|
3472
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectedIndicatorContext.Provider, { value: { selected }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3473
|
-
MenuItem,
|
|
3474
|
-
{
|
|
3475
|
-
ref,
|
|
3476
|
-
role: "menuitemcheckbox",
|
|
3477
|
-
onSelect: handleSelect,
|
|
3478
|
-
closeOnSelect,
|
|
3479
|
-
"data-selected": selected ? "" : void 0,
|
|
3480
|
-
...rest,
|
|
3481
|
-
children: computedChildren
|
|
3482
|
-
}
|
|
3483
|
-
) });
|
|
3484
|
-
})
|
|
3485
|
-
);
|
|
3486
3494
|
const MenuSeparator = React.memo(
|
|
3487
3495
|
React.forwardRef((props, ref) => {
|
|
3488
3496
|
const { className, ...rest } = props;
|
|
@@ -3553,7 +3561,7 @@
|
|
|
3553
3561
|
"max-h-(--overmap-menu-available-height)"
|
|
3554
3562
|
),
|
|
3555
3563
|
ref: forwardedRef,
|
|
3556
|
-
"data-state": open
|
|
3564
|
+
"data-state": getOpenState(open),
|
|
3557
3565
|
"data-side": side,
|
|
3558
3566
|
"data-accent-color": accentColor,
|
|
3559
3567
|
...rest,
|
|
@@ -3577,7 +3585,7 @@
|
|
|
3577
3585
|
ref: mergedRefs,
|
|
3578
3586
|
closeOnSelect: false,
|
|
3579
3587
|
"aria-haspopup": "menu",
|
|
3580
|
-
"data-
|
|
3588
|
+
"data-state": getOpenState(open),
|
|
3581
3589
|
disabled,
|
|
3582
3590
|
...getReferenceProps(rest),
|
|
3583
3591
|
children
|
|
@@ -3629,7 +3637,6 @@
|
|
|
3629
3637
|
SelectAllItem: MenuSelectAllItem,
|
|
3630
3638
|
CheckboxItem: MenuCheckboxItem,
|
|
3631
3639
|
// indicators
|
|
3632
|
-
SelectAllIndicator: MenuSelectAllIndicator,
|
|
3633
3640
|
SelectedIndicator: MenuSelectedIndicator,
|
|
3634
3641
|
CheckboxItemIndicator: MenuCheckboxItemIndicator,
|
|
3635
3642
|
// input
|
|
@@ -5010,7 +5017,6 @@
|
|
|
5010
5017
|
exports2.MenuPages = MenuPages;
|
|
5011
5018
|
exports2.MenuRoot = MenuRoot;
|
|
5012
5019
|
exports2.MenuScroll = MenuScroll;
|
|
5013
|
-
exports2.MenuSelectAllIndicator = MenuSelectAllIndicator;
|
|
5014
5020
|
exports2.MenuSelectAllItem = MenuSelectAllItem;
|
|
5015
5021
|
exports2.MenuSelectGroup = MenuSelectGroup;
|
|
5016
5022
|
exports2.MenuSelectItem = MenuSelectItem;
|