@dxos/react-ui 0.8.2-main.f11618f → 0.8.2-staging.7ac8446

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.
@@ -200,18 +200,17 @@ var DxAvatar = createComponent({
200
200
  elementClass: NaturalDxAvatar,
201
201
  react: React3
202
202
  });
203
- var AvatarContent = /* @__PURE__ */ forwardRef2(({ icon, classNames, ...props }, forwardedRef) => {
203
+ var AvatarContent = ({ icon, classNames, ...props }) => {
204
204
  const href = useIconHref(icon);
205
205
  const { labelId, descriptionId } = useAvatarContext("AvatarContent");
206
206
  return /* @__PURE__ */ React3.createElement(DxAvatar, {
207
207
  ...props,
208
208
  icon: href,
209
- "aria-labelledby": labelId,
209
+ labelId,
210
210
  "aria-describedby": descriptionId,
211
- rootClassName: mx(classNames),
212
- ref: forwardedRef
211
+ rootClassName: mx(classNames)
213
212
  });
214
- });
213
+ };
215
214
  var AvatarLabel = /* @__PURE__ */ forwardRef2(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
216
215
  const Root5 = asChild ? Slot2 : Primitive2.span;
217
216
  const { tx } = useThemeContext();
@@ -791,7 +790,6 @@ var DialogContent = /* @__PURE__ */ forwardRef11(({ classNames, children, inOver
791
790
  const { tx } = useThemeContext();
792
791
  const { inOverlayLayout } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
793
792
  return /* @__PURE__ */ React17.createElement(DialogContentPrimitive, {
794
- "aria-describedby": void 0,
795
793
  ...props,
796
794
  className: tx("dialog.content", "dialog", {
797
795
  inOverlayLayout: propsInOverlayLayout || inOverlayLayout
@@ -883,1310 +881,1310 @@ var AlertDialog = {
883
881
  Action: AlertDialogAction
884
882
  };
885
883
 
886
- // packages/ui/react-ui/src/components/Input/Input.tsx
887
- import { Root as CheckboxPrimitive } from "@radix-ui/react-checkbox";
888
- import { useControllableState } from "@radix-ui/react-use-controllable-state";
889
- import React19, { forwardRef as forwardRef13, useCallback as useCallback4 } from "react";
890
- import { InputRoot, PinInput as PinInputPrimitive, TextInput as TextInputPrimitive, TextArea as TextAreaPrimitive, useInputContext, INPUT_NAME, Description as DescriptionPrimitive, DescriptionAndValidation as DescriptionAndValidationPrimitive, Label as LabelPrimitive, Validation as ValidationPrimitive } from "@dxos/react-input";
891
- import { mx as mx3 } from "@dxos/react-ui-theme";
892
- var Label = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
884
+ // packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
885
+ import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
886
+ import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
887
+ import { Slot as Slot6 } from "@radix-ui/react-slot";
888
+ import React19, { forwardRef as forwardRef13 } from "react";
889
+ var ContextMenuRoot = ContextMenuPrimitive.ContextMenu;
890
+ var ContextMenuTrigger = ContextMenuPrimitive.Trigger;
891
+ var ContextMenuPortal = ContextMenuPrimitive.Portal;
892
+ var ContextMenuContent = /* @__PURE__ */ forwardRef13(({ classNames, children, collisionPadding = 8, ...props }, forwardedRef) => {
893
893
  const { tx } = useThemeContext();
894
- return /* @__PURE__ */ React19.createElement(LabelPrimitive, {
894
+ const elevation = useElevationContext();
895
+ const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
896
+ return /* @__PURE__ */ React19.createElement(ContextMenuPrimitive.Content, {
895
897
  ...props,
896
- className: tx("input.label", "input__label", {
897
- srOnly
898
+ collisionPadding: safeCollisionPadding,
899
+ className: tx("menu.content", "menu", {
900
+ elevation
898
901
  }, classNames),
899
902
  ref: forwardedRef
900
903
  }, children);
901
904
  });
902
- var Description = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
905
+ var ContextMenuViewport = /* @__PURE__ */ forwardRef13(({ classNames, asChild, children, ...props }, forwardedRef) => {
903
906
  const { tx } = useThemeContext();
904
- return /* @__PURE__ */ React19.createElement(DescriptionPrimitive, {
907
+ const Root5 = asChild ? Slot6 : Primitive6.div;
908
+ return /* @__PURE__ */ React19.createElement(Root5, {
905
909
  ...props,
906
- className: tx("input.description", "input__description", {
907
- srOnly
908
- }, classNames),
910
+ className: tx("menu.viewport", "menu__viewport", {}, classNames),
909
911
  ref: forwardedRef
910
912
  }, children);
911
913
  });
912
- var Validation = /* @__PURE__ */ forwardRef13(({ __inputScope, srOnly, classNames, children, ...props }, forwardedRef) => {
914
+ var ContextMenuArrow = /* @__PURE__ */ forwardRef13(({ classNames, ...props }, forwardedRef) => {
913
915
  const { tx } = useThemeContext();
914
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
915
- return /* @__PURE__ */ React19.createElement(ValidationPrimitive, {
916
+ return /* @__PURE__ */ React19.createElement(ContextMenuPrimitive.Arrow, {
916
917
  ...props,
917
- className: tx("input.validation", `input__validation-message input__validation-message--${validationValence}`, {
918
- srOnly,
919
- validationValence
920
- }, classNames),
918
+ className: tx("menu.arrow", "menu__arrow", {}, classNames),
921
919
  ref: forwardedRef
922
- }, children);
920
+ });
923
921
  });
924
- var DescriptionAndValidation = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
922
+ var ContextMenuGroup = ContextMenuPrimitive.Group;
923
+ var ContextMenuItemIndicator = ContextMenuPrimitive.ItemIndicator;
924
+ var ContextMenuItem = /* @__PURE__ */ forwardRef13(({ classNames, ...props }, forwardedRef) => {
925
925
  const { tx } = useThemeContext();
926
- return /* @__PURE__ */ React19.createElement(DescriptionAndValidationPrimitive, {
926
+ return /* @__PURE__ */ React19.createElement(ContextMenuPrimitive.Item, {
927
927
  ...props,
928
- className: tx("input.descriptionAndValidation", "input__description-and-validation", {
929
- srOnly
930
- }, classNames),
928
+ className: tx("menu.item", "menu__item", {}, classNames),
931
929
  ref: forwardedRef
932
- }, children);
930
+ });
933
931
  });
934
- var PinInput = /* @__PURE__ */ forwardRef13(({ density: propsDensity, elevation: propsElevation, segmentClassName: propsSegmentClassName, inputClassName, variant, ...props }, forwardedRef) => {
935
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
932
+ var ContextMenuCheckboxItem = /* @__PURE__ */ forwardRef13(({ classNames, ...props }, forwardedRef) => {
936
933
  const { tx } = useThemeContext();
937
- const density = useDensityContext(propsDensity);
938
- const elevation = useElevationContext(propsElevation);
939
- const segmentClassName = useCallback4(({ focused, validationValence }) => tx("input.input", "input--pin-segment", {
940
- variant: "static",
941
- focused,
942
- disabled: props.disabled,
943
- density,
944
- elevation,
945
- validationValence
946
- }, propsSegmentClassName), [
947
- tx,
948
- props.disabled,
949
- elevation,
950
- propsElevation,
951
- density
952
- ]);
953
- return /* @__PURE__ */ React19.createElement(PinInputPrimitive, {
934
+ return /* @__PURE__ */ React19.createElement(ContextMenuPrimitive.CheckboxItem, {
954
935
  ...props,
955
- segmentClassName,
956
- ...props.autoFocus && !hasIosKeyboard2 && {
957
- autoFocus: true
958
- },
959
- inputClassName: tx("input.inputWithSegments", "input input--pin", {
960
- disabled: props.disabled
961
- }, inputClassName),
936
+ className: tx("menu.item", "menu__item--checkbox", {}, classNames),
962
937
  ref: forwardedRef
963
938
  });
964
939
  });
965
- var TextInput = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
966
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
967
- const themeContextValue = useThemeContext();
968
- const density = useDensityContext(propsDensity);
969
- const elevation = useElevationContext(propsElevation);
970
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
971
- const { tx } = themeContextValue;
972
- return /* @__PURE__ */ React19.createElement(TextInputPrimitive, {
940
+ var ContextMenuSeparator = /* @__PURE__ */ forwardRef13(({ classNames, ...props }, forwardedRef) => {
941
+ const { tx } = useThemeContext();
942
+ return /* @__PURE__ */ React19.createElement(ContextMenuPrimitive.Separator, {
973
943
  ...props,
974
- className: tx("input.input", "input", {
975
- variant,
976
- disabled: props.disabled,
977
- density,
978
- elevation,
979
- validationValence
980
- }, classNames),
981
- ...props.autoFocus && !hasIosKeyboard2 && {
982
- autoFocus: true
983
- },
944
+ className: tx("menu.separator", "menu__item", {}, classNames),
984
945
  ref: forwardedRef
985
946
  });
986
947
  });
987
- var TextArea = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
988
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
948
+ var ContextMenuGroupLabel = /* @__PURE__ */ forwardRef13(({ classNames, ...props }, forwardedRef) => {
989
949
  const { tx } = useThemeContext();
990
- const density = useDensityContext(propsDensity);
991
- const elevation = useElevationContext(propsElevation);
992
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
993
- return /* @__PURE__ */ React19.createElement(TextAreaPrimitive, {
950
+ return /* @__PURE__ */ React19.createElement(ContextMenuPrimitive.Label, {
994
951
  ...props,
995
- className: tx("input.input", "input--text-area", {
996
- variant,
997
- disabled: props.disabled,
998
- density,
999
- elevation,
1000
- validationValence
1001
- }, classNames),
1002
- ...props.autoFocus && !hasIosKeyboard2 && {
1003
- autoFocus: true
1004
- },
952
+ className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
1005
953
  ref: forwardedRef
1006
954
  });
1007
955
  });
1008
- var Checkbox = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, size, weight = "bold", classNames, ...props }, forwardedRef) => {
1009
- const [checked, onCheckedChange] = useControllableState({
1010
- prop: propsChecked,
1011
- defaultProp: propsDefaultChecked,
1012
- onChange: propsOnCheckedChange
956
+ var ContextMenu2 = {
957
+ Root: ContextMenuRoot,
958
+ Trigger: ContextMenuTrigger,
959
+ Portal: ContextMenuPortal,
960
+ Content: ContextMenuContent,
961
+ Viewport: ContextMenuViewport,
962
+ Arrow: ContextMenuArrow,
963
+ Group: ContextMenuGroup,
964
+ Item: ContextMenuItem,
965
+ CheckboxItem: ContextMenuCheckboxItem,
966
+ ItemIndicator: ContextMenuItemIndicator,
967
+ Separator: ContextMenuSeparator,
968
+ GroupLabel: ContextMenuGroupLabel
969
+ };
970
+
971
+ // packages/ui/react-ui/src/components/Menus/DropdownMenu.tsx
972
+ import { composeEventHandlers } from "@radix-ui/primitive";
973
+ import { composeRefs } from "@radix-ui/react-compose-refs";
974
+ import { createContextScope } from "@radix-ui/react-context";
975
+ import { useId as useId2 } from "@radix-ui/react-id";
976
+ import * as MenuPrimitive from "@radix-ui/react-menu";
977
+ import { createMenuScope } from "@radix-ui/react-menu";
978
+ import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
979
+ import { Slot as Slot7 } from "@radix-ui/react-slot";
980
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
981
+ import React20, { useRef, useCallback as useCallback4, forwardRef as forwardRef14, useEffect as useEffect3 } from "react";
982
+ var DROPDOWN_MENU_NAME = "DropdownMenu";
983
+ var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(DROPDOWN_MENU_NAME, [
984
+ createMenuScope
985
+ ]);
986
+ var useMenuScope = createMenuScope();
987
+ var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
988
+ var DropdownMenuRoot = (props) => {
989
+ const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
990
+ const menuScope = useMenuScope(__scopeDropdownMenu);
991
+ const triggerRef = useRef(null);
992
+ const [open = false, setOpen] = useControllableState({
993
+ prop: openProp,
994
+ defaultProp: defaultOpen,
995
+ onChange: onOpenChange
1013
996
  });
1014
- const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1015
- const { tx } = useThemeContext();
1016
- return /* @__PURE__ */ React19.createElement(CheckboxPrimitive, {
1017
- ...props,
1018
- checked,
1019
- onCheckedChange,
1020
- id,
1021
- "aria-describedby": descriptionId,
1022
- ...validationValence === "error" && {
1023
- "aria-invalid": "true",
1024
- "aria-errormessage": errorMessageId
1025
- },
1026
- className: tx("input.checkbox", "input--checkbox", {
1027
- size
1028
- }, "shrink-0", classNames),
1029
- ref: forwardedRef
1030
- }, /* @__PURE__ */ React19.createElement(Icon, {
1031
- icon: checked === "indeterminate" ? "ph--minus--regular" : "ph--check--regular",
1032
- classNames: tx("input.checkboxIndicator", "input--checkbox__indicator", {
1033
- size,
1034
- checked
997
+ return /* @__PURE__ */ React20.createElement(DropdownMenuProvider, {
998
+ scope: __scopeDropdownMenu,
999
+ triggerId: useId2(),
1000
+ triggerRef,
1001
+ contentId: useId2(),
1002
+ open,
1003
+ onOpenChange: setOpen,
1004
+ onOpenToggle: useCallback4(() => setOpen((prevOpen) => !prevOpen), [
1005
+ setOpen
1006
+ ]),
1007
+ modal
1008
+ }, /* @__PURE__ */ React20.createElement(MenuPrimitive.Root, {
1009
+ ...menuScope,
1010
+ open,
1011
+ onOpenChange: setOpen,
1012
+ dir,
1013
+ modal
1014
+ }, children));
1015
+ };
1016
+ DropdownMenuRoot.displayName = DROPDOWN_MENU_NAME;
1017
+ var TRIGGER_NAME = "DropdownMenuTrigger";
1018
+ var DropdownMenuTrigger = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1019
+ const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
1020
+ const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
1021
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1022
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Anchor, {
1023
+ asChild: true,
1024
+ ...menuScope
1025
+ }, /* @__PURE__ */ React20.createElement(Primitive7.button, {
1026
+ type: "button",
1027
+ id: context.triggerId,
1028
+ "aria-haspopup": "menu",
1029
+ "aria-expanded": context.open,
1030
+ "aria-controls": context.open ? context.contentId : void 0,
1031
+ "data-state": context.open ? "open" : "closed",
1032
+ "data-disabled": disabled ? "" : void 0,
1033
+ disabled,
1034
+ ...triggerProps,
1035
+ ref: composeRefs(forwardedRef, context.triggerRef),
1036
+ onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
1037
+ if (!disabled && event.button === 0 && event.ctrlKey === false) {
1038
+ context.onOpenToggle();
1039
+ if (!context.open) {
1040
+ event.preventDefault();
1041
+ }
1042
+ }
1043
+ }),
1044
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
1045
+ if (disabled) {
1046
+ return;
1047
+ }
1048
+ if ([
1049
+ "Enter",
1050
+ " "
1051
+ ].includes(event.key)) {
1052
+ context.onOpenToggle();
1053
+ }
1054
+ if (event.key === "ArrowDown") {
1055
+ context.onOpenChange(true);
1056
+ }
1057
+ if ([
1058
+ "Enter",
1059
+ " ",
1060
+ "ArrowDown"
1061
+ ].includes(event.key)) {
1062
+ event.preventDefault();
1063
+ }
1035
1064
  })
1036
1065
  }));
1037
1066
  });
1038
- var Switch = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, classNames, ...props }, forwardedRef) => {
1039
- const [checked, onCheckedChange] = useControllableState({
1040
- prop: propsChecked,
1041
- defaultProp: propsDefaultChecked ?? false,
1042
- onChange: propsOnCheckedChange
1067
+ DropdownMenuTrigger.displayName = TRIGGER_NAME;
1068
+ var VIRTUAL_TRIGGER_NAME = "DropdownMenuVirtualTrigger";
1069
+ var DropdownMenuVirtualTrigger = (props) => {
1070
+ const { __scopeDropdownMenu, virtualRef } = props;
1071
+ const context = useDropdownMenuContext(VIRTUAL_TRIGGER_NAME, __scopeDropdownMenu);
1072
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1073
+ useEffect3(() => {
1074
+ if (virtualRef.current) {
1075
+ context.triggerRef.current = virtualRef.current;
1076
+ }
1043
1077
  });
1044
- const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1045
- return /* @__PURE__ */ React19.createElement("input", {
1046
- type: "checkbox",
1047
- className: mx3("dx-checkbox--switch dx-focus-ring", classNames),
1048
- checked,
1049
- onChange: (event) => {
1050
- onCheckedChange(event.target.checked);
1051
- },
1052
- id,
1053
- "aria-describedby": descriptionId,
1054
- ...props,
1055
- ...validationValence === "error" && {
1056
- "aria-invalid": "true",
1057
- "aria-errormessage": errorMessageId
1058
- },
1059
- ref: forwardedRef
1078
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Anchor, {
1079
+ ...menuScope,
1080
+ virtualRef
1060
1081
  });
1061
- });
1062
- var Input = {
1063
- Root: InputRoot,
1064
- PinInput,
1065
- TextInput,
1066
- TextArea,
1067
- Checkbox,
1068
- Switch,
1069
- Label,
1070
- Description,
1071
- Validation,
1072
- DescriptionAndValidation
1073
- };
1074
-
1075
- // packages/ui/react-ui/src/components/Lists/List.tsx
1076
- import { CaretDown, CaretRight } from "@phosphor-icons/react";
1077
- import { Slot as Slot6 } from "@radix-ui/react-slot";
1078
- import React21, { forwardRef as forwardRef14 } from "react";
1079
- import { List as ListPrimitive, ListItemHeading as ListPrimitiveItemHeading, ListItemOpenTrigger as ListPrimitiveItemOpenTrigger, ListItemCollapsibleContent, ListItem as ListPrimitiveItem, LIST_NAME, LIST_ITEM_NAME, useListContext, useListItemContext } from "@dxos/react-list";
1080
-
1081
- // packages/ui/react-ui/src/components/Lists/ListDropIndicator.tsx
1082
- import React20 from "react";
1083
- var edgeToOrientationMap = {
1084
- top: "horizontal",
1085
- bottom: "horizontal",
1086
- left: "vertical",
1087
- right: "vertical"
1088
- };
1089
- var orientationStyles = {
1090
- horizontal: "h-[--line-thickness] left-[calc(var(--line-inset)+var(--terminal-radius))] right-[--line-inset] before:left-[--terminal-inset]",
1091
- vertical: "w-[--line-thickness] top-[calc(var(--line-inset)+var(--terminal-radius))] bottom-[--line-inset] before:top-[--terminal-inset]"
1092
- };
1093
- var edgeStyles = {
1094
- top: "top-[--line-offset] before:top-[--offset-terminal]",
1095
- right: "right-[--line-offset] before:right-[--offset-terminal]",
1096
- bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
1097
- left: "left-[--line-offset] before:left-[--offset-terminal]"
1098
1082
  };
1099
- var strokeSize = 2;
1100
- var terminalSize = 8;
1101
- var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
1102
- var ListDropIndicator = ({ edge, gap = 0, lineInset = 0, terminalInset = lineInset - terminalSize }) => {
1103
- const orientation = edgeToOrientationMap[edge];
1104
- return /* @__PURE__ */ React20.createElement("div", {
1105
- role: "none",
1106
- style: {
1107
- "--line-thickness": `${strokeSize}px`,
1108
- "--line-offset": `calc(-0.5 * (${gap}px + ${strokeSize}px))`,
1109
- "--line-inset": `${lineInset}px`,
1110
- "--terminal-size": `${terminalSize}px`,
1111
- "--terminal-radius": `${terminalSize / 2}px`,
1112
- "--terminal-inset": `${terminalInset}px`,
1113
- "--offset-terminal": `${offsetToAlignTerminalWithLine}px`
1114
- },
1115
- className: `absolute z-10 pointer-events-none bg-accentSurface before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full ${orientationStyles[orientation]} ${edgeStyles[edge]}`
1083
+ DropdownMenuVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME;
1084
+ var PORTAL_NAME = "DropdownMenuPortal";
1085
+ var DropdownMenuPortal = (props) => {
1086
+ const { __scopeDropdownMenu, ...portalProps } = props;
1087
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1088
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Portal, {
1089
+ ...menuScope,
1090
+ ...portalProps
1116
1091
  });
1117
1092
  };
1118
-
1119
- // packages/ui/react-ui/src/components/Lists/List.tsx
1120
- var List = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, forwardedRef) => {
1093
+ DropdownMenuPortal.displayName = PORTAL_NAME;
1094
+ var DropdownMenuViewport = /* @__PURE__ */ forwardRef14(({ classNames, asChild, children, ...props }, forwardedRef) => {
1121
1095
  const { tx } = useThemeContext();
1122
- const density = useDensityContext(props.density);
1123
- return /* @__PURE__ */ React21.createElement(DensityProvider, {
1124
- density
1125
- }, /* @__PURE__ */ React21.createElement(ListPrimitive, {
1096
+ const Root5 = asChild ? Slot7 : Primitive7.div;
1097
+ return /* @__PURE__ */ React20.createElement(Root5, {
1126
1098
  ...props,
1127
- className: tx("list.root", "list", {}, classNames),
1099
+ className: tx("menu.viewport", "menu__viewport", {}, classNames),
1128
1100
  ref: forwardedRef
1129
- }, children));
1101
+ }, children);
1130
1102
  });
1131
- var ListItemEndcap = /* @__PURE__ */ forwardRef14(({ children, classNames, asChild, ...props }, forwardedRef) => {
1132
- const Root5 = asChild ? Slot6 : "div";
1133
- const density = useDensityContext();
1103
+ var CONTENT_NAME = "DropdownMenuContent";
1104
+ var DropdownMenuContent = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1105
+ const { __scopeDropdownMenu, classNames, collisionPadding = 8, ...contentProps } = props;
1134
1106
  const { tx } = useThemeContext();
1135
- return /* @__PURE__ */ React21.createElement(Root5, {
1136
- ...!asChild && {
1137
- role: "none"
1138
- },
1139
- ...props,
1140
- className: tx("list.item.endcap", "list__listItem__endcap", {
1141
- density
1107
+ const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
1108
+ const elevation = useElevationContext();
1109
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1110
+ const hasInteractedOutsideRef = useRef(false);
1111
+ const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
1112
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Content, {
1113
+ id: context.contentId,
1114
+ "aria-labelledby": context.triggerId,
1115
+ ...menuScope,
1116
+ ...contentProps,
1117
+ collisionPadding: safeCollisionPadding,
1118
+ ref: forwardedRef,
1119
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
1120
+ if (!hasInteractedOutsideRef.current) {
1121
+ context.triggerRef.current?.focus();
1122
+ }
1123
+ hasInteractedOutsideRef.current = false;
1124
+ event.preventDefault();
1125
+ }),
1126
+ onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
1127
+ const originalEvent = event.detail.originalEvent;
1128
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
1129
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
1130
+ if (!context.modal || isRightClick) {
1131
+ hasInteractedOutsideRef.current = true;
1132
+ }
1133
+ }),
1134
+ className: tx("menu.content", "menu", {
1135
+ elevation
1142
1136
  }, classNames),
1143
- ref: forwardedRef
1144
- }, children);
1137
+ style: {
1138
+ ...props.style,
1139
+ // re-namespace exposed content custom properties
1140
+ ...{
1141
+ "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
1142
+ "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
1143
+ "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
1144
+ "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
1145
+ "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
1146
+ }
1147
+ }
1148
+ });
1145
1149
  });
1146
- var MockListItemOpenTrigger = ({ classNames, ...props }) => {
1147
- const density = useDensityContext();
1148
- const { tx } = useThemeContext();
1149
- return /* @__PURE__ */ React21.createElement("div", {
1150
- role: "none",
1151
- ...props,
1152
- className: tx("list.item.openTrigger", "list__listItem__openTrigger--mock", {
1153
- density
1154
- }, classNames)
1150
+ DropdownMenuContent.displayName = CONTENT_NAME;
1151
+ var GROUP_NAME = "DropdownMenuGroup";
1152
+ var DropdownMenuGroup = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1153
+ const { __scopeDropdownMenu, ...groupProps } = props;
1154
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1155
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Group, {
1156
+ ...menuScope,
1157
+ ...groupProps,
1158
+ ref: forwardedRef
1155
1159
  });
1156
- };
1157
- var ListItemHeading = /* @__PURE__ */ forwardRef14(({ children, classNames, ...props }, forwardedRef) => {
1160
+ });
1161
+ DropdownMenuGroup.displayName = GROUP_NAME;
1162
+ var LABEL_NAME = "DropdownMenuLabel";
1163
+ var DropdownMenuGroupLabel = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1164
+ const { __scopeDropdownMenu, classNames, ...labelProps } = props;
1165
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1158
1166
  const { tx } = useThemeContext();
1159
- const density = useDensityContext();
1160
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItemHeading, {
1161
- ...props,
1162
- className: tx("list.item.heading", "list__listItem__heading", {
1163
- density
1164
- }, classNames),
1167
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Label, {
1168
+ ...menuScope,
1169
+ ...labelProps,
1170
+ className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
1165
1171
  ref: forwardedRef
1166
- }, children);
1172
+ });
1167
1173
  });
1168
- var ListItemOpenTrigger = /* @__PURE__ */ forwardRef14(({ __listItemScope, classNames, children, ...props }, forwardedRef) => {
1174
+ DropdownMenuGroupLabel.displayName = LABEL_NAME;
1175
+ var ITEM_NAME = "DropdownMenuItem";
1176
+ var DropdownMenuItem = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1177
+ const { __scopeDropdownMenu, classNames, ...itemProps } = props;
1178
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1169
1179
  const { tx } = useThemeContext();
1170
- const density = useDensityContext();
1171
- const { open } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
1172
- const Icon3 = open ? CaretDown : CaretRight;
1173
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItemOpenTrigger, {
1174
- ...props,
1175
- className: tx("list.item.openTrigger", "list__listItem__openTrigger", {
1176
- density
1177
- }, classNames),
1180
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Item, {
1181
+ ...menuScope,
1182
+ ...itemProps,
1183
+ className: tx("menu.item", "menu__item", {}, classNames),
1178
1184
  ref: forwardedRef
1179
- }, children || /* @__PURE__ */ React21.createElement(Icon3, {
1180
- weight: "bold",
1181
- className: tx("list.item.openTriggerIcon", "list__listItem__openTrigger__icon", {})
1182
- }));
1185
+ });
1183
1186
  });
1184
- var ListItemRoot = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, forwardedRef) => {
1187
+ DropdownMenuItem.displayName = ITEM_NAME;
1188
+ var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
1189
+ var DropdownMenuCheckboxItem = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1190
+ const { __scopeDropdownMenu, classNames, ...checkboxItemProps } = props;
1191
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1185
1192
  const { tx } = useThemeContext();
1186
- const density = useDensityContext();
1187
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItem, {
1188
- ...props,
1189
- className: tx("list.item.root", "list__listItem", {
1190
- density,
1191
- collapsible: props.collapsible
1192
- }, classNames),
1193
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.CheckboxItem, {
1194
+ ...menuScope,
1195
+ ...checkboxItemProps,
1196
+ className: tx("menu.item", "menu__item--checkbox", {}, classNames),
1193
1197
  ref: forwardedRef
1194
- }, children);
1195
- });
1196
- var ListItem = {
1197
- Root: ListItemRoot,
1198
- Endcap: ListItemEndcap,
1199
- Heading: ListItemHeading,
1200
- OpenTrigger: ListItemOpenTrigger,
1201
- CollapsibleContent: ListItemCollapsibleContent,
1202
- MockOpenTrigger: MockListItemOpenTrigger,
1203
- DropIndicator: ListDropIndicator
1204
- };
1205
-
1206
- // packages/ui/react-ui/src/components/Lists/Tree.tsx
1207
- import React23, { forwardRef as forwardRef15 } from "react";
1208
-
1209
- // packages/ui/react-ui/src/components/Lists/TreeDropIndicator.tsx
1210
- import React22 from "react";
1211
- var edgeToOrientationMap2 = {
1212
- "reorder-above": "sibling",
1213
- "reorder-below": "sibling",
1214
- "make-child": "child",
1215
- reparent: "child"
1216
- };
1217
- var orientationStyles2 = {
1218
- // TODO(wittjosiah): Stop using left/right here.
1219
- sibling: "bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]",
1220
- child: "is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible"
1221
- };
1222
- var instructionStyles = {
1223
- "reorder-above": "block-start-[--line-offset] before:block-start-[--offset-terminal]",
1224
- "reorder-below": "block-end-[--line-offset] before:block-end-[--offset-terminal]",
1225
- "make-child": "border-accentSurface",
1226
- // TODO(wittjosiah): This is not occurring in the current implementation.
1227
- reparent: ""
1228
- };
1229
- var strokeSize2 = 2;
1230
- var terminalSize2 = 8;
1231
- var offsetToAlignTerminalWithLine2 = (strokeSize2 - terminalSize2) / 2;
1232
- var TreeDropIndicator = ({ instruction, gap = 0 }) => {
1233
- const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize2}px))`;
1234
- const isBlocked = instruction.type === "instruction-blocked";
1235
- const desiredInstruction = isBlocked ? instruction.desired : instruction;
1236
- const orientation = edgeToOrientationMap2[desiredInstruction.type];
1237
- if (isBlocked) {
1238
- return null;
1239
- }
1240
- return /* @__PURE__ */ React22.createElement("div", {
1241
- style: {
1242
- "--line-thickness": `${strokeSize2}px`,
1243
- "--line-offset": `${lineOffset}`,
1244
- "--terminal-size": `${terminalSize2}px`,
1245
- "--terminal-radius": `${terminalSize2 / 2}px`,
1246
- "--negative-terminal-size": `-${terminalSize2}px`,
1247
- "--offset-terminal": `${offsetToAlignTerminalWithLine2}px`,
1248
- "--horizontal-indent": `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`
1249
- },
1250
- className: `absolute z-10 pointer-events-none before:is-[--terminal-size] before:bs-[--terminal-size] box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full ${orientationStyles2[orientation]} ${instructionStyles[desiredInstruction.type]}`
1251
1198
  });
1252
- };
1253
-
1254
- // packages/ui/react-ui/src/components/Lists/Tree.tsx
1255
- var TreeRoot = /* @__PURE__ */ forwardRef15((props, forwardedRef) => {
1256
- return /* @__PURE__ */ React23.createElement(List, {
1257
- ...props,
1199
+ });
1200
+ DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
1201
+ var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
1202
+ var DropdownMenuRadioGroup = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1203
+ const { __scopeDropdownMenu, ...radioGroupProps } = props;
1204
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1205
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.RadioGroup, {
1206
+ ...menuScope,
1207
+ ...radioGroupProps,
1258
1208
  ref: forwardedRef
1259
1209
  });
1260
1210
  });
1261
- var TreeBranch = /* @__PURE__ */ forwardRef15(({ __listScope, ...props }, forwardedRef) => {
1262
- const { headingId } = useListItemContext(LIST_ITEM_NAME, __listScope);
1263
- return /* @__PURE__ */ React23.createElement(List, {
1264
- ...props,
1265
- "aria-labelledby": headingId,
1211
+ DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
1212
+ var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
1213
+ var DropdownMenuRadioItem = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1214
+ const { __scopeDropdownMenu, ...radioItemProps } = props;
1215
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1216
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.RadioItem, {
1217
+ ...menuScope,
1218
+ ...radioItemProps,
1266
1219
  ref: forwardedRef
1267
1220
  });
1268
1221
  });
1269
- var TreeItemRoot = /* @__PURE__ */ forwardRef15((props, forwardedRef) => {
1270
- return /* @__PURE__ */ React23.createElement(ListItem.Root, {
1271
- role: "treeitem",
1272
- ...props,
1222
+ DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
1223
+ var INDICATOR_NAME = "DropdownMenuItemIndicator";
1224
+ var DropdownMenuItemIndicator = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1225
+ const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
1226
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1227
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.ItemIndicator, {
1228
+ ...menuScope,
1229
+ ...itemIndicatorProps,
1273
1230
  ref: forwardedRef
1274
1231
  });
1275
1232
  });
1276
- var TreeItemHeading = ListItem.Heading;
1277
- var TreeItemOpenTrigger = ListItem.OpenTrigger;
1278
- var MockTreeItemOpenTrigger = ListItem.MockOpenTrigger;
1279
- var TreeItemBody = ListItem.CollapsibleContent;
1280
- var Tree = {
1281
- Root: TreeRoot,
1282
- Branch: TreeBranch
1233
+ DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
1234
+ var SEPARATOR_NAME = "DropdownMenuSeparator";
1235
+ var DropdownMenuSeparator = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1236
+ const { __scopeDropdownMenu, classNames, ...separatorProps } = props;
1237
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1238
+ const { tx } = useThemeContext();
1239
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Separator, {
1240
+ ...menuScope,
1241
+ ...separatorProps,
1242
+ className: tx("menu.separator", "menu__item", {}, classNames),
1243
+ ref: forwardedRef
1244
+ });
1245
+ });
1246
+ DropdownMenuSeparator.displayName = SEPARATOR_NAME;
1247
+ var ARROW_NAME = "DropdownMenuArrow";
1248
+ var DropdownMenuArrow = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1249
+ const { __scopeDropdownMenu, classNames, ...arrowProps } = props;
1250
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1251
+ const { tx } = useThemeContext();
1252
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Arrow, {
1253
+ ...menuScope,
1254
+ ...arrowProps,
1255
+ className: tx("menu.arrow", "menu__arrow", {}, classNames),
1256
+ ref: forwardedRef
1257
+ });
1258
+ });
1259
+ DropdownMenuArrow.displayName = ARROW_NAME;
1260
+ var DropdownMenuSub = (props) => {
1261
+ const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
1262
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1263
+ const [open = false, setOpen] = useControllableState({
1264
+ prop: openProp,
1265
+ defaultProp: defaultOpen,
1266
+ onChange: onOpenChange
1267
+ });
1268
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.Sub, {
1269
+ ...menuScope,
1270
+ open,
1271
+ onOpenChange: setOpen
1272
+ }, children);
1283
1273
  };
1284
- var TreeItem = {
1285
- Root: TreeItemRoot,
1286
- Heading: TreeItemHeading,
1287
- Body: TreeItemBody,
1288
- OpenTrigger: TreeItemOpenTrigger,
1289
- MockOpenTrigger: MockTreeItemOpenTrigger,
1290
- DropIndicator: TreeDropIndicator
1274
+ var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
1275
+ var DropdownMenuSubTrigger = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1276
+ const { __scopeDropdownMenu, ...subTriggerProps } = props;
1277
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1278
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.SubTrigger, {
1279
+ ...menuScope,
1280
+ ...subTriggerProps,
1281
+ ref: forwardedRef
1282
+ });
1283
+ });
1284
+ DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
1285
+ var SUB_CONTENT_NAME = "DropdownMenuSubContent";
1286
+ var DropdownMenuSubContent = /* @__PURE__ */ forwardRef14((props, forwardedRef) => {
1287
+ const { __scopeDropdownMenu, ...subContentProps } = props;
1288
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1289
+ return /* @__PURE__ */ React20.createElement(MenuPrimitive.SubContent, {
1290
+ ...menuScope,
1291
+ ...subContentProps,
1292
+ ref: forwardedRef,
1293
+ style: {
1294
+ ...props.style,
1295
+ // re-namespace exposed content custom properties
1296
+ ...{
1297
+ "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
1298
+ "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
1299
+ "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
1300
+ "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
1301
+ "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
1302
+ }
1303
+ }
1304
+ });
1305
+ });
1306
+ DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
1307
+ var DropdownMenu = {
1308
+ Root: DropdownMenuRoot,
1309
+ Trigger: DropdownMenuTrigger,
1310
+ VirtualTrigger: DropdownMenuVirtualTrigger,
1311
+ Portal: DropdownMenuPortal,
1312
+ Content: DropdownMenuContent,
1313
+ Viewport: DropdownMenuViewport,
1314
+ Group: DropdownMenuGroup,
1315
+ GroupLabel: DropdownMenuGroupLabel,
1316
+ Item: DropdownMenuItem,
1317
+ CheckboxItem: DropdownMenuCheckboxItem,
1318
+ RadioGroup: DropdownMenuRadioGroup,
1319
+ RadioItem: DropdownMenuRadioItem,
1320
+ ItemIndicator: DropdownMenuItemIndicator,
1321
+ Separator: DropdownMenuSeparator,
1322
+ Arrow: DropdownMenuArrow,
1323
+ Sub: DropdownMenuSub,
1324
+ SubTrigger: DropdownMenuSubTrigger,
1325
+ SubContent: DropdownMenuSubContent
1291
1326
  };
1327
+ var useDropdownMenuMenuScope = useMenuScope;
1292
1328
 
1293
- // packages/ui/react-ui/src/components/Lists/Treegrid.tsx
1294
- import { useArrowNavigationGroup, useFocusableGroup } from "@fluentui/react-tabster";
1295
- import { createContextScope } from "@radix-ui/react-context";
1296
- import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
1297
- import { Slot as Slot7 } from "@radix-ui/react-slot";
1329
+ // packages/ui/react-ui/src/components/Input/Input.tsx
1330
+ import { Root as CheckboxPrimitive } from "@radix-ui/react-checkbox";
1298
1331
  import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
1299
- import React24, { forwardRef as forwardRef16 } from "react";
1300
- var TREEGRID_ROW_NAME = "TreegridRow";
1301
- var [createTreegridRowContext, createTreegridRowScope] = createContextScope(TREEGRID_ROW_NAME, []);
1302
- var [TreegridRowProvider, useTreegridRowContext] = createTreegridRowContext(TREEGRID_ROW_NAME);
1303
- var PATH_SEPARATOR = "~";
1304
- var PARENT_OF_SEPARATOR = " ";
1305
- var TreegridRoot = /* @__PURE__ */ forwardRef16(({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
1332
+ import React21, { forwardRef as forwardRef15, useCallback as useCallback5 } from "react";
1333
+ import { InputRoot, PinInput as PinInputPrimitive, TextInput as TextInputPrimitive, TextArea as TextAreaPrimitive, useInputContext, INPUT_NAME, Description as DescriptionPrimitive, DescriptionAndValidation as DescriptionAndValidationPrimitive, Label as LabelPrimitive, Validation as ValidationPrimitive } from "@dxos/react-input";
1334
+ import { mx as mx3 } from "@dxos/react-ui-theme";
1335
+ var Label3 = /* @__PURE__ */ forwardRef15(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1306
1336
  const { tx } = useThemeContext();
1307
- const Root5 = asChild ? Slot7 : Primitive6.div;
1308
- const arrowNavigationAttrs = useArrowNavigationGroup({
1309
- axis: "vertical",
1310
- tabbable: false,
1311
- circular: true
1312
- });
1313
- return /* @__PURE__ */ React24.createElement(Root5, {
1314
- role: "treegrid",
1315
- ...arrowNavigationAttrs,
1337
+ return /* @__PURE__ */ React21.createElement(LabelPrimitive, {
1316
1338
  ...props,
1317
- className: tx("treegrid.root", "treegrid", {}, classNames),
1318
- style: {
1319
- ...style,
1320
- gridTemplateColumns
1321
- },
1339
+ className: tx("input.label", "input__label", {
1340
+ srOnly
1341
+ }, classNames),
1322
1342
  ref: forwardedRef
1323
1343
  }, children);
1324
1344
  });
1325
- var TreegridRow = /* @__PURE__ */ forwardRef16(({ __treegridRowScope, asChild, classNames, children, id, parentOf, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, ...props }, forwardedRef) => {
1345
+ var Description = /* @__PURE__ */ forwardRef15(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1326
1346
  const { tx } = useThemeContext();
1327
- const Root5 = asChild ? Slot7 : Primitive6.div;
1328
- const pathParts = id.split(PATH_SEPARATOR);
1329
- const level = pathParts.length - 1;
1330
- const [open, onOpenChange] = useControllableState2({
1331
- prop: propsOpen,
1332
- onChange: propsOnOpenChange,
1333
- defaultProp: defaultOpen
1334
- });
1335
- const focusableGroupAttrs = useFocusableGroup({
1336
- tabBehavior: "limited"
1337
- });
1338
- const arrowGroupAttrs = useArrowNavigationGroup({
1339
- axis: "horizontal",
1340
- tabbable: false,
1341
- circular: false,
1342
- memorizeCurrent: false
1343
- });
1344
- return /* @__PURE__ */ React24.createElement(TreegridRowProvider, {
1345
- open,
1346
- onOpenChange,
1347
- scope: __treegridRowScope
1348
- }, /* @__PURE__ */ React24.createElement(Root5, {
1349
- role: "row",
1350
- "aria-level": level,
1351
- className: tx("treegrid.row", "treegrid__row", {
1352
- level
1353
- }, classNames),
1354
- ...parentOf && {
1355
- "aria-expanded": open,
1356
- "aria-owns": parentOf
1357
- },
1358
- tabIndex: 0,
1359
- ...focusableGroupAttrs,
1347
+ return /* @__PURE__ */ React21.createElement(DescriptionPrimitive, {
1360
1348
  ...props,
1361
- id,
1349
+ className: tx("input.description", "input__description", {
1350
+ srOnly
1351
+ }, classNames),
1362
1352
  ref: forwardedRef
1363
- }, /* @__PURE__ */ React24.createElement("div", {
1364
- role: "none",
1365
- className: "contents",
1366
- ...arrowGroupAttrs
1367
- }, children)));
1353
+ }, children);
1368
1354
  });
1369
- var TreegridCell = /* @__PURE__ */ forwardRef16(({ classNames, children, indent, ...props }, forwardedRef) => {
1355
+ var Validation = /* @__PURE__ */ forwardRef15(({ __inputScope, srOnly, classNames, children, ...props }, forwardedRef) => {
1370
1356
  const { tx } = useThemeContext();
1371
- return /* @__PURE__ */ React24.createElement("div", {
1372
- role: "gridcell",
1373
- className: tx("treegrid.cell", "treegrid__cell", {
1374
- indent
1357
+ const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1358
+ return /* @__PURE__ */ React21.createElement(ValidationPrimitive, {
1359
+ ...props,
1360
+ className: tx("input.validation", `input__validation-message input__validation-message--${validationValence}`, {
1361
+ srOnly,
1362
+ validationValence
1375
1363
  }, classNames),
1364
+ ref: forwardedRef
1365
+ }, children);
1366
+ });
1367
+ var DescriptionAndValidation = /* @__PURE__ */ forwardRef15(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1368
+ const { tx } = useThemeContext();
1369
+ return /* @__PURE__ */ React21.createElement(DescriptionAndValidationPrimitive, {
1376
1370
  ...props,
1371
+ className: tx("input.descriptionAndValidation", "input__description-and-validation", {
1372
+ srOnly
1373
+ }, classNames),
1377
1374
  ref: forwardedRef
1378
1375
  }, children);
1379
1376
  });
1380
- var Treegrid = {
1381
- Root: TreegridRoot,
1382
- Row: TreegridRow,
1383
- Cell: TreegridCell,
1384
- PARENT_OF_SEPARATOR,
1385
- PATH_SEPARATOR,
1386
- createTreegridRowScope,
1387
- useTreegridRowContext
1388
- };
1389
-
1390
- // packages/ui/react-ui/src/components/Main/Main.tsx
1391
- import { createContext as createContext10 } from "@radix-ui/react-context";
1392
- import { Root as DialogRoot2, DialogContent as DialogContent2, DialogTitle as DialogTitle2 } from "@radix-ui/react-dialog";
1393
- import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
1394
- import { Slot as Slot8 } from "@radix-ui/react-slot";
1395
- import { useControllableState as useControllableState3 } from "@radix-ui/react-use-controllable-state";
1396
- import React25, { forwardRef as forwardRef17, useCallback as useCallback6, useEffect as useEffect4, useRef, useState as useState8 } from "react";
1397
- import { log } from "@dxos/log";
1398
- import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
1399
-
1400
- // packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
1401
- import { useCallback as useCallback5, useEffect as useEffect3, useState as useState7 } from "react";
1402
- var MotionState;
1403
- (function(MotionState2) {
1404
- MotionState2[MotionState2["IDLE"] = 0] = "IDLE";
1405
- MotionState2[MotionState2["DEBOUNCING"] = 1] = "DEBOUNCING";
1406
- MotionState2[MotionState2["FOLLOWING"] = 2] = "FOLLOWING";
1407
- })(MotionState || (MotionState = {}));
1408
- var useSwipeToDismiss = (ref, {
1409
- onDismiss,
1410
- dismissThreshold = 64,
1411
- debounceThreshold = 8,
1412
- offset = 0
1413
- /* side = 'inline-start' */
1414
- }) => {
1415
- const $root = ref.current;
1416
- const [motionState, setMotionState] = useState7(0);
1417
- const [gestureStartX, setGestureStartX] = useState7(0);
1418
- const setIdle = useCallback5(() => {
1419
- setMotionState(0);
1420
- $root?.style.removeProperty("inset-inline-start");
1421
- $root?.style.setProperty("transition-duration", "200ms");
1422
- }, [
1423
- $root
1424
- ]);
1425
- const setFollowing = useCallback5(() => {
1426
- setMotionState(2);
1427
- $root?.style.setProperty("transition-duration", "0ms");
1428
- }, [
1429
- $root
1430
- ]);
1431
- const handlePointerDown = useCallback5(({ screenX }) => {
1432
- if (motionState === 0) {
1433
- setMotionState(1);
1434
- setGestureStartX(screenX);
1435
- }
1436
- }, [
1437
- motionState
1377
+ var PinInput = /* @__PURE__ */ forwardRef15(({ density: propsDensity, elevation: propsElevation, segmentClassName: propsSegmentClassName, inputClassName, variant, ...props }, forwardedRef) => {
1378
+ const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1379
+ const { tx } = useThemeContext();
1380
+ const density = useDensityContext(propsDensity);
1381
+ const elevation = useElevationContext(propsElevation);
1382
+ const segmentClassName = useCallback5(({ focused, validationValence }) => tx("input.input", "input--pin-segment", {
1383
+ variant: "static",
1384
+ focused,
1385
+ disabled: props.disabled,
1386
+ density,
1387
+ elevation,
1388
+ validationValence
1389
+ }, propsSegmentClassName), [
1390
+ tx,
1391
+ props.disabled,
1392
+ elevation,
1393
+ propsElevation,
1394
+ density
1438
1395
  ]);
1439
- const handlePointerMove = useCallback5(({ screenX }) => {
1440
- if ($root) {
1441
- const delta = Math.min(screenX - gestureStartX, 0);
1442
- switch (motionState) {
1443
- case 2:
1444
- if (Math.abs(delta) > dismissThreshold) {
1445
- setIdle();
1446
- onDismiss?.();
1447
- } else {
1448
- $root.style.setProperty("inset-inline-start", `${offset + delta}px`);
1449
- }
1450
- break;
1451
- case 1:
1452
- if (Math.abs(delta) > debounceThreshold) {
1453
- setFollowing();
1454
- }
1455
- break;
1456
- }
1457
- }
1458
- }, [
1459
- $root,
1460
- motionState,
1461
- gestureStartX
1462
- ]);
1463
- const handlePointerUp = useCallback5(() => {
1464
- setIdle();
1465
- }, [
1466
- setIdle
1467
- ]);
1468
- useEffect3(() => {
1469
- $root?.addEventListener("pointerdown", handlePointerDown);
1470
- return () => {
1471
- $root?.removeEventListener("pointerdown", handlePointerDown);
1472
- };
1473
- }, [
1474
- $root,
1475
- handlePointerDown
1476
- ]);
1477
- useEffect3(() => {
1478
- $root && document.documentElement.addEventListener("pointermove", handlePointerMove);
1479
- return () => {
1480
- document.documentElement.removeEventListener("pointermove", handlePointerMove);
1481
- };
1482
- }, [
1483
- $root,
1484
- handlePointerMove
1485
- ]);
1486
- useEffect3(() => {
1487
- $root && document.documentElement.addEventListener("pointerup", handlePointerUp);
1488
- return () => {
1489
- document.documentElement.removeEventListener("pointerup", handlePointerUp);
1490
- };
1491
- }, [
1492
- $root,
1493
- handlePointerUp
1494
- ]);
1495
- };
1496
-
1497
- // packages/ui/react-ui/src/components/Main/Main.tsx
1498
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui/src/components/Main/Main.tsx";
1499
- var MAIN_ROOT_NAME = "MainRoot";
1500
- var NAVIGATION_SIDEBAR_NAME = "NavigationSidebar";
1501
- var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
1502
- var MAIN_NAME = "Main";
1503
- var GENERIC_CONSUMER_NAME = "GenericConsumer";
1504
- var landmarkAttr = "data-main-landmark";
1505
- var useLandmarkMover = (propsOnKeyDown, landmark) => {
1506
- const handleKeyDown = useCallback6((event) => {
1507
- const target = event.target;
1508
- if (event.target === event.currentTarget && event.key === "Tab" && target.hasAttribute(landmarkAttr)) {
1509
- event.preventDefault();
1510
- const landmarks = Array.from(document.querySelectorAll(`[${landmarkAttr}]:not([inert])`)).map((el) => el.hasAttribute(landmarkAttr) ? parseInt(el.getAttribute(landmarkAttr)) : NaN).sort();
1511
- const l = landmarks.length;
1512
- const cursor = landmarks.indexOf(parseInt(target.getAttribute(landmarkAttr)));
1513
- const nextLandmark = landmarks[(cursor + l + (event.getModifierState("Shift") ? -1 : 1)) % l];
1514
- document.querySelector(`[${landmarkAttr}="${nextLandmark}"]`)?.focus();
1515
- }
1516
- propsOnKeyDown?.(event);
1517
- }, [
1518
- propsOnKeyDown
1519
- ]);
1520
- const focusableGroupAttrs = window ? {} : {
1521
- tabBehavior: "limited",
1522
- ignoreDefaultKeydown: {
1523
- Tab: true
1524
- }
1525
- };
1526
- return {
1527
- onKeyDown: handleKeyDown,
1528
- [landmarkAttr]: landmark,
1529
- tabIndex: 0,
1530
- ...focusableGroupAttrs
1531
- };
1532
- };
1533
- var [MainProvider, useMainContext] = createContext10(MAIN_NAME, {
1534
- resizing: false,
1535
- navigationSidebarState: "closed",
1536
- setNavigationSidebarState: (nextState) => {
1537
- log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
1538
- F: __dxlog_file,
1539
- L: 82,
1540
- S: void 0,
1541
- C: (f, a) => f(...a)
1542
- });
1543
- },
1544
- complementarySidebarState: "closed",
1545
- setComplementarySidebarState: (nextState) => {
1546
- log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
1547
- F: __dxlog_file,
1548
- L: 87,
1549
- S: void 0,
1550
- C: (f, a) => f(...a)
1551
- });
1552
- }
1553
- });
1554
- var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
1555
- const { setNavigationSidebarState, navigationSidebarState, setComplementarySidebarState, complementarySidebarState } = useMainContext(consumerName);
1556
- return {
1557
- navigationSidebarState,
1558
- setNavigationSidebarState,
1559
- toggleNavigationSidebar: useCallback6(() => setNavigationSidebarState(navigationSidebarState === "expanded" ? "closed" : "expanded"), [
1560
- navigationSidebarState,
1561
- setNavigationSidebarState
1562
- ]),
1563
- openNavigationSidebar: useCallback6(() => setNavigationSidebarState("expanded"), []),
1564
- collapseNavigationSidebar: useCallback6(() => setNavigationSidebarState("collapsed"), []),
1565
- closeNavigationSidebar: useCallback6(() => setNavigationSidebarState("closed"), []),
1566
- complementarySidebarState,
1567
- setComplementarySidebarState,
1568
- toggleComplementarySidebar: useCallback6(() => setComplementarySidebarState(complementarySidebarState === "expanded" ? "closed" : "expanded"), [
1569
- complementarySidebarState,
1570
- setComplementarySidebarState
1571
- ]),
1572
- openComplementarySidebar: useCallback6(() => setComplementarySidebarState("expanded"), []),
1573
- collapseComplementarySidebar: useCallback6(() => setComplementarySidebarState("collapsed"), []),
1574
- closeComplementarySidebar: useCallback6(() => setComplementarySidebarState("closed"), [])
1575
- };
1576
- };
1577
- var resizeDebounce = 3e3;
1578
- var MainRoot = ({ navigationSidebarState: propsNavigationSidebarState, defaultNavigationSidebarState, onNavigationSidebarStateChange, complementarySidebarState: propsComplementarySidebarState, defaultComplementarySidebarState, onComplementarySidebarStateChange, children, ...props }) => {
1579
- const [isLg] = useMediaQuery("lg", {
1580
- ssr: false
1581
- });
1582
- const [navigationSidebarState = isLg ? "expanded" : "collapsed", setNavigationSidebarState] = useControllableState3({
1583
- prop: propsNavigationSidebarState,
1584
- defaultProp: defaultNavigationSidebarState,
1585
- onChange: onNavigationSidebarStateChange
1586
- });
1587
- const [complementarySidebarState = isLg ? "expanded" : "collapsed", setComplementarySidebarState] = useControllableState3({
1588
- prop: propsComplementarySidebarState,
1589
- defaultProp: defaultComplementarySidebarState,
1590
- onChange: onComplementarySidebarStateChange
1591
- });
1592
- const [resizing, setResizing] = useState8(false);
1593
- const resizeInterval = useRef(null);
1594
- const handleResize = useCallback6(() => {
1595
- setResizing(true);
1596
- if (resizeInterval.current) {
1597
- clearTimeout(resizeInterval.current);
1598
- }
1599
- resizeInterval.current = setTimeout(() => {
1600
- setResizing(false);
1601
- resizeInterval.current = null;
1602
- }, resizeDebounce);
1603
- }, []);
1604
- useEffect4(() => {
1605
- window.addEventListener("resize", handleResize);
1606
- return () => window.removeEventListener("resize", handleResize);
1607
- }, [
1608
- handleResize
1609
- ]);
1610
- return /* @__PURE__ */ React25.createElement(MainProvider, {
1611
- ...props,
1612
- navigationSidebarState,
1613
- setNavigationSidebarState,
1614
- complementarySidebarState,
1615
- setComplementarySidebarState,
1616
- resizing
1617
- }, children);
1618
- };
1619
- MainRoot.displayName = MAIN_ROOT_NAME;
1620
- var handleOpenAutoFocus = (event) => {
1621
- !document.body.hasAttribute("data-is-keyboard") && event.preventDefault();
1622
- };
1623
- var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToDismiss, onOpenAutoFocus, state, resizing, onStateChange, side, label, ...props }, forwardedRef) => {
1624
- const [isLg] = useMediaQuery("lg", {
1625
- ssr: false
1626
- });
1627
- const { tx } = useThemeContext();
1628
- const { t } = useTranslation();
1629
- const ref = useForwardedRef(forwardedRef);
1630
- const noopRef = useRef(null);
1631
- useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
1632
- onDismiss: () => onStateChange?.("closed")
1633
- });
1634
- const handleKeyDown = useCallback6((event) => {
1635
- if (event.key === "Escape") {
1636
- event.target.closest("[data-tabster]")?.focus();
1637
- }
1638
- props.onKeyDown?.(event);
1639
- }, [
1640
- props.onKeyDown
1641
- ]);
1642
- const Root5 = isLg ? Primitive7.div : DialogContent2;
1643
- return /* @__PURE__ */ React25.createElement(DialogRoot2, {
1644
- open: state !== "closed",
1645
- "aria-label": toLocalizedString(label, t),
1646
- modal: false
1647
- }, !isLg && /* @__PURE__ */ React25.createElement(DialogTitle2, {
1648
- className: "sr-only"
1649
- }, toLocalizedString(label, t)), /* @__PURE__ */ React25.createElement(Root5, {
1650
- ...!isLg && {
1651
- forceMount: true,
1652
- tabIndex: -1,
1653
- onOpenAutoFocus: onOpenAutoFocus ?? handleOpenAutoFocus
1654
- },
1396
+ return /* @__PURE__ */ React21.createElement(PinInputPrimitive, {
1655
1397
  ...props,
1656
- "data-side": side === "inline-end" ? "ie" : "is",
1657
- "data-state": state,
1658
- "data-resizing": resizing ? "true" : "false",
1659
- className: tx("main.sidebar", "main__sidebar", {}, classNames),
1660
- onKeyDown: handleKeyDown,
1661
- ...state === "closed" && {
1662
- inert: "true"
1398
+ segmentClassName,
1399
+ ...props.autoFocus && !hasIosKeyboard2 && {
1400
+ autoFocus: true
1663
1401
  },
1664
- ref
1665
- }, children));
1666
- });
1667
- var MainNavigationSidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
1668
- const { navigationSidebarState, setNavigationSidebarState, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
1669
- const mover = useLandmarkMover(props.onKeyDown, "0");
1670
- return /* @__PURE__ */ React25.createElement(MainSidebar, {
1671
- ...mover,
1672
- ...props,
1673
- state: navigationSidebarState,
1674
- onStateChange: setNavigationSidebarState,
1675
- resizing,
1676
- side: "inline-start",
1402
+ inputClassName: tx("input.inputWithSegments", "input input--pin", {
1403
+ disabled: props.disabled
1404
+ }, inputClassName),
1677
1405
  ref: forwardedRef
1678
1406
  });
1679
1407
  });
1680
- MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
1681
- var MainComplementarySidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
1682
- const { complementarySidebarState, setComplementarySidebarState, resizing } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
1683
- const mover = useLandmarkMover(props.onKeyDown, "2");
1684
- return /* @__PURE__ */ React25.createElement(MainSidebar, {
1685
- ...mover,
1408
+ var TextInput = /* @__PURE__ */ forwardRef15(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
1409
+ const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1410
+ const themeContextValue = useThemeContext();
1411
+ const density = useDensityContext(propsDensity);
1412
+ const elevation = useElevationContext(propsElevation);
1413
+ const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1414
+ const { tx } = themeContextValue;
1415
+ return /* @__PURE__ */ React21.createElement(TextInputPrimitive, {
1686
1416
  ...props,
1687
- state: complementarySidebarState,
1688
- onStateChange: setComplementarySidebarState,
1689
- resizing,
1690
- side: "inline-end",
1417
+ className: tx("input.input", "input", {
1418
+ variant,
1419
+ disabled: props.disabled,
1420
+ density,
1421
+ elevation,
1422
+ validationValence
1423
+ }, classNames),
1424
+ ...props.autoFocus && !hasIosKeyboard2 && {
1425
+ autoFocus: true
1426
+ },
1691
1427
  ref: forwardedRef
1692
1428
  });
1693
1429
  });
1694
- MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
1695
- var MainContent = /* @__PURE__ */ forwardRef17(({ asChild, classNames, bounce, handlesFocus, children, role, ...props }, forwardedRef) => {
1696
- const { navigationSidebarState, complementarySidebarState } = useMainContext(MAIN_NAME);
1430
+ var TextArea = /* @__PURE__ */ forwardRef15(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
1431
+ const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1697
1432
  const { tx } = useThemeContext();
1698
- const Root5 = asChild ? Slot8 : role ? "div" : "main";
1699
- const mover = useLandmarkMover(props.onKeyDown, "1");
1700
- return /* @__PURE__ */ React25.createElement(Root5, {
1701
- role,
1702
- ...handlesFocus && {
1703
- ...mover
1704
- },
1433
+ const density = useDensityContext(propsDensity);
1434
+ const elevation = useElevationContext(propsElevation);
1435
+ const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1436
+ return /* @__PURE__ */ React21.createElement(TextAreaPrimitive, {
1705
1437
  ...props,
1706
- "data-sidebar-inline-start-state": navigationSidebarState,
1707
- "data-sidebar-inline-end-state": complementarySidebarState,
1708
- className: tx("main.content", "main", {
1709
- bounce,
1710
- handlesFocus
1438
+ className: tx("input.input", "input--text-area", {
1439
+ variant,
1440
+ disabled: props.disabled,
1441
+ density,
1442
+ elevation,
1443
+ validationValence
1711
1444
  }, classNames),
1712
- ref: forwardedRef
1713
- }, children);
1445
+ ...props.autoFocus && !hasIosKeyboard2 && {
1446
+ autoFocus: true
1447
+ },
1448
+ ref: forwardedRef
1449
+ });
1714
1450
  });
1715
- MainContent.displayName = MAIN_NAME;
1716
- var MainOverlay = /* @__PURE__ */ forwardRef17(({ classNames, ...props }, forwardedRef) => {
1717
- const [isLg] = useMediaQuery("lg", {
1718
- ssr: false
1451
+ var Checkbox = /* @__PURE__ */ forwardRef15(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, size, weight = "bold", classNames, ...props }, forwardedRef) => {
1452
+ const [checked, onCheckedChange] = useControllableState2({
1453
+ prop: propsChecked,
1454
+ defaultProp: propsDefaultChecked,
1455
+ onChange: propsOnCheckedChange
1719
1456
  });
1720
- const { navigationSidebarState, setNavigationSidebarState, complementarySidebarState, setComplementarySidebarState } = useMainContext(MAIN_NAME);
1457
+ const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1721
1458
  const { tx } = useThemeContext();
1722
- return /* @__PURE__ */ React25.createElement("div", {
1723
- onClick: () => {
1724
- setNavigationSidebarState("collapsed");
1725
- setComplementarySidebarState("collapsed");
1459
+ return /* @__PURE__ */ React21.createElement(CheckboxPrimitive, {
1460
+ ...props,
1461
+ checked,
1462
+ onCheckedChange,
1463
+ id,
1464
+ "aria-describedby": descriptionId,
1465
+ ...validationValence === "error" && {
1466
+ "aria-invalid": "true",
1467
+ "aria-errormessage": errorMessageId
1468
+ },
1469
+ className: tx("input.checkbox", "input--checkbox", {
1470
+ size
1471
+ }, "shrink-0", classNames),
1472
+ ref: forwardedRef
1473
+ }, /* @__PURE__ */ React21.createElement(Icon, {
1474
+ icon: checked === "indeterminate" ? "ph--minus--regular" : "ph--check--regular",
1475
+ classNames: tx("input.checkboxIndicator", "input--checkbox__indicator", {
1476
+ size,
1477
+ checked
1478
+ })
1479
+ }));
1480
+ });
1481
+ var Switch = /* @__PURE__ */ forwardRef15(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, classNames, ...props }, forwardedRef) => {
1482
+ const [checked, onCheckedChange] = useControllableState2({
1483
+ prop: propsChecked,
1484
+ defaultProp: propsDefaultChecked ?? false,
1485
+ onChange: propsOnCheckedChange
1486
+ });
1487
+ const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1488
+ return /* @__PURE__ */ React21.createElement("input", {
1489
+ type: "checkbox",
1490
+ className: mx3("dx-checkbox--switch dx-focus-ring", classNames),
1491
+ checked,
1492
+ onChange: (event) => {
1493
+ onCheckedChange(event.target.checked);
1726
1494
  },
1495
+ id,
1496
+ "aria-describedby": descriptionId,
1727
1497
  ...props,
1728
- className: tx("main.overlay", "main__overlay", {
1729
- isLg,
1730
- inlineStartSidebarOpen: navigationSidebarState,
1731
- inlineEndSidebarOpen: complementarySidebarState
1732
- }, classNames),
1733
- "data-state": navigationSidebarState === "expanded" || complementarySidebarState === "expanded" ? "open" : "closed",
1734
- "aria-hidden": "true",
1498
+ ...validationValence === "error" && {
1499
+ "aria-invalid": "true",
1500
+ "aria-errormessage": errorMessageId
1501
+ },
1735
1502
  ref: forwardedRef
1736
1503
  });
1737
1504
  });
1738
- var Main = {
1739
- Root: MainRoot,
1740
- Content: MainContent,
1741
- Overlay: MainOverlay,
1742
- NavigationSidebar: MainNavigationSidebar,
1743
- ComplementarySidebar: MainComplementarySidebar
1505
+ var Input = {
1506
+ Root: InputRoot,
1507
+ PinInput,
1508
+ TextInput,
1509
+ TextArea,
1510
+ Checkbox,
1511
+ Switch,
1512
+ Label: Label3,
1513
+ Description,
1514
+ Validation,
1515
+ DescriptionAndValidation
1744
1516
  };
1745
1517
 
1746
- // packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
1747
- import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
1748
- import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1749
- import { Slot as Slot9 } from "@radix-ui/react-slot";
1750
- import React26, { forwardRef as forwardRef18 } from "react";
1751
- var ContextMenuRoot = ContextMenuPrimitive.ContextMenu;
1752
- var ContextMenuTrigger = ContextMenuPrimitive.Trigger;
1753
- var ContextMenuPortal = ContextMenuPrimitive.Portal;
1754
- var ContextMenuContent = /* @__PURE__ */ forwardRef18(({ classNames, children, collisionPadding = 8, ...props }, forwardedRef) => {
1518
+ // packages/ui/react-ui/src/components/Lists/List.tsx
1519
+ import { CaretDown, CaretRight } from "@phosphor-icons/react";
1520
+ import { Slot as Slot8 } from "@radix-ui/react-slot";
1521
+ import React23, { forwardRef as forwardRef16 } from "react";
1522
+ import { List as ListPrimitive, ListItemHeading as ListPrimitiveItemHeading, ListItemOpenTrigger as ListPrimitiveItemOpenTrigger, ListItemCollapsibleContent, ListItem as ListPrimitiveItem, LIST_NAME, LIST_ITEM_NAME, useListContext, useListItemContext } from "@dxos/react-list";
1523
+
1524
+ // packages/ui/react-ui/src/components/Lists/ListDropIndicator.tsx
1525
+ import React22 from "react";
1526
+ var edgeToOrientationMap = {
1527
+ top: "horizontal",
1528
+ bottom: "horizontal",
1529
+ left: "vertical",
1530
+ right: "vertical"
1531
+ };
1532
+ var orientationStyles = {
1533
+ horizontal: "h-[--line-thickness] left-[calc(var(--line-inset)+var(--terminal-radius))] right-[--line-inset] before:left-[--terminal-inset]",
1534
+ vertical: "w-[--line-thickness] top-[calc(var(--line-inset)+var(--terminal-radius))] bottom-[--line-inset] before:top-[--terminal-inset]"
1535
+ };
1536
+ var edgeStyles = {
1537
+ top: "top-[--line-offset] before:top-[--offset-terminal]",
1538
+ right: "right-[--line-offset] before:right-[--offset-terminal]",
1539
+ bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
1540
+ left: "left-[--line-offset] before:left-[--offset-terminal]"
1541
+ };
1542
+ var strokeSize = 2;
1543
+ var terminalSize = 8;
1544
+ var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
1545
+ var ListDropIndicator = ({ edge, gap = 0, lineInset = 0, terminalInset = lineInset - terminalSize }) => {
1546
+ const orientation = edgeToOrientationMap[edge];
1547
+ return /* @__PURE__ */ React22.createElement("div", {
1548
+ role: "none",
1549
+ style: {
1550
+ "--line-thickness": `${strokeSize}px`,
1551
+ "--line-offset": `calc(-0.5 * (${gap}px + ${strokeSize}px))`,
1552
+ "--line-inset": `${lineInset}px`,
1553
+ "--terminal-size": `${terminalSize}px`,
1554
+ "--terminal-radius": `${terminalSize / 2}px`,
1555
+ "--terminal-inset": `${terminalInset}px`,
1556
+ "--offset-terminal": `${offsetToAlignTerminalWithLine}px`
1557
+ },
1558
+ className: `absolute z-10 pointer-events-none bg-accentSurface before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full ${orientationStyles[orientation]} ${edgeStyles[edge]}`
1559
+ });
1560
+ };
1561
+
1562
+ // packages/ui/react-ui/src/components/Lists/List.tsx
1563
+ var List = /* @__PURE__ */ forwardRef16(({ classNames, children, ...props }, forwardedRef) => {
1755
1564
  const { tx } = useThemeContext();
1756
- const elevation = useElevationContext();
1757
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
1758
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Content, {
1565
+ const density = useDensityContext(props.density);
1566
+ return /* @__PURE__ */ React23.createElement(DensityProvider, {
1567
+ density
1568
+ }, /* @__PURE__ */ React23.createElement(ListPrimitive, {
1759
1569
  ...props,
1760
- collisionPadding: safeCollisionPadding,
1761
- className: tx("menu.content", "menu", {
1762
- elevation
1570
+ className: tx("list.root", "list", {}, classNames),
1571
+ ref: forwardedRef
1572
+ }, children));
1573
+ });
1574
+ var ListItemEndcap = /* @__PURE__ */ forwardRef16(({ children, classNames, asChild, ...props }, forwardedRef) => {
1575
+ const Root5 = asChild ? Slot8 : "div";
1576
+ const density = useDensityContext();
1577
+ const { tx } = useThemeContext();
1578
+ return /* @__PURE__ */ React23.createElement(Root5, {
1579
+ ...!asChild && {
1580
+ role: "none"
1581
+ },
1582
+ ...props,
1583
+ className: tx("list.item.endcap", "list__listItem__endcap", {
1584
+ density
1763
1585
  }, classNames),
1764
1586
  ref: forwardedRef
1765
1587
  }, children);
1766
1588
  });
1767
- var ContextMenuViewport = /* @__PURE__ */ forwardRef18(({ classNames, asChild, children, ...props }, forwardedRef) => {
1589
+ var MockListItemOpenTrigger = ({ classNames, ...props }) => {
1590
+ const density = useDensityContext();
1768
1591
  const { tx } = useThemeContext();
1769
- const Root5 = asChild ? Slot9 : Primitive8.div;
1770
- return /* @__PURE__ */ React26.createElement(Root5, {
1592
+ return /* @__PURE__ */ React23.createElement("div", {
1593
+ role: "none",
1771
1594
  ...props,
1772
- className: tx("menu.viewport", "menu__viewport", {}, classNames),
1595
+ className: tx("list.item.openTrigger", "list__listItem__openTrigger--mock", {
1596
+ density
1597
+ }, classNames)
1598
+ });
1599
+ };
1600
+ var ListItemHeading = /* @__PURE__ */ forwardRef16(({ children, classNames, ...props }, forwardedRef) => {
1601
+ const { tx } = useThemeContext();
1602
+ const density = useDensityContext();
1603
+ return /* @__PURE__ */ React23.createElement(ListPrimitiveItemHeading, {
1604
+ ...props,
1605
+ className: tx("list.item.heading", "list__listItem__heading", {
1606
+ density
1607
+ }, classNames),
1773
1608
  ref: forwardedRef
1774
1609
  }, children);
1775
1610
  });
1776
- var ContextMenuArrow = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
1611
+ var ListItemOpenTrigger = /* @__PURE__ */ forwardRef16(({ __listItemScope, classNames, children, ...props }, forwardedRef) => {
1777
1612
  const { tx } = useThemeContext();
1778
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Arrow, {
1613
+ const density = useDensityContext();
1614
+ const { open } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
1615
+ const Icon3 = open ? CaretDown : CaretRight;
1616
+ return /* @__PURE__ */ React23.createElement(ListPrimitiveItemOpenTrigger, {
1779
1617
  ...props,
1780
- className: tx("menu.arrow", "menu__arrow", {}, classNames),
1618
+ className: tx("list.item.openTrigger", "list__listItem__openTrigger", {
1619
+ density
1620
+ }, classNames),
1781
1621
  ref: forwardedRef
1782
- });
1622
+ }, children || /* @__PURE__ */ React23.createElement(Icon3, {
1623
+ weight: "bold",
1624
+ className: tx("list.item.openTriggerIcon", "list__listItem__openTrigger__icon", {})
1625
+ }));
1783
1626
  });
1784
- var ContextMenuGroup = ContextMenuPrimitive.Group;
1785
- var ContextMenuItemIndicator = ContextMenuPrimitive.ItemIndicator;
1786
- var ContextMenuItem = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
1627
+ var ListItemRoot = /* @__PURE__ */ forwardRef16(({ classNames, children, ...props }, forwardedRef) => {
1787
1628
  const { tx } = useThemeContext();
1788
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Item, {
1629
+ const density = useDensityContext();
1630
+ return /* @__PURE__ */ React23.createElement(ListPrimitiveItem, {
1789
1631
  ...props,
1790
- className: tx("menu.item", "menu__item", {}, classNames),
1632
+ className: tx("list.item.root", "list__listItem", {
1633
+ density,
1634
+ collapsible: props.collapsible
1635
+ }, classNames),
1791
1636
  ref: forwardedRef
1792
- });
1637
+ }, children);
1793
1638
  });
1794
- var ContextMenuCheckboxItem = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
1795
- const { tx } = useThemeContext();
1796
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.CheckboxItem, {
1639
+ var ListItem = {
1640
+ Root: ListItemRoot,
1641
+ Endcap: ListItemEndcap,
1642
+ Heading: ListItemHeading,
1643
+ OpenTrigger: ListItemOpenTrigger,
1644
+ CollapsibleContent: ListItemCollapsibleContent,
1645
+ MockOpenTrigger: MockListItemOpenTrigger,
1646
+ DropIndicator: ListDropIndicator
1647
+ };
1648
+
1649
+ // packages/ui/react-ui/src/components/Lists/Tree.tsx
1650
+ import React25, { forwardRef as forwardRef17 } from "react";
1651
+
1652
+ // packages/ui/react-ui/src/components/Lists/TreeDropIndicator.tsx
1653
+ import React24 from "react";
1654
+ var edgeToOrientationMap2 = {
1655
+ "reorder-above": "sibling",
1656
+ "reorder-below": "sibling",
1657
+ "make-child": "child",
1658
+ reparent: "child"
1659
+ };
1660
+ var orientationStyles2 = {
1661
+ // TODO(wittjosiah): Stop using left/right here.
1662
+ sibling: "bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]",
1663
+ child: "is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible"
1664
+ };
1665
+ var instructionStyles = {
1666
+ "reorder-above": "block-start-[--line-offset] before:block-start-[--offset-terminal]",
1667
+ "reorder-below": "block-end-[--line-offset] before:block-end-[--offset-terminal]",
1668
+ "make-child": "border-accentSurface",
1669
+ // TODO(wittjosiah): This is not occurring in the current implementation.
1670
+ reparent: ""
1671
+ };
1672
+ var strokeSize2 = 2;
1673
+ var terminalSize2 = 8;
1674
+ var offsetToAlignTerminalWithLine2 = (strokeSize2 - terminalSize2) / 2;
1675
+ var TreeDropIndicator = ({ instruction, gap = 0 }) => {
1676
+ const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize2}px))`;
1677
+ const isBlocked = instruction.type === "instruction-blocked";
1678
+ const desiredInstruction = isBlocked ? instruction.desired : instruction;
1679
+ const orientation = edgeToOrientationMap2[desiredInstruction.type];
1680
+ if (isBlocked) {
1681
+ return null;
1682
+ }
1683
+ return /* @__PURE__ */ React24.createElement("div", {
1684
+ style: {
1685
+ "--line-thickness": `${strokeSize2}px`,
1686
+ "--line-offset": `${lineOffset}`,
1687
+ "--terminal-size": `${terminalSize2}px`,
1688
+ "--terminal-radius": `${terminalSize2 / 2}px`,
1689
+ "--negative-terminal-size": `-${terminalSize2}px`,
1690
+ "--offset-terminal": `${offsetToAlignTerminalWithLine2}px`,
1691
+ "--horizontal-indent": `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`
1692
+ },
1693
+ className: `absolute z-10 pointer-events-none before:is-[--terminal-size] before:bs-[--terminal-size] box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full ${orientationStyles2[orientation]} ${instructionStyles[desiredInstruction.type]}`
1694
+ });
1695
+ };
1696
+
1697
+ // packages/ui/react-ui/src/components/Lists/Tree.tsx
1698
+ var TreeRoot = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
1699
+ return /* @__PURE__ */ React25.createElement(List, {
1797
1700
  ...props,
1798
- className: tx("menu.item", "menu__item--checkbox", {}, classNames),
1799
1701
  ref: forwardedRef
1800
1702
  });
1801
1703
  });
1802
- var ContextMenuSeparator = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
1803
- const { tx } = useThemeContext();
1804
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Separator, {
1704
+ var TreeBranch = /* @__PURE__ */ forwardRef17(({ __listScope, ...props }, forwardedRef) => {
1705
+ const { headingId } = useListItemContext(LIST_ITEM_NAME, __listScope);
1706
+ return /* @__PURE__ */ React25.createElement(List, {
1805
1707
  ...props,
1806
- className: tx("menu.separator", "menu__item", {}, classNames),
1708
+ "aria-labelledby": headingId,
1807
1709
  ref: forwardedRef
1808
1710
  });
1809
1711
  });
1810
- var ContextMenuGroupLabel = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
1811
- const { tx } = useThemeContext();
1812
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Label, {
1712
+ var TreeItemRoot = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
1713
+ return /* @__PURE__ */ React25.createElement(ListItem.Root, {
1714
+ role: "treeitem",
1813
1715
  ...props,
1814
- className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
1815
1716
  ref: forwardedRef
1816
1717
  });
1817
1718
  });
1818
- var ContextMenu2 = {
1819
- Root: ContextMenuRoot,
1820
- Trigger: ContextMenuTrigger,
1821
- Portal: ContextMenuPortal,
1822
- Content: ContextMenuContent,
1823
- Viewport: ContextMenuViewport,
1824
- Arrow: ContextMenuArrow,
1825
- Group: ContextMenuGroup,
1826
- Item: ContextMenuItem,
1827
- CheckboxItem: ContextMenuCheckboxItem,
1828
- ItemIndicator: ContextMenuItemIndicator,
1829
- Separator: ContextMenuSeparator,
1830
- GroupLabel: ContextMenuGroupLabel
1719
+ var TreeItemHeading = ListItem.Heading;
1720
+ var TreeItemOpenTrigger = ListItem.OpenTrigger;
1721
+ var MockTreeItemOpenTrigger = ListItem.MockOpenTrigger;
1722
+ var TreeItemBody = ListItem.CollapsibleContent;
1723
+ var Tree = {
1724
+ Root: TreeRoot,
1725
+ Branch: TreeBranch
1726
+ };
1727
+ var TreeItem = {
1728
+ Root: TreeItemRoot,
1729
+ Heading: TreeItemHeading,
1730
+ Body: TreeItemBody,
1731
+ OpenTrigger: TreeItemOpenTrigger,
1732
+ MockOpenTrigger: MockTreeItemOpenTrigger,
1733
+ DropIndicator: TreeDropIndicator
1831
1734
  };
1832
1735
 
1833
- // packages/ui/react-ui/src/components/Menus/DropdownMenu.tsx
1834
- import { composeEventHandlers } from "@radix-ui/primitive";
1835
- import { composeRefs } from "@radix-ui/react-compose-refs";
1736
+ // packages/ui/react-ui/src/components/Lists/Treegrid.tsx
1737
+ import { useArrowNavigationGroup, useFocusableGroup } from "@fluentui/react-tabster";
1836
1738
  import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
1837
- import { useId as useId2 } from "@radix-ui/react-id";
1838
- import * as MenuPrimitive from "@radix-ui/react-menu";
1839
- import { createMenuScope } from "@radix-ui/react-menu";
1840
- import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
1841
- import { Slot as Slot10 } from "@radix-ui/react-slot";
1842
- import { useControllableState as useControllableState4 } from "@radix-ui/react-use-controllable-state";
1843
- import React27, { useRef as useRef2, useCallback as useCallback7, forwardRef as forwardRef19, useEffect as useEffect5 } from "react";
1844
- var DROPDOWN_MENU_NAME = "DropdownMenu";
1845
- var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope2(DROPDOWN_MENU_NAME, [
1846
- createMenuScope
1847
- ]);
1848
- var useMenuScope = createMenuScope();
1849
- var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
1850
- var DropdownMenuRoot = (props) => {
1851
- const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
1852
- const menuScope = useMenuScope(__scopeDropdownMenu);
1853
- const triggerRef = useRef2(null);
1854
- const [open = false, setOpen] = useControllableState4({
1855
- prop: openProp,
1856
- defaultProp: defaultOpen,
1857
- onChange: onOpenChange
1739
+ import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1740
+ import { Slot as Slot9 } from "@radix-ui/react-slot";
1741
+ import { useControllableState as useControllableState3 } from "@radix-ui/react-use-controllable-state";
1742
+ import React26, { forwardRef as forwardRef18 } from "react";
1743
+ var TREEGRID_ROW_NAME = "TreegridRow";
1744
+ var [createTreegridRowContext, createTreegridRowScope] = createContextScope2(TREEGRID_ROW_NAME, []);
1745
+ var [TreegridRowProvider, useTreegridRowContext] = createTreegridRowContext(TREEGRID_ROW_NAME);
1746
+ var PATH_SEPARATOR = "~";
1747
+ var PARENT_OF_SEPARATOR = " ";
1748
+ var TreegridRoot = /* @__PURE__ */ forwardRef18(({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
1749
+ const { tx } = useThemeContext();
1750
+ const Root5 = asChild ? Slot9 : Primitive8.div;
1751
+ const arrowNavigationAttrs = useArrowNavigationGroup({
1752
+ axis: "vertical",
1753
+ tabbable: false,
1754
+ circular: true
1858
1755
  });
1859
- return /* @__PURE__ */ React27.createElement(DropdownMenuProvider, {
1860
- scope: __scopeDropdownMenu,
1861
- triggerId: useId2(),
1862
- triggerRef,
1863
- contentId: useId2(),
1864
- open,
1865
- onOpenChange: setOpen,
1866
- onOpenToggle: useCallback7(() => setOpen((prevOpen) => !prevOpen), [
1867
- setOpen
1868
- ]),
1869
- modal
1870
- }, /* @__PURE__ */ React27.createElement(MenuPrimitive.Root, {
1871
- ...menuScope,
1872
- open,
1873
- onOpenChange: setOpen,
1874
- dir,
1875
- modal
1876
- }, children));
1877
- };
1878
- DropdownMenuRoot.displayName = DROPDOWN_MENU_NAME;
1879
- var TRIGGER_NAME = "DropdownMenuTrigger";
1880
- var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
1881
- const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
1882
- const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
1883
- const menuScope = useMenuScope(__scopeDropdownMenu);
1884
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
1885
- asChild: true,
1886
- ...menuScope
1887
- }, /* @__PURE__ */ React27.createElement(Primitive9.button, {
1888
- type: "button",
1889
- id: context.triggerId,
1890
- "aria-haspopup": "menu",
1891
- "aria-expanded": context.open,
1892
- "aria-controls": context.open ? context.contentId : void 0,
1893
- "data-state": context.open ? "open" : "closed",
1894
- "data-disabled": disabled ? "" : void 0,
1895
- disabled,
1896
- ...triggerProps,
1897
- ref: composeRefs(forwardedRef, context.triggerRef),
1898
- onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
1899
- if (!disabled && event.button === 0 && event.ctrlKey === false) {
1900
- context.onOpenToggle();
1901
- if (!context.open) {
1902
- event.preventDefault();
1903
- }
1904
- }
1905
- }),
1906
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
1907
- if (disabled) {
1908
- return;
1909
- }
1910
- if ([
1911
- "Enter",
1912
- " "
1913
- ].includes(event.key)) {
1914
- context.onOpenToggle();
1915
- }
1916
- if (event.key === "ArrowDown") {
1917
- context.onOpenChange(true);
1918
- }
1919
- if ([
1920
- "Enter",
1921
- " ",
1922
- "ArrowDown"
1923
- ].includes(event.key)) {
1924
- event.preventDefault();
1925
- }
1926
- })
1927
- }));
1756
+ return /* @__PURE__ */ React26.createElement(Root5, {
1757
+ role: "treegrid",
1758
+ ...arrowNavigationAttrs,
1759
+ ...props,
1760
+ className: tx("treegrid.root", "treegrid", {}, classNames),
1761
+ style: {
1762
+ ...style,
1763
+ gridTemplateColumns
1764
+ },
1765
+ ref: forwardedRef
1766
+ }, children);
1928
1767
  });
1929
- DropdownMenuTrigger.displayName = TRIGGER_NAME;
1930
- var VIRTUAL_TRIGGER_NAME = "DropdownMenuVirtualTrigger";
1931
- var DropdownMenuVirtualTrigger = (props) => {
1932
- const { __scopeDropdownMenu, virtualRef } = props;
1933
- const context = useDropdownMenuContext(VIRTUAL_TRIGGER_NAME, __scopeDropdownMenu);
1934
- const menuScope = useMenuScope(__scopeDropdownMenu);
1935
- useEffect5(() => {
1936
- if (virtualRef.current) {
1937
- context.triggerRef.current = virtualRef.current;
1938
- }
1768
+ var TreegridRow = /* @__PURE__ */ forwardRef18(({ __treegridRowScope, asChild, classNames, children, id, parentOf, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, ...props }, forwardedRef) => {
1769
+ const { tx } = useThemeContext();
1770
+ const Root5 = asChild ? Slot9 : Primitive8.div;
1771
+ const pathParts = id.split(PATH_SEPARATOR);
1772
+ const level = pathParts.length - 1;
1773
+ const [open, onOpenChange] = useControllableState3({
1774
+ prop: propsOpen,
1775
+ onChange: propsOnOpenChange,
1776
+ defaultProp: defaultOpen
1939
1777
  });
1940
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
1941
- ...menuScope,
1942
- virtualRef
1778
+ const focusableGroupAttrs = useFocusableGroup({
1779
+ tabBehavior: "limited"
1943
1780
  });
1944
- };
1945
- DropdownMenuVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME;
1946
- var PORTAL_NAME = "DropdownMenuPortal";
1947
- var DropdownMenuPortal = (props) => {
1948
- const { __scopeDropdownMenu, ...portalProps } = props;
1949
- const menuScope = useMenuScope(__scopeDropdownMenu);
1950
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Portal, {
1951
- ...menuScope,
1952
- ...portalProps
1781
+ const arrowGroupAttrs = useArrowNavigationGroup({
1782
+ axis: "horizontal",
1783
+ tabbable: false,
1784
+ circular: false,
1785
+ memorizeCurrent: false
1953
1786
  });
1954
- };
1955
- DropdownMenuPortal.displayName = PORTAL_NAME;
1956
- var DropdownMenuViewport = /* @__PURE__ */ forwardRef19(({ classNames, asChild, children, ...props }, forwardedRef) => {
1787
+ return /* @__PURE__ */ React26.createElement(TreegridRowProvider, {
1788
+ open,
1789
+ onOpenChange,
1790
+ scope: __treegridRowScope
1791
+ }, /* @__PURE__ */ React26.createElement(Root5, {
1792
+ role: "row",
1793
+ "aria-level": level,
1794
+ className: tx("treegrid.row", "treegrid__row", {
1795
+ level
1796
+ }, classNames),
1797
+ ...parentOf && {
1798
+ "aria-expanded": open,
1799
+ "aria-owns": parentOf
1800
+ },
1801
+ tabIndex: 0,
1802
+ ...focusableGroupAttrs,
1803
+ ...props,
1804
+ id,
1805
+ ref: forwardedRef
1806
+ }, /* @__PURE__ */ React26.createElement("div", {
1807
+ role: "none",
1808
+ className: "contents",
1809
+ ...arrowGroupAttrs
1810
+ }, children)));
1811
+ });
1812
+ var TreegridCell = /* @__PURE__ */ forwardRef18(({ classNames, children, indent, ...props }, forwardedRef) => {
1957
1813
  const { tx } = useThemeContext();
1958
- const Root5 = asChild ? Slot10 : Primitive9.div;
1959
- return /* @__PURE__ */ React27.createElement(Root5, {
1814
+ return /* @__PURE__ */ React26.createElement("div", {
1815
+ role: "gridcell",
1816
+ className: tx("treegrid.cell", "treegrid__cell", {
1817
+ indent
1818
+ }, classNames),
1960
1819
  ...props,
1961
- className: tx("menu.viewport", "menu__viewport", {}, classNames),
1962
1820
  ref: forwardedRef
1963
1821
  }, children);
1964
1822
  });
1965
- var CONTENT_NAME = "DropdownMenuContent";
1966
- var DropdownMenuContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
1967
- const { __scopeDropdownMenu, classNames, collisionPadding = 8, ...contentProps } = props;
1968
- const { tx } = useThemeContext();
1969
- const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
1970
- const elevation = useElevationContext();
1971
- const menuScope = useMenuScope(__scopeDropdownMenu);
1972
- const hasInteractedOutsideRef = useRef2(false);
1973
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
1974
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Content, {
1975
- id: context.contentId,
1976
- "aria-labelledby": context.triggerId,
1977
- ...menuScope,
1978
- ...contentProps,
1979
- collisionPadding: safeCollisionPadding,
1980
- ref: forwardedRef,
1981
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
1982
- if (!hasInteractedOutsideRef.current) {
1983
- context.triggerRef.current?.focus();
1823
+ var Treegrid = {
1824
+ Root: TreegridRoot,
1825
+ Row: TreegridRow,
1826
+ Cell: TreegridCell,
1827
+ PARENT_OF_SEPARATOR,
1828
+ PATH_SEPARATOR,
1829
+ createTreegridRowScope,
1830
+ useTreegridRowContext
1831
+ };
1832
+
1833
+ // packages/ui/react-ui/src/components/Main/Main.tsx
1834
+ import { createContext as createContext10 } from "@radix-ui/react-context";
1835
+ import { Root as DialogRoot2, DialogContent as DialogContent2, DialogTitle as DialogTitle2 } from "@radix-ui/react-dialog";
1836
+ import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
1837
+ import { Slot as Slot10 } from "@radix-ui/react-slot";
1838
+ import { useControllableState as useControllableState4 } from "@radix-ui/react-use-controllable-state";
1839
+ import React27, { forwardRef as forwardRef19, useCallback as useCallback7, useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
1840
+ import { log } from "@dxos/log";
1841
+ import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
1842
+
1843
+ // packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
1844
+ import { useCallback as useCallback6, useEffect as useEffect4, useState as useState7 } from "react";
1845
+ var MotionState;
1846
+ (function(MotionState2) {
1847
+ MotionState2[MotionState2["IDLE"] = 0] = "IDLE";
1848
+ MotionState2[MotionState2["DEBOUNCING"] = 1] = "DEBOUNCING";
1849
+ MotionState2[MotionState2["FOLLOWING"] = 2] = "FOLLOWING";
1850
+ })(MotionState || (MotionState = {}));
1851
+ var useSwipeToDismiss = (ref, {
1852
+ onDismiss,
1853
+ dismissThreshold = 64,
1854
+ debounceThreshold = 8,
1855
+ offset = 0
1856
+ /* side = 'inline-start' */
1857
+ }) => {
1858
+ const $root = ref.current;
1859
+ const [motionState, setMotionState] = useState7(0);
1860
+ const [gestureStartX, setGestureStartX] = useState7(0);
1861
+ const setIdle = useCallback6(() => {
1862
+ setMotionState(0);
1863
+ $root?.style.removeProperty("inset-inline-start");
1864
+ $root?.style.setProperty("transition-duration", "200ms");
1865
+ }, [
1866
+ $root
1867
+ ]);
1868
+ const setFollowing = useCallback6(() => {
1869
+ setMotionState(2);
1870
+ $root?.style.setProperty("transition-duration", "0ms");
1871
+ }, [
1872
+ $root
1873
+ ]);
1874
+ const handlePointerDown = useCallback6(({ screenX }) => {
1875
+ if (motionState === 0) {
1876
+ setMotionState(1);
1877
+ setGestureStartX(screenX);
1878
+ }
1879
+ }, [
1880
+ motionState
1881
+ ]);
1882
+ const handlePointerMove = useCallback6(({ screenX }) => {
1883
+ if ($root) {
1884
+ const delta = Math.min(screenX - gestureStartX, 0);
1885
+ switch (motionState) {
1886
+ case 2:
1887
+ if (Math.abs(delta) > dismissThreshold) {
1888
+ setIdle();
1889
+ onDismiss?.();
1890
+ } else {
1891
+ $root.style.setProperty("inset-inline-start", `${offset + delta}px`);
1892
+ }
1893
+ break;
1894
+ case 1:
1895
+ if (Math.abs(delta) > debounceThreshold) {
1896
+ setFollowing();
1897
+ }
1898
+ break;
1984
1899
  }
1985
- hasInteractedOutsideRef.current = false;
1900
+ }
1901
+ }, [
1902
+ $root,
1903
+ motionState,
1904
+ gestureStartX
1905
+ ]);
1906
+ const handlePointerUp = useCallback6(() => {
1907
+ setIdle();
1908
+ }, [
1909
+ setIdle
1910
+ ]);
1911
+ useEffect4(() => {
1912
+ $root?.addEventListener("pointerdown", handlePointerDown);
1913
+ return () => {
1914
+ $root?.removeEventListener("pointerdown", handlePointerDown);
1915
+ };
1916
+ }, [
1917
+ $root,
1918
+ handlePointerDown
1919
+ ]);
1920
+ useEffect4(() => {
1921
+ $root && document.documentElement.addEventListener("pointermove", handlePointerMove);
1922
+ return () => {
1923
+ document.documentElement.removeEventListener("pointermove", handlePointerMove);
1924
+ };
1925
+ }, [
1926
+ $root,
1927
+ handlePointerMove
1928
+ ]);
1929
+ useEffect4(() => {
1930
+ $root && document.documentElement.addEventListener("pointerup", handlePointerUp);
1931
+ return () => {
1932
+ document.documentElement.removeEventListener("pointerup", handlePointerUp);
1933
+ };
1934
+ }, [
1935
+ $root,
1936
+ handlePointerUp
1937
+ ]);
1938
+ };
1939
+
1940
+ // packages/ui/react-ui/src/components/Main/Main.tsx
1941
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui/src/components/Main/Main.tsx";
1942
+ var MAIN_ROOT_NAME = "MainRoot";
1943
+ var NAVIGATION_SIDEBAR_NAME = "NavigationSidebar";
1944
+ var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
1945
+ var MAIN_NAME = "Main";
1946
+ var GENERIC_CONSUMER_NAME = "GenericConsumer";
1947
+ var landmarkAttr = "data-main-landmark";
1948
+ var useLandmarkMover = (propsOnKeyDown, landmark) => {
1949
+ const handleKeyDown = useCallback7((event) => {
1950
+ const target = event.target;
1951
+ if (event.target === event.currentTarget && event.key === "Tab" && target.hasAttribute(landmarkAttr)) {
1986
1952
  event.preventDefault();
1987
- }),
1988
- onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
1989
- const originalEvent = event.detail.originalEvent;
1990
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
1991
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
1992
- if (!context.modal || isRightClick) {
1993
- hasInteractedOutsideRef.current = true;
1994
- }
1995
- }),
1996
- className: tx("menu.content", "menu", {
1997
- elevation
1998
- }, classNames),
1999
- style: {
2000
- ...props.style,
2001
- // re-namespace exposed content custom properties
2002
- ...{
2003
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
2004
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
2005
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
2006
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
2007
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
2008
- }
1953
+ const landmarks = Array.from(document.querySelectorAll(`[${landmarkAttr}]:not([inert])`)).map((el) => el.hasAttribute(landmarkAttr) ? parseInt(el.getAttribute(landmarkAttr)) : NaN).sort();
1954
+ const l = landmarks.length;
1955
+ const cursor = landmarks.indexOf(parseInt(target.getAttribute(landmarkAttr)));
1956
+ const nextLandmark = landmarks[(cursor + l + (event.getModifierState("Shift") ? -1 : 1)) % l];
1957
+ document.querySelector(`[${landmarkAttr}="${nextLandmark}"]`)?.focus();
2009
1958
  }
2010
- });
2011
- });
2012
- DropdownMenuContent.displayName = CONTENT_NAME;
2013
- var GROUP_NAME = "DropdownMenuGroup";
2014
- var DropdownMenuGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2015
- const { __scopeDropdownMenu, ...groupProps } = props;
2016
- const menuScope = useMenuScope(__scopeDropdownMenu);
2017
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Group, {
2018
- ...menuScope,
2019
- ...groupProps,
2020
- ref: forwardedRef
2021
- });
1959
+ propsOnKeyDown?.(event);
1960
+ }, [
1961
+ propsOnKeyDown
1962
+ ]);
1963
+ const focusableGroupAttrs = window ? {} : {
1964
+ tabBehavior: "limited",
1965
+ ignoreDefaultKeydown: {
1966
+ Tab: true
1967
+ }
1968
+ };
1969
+ return {
1970
+ onKeyDown: handleKeyDown,
1971
+ [landmarkAttr]: landmark,
1972
+ tabIndex: 0,
1973
+ ...focusableGroupAttrs
1974
+ };
1975
+ };
1976
+ var [MainProvider, useMainContext] = createContext10(MAIN_NAME, {
1977
+ resizing: false,
1978
+ navigationSidebarState: "closed",
1979
+ setNavigationSidebarState: (nextState) => {
1980
+ log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
1981
+ F: __dxlog_file,
1982
+ L: 82,
1983
+ S: void 0,
1984
+ C: (f, a) => f(...a)
1985
+ });
1986
+ },
1987
+ complementarySidebarState: "closed",
1988
+ setComplementarySidebarState: (nextState) => {
1989
+ log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
1990
+ F: __dxlog_file,
1991
+ L: 87,
1992
+ S: void 0,
1993
+ C: (f, a) => f(...a)
1994
+ });
1995
+ }
2022
1996
  });
2023
- DropdownMenuGroup.displayName = GROUP_NAME;
2024
- var LABEL_NAME = "DropdownMenuLabel";
2025
- var DropdownMenuGroupLabel = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2026
- const { __scopeDropdownMenu, classNames, ...labelProps } = props;
2027
- const menuScope = useMenuScope(__scopeDropdownMenu);
2028
- const { tx } = useThemeContext();
2029
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Label, {
2030
- ...menuScope,
2031
- ...labelProps,
2032
- className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
2033
- ref: forwardedRef
1997
+ var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
1998
+ const { setNavigationSidebarState, navigationSidebarState, setComplementarySidebarState, complementarySidebarState } = useMainContext(consumerName);
1999
+ return {
2000
+ navigationSidebarState,
2001
+ setNavigationSidebarState,
2002
+ toggleNavigationSidebar: useCallback7(() => setNavigationSidebarState(navigationSidebarState === "expanded" ? "closed" : "expanded"), [
2003
+ navigationSidebarState,
2004
+ setNavigationSidebarState
2005
+ ]),
2006
+ openNavigationSidebar: useCallback7(() => setNavigationSidebarState("expanded"), []),
2007
+ collapseNavigationSidebar: useCallback7(() => setNavigationSidebarState("collapsed"), []),
2008
+ closeNavigationSidebar: useCallback7(() => setNavigationSidebarState("closed"), []),
2009
+ complementarySidebarState,
2010
+ setComplementarySidebarState,
2011
+ toggleComplementarySidebar: useCallback7(() => setComplementarySidebarState(complementarySidebarState === "expanded" ? "closed" : "expanded"), [
2012
+ complementarySidebarState,
2013
+ setComplementarySidebarState
2014
+ ]),
2015
+ openComplementarySidebar: useCallback7(() => setComplementarySidebarState("expanded"), []),
2016
+ collapseComplementarySidebar: useCallback7(() => setComplementarySidebarState("collapsed"), []),
2017
+ closeComplementarySidebar: useCallback7(() => setComplementarySidebarState("closed"), [])
2018
+ };
2019
+ };
2020
+ var resizeDebounce = 3e3;
2021
+ var MainRoot = ({ navigationSidebarState: propsNavigationSidebarState, defaultNavigationSidebarState, onNavigationSidebarStateChange, complementarySidebarState: propsComplementarySidebarState, defaultComplementarySidebarState, onComplementarySidebarStateChange, children, ...props }) => {
2022
+ const [isLg] = useMediaQuery("lg", {
2023
+ ssr: false
2034
2024
  });
2035
- });
2036
- DropdownMenuGroupLabel.displayName = LABEL_NAME;
2037
- var ITEM_NAME = "DropdownMenuItem";
2038
- var DropdownMenuItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2039
- const { __scopeDropdownMenu, classNames, ...itemProps } = props;
2040
- const menuScope = useMenuScope(__scopeDropdownMenu);
2041
- const { tx } = useThemeContext();
2042
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Item, {
2043
- ...menuScope,
2044
- ...itemProps,
2045
- className: tx("menu.item", "menu__item", {}, classNames),
2046
- ref: forwardedRef
2025
+ const [navigationSidebarState = isLg ? "expanded" : "collapsed", setNavigationSidebarState] = useControllableState4({
2026
+ prop: propsNavigationSidebarState,
2027
+ defaultProp: defaultNavigationSidebarState,
2028
+ onChange: onNavigationSidebarStateChange
2047
2029
  });
2048
- });
2049
- DropdownMenuItem.displayName = ITEM_NAME;
2050
- var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
2051
- var DropdownMenuCheckboxItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2052
- const { __scopeDropdownMenu, classNames, ...checkboxItemProps } = props;
2053
- const menuScope = useMenuScope(__scopeDropdownMenu);
2054
- const { tx } = useThemeContext();
2055
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.CheckboxItem, {
2056
- ...menuScope,
2057
- ...checkboxItemProps,
2058
- className: tx("menu.item", "menu__item--checkbox", {}, classNames),
2059
- ref: forwardedRef
2030
+ const [complementarySidebarState = isLg ? "expanded" : "collapsed", setComplementarySidebarState] = useControllableState4({
2031
+ prop: propsComplementarySidebarState,
2032
+ defaultProp: defaultComplementarySidebarState,
2033
+ onChange: onComplementarySidebarStateChange
2060
2034
  });
2061
- });
2062
- DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
2063
- var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
2064
- var DropdownMenuRadioGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2065
- const { __scopeDropdownMenu, ...radioGroupProps } = props;
2066
- const menuScope = useMenuScope(__scopeDropdownMenu);
2067
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.RadioGroup, {
2068
- ...menuScope,
2069
- ...radioGroupProps,
2070
- ref: forwardedRef
2035
+ const [resizing, setResizing] = useState8(false);
2036
+ const resizeInterval = useRef2(null);
2037
+ const handleResize = useCallback7(() => {
2038
+ setResizing(true);
2039
+ if (resizeInterval.current) {
2040
+ clearTimeout(resizeInterval.current);
2041
+ }
2042
+ resizeInterval.current = setTimeout(() => {
2043
+ setResizing(false);
2044
+ resizeInterval.current = null;
2045
+ }, resizeDebounce);
2046
+ }, []);
2047
+ useEffect5(() => {
2048
+ window.addEventListener("resize", handleResize);
2049
+ return () => window.removeEventListener("resize", handleResize);
2050
+ }, [
2051
+ handleResize
2052
+ ]);
2053
+ return /* @__PURE__ */ React27.createElement(MainProvider, {
2054
+ ...props,
2055
+ navigationSidebarState,
2056
+ setNavigationSidebarState,
2057
+ complementarySidebarState,
2058
+ setComplementarySidebarState,
2059
+ resizing
2060
+ }, children);
2061
+ };
2062
+ MainRoot.displayName = MAIN_ROOT_NAME;
2063
+ var handleOpenAutoFocus = (event) => {
2064
+ !document.body.hasAttribute("data-is-keyboard") && event.preventDefault();
2065
+ };
2066
+ var MainSidebar = /* @__PURE__ */ forwardRef19(({ classNames, children, swipeToDismiss, onOpenAutoFocus, state, resizing, onStateChange, side, label, ...props }, forwardedRef) => {
2067
+ const [isLg] = useMediaQuery("lg", {
2068
+ ssr: false
2071
2069
  });
2072
- });
2073
- DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
2074
- var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
2075
- var DropdownMenuRadioItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2076
- const { __scopeDropdownMenu, ...radioItemProps } = props;
2077
- const menuScope = useMenuScope(__scopeDropdownMenu);
2078
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.RadioItem, {
2079
- ...menuScope,
2080
- ...radioItemProps,
2081
- ref: forwardedRef
2070
+ const { tx } = useThemeContext();
2071
+ const { t } = useTranslation();
2072
+ const ref = useForwardedRef(forwardedRef);
2073
+ const noopRef = useRef2(null);
2074
+ useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
2075
+ onDismiss: () => onStateChange?.("closed")
2082
2076
  });
2077
+ const handleKeyDown = useCallback7((event) => {
2078
+ if (event.key === "Escape") {
2079
+ event.target.closest("[data-tabster]")?.focus();
2080
+ }
2081
+ props.onKeyDown?.(event);
2082
+ }, [
2083
+ props.onKeyDown
2084
+ ]);
2085
+ const Root5 = isLg ? Primitive9.div : DialogContent2;
2086
+ return /* @__PURE__ */ React27.createElement(DialogRoot2, {
2087
+ open: state !== "closed",
2088
+ "aria-label": toLocalizedString(label, t),
2089
+ modal: false
2090
+ }, !isLg && /* @__PURE__ */ React27.createElement(DialogTitle2, {
2091
+ className: "sr-only"
2092
+ }, toLocalizedString(label, t)), /* @__PURE__ */ React27.createElement(Root5, {
2093
+ ...!isLg && {
2094
+ forceMount: true,
2095
+ tabIndex: -1,
2096
+ onOpenAutoFocus: onOpenAutoFocus ?? handleOpenAutoFocus
2097
+ },
2098
+ ...props,
2099
+ "data-side": side === "inline-end" ? "ie" : "is",
2100
+ "data-state": state,
2101
+ "data-resizing": resizing ? "true" : "false",
2102
+ className: tx("main.sidebar", "main__sidebar", {}, classNames),
2103
+ onKeyDown: handleKeyDown,
2104
+ ...state === "closed" && {
2105
+ inert: "true"
2106
+ },
2107
+ ref
2108
+ }, children));
2083
2109
  });
2084
- DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
2085
- var INDICATOR_NAME = "DropdownMenuItemIndicator";
2086
- var DropdownMenuItemIndicator = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2087
- const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
2088
- const menuScope = useMenuScope(__scopeDropdownMenu);
2089
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.ItemIndicator, {
2090
- ...menuScope,
2091
- ...itemIndicatorProps,
2110
+ var MainNavigationSidebar = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2111
+ const { navigationSidebarState, setNavigationSidebarState, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
2112
+ const mover = useLandmarkMover(props.onKeyDown, "0");
2113
+ return /* @__PURE__ */ React27.createElement(MainSidebar, {
2114
+ ...mover,
2115
+ ...props,
2116
+ state: navigationSidebarState,
2117
+ onStateChange: setNavigationSidebarState,
2118
+ resizing,
2119
+ side: "inline-start",
2092
2120
  ref: forwardedRef
2093
2121
  });
2094
2122
  });
2095
- DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
2096
- var SEPARATOR_NAME = "DropdownMenuSeparator";
2097
- var DropdownMenuSeparator = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2098
- const { __scopeDropdownMenu, classNames, ...separatorProps } = props;
2099
- const menuScope = useMenuScope(__scopeDropdownMenu);
2100
- const { tx } = useThemeContext();
2101
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Separator, {
2102
- ...menuScope,
2103
- ...separatorProps,
2104
- className: tx("menu.separator", "menu__item", {}, classNames),
2123
+ MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
2124
+ var MainComplementarySidebar = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2125
+ const { complementarySidebarState, setComplementarySidebarState, resizing } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
2126
+ const mover = useLandmarkMover(props.onKeyDown, "2");
2127
+ return /* @__PURE__ */ React27.createElement(MainSidebar, {
2128
+ ...mover,
2129
+ ...props,
2130
+ state: complementarySidebarState,
2131
+ onStateChange: setComplementarySidebarState,
2132
+ resizing,
2133
+ side: "inline-end",
2105
2134
  ref: forwardedRef
2106
2135
  });
2107
2136
  });
