this repo has no description

core-ext/contextMenu: fix patches

Co-Authored-By: hi@notnite.com

adryd b73b2d7c 474c7ea0

Changed files
+61 -53
packages
core-extensions
src
contextMenu
webpackModules
types
src
coreExtensions
+1 -2
packages/core-extensions/src/contextMenu/index.tsx
··· 5 5 find: "Menu API only allows Items and groups of Items as children.", 6 6 replace: [ 7 7 { 8 - match: 9 - /(?<=let{navId[^}]+?}=(.),(.)=function .\(.\){.+(?=,.=function))/, 8 + match: /(?<=let{navId[^}]+?}=(.),(.)=.\(.\))/, 10 9 replacement: (_, props, items) => 11 10 `,__contextMenu=!${props}.__contextMenu_evilMenu&&require("contextMenu_contextMenu")._patchMenu(${props}, ${items})` 12 11 }
+5 -6
packages/core-extensions/src/contextMenu/webpackModules/evilMenu.ts
··· 6 6 "Menu API only allows Items and groups of Items as children." 7 7 )[0].id 8 8 ].toString(); 9 - code = code.replace(/,.=(?=function .\(.\){.+?,.=function)/, ";return "); 10 - code = code.replace(/,(?=__contextMenu)/, ";let "); 9 + code = code.replace( 10 + /onSelect:(.)}=(.),.=(.\(.\)),/, 11 + `onSelect:$1}=$2;return $3;let ` 12 + ); 11 13 const mod = new Function( 12 14 "module", 13 15 "exports", ··· 16 18 ); 17 19 const exp: any = {}; 18 20 mod({}, exp, require); 19 - const Menu = spacepack.findFunctionByStrings( 20 - exp, 21 - "Menu API only allows Items and groups of Items as children." 22 - )!; 21 + const Menu = spacepack.findFunctionByStrings(exp, "isUsingKeyboardNavigation")!; 23 22 module.exports = (el: any) => { 24 23 return Menu({ 25 24 children: el,
+55 -45
packages/types/src/coreExtensions/contextMenu.ts
··· 27 27 color?: string; 28 28 children: React.ReactComponentElement<MenuElement>[]; 29 29 }>; 30 - export type MenuItem = React.FunctionComponent<{ 31 - id: any; 32 - dontCloseOnActionIfHoldingShiftKey?: boolean; 33 - } & ({ 34 - label: string; 35 - subtext?: string; 36 - color?: string; 37 - hint?: string; 38 - disabled?: boolean; 39 - icon?: any; 40 - showIconFirst?: boolean; 41 - imageUrl?: string; 30 + export type MenuItem = React.FunctionComponent< 31 + { 32 + id: any; 33 + dontCloseOnActionIfHoldingShiftKey?: boolean; 34 + } & ( 35 + | { 36 + label: string; 37 + subtext?: string; 38 + color?: string; 39 + hint?: string; 40 + disabled?: boolean; 41 + icon?: any; 42 + showIconFirst?: boolean; 43 + imageUrl?: string; 42 44 43 - className?: string; 44 - focusedClassName?: string; 45 - subMenuIconClassName?: string; 45 + className?: string; 46 + focusedClassName?: string; 47 + subMenuIconClassName?: string; 46 48 47 - action?: () => void; 48 - onFocus?: () => void; 49 + action?: () => void; 50 + onFocus?: () => void; 49 51 50 - iconProps?: any; 51 - sparkle?: any; 52 + iconProps?: any; 53 + sparkle?: any; 52 54 53 - children?: React.ReactComponentElement<MenuElement>[]; 54 - onChildrenScroll?: any; 55 - childRowHeight?: any; 56 - listClassName?: string; 57 - subMenuClassName?: string; 58 - } | { 59 - color?: string; 60 - disabled?: boolean; 61 - keepItemStyles?: boolean; 55 + children?: React.ReactComponentElement<MenuElement>[]; 56 + onChildrenScroll?: any; 57 + childRowHeight?: any; 58 + listClassName?: string; 59 + subMenuClassName?: string; 60 + } 61 + | { 62 + color?: string; 63 + disabled?: boolean; 64 + keepItemStyles?: boolean; 62 65 63 - action?: () => void; 66 + action?: () => void; 64 67 65 - render: any; 66 - navigable?: boolean; 67 - })>; 68 + render: any; 69 + navigable?: boolean; 70 + } 71 + ) 72 + >; 68 73 export type MenuCheckboxItem = React.FunctionComponent<{ 69 74 id: any; 70 75 label: string; ··· 84 89 disabled?: boolean; 85 90 action?: () => void; 86 91 }>; 87 - export type MenuControlItem = React.FunctionComponent<{ 88 - id: any; 89 - label: string; 90 - color?: string; 91 - disabled?: boolean; 92 - showDefaultFocus?: boolean; 93 - } & ({ 94 - control: any; 95 - } | { 96 - control?: undefined; 97 - interactive?: boolean; 98 - children?: React.ReactComponentElement<MenuElement>[]; 99 - })>; 92 + export type MenuControlItem = React.FunctionComponent< 93 + { 94 + id: any; 95 + label: string; 96 + color?: string; 97 + disabled?: boolean; 98 + showDefaultFocus?: boolean; 99 + } & ( 100 + | { 101 + control: any; 102 + } 103 + | { 104 + control?: undefined; 105 + interactive?: boolean; 106 + children?: React.ReactComponentElement<MenuElement>[]; 107 + } 108 + ) 109 + >; 100 110 /* eslint-disable prettier/prettier */ 101 111 102 112 export type ContextMenu = {