UNPKG

@wordpress/components

Version:
8 lines (7 loc) 2.49 kB
{ "version": 3, "sources": ["../../src/menu/submenu-trigger-item.tsx"], "sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport { chevronRightSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\n\nimport { Context } from './context';\nimport { Item } from './item';\nimport * as Styled from './styles';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const SubmenuTriggerItem = forwardRef(function SubmenuTriggerItem({\n suffix,\n ...otherProps\n}, ref) {\n const menuContext = useContext(Context);\n if (!menuContext?.store.parent) {\n throw new Error('Menu.SubmenuTriggerItem can only be rendered inside a nested Menu component');\n }\n return /*#__PURE__*/_jsx(Ariakit.MenuButton, {\n ref: ref,\n accessibleWhenDisabled: true,\n store: menuContext.store,\n render: /*#__PURE__*/_jsx(Item, {\n ...otherProps,\n // The menu item needs to register and be part of the parent menu.\n // Without specifying the store explicitly, the `Item` component\n // would otherwise read the store via context and pick up the one from\n // the sub-menu `Menu` component.\n store: menuContext.store.parent,\n suffix: /*#__PURE__*/_jsxs(_Fragment, {\n children: [suffix, /*#__PURE__*/_jsx(Styled.SubmenuChevronIcon, {\n \"aria-hidden\": \"true\",\n icon: chevronRightSmall,\n size: 24,\n preserveAspectRatio: \"xMidYMid slice\"\n })]\n })\n })\n });\n});"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,cAAyB;AAKzB,qBAAuC;AACvC,mBAAkC;AAMlC,qBAAwB;AACxB,kBAAqB;AACrB,aAAwB;AACxB,yBAAkE;AAC3D,IAAM,yBAAqB,2BAAW,SAASA,oBAAmB;AAAA,EACvE;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,kBAAc,2BAAW,sBAAO;AACtC,MAAI,CAAC,aAAa,MAAM,QAAQ;AAC9B,UAAM,IAAI,MAAM,6EAA6E;AAAA,EAC/F;AACA,SAAoB,uCAAAC,KAAa,oBAAY;AAAA,IAC3C;AAAA,IACA,wBAAwB;AAAA,IACxB,OAAO,YAAY;AAAA,IACnB,QAAqB,uCAAAA,KAAK,kBAAM;AAAA,MAC9B,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,MAKH,OAAO,YAAY,MAAM;AAAA,MACzB,QAAqB,uCAAAC,MAAM,mBAAAC,UAAW;AAAA,QACpC,UAAU,CAAC,QAAqB,uCAAAF,KAAY,2BAAoB;AAAA,UAC9D,eAAe;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,qBAAqB;AAAA,QACvB,CAAC,CAAC;AAAA,MACJ,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH,CAAC;", "names": ["SubmenuTriggerItem", "_jsx", "_jsxs", "_Fragment"] }