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