2108
- DropdownMenuSeparator.displayName = SEPARATOR_NAME;
2109
- var ARROW_NAME = "DropdownMenuArrow";
2110
- var DropdownMenuArrow = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2111
- const { __scopeDropdownMenu, classNames, ...arrowProps } = props;
2112
- const menuScope = useMenuScope(__scopeDropdownMenu);
2137
+ MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
2138
+ var MainContent = /* @__PURE__ */ forwardRef19(({ asChild, classNames, bounce, handlesFocus, children, role, ...props }, forwardedRef) => {
2139
+ const { navigationSidebarState, complementarySidebarState } = useMainContext(MAIN_NAME);
2113
2140
  const { tx } = useThemeContext();
2114
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Arrow, {
2115
- ...menuScope,
2116
- ...arrowProps,
2117
- className: tx("menu.arrow", "menu__arrow", {}, classNames),
2141
+ const Root5 = asChild ? Slot10 : role ? "div" : "main";
2142
+ const mover = useLandmarkMover(props.onKeyDown, "1");
2143
+ return /* @__PURE__ */ React27.createElement(Root5, {
2144
+ role,
2145
+ ...handlesFocus && {
2146
+ ...mover
2147
+ },
2148
+ ...props,
2149
+ "data-sidebar-inline-start-state": navigationSidebarState,
2150
+ "data-sidebar-inline-end-state": complementarySidebarState,
2151
+ className: tx("main.content", "main", {
2152
+ bounce,
2153
+ handlesFocus
2154
+ }, classNames),
2118
2155
  ref: forwardedRef
2119
- });
2156
+ }, children);
2120
2157
  });
