@sanity/ui 0.36.16 → 0.37.2

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.
@@ -40,6 +40,8 @@ export interface AutocompleteProps<Option extends BaseAutocompleteOption> {
40
40
  content: React.ReactElement | null;
41
41
  hidden: boolean;
42
42
  inputElement: HTMLInputElement | null;
43
+ onMouseEnter: () => void;
44
+ onMouseLeave: () => void;
43
45
  }, ref: React.Ref<HTMLDivElement>) => React.ReactNode;
44
46
  renderValue?: (value: string, option?: Option) => string;
45
47
  suffix?: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,KASN,MAAM,OAAO,CAAA;AAId,OAAO,EAAM,QAAQ,EAAgB,YAAY,EAAyB,MAAM,kBAAkB,CAAA;AAWlG,OAAO,EAAC,2BAA2B,EAAE,sBAAsB,EAAC,MAAM,SAAS,CAAA;AAE3E;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,sBAAsB;IACtE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAA;IACzD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC5B,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,SAAS,CAAA;IAC5C,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IA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AE,CAAA;IAC/B,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,YAAY,CAAA;IACrD;;OAEG;IACH,aAAa,CAAC,EAAE,CACd,KAAK,EAAE;QACL,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;QAClC,MAAM,EAAE,OAAO,CAAA;QACf,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAA;QACrC,YAAY,EAAE,MAAM,IAAI,CAAA;QACxB,YAAY,EAAE,MAAM,IAAI,CAAA;KACzB,EACD,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,KAC3B,KAAK,CAAC,SAAS,CAAA;IACpB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACxD,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AA8jBD;;GAEG;AACH,eAAO,MAAM,YAAY;;MAyBpB,MAAM,YAAY,CAAA"}
