@radix-ui/react-menu
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -7,6 +7,5 @@ import * as React from "react"; | ||
import * as Polymorphic from "@radix-ui/react-polymorphic"; | ||
import { Merge } from "@radix-ui/utils"; | ||
type FocusScopeProps = React.ComponentProps<typeof FocusScope>; | ||
type DismissableLayerProps = React.ComponentProps<typeof DismissableLayer>; | ||
type MenuOwnProps = Merge<Polymorphic.OwnProps<typeof MenuImpl>, { | ||
type MenuOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof MenuImpl>, { | ||
open?: boolean; | ||
@@ -21,3 +20,3 @@ /** | ||
export const Menu: MenuPrimitive; | ||
type MenuImplOwnProps = Merge<Polymorphic.OwnProps<typeof PopperPrimitive.Root>, { | ||
type MenuImplOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof PopperPrimitive.Root>, { | ||
open: boolean; | ||
@@ -86,6 +85,3 @@ onOpenChange?: (open: boolean) => void; | ||
export const MenuGroup: MenuGroupPrimitive; | ||
type MenuLabelOwnProps = Polymorphic.OwnProps<typeof Primitive>; | ||
type MenuLabelPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Primitive>, MenuLabelOwnProps>; | ||
export const MenuLabel: MenuLabelPrimitive; | ||
type MenuItemOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
type MenuItemOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
disabled?: boolean; | ||
@@ -97,3 +93,3 @@ textValue?: string; | ||
export const MenuItem: MenuItemPrimitive; | ||
type MenuCheckboxItemOwnProps = Merge<Polymorphic.OwnProps<typeof MenuItem>, { | ||
type MenuCheckboxItemOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof MenuItem>, { | ||
checked?: boolean; | ||
@@ -104,3 +100,3 @@ onCheckedChange?: (checked: boolean) => void; | ||
export const MenuCheckboxItem: MenyCheckboxItemPrimitive; | ||
type MenuRadioGroupOwnProps = Merge<Polymorphic.OwnProps<typeof MenuGroup>, { | ||
type MenuRadioGroupOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof MenuGroup>, { | ||
value?: string; | ||
@@ -111,3 +107,3 @@ onValueChange?: (value: string) => void; | ||
export const MenuRadioGroup: MenuRadioGroupPrimitive; | ||
type MenuRadioItemOwnProps = Merge<Polymorphic.OwnProps<typeof MenuItem>, { | ||
type MenuRadioItemOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof MenuItem>, { | ||
value: string; | ||
@@ -118,3 +114,3 @@ }>; | ||
declare const ITEM_INDICATOR_DEFAULT_TAG = "span"; | ||
type MenuItemIndicatorOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
type MenuItemIndicatorOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
/** | ||
@@ -131,5 +127,4 @@ * Used to force mounting when more control is needed. Useful when | ||
export const MenuSeparator: MenuSeparatorPrimitive; | ||
export const MenuArrow: Polymorphic.ForwardRefComponent<"svg", Merge<{ | ||
selector?: string | null | undefined; | ||
}, { | ||
export const MenuLabel: Polymorphic.ForwardRefComponent<"div", {}>; | ||
export const MenuArrow: Polymorphic.ForwardRefComponent<"svg", Polymorphic.Merge<{}, { | ||
offset?: number | undefined; | ||
@@ -139,3 +134,3 @@ }>>; | ||
export const Group: MenuGroupPrimitive; | ||
export const Label: MenuLabelPrimitive; | ||
export const Label: Polymorphic.ForwardRefComponent<"div", {}>; | ||
export const Item: MenuItemPrimitive; | ||
@@ -147,5 +142,3 @@ export const CheckboxItem: MenyCheckboxItemPrimitive; | ||
export const Separator: MenuSeparatorPrimitive; | ||
export const Arrow: Polymorphic.ForwardRefComponent<"svg", Merge<{ | ||
selector?: string | null | undefined; | ||
}, { | ||
export const Arrow: Polymorphic.ForwardRefComponent<"svg", Polymorphic.Merge<{}, { | ||
offset?: number | undefined; | ||
@@ -152,0 +145,0 @@ }>>; |
@@ -1,2 +0,2 @@ | ||
var e=require("aria-hidden").hideOthers,r=require("react-remove-scroll").RemoveScroll,t=require("@radix-ui/react-focus-guards").useFocusGuards,n=require("@radix-ui/react-portal").Portal,o=require("@radix-ui/react-focus-scope").FocusScope,u=require("@radix-ui/react-dismissable-layer").DismissableLayer,a=g({},require("@radix-ui/react-popper")),c=require("@radix-ui/react-roving-focus"),i=c.RovingFocusGroup,l=c.useRovingFocus,s=require("@radix-ui/react-primitive").Primitive,f=require("@radix-ui/react-presence").Presence,d=require("@radix-ui/utils"),p=d.getSelector,v=d.wrapArray,m=require("@radix-ui/react-utils"),y=m.composeEventHandlers,b=m.composeRefs,h=m.createContext,w=m.extendComponent,M=m.useCallbackRef,O=m.useComposedRefs,x=g({},require("react"));function g(e,r){return Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e}function C(){var e=x.useRef(0),r=x.useRef(""),t=x.useCallback((function(n){r.current=n,window.clearTimeout(e.current),e.current=window.setTimeout((function(){return t("")}),1e3)}),[]);return{onKeyDownCapture:function(e){if(1===e.key.length&&!(e.ctrlKey||e.altKey||e.metaKey)){var n=e.currentTarget;t(r.current+e.key)," "!==e.key||r.current.startsWith(" ")||e.stopPropagation();var o=document.activeElement,u=o?E(o):void 0,a=function(e,r,t){var n=r.length>1&&Array.from(r).every((function(e){return e===r[0]}))?r[0]:r,o=t?e.indexOf(t):-1,u=v(e,Math.max(o,0));1===n.length&&(u=u.filter((function(e){return e!==t})));var a=u.find((function(e){return e.toLowerCase().startsWith(n.toLowerCase())}));return a!==t?a:void 0}(Array.from(n.querySelectorAll("[".concat(D,"]"))).map(E),r.current,u),c=n.querySelector("[".concat(D,'="').concat(a,'"]'));c&&setTimeout((function(){return c.focus()}))}}}}var E=function(e){var r;return null!==(r=e.getAttribute(D))&&void 0!==r?r:""},D="data-".concat(p("MenuTypeaheadItem"));function P(e){var r,t,n,o=e.textValue,u=e.disabled;return n=u?void 0:o,(t=D)in(r={})?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function R(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function S(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?R(Object(t),!0).forEach((function(r){k(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):R(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function k(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function I(){return(I=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function F(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},u=Object.keys(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function j(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,u=void 0;try{for(var a,c=e[Symbol.iterator]();!(n=(a=c.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw u}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return A(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return A(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var q=["ArrowDown","PageUp","Home"],K=[].concat(q,["ArrowUp","PageDown","End"]),L=j(h("MenuContext","Menu"),2),G=L[0],T=L[1],N=x.forwardRef((function(e,r){var t=e.forceMount,n=e.open,o=void 0!==n&&n,u=F(e,["forceMount","open"]);return x.createElement(f,{present:t||o},x.createElement(V,I({ref:r},u,{open:o,"data-state":re(o)})))}));exports.Menu=N;var V=x.forwardRef((function(c,l){var s=c.selector,f=void 0===s?p("Menu"):s,d=c.open,v=c.onOpenChange,m=c.anchorRef,h=c.loop,w=c.trapFocus,O=c.onOpenAutoFocus,g=c.onCloseAutoFocus,E=c.disableOutsidePointerEvents,D=c.onEscapeKeyDown,P=c.onPointerDownOutside,R=c.onFocusOutside,k=c.onInteractOutside,A=c.onDismiss,L=c.disableOutsideScroll,T=c.portalled,N=F(c,["selector","open","onOpenChange","anchorRef","loop","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","disableOutsideScroll","portalled"]),V=M(v),U=x.useRef(null),B=j(x.useState(0),2),H=B[0],_=B[1],z=j(x.useState(!1),2),$=z[0],J=z[1],Q=C(),X=x.useMemo((function(){return{menuRef:U,setItemsReachable:J,onOpenChange:V}}),[V]);x.useEffect((function(){_($?-1:0)}),[$]);var Y=j(x.useState(!1),2),Z=Y[0],ee=Y[1],re=T?n:x.Fragment,te=L?r:x.Fragment;return t(),x.useEffect((function(){var r=U.current;if(r)return e(r)}),[]),x.createElement(re,null,x.createElement(te,null,x.createElement(G.Provider,{value:X},x.createElement(i,{reachable:$,onReachableChange:J,orientation:"vertical",loop:h},x.createElement(o,{trapped:!Z&&(w&&d),onMountAutoFocus:O,onUnmountAutoFocus:function(e){Z?e.preventDefault():null==g||g(e)}},(function(e){return x.createElement(u,{disableOutsidePointerEvents:E,onEscapeKeyDown:D,onPointerDownOutside:y(P,(function(e){var r=0===e.button&&!1===e.ctrlKey;ee(!E&&r),e.defaultPrevented&&ee(!1)}),{checkForDefaultPrevented:!1}),onFocusOutside:y(R,(function(e){w&&e.preventDefault()}),{checkForDefaultPrevented:!1}),onInteractOutside:k,onDismiss:A},(function(r){return x.createElement(a.Root,I({role:"menu"},N,{selector:f,ref:b(l,U,e.ref,r.ref),anchorRef:m,tabIndex:H,style:S(S({},r.style),{},{outline:"none"},N.style),onBlurCapture:y(N.onBlurCapture,r.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:y(N.onFocusCapture,r.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:y(N.onMouseDownCapture,r.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:y(N.onTouchStartCapture,r.onTouchStartCapture,{checkForDefaultPrevented:!1}),onKeyDownCapture:y(N.onKeyDownCapture,Q.onKeyDownCapture),onKeyDown:y(N.onKeyDown,(function(e){var r=U.current;if(e.target===r&&K.includes(e.key)){e.preventDefault();var t=Array.from(r.querySelectorAll(W)),n=q.includes(e.key)?t[0]:t.reverse()[0];null==n||n.focus()}}))}))}))}))))))}));N.displayName="Menu";var U=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuGroup"):t,o=F(e,["selector"]);return x.createElement(s,I({role:"group"},o,{selector:n,ref:r}))}));exports.MenuGroup=U,U.displayName="MenuGroup";var B=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuLabel"):t,o=F(e,["selector"]);return x.createElement(s,I({},o,{selector:n,ref:r}))}));exports.MenuLabel=B,B.displayName="MenuLabel";var H="data-".concat(p("MenuItem")),W="[".concat(H,"]:not([data-disabled])"),_=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuItem"):t,o=e.disabled,u=e.textValue,a=e.onSelect,c=F(e,["selector","disabled","textValue","onSelect"]),i=x.useRef(null),f=O(r,i),d=T("MenuItem"),v=l({disabled:o}),m=j(x.useState(""),2),b=m[0],h=m[1];x.useEffect((function(){var e,r=i.current;r&&h((null!==(e=r.textContent)&&void 0!==e?e:"").trim())}),[c.children]);var w=P({textValue:null!=u?u:b,disabled:o}),M=function(){var e=i.current;if(!o&&e){var r,t=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});if(e.dispatchEvent(t),t.defaultPrevented)return;null===(r=d.onOpenChange)||void 0===r||r.call(d,!1)}};return x.useEffect((function(){var e=i.current;if(e){var r=function(e){return null==a?void 0:a(e)};return e.addEventListener("menu.itemSelect",r),function(){return e.removeEventListener("menu.itemSelect",r)}}}),[a]),x.createElement(s,I({role:"menuitem","aria-disabled":o||void 0},c,v,w,k({},H,""),{selector:n,ref:f,"data-disabled":o?"":void 0,onFocus:y(c.onFocus,v.onFocus),onKeyDown:y(c.onKeyDown,y(v.onKeyDown,(function(e){o||"Enter"!==e.key&&" "!==e.key||M()}))),onMouseDown:y(c.onMouseDown,v.onMouseDown),onMouseUp:y(c.onMouseUp,M),onMouseMove:y(c.onMouseMove,(function(e){o||e.currentTarget.focus()})),onBlur:y(c.onBlur,(function(e){d.setItemsReachable(!1)})),onMouseLeave:y(c.onMouseLeave,(function(e){var r;null===(r=d.menuRef.current)||void 0===r||r.focus()}))}))}));exports.MenuItem=_,_.displayName="MenuItem";var z=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuCheckboxItem"):t,o=e.checked,u=void 0!==o&&o,a=e.onCheckedChange,c=F(e,["selector","checked","onCheckedChange"]);return x.createElement(X.Provider,{value:u},x.createElement(_,I({role:"menuitemcheckbox","aria-checked":u},c,{selector:n,ref:r,"data-state":te(u),onSelect:y(c.onSelect,(function(){return null==a?void 0:a(!u)}),{checkForDefaultPrevented:!1})})))}));exports.MenuCheckboxItem=z,z.displayName="MenuCheckboxItem";var $=x.createContext({}),J=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuRadioGroup"):t,o=e.value,u=e.onValueChange,a=F(e,["selector","value","onValueChange"]),c=M(u),i=x.useMemo((function(){return{value:o,onValueChange:c}}),[o,c]);return x.createElement($.Provider,{value:i},x.createElement(U,I({},a,{selector:n,ref:r})))}));exports.MenuRadioGroup=J,J.displayName="MenuRadioGroup";var Q=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuRadioItem"):t,o=e.value,u=F(e,["selector","value"]),a=x.useContext($),c=o===a.value;return x.createElement(X.Provider,{value:c},x.createElement(_,I({role:"menuitemradio","aria-checked":c},u,{selector:n,ref:r,"data-state":te(c),onSelect:y(u.onSelect,(function(){var e;return null===(e=a.onValueChange)||void 0===e?void 0:e.call(a,o)}),{checkForDefaultPrevented:!1})})))}));exports.MenuRadioItem=Q,Q.displayName="MenuRadioItem";var X=x.createContext(!1),Y=x.forwardRef((function(e,r){var t=e.as,n=void 0===t?"span":t,o=e.selector,u=void 0===o?p("MenuItemIndicator"):o,a=e.forceMount,c=F(e,["as","selector","forceMount"]),i=x.useContext(X);return x.createElement(f,{present:a||i},x.createElement(s,I({},c,{as:n,selector:u,ref:r,"data-state":te(i)})))}));exports.MenuItemIndicator=Y,Y.displayName="MenuItemIndicator";var Z=x.forwardRef((function(e,r){var t=e.selector,n=void 0===t?p("MenuSeparator"):t,o=F(e,["selector"]);return x.createElement(s,I({role:"separator","aria-orientation":"horizontal"},o,{selector:n,ref:r}))}));exports.MenuSeparator=Z,Z.displayName="MenuSeparator";var ee=w(a.Arrow,"MenuArrow");function re(e){return e?"open":"closed"}function te(e){return e?"checked":"unchecked"}exports.MenuArrow=ee;var ne=N;exports.Root=ne;var oe=U;exports.Group=oe;var ue=B;exports.Label=ue;var ae=_;exports.Item=ae;var ce=z;exports.CheckboxItem=ce;var ie=J;exports.RadioGroup=ie;var le=Q;exports.RadioItem=le;var se=Y;exports.ItemIndicator=se;var fe=Z;exports.Separator=fe;var de=ee;exports.Arrow=de; | ||
var e=require("aria-hidden").hideOthers,r=require("react-remove-scroll").RemoveScroll,t=require("@radix-ui/react-focus-guards").useFocusGuards,n=require("@radix-ui/react-portal").Portal,o=require("@radix-ui/react-focus-scope").FocusScope,a=require("@radix-ui/react-dismissable-layer").DismissableLayer,u=O({},require("@radix-ui/react-popper")),c=require("@radix-ui/react-roving-focus"),i=c.RovingFocusGroup,l=c.useRovingFocus,s=require("@radix-ui/react-primitive"),f=s.Primitive,d=s.extendPrimitive,p=require("@radix-ui/react-presence").Presence,v=require("@radix-ui/react-use-callback-ref").useCallbackRef,m=require("@radix-ui/react-context").createContext,y=require("@radix-ui/react-compose-refs"),b=y.composeRefs,h=y.useComposedRefs,w=require("@radix-ui/primitive").composeEventHandlers,x=O({},require("react"));function O(e,r){return Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e}function g(){var e=x.useRef(0),r=x.useRef(""),t=x.useCallback((function(n){r.current=n,window.clearTimeout(e.current),e.current=window.setTimeout((function(){return t("")}),1e3)}),[]);return{onKeyDownCapture:function(e){if(1===e.key.length&&!(e.ctrlKey||e.altKey||e.metaKey)){var n=e.currentTarget;t(r.current+e.key)," "!==e.key||r.current.startsWith(" ")||e.stopPropagation();var o=document.activeElement,a=o?C(o):void 0,u=function(e,r,t){var n=r.length>1&&Array.from(r).every((function(e){return e===r[0]}))?r[0]:r,o=t?e.indexOf(t):-1,a=(u=e,c=Math.max(o,0),u.map((function(e,r){return u[(c+r)%u.length]})));var u,c;1===n.length&&(a=a.filter((function(e){return e!==t})));var i=a.find((function(e){return e.toLowerCase().startsWith(n.toLowerCase())}));return i!==t?i:void 0}(Array.from(n.querySelectorAll("[".concat(M,"]"))).map(C),r.current,a),c=n.querySelector("[".concat(M,'="').concat(u,'"]'));c&&setTimeout((function(){return c.focus()}))}}}}var C=function(e){var r;return null!==(r=e.getAttribute(M))&&void 0!==r?r:""},M="data-radix-menu-typeahead-item";function E(e){var r,t,n,o=e.textValue,a=e.disabled;return n=a?void 0:o,(t=M)in(r={})?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function D(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function P(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?D(Object(t),!0).forEach((function(r){S(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):D(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function S(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function R(){return(R=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function k(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function F(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var u,c=e[Symbol.iterator]();!(n=(u=c.next()).done)&&(t.push(u.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw a}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return I(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var j=["ArrowDown","PageUp","Home"],A=[].concat(j,["ArrowUp","PageDown","End"]),q=F(m("Menu"),2),K=q[0],L=q[1],T=x.forwardRef((function(e,r){var t=e.forceMount,n=e.open,o=void 0!==n&&n,a=k(e,["forceMount","open"]);return x.createElement(p,{present:t||o},x.createElement(G,R({"data-state":Y(o)},a,{ref:r,open:o})))}));exports.Menu=T;var G=x.forwardRef((function(c,l){var s=c.open,f=c.onOpenChange,d=c.anchorRef,p=c.loop,m=c.trapFocus,y=c.onOpenAutoFocus,h=c.onCloseAutoFocus,O=c.disableOutsidePointerEvents,C=c.onEscapeKeyDown,M=c.onPointerDownOutside,E=c.onFocusOutside,D=c.onInteractOutside,S=c.onDismiss,I=c.disableOutsideScroll,q=c.portalled,L=k(c,["open","onOpenChange","anchorRef","loop","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","disableOutsideScroll","portalled"]),T=v(f),G=x.useRef(null),N=F(x.useState(0),2),U=N[0],B=N[1],H=F(x.useState(!1),2),W=H[0],_=H[1],z=g();x.useEffect((function(){B(W?-1:0)}),[W]);var $=F(x.useState(!1),2),J=$[0],Q=$[1],X=q?n:x.Fragment,Y=I?r:x.Fragment;return t(),x.useEffect((function(){var r=G.current;if(r)return e(r)}),[]),x.createElement(X,null,x.createElement(Y,null,x.createElement(K,{menuRef:G,onItemsReachableChange:_,onOpenChange:T},x.createElement(i,{reachable:W,onReachableChange:_,orientation:"vertical",loop:p},x.createElement(o,{trapped:!J&&(m&&s),onMountAutoFocus:y,onUnmountAutoFocus:function(e){J?e.preventDefault():null==h||h(e)}},(function(e){return x.createElement(a,{disableOutsidePointerEvents:O,onEscapeKeyDown:C,onPointerDownOutside:w(M,(function(e){var r=0===e.button&&!1===e.ctrlKey;Q(!O&&r),e.defaultPrevented&&Q(!1)}),{checkForDefaultPrevented:!1}),onFocusOutside:w(E,(function(e){m&&e.preventDefault()}),{checkForDefaultPrevented:!1}),onInteractOutside:D,onDismiss:S},(function(r){return x.createElement(u.Root,R({role:"menu"},L,{ref:b(l,G,e.ref,r.ref),anchorRef:d,tabIndex:U,style:P(P({},r.style),{},{outline:"none"},L.style),onBlurCapture:w(L.onBlurCapture,r.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:w(L.onFocusCapture,r.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:w(L.onMouseDownCapture,r.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:w(L.onTouchStartCapture,r.onTouchStartCapture,{checkForDefaultPrevented:!1}),onKeyDownCapture:w(L.onKeyDownCapture,z.onKeyDownCapture),onKeyDown:w(L.onKeyDown,(function(e){var r=G.current;if(e.target===r&&A.includes(e.key)){e.preventDefault();var t=Array.from(r.querySelectorAll(V)),n=j.includes(e.key)?t[0]:t.reverse()[0];null==n||n.focus()}}))}))}))}))))))}));T.displayName="Menu";var N=x.forwardRef((function(e,r){return x.createElement(f,R({role:"group"},e,{ref:r}))}));exports.MenuGroup=N,N.displayName="MenuGroup";var V="[".concat("data-radix-menu-item","]:not([data-disabled])"),U=x.forwardRef((function(e,r){var t=e.disabled,n=e.textValue,o=e.onSelect,a=k(e,["disabled","textValue","onSelect"]),u=x.useRef(null),c=h(r,u),i=L("MenuItem"),s=l({disabled:t}),d=F(x.useState(""),2),p=d[0],v=d[1];x.useEffect((function(){var e,r=u.current;r&&v((null!==(e=r.textContent)&&void 0!==e?e:"").trim())}),[a.children]);var m=E({textValue:null!=n?n:p,disabled:t}),y=function(){var e=u.current;if(!t&&e){var r,n=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});if(e.dispatchEvent(n),n.defaultPrevented)return;null===(r=i.onOpenChange)||void 0===r||r.call(i,!1)}};return x.useEffect((function(){var e=u.current;if(e){var r=function(e){return null==o?void 0:o(e)};return e.addEventListener("menu.itemSelect",r),function(){return e.removeEventListener("menu.itemSelect",r)}}}),[o]),x.createElement(f,R({role:"menuitem","aria-disabled":t||void 0},a,s,m,S({},"data-radix-menu-item",""),{ref:c,"data-disabled":t?"":void 0,onFocus:w(a.onFocus,s.onFocus),onKeyDown:w(a.onKeyDown,w(s.onKeyDown,(function(e){t||"Enter"!==e.key&&" "!==e.key||y()}))),onMouseDown:w(a.onMouseDown,s.onMouseDown),onMouseUp:w(a.onMouseUp,y),onMouseMove:w(a.onMouseMove,(function(e){t||e.currentTarget.focus()})),onBlur:w(a.onBlur,(function(e){i.onItemsReachableChange(!1)})),onMouseLeave:w(a.onMouseLeave,(function(e){var r;null===(r=i.menuRef.current)||void 0===r||r.focus()}))}))}));exports.MenuItem=U,U.displayName="MenuItem";var B=x.forwardRef((function(e,r){var t=e.checked,n=void 0!==t&&t,o=e.onCheckedChange,a=k(e,["checked","onCheckedChange"]);return x.createElement(z.Provider,{value:n},x.createElement(U,R({role:"menuitemcheckbox","aria-checked":n},a,{ref:r,"data-state":Z(n),onSelect:w(a.onSelect,(function(){return null==o?void 0:o(!n)}),{checkForDefaultPrevented:!1})})))}));exports.MenuCheckboxItem=B,B.displayName="MenuCheckboxItem";var H=x.createContext({}),W=x.forwardRef((function(e,r){var t=e.value,n=e.onValueChange,o=k(e,["value","onValueChange"]),a=v(n),u=x.useMemo((function(){return{value:t,onValueChange:a}}),[t,a]);return x.createElement(H.Provider,{value:u},x.createElement(N,R({},o,{ref:r})))}));exports.MenuRadioGroup=W,W.displayName="MenuRadioGroup";var _=x.forwardRef((function(e,r){var t=e.value,n=k(e,["value"]),o=x.useContext(H),a=t===o.value;return x.createElement(z.Provider,{value:a},x.createElement(U,R({role:"menuitemradio","aria-checked":a},n,{ref:r,"data-state":Z(a),onSelect:w(n.onSelect,(function(){var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,t)}),{checkForDefaultPrevented:!1})})))}));exports.MenuRadioItem=_,_.displayName="MenuRadioItem";var z=x.createContext(!1),$=x.forwardRef((function(e,r){var t=e.as,n=void 0===t?"span":t,o=e.forceMount,a=k(e,["as","forceMount"]),u=x.useContext(z);return x.createElement(p,{present:o||u},x.createElement(f,R({},a,{as:n,ref:r,"data-state":Z(u)})))}));exports.MenuItemIndicator=$,$.displayName="MenuItemIndicator";var J=x.forwardRef((function(e,r){return x.createElement(f,R({role:"separator","aria-orientation":"horizontal"},e,{ref:r}))}));exports.MenuSeparator=J,J.displayName="MenuSeparator";var Q=d(f,"MenuLabel");exports.MenuLabel=Q;var X=d(u.Arrow,"MenuArrow");function Y(e){return e?"open":"closed"}function Z(e){return e?"checked":"unchecked"}exports.MenuArrow=X;var ee=T;exports.Root=ee;var re=N;exports.Group=re;var te=Q;exports.Label=te;var ne=U;exports.Item=ne;var oe=B;exports.CheckboxItem=oe;var ae=W;exports.RadioGroup=ae;var ue=_;exports.RadioItem=ue;var ce=$;exports.ItemIndicator=ce;var ie=J;exports.Separator=ie;var le=X;exports.Arrow=le; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{hideOthers as e}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as o}from"@radix-ui/react-focus-guards";import{Portal as r}from"@radix-ui/react-portal";import{FocusScope as n}from"@radix-ui/react-focus-scope";import{DismissableLayer as a}from"@radix-ui/react-dismissable-layer";import*as c from"@radix-ui/react-popper";import{RovingFocusGroup as u,useRovingFocus as s}from"@radix-ui/react-roving-focus";import{Primitive as l}from"@radix-ui/react-primitive";import{Presence as i}from"@radix-ui/react-presence";import{getSelector as d,wrapArray as p}from"@radix-ui/utils";import{composeEventHandlers as f,composeRefs as m,createContext as v,extendComponent as y,useCallbackRef as M,useComposedRefs as b}from"@radix-ui/react-utils";import*as h from"react";function w(){const e=h.useRef(0),t=h.useRef(""),o=h.useCallback((r=>{t.current=r,window.clearTimeout(e.current),e.current=window.setTimeout((()=>o("")),1e3)}),[]);return{onKeyDownCapture:e=>{if(1===e.key.length&&!(e.ctrlKey||e.altKey||e.metaKey)){const r=e.currentTarget;o(t.current+e.key)," "!==e.key||t.current.startsWith(" ")||e.stopPropagation();const n=document.activeElement,a=n?x(n):void 0,c=function(e,t,o){const r=t.length>1&&Array.from(t).every((e=>e===t[0]))?t[0]:t,n=o?e.indexOf(o):-1;let a=p(e,Math.max(n,0));1===r.length&&(a=a.filter((e=>e!==o)));const c=a.find((e=>e.toLowerCase().startsWith(r.toLowerCase())));return c!==o?c:void 0}(Array.from(r.querySelectorAll("[".concat(O,"]"))).map(x),t.current,a),u=r.querySelector("[".concat(O,'="').concat(c,'"]'));u&&setTimeout((()=>u.focus()))}}}}const x=e=>{var t;return null!==(t=e.getAttribute(O))&&void 0!==t?t:""},O="data-".concat(d("MenuTypeaheadItem"));function C(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function D(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?C(Object(o),!0).forEach((function(t){E(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):C(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function E(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function g(){return(g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function I(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},a=Object.keys(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}const P=["ArrowDown","PageUp","Home"],R=[...P,"ArrowUp","PageDown","End"],k="Menu",[S,F]=v(k+"Context",k);export const Menu=h.forwardRef(((e,t)=>{const{forceMount:o,open:r=!1}=e,n=I(e,["forceMount","open"]);return h.createElement(i,{present:o||r},h.createElement(A,g({ref:t},n,{open:r,"data-state":J(r)})))}));const A=h.forwardRef(((s,l)=>{const{selector:i=d(k),open:p,onOpenChange:v,anchorRef:y,loop:b,trapFocus:x,onOpenAutoFocus:O,onCloseAutoFocus:C,disableOutsidePointerEvents:E,onEscapeKeyDown:F,onPointerDownOutside:A,onFocusOutside:j,onInteractOutside:K,onDismiss:G,disableOutsideScroll:L,portalled:T}=s,V=I(s,["selector","open","onOpenChange","anchorRef","loop","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","disableOutsideScroll","portalled"]),B=M(v),U=h.useRef(null),[q,W]=h.useState(0),[z,H]=h.useState(!1),J=w(),Q=h.useMemo((()=>({menuRef:U,setItemsReachable:H,onOpenChange:B})),[B]);h.useEffect((()=>{W(z?-1:0)}),[z]);const[X,Y]=h.useState(!1),Z=T?r:h.Fragment,$=L?t:h.Fragment;return o(),h.useEffect((()=>{const t=U.current;if(t)return e(t)}),[]),h.createElement(Z,null,h.createElement($,null,h.createElement(S.Provider,{value:Q},h.createElement(u,{reachable:z,onReachableChange:H,orientation:"vertical",loop:b},h.createElement(n,{trapped:!X&&(x&&p),onMountAutoFocus:O,onUnmountAutoFocus:e=>{X?e.preventDefault():null==C||C(e)}},(e=>h.createElement(a,{disableOutsidePointerEvents:E,onEscapeKeyDown:F,onPointerDownOutside:f(A,(e=>{const t=0===e.button&&!1===e.ctrlKey;Y(!E&&t),e.defaultPrevented&&Y(!1)}),{checkForDefaultPrevented:!1}),onFocusOutside:f(j,(e=>{x&&e.preventDefault()}),{checkForDefaultPrevented:!1}),onInteractOutside:K,onDismiss:G},(t=>h.createElement(c.Root,g({role:"menu"},V,{selector:i,ref:m(l,U,e.ref,t.ref),anchorRef:y,tabIndex:q,style:D(D({},t.style),{},{outline:"none"},V.style),onBlurCapture:f(V.onBlurCapture,t.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:f(V.onFocusCapture,t.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:f(V.onMouseDownCapture,t.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:f(V.onTouchStartCapture,t.onTouchStartCapture,{checkForDefaultPrevented:!1}),onKeyDownCapture:f(V.onKeyDownCapture,J.onKeyDownCapture),onKeyDown:f(V.onKeyDown,(e=>{const t=U.current;if(e.target===t&&R.includes(e.key)){e.preventDefault();const o=Array.from(t.querySelectorAll(N)),r=P.includes(e.key)?o[0]:o.reverse()[0];null==r||r.focus()}}))}))))))))))}));Menu.displayName=k;const j="MenuGroup";export const MenuGroup=h.forwardRef(((e,t)=>{const{selector:o=d(j)}=e,r=I(e,["selector"]);return h.createElement(l,g({role:"group"},r,{selector:o,ref:t}))}));MenuGroup.displayName=j;const K="MenuLabel";export const MenuLabel=h.forwardRef(((e,t)=>{const{selector:o=d(K)}=e,r=I(e,["selector"]);return h.createElement(l,g({},r,{selector:o,ref:t}))}));MenuLabel.displayName=K;const G="MenuItem",L="data-".concat(d(G)),N="[".concat(L,"]:not([data-disabled])");export const MenuItem=h.forwardRef(((e,t)=>{const{selector:o=d(G),disabled:r,textValue:n,onSelect:a}=e,c=I(e,["selector","disabled","textValue","onSelect"]),u=h.useRef(null),i=b(t,u),p=F(G),m=s({disabled:r}),[v,y]=h.useState("");h.useEffect((()=>{const e=u.current;var t;e&&y((null!==(t=e.textContent)&&void 0!==t?t:"").trim())}),[c.children]);const M=function({textValue:e,disabled:t}){return{[O]:t?void 0:e}}({textValue:null!=n?n:v,disabled:r}),w=()=>{const e=u.current;if(!r&&e){var t;const o=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});if(e.dispatchEvent(o),o.defaultPrevented)return;null===(t=p.onOpenChange)||void 0===t||t.call(p,!1)}};return h.useEffect((()=>{const e=u.current;if(e){const t=e=>null==a?void 0:a(e);return e.addEventListener("menu.itemSelect",t),()=>e.removeEventListener("menu.itemSelect",t)}}),[a]),h.createElement(l,g({role:"menuitem","aria-disabled":r||void 0},c,m,M,{[L]:""},{selector:o,ref:i,"data-disabled":r?"":void 0,onFocus:f(c.onFocus,m.onFocus),onKeyDown:f(c.onKeyDown,f(m.onKeyDown,(e=>{r||"Enter"!==e.key&&" "!==e.key||w()}))),onMouseDown:f(c.onMouseDown,m.onMouseDown),onMouseUp:f(c.onMouseUp,w),onMouseMove:f(c.onMouseMove,(e=>{if(!r){e.currentTarget.focus()}})),onBlur:f(c.onBlur,(e=>{p.setItemsReachable(!1)})),onMouseLeave:f(c.onMouseLeave,(e=>{var t;null===(t=p.menuRef.current)||void 0===t||t.focus()}))}))}));MenuItem.displayName=G;const T="MenuCheckboxItem";export const MenuCheckboxItem=h.forwardRef(((e,t)=>{const{selector:o=d(T),checked:r=!1,onCheckedChange:n}=e,a=I(e,["selector","checked","onCheckedChange"]);return h.createElement(z.Provider,{value:r},h.createElement(MenuItem,g({role:"menuitemcheckbox","aria-checked":r},a,{selector:o,ref:t,"data-state":Q(r),onSelect:f(a.onSelect,(()=>null==n?void 0:n(!r)),{checkForDefaultPrevented:!1})})))}));MenuCheckboxItem.displayName=T;const V="MenuRadioGroup",B=h.createContext({});export const MenuRadioGroup=h.forwardRef(((e,t)=>{const{selector:o=d(V),value:r,onValueChange:n}=e,a=I(e,["selector","value","onValueChange"]),c=M(n),u=h.useMemo((()=>({value:r,onValueChange:c})),[r,c]);return h.createElement(B.Provider,{value:u},h.createElement(MenuGroup,g({},a,{selector:o,ref:t})))}));MenuRadioGroup.displayName=V;const U="MenuRadioItem";export const MenuRadioItem=h.forwardRef(((e,t)=>{const{selector:o=d(U),value:r}=e,n=I(e,["selector","value"]),a=h.useContext(B),c=r===a.value;return h.createElement(z.Provider,{value:c},h.createElement(MenuItem,g({role:"menuitemradio","aria-checked":c},n,{selector:o,ref:t,"data-state":Q(c),onSelect:f(n.onSelect,(()=>{var e;return null===(e=a.onValueChange)||void 0===e?void 0:e.call(a,r)}),{checkForDefaultPrevented:!1})})))}));MenuRadioItem.displayName=U;const q="MenuItemIndicator",W="span",z=h.createContext(!1);export const MenuItemIndicator=h.forwardRef(((e,t)=>{const{as:o=W,selector:r=d(q),forceMount:n}=e,a=I(e,["as","selector","forceMount"]),c=h.useContext(z);return h.createElement(i,{present:n||c},h.createElement(l,g({},a,{as:o,selector:r,ref:t,"data-state":Q(c)})))}));MenuItemIndicator.displayName=q;const H="MenuSeparator";export const MenuSeparator=h.forwardRef(((e,t)=>{const{selector:o=d(H)}=e,r=I(e,["selector"]);return h.createElement(l,g({role:"separator","aria-orientation":"horizontal"},r,{selector:o,ref:t}))}));MenuSeparator.displayName=H;export const MenuArrow=y(c.Arrow,"MenuArrow");function J(e){return e?"open":"closed"}function Q(e){return e?"checked":"unchecked"}export const Root=Menu;export const Group=MenuGroup;export const Label=MenuLabel;export const Item=MenuItem;export const CheckboxItem=MenuCheckboxItem;export const RadioGroup=MenuRadioGroup;export const RadioItem=MenuRadioItem;export const ItemIndicator=MenuItemIndicator;export const Separator=MenuSeparator;export const Arrow=MenuArrow; | ||
import{hideOthers as e}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as o}from"@radix-ui/react-focus-guards";import{Portal as r}from"@radix-ui/react-portal";import{FocusScope as n}from"@radix-ui/react-focus-scope";import{DismissableLayer as a}from"@radix-ui/react-dismissable-layer";import*as u from"@radix-ui/react-popper";import{RovingFocusGroup as c,useRovingFocus as s}from"@radix-ui/react-roving-focus";import{Primitive as i,extendPrimitive as l}from"@radix-ui/react-primitive";import{Presence as d}from"@radix-ui/react-presence";import{useCallbackRef as m}from"@radix-ui/react-use-callback-ref";import{createContext as p}from"@radix-ui/react-context";import{composeRefs as f,useComposedRefs as v}from"@radix-ui/react-compose-refs";import{composeEventHandlers as M}from"@radix-ui/primitive";import*as h from"react";function x(){const e=h.useRef(0),t=h.useRef(""),o=h.useCallback((r=>{t.current=r,window.clearTimeout(e.current),e.current=window.setTimeout((()=>o("")),1e3)}),[]);return{onKeyDownCapture:e=>{if(1===e.key.length&&!(e.ctrlKey||e.altKey||e.metaKey)){const r=e.currentTarget;o(t.current+e.key)," "!==e.key||t.current.startsWith(" ")||e.stopPropagation();const n=document.activeElement,a=n?w(n):void 0,u=function(e,t,o){const r=t.length>1&&Array.from(t).every((e=>e===t[0]))?t[0]:t,n=o?e.indexOf(o):-1;let a=(u=e,c=Math.max(n,0),u.map(((e,t)=>u[(c+t)%u.length])));var u,c;1===r.length&&(a=a.filter((e=>e!==o)));const s=a.find((e=>e.toLowerCase().startsWith(r.toLowerCase())));return s!==o?s:void 0}(Array.from(r.querySelectorAll("[".concat(y,"]"))).map(w),t.current,a),c=r.querySelector("[".concat(y,'="').concat(u,'"]'));c&&setTimeout((()=>c.focus()))}}}}const w=e=>{var t;return null!==(t=e.getAttribute(y))&&void 0!==t?t:""},y="data-radix-menu-typeahead-item";function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}const b=["ArrowDown","PageUp","Home"],E=[...b,"ArrowUp","PageDown","End"],[D,I]=p("Menu");export const Menu=h.forwardRef(((e,t)=>{const{forceMount:o,open:r=!1,...n}=e;return h.createElement(d,{present:o||r},h.createElement(R,C({"data-state":P(r)},n,{ref:t,open:r})))}));const R=h.forwardRef(((s,i)=>{const{open:l,onOpenChange:d,anchorRef:p,loop:v,trapFocus:w,onOpenAutoFocus:y,onCloseAutoFocus:I,disableOutsidePointerEvents:R,onEscapeKeyDown:g,onPointerDownOutside:S,onFocusOutside:F,onInteractOutside:P,onDismiss:A,disableOutsideScroll:O,portalled:K,...G}=s,L=m(d),N=h.useRef(null),[T,V]=h.useState(0),[B,U]=h.useState(!1),q=x();h.useEffect((()=>{V(B?-1:0)}),[B]);const[j,W]=h.useState(!1),z=K?r:h.Fragment,H=O?t:h.Fragment;return o(),h.useEffect((()=>{const t=N.current;if(t)return e(t)}),[]),h.createElement(z,null,h.createElement(H,null,h.createElement(D,{menuRef:N,onItemsReachableChange:U,onOpenChange:L},h.createElement(c,{reachable:B,onReachableChange:U,orientation:"vertical",loop:v},h.createElement(n,{trapped:!j&&(w&&l),onMountAutoFocus:y,onUnmountAutoFocus:e=>{j?e.preventDefault():null==I||I(e)}},(e=>h.createElement(a,{disableOutsidePointerEvents:R,onEscapeKeyDown:g,onPointerDownOutside:M(S,(e=>{const t=0===e.button&&!1===e.ctrlKey;W(!R&&t),e.defaultPrevented&&W(!1)}),{checkForDefaultPrevented:!1}),onFocusOutside:M(F,(e=>{w&&e.preventDefault()}),{checkForDefaultPrevented:!1}),onInteractOutside:P,onDismiss:A},(t=>h.createElement(u.Root,C({role:"menu"},G,{ref:f(i,N,e.ref,t.ref),anchorRef:p,tabIndex:T,style:{...t.style,outline:"none",...G.style},onBlurCapture:M(G.onBlurCapture,t.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:M(G.onFocusCapture,t.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:M(G.onMouseDownCapture,t.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:M(G.onTouchStartCapture,t.onTouchStartCapture,{checkForDefaultPrevented:!1}),onKeyDownCapture:M(G.onKeyDownCapture,q.onKeyDownCapture),onKeyDown:M(G.onKeyDown,(e=>{const t=N.current;if(e.target===t&&E.includes(e.key)){e.preventDefault();const o=Array.from(t.querySelectorAll(k)),r=b.includes(e.key)?o[0]:o.reverse()[0];null==r||r.focus()}}))}))))))))))}));Menu.displayName="Menu";export const MenuGroup=h.forwardRef(((e,t)=>h.createElement(i,C({role:"group"},e,{ref:t}))));MenuGroup.displayName="MenuGroup";const k="[".concat("data-radix-menu-item","]:not([data-disabled])");export const MenuItem=h.forwardRef(((e,t)=>{const{disabled:o,textValue:r,onSelect:n,...a}=e,u=h.useRef(null),c=v(t,u),l=I("MenuItem"),d=s({disabled:o}),[m,p]=h.useState("");h.useEffect((()=>{const e=u.current;var t;e&&p((null!==(t=e.textContent)&&void 0!==t?t:"").trim())}),[a.children]);const f=function({textValue:e,disabled:t}){return{[y]:t?void 0:e}}({textValue:null!=r?r:m,disabled:o}),x=()=>{const e=u.current;if(!o&&e){var t;const o=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});if(e.dispatchEvent(o),o.defaultPrevented)return;null===(t=l.onOpenChange)||void 0===t||t.call(l,!1)}};return h.useEffect((()=>{const e=u.current;if(e){const t=e=>null==n?void 0:n(e);return e.addEventListener("menu.itemSelect",t),()=>e.removeEventListener("menu.itemSelect",t)}}),[n]),h.createElement(i,C({role:"menuitem","aria-disabled":o||void 0},a,d,f,{"data-radix-menu-item":"",ref:c,"data-disabled":o?"":void 0,onFocus:M(a.onFocus,d.onFocus),onKeyDown:M(a.onKeyDown,M(d.onKeyDown,(e=>{o||"Enter"!==e.key&&" "!==e.key||x()}))),onMouseDown:M(a.onMouseDown,d.onMouseDown),onMouseUp:M(a.onMouseUp,x),onMouseMove:M(a.onMouseMove,(e=>{if(!o){e.currentTarget.focus()}})),onBlur:M(a.onBlur,(e=>{l.onItemsReachableChange(!1)})),onMouseLeave:M(a.onMouseLeave,(e=>{var t;null===(t=l.menuRef.current)||void 0===t||t.focus()}))}))}));MenuItem.displayName="MenuItem";export const MenuCheckboxItem=h.forwardRef(((e,t)=>{const{checked:o=!1,onCheckedChange:r,...n}=e;return h.createElement(F.Provider,{value:o},h.createElement(MenuItem,C({role:"menuitemcheckbox","aria-checked":o},n,{ref:t,"data-state":A(o),onSelect:M(n.onSelect,(()=>null==r?void 0:r(!o)),{checkForDefaultPrevented:!1})})))}));MenuCheckboxItem.displayName="MenuCheckboxItem";const g=h.createContext({});export const MenuRadioGroup=h.forwardRef(((e,t)=>{const{value:o,onValueChange:r,...n}=e,a=m(r),u=h.useMemo((()=>({value:o,onValueChange:a})),[o,a]);return h.createElement(g.Provider,{value:u},h.createElement(MenuGroup,C({},n,{ref:t})))}));MenuRadioGroup.displayName="MenuRadioGroup";export const MenuRadioItem=h.forwardRef(((e,t)=>{const{value:o,...r}=e,n=h.useContext(g),a=o===n.value;return h.createElement(F.Provider,{value:a},h.createElement(MenuItem,C({role:"menuitemradio","aria-checked":a},r,{ref:t,"data-state":A(a),onSelect:M(r.onSelect,(()=>{var e;return null===(e=n.onValueChange)||void 0===e?void 0:e.call(n,o)}),{checkForDefaultPrevented:!1})})))}));MenuRadioItem.displayName="MenuRadioItem";const S="span",F=h.createContext(!1);export const MenuItemIndicator=h.forwardRef(((e,t)=>{const{as:o=S,forceMount:r,...n}=e,a=h.useContext(F);return h.createElement(d,{present:r||a},h.createElement(i,C({},n,{as:o,ref:t,"data-state":A(a)})))}));MenuItemIndicator.displayName="MenuItemIndicator";export const MenuSeparator=h.forwardRef(((e,t)=>h.createElement(i,C({role:"separator","aria-orientation":"horizontal"},e,{ref:t}))));MenuSeparator.displayName="MenuSeparator";export const MenuLabel=l(i,"MenuLabel");export const MenuArrow=l(u.Arrow,"MenuArrow");function P(e){return e?"open":"closed"}function A(e){return e?"checked":"unchecked"}export const Root=Menu;export const Group=MenuGroup;export const Label=MenuLabel;export const Item=MenuItem;export const CheckboxItem=MenuCheckboxItem;export const RadioGroup=MenuRadioGroup;export const RadioItem=MenuRadioItem;export const ItemIndicator=MenuItemIndicator;export const Separator=MenuSeparator;export const Arrow=MenuArrow; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-menu", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"license": "MIT", | ||
@@ -19,13 +19,15 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@radix-ui/react-dismissable-layer": "0.0.5", | ||
"@radix-ui/primitive": "0.0.1", | ||
"@radix-ui/react-compose-refs": "0.0.1", | ||
"@radix-ui/react-context": "0.0.1", | ||
"@radix-ui/react-dismissable-layer": "0.0.6", | ||
"@radix-ui/react-focus-guards": "0.0.3", | ||
"@radix-ui/react-focus-scope": "0.0.5", | ||
"@radix-ui/react-polymorphic": "0.0.5", | ||
"@radix-ui/react-popper": "0.0.6", | ||
"@radix-ui/react-portal": "0.0.5", | ||
"@radix-ui/react-presence": "0.0.5", | ||
"@radix-ui/react-primitive": "0.0.4", | ||
"@radix-ui/react-roving-focus": "0.0.5", | ||
"@radix-ui/react-utils": "0.0.5", | ||
"@radix-ui/utils": "0.0.3", | ||
"@radix-ui/react-focus-scope": "0.0.6", | ||
"@radix-ui/react-polymorphic": "0.0.6", | ||
"@radix-ui/react-popper": "0.0.7", | ||
"@radix-ui/react-portal": "0.0.6", | ||
"@radix-ui/react-presence": "0.0.6", | ||
"@radix-ui/react-primitive": "0.0.5", | ||
"@radix-ui/react-roving-focus": "0.0.6", | ||
"@radix-ui/react-use-callback-ref": "0.0.1", | ||
"aria-hidden": "^1.1.1", | ||
@@ -32,0 +34,0 @@ "react-remove-scroll": "^2.4.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112671
16
211
+ Added@radix-ui/primitive@0.0.1
+ Added@radix-ui/number@0.0.1(transitive)
+ Added@radix-ui/popper@0.0.5(transitive)
+ Added@radix-ui/primitive@0.0.1(transitive)
+ Added@radix-ui/react-arrow@0.0.6(transitive)
+ Added@radix-ui/react-compose-refs@0.0.1(transitive)
+ Added@radix-ui/react-context@0.0.1(transitive)
+ Added@radix-ui/react-dismissable-layer@0.0.6(transitive)
+ Added@radix-ui/react-focus-scope@0.0.6(transitive)
+ Added@radix-ui/react-id@0.0.1(transitive)
+ Added@radix-ui/react-polymorphic@0.0.6(transitive)
+ Added@radix-ui/react-popper@0.0.7(transitive)
+ Added@radix-ui/react-portal@0.0.6(transitive)
+ Added@radix-ui/react-presence@0.0.6(transitive)
+ Added@radix-ui/react-primitive@0.0.5(transitive)
+ Added@radix-ui/react-roving-focus@0.0.6(transitive)
+ Added@radix-ui/react-use-body-pointer-events@0.0.1(transitive)
+ Added@radix-ui/react-use-callback-ref@0.0.1(transitive)
+ Added@radix-ui/react-use-controllable-state@0.0.1(transitive)
+ Added@radix-ui/react-use-layout-effect@0.0.1(transitive)
+ Added@radix-ui/react-use-rect@0.0.1(transitive)
+ Added@radix-ui/react-use-size@0.0.1(transitive)
+ Added@radix-ui/rect@0.0.1(transitive)
- Removed@radix-ui/react-utils@0.0.5
- Removed@radix-ui/utils@0.0.3
- Removed@radix-ui/popper@0.0.4(transitive)
- Removed@radix-ui/react-arrow@0.0.5(transitive)
- Removed@radix-ui/react-dismissable-layer@0.0.5(transitive)
- Removed@radix-ui/react-focus-scope@0.0.5(transitive)
- Removed@radix-ui/react-polymorphic@0.0.5(transitive)
- Removed@radix-ui/react-popper@0.0.6(transitive)
- Removed@radix-ui/react-portal@0.0.5(transitive)
- Removed@radix-ui/react-presence@0.0.5(transitive)
- Removed@radix-ui/react-primitive@0.0.4(transitive)
- Removed@radix-ui/react-roving-focus@0.0.5(transitive)
- Removed@radix-ui/react-utils@0.0.5(transitive)
- Removed@radix-ui/utils@0.0.3(transitive)
- Removed@xstate/fsm@1.6.5(transitive)
Updated@radix-ui/react-popper@0.0.7
Updated@radix-ui/react-portal@0.0.6