@overmap-ai/blocks 1.0.33 → 1.0.34-command-menu.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CommandMenu/CheckboxIndicator.d.ts +7 -0
- package/dist/CommandMenu/CheckboxItem.d.ts +7 -0
- package/dist/CommandMenu/Content.d.ts +7 -0
- package/dist/CommandMenu/Empty.d.ts +5 -0
- package/dist/CommandMenu/Group.d.ts +5 -0
- package/dist/CommandMenu/Input.d.ts +5 -0
- package/dist/CommandMenu/Item.d.ts +6 -0
- package/dist/CommandMenu/List.d.ts +5 -0
- package/dist/CommandMenu/MultiSelectGroup.d.ts +7 -0
- package/dist/CommandMenu/MultiSelectItem.d.ts +5 -0
- package/dist/CommandMenu/Overlay.d.ts +5 -0
- package/dist/CommandMenu/Page.d.ts +5 -0
- package/dist/CommandMenu/PageTriggerItem.d.ts +5 -0
- package/dist/CommandMenu/Pages.d.ts +7 -0
- package/dist/CommandMenu/RadioGroup.d.ts +7 -0
- package/dist/CommandMenu/RadioItem.d.ts +5 -0
- package/dist/CommandMenu/Root.d.ts +5 -0
- package/dist/CommandMenu/SelectAllItem.d.ts +4 -0
- package/dist/CommandMenu/SelectedIndicator.d.ts +6 -0
- package/dist/CommandMenu/Separator.d.ts +6 -0
- package/dist/CommandMenu/Trigger.d.ts +5 -0
- package/dist/CommandMenu/context.d.ts +34 -0
- package/dist/CommandMenu/cva.d.ts +25 -0
- package/dist/CommandMenu/index.d.ts +46 -0
- package/dist/CommandMenu/typings.d.ts +10 -0
- package/dist/CommandMenu/utils.d.ts +4 -0
- package/dist/blocks.js +618 -20
- package/dist/blocks.js.map +1 -1
- package/dist/blocks.umd.cjs +617 -21
- package/dist/blocks.umd.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/utils.d.ts +1 -6
- package/package.json +2 -1
package/dist/blocks.js
CHANGED
|
@@ -2,15 +2,17 @@ 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, useRef } from "react";
|
|
5
|
+
import React__default, { createContext, useContext, useMemo, forwardRef, memo, useState, useCallback, useLayoutEffect, useEffect, use, useId, 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";
|
|
9
9
|
import { useMediaQuery } from "react-responsive";
|
|
10
|
+
import { CommandItem, CommandRoot, CommandEmpty, CommandGroup, CommandInput, useCommandState, CommandList, CommandSeparator } from "cmdk";
|
|
11
|
+
import * as RadixDialog from "@radix-ui/react-dialog";
|
|
12
|
+
import { DialogPortal, DialogContent as DialogContent$1, DialogTitle, DialogDescription, DialogOverlay as DialogOverlay$1, Dialog as Dialog$1, DialogTrigger } from "@radix-ui/react-dialog";
|
|
10
13
|
import { DayPicker as DayPicker$1 } from "react-day-picker";
|
|
11
14
|
import * as RiIcons from "react-icons/ri";
|
|
12
15
|
import { RiArrowRightSLine, RiArrowLeftSLine, RiArrowDownSLine, RiArrowUpSLine, RiQuestionMark } from "react-icons/ri";
|
|
13
|
-
import * as RadixDialog from "@radix-ui/react-dialog";
|
|
14
16
|
import { HiX } from "react-icons/hi";
|
|
15
17
|
import * as RadixHoverCard from "@radix-ui/react-hover-card";
|
|
16
18
|
import { CSSTransition } from "react-transition-group";
|
|
@@ -132,12 +134,13 @@ const dialogContent = cva(
|
|
|
132
134
|
"[scrollbar-width:thin]",
|
|
133
135
|
"[scrollbar-color:var(--base-6)_transparent]",
|
|
134
136
|
"max-h-3/4",
|
|
137
|
+
"shadow-md",
|
|
135
138
|
"overflow-hidden",
|
|
136
139
|
"w-full",
|
|
137
140
|
"bg-(--color-background)",
|
|
138
141
|
"dark:bg-(--base-2)",
|
|
139
142
|
"ring-1",
|
|
140
|
-
"ring-(--base-
|
|
143
|
+
"ring-(--base-a6)",
|
|
141
144
|
"fixed",
|
|
142
145
|
"left-[50%]",
|
|
143
146
|
"top-[50%]",
|
|
@@ -890,8 +893,7 @@ const useSize = (target) => {
|
|
|
890
893
|
return size2;
|
|
891
894
|
};
|
|
892
895
|
const genericMemo = memo;
|
|
893
|
-
function useControlledState(
|
|
894
|
-
const { state, setState, initialState } = args;
|
|
896
|
+
function useControlledState(initialState, state, setState) {
|
|
895
897
|
const [uncontrolledState, setUncontrolledState] = useState(initialState);
|
|
896
898
|
return [state !== void 0 ? state : uncontrolledState, setState !== void 0 ? setState : setUncontrolledState];
|
|
897
899
|
}
|
|
@@ -1018,6 +1020,592 @@ const CollapsibleTree = genericMemo(function(props) {
|
|
|
1018
1020
|
}
|
|
1019
1021
|
);
|
|
1020
1022
|
});
|
|
1023
|
+
const CommandMenuContext = createContext({});
|
|
1024
|
+
const SelectContext$1 = createContext({});
|
|
1025
|
+
const MultiSelectGroupContext = createContext({});
|
|
1026
|
+
const SelectedIndicatorContext$1 = createContext(false);
|
|
1027
|
+
const CheckboxIndicatorContext = createContext(false);
|
|
1028
|
+
const CommandMenuPageContext = createContext({});
|
|
1029
|
+
const CommandMenuDialogContext = createContext({});
|
|
1030
|
+
function getSelectedState(selected) {
|
|
1031
|
+
return selected ? "selected" : "unselected";
|
|
1032
|
+
}
|
|
1033
|
+
function getCheckedState(checked) {
|
|
1034
|
+
return checked === true ? "checked" : checked === false ? "unchecked" : "indeterminate";
|
|
1035
|
+
}
|
|
1036
|
+
function getActiveState(active) {
|
|
1037
|
+
return active ? "active" : "inactive";
|
|
1038
|
+
}
|
|
1039
|
+
const CommandMenuCheckboxIndicator = (props) => {
|
|
1040
|
+
const { ref, alwaysRender = false, children, ...rest } = props;
|
|
1041
|
+
const checkedState = use(CheckboxIndicatorContext);
|
|
1042
|
+
const computedChildren = useMemo(() => {
|
|
1043
|
+
return typeof children === "function" ? children(checkedState) : children;
|
|
1044
|
+
}, [checkedState, children]);
|
|
1045
|
+
const render = alwaysRender || !!checkedState;
|
|
1046
|
+
if (!render) return null;
|
|
1047
|
+
return /* @__PURE__ */ jsx("span", { ref, "data-state": getCheckedState(checkedState), className: "size-max", ...rest, children: computedChildren });
|
|
1048
|
+
};
|
|
1049
|
+
const commandMenuContentCva = cva(
|
|
1050
|
+
[
|
|
1051
|
+
"ring",
|
|
1052
|
+
"ring-(--base-a6)",
|
|
1053
|
+
"shadow-md",
|
|
1054
|
+
"fixed",
|
|
1055
|
+
"max-w-lg",
|
|
1056
|
+
"size-full",
|
|
1057
|
+
"h-max",
|
|
1058
|
+
"overflow-hidden",
|
|
1059
|
+
"bg-(--color-background)",
|
|
1060
|
+
"dark:bg-(--base-2)",
|
|
1061
|
+
"outline-none",
|
|
1062
|
+
"top-[15%]",
|
|
1063
|
+
"left-1/2",
|
|
1064
|
+
"-translate-x-1/2",
|
|
1065
|
+
"data-[state='open']:animate-in",
|
|
1066
|
+
"data-[state='open']:fade-in-0",
|
|
1067
|
+
"data-[state='closed']:animate-out",
|
|
1068
|
+
"data-[state='closed']:fade-out-0"
|
|
1069
|
+
],
|
|
1070
|
+
{
|
|
1071
|
+
variants: {
|
|
1072
|
+
size: {
|
|
1073
|
+
xs: ["text-sm"],
|
|
1074
|
+
sm: ["text-base"],
|
|
1075
|
+
md: ["text-base"],
|
|
1076
|
+
lg: ["text-lg"],
|
|
1077
|
+
xl: ["text-lg"]
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
defaultVariants: {
|
|
1081
|
+
size: "md"
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
const commandMenuOverlayCva = cva([
|
|
1086
|
+
"fixed",
|
|
1087
|
+
"inset-0",
|
|
1088
|
+
"duration-200",
|
|
1089
|
+
"bg-(--black-a6)",
|
|
1090
|
+
"dark:bg-(--black-a8)",
|
|
1091
|
+
"data-[state='open']:animate-in",
|
|
1092
|
+
"data-[state='open']:fade-in-0",
|
|
1093
|
+
"data-[state='closed']:animate-out",
|
|
1094
|
+
"data-[state='closed']:fade-out-0"
|
|
1095
|
+
]);
|
|
1096
|
+
const commandMenuListCva = cva(
|
|
1097
|
+
["[scrollbar-width:thin]", "[scrollbar-color:var(--base-6)_transparent]", "overflow-auto", "h-max", "max-h-100"],
|
|
1098
|
+
{
|
|
1099
|
+
variants: {
|
|
1100
|
+
size: {
|
|
1101
|
+
xs: ["py-1.75", "scroll-py-1.75"],
|
|
1102
|
+
sm: ["py-2", "scroll-py-2"],
|
|
1103
|
+
md: ["py-2.25", "scroll-py-2.25"],
|
|
1104
|
+
lg: ["py-2.5", "scroll-py-2.5"],
|
|
1105
|
+
xl: ["py-2.75", "scroll-py-2.75"]
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1108
|
+
defaultVariants: {
|
|
1109
|
+
size: "md"
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
);
|
|
1113
|
+
const commandMenuInputCva = cva(["outline-none", "w-full"], {
|
|
1114
|
+
variants: {
|
|
1115
|
+
size: {
|
|
1116
|
+
xs: ["h-12", "px-5.25", "text-base"],
|
|
1117
|
+
sm: ["h-13", "px-6", "text-lg"],
|
|
1118
|
+
md: ["h-14", "px-6.75", "text-lg"],
|
|
1119
|
+
lg: ["h-15", "px-8.5", "text-xl"],
|
|
1120
|
+
xl: ["h-16", "px-9.25", "text-xl"]
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
const commandMenuSeparatorCva = cva(["h-px", "bg-(--base-a6)", "w-full"], {
|
|
1125
|
+
variants: {
|
|
1126
|
+
spacing: {
|
|
1127
|
+
true: [],
|
|
1128
|
+
false: []
|
|
1129
|
+
},
|
|
1130
|
+
size: {
|
|
1131
|
+
xs: [],
|
|
1132
|
+
sm: [],
|
|
1133
|
+
md: [],
|
|
1134
|
+
lg: [],
|
|
1135
|
+
xl: []
|
|
1136
|
+
}
|
|
1137
|
+
},
|
|
1138
|
+
compoundVariants: [
|
|
1139
|
+
{ spacing: true, size: "xs", className: ["my-1.75"] },
|
|
1140
|
+
{ spacing: true, size: "sm", className: ["my-2"] },
|
|
1141
|
+
{ spacing: true, size: "md", className: ["my-2.25"] },
|
|
1142
|
+
{ spacing: true, size: "lg", className: ["my-2.5"] },
|
|
1143
|
+
{ spacing: true, size: "xl", className: ["my-2.75"] }
|
|
1144
|
+
]
|
|
1145
|
+
});
|
|
1146
|
+
const commandMenuItemCva = cva(
|
|
1147
|
+
[
|
|
1148
|
+
"relative",
|
|
1149
|
+
"flex",
|
|
1150
|
+
"items-center",
|
|
1151
|
+
"outline-none",
|
|
1152
|
+
// select
|
|
1153
|
+
"select-none",
|
|
1154
|
+
// cursor
|
|
1155
|
+
"cursor-pointer",
|
|
1156
|
+
// disabled
|
|
1157
|
+
"data-[disabled=true]:text-(--base-a8)",
|
|
1158
|
+
"data-[disabled=true]:pointer-events-none",
|
|
1159
|
+
// after
|
|
1160
|
+
"after:absolute",
|
|
1161
|
+
"after:bg-transparent",
|
|
1162
|
+
"after:z-[-1]",
|
|
1163
|
+
"after:inset-y-0"
|
|
1164
|
+
],
|
|
1165
|
+
{
|
|
1166
|
+
variants: {
|
|
1167
|
+
size: {
|
|
1168
|
+
xs: ["h-10", "gap-3.5", "px-5.25", "after:inset-x-1.75"],
|
|
1169
|
+
sm: ["h-11", "gap-4", "px-6", "after:inset-x-2"],
|
|
1170
|
+
md: ["h-12", "gap-4.5", "px-6.75", "after:inset-x-2.25"],
|
|
1171
|
+
lg: ["h-13", "gap-5", "px-7.5", "after:inset-x-2.5"],
|
|
1172
|
+
xl: ["h-14", "gap-5.5", "px-8.25", "after:inset-x-2.75"]
|
|
1173
|
+
},
|
|
1174
|
+
variant: {
|
|
1175
|
+
solid: [
|
|
1176
|
+
"text-(--base-12)",
|
|
1177
|
+
"data-[selected=true]:text-(--accent-contrast)",
|
|
1178
|
+
"data-[selected=true]:after:bg-(--accent-a9)",
|
|
1179
|
+
"data-[selected=true]:active:after:brightness-110"
|
|
1180
|
+
],
|
|
1181
|
+
soft: [
|
|
1182
|
+
"text-(--base-12)",
|
|
1183
|
+
"data-[selected=true]:after:bg-(--accent-a3)",
|
|
1184
|
+
"data-[selected=true]:active:after:bg-(--accent-a4)"
|
|
1185
|
+
]
|
|
1186
|
+
},
|
|
1187
|
+
radius: {
|
|
1188
|
+
none: ["after:rounded-none"],
|
|
1189
|
+
xs: ["after:rounded-xs"],
|
|
1190
|
+
sm: ["after:rounded-sm"],
|
|
1191
|
+
md: ["after:rounded-md"],
|
|
1192
|
+
lg: ["after:rounded-lg"],
|
|
1193
|
+
xl: ["after:rounded-xl"],
|
|
1194
|
+
full: ["after:rounded-full"]
|
|
1195
|
+
}
|
|
1196
|
+
},
|
|
1197
|
+
defaultVariants: {
|
|
1198
|
+
size: "md",
|
|
1199
|
+
variant: "soft"
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
);
|
|
1203
|
+
const commandMenuEmptyCva = cva(["flex", "justify-center", "text-(--base-a11)"], {
|
|
1204
|
+
variants: {
|
|
1205
|
+
size: {
|
|
1206
|
+
xs: ["py-3.5"],
|
|
1207
|
+
sm: ["py-4"],
|
|
1208
|
+
md: ["py-4.5"],
|
|
1209
|
+
lg: ["py-5"],
|
|
1210
|
+
xl: ["py-5.5"]
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
const commandMenuGroupCva = cva(
|
|
1215
|
+
[
|
|
1216
|
+
"[&_[cmdk-group-heading]]:text-(--base-a10)",
|
|
1217
|
+
"[&_[cmdk-group-heading]]:flex",
|
|
1218
|
+
"[&_[cmdk-group-heading]]:items-center"
|
|
1219
|
+
],
|
|
1220
|
+
{
|
|
1221
|
+
variants: {
|
|
1222
|
+
size: {
|
|
1223
|
+
xs: [
|
|
1224
|
+
"[&_[cmdk-group-heading]]:px-2.5",
|
|
1225
|
+
"[&_[cmdk-group-heading]]:h-6",
|
|
1226
|
+
"[&_[cmdk-group-heading]]:text-xs",
|
|
1227
|
+
"[&_[cmdk-group-heading]]:gap-2.5"
|
|
1228
|
+
],
|
|
1229
|
+
sm: [
|
|
1230
|
+
"[&_[cmdk-group-heading]]:px-2.75",
|
|
1231
|
+
"[&_[cmdk-group-heading]]:h-6.5",
|
|
1232
|
+
"[&_[cmdk-group-heading]]:text-sm",
|
|
1233
|
+
"[&_[cmdk-group-heading]]:gap-2.75"
|
|
1234
|
+
],
|
|
1235
|
+
md: [
|
|
1236
|
+
"[&_[cmdk-group-heading]]:px-3",
|
|
1237
|
+
"[&_[cmdk-group-heading]]:h-7",
|
|
1238
|
+
"[&_[cmdk-group-heading]]:text-sm",
|
|
1239
|
+
"[&_[cmdk-group-heading]]:gap-3"
|
|
1240
|
+
],
|
|
1241
|
+
lg: [
|
|
1242
|
+
"[&_[cmdk-group-heading]]:px-3.25",
|
|
1243
|
+
"[&_[cmdk-group-heading]]:h-7.5",
|
|
1244
|
+
"[&_[cmdk-group-heading]]:text-base",
|
|
1245
|
+
"[&_[cmdk-group-heading]]:gap-3.25"
|
|
1246
|
+
],
|
|
1247
|
+
xl: [
|
|
1248
|
+
"[&_[cmdk-group-heading]]:px-3.5",
|
|
1249
|
+
"[&_[cmdk-group-heading]]:h-8",
|
|
1250
|
+
"[&_[cmdk-group-heading]]:text-base",
|
|
1251
|
+
"[&_[cmdk-group-heading]]:gap-3.5"
|
|
1252
|
+
]
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
);
|
|
1257
|
+
const CommandMenuItem = memo((props) => {
|
|
1258
|
+
const { className, ref, closeOnSelect = true, onSelect, ...rest } = props;
|
|
1259
|
+
const { size: size2, variant, radius } = use(CommandMenuContext);
|
|
1260
|
+
const { setOpen } = use(CommandMenuDialogContext);
|
|
1261
|
+
const handleSelect = useCallback(
|
|
1262
|
+
(value) => {
|
|
1263
|
+
onSelect == null ? void 0 : onSelect(value);
|
|
1264
|
+
if (closeOnSelect) {
|
|
1265
|
+
setOpen(false);
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
[closeOnSelect, onSelect, setOpen]
|
|
1269
|
+
);
|
|
1270
|
+
return /* @__PURE__ */ jsx(
|
|
1271
|
+
CommandItem,
|
|
1272
|
+
{
|
|
1273
|
+
className: cx(className, commandMenuItemCva({ size: size2, variant, radius })),
|
|
1274
|
+
ref,
|
|
1275
|
+
onSelect: handleSelect,
|
|
1276
|
+
...rest
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
});
|
|
1280
|
+
CommandMenuItem.displayName = "CommandMenuItem";
|
|
1281
|
+
const CommandMenuCheckboxItem = (props) => {
|
|
1282
|
+
const { children, ref, checked, onCheckedChange, onSelect, ...rest } = props;
|
|
1283
|
+
const handleSelect = useCallback(
|
|
1284
|
+
(value) => {
|
|
1285
|
+
onSelect == null ? void 0 : onSelect(value);
|
|
1286
|
+
onCheckedChange(checked !== true);
|
|
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 }) });
|
|
1291
|
+
};
|
|
1292
|
+
const CommandMenuContent = memo((props) => {
|
|
1293
|
+
const providerContext = useProvider();
|
|
1294
|
+
const {
|
|
1295
|
+
children,
|
|
1296
|
+
className,
|
|
1297
|
+
ref,
|
|
1298
|
+
// DialogContent props
|
|
1299
|
+
forceMount,
|
|
1300
|
+
onOpenAutoFocus,
|
|
1301
|
+
onCloseAutoFocus,
|
|
1302
|
+
onEscapeKeyDown,
|
|
1303
|
+
onPointerDownOutside,
|
|
1304
|
+
onInteractOutside,
|
|
1305
|
+
// CommandMenuVariantProps
|
|
1306
|
+
variant = "soft",
|
|
1307
|
+
size: size2 = "md",
|
|
1308
|
+
accentColor = "base",
|
|
1309
|
+
radius = providerContext.radius,
|
|
1310
|
+
...rest
|
|
1311
|
+
} = props;
|
|
1312
|
+
const contextValue = useMemo(() => {
|
|
1313
|
+
return {
|
|
1314
|
+
variant,
|
|
1315
|
+
size: size2,
|
|
1316
|
+
radius
|
|
1317
|
+
};
|
|
1318
|
+
}, [radius, size2, variant]);
|
|
1319
|
+
return /* @__PURE__ */ jsx(DialogPortal, { children: /* @__PURE__ */ jsx(
|
|
1320
|
+
DialogContent$1,
|
|
1321
|
+
{
|
|
1322
|
+
forceMount,
|
|
1323
|
+
onOpenAutoFocus,
|
|
1324
|
+
onCloseAutoFocus,
|
|
1325
|
+
onEscapeKeyDown,
|
|
1326
|
+
onPointerDownOutside,
|
|
1327
|
+
onInteractOutside,
|
|
1328
|
+
asChild: true,
|
|
1329
|
+
children: /* @__PURE__ */ jsxs(
|
|
1330
|
+
CommandRoot,
|
|
1331
|
+
{
|
|
1332
|
+
className: cx(className, commandMenuContentCva({ size: size2 }), radiusCva({ radius, maxLarge: true })),
|
|
1333
|
+
ref,
|
|
1334
|
+
"data-accent-color": accentColor,
|
|
1335
|
+
...rest,
|
|
1336
|
+
children: [
|
|
1337
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "sr-only", children: props.label }),
|
|
1338
|
+
/* @__PURE__ */ jsx(DialogDescription, { className: "sr-only", children: "Use the command menu to trigger commands." }),
|
|
1339
|
+
/* @__PURE__ */ jsx(CommandMenuContext, { value: contextValue, children })
|
|
1340
|
+
]
|
|
1341
|
+
}
|
|
1342
|
+
)
|
|
1343
|
+
}
|
|
1344
|
+
) });
|
|
1345
|
+
});
|
|
1346
|
+
CommandMenuContent.displayName = "CommandMenuContent";
|
|
1347
|
+
const CommandMenuEmpty = memo((props) => {
|
|
1348
|
+
const { className, ref, ...rest } = props;
|
|
1349
|
+
const { size: size2 } = use(CommandMenuContext);
|
|
1350
|
+
return /* @__PURE__ */ jsx(CommandEmpty, { className: cx(className, commandMenuEmptyCva({ size: size2 })), ref, ...rest });
|
|
1351
|
+
});
|
|
1352
|
+
CommandMenuEmpty.displayName = "CommandMenuEmpty";
|
|
1353
|
+
const CommandMenuGroup = memo((props) => {
|
|
1354
|
+
const { className, ref, ...rest } = props;
|
|
1355
|
+
const { size: size2 } = use(CommandMenuContext);
|
|
1356
|
+
return /* @__PURE__ */ jsx(CommandGroup, { className: cx(className, commandMenuGroupCva({ size: size2 })), ref, ...rest });
|
|
1357
|
+
});
|
|
1358
|
+
CommandMenuGroup.displayName = "CommandMenuGroup";
|
|
1359
|
+
const CommandMenuInput = memo((props) => {
|
|
1360
|
+
const { className, ref, ...rest } = props;
|
|
1361
|
+
const { size: size2 } = use(CommandMenuContext);
|
|
1362
|
+
return /* @__PURE__ */ jsx(CommandInput, { className: cx(className, commandMenuInputCva({ size: size2 })), ref, ...rest });
|
|
1363
|
+
});
|
|
1364
|
+
CommandMenuInput.displayName = "CommandMenuInput";
|
|
1365
|
+
const CommandMenuList = memo((props) => {
|
|
1366
|
+
const { className, ref, ...rest } = props;
|
|
1367
|
+
const { size: size2 } = use(CommandMenuContext);
|
|
1368
|
+
const filterCount = useCommandState((state) => state.filtered.count);
|
|
1369
|
+
return /* @__PURE__ */ jsx(
|
|
1370
|
+
CommandList,
|
|
1371
|
+
{
|
|
1372
|
+
className: cx(className, commandMenuListCva({ size: size2 })),
|
|
1373
|
+
ref,
|
|
1374
|
+
hidden: filterCount === 0,
|
|
1375
|
+
...rest
|
|
1376
|
+
}
|
|
1377
|
+
);
|
|
1378
|
+
});
|
|
1379
|
+
CommandMenuList.displayName = "CommandMenuList";
|
|
1380
|
+
const CommandMenuMultiSelectGroup = (props) => {
|
|
1381
|
+
const { children, ref, defaultValues = [], values: controlledValues, onValuesChange, ...rest } = props;
|
|
1382
|
+
const [itemValueMapping, setItemValueMapping] = useState(/* @__PURE__ */ new Map());
|
|
1383
|
+
const [values, setValues] = useControlledState(defaultValues, controlledValues, onValuesChange);
|
|
1384
|
+
const selected = useCallback((value) => values.includes(value), [values]);
|
|
1385
|
+
const selectValue = useCallback(
|
|
1386
|
+
(value) => {
|
|
1387
|
+
if (selected(value)) {
|
|
1388
|
+
setValues(values.filter((v) => v !== value));
|
|
1389
|
+
} else {
|
|
1390
|
+
setValues([...values, value]);
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
[selected, setValues, values]
|
|
1394
|
+
);
|
|
1395
|
+
const selectContextValue = useMemo(() => {
|
|
1396
|
+
return {
|
|
1397
|
+
selected,
|
|
1398
|
+
selectValue
|
|
1399
|
+
};
|
|
1400
|
+
}, [selectValue, selected]);
|
|
1401
|
+
const contextValue = useMemo(() => {
|
|
1402
|
+
return {
|
|
1403
|
+
itemValueMapping,
|
|
1404
|
+
setItemValueMapping,
|
|
1405
|
+
values,
|
|
1406
|
+
setValues
|
|
1407
|
+
};
|
|
1408
|
+
}, [itemValueMapping, setValues, values]);
|
|
1409
|
+
return /* @__PURE__ */ jsx(SelectContext$1, { value: selectContextValue, children: /* @__PURE__ */ jsx(MultiSelectGroupContext, { value: contextValue, children: /* @__PURE__ */ jsx(CommandMenuGroup, { ref, "aria-multiselectable": true, ...rest, children }) }) });
|
|
1410
|
+
};
|
|
1411
|
+
const CommandMenuMultiSelectItem = (props) => {
|
|
1412
|
+
const { children, ref, value, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1413
|
+
const { selected, selectValue: handleSelectValue } = use(SelectContext$1);
|
|
1414
|
+
const itemValueId = useId();
|
|
1415
|
+
const { setItemValueMapping } = use(MultiSelectGroupContext);
|
|
1416
|
+
useLayoutEffect(() => {
|
|
1417
|
+
setItemValueMapping((prev) => new Map(prev).set(itemValueId, value));
|
|
1418
|
+
return () => {
|
|
1419
|
+
setItemValueMapping((prev) => {
|
|
1420
|
+
const next = new Map(prev);
|
|
1421
|
+
next.delete(itemValueId);
|
|
1422
|
+
return next;
|
|
1423
|
+
});
|
|
1424
|
+
};
|
|
1425
|
+
}, [itemValueId, setItemValueMapping, value]);
|
|
1426
|
+
const handleSelect = useCallback(
|
|
1427
|
+
(value2) => {
|
|
1428
|
+
onSelect == null ? void 0 : onSelect(value2);
|
|
1429
|
+
handleSelectValue(value2);
|
|
1430
|
+
},
|
|
1431
|
+
[handleSelectValue, onSelect]
|
|
1432
|
+
);
|
|
1433
|
+
const isSelected = selected(value);
|
|
1434
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
1435
|
+
CommandMenuItem,
|
|
1436
|
+
{
|
|
1437
|
+
ref,
|
|
1438
|
+
onSelect: handleSelect,
|
|
1439
|
+
"data-state": getSelectedState(isSelected),
|
|
1440
|
+
"aria-selected": isSelected,
|
|
1441
|
+
value,
|
|
1442
|
+
closeOnSelect,
|
|
1443
|
+
...rest,
|
|
1444
|
+
children
|
|
1445
|
+
}
|
|
1446
|
+
) });
|
|
1447
|
+
};
|
|
1448
|
+
const CommandMenuOverlay = memo((props) => {
|
|
1449
|
+
const { container, className, ...rest } = props;
|
|
1450
|
+
return /* @__PURE__ */ jsx(DialogPortal, { container, children: /* @__PURE__ */ jsx(DialogOverlay$1, { className: cx(className, commandMenuOverlayCva()), ...rest }) });
|
|
1451
|
+
});
|
|
1452
|
+
CommandMenuOverlay.displayName = "CommandMenuOverlay";
|
|
1453
|
+
const CommandMenuPage = (props) => {
|
|
1454
|
+
const { children, ref, page, ...rest } = props;
|
|
1455
|
+
const { page: activePage } = use(CommandMenuPageContext);
|
|
1456
|
+
const isActive = useMemo(() => page === activePage, [page, activePage]);
|
|
1457
|
+
return /* @__PURE__ */ jsx("div", { ref, "data-active": getActiveState(isActive), hidden: !isActive, ...rest, children: isActive ? children : null });
|
|
1458
|
+
};
|
|
1459
|
+
const CommandMenuPages = (props) => {
|
|
1460
|
+
const { children, defaultPage = "", page: controlledPage, onPageChange } = props;
|
|
1461
|
+
const [page, setPage] = useControlledState(defaultPage, controlledPage, onPageChange);
|
|
1462
|
+
return /* @__PURE__ */ jsx(CommandMenuPageContext, { value: { page, setPage }, children });
|
|
1463
|
+
};
|
|
1464
|
+
const CommandMenuPageTriggerItem = (props) => {
|
|
1465
|
+
const { ref, page, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1466
|
+
const { page: activePage, setPage } = use(CommandMenuPageContext);
|
|
1467
|
+
const isActive = useMemo(() => page === activePage, [page, activePage]);
|
|
1468
|
+
const handleSelect = useCallback(
|
|
1469
|
+
(value) => {
|
|
1470
|
+
onSelect == null ? void 0 : onSelect(value);
|
|
1471
|
+
setPage(page);
|
|
1472
|
+
},
|
|
1473
|
+
[onSelect, page, setPage]
|
|
1474
|
+
);
|
|
1475
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isActive, children: /* @__PURE__ */ jsx(
|
|
1476
|
+
CommandMenuItem,
|
|
1477
|
+
{
|
|
1478
|
+
ref,
|
|
1479
|
+
onSelect: handleSelect,
|
|
1480
|
+
"data-state": getActiveState(isActive),
|
|
1481
|
+
closeOnSelect,
|
|
1482
|
+
...rest
|
|
1483
|
+
}
|
|
1484
|
+
) });
|
|
1485
|
+
};
|
|
1486
|
+
const CommandMenuRadioGroup = (props) => {
|
|
1487
|
+
const { children, ref, defaultValue = null, value: controlledValue, onValueChange, ...rest } = props;
|
|
1488
|
+
const [value, setValue] = useControlledState(defaultValue, controlledValue, onValueChange);
|
|
1489
|
+
const selected = useCallback((v) => v === value, [value]);
|
|
1490
|
+
const selectValue = useCallback(
|
|
1491
|
+
(v) => {
|
|
1492
|
+
setValue(selected(v) ? null : v);
|
|
1493
|
+
},
|
|
1494
|
+
[selected, setValue]
|
|
1495
|
+
);
|
|
1496
|
+
const contextValue = useMemo(() => ({ selected, selectValue }), [selected, selectValue]);
|
|
1497
|
+
return /* @__PURE__ */ jsx(CommandMenuGroup, { ref, role: "radiogroup", ...rest, children: /* @__PURE__ */ jsx(SelectContext$1, { value: contextValue, children }) });
|
|
1498
|
+
};
|
|
1499
|
+
const CommandMenuRadioItem = (props) => {
|
|
1500
|
+
const { children, ref, value, onSelect, ...rest } = props;
|
|
1501
|
+
const { selected, selectValue } = use(SelectContext$1);
|
|
1502
|
+
const handleSelect = useCallback(
|
|
1503
|
+
(value2) => {
|
|
1504
|
+
onSelect == null ? void 0 : onSelect(value2);
|
|
1505
|
+
selectValue(value2);
|
|
1506
|
+
},
|
|
1507
|
+
[onSelect, selectValue]
|
|
1508
|
+
);
|
|
1509
|
+
const isSelected = selected(value);
|
|
1510
|
+
return /* @__PURE__ */ jsx(SelectedIndicatorContext$1, { value: isSelected, children: /* @__PURE__ */ jsx(
|
|
1511
|
+
CommandMenuItem,
|
|
1512
|
+
{
|
|
1513
|
+
ref,
|
|
1514
|
+
onSelect: handleSelect,
|
|
1515
|
+
"data-state": getSelectedState(isSelected),
|
|
1516
|
+
value,
|
|
1517
|
+
...rest,
|
|
1518
|
+
children
|
|
1519
|
+
}
|
|
1520
|
+
) });
|
|
1521
|
+
};
|
|
1522
|
+
const CommandMenuRoot = memo((props) => {
|
|
1523
|
+
const { children, defaultOpen, open: controlledOpen, onOpenChange } = props;
|
|
1524
|
+
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
1525
|
+
const contextValue = useMemo(() => {
|
|
1526
|
+
return {
|
|
1527
|
+
open,
|
|
1528
|
+
setOpen
|
|
1529
|
+
};
|
|
1530
|
+
}, [open, setOpen]);
|
|
1531
|
+
return /* @__PURE__ */ jsx(Dialog$1, { open, onOpenChange: setOpen, ...props, children: /* @__PURE__ */ jsx(CommandMenuDialogContext, { value: contextValue, children }) });
|
|
1532
|
+
});
|
|
1533
|
+
CommandMenuRoot.displayName = "CommandMenuRoot";
|
|
1534
|
+
const CommandMenuSelectAllItem = (props) => {
|
|
1535
|
+
const { ref, onSelect, closeOnSelect = false, ...rest } = props;
|
|
1536
|
+
const { itemValueMapping, values, setValues } = use(MultiSelectGroupContext);
|
|
1537
|
+
const selectedState = useMemo(() => {
|
|
1538
|
+
const allValues = Array.from(itemValueMapping.values());
|
|
1539
|
+
if (allValues.every((value) => values.includes(value))) return true;
|
|
1540
|
+
if (allValues.some((value) => values.includes(value))) return "indeterminate";
|
|
1541
|
+
return false;
|
|
1542
|
+
}, [itemValueMapping, values]);
|
|
1543
|
+
const handleSelect = useCallback(
|
|
1544
|
+
(value) => {
|
|
1545
|
+
onSelect == null ? void 0 : onSelect(value);
|
|
1546
|
+
setValues(selectedState !== true ? Array.from(itemValueMapping.values()) : []);
|
|
1547
|
+
},
|
|
1548
|
+
[itemValueMapping, onSelect, selectedState, setValues]
|
|
1549
|
+
);
|
|
1550
|
+
return /* @__PURE__ */ jsx(CheckboxIndicatorContext, { value: selectedState, children: /* @__PURE__ */ jsx(
|
|
1551
|
+
CommandMenuItem,
|
|
1552
|
+
{
|
|
1553
|
+
ref,
|
|
1554
|
+
role: "menuitemcheckbox",
|
|
1555
|
+
onSelect: handleSelect,
|
|
1556
|
+
"data-state": getCheckedState(selectedState),
|
|
1557
|
+
closeOnSelect,
|
|
1558
|
+
...rest
|
|
1559
|
+
}
|
|
1560
|
+
) });
|
|
1561
|
+
};
|
|
1562
|
+
const CommandMenuSelectedIndicator = (props) => {
|
|
1563
|
+
const { ref, alwaysRender = false, children, ...rest } = props;
|
|
1564
|
+
const isSelected = use(SelectedIndicatorContext$1);
|
|
1565
|
+
const computedChildren = useMemo(() => {
|
|
1566
|
+
return typeof children === "function" ? children(isSelected) : children;
|
|
1567
|
+
}, [isSelected, children]);
|
|
1568
|
+
const render = alwaysRender || isSelected;
|
|
1569
|
+
if (!render) return null;
|
|
1570
|
+
return /* @__PURE__ */ jsx("span", { ref, "data-state": getSelectedState(isSelected), className: "inline-block size-max", ...rest, children: computedChildren });
|
|
1571
|
+
};
|
|
1572
|
+
const CommandMenuSeparator = memo((props) => {
|
|
1573
|
+
const { className, ref, spacing = false, ...rest } = props;
|
|
1574
|
+
const { size: size2 } = use(CommandMenuContext);
|
|
1575
|
+
return /* @__PURE__ */ jsx(CommandSeparator, { ref, className: cx(className, commandMenuSeparatorCva({ size: size2, spacing })), ...rest });
|
|
1576
|
+
});
|
|
1577
|
+
CommandMenuSeparator.displayName = "CommandMenuSeparator";
|
|
1578
|
+
const CommandMenuTrigger = memo((props) => {
|
|
1579
|
+
return /* @__PURE__ */ jsx(DialogTrigger, { ...props });
|
|
1580
|
+
});
|
|
1581
|
+
CommandMenuTrigger.displayName = "CommandMenuTrigger";
|
|
1582
|
+
const CommandMenu = {
|
|
1583
|
+
Root: CommandMenuRoot,
|
|
1584
|
+
Overlay: CommandMenuOverlay,
|
|
1585
|
+
Content: CommandMenuContent,
|
|
1586
|
+
Trigger: CommandMenuTrigger,
|
|
1587
|
+
Input: CommandMenuInput,
|
|
1588
|
+
List: CommandMenuList,
|
|
1589
|
+
Group: CommandMenuGroup,
|
|
1590
|
+
Item: CommandMenuItem,
|
|
1591
|
+
Separator: CommandMenuSeparator,
|
|
1592
|
+
Empty: CommandMenuEmpty,
|
|
1593
|
+
// Multi select
|
|
1594
|
+
MultiSelectGroup: CommandMenuMultiSelectGroup,
|
|
1595
|
+
MultiSelectItem: CommandMenuMultiSelectItem,
|
|
1596
|
+
SelectAllItem: CommandMenuSelectAllItem,
|
|
1597
|
+
SelectedIndicator: CommandMenuSelectedIndicator,
|
|
1598
|
+
// Radio / single select
|
|
1599
|
+
RadioGroup: CommandMenuRadioGroup,
|
|
1600
|
+
RadioItem: CommandMenuRadioItem,
|
|
1601
|
+
// Checkbox
|
|
1602
|
+
CheckboxItem: CommandMenuCheckboxItem,
|
|
1603
|
+
CheckboxIndicator: CommandMenuCheckboxIndicator,
|
|
1604
|
+
// Pages
|
|
1605
|
+
Pages: CommandMenuPages,
|
|
1606
|
+
Page: CommandMenuPage,
|
|
1607
|
+
PageTriggerItem: CommandMenuPageTriggerItem
|
|
1608
|
+
};
|
|
1021
1609
|
const Chevron = (props) => {
|
|
1022
1610
|
const { orientation, ...rest } = props;
|
|
1023
1611
|
switch (orientation) {
|
|
@@ -2186,11 +2774,7 @@ const MenuRoot = (props) => {
|
|
|
2186
2774
|
onOpenChange,
|
|
2187
2775
|
defaultOpen
|
|
2188
2776
|
} = props;
|
|
2189
|
-
const [open, setOpen] = useControlledState(
|
|
2190
|
-
state: controlledOpen,
|
|
2191
|
-
initialState: defaultOpen ?? false,
|
|
2192
|
-
setState: onOpenChange
|
|
2193
|
-
});
|
|
2777
|
+
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
2194
2778
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
2195
2779
|
const [triggerType, setTriggerType] = useState(null);
|
|
2196
2780
|
const elementsRef = useRef([]);
|
|
@@ -2403,11 +2987,7 @@ const MenuSub = (props) => {
|
|
|
2403
2987
|
onOpenChange,
|
|
2404
2988
|
defaultOpen
|
|
2405
2989
|
} = props;
|
|
2406
|
-
const [open, setOpen] = useControlledState(
|
|
2407
|
-
initialState: defaultOpen ?? false,
|
|
2408
|
-
state: controlledOpen,
|
|
2409
|
-
setState: onOpenChange
|
|
2410
|
-
});
|
|
2990
|
+
const [open, setOpen] = useControlledState(defaultOpen ?? false, controlledOpen, onOpenChange);
|
|
2411
2991
|
const nodeId = useFloatingNodeId();
|
|
2412
2992
|
const { refs, floatingStyles, context } = useFloating({
|
|
2413
2993
|
nodeId,
|
|
@@ -2787,11 +3367,7 @@ const PagesContext = createContext({});
|
|
|
2787
3367
|
const usePagesContext = () => useContext(PagesContext);
|
|
2788
3368
|
const MenuPages = (props) => {
|
|
2789
3369
|
const { children, defaultPage, page, onPageChange } = props;
|
|
2790
|
-
const [activePage, setActivePage] = useControlledState(
|
|
2791
|
-
state: page,
|
|
2792
|
-
initialState: defaultPage ?? "",
|
|
2793
|
-
setState: onPageChange
|
|
2794
|
-
});
|
|
3370
|
+
const [activePage, setActivePage] = useControlledState(defaultPage ?? "", page, onPageChange);
|
|
2795
3371
|
return /* @__PURE__ */ jsx(PagesContext.Provider, { value: { activePage, setActivePage }, children });
|
|
2796
3372
|
};
|
|
2797
3373
|
const MenuPageContent = (props) => {
|
|
@@ -4370,6 +4946,28 @@ export {
|
|
|
4370
4946
|
CheckboxIndicator,
|
|
4371
4947
|
CheckboxRoot,
|
|
4372
4948
|
CollapsibleTree,
|
|
4949
|
+
CommandMenu,
|
|
4950
|
+
CommandMenuCheckboxIndicator,
|
|
4951
|
+
CommandMenuCheckboxItem,
|
|
4952
|
+
CommandMenuContent,
|
|
4953
|
+
CommandMenuEmpty,
|
|
4954
|
+
CommandMenuGroup,
|
|
4955
|
+
CommandMenuInput,
|
|
4956
|
+
CommandMenuItem,
|
|
4957
|
+
CommandMenuList,
|
|
4958
|
+
CommandMenuMultiSelectGroup,
|
|
4959
|
+
CommandMenuMultiSelectItem,
|
|
4960
|
+
CommandMenuOverlay,
|
|
4961
|
+
CommandMenuPage,
|
|
4962
|
+
CommandMenuPageTriggerItem,
|
|
4963
|
+
CommandMenuPages,
|
|
4964
|
+
CommandMenuRadioGroup,
|
|
4965
|
+
CommandMenuRadioItem,
|
|
4966
|
+
CommandMenuRoot,
|
|
4967
|
+
CommandMenuSelectAllItem,
|
|
4968
|
+
CommandMenuSelectedIndicator,
|
|
4969
|
+
CommandMenuSeparator,
|
|
4970
|
+
CommandMenuTrigger,
|
|
4373
4971
|
DayPicker,
|
|
4374
4972
|
Dialog,
|
|
4375
4973
|
DialogContent,
|