@@ -24,5 +24,5 @@ export interface MenuProps extends ResponsivePaddingProps {
24
24
  /**
25
25
  * @public
26
26
  */
27
- export declare const Menu: React.ForwardRefExoticComponent<Pick<MenuProps & Omit<React.HTMLProps<HTMLDivElement>, "as" | "height" | "tabIndex" | "role">, "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "content" | "controls" | "coords" | "crossOrigin" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "target" | "type" | "useMap" | "value" | "width" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | keyof MenuProps> & React.RefAttributes<unknown>>;
27
+ export declare const Menu: React.ForwardRefExoticComponent<Pick<MenuProps & Omit<React.HTMLProps<HTMLDivElement>, "as" | "height" | "tabIndex" | "role">, "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "content" | "controls" | "coords" | "crossOrigin" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "target" | "type" | "useMap" | "value" | "width" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | keyof MenuProps> & React.RefAttributes<HTMLDivElement>>;
28
28
  //# sourceMappingURL=menu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAA;AAI1F,OAAO,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAA;AAK7D;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,sBAAsB;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IAC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A"}
@@ -7,9 +7,17 @@ export interface MenuContextValue {
7
7
  onClickOutside?: (event: MouseEvent) => void;
8
8
  onEscape?: () => void;
9
9
  onItemClick?: () => void;
10
+ onItemMouseEnter?: (event: React.MouseEvent<HTMLElement>) => void;
11
+ onItemMouseLeave?: (event: React.MouseEvent<HTMLElement>) => void;
12
+ registerElement?: (el: HTMLElement) => () => void;
13
+ /**
14
+ * @deprecated Use `onItemMouseEnter` instead
15
+ */
10
16
  onMouseEnter: (event: React.MouseEvent<HTMLElement>) => void;
17
+ /**
18
+ * @deprecated Use `onItemMouseLeave` instead
19
+ */
11
20
  onMouseLeave: (event: React.MouseEvent<HTMLElement>) => void;
12
- registerElement?: (el: HTMLElement) => () => void;
13
21
  }
14
22
  export declare const MenuContext: React.Context<MenuContextValue | null>;
15
23
  //# sourceMappingURL=menuContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"menuContext.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menuContext.ts"],"names":[],"mappings":";AAGA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,GAAG,CAAA;IACZ,aAAa,EAAE,WAAW,GAAG,IAAI,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,MAAM,IAAI,CAAA;IACtE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;IAC5D,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;IAC5D,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,MAAM,IAAI,CAAA;CAClD;AAMD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAoB,CAAA"}
1
+ {"version":3,"file":"menuContext.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menuContext.ts"],"names":[],"mappings":";AAGA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,GAAG,CAAA;IACZ,aAAa,EAAE,WAAW,GAAG,IAAI,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,MAAM,IAAI,CAAA;IACtE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;IACjE,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;IACjE,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,MAAM,IAAI,CAAA;IAEjD;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;CAC7D;AAMD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAoB,CAAA"}
@@ -7,9 +7,11 @@ import { SelectableTone } from '../../types/selectable';
7
7
  export interface MenuGroupProps {
8
8
  as?: React.ElementType | keyof JSX.IntrinsicElements;
9
9
  fontSize?: number | number[];
10
+ icon?: React.ComponentType | React.ReactNode;
10
11
  padding?: number | number[];
11
12
  popover?: Omit<PopoverProps, 'content' | 'open'>;
12
13
  radius?: number | number[];
14
+ space?: number | number[];
13
15
  text: React.ReactNode;
14
16
  tone?: SelectableTone;
15
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"menuGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menuGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiD,MAAM,OAAO,CAAA;AAErE,OAAO,EAAe,YAAY,EAAO,MAAM,kBAAkB,CAAA;AAEjE,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AAIrD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAA;IACpD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC,CAAA;IAChD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB;AAeD;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,cAAc,GACnB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAC,GAC5E,KAAK,CAAC,YAAY,CAoLpB"}
1
+ {"version":3,"file":"menuGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menuGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAA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EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,iLA6InB,CAAA"}
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface MenuController {
6
+ activeElement: HTMLElement | null;
7
+ activeIndex: number;
8
+ handleItemMouseEnter: (event: React.MouseEvent<HTMLElement>) => void;
9
+ handleItemMouseLeave: () => void;
10
+ handleKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void;
11
+ mount: (element: HTMLElement | null, selected?: boolean) => () => void;
12
+ rootElement: HTMLDivElement | null;
13
+ setRootElement: (el: HTMLDivElement | null) => void;
14
+ }
15
+ /**
16
+ * This controller is responsible for controlling UI menu state.
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function useMenuController(props: {
21
+ onKeyDown?: React.KeyboardEventHandler;
22
+ originElement?: HTMLElement | null;
23
+ shouldFocus: 'first' | 'last' | null;
24
+ }): MenuController;
25
+ //# sourceMappingURL=useMenuController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuController.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/useMenuController.ts"],"names":[],"mappings":";AAGA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,WAAW,GAAG,IAAI,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,oBAAoB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAA;IACpE,oBAAoB,EAAE,MAAM,IAAI,CAAA;IAChC,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IACnE,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,MAAM,IAAI,CAAA;IACtE,WAAW,EAAE,cAAc,GAAG,IAAI,CAAA;IAClC,cAAc,EAAE,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAA;CACpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAA;IACtC,aAAa,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;CACrC,GAAG,cAAc,CAoNjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "0.36.16",
3
+ "version": "0.37.2",
4
4
  "sideEffects": false,
5
5
  "source": "src/index.ts",
6
6
  "exports": {
@@ -29,11 +29,11 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@juggle/resize-observer": "^3.3.1",
32
- "@popperjs/core": "^2.10.2",
32
+ "@popperjs/core": "^2.11.2",
33
33
  "@reach/auto-id": "^0.16.0",
34
34
  "@sanity/color": "^2.1.6",
35
- "@sanity/icons": "^1.2.2",
36
- "framer-motion": "5.3.3",
35
+ "@sanity/icons": "^1.2.3",
36
+ "framer-motion": "5.5.5",
37
37
  "lodash": "^4.17.21",
38
38
  "popper-max-size-modifier": "^0.2.0",
39
39
  "react-is": "^17.0.2",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@testing-library/dom": "^8.11.1",
45
- "@testing-library/jest-dom": "^5.15.1",
45
+ "@testing-library/jest-dom": "^5.16.1",
46
46
  "@testing-library/react": "^12.1.2",
47
47
  "@types/refractor": "^3.0.2",
48
48
  "react": "^17.0.2",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "ae8fa191ffc390ff27427d393451a181c381c399"
74
+ "gitHead": "4aa7b389d7379a58ed02977022ec00f7e0114711"
75
75
  }
@@ -81,13 +81,22 @@ export default function Fullscreen() {
81
81
  }, [])
82
82
 
83
83
  const renderPopover = useCallback(
84
- (props: {content: React.ReactNode; hidden: boolean}, ref: React.Ref<HTMLDivElement>) => {
84
+ (
85
+ props: {
86
+ content: React.ReactNode
87
+ hidden: boolean
88
+ onMouseEnter: () => void
89
+ onMouseLeave: () => void
90
+ },
91
+ ref: React.Ref<HTMLDivElement>
92
+ ) => {
85
93
  if (!props.hidden && error) {
86
94
  return (
87
95
  <Portal>
88
96
  <Card
97
+ onMouseEnter={props.onMouseEnter}
98
+ onMouseLeave={props.onMouseLeave}
89
99
  padding={4}
90
- scheme="light"
91
100
  style={{position: 'absolute', inset: '0 0 0 0'}}
92
101
  tone="critical"
93
102
  >
@@ -104,7 +113,12 @@ export default function Fullscreen() {
104
113
  if (!props.hidden && query && !loading && options.length === 0) {
105
114
  return (
106
115
  <Portal>
107
- <Card padding={4} scheme="light" style={{position: 'absolute', inset: '0 0 0 0'}}>
116
+ <Card
117
+ onMouseEnter={props.onMouseEnter}
118
+ onMouseLeave={props.onMouseLeave}
119
+ padding={4}
120
+ style={{position: 'absolute', inset: '0 0 0 0'}}
121
+ >
108
122
  <Flex align="center" height="fill" justify="center">
109
123
  <Text align="center" muted>
110
124
  No results for <strong>‘{query}’</strong>
@@ -117,7 +131,12 @@ export default function Fullscreen() {
117
131
 
118
132
  return (
119
133
  <Portal>
120
- <Card hidden={props.hidden} ref={ref} scheme="light">
134
+ <Card
135
+ hidden={props.hidden}
136
+ onMouseEnter={props.onMouseEnter}
137
+ onMouseLeave={props.onMouseLeave}
138
+ ref={ref}
139
+ >
121
140
  {props.content}
122
141
  </Card>
123
142
  </Portal>
@@ -158,7 +177,7 @@ export default function Fullscreen() {
158
177
  <Card style={{display: 'flex', flexDirection: 'column', minHeight: '100%'}} tone="transparent">
159
178
  <PortalProvider element={portalElement}>
160
179
  <Flex direction="column" flex={1} height="fill">
161
- <Card hidden={open} padding={2} scheme="dark">
180
+ <Card hidden={open} padding={2}>
162
181
  <Flex align="center">
163
182
  <Box flex={1} />
164
183
  <Button
@@ -65,6 +65,8 @@ export interface AutocompleteProps<Option extends BaseAutocompleteOption> {
65
65
  content: React.ReactElement | null
66
66
  hidden: boolean
67
67
  inputElement: HTMLInputElement | null
68
+ onMouseEnter: () => void
69
+ onMouseLeave: () => void
68
70
  },
69
71
  ref: React.Ref<HTMLDivElement>
70
72
  ) => React.ReactNode
@@ -586,7 +588,13 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
586
588
  const results = useMemo(() => {
587
589
  if (renderPopover) {
588
590
  return renderPopover(
589
- {content, hidden: !expanded, inputElement: inputElementRef.current},
591
+ {
592
+ content,
593
+ hidden: !expanded,
594
+ inputElement: inputElementRef.current,
595
+ onMouseEnter: handlePopoverMouseEnter,
596
+ onMouseLeave: handlePopoverMouseLeave,
597
+ },
590
598
  setResultsPopoverElement
591
599
  )
592
600
  }
@@ -22,6 +22,11 @@ export default defineScope('components/menu', 'Menu', [
22
22
  title: 'Groups',
23
23
  component: lazy(() => import('./groups')),
24
24
  },
25
+ {
26
+ name: 'menu-group-right',
27
+ title: 'Menu group (right)',
28
+ component: lazy(() => import('./menuGroupRight')),
29
+ },
25
30
  {
26
31
  name: 'tones',
27
32
  title: 'Tones',
@@ -0,0 +1,59 @@
1
+ import {
2
+ AddIcon,
3
+ BookIcon,
4
+ CopyIcon,
5
+ EllipsisVerticalIcon,
6
+ ImageIcon,
7
+ TrashIcon,
8
+ } from '@sanity/icons'
9
+ import {
10
+ Box,
11
+ Button,
12
+ Card,
13
+ Container,
14
+ Flex,
15
+ Menu,
16
+ MenuButton,
17
+ MenuDivider,
18
+ MenuGroup,
19
+ MenuItem,
20
+ } from '@sanity/ui'
21
+ import React from 'react'
22
+
23
+ export default function MenuGroupRightStory() {
24
+ return (
25
+ <Card height="fill" tone="transparent">
26
+ <Flex align="center" height="fill" padding={4} sizing="border">
27
+ <Container width={1}>
28
+ <Card padding={2} radius={2} shadow={2}>
29
+ <Flex>
30
+ <Box flex={1} />
31
+ <Box>
32
+ <MenuButton
33
+ button={<Button icon={EllipsisVerticalIcon} mode="bleed" />}
34
+ id="right-menu"
35
+ menu={
36
+ <Menu>
37
+ <MenuGroup icon={AddIcon} popover={{placement: 'left'}} text="Add above">
38
+ <MenuItem icon={ImageIcon} text="Image" />
39
+ <MenuItem icon={BookIcon} text="Book" />
40
+ </MenuGroup>
41
+ <MenuGroup icon={AddIcon} popover={{placement: 'left'}} text="Add below">
42
+ <MenuItem icon={ImageIcon} text="Image" />
43
+ <MenuItem icon={BookIcon} text="Book" />
44
+ </MenuGroup>
45
+ <MenuDivider />
46
+ <MenuItem icon={CopyIcon} text="Duplicate" />
47
+ <MenuItem icon={TrashIcon} text="Remove" tone="critical" />
48
+ </Menu>
49
+ }
50
+ popover={{placement: 'right', portal: true}}
51
+ />
52
+ </Box>
53
+ </Flex>
54
+ </Card>
55
+ </Container>
56
+ </Flex>
57
+ </Card>
58
+ )
59
+ }
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
- import React from 'react'
3
+ import React, {useCallback, useMemo} from 'react'
4
4
  import {render} from '../../../test'
5
5
  import {MenuContext, MenuContextValue} from './menuContext'
6
6
  import {useMenu} from './useMenu'
@@ -19,15 +19,30 @@ describe('components/menu', () => {
19
19
  }
20
20
 
21
21
  function Root() {
22
- const value: MenuContextValue = {
23
- version: 0.0,
24
- activeElement: null,
25
- activeIndex: 0,
26
- mount: (element: HTMLElement | null) => () => console.log(element),
27
- onItemClick: () => undefined,
28
- onMouseEnter: (event: React.MouseEvent<HTMLElement>) => console.log(event),
29
- onMouseLeave: (event: React.MouseEvent<HTMLElement>) => console.log(event),
30
- }
22
+ const handleItemMouseEnter = useCallback(
23
+ (event: React.MouseEvent<HTMLElement>) => console.log(event),
24
+ []
25
+ )
26
+
27
+ const handleItemMouseLeave = useCallback(
28
+ (event: React.MouseEvent<HTMLElement>) => console.log(event),
29
+ []
30
+ )
31
+
32
+ const value: MenuContextValue = useMemo(
33
+ () => ({
34
+ version: 0.0,
35
+ activeElement: null,
36
+ activeIndex: 0,
37
+ mount: (element: HTMLElement | null) => () => console.log(element),
38
+ onItemClick: () => undefined,
39
+ onItemMouseEnter: handleItemMouseEnter,
40
+ onItemMouseLeave: handleItemMouseLeave,
41
+ onMouseEnter: handleItemMouseEnter,
42
+ onMouseLeave: handleItemMouseLeave,
43
+ }),
44
+ [handleItemMouseEnter, handleItemMouseLeave]
45
+ )
31
46
 
32
47
  return (
33
48
  <MenuContext.Provider value={value}>
@@ -38,12 +53,14 @@ describe('components/menu', () => {
38
53
 
39
54
  render(<Root />)
40
55
 
41
- expect(log.mock.calls[0][0].version).toBe(0.0)
42
- expect(log.mock.calls[0][0].activeIndex).toBe(0)
43
- expect(typeof log.mock.calls[0][0].mount).toBe('function')
44
- expect(typeof log.mock.calls[0][0].onItemClick).toBe('function')
45
- expect(typeof log.mock.calls[0][0].onMouseEnter).toBe('function')
46
- expect(typeof log.mock.calls[0][0].onMouseLeave).toBe('function')
56
+ const contextValue = log.mock.calls[0][0]
57
+
58
+ expect(contextValue.version).toBe(0.0)
59
+ expect(contextValue.activeIndex).toBe(0)
60
+ expect(typeof contextValue.mount).toBe('function')
61
+ expect(typeof contextValue.onItemClick).toBe('function')
62
+ expect(typeof contextValue.onItemMouseEnter).toBe('function')
63
+ expect(typeof contextValue.onItemMouseEnter).toBe('function')
47
64
  })
48
65
 
49
66
  it('should fail when no context value is provided', async () => {
@@ -60,10 +77,11 @@ describe('components/menu', () => {
60
77
  }
61
78
 
62
79
  function Root() {
63
- const value = undefined
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ const value: any = undefined
64
82
 
65
83
  return (
66
- <MenuContext.Provider value={value as any}>
84
+ <MenuContext.Provider value={value}>
67
85
  <Debug />
68
86
  </MenuContext.Provider>
69
87
  )
@@ -89,12 +107,13 @@ describe('components/menu', () => {
89
107
 
90
108
  function Root() {
91
109
  // NOTE: we’re testing this because the context value may be a function in the future
92
- const value = () => {
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ const value: any = () => {
93
112
  return {version: 1}
94
113
  }
95
114
 
96
115
  return (
97
- <MenuContext.Provider value={value as any}>
116
+ <MenuContext.Provider value={value}>
98
117
  <Debug />
99
118
  </MenuContext.Provider>
100
119
  )