2121
- DropdownMenuArrow.displayName = ARROW_NAME;
2122
- var DropdownMenuSub = (props) => {
2123
- const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
2124
- const menuScope = useMenuScope(__scopeDropdownMenu);
2125
- const [open = false, setOpen] = useControllableState4({
2126
- prop: openProp,
2127
- defaultProp: defaultOpen,
2128
- onChange: onOpenChange
2158
+ MainContent.displayName = MAIN_NAME;
2159
+ var MainOverlay = /* @__PURE__ */ forwardRef19(({ classNames, ...props }, forwardedRef) => {
2160
+ const [isLg] = useMediaQuery("lg", {
2161
+ ssr: false
2129
2162
  });
2130
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Sub, {
2131
- ...menuScope,
2132
- open,
2133
- onOpenChange: setOpen
2134
- }, children);
2135
- };
2136
- var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
2137
- var DropdownMenuSubTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2138
- const { __scopeDropdownMenu, ...subTriggerProps } = props;
2139
- const menuScope = useMenuScope(__scopeDropdownMenu);
2140
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.SubTrigger, {
2141
- ...menuScope,
2142
- ...subTriggerProps,
2163
+ const { navigationSidebarState, setNavigationSidebarState, complementarySidebarState, setComplementarySidebarState } = useMainContext(MAIN_NAME);
2164
+ const { tx } = useThemeContext();
2165
+ return /* @__PURE__ */ React27.createElement("div", {
2166
+ onClick: () => {
2167
+ setNavigationSidebarState("collapsed");
2168
+ setComplementarySidebarState("collapsed");
2169
+ },
2170
+ ...props,
2171
+ className: tx("main.overlay", "main__overlay", {
2172
+ isLg,
2173
+ inlineStartSidebarOpen: navigationSidebarState,
2174
+ inlineEndSidebarOpen: complementarySidebarState
2175
+ }, classNames),
2176
+ "data-state": navigationSidebarState === "expanded" || complementarySidebarState === "expanded" ? "open" : "closed",
2177
+ "aria-hidden": "true",
2143
2178
  ref: forwardedRef
2144
2179
  });
2145
2180
  });
2146
- DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
2147
- var SUB_CONTENT_NAME = "DropdownMenuSubContent";
2148
- var DropdownMenuSubContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2149
- const { __scopeDropdownMenu, ...subContentProps } = props;
2150
- const menuScope = useMenuScope(__scopeDropdownMenu);
2151
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.SubContent, {
2152
- ...menuScope,
2153
- ...subContentProps,
2154
- ref: forwardedRef,
2155
- style: {
2156
- ...props.style,
2157
- // re-namespace exposed content custom properties
2158
- ...{
2159
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
2160
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
2161
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
2162
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
2163
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
2164
- }
2165
- }
2166
- });
2167
- });
2168
- DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
2169
- var DropdownMenu = {
2170
- Root: DropdownMenuRoot,
2171
- Trigger: DropdownMenuTrigger,
2172
- VirtualTrigger: DropdownMenuVirtualTrigger,
2173
- Portal: DropdownMenuPortal,
2174
- Content: DropdownMenuContent,
2175
- Viewport: DropdownMenuViewport,
2176
- Group: DropdownMenuGroup,
2177
- GroupLabel: DropdownMenuGroupLabel,
2178
- Item: DropdownMenuItem,
2179
- CheckboxItem: DropdownMenuCheckboxItem,
2180
- RadioGroup: DropdownMenuRadioGroup,
2181
- RadioItem: DropdownMenuRadioItem,
2182
- ItemIndicator: DropdownMenuItemIndicator,
2183
- Separator: DropdownMenuSeparator,
2184
- Arrow: DropdownMenuArrow,
2185
- Sub: DropdownMenuSub,
2186
- SubTrigger: DropdownMenuSubTrigger,
2187
- SubContent: DropdownMenuSubContent
2181
+ var Main = {
2182
+ Root: MainRoot,
2183
+ Content: MainContent,
2184
+ Overlay: MainOverlay,
2185
+ NavigationSidebar: MainNavigationSidebar,
2186
+ ComplementarySidebar: MainComplementarySidebar
2188
2187
  };
2189
- var useDropdownMenuMenuScope = useMenuScope;
2190
2188
 
2191
2189
  // packages/ui/react-ui/src/components/Message/Message.tsx
2192
2190
  import { createContext as createContext11 } from "@radix-ui/react-context";