@elliemae/ds-menu-button 3.39.1-rc.0 → 3.40.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/parts/ItemFactory.js +1 -1
- package/dist/cjs/parts/ItemFactory.js.map +2 -2
- package/dist/cjs/parts/Menu.js +2 -2
- package/dist/cjs/parts/Menu.js.map +2 -2
- package/dist/cjs/parts/MenuButtonContent.js +11 -6
- package/dist/cjs/parts/MenuButtonContent.js.map +2 -2
- package/dist/cjs/parts/MenuItem.js +5 -4
- package/dist/cjs/parts/MenuItem.js.map +2 -2
- package/dist/cjs/styled.js +7 -15
- package/dist/cjs/styled.js.map +2 -2
- package/dist/esm/parts/ItemFactory.js +1 -1
- package/dist/esm/parts/ItemFactory.js.map +2 -2
- package/dist/esm/parts/Menu.js +2 -2
- package/dist/esm/parts/Menu.js.map +2 -2
- package/dist/esm/parts/MenuButtonContent.js +11 -6
- package/dist/esm/parts/MenuButtonContent.js.map +2 -2
- package/dist/esm/parts/MenuItem.js +6 -11
- package/dist/esm/parts/MenuItem.js.map +2 -2
- package/dist/esm/styled.js +8 -16
- package/dist/esm/styled.js.map +2 -2
- package/dist/types/styled.d.ts +1 -1
- package/package.json +10 -10
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/parts/ItemFactory.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["/* eslint-disable import/no-cycle */\n/* eslint-disable arrow-body-style */\nimport React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { MenuItem, Section, Separator } from './MenuItem.js';\n\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\ninterface ItemFactoryProps {\n item: MenuButtonT.Item;\n level: number;\n selectionMode?: 'single' | 'multiple';\n parentId?: string;\n tabIndex: TypescriptHelpersT.WCAGTabIndex;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}\n\nexport const ItemFactory: React.FC<ItemFactoryProps> = ({\n item,\n innerRef,\n onFocus,\n tabIndex,\n level,\n selectionMode,\n parentId,\n}) => {\n if (item.type === 'separator') {\n return <Separator />;\n }\n if (item.type === 'section') {\n return <Section item={item} />;\n }\n return (\n <MenuItem\n key={item.dsId}\n item={item}\n innerRef={innerRef}\n onFocus={onFocus}\n tabIndex={tabIndex}\n level={level}\n parentId={parentId}\n selectionMode={selectionMode}\n />\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2BZ;AAvBX,sBAA6C;AAatC,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO,4CAAC,6BAAU;AAAA,EACpB;AACA,MAAI,KAAK,SAAS,WAAW;AAC3B,WAAO,4CAAC,2BAAQ,MAAY;AAAA,EAC9B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,
|
4
|
+
"sourcesContent": ["/* eslint-disable import/no-cycle */\n/* eslint-disable arrow-body-style */\nimport React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { MenuItem, Section, Separator } from './MenuItem.js';\n\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\ninterface ItemFactoryProps {\n item: MenuButtonT.Item;\n level: number;\n selectionMode?: 'single' | 'multiple';\n parentId?: string;\n tabIndex: TypescriptHelpersT.WCAGTabIndex;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}\n\nexport const ItemFactory: React.FC<ItemFactoryProps> = ({\n item,\n innerRef,\n onFocus,\n tabIndex,\n level,\n selectionMode,\n parentId,\n}) => {\n if (item.type === 'separator') {\n return <Separator />;\n }\n if (item.type === 'section') {\n return <Section item={item} />;\n }\n return (\n <MenuItem\n key={item.dsId}\n item={item}\n innerRef={innerRef}\n onFocus={onFocus}\n tabIndex={tabIndex}\n level={level}\n parentId={parentId}\n selectionMode={selectionMode || item.type}\n />\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2BZ;AAvBX,sBAA6C;AAatC,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO,4CAAC,6BAAU;AAAA,EACpB;AACA,MAAI,KAAK,SAAS,WAAW;AAC3B,WAAO,4CAAC,2BAAQ,MAAY;AAAA,EAC9B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,iBAAiB,KAAK;AAAA;AAAA,IAPhC,KAAK;AAAA,EAQZ;AAEJ;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/dist/cjs/parts/Menu.js
CHANGED
@@ -56,11 +56,11 @@ const Menu = (props) => {
|
|
56
56
|
return;
|
57
57
|
}
|
58
58
|
if (listRect.right > window.innerWidth) {
|
59
|
-
setCoords({ x: -(rect?.width || 0), y: 0 });
|
59
|
+
setCoords({ x: -(minWidth || rect?.width || 0), y: 0 });
|
60
60
|
} else {
|
61
61
|
setCoords({ x: rect?.width || 0, y: 0 });
|
62
62
|
}
|
63
|
-
}, [level, rect?.height, rect?.width, referenceElement]);
|
63
|
+
}, [level, minWidth, rect?.height, rect?.width, referenceElement]);
|
64
64
|
const config = {
|
65
65
|
options: items.filter((item) => item.type !== "separator" && item.type !== "section").map((item) => item.dsId),
|
66
66
|
direction: import_ds_hooks_keyboard_navigation.DIRECTIONS.VERTICAL,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/parts/Menu.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["/* eslint-disable import/no-cycle */\nimport React, { useState, useMemo, useCallback, useContext } from 'react';\nimport { useKeyboardNavigation, DIRECTIONS } from '@elliemae/ds-hooks-keyboard-navigation';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\nimport { StyledMenu } from '../styled.js';\nimport { ItemFactory } from './ItemFactory.js';\n\ninterface SubMenuProps {\n referenceElement: HTMLElement | null;\n showSubMenu: boolean;\n selectionMode?: 'single' | 'multiple';\n setShowSubMenu: React.Dispatch<React.SetStateAction<boolean>>;\n parentId?: string;\n level: number;\n items: MenuButtonT.Item[];\n minWidth?: string | number;\n}\n\nexport const Menu: React.FC<SubMenuProps> = (props) => {\n const { referenceElement, showSubMenu, selectionMode, setShowSubMenu, parentId, level, items, minWidth } = props;\n const { focusedOption, setFocusedOption } = useContext(MenuButtonContext);\n const listRef = React.useRef<HTMLDivElement>(null);\n const rect = referenceElement?.getBoundingClientRect();\n const [coords, setCoords] = useState<{ x: number; y: number }>({ x: rect?.width ?? 0, y: 0 });\n\n // this logic will be part of the new popper custom hook\n React.useLayoutEffect(() => {\n const listRect = listRef?.current?.getBoundingClientRect();\n if (!listRect) return;\n if (level === 1) {\n if (listRect.bottom < window.innerHeight) {\n setCoords({ x: 0, y: rect?.height || 0 });\n } else {\n setCoords({ x: 0, y: -listRect.height });\n }\n return;\n }\n if (listRect.right > window.innerWidth) {\n setCoords({ x: -(rect?.width || 0), y: 0 });\n } else {\n setCoords({ x: rect?.width || 0, y: 0 });\n }\n }, [level, rect?.height, rect?.width, referenceElement]);\n\n const config = {\n options: items.filter((item) => item.type !== 'separator' && item.type !== 'section').map((item) => item.dsId),\n direction: DIRECTIONS.VERTICAL,\n focusedOption,\n setFocusedOption,\n };\n\n const { getWrapperProps, getItemProps } = useKeyboardNavigation(config);\n\n const { onKeyDown, onBlur } = getWrapperProps();\n\n const handleOnMenuKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.stopPropagation();\n }\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n const handleOnBlur: React.FocusEventHandler<HTMLDivElement> = useCallback(\n (e) => {\n setTimeout(() => {\n if (!listRef.current?.contains(document.activeElement)) {\n setShowSubMenu(false);\n }\n });\n onBlur(e);\n },\n [onBlur, setShowSubMenu],\n );\n\n const subMenuStyles = useMemo(\n () => ({\n position: 'absolute',\n top: coords.y,\n left: coords.x,\n zIndex: 1001 + level,\n minWidth,\n }),\n [coords, level, minWidth],\n );\n\n if (!referenceElement || !showSubMenu) return null;\n\n return (\n <StyledMenu\n innerRef={listRef}\n role=\"menu\"\n onKeyDown={handleOnMenuKeyDown}\n onBlur={handleOnBlur}\n style={subMenuStyles}\n >\n {items.map((item) => (\n <ItemFactory\n key={item.dsId}\n item={item}\n selectionMode={selectionMode}\n level={level}\n parentId={parentId}\n {...getItemProps(item.dsId)}\n />\n ))}\n </StyledMenu>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoGf;AAnGR,mBAAkE;AAClE,0CAAkD;AAClD,6BAAkC;AAElC,oBAA2B;AAC3B,yBAA4B;AAarB,MAAM,OAA+B,CAAC,UAAU;AACrD,QAAM,EAAE,kBAAkB,aAAa,eAAe,gBAAgB,UAAU,OAAO,OAAO,SAAS,IAAI;AAC3G,QAAM,EAAE,eAAe,iBAAiB,QAAI,yBAAW,wCAAiB;AACxE,QAAM,UAAU,aAAAA,QAAM,OAAuB,IAAI;AACjD,QAAM,OAAO,kBAAkB,sBAAsB;AACrD,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAmC,EAAE,GAAG,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;AAG5F,eAAAA,QAAM,gBAAgB,MAAM;AAC1B,UAAM,WAAW,SAAS,SAAS,sBAAsB;AACzD,QAAI,CAAC,SAAU;AACf,QAAI,UAAU,GAAG;AACf,UAAI,SAAS,SAAS,OAAO,aAAa;AACxC,kBAAU,EAAE,GAAG,GAAG,GAAG,MAAM,UAAU,EAAE,CAAC;AAAA,MAC1C,OAAO;AACL,kBAAU,EAAE,GAAG,GAAG,GAAG,CAAC,SAAS,OAAO,CAAC;AAAA,MACzC;AACA;AAAA,IACF;AACA,QAAI,SAAS,QAAQ,OAAO,YAAY;AACtC,gBAAU,EAAE,GAAG,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,CAAC;AAAA,
|
4
|
+
"sourcesContent": ["/* eslint-disable import/no-cycle */\nimport React, { useState, useMemo, useCallback, useContext } from 'react';\nimport { useKeyboardNavigation, DIRECTIONS } from '@elliemae/ds-hooks-keyboard-navigation';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\nimport { StyledMenu } from '../styled.js';\nimport { ItemFactory } from './ItemFactory.js';\n\ninterface SubMenuProps {\n referenceElement: HTMLElement | null;\n showSubMenu: boolean;\n selectionMode?: 'single' | 'multiple';\n setShowSubMenu: React.Dispatch<React.SetStateAction<boolean>>;\n parentId?: string;\n level: number;\n items: MenuButtonT.Item[];\n minWidth?: string | number;\n}\n\nexport const Menu: React.FC<SubMenuProps> = (props) => {\n const { referenceElement, showSubMenu, selectionMode, setShowSubMenu, parentId, level, items, minWidth } = props;\n const { focusedOption, setFocusedOption } = useContext(MenuButtonContext);\n const listRef = React.useRef<HTMLDivElement>(null);\n const rect = referenceElement?.getBoundingClientRect();\n const [coords, setCoords] = useState<{ x: number; y: number }>({ x: rect?.width ?? 0, y: 0 });\n\n // this logic will be part of the new popper custom hook\n React.useLayoutEffect(() => {\n const listRect = listRef?.current?.getBoundingClientRect();\n if (!listRect) return;\n if (level === 1) {\n if (listRect.bottom < window.innerHeight) {\n setCoords({ x: 0, y: rect?.height || 0 });\n } else {\n setCoords({ x: 0, y: -listRect.height });\n }\n return;\n }\n if (listRect.right > window.innerWidth) {\n setCoords({ x: -(minWidth || rect?.width || 0), y: 0 });\n } else {\n setCoords({ x: rect?.width || 0, y: 0 });\n }\n }, [level, minWidth, rect?.height, rect?.width, referenceElement]);\n\n const config = {\n options: items.filter((item) => item.type !== 'separator' && item.type !== 'section').map((item) => item.dsId),\n direction: DIRECTIONS.VERTICAL,\n focusedOption,\n setFocusedOption,\n };\n\n const { getWrapperProps, getItemProps } = useKeyboardNavigation(config);\n\n const { onKeyDown, onBlur } = getWrapperProps();\n\n const handleOnMenuKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.stopPropagation();\n }\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n const handleOnBlur: React.FocusEventHandler<HTMLDivElement> = useCallback(\n (e) => {\n setTimeout(() => {\n if (!listRef.current?.contains(document.activeElement)) {\n setShowSubMenu(false);\n }\n });\n onBlur(e);\n },\n [onBlur, setShowSubMenu],\n );\n\n const subMenuStyles = useMemo(\n () => ({\n position: 'absolute',\n top: coords.y,\n left: coords.x,\n zIndex: 1001 + level,\n minWidth,\n }),\n [coords, level, minWidth],\n );\n\n if (!referenceElement || !showSubMenu) return null;\n\n return (\n <StyledMenu\n innerRef={listRef}\n role=\"menu\"\n onKeyDown={handleOnMenuKeyDown}\n onBlur={handleOnBlur}\n style={subMenuStyles}\n >\n {items.map((item) => (\n <ItemFactory\n key={item.dsId}\n item={item}\n selectionMode={selectionMode}\n level={level}\n parentId={parentId}\n {...getItemProps(item.dsId)}\n />\n ))}\n </StyledMenu>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}
|
@@ -60,10 +60,7 @@ const MenuButtonContent = () => {
|
|
60
60
|
const globalProps = (0, import_ds_props_helpers.useGetGlobalAttributes)(propsWithDefault);
|
61
61
|
const xstyledProps = (0, import_ds_props_helpers.useGetXstyledProps)(propsWithDefault);
|
62
62
|
const firstItem = (0, import_react.useMemo)(() => {
|
63
|
-
const first = items.find((item) => item.type !== "separator");
|
64
|
-
if (first && first.type === "section") {
|
65
|
-
return first.childrens?.find((item) => item.type !== "separator");
|
66
|
-
}
|
63
|
+
const first = items.find((item) => item.type !== "separator" && item.type !== "section");
|
67
64
|
return first;
|
68
65
|
}, [items]);
|
69
66
|
const handleOnKeyDown = (0, import_react.useCallback)(
|
@@ -89,10 +86,18 @@ const MenuButtonContent = () => {
|
|
89
86
|
(e) => {
|
90
87
|
if (e.key === "Enter" || e.key === " ") {
|
91
88
|
e.preventDefault();
|
92
|
-
setFocusedOption(
|
89
|
+
setFocusedOption(firstItem?.dsId || "");
|
90
|
+
}
|
91
|
+
if (e.key === "ArrowDown" && !isOpen) {
|
92
|
+
setIsOpen(true);
|
93
|
+
setFocusedOption(firstItem?.dsId || "");
|
94
|
+
}
|
95
|
+
if (e.key === "ArrowUp" && !isOpen) {
|
96
|
+
setIsOpen(true);
|
97
|
+
setFocusedOption(items[items.length - 1].dsId);
|
93
98
|
}
|
94
99
|
},
|
95
|
-
[items, setFocusedOption]
|
100
|
+
[firstItem?.dsId, isOpen, items, setFocusedOption, setIsOpen]
|
96
101
|
);
|
97
102
|
const handleOnClick = (0, import_react.useCallback)(() => {
|
98
103
|
setIsOpen(!isOpen);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/parts/MenuButtonContent.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useMemo, useCallback, useContext, useRef } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { Menu } from './Menu.js';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\n\nimport { StyledMenuButtonWrapper } from '../styled.js';\nfunction useOnClickOutside(ref: React.RefObject<HTMLElement>, cb: (event: MouseEvent | TouchEvent) => void) {\n React.useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref?.current || ref?.current?.contains?.(event.target as Node)) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb]);\n}\n\nexport const MenuButtonContent = () => {\n const { setFocusedOption, triggerElementRef, setTriggerElementRef, isOpen, setIsOpen, propsWithDefault } =\n useContext(MenuButtonContext);\n\n const { items, TriggerElement, selectionMode, triggerElementProps, menuMinWidth } = propsWithDefault;\n const globalProps = useGetGlobalAttributes(propsWithDefault);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const firstItem = useMemo(() => {\n const first = items.find((item) => item.type !== 'separator'
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useMemo, useCallback, useContext, useRef } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { Menu } from './Menu.js';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\n\nimport { StyledMenuButtonWrapper } from '../styled.js';\nfunction useOnClickOutside(ref: React.RefObject<HTMLElement>, cb: (event: MouseEvent | TouchEvent) => void) {\n React.useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref?.current || ref?.current?.contains?.(event.target as Node)) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb]);\n}\n\nexport const MenuButtonContent = () => {\n const { setFocusedOption, triggerElementRef, setTriggerElementRef, isOpen, setIsOpen, propsWithDefault } =\n useContext(MenuButtonContext);\n\n const { items, TriggerElement, selectionMode, triggerElementProps, menuMinWidth } = propsWithDefault;\n const globalProps = useGetGlobalAttributes(propsWithDefault);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const firstItem = useMemo(() => {\n const first = items.find((item) => item.type !== 'separator' && item.type !== 'section');\n return first;\n }, [items]);\n\n const handleOnKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n triggerElementRef?.focus();\n }\n if (event.key === 'ArrowDown' && isOpen) {\n event.preventDefault();\n setFocusedOption(firstItem?.dsId || '');\n }\n if (event.key === 'ArrowUp' && isOpen) {\n event.preventDefault();\n setFocusedOption(items[items.length - 1].dsId);\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && !isOpen && firstItem) {\n setFocusedOption(firstItem?.dsId);\n }\n },\n [isOpen, firstItem, triggerElementRef, setFocusedOption, items],\n );\n\n const handleOnTriggerOnKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n setFocusedOption(firstItem?.dsId || '');\n }\n if (e.key === 'ArrowDown' && !isOpen) {\n setIsOpen(true);\n setFocusedOption(firstItem?.dsId || '');\n }\n if (e.key === 'ArrowUp' && !isOpen) {\n setIsOpen(true);\n setFocusedOption(items[items.length - 1].dsId);\n }\n },\n [firstItem?.dsId, isOpen, items, setFocusedOption, setIsOpen],\n );\n\n const handleOnClick = useCallback(() => {\n setIsOpen(!isOpen);\n }, [isOpen, setIsOpen]);\n\n const attributes = useMemo(\n () => ({\n 'aria-haspopup': 'true',\n 'aria-expanded': isOpen,\n }),\n [isOpen],\n );\n\n const listeners = useMemo(\n () => ({\n onKeyDown: handleOnTriggerOnKeyDown,\n }),\n [handleOnTriggerOnKeyDown],\n );\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n useOnClickOutside(containerRef, () => setIsOpen(false));\n\n return (\n <StyledMenuButtonWrapper\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n innerRef={containerRef}\n {...globalProps}\n {...xstyledProps}\n >\n <TriggerElement\n isOpen={isOpen}\n innerRef={setTriggerElementRef}\n setIsOpen={setIsOpen}\n attributes={attributes}\n listeners={listeners}\n triggerElementProps={triggerElementProps}\n />\n {isOpen && (\n <Menu\n level={1}\n items={items}\n showSubMenu={isOpen}\n setShowSubMenu={setIsOpen}\n referenceElement={triggerElementRef}\n selectionMode={selectionMode}\n minWidth={menuMinWidth}\n />\n )}\n </StyledMenuButtonWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoGnB;AAnGJ,mBAAgE;AAChE,8BAA2D;AAC3D,kBAAqB;AACrB,6BAAkC;AAElC,oBAAwC;AACxC,SAAS,kBAAkB,KAAmC,IAA8C;AAC1G,eAAAA,QAAM,UAAU,MAAM;AACpB,UAAM,WAAW,CAAC,UAAmC;AAEnD,UAAI,CAAC,KAAK,WAAW,KAAK,SAAS,WAAW,MAAM,MAAc,GAAG;AACnE;AAAA,MACF;AACA,SAAG,KAAK;AAAA,IACV;AACA,aAAS,iBAAiB,aAAa,QAAQ;AAC/C,aAAS,iBAAiB,cAAc,QAAQ;AAChD,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,QAAQ;AAClD,eAAS,oBAAoB,cAAc,QAAQ;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,KAAK,EAAE,CAAC;AACd;AAEO,MAAM,oBAAoB,MAAM;AACrC,QAAM,EAAE,kBAAkB,mBAAmB,sBAAsB,QAAQ,WAAW,iBAAiB,QACrG,yBAAW,w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ACA,CAAC,WAAW,MAAM,QAAQ,OAAO,kBAAkB,SAAS;AAAA,EAC9D;AAEA,QAAM,oBAAgB,0BAAY,MAAM;AACtC,cAAU,CAAC,MAAM;AAAA,EACnB,GAAG,CAAC,QAAQ,SAAS,CAAC;AAEtB,QAAM,iBAAa;AAAA,IACjB,OAAO;AAAA,MACL,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,IACnB;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,gBAAY;AAAA,IAChB,OAAO;AAAA,MACL,WAAW;AAAA,IACb;AAAA,IACA,CAAC,wBAAwB;AAAA,EAC3B;AAEA,QAAM,mBAAe,qBAA8B,IAAI;AACvD,oBAAkB,cAAc,MAAM,UAAU,KAAK,CAAC;AAEtD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,WAAW;AAAA,MACX,UAAU;AAAA,MACT,GAAG;AAAA,MACH,GAAG;AAAA,MAEJ;AAAA;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACF;AAAA,QACC,UACC;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP;AAAA,YACA,aAAa;AAAA,YACb,gBAAgB;AAAA,YAChB,kBAAkB;AAAA,YAClB;AAAA,YACA,UAAU;AAAA;AAAA,QACZ;AAAA;AAAA;AAAA,EAEJ;AAEJ;",
|
6
6
|
"names": ["React"]
|
7
7
|
}
|
@@ -38,6 +38,7 @@ var React = __toESM(require("react"));
|
|
38
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
39
39
|
var import_react = __toESM(require("react"));
|
40
40
|
var import_ds_icons = require("@elliemae/ds-icons");
|
41
|
+
var import_ds_typography = require("@elliemae/ds-typography");
|
41
42
|
var import_ds_system = require("@elliemae/ds-system");
|
42
43
|
var import_ds_grid = require("@elliemae/ds-grid");
|
43
44
|
var import_DSMenuButtonCTX = require("../DSMenuButtonCTX.js");
|
@@ -92,7 +93,7 @@ const MenuItem = ({
|
|
92
93
|
}, [item, onSelectionChange, parentId, selectedKeys, selectionMode]);
|
93
94
|
const handleOnClick = (0, import_react.useCallback)(
|
94
95
|
(e) => {
|
95
|
-
if (selectionMode
|
96
|
+
if (selectionMode !== "single" || item.disabled) {
|
96
97
|
e.stopPropagation();
|
97
98
|
}
|
98
99
|
selectionLogic();
|
@@ -178,7 +179,7 @@ const MenuItem = ({
|
|
178
179
|
isOpen: showSubMenu,
|
179
180
|
level,
|
180
181
|
isVertical,
|
181
|
-
|
182
|
+
isDisabled: item.disabled,
|
182
183
|
children: [
|
183
184
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
184
185
|
import_styled.StyledMenuItemContent,
|
@@ -233,7 +234,7 @@ const MenuItemContent = import_react.default.memo(
|
|
233
234
|
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
234
235
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styled.StyledLeftContent, { children: [
|
235
236
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectionAddon, { selectionMode, item, selectedKeys }),
|
236
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_typography.DSTypography, { variant: "b1", children: item.label })
|
237
238
|
] }),
|
238
239
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledRightContent, { children: item.subitems ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuItemAddon, { isOpen: showSubMenu, level }) : null })
|
239
240
|
] })
|
@@ -244,7 +245,7 @@ const SelectionAddon = ({
|
|
244
245
|
selectionMode
|
245
246
|
}) => {
|
246
247
|
if (selectionMode) {
|
247
|
-
return selectedKeys.includes(item.dsId) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_grid.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.
|
248
|
+
return selectedKeys.includes(item.dsId) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_grid.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.Checkmark, { size: "s", color: ["brand-primary", "600"] }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { width: "16px" } });
|
248
249
|
}
|
249
250
|
return null;
|
250
251
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/parts/MenuItem.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["/* eslint-disable import/no-cycle */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { useState, useCallback, useMemo } from 'react';\nimport {
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
4
|
+
"sourcesContent": ["/* eslint-disable import/no-cycle */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { useState, useCallback, useMemo } from 'react';\nimport { TriangleUpSmall, Checkmark, TriangleDownSmall, ChevronSmallDown, ChevronSmallRight } from '@elliemae/ds-icons';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\nimport {\n StyledMenuItem,\n StyledMenuItemContent,\n StyledLeftContent,\n StyledRightContent,\n StyledSeparator,\n StyledSection,\n} from '../styled.js';\nimport { Menu } from './Menu.js';\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\n\nexport const MenuItemAddon = React.memo(({ level, isOpen }: { level: number; isOpen: boolean }) => {\n if (level === 0)\n return isOpen ? (\n <TriangleUpSmall color={['brand-primary', '600']} />\n ) : (\n <TriangleDownSmall color={['brand-primary', '600']} />\n );\n return isOpen ? (\n <ChevronSmallDown size=\"m\" color={['brand-primary', '600']} />\n ) : (\n <ChevronSmallRight size=\"m\" color={['brand-primary', '600']} />\n );\n});\n\nexport const MenuItem = ({\n innerRef,\n tabIndex,\n onFocus,\n selectionMode,\n item,\n level,\n parentId,\n isVertical,\n}: {\n selectionMode?: 'single' | 'multiple';\n item: MenuButtonT.Item;\n level: number;\n parentId: string | undefined;\n isVertical?: boolean;\n tabIndex: number;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}) => {\n const {\n setFocusedOption,\n focusedOption,\n selectedKeys,\n onSelectionChange,\n triggerElementRef,\n setIsOpen,\n propsWithDefault: { ItemRenderer },\n } = React.useContext(MenuButtonContext);\n const listRef = React.useRef(null);\n const [showSubMenu, setShowSubMenu] = useState(false);\n const [referenceElement, setReferenceElement] = React.useState<HTMLElement | null>(null);\n const itemRef = useCallback(\n (node: HTMLElement | null) => {\n if (node !== null) {\n if (focusedOption === item.dsId) node.focus();\n }\n return node;\n },\n [focusedOption, item.dsId],\n );\n\n const selectionLogic = useCallback(() => {\n if (item.disabled) return;\n if (selectionMode === 'single') {\n const newValue = item.dsId === selectedKeys[0] ? [] : [item.dsId];\n onSelectionChange(newValue, parentId || 'root', item);\n }\n if (selectionMode === 'multiple') {\n const newValue = selectedKeys.includes(item.dsId)\n ? selectedKeys.filter((key: string) => key !== item.dsId)\n : [...selectedKeys, item.dsId];\n onSelectionChange(newValue, parentId || 'root', item);\n }\n }, [item, onSelectionChange, parentId, selectedKeys, selectionMode]);\n\n const handleOnClick: React.MouseEventHandler = useCallback(\n (e) => {\n if (selectionMode !== 'single' || item.disabled) {\n e.stopPropagation();\n }\n selectionLogic();\n },\n [item.disabled, selectionLogic, selectionMode],\n );\n const onItemKeyDown: React.KeyboardEventHandler = useCallback(\n (event) => {\n // Enter to close the menu and focus the trigger element\n if (event.key === 'Enter' && !item.disabled) {\n setIsOpen(false);\n triggerElementRef?.focus();\n }\n // selection\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n selectionLogic();\n }\n // open submenu logic\n if (\n ((event.key === 'ArrowDown' && level === 0) || (event.key === 'ArrowRight' && level !== 0)) &&\n item.subitems\n ) {\n event.preventDefault();\n event.stopPropagation();\n setShowSubMenu(true);\n setFocusedOption(item.subitems[0].dsId);\n }\n\n // close submenu logic\n if (event.key === 'ArrowLeft' && level >= 2) {\n event.preventDefault();\n event.stopPropagation();\n if (parentId) setFocusedOption(parentId);\n }\n if (event.key === 'Escape' && level > 0) {\n if (parentId !== undefined) {\n setFocusedOption(parentId);\n }\n }\n },\n [item.disabled, item.subitems, level, setIsOpen, triggerElementRef, selectionLogic, setFocusedOption, parentId],\n );\n\n const handleOnLIKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n // logic to close all submenus and focus on parent\n if (e.key === 'Enter') {\n setShowSubMenu(false);\n if (level === 0) {\n setFocusedOption(item.dsId);\n }\n }\n },\n [item.dsId, level, setFocusedOption],\n );\n\n const handleOnMouseEnter = useCallback(() => {\n setShowSubMenu(true);\n setFocusedOption(item.dsId);\n }, [item.dsId, setFocusedOption]);\n\n const handleOnMouseLeave = useCallback(() => {\n setShowSubMenu(false);\n }, []);\n\n const ariaExpanded = useMemo(() => {\n if (item.subitems) {\n return showSubMenu ? 'true' : 'false';\n }\n return undefined;\n }, [item.subitems, showSubMenu]);\n\n const role = useMemo(() => {\n if (selectionMode === 'single') {\n return 'menuitemradio';\n }\n if (selectionMode === 'multiple') {\n return 'menuitemcheckbox';\n }\n return 'menuitem';\n }, [selectionMode]);\n\n const ariaChecked = useMemo(() => {\n if (selectionMode === 'multiple' || selectionMode === 'single') {\n return selectedKeys.includes(item.dsId) ? 'true' : 'false';\n }\n return undefined;\n }, [item.dsId, selectionMode, selectedKeys]);\n\n return (\n <StyledMenuItem\n role=\"none\"\n innerRef={listRef}\n onMouseEnter={handleOnMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n onKeyDown={handleOnLIKeyDown}\n isOpen={showSubMenu}\n level={level}\n isVertical={isVertical}\n isDisabled={item.disabled}\n >\n <StyledMenuItemContent\n role={role}\n aria-checked={ariaChecked}\n aria-haspopup={item.subitems ? 'true' : 'false'}\n aria-expanded={ariaExpanded}\n innerRef={mergeRefs(innerRef, itemRef, setReferenceElement)}\n onKeyDown={onItemKeyDown}\n onClick={handleOnClick}\n hasChildren={item.subitems !== undefined}\n onFocus={onFocus}\n tabIndex={tabIndex}\n aria-disabled={item.disabled ? 'true' : 'false'}\n >\n {ItemRenderer ? (\n <ItemRenderer item={item} isSelected={selectedKeys.includes(item.dsId)} />\n ) : (\n <MenuItemContent\n item={item}\n selectionMode={selectionMode}\n selectedKeys={selectedKeys}\n showSubMenu={showSubMenu}\n level={level}\n />\n )}\n </StyledMenuItemContent>\n {item.subitems && showSubMenu && (\n <Menu\n level={level + 1}\n items={item.subitems}\n showSubMenu={showSubMenu}\n setShowSubMenu={setShowSubMenu}\n referenceElement={referenceElement}\n parentId={item.dsId}\n selectionMode={item.selectionMode}\n minWidth={item.minWidth}\n />\n )}\n </StyledMenuItem>\n );\n};\n\nconst MenuItemContent = React.memo(\n ({\n item,\n selectionMode,\n selectedKeys,\n showSubMenu,\n level,\n }: {\n item: MenuButtonT.Item;\n selectionMode?: 'single' | 'multiple';\n selectedKeys: string[];\n showSubMenu: boolean;\n level: number;\n }) => (\n <>\n <StyledLeftContent>\n <SelectionAddon selectionMode={selectionMode} item={item} selectedKeys={selectedKeys} />\n <DSTypography variant=\"b1\">{item.label}</DSTypography>\n </StyledLeftContent>\n <StyledRightContent>\n {item.subitems ? <MenuItemAddon isOpen={showSubMenu} level={level} /> : null}\n </StyledRightContent>\n </>\n ),\n);\n\nconst SelectionAddon = ({\n item,\n selectedKeys,\n selectionMode,\n}: {\n item: MenuButtonT.Item;\n selectedKeys: string[];\n selectionMode?: 'single' | 'multiple';\n}) => {\n if (selectionMode) {\n return selectedKeys.includes(item.dsId) ? (\n <Grid>\n <Checkmark size=\"s\" color={['brand-primary', '600']} />\n </Grid>\n ) : (\n <div style={{ width: '16px' }} />\n );\n }\n return null;\n};\n\nexport const Separator = () => (\n <li role=\"none\" style={{ padding: '0px 16px' }}>\n <StyledSeparator role=\"separator\" />\n </li>\n);\n\nexport const Section = ({ item }: { item: MenuButtonT.Item }) => (\n <li role=\"none\" style={{ padding: '0px 16px', minHeight: 24, display: 'flex', alignItems: 'center' }}>\n <StyledSection role=\"presentation\">{item.label}</StyledSection>\n </li>\n);\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADyBjB;AArBN,mBAAsD;AACtD,sBAAmG;AAEnG,2BAA6B;AAC7B,uBAA0B;AAC1B,qBAAqB;AACrB,6BAAkC;AAClC,oBAOO;AACP,kBAAqB;AAGd,MAAM,gBAAgB,aAAAA,QAAM,KAAK,CAAC,EAAE,OAAO,OAAO,MAA0C;AACjG,MAAI,UAAU;AACZ,WAAO,SACL,4CAAC,mCAAgB,OAAO,CAAC,iBAAiB,KAAK,GAAG,IAElD,4CAAC,qCAAkB,OAAO,CAAC,iBAAiB,KAAK,GAAG;AAExD,SAAO,SACL,4CAAC,oCAAiB,MAAK,KAAI,OAAO,CAAC,iBAAiB,KAAK,GAAG,IAE5D,4CAAC,qCAAkB,MAAK,KAAI,OAAO,CAAC,iBAAiB,KAAK,GAAG;AAEjE,CAAC;AAEM,MAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MASM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA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AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAU,KAAK;AAAA,YACf,eAAe,KAAK;AAAA,YACpB,UAAU,KAAK;AAAA;AAAA,QACjB;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,MAAM,kBAAkB,aAAAA,QAAM;AAAA,EAC5B,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAOE,4EACE;AAAA,iDAAC,mCACC;AAAA,kDAAC,kBAAe,eAA8B,MAAY,cAA4B;AAAA,MACtF,4CAAC,qCAAa,SAAQ,MAAM,eAAK,OAAM;AAAA,OACzC;AAAA,IACA,4CAAC,oCACE,eAAK,WAAW,4CAAC,iBAAc,QAAQ,aAAa,OAAc,IAAK,MAC1E;AAAA,KACF;AAEJ;AAEA,MAAM,iBAAiB,CAAC;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AACF,MAIM;AACJ,MAAI,eAAe;AACjB,WAAO,aAAa,SAAS,KAAK,IAAI,IACpC,4CAAC,uBACC,sDAAC,6BAAU,MAAK,KAAI,OAAO,CAAC,iBAAiB,KAAK,GAAG,GACvD,IAEA,4CAAC,SAAI,OAAO,EAAE,OAAO,OAAO,GAAG;AAAA,EAEnC;AACA,SAAO;AACT;AAEO,MAAM,YAAY,MACvB,4CAAC,QAAG,MAAK,QAAO,OAAO,EAAE,SAAS,WAAW,GAC3C,sDAAC,iCAAgB,MAAK,aAAY,GACpC;AAGK,MAAM,UAAU,CAAC,EAAE,KAAK,MAC7B,4CAAC,QAAG,MAAK,QAAO,OAAO,EAAE,SAAS,YAAY,WAAW,IAAI,SAAS,QAAQ,YAAY,SAAS,GACjG,sDAAC,+BAAc,MAAK,gBAAgB,eAAK,OAAM,GACjD;",
|
6
6
|
"names": ["React"]
|
7
7
|
}
|
package/dist/cjs/styled.js
CHANGED
@@ -41,16 +41,6 @@ __export(styled_exports, {
|
|
41
41
|
module.exports = __toCommonJS(styled_exports);
|
42
42
|
var React = __toESM(require("react"));
|
43
43
|
var import_ds_system = require("@elliemae/ds-system");
|
44
|
-
const disabledOption = () => import_ds_system.css`
|
45
|
-
a {
|
46
|
-
color: ${({ theme }) => theme.colors.neutral[500]};
|
47
|
-
}
|
48
|
-
background-color: ${({ theme }) => theme.colors.neutral["000"]};
|
49
|
-
cursor: not-allowed;
|
50
|
-
* {
|
51
|
-
cursor: not-allowed;
|
52
|
-
}
|
53
|
-
`;
|
54
44
|
const StyledMenuButtonWrapper = (0, import_ds_system.styled)("div")`
|
55
45
|
position: relative;
|
56
46
|
`;
|
@@ -81,9 +71,12 @@ const StyledMenuItem = (0, import_ds_system.styled)("li")`
|
|
81
71
|
min-width: 200px;
|
82
72
|
}
|
83
73
|
|
84
|
-
|
85
|
-
|
86
|
-
|
74
|
+
${({ isDisabled, theme }) => isDisabled && `
|
75
|
+
color: ${theme.colors.neutral[500]};
|
76
|
+
* {
|
77
|
+
cursor: not-allowed;
|
78
|
+
}
|
79
|
+
`}
|
87
80
|
|
88
81
|
a:focus {
|
89
82
|
outline: 1px solid brand-500;
|
@@ -91,8 +84,6 @@ const StyledMenuItem = (0, import_ds_system.styled)("li")`
|
|
91
84
|
}
|
92
85
|
|
93
86
|
${({ isOpen, theme }) => isOpen ? `background-color: ${theme.colors.brand["200"]}` : ""}
|
94
|
-
|
95
|
-
${({ disabled }) => disabled ? disabledOption() : ""}
|
96
87
|
`;
|
97
88
|
const StyledMenuItemContent = (0, import_ds_system.styled)("a")`
|
98
89
|
display: flex;
|
@@ -136,5 +127,6 @@ const StyledSection = (0, import_ds_system.styled)("div")`
|
|
136
127
|
display: flex;
|
137
128
|
flex-direction: column;
|
138
129
|
gap: 1px;
|
130
|
+
color: neutral-500;
|
139
131
|
`;
|
140
132
|
//# sourceMappingURL=styled.js.map
|
package/dist/cjs/styled.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/styled.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["import { xStyledCommonProps, styled
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
4
|
+
"sourcesContent": ["import { xStyledCommonProps, styled } from '@elliemae/ds-system';\n\nexport const StyledMenuButtonWrapper = styled('div')`\n position: relative;\n`;\n\nexport const StyledMenu = styled('ul')`\n display: flex;\n flex-direction: column;\n gap: 1px;\n list-style-type: none;\n padding: 0;\n margin: 0;\n background-color: white;\n /* height: 100%; */\n ${xStyledCommonProps}\n box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1),\n 0 2px 4px rgba(16, 22, 26, 0.2),\n 0 8px 24px rgba(16, 22, 26, 0.2);\n`;\n\nexport const StyledMenuItem = styled('li')<{\n isVertical?: boolean;\n level?: number;\n isOpen?: boolean;\n isDisabled?: boolean;\n}>`\n position: relative;\n background-color: white;\n display: flex;\n margin: 0;\n min-height: 32px;\n width: ${({ isVertical, level }) => (!isVertical && level === 0 ? 'auto' : '100%')};\n cursor: pointer;\n\n ul li {\n min-width: 200px;\n }\n\n ${({ isDisabled, theme }) =>\n isDisabled &&\n `\n color: ${theme.colors.neutral[500]};\n * {\n cursor: not-allowed;\n }\n `}\n\n a:focus {\n outline: 1px solid brand-500;\n background-color: brand-200;\n }\n\n ${({ isOpen, theme }) => (isOpen ? `background-color: ${theme.colors.brand['200']}` : '')}\n`;\n\nexport const StyledMenuItemContent = styled('a')<{ hasChildren?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n text-decoration: none;\n color: inherit;\n &:focus {\n outline: none;\n }\n ${({ hasChildren }) => (hasChildren ? 'padding-left: 16px;' : 'padding: 0 16px;')}\n ${xStyledCommonProps}\n`;\n\nexport const StyledLeftContent = styled('div')`\n display: flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n`;\n\nexport const StyledRightContent = styled('div')`\n display: flex;\n align-items: center;\n`;\n\nexport const StyledSeparator = styled('hr')`\n border: 0;\n border-top: 1px solid #697489;\n margin: 4px 0px;\n padding: 0;\n`;\n\nexport const StyledSectionLabel = styled('div')`\n color: neutral-500;\n display: flex;\n flex-direction: column;\n gap: 1px;\n padding: 0 16px;\n min-height: 24px;\n justify-content: center;\n`;\n\nexport const StyledSection = styled('div')`\n display: flex;\n flex-direction: column;\n gap: 1px;\n color: neutral-500;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA2C;AAEpC,MAAM,8BAA0B,yBAAO,KAAK;AAAA;AAAA;AAI5C,MAAM,iBAAa,yBAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASjC,mCAAkB;AAAA;AAAA;AAAA;AAAA;AAMf,MAAM,qBAAiB,yBAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAW9B,CAAC,EAAE,YAAY,MAAM,MAAO,CAAC,cAAc,UAAU,IAAI,SAAS,MAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhF,CAAC,EAAE,YAAY,MAAM,MACrB,cACA;AAAA,aACS,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,GAInC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOC,CAAC,EAAE,QAAQ,MAAM,MAAO,SAAS,qBAAqB,MAAM,OAAO,MAAM,KAAK,CAAC,KAAK,EAAG;AAAA;AAGpF,MAAM,4BAAwB,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAU3C,CAAC,EAAE,YAAY,MAAO,cAAc,wBAAwB,kBAAmB;AAAA,IAC/E,mCAAkB;AAAA;AAGf,MAAM,wBAAoB,yBAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAOtC,MAAM,yBAAqB,yBAAO,KAAK;AAAA;AAAA;AAAA;AAKvC,MAAM,sBAAkB,yBAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAOnC,MAAM,yBAAqB,yBAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUvC,MAAM,oBAAgB,yBAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/ItemFactory.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\n/* eslint-disable arrow-body-style */\nimport React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { MenuItem, Section, Separator } from './MenuItem.js';\n\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\ninterface ItemFactoryProps {\n item: MenuButtonT.Item;\n level: number;\n selectionMode?: 'single' | 'multiple';\n parentId?: string;\n tabIndex: TypescriptHelpersT.WCAGTabIndex;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}\n\nexport const ItemFactory: React.FC<ItemFactoryProps> = ({\n item,\n innerRef,\n onFocus,\n tabIndex,\n level,\n selectionMode,\n parentId,\n}) => {\n if (item.type === 'separator') {\n return <Separator />;\n }\n if (item.type === 'section') {\n return <Section item={item} />;\n }\n return (\n <MenuItem\n key={item.dsId}\n item={item}\n innerRef={innerRef}\n onFocus={onFocus}\n tabIndex={tabIndex}\n level={level}\n parentId={parentId}\n selectionMode={selectionMode}\n />\n );\n};\n"],
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;AC2BZ;AAvBX,SAAS,UAAU,SAAS,iBAAiB;AAatC,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO,oBAAC,aAAU;AAAA,EACpB;AACA,MAAI,KAAK,SAAS,WAAW;AAC3B,WAAO,oBAAC,WAAQ,MAAY;AAAA,EAC9B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\n/* eslint-disable arrow-body-style */\nimport React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { MenuItem, Section, Separator } from './MenuItem.js';\n\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\ninterface ItemFactoryProps {\n item: MenuButtonT.Item;\n level: number;\n selectionMode?: 'single' | 'multiple';\n parentId?: string;\n tabIndex: TypescriptHelpersT.WCAGTabIndex;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}\n\nexport const ItemFactory: React.FC<ItemFactoryProps> = ({\n item,\n innerRef,\n onFocus,\n tabIndex,\n level,\n selectionMode,\n parentId,\n}) => {\n if (item.type === 'separator') {\n return <Separator />;\n }\n if (item.type === 'section') {\n return <Section item={item} />;\n }\n return (\n <MenuItem\n key={item.dsId}\n item={item}\n innerRef={innerRef}\n onFocus={onFocus}\n tabIndex={tabIndex}\n level={level}\n parentId={parentId}\n selectionMode={selectionMode || item.type}\n />\n );\n};\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC2BZ;AAvBX,SAAS,UAAU,SAAS,iBAAiB;AAatC,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO,oBAAC,aAAU;AAAA,EACpB;AACA,MAAI,KAAK,SAAS,WAAW;AAC3B,WAAO,oBAAC,WAAQ,MAAY;AAAA,EAC9B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,iBAAiB,KAAK;AAAA;AAAA,IAPhC,KAAK;AAAA,EAQZ;AAEJ;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/dist/esm/parts/Menu.js
CHANGED
@@ -23,11 +23,11 @@ const Menu = (props) => {
|
|
23
23
|
return;
|
24
24
|
}
|
25
25
|
if (listRect.right > window.innerWidth) {
|
26
|
-
setCoords({ x: -(rect?.width || 0), y: 0 });
|
26
|
+
setCoords({ x: -(minWidth || rect?.width || 0), y: 0 });
|
27
27
|
} else {
|
28
28
|
setCoords({ x: rect?.width || 0, y: 0 });
|
29
29
|
}
|
30
|
-
}, [level, rect?.height, rect?.width, referenceElement]);
|
30
|
+
}, [level, minWidth, rect?.height, rect?.width, referenceElement]);
|
31
31
|
const config = {
|
32
32
|
options: items.filter((item) => item.type !== "separator" && item.type !== "section").map((item) => item.dsId),
|
33
33
|
direction: DIRECTIONS.VERTICAL,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Menu.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\nimport React, { useState, useMemo, useCallback, useContext } from 'react';\nimport { useKeyboardNavigation, DIRECTIONS } from '@elliemae/ds-hooks-keyboard-navigation';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\nimport { StyledMenu } from '../styled.js';\nimport { ItemFactory } from './ItemFactory.js';\n\ninterface SubMenuProps {\n referenceElement: HTMLElement | null;\n showSubMenu: boolean;\n selectionMode?: 'single' | 'multiple';\n setShowSubMenu: React.Dispatch<React.SetStateAction<boolean>>;\n parentId?: string;\n level: number;\n items: MenuButtonT.Item[];\n minWidth?: string | number;\n}\n\nexport const Menu: React.FC<SubMenuProps> = (props) => {\n const { referenceElement, showSubMenu, selectionMode, setShowSubMenu, parentId, level, items, minWidth } = props;\n const { focusedOption, setFocusedOption } = useContext(MenuButtonContext);\n const listRef = React.useRef<HTMLDivElement>(null);\n const rect = referenceElement?.getBoundingClientRect();\n const [coords, setCoords] = useState<{ x: number; y: number }>({ x: rect?.width ?? 0, y: 0 });\n\n // this logic will be part of the new popper custom hook\n React.useLayoutEffect(() => {\n const listRect = listRef?.current?.getBoundingClientRect();\n if (!listRect) return;\n if (level === 1) {\n if (listRect.bottom < window.innerHeight) {\n setCoords({ x: 0, y: rect?.height || 0 });\n } else {\n setCoords({ x: 0, y: -listRect.height });\n }\n return;\n }\n if (listRect.right > window.innerWidth) {\n setCoords({ x: -(rect?.width || 0), y: 0 });\n } else {\n setCoords({ x: rect?.width || 0, y: 0 });\n }\n }, [level, rect?.height, rect?.width, referenceElement]);\n\n const config = {\n options: items.filter((item) => item.type !== 'separator' && item.type !== 'section').map((item) => item.dsId),\n direction: DIRECTIONS.VERTICAL,\n focusedOption,\n setFocusedOption,\n };\n\n const { getWrapperProps, getItemProps } = useKeyboardNavigation(config);\n\n const { onKeyDown, onBlur } = getWrapperProps();\n\n const handleOnMenuKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.stopPropagation();\n }\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n const handleOnBlur: React.FocusEventHandler<HTMLDivElement> = useCallback(\n (e) => {\n setTimeout(() => {\n if (!listRef.current?.contains(document.activeElement)) {\n setShowSubMenu(false);\n }\n });\n onBlur(e);\n },\n [onBlur, setShowSubMenu],\n );\n\n const subMenuStyles = useMemo(\n () => ({\n position: 'absolute',\n top: coords.y,\n left: coords.x,\n zIndex: 1001 + level,\n minWidth,\n }),\n [coords, level, minWidth],\n );\n\n if (!referenceElement || !showSubMenu) return null;\n\n return (\n <StyledMenu\n innerRef={listRef}\n role=\"menu\"\n onKeyDown={handleOnMenuKeyDown}\n onBlur={handleOnBlur}\n style={subMenuStyles}\n >\n {items.map((item) => (\n <ItemFactory\n key={item.dsId}\n item={item}\n selectionMode={selectionMode}\n level={level}\n parentId={parentId}\n {...getItemProps(item.dsId)}\n />\n ))}\n </StyledMenu>\n );\n};\n"],
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACoGf;AAnGR,OAAOA,UAAS,UAAU,SAAS,aAAa,kBAAkB;AAClE,SAAS,uBAAuB,kBAAkB;AAClD,SAAS,yBAAyB;AAElC,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAarB,MAAM,OAA+B,CAAC,UAAU;AACrD,QAAM,EAAE,kBAAkB,aAAa,eAAe,gBAAgB,UAAU,OAAO,OAAO,SAAS,IAAI;AAC3G,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,iBAAiB;AACxE,QAAM,UAAUA,OAAM,OAAuB,IAAI;AACjD,QAAM,OAAO,kBAAkB,sBAAsB;AACrD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAmC,EAAE,GAAG,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;AAG5F,EAAAA,OAAM,gBAAgB,MAAM;AAC1B,UAAM,WAAW,SAAS,SAAS,sBAAsB;AACzD,QAAI,CAAC,SAAU;AACf,QAAI,UAAU,GAAG;AACf,UAAI,SAAS,SAAS,OAAO,aAAa;AACxC,kBAAU,EAAE,GAAG,GAAG,GAAG,MAAM,UAAU,EAAE,CAAC;AAAA,MAC1C,OAAO;AACL,kBAAU,EAAE,GAAG,GAAG,GAAG,CAAC,SAAS,OAAO,CAAC;AAAA,MACzC;AACA;AAAA,IACF;AACA,QAAI,SAAS,QAAQ,OAAO,YAAY;AACtC,gBAAU,EAAE,GAAG,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,CAAC;AAAA,
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\nimport React, { useState, useMemo, useCallback, useContext } from 'react';\nimport { useKeyboardNavigation, DIRECTIONS } from '@elliemae/ds-hooks-keyboard-navigation';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\nimport { StyledMenu } from '../styled.js';\nimport { ItemFactory } from './ItemFactory.js';\n\ninterface SubMenuProps {\n referenceElement: HTMLElement | null;\n showSubMenu: boolean;\n selectionMode?: 'single' | 'multiple';\n setShowSubMenu: React.Dispatch<React.SetStateAction<boolean>>;\n parentId?: string;\n level: number;\n items: MenuButtonT.Item[];\n minWidth?: string | number;\n}\n\nexport const Menu: React.FC<SubMenuProps> = (props) => {\n const { referenceElement, showSubMenu, selectionMode, setShowSubMenu, parentId, level, items, minWidth } = props;\n const { focusedOption, setFocusedOption } = useContext(MenuButtonContext);\n const listRef = React.useRef<HTMLDivElement>(null);\n const rect = referenceElement?.getBoundingClientRect();\n const [coords, setCoords] = useState<{ x: number; y: number }>({ x: rect?.width ?? 0, y: 0 });\n\n // this logic will be part of the new popper custom hook\n React.useLayoutEffect(() => {\n const listRect = listRef?.current?.getBoundingClientRect();\n if (!listRect) return;\n if (level === 1) {\n if (listRect.bottom < window.innerHeight) {\n setCoords({ x: 0, y: rect?.height || 0 });\n } else {\n setCoords({ x: 0, y: -listRect.height });\n }\n return;\n }\n if (listRect.right > window.innerWidth) {\n setCoords({ x: -(minWidth || rect?.width || 0), y: 0 });\n } else {\n setCoords({ x: rect?.width || 0, y: 0 });\n }\n }, [level, minWidth, rect?.height, rect?.width, referenceElement]);\n\n const config = {\n options: items.filter((item) => item.type !== 'separator' && item.type !== 'section').map((item) => item.dsId),\n direction: DIRECTIONS.VERTICAL,\n focusedOption,\n setFocusedOption,\n };\n\n const { getWrapperProps, getItemProps } = useKeyboardNavigation(config);\n\n const { onKeyDown, onBlur } = getWrapperProps();\n\n const handleOnMenuKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.stopPropagation();\n }\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n const handleOnBlur: React.FocusEventHandler<HTMLDivElement> = useCallback(\n (e) => {\n setTimeout(() => {\n if (!listRef.current?.contains(document.activeElement)) {\n setShowSubMenu(false);\n }\n });\n onBlur(e);\n },\n [onBlur, setShowSubMenu],\n );\n\n const subMenuStyles = useMemo(\n () => ({\n position: 'absolute',\n top: coords.y,\n left: coords.x,\n zIndex: 1001 + level,\n minWidth,\n }),\n [coords, level, minWidth],\n );\n\n if (!referenceElement || !showSubMenu) return null;\n\n return (\n <StyledMenu\n innerRef={listRef}\n role=\"menu\"\n onKeyDown={handleOnMenuKeyDown}\n onBlur={handleOnBlur}\n style={subMenuStyles}\n >\n {items.map((item) => (\n <ItemFactory\n key={item.dsId}\n item={item}\n selectionMode={selectionMode}\n level={level}\n parentId={parentId}\n {...getItemProps(item.dsId)}\n />\n ))}\n </StyledMenu>\n );\n};\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoGf;AAnGR,OAAOA,UAAS,UAAU,SAAS,aAAa,kBAAkB;AAClE,SAAS,uBAAuB,kBAAkB;AAClD,SAAS,yBAAyB;AAElC,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAarB,MAAM,OAA+B,CAAC,UAAU;AACrD,QAAM,EAAE,kBAAkB,aAAa,eAAe,gBAAgB,UAAU,OAAO,OAAO,SAAS,IAAI;AAC3G,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,iBAAiB;AACxE,QAAM,UAAUA,OAAM,OAAuB,IA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AwD;AAAA,IAC5D,CAAC,MAAM;AACL,iBAAW,MAAM;AACf,YAAI,CAAC,QAAQ,SAAS,SAAS,SAAS,aAAa,GAAG;AACtD,yBAAe,KAAK;AAAA,QACtB;AAAA,MACF,CAAC;AACD,aAAO,CAAC;AAAA,IACV;AAAA,IACA,CAAC,QAAQ,cAAc;AAAA,EACzB;AAEA,QAAM,gBAAgB;AAAA,IACpB,OAAO;AAAA,MACL,UAAU;AAAA,MACV,KAAK,OAAO;AAAA,MACZ,MAAM,OAAO;AAAA,MACb,QAAQ,OAAO;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,QAAQ,OAAO,QAAQ;AAAA,EAC1B;AAEA,MAAI,CAAC,oBAAoB,CAAC,YAAa,QAAO;AAE9C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,MAAK;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,OAAO;AAAA,MAEN,gBAAM,IAAI,CAAC,SACV;AAAA,QAAC;AAAA;AAAA,UAEC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACC,GAAG,aAAa,KAAK,IAAI;AAAA;AAAA,QALrB,KAAK;AAAA,MAMZ,CACD;AAAA;AAAA,EACH;AAEJ;",
|
6
6
|
"names": ["React"]
|
7
7
|
}
|
@@ -27,10 +27,7 @@ const MenuButtonContent = () => {
|
|
27
27
|
const globalProps = useGetGlobalAttributes(propsWithDefault);
|
28
28
|
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
29
29
|
const firstItem = useMemo(() => {
|
30
|
-
const first = items.find((item) => item.type !== "separator");
|
31
|
-
if (first && first.type === "section") {
|
32
|
-
return first.childrens?.find((item) => item.type !== "separator");
|
33
|
-
}
|
30
|
+
const first = items.find((item) => item.type !== "separator" && item.type !== "section");
|
34
31
|
return first;
|
35
32
|
}, [items]);
|
36
33
|
const handleOnKeyDown = useCallback(
|
@@ -56,10 +53,18 @@ const MenuButtonContent = () => {
|
|
56
53
|
(e) => {
|
57
54
|
if (e.key === "Enter" || e.key === " ") {
|
58
55
|
e.preventDefault();
|
59
|
-
setFocusedOption(
|
56
|
+
setFocusedOption(firstItem?.dsId || "");
|
57
|
+
}
|
58
|
+
if (e.key === "ArrowDown" && !isOpen) {
|
59
|
+
setIsOpen(true);
|
60
|
+
setFocusedOption(firstItem?.dsId || "");
|
61
|
+
}
|
62
|
+
if (e.key === "ArrowUp" && !isOpen) {
|
63
|
+
setIsOpen(true);
|
64
|
+
setFocusedOption(items[items.length - 1].dsId);
|
60
65
|
}
|
61
66
|
},
|
62
|
-
[items, setFocusedOption]
|
67
|
+
[firstItem?.dsId, isOpen, items, setFocusedOption, setIsOpen]
|
63
68
|
);
|
64
69
|
const handleOnClick = useCallback(() => {
|
65
70
|
setIsOpen(!isOpen);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/MenuButtonContent.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useMemo, useCallback, useContext, useRef } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { Menu } from './Menu.js';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\n\nimport { StyledMenuButtonWrapper } from '../styled.js';\nfunction useOnClickOutside(ref: React.RefObject<HTMLElement>, cb: (event: MouseEvent | TouchEvent) => void) {\n React.useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref?.current || ref?.current?.contains?.(event.target as Node)) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb]);\n}\n\nexport const MenuButtonContent = () => {\n const { setFocusedOption, triggerElementRef, setTriggerElementRef, isOpen, setIsOpen, propsWithDefault } =\n useContext(MenuButtonContext);\n\n const { items, TriggerElement, selectionMode, triggerElementProps, menuMinWidth } = propsWithDefault;\n const globalProps = useGetGlobalAttributes(propsWithDefault);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const firstItem = useMemo(() => {\n const first = items.find((item) => item.type !== 'separator'
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useMemo, useCallback, useContext, useRef } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { Menu } from './Menu.js';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\n\nimport { StyledMenuButtonWrapper } from '../styled.js';\nfunction useOnClickOutside(ref: React.RefObject<HTMLElement>, cb: (event: MouseEvent | TouchEvent) => void) {\n React.useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref?.current || ref?.current?.contains?.(event.target as Node)) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb]);\n}\n\nexport const MenuButtonContent = () => {\n const { setFocusedOption, triggerElementRef, setTriggerElementRef, isOpen, setIsOpen, propsWithDefault } =\n useContext(MenuButtonContext);\n\n const { items, TriggerElement, selectionMode, triggerElementProps, menuMinWidth } = propsWithDefault;\n const globalProps = useGetGlobalAttributes(propsWithDefault);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const firstItem = useMemo(() => {\n const first = items.find((item) => item.type !== 'separator' && item.type !== 'section');\n return first;\n }, [items]);\n\n const handleOnKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n triggerElementRef?.focus();\n }\n if (event.key === 'ArrowDown' && isOpen) {\n event.preventDefault();\n setFocusedOption(firstItem?.dsId || '');\n }\n if (event.key === 'ArrowUp' && isOpen) {\n event.preventDefault();\n setFocusedOption(items[items.length - 1].dsId);\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && !isOpen && firstItem) {\n setFocusedOption(firstItem?.dsId);\n }\n },\n [isOpen, firstItem, triggerElementRef, setFocusedOption, items],\n );\n\n const handleOnTriggerOnKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n setFocusedOption(firstItem?.dsId || '');\n }\n if (e.key === 'ArrowDown' && !isOpen) {\n setIsOpen(true);\n setFocusedOption(firstItem?.dsId || '');\n }\n if (e.key === 'ArrowUp' && !isOpen) {\n setIsOpen(true);\n setFocusedOption(items[items.length - 1].dsId);\n }\n },\n [firstItem?.dsId, isOpen, items, setFocusedOption, setIsOpen],\n );\n\n const handleOnClick = useCallback(() => {\n setIsOpen(!isOpen);\n }, [isOpen, setIsOpen]);\n\n const attributes = useMemo(\n () => ({\n 'aria-haspopup': 'true',\n 'aria-expanded': isOpen,\n }),\n [isOpen],\n );\n\n const listeners = useMemo(\n () => ({\n onKeyDown: handleOnTriggerOnKeyDown,\n }),\n [handleOnTriggerOnKeyDown],\n );\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n useOnClickOutside(containerRef, () => setIsOpen(false));\n\n return (\n <StyledMenuButtonWrapper\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n innerRef={containerRef}\n {...globalProps}\n {...xstyledProps}\n >\n <TriggerElement\n isOpen={isOpen}\n innerRef={setTriggerElementRef}\n setIsOpen={setIsOpen}\n attributes={attributes}\n listeners={listeners}\n triggerElementProps={triggerElementProps}\n />\n {isOpen && (\n <Menu\n level={1}\n items={items}\n showSubMenu={isOpen}\n setShowSubMenu={setIsOpen}\n referenceElement={triggerElementRef}\n selectionMode={selectionMode}\n minWidth={menuMinWidth}\n />\n )}\n </StyledMenuButtonWrapper>\n );\n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,MACT,WAAW;AAAA,MACX,UAAU;AAAA,MACT,GAAG;AAAA,MACH,GAAG;AAAA,MAEJ;AAAA;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACF;AAAA,QACC,UACC;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP;AAAA,YACA,aAAa;AAAA,YACb,gBAAgB;AAAA,YAChB,kBAAkB;AAAA,YAClB;AAAA,YACA,UAAU;AAAA;AAAA,QACZ;AAAA;AAAA;AAAA,EAEJ;AAEJ;",
|
6
6
|
"names": ["React"]
|
7
7
|
}
|
@@ -1,13 +1,8 @@
|
|
1
1
|
import * as React from "react";
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
3
3
|
import React2, { useState, useCallback, useMemo } from "react";
|
4
|
-
import {
|
5
|
-
|
6
|
-
CheckmarkXsmall,
|
7
|
-
TriangleDownSmall,
|
8
|
-
ChevronSmallDown,
|
9
|
-
ChevronSmallRight
|
10
|
-
} from "@elliemae/ds-icons";
|
4
|
+
import { TriangleUpSmall, Checkmark, TriangleDownSmall, ChevronSmallDown, ChevronSmallRight } from "@elliemae/ds-icons";
|
5
|
+
import { DSTypography } from "@elliemae/ds-typography";
|
11
6
|
import { mergeRefs } from "@elliemae/ds-system";
|
12
7
|
import { Grid } from "@elliemae/ds-grid";
|
13
8
|
import { MenuButtonContext } from "../DSMenuButtonCTX.js";
|
@@ -69,7 +64,7 @@ const MenuItem = ({
|
|
69
64
|
}, [item, onSelectionChange, parentId, selectedKeys, selectionMode]);
|
70
65
|
const handleOnClick = useCallback(
|
71
66
|
(e) => {
|
72
|
-
if (selectionMode
|
67
|
+
if (selectionMode !== "single" || item.disabled) {
|
73
68
|
e.stopPropagation();
|
74
69
|
}
|
75
70
|
selectionLogic();
|
@@ -155,7 +150,7 @@ const MenuItem = ({
|
|
155
150
|
isOpen: showSubMenu,
|
156
151
|
level,
|
157
152
|
isVertical,
|
158
|
-
|
153
|
+
isDisabled: item.disabled,
|
159
154
|
children: [
|
160
155
|
/* @__PURE__ */ jsx(
|
161
156
|
StyledMenuItemContent,
|
@@ -210,7 +205,7 @@ const MenuItemContent = React2.memo(
|
|
210
205
|
}) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
211
206
|
/* @__PURE__ */ jsxs(StyledLeftContent, { children: [
|
212
207
|
/* @__PURE__ */ jsx(SelectionAddon, { selectionMode, item, selectedKeys }),
|
213
|
-
/* @__PURE__ */ jsx(
|
208
|
+
/* @__PURE__ */ jsx(DSTypography, { variant: "b1", children: item.label })
|
214
209
|
] }),
|
215
210
|
/* @__PURE__ */ jsx(StyledRightContent, { children: item.subitems ? /* @__PURE__ */ jsx(MenuItemAddon, { isOpen: showSubMenu, level }) : null })
|
216
211
|
] })
|
@@ -221,7 +216,7 @@ const SelectionAddon = ({
|
|
221
216
|
selectionMode
|
222
217
|
}) => {
|
223
218
|
if (selectionMode) {
|
224
|
-
return selectedKeys.includes(item.dsId) ? /* @__PURE__ */ jsx(Grid, { children: /* @__PURE__ */ jsx(
|
219
|
+
return selectedKeys.includes(item.dsId) ? /* @__PURE__ */ jsx(Grid, { children: /* @__PURE__ */ jsx(Checkmark, { size: "s", color: ["brand-primary", "600"] }) }) : /* @__PURE__ */ jsx("div", { style: { width: "16px" } });
|
225
220
|
}
|
226
221
|
return null;
|
227
222
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/MenuItem.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { useState, useCallback, useMemo } from 'react';\nimport {
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { useState, useCallback, useMemo } from 'react';\nimport { TriangleUpSmall, Checkmark, TriangleDownSmall, ChevronSmallDown, ChevronSmallRight } from '@elliemae/ds-icons';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\nimport {\n StyledMenuItem,\n StyledMenuItemContent,\n StyledLeftContent,\n StyledRightContent,\n StyledSeparator,\n StyledSection,\n} from '../styled.js';\nimport { Menu } from './Menu.js';\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\n\nexport const MenuItemAddon = React.memo(({ level, isOpen }: { level: number; isOpen: boolean }) => {\n if (level === 0)\n return isOpen ? (\n <TriangleUpSmall color={['brand-primary', '600']} />\n ) : (\n <TriangleDownSmall color={['brand-primary', '600']} />\n );\n return isOpen ? (\n <ChevronSmallDown size=\"m\" color={['brand-primary', '600']} />\n ) : (\n <ChevronSmallRight size=\"m\" color={['brand-primary', '600']} />\n );\n});\n\nexport const MenuItem = ({\n innerRef,\n tabIndex,\n onFocus,\n selectionMode,\n item,\n level,\n parentId,\n isVertical,\n}: {\n selectionMode?: 'single' | 'multiple';\n item: MenuButtonT.Item;\n level: number;\n parentId: string | undefined;\n isVertical?: boolean;\n tabIndex: number;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}) => {\n const {\n setFocusedOption,\n focusedOption,\n selectedKeys,\n onSelectionChange,\n triggerElementRef,\n setIsOpen,\n propsWithDefault: { ItemRenderer },\n } = React.useContext(MenuButtonContext);\n const listRef = React.useRef(null);\n const [showSubMenu, setShowSubMenu] = useState(false);\n const [referenceElement, setReferenceElement] = React.useState<HTMLElement | null>(null);\n const itemRef = useCallback(\n (node: HTMLElement | null) => {\n if (node !== null) {\n if (focusedOption === item.dsId) node.focus();\n }\n return node;\n },\n [focusedOption, item.dsId],\n );\n\n const selectionLogic = useCallback(() => {\n if (item.disabled) return;\n if (selectionMode === 'single') {\n const newValue = item.dsId === selectedKeys[0] ? [] : [item.dsId];\n onSelectionChange(newValue, parentId || 'root', item);\n }\n if (selectionMode === 'multiple') {\n const newValue = selectedKeys.includes(item.dsId)\n ? selectedKeys.filter((key: string) => key !== item.dsId)\n : [...selectedKeys, item.dsId];\n onSelectionChange(newValue, parentId || 'root', item);\n }\n }, [item, onSelectionChange, parentId, selectedKeys, selectionMode]);\n\n const handleOnClick: React.MouseEventHandler = useCallback(\n (e) => {\n if (selectionMode !== 'single' || item.disabled) {\n e.stopPropagation();\n }\n selectionLogic();\n },\n [item.disabled, selectionLogic, selectionMode],\n );\n const onItemKeyDown: React.KeyboardEventHandler = useCallback(\n (event) => {\n // Enter to close the menu and focus the trigger element\n if (event.key === 'Enter' && !item.disabled) {\n setIsOpen(false);\n triggerElementRef?.focus();\n }\n // selection\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n selectionLogic();\n }\n // open submenu logic\n if (\n ((event.key === 'ArrowDown' && level === 0) || (event.key === 'ArrowRight' && level !== 0)) &&\n item.subitems\n ) {\n event.preventDefault();\n event.stopPropagation();\n setShowSubMenu(true);\n setFocusedOption(item.subitems[0].dsId);\n }\n\n // close submenu logic\n if (event.key === 'ArrowLeft' && level >= 2) {\n event.preventDefault();\n event.stopPropagation();\n if (parentId) setFocusedOption(parentId);\n }\n if (event.key === 'Escape' && level > 0) {\n if (parentId !== undefined) {\n setFocusedOption(parentId);\n }\n }\n },\n [item.disabled, item.subitems, level, setIsOpen, triggerElementRef, selectionLogic, setFocusedOption, parentId],\n );\n\n const handleOnLIKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n // logic to close all submenus and focus on parent\n if (e.key === 'Enter') {\n setShowSubMenu(false);\n if (level === 0) {\n setFocusedOption(item.dsId);\n }\n }\n },\n [item.dsId, level, setFocusedOption],\n );\n\n const handleOnMouseEnter = useCallback(() => {\n setShowSubMenu(true);\n setFocusedOption(item.dsId);\n }, [item.dsId, setFocusedOption]);\n\n const handleOnMouseLeave = useCallback(() => {\n setShowSubMenu(false);\n }, []);\n\n const ariaExpanded = useMemo(() => {\n if (item.subitems) {\n return showSubMenu ? 'true' : 'false';\n }\n return undefined;\n }, [item.subitems, showSubMenu]);\n\n const role = useMemo(() => {\n if (selectionMode === 'single') {\n return 'menuitemradio';\n }\n if (selectionMode === 'multiple') {\n return 'menuitemcheckbox';\n }\n return 'menuitem';\n }, [selectionMode]);\n\n const ariaChecked = useMemo(() => {\n if (selectionMode === 'multiple' || selectionMode === 'single') {\n return selectedKeys.includes(item.dsId) ? 'true' : 'false';\n }\n return undefined;\n }, [item.dsId, selectionMode, selectedKeys]);\n\n return (\n <StyledMenuItem\n role=\"none\"\n innerRef={listRef}\n onMouseEnter={handleOnMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n onKeyDown={handleOnLIKeyDown}\n isOpen={showSubMenu}\n level={level}\n isVertical={isVertical}\n isDisabled={item.disabled}\n >\n <StyledMenuItemContent\n role={role}\n aria-checked={ariaChecked}\n aria-haspopup={item.subitems ? 'true' : 'false'}\n aria-expanded={ariaExpanded}\n innerRef={mergeRefs(innerRef, itemRef, setReferenceElement)}\n onKeyDown={onItemKeyDown}\n onClick={handleOnClick}\n hasChildren={item.subitems !== undefined}\n onFocus={onFocus}\n tabIndex={tabIndex}\n aria-disabled={item.disabled ? 'true' : 'false'}\n >\n {ItemRenderer ? (\n <ItemRenderer item={item} isSelected={selectedKeys.includes(item.dsId)} />\n ) : (\n <MenuItemContent\n item={item}\n selectionMode={selectionMode}\n selectedKeys={selectedKeys}\n showSubMenu={showSubMenu}\n level={level}\n />\n )}\n </StyledMenuItemContent>\n {item.subitems && showSubMenu && (\n <Menu\n level={level + 1}\n items={item.subitems}\n showSubMenu={showSubMenu}\n setShowSubMenu={setShowSubMenu}\n referenceElement={referenceElement}\n parentId={item.dsId}\n selectionMode={item.selectionMode}\n minWidth={item.minWidth}\n />\n )}\n </StyledMenuItem>\n );\n};\n\nconst MenuItemContent = React.memo(\n ({\n item,\n selectionMode,\n selectedKeys,\n showSubMenu,\n level,\n }: {\n item: MenuButtonT.Item;\n selectionMode?: 'single' | 'multiple';\n selectedKeys: string[];\n showSubMenu: boolean;\n level: number;\n }) => (\n <>\n <StyledLeftContent>\n <SelectionAddon selectionMode={selectionMode} item={item} selectedKeys={selectedKeys} />\n <DSTypography variant=\"b1\">{item.label}</DSTypography>\n </StyledLeftContent>\n <StyledRightContent>\n {item.subitems ? <MenuItemAddon isOpen={showSubMenu} level={level} /> : null}\n </StyledRightContent>\n </>\n ),\n);\n\nconst SelectionAddon = ({\n item,\n selectedKeys,\n selectionMode,\n}: {\n item: MenuButtonT.Item;\n selectedKeys: string[];\n selectionMode?: 'single' | 'multiple';\n}) => {\n if (selectionMode) {\n return selectedKeys.includes(item.dsId) ? (\n <Grid>\n <Checkmark size=\"s\" color={['brand-primary', '600']} />\n </Grid>\n ) : (\n <div style={{ width: '16px' }} />\n );\n }\n return null;\n};\n\nexport const Separator = () => (\n <li role=\"none\" style={{ padding: '0px 16px' }}>\n <StyledSeparator role=\"separator\" />\n </li>\n);\n\nexport const Section = ({ item }: { item: MenuButtonT.Item }) => (\n <li role=\"none\" style={{ padding: '0px 16px', minHeight: 24, display: 'flex', alignItems: 'center' }}>\n <StyledSection role=\"presentation\">{item.label}</StyledSection>\n </li>\n);\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACyBjB,SAkOF,UAlOE,KAgKF,YAhKE;AArBN,OAAOA,UAAS,UAAU,aAAa,eAAe;AACtD,SAAS,iBAAiB,WAAW,mBAAmB,kBAAkB,yBAAyB;AAEnG,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS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,IACpC,oBAAC,QACC,8BAAC,aAAU,MAAK,KAAI,OAAO,CAAC,iBAAiB,KAAK,GAAG,GACvD,IAEA,oBAAC,SAAI,OAAO,EAAE,OAAO,OAAO,GAAG;AAAA,EAEnC;AACA,SAAO;AACT;AAEO,MAAM,YAAY,MACvB,oBAAC,QAAG,MAAK,QAAO,OAAO,EAAE,SAAS,WAAW,GAC3C,8BAAC,mBAAgB,MAAK,aAAY,GACpC;AAGK,MAAM,UAAU,CAAC,EAAE,KAAK,MAC7B,oBAAC,QAAG,MAAK,QAAO,OAAO,EAAE,SAAS,YAAY,WAAW,IAAI,SAAS,QAAQ,YAAY,SAAS,GACjG,8BAAC,iBAAc,MAAK,gBAAgB,eAAK,OAAM,GACjD;",
|
6
6
|
"names": ["React"]
|
7
7
|
}
|
package/dist/esm/styled.js
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import { xStyledCommonProps, styled
|
3
|
-
const disabledOption = () => css`
|
4
|
-
a {
|
5
|
-
color: ${({ theme }) => theme.colors.neutral[500]};
|
6
|
-
}
|
7
|
-
background-color: ${({ theme }) => theme.colors.neutral["000"]};
|
8
|
-
cursor: not-allowed;
|
9
|
-
* {
|
10
|
-
cursor: not-allowed;
|
11
|
-
}
|
12
|
-
`;
|
2
|
+
import { xStyledCommonProps, styled } from "@elliemae/ds-system";
|
13
3
|
const StyledMenuButtonWrapper = styled("div")`
|
14
4
|
position: relative;
|
15
5
|
`;
|
@@ -40,9 +30,12 @@ const StyledMenuItem = styled("li")`
|
|
40
30
|
min-width: 200px;
|
41
31
|
}
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
${({ isDisabled, theme }) => isDisabled && `
|
34
|
+
color: ${theme.colors.neutral[500]};
|
35
|
+
* {
|
36
|
+
cursor: not-allowed;
|
37
|
+
}
|
38
|
+
`}
|
46
39
|
|
47
40
|
a:focus {
|
48
41
|
outline: 1px solid brand-500;
|
@@ -50,8 +43,6 @@ const StyledMenuItem = styled("li")`
|
|
50
43
|
}
|
51
44
|
|
52
45
|
${({ isOpen, theme }) => isOpen ? `background-color: ${theme.colors.brand["200"]}` : ""}
|
53
|
-
|
54
|
-
${({ disabled }) => disabled ? disabledOption() : ""}
|
55
46
|
`;
|
56
47
|
const StyledMenuItemContent = styled("a")`
|
57
48
|
display: flex;
|
@@ -95,6 +86,7 @@ const StyledSection = styled("div")`
|
|
95
86
|
display: flex;
|
96
87
|
flex-direction: column;
|
97
88
|
gap: 1px;
|
89
|
+
color: neutral-500;
|
98
90
|
`;
|
99
91
|
export {
|
100
92
|
StyledLeftContent,
|
package/dist/esm/styled.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/styled.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { xStyledCommonProps, styled
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,oBAAoB,
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { xStyledCommonProps, styled } from '@elliemae/ds-system';\n\nexport const StyledMenuButtonWrapper = styled('div')`\n position: relative;\n`;\n\nexport const StyledMenu = styled('ul')`\n display: flex;\n flex-direction: column;\n gap: 1px;\n list-style-type: none;\n padding: 0;\n margin: 0;\n background-color: white;\n /* height: 100%; */\n ${xStyledCommonProps}\n box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1),\n 0 2px 4px rgba(16, 22, 26, 0.2),\n 0 8px 24px rgba(16, 22, 26, 0.2);\n`;\n\nexport const StyledMenuItem = styled('li')<{\n isVertical?: boolean;\n level?: number;\n isOpen?: boolean;\n isDisabled?: boolean;\n}>`\n position: relative;\n background-color: white;\n display: flex;\n margin: 0;\n min-height: 32px;\n width: ${({ isVertical, level }) => (!isVertical && level === 0 ? 'auto' : '100%')};\n cursor: pointer;\n\n ul li {\n min-width: 200px;\n }\n\n ${({ isDisabled, theme }) =>\n isDisabled &&\n `\n color: ${theme.colors.neutral[500]};\n * {\n cursor: not-allowed;\n }\n `}\n\n a:focus {\n outline: 1px solid brand-500;\n background-color: brand-200;\n }\n\n ${({ isOpen, theme }) => (isOpen ? `background-color: ${theme.colors.brand['200']}` : '')}\n`;\n\nexport const StyledMenuItemContent = styled('a')<{ hasChildren?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n text-decoration: none;\n color: inherit;\n &:focus {\n outline: none;\n }\n ${({ hasChildren }) => (hasChildren ? 'padding-left: 16px;' : 'padding: 0 16px;')}\n ${xStyledCommonProps}\n`;\n\nexport const StyledLeftContent = styled('div')`\n display: flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n`;\n\nexport const StyledRightContent = styled('div')`\n display: flex;\n align-items: center;\n`;\n\nexport const StyledSeparator = styled('hr')`\n border: 0;\n border-top: 1px solid #697489;\n margin: 4px 0px;\n padding: 0;\n`;\n\nexport const StyledSectionLabel = styled('div')`\n color: neutral-500;\n display: flex;\n flex-direction: column;\n gap: 1px;\n padding: 0 16px;\n min-height: 24px;\n justify-content: center;\n`;\n\nexport const StyledSection = styled('div')`\n display: flex;\n flex-direction: column;\n gap: 1px;\n color: neutral-500;\n`;\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,oBAAoB,cAAc;AAEpC,MAAM,0BAA0B,OAAO,KAAK;AAAA;AAAA;AAI5C,MAAM,aAAa,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASjC,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAMf,MAAM,iBAAiB,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAW9B,CAAC,EAAE,YAAY,MAAM,MAAO,CAAC,cAAc,UAAU,IAAI,SAAS,MAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhF,CAAC,EAAE,YAAY,MAAM,MACrB,cACA;AAAA,aACS,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,GAInC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOC,CAAC,EAAE,QAAQ,MAAM,MAAO,SAAS,qBAAqB,MAAM,OAAO,MAAM,KAAK,CAAC,KAAK,EAAG;AAAA;AAGpF,MAAM,wBAAwB,OAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAU3C,CAAC,EAAE,YAAY,MAAO,cAAc,wBAAwB,kBAAmB;AAAA,IAC/E,kBAAkB;AAAA;AAGf,MAAM,oBAAoB,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAOtC,MAAM,qBAAqB,OAAO,KAAK;AAAA;AAAA;AAAA;AAKvC,MAAM,kBAAkB,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAOnC,MAAM,qBAAqB,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUvC,MAAM,gBAAgB,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/dist/types/styled.d.ts
CHANGED
@@ -4,7 +4,7 @@ export declare const StyledMenuItem: import("styled-components").StyledComponent
|
|
4
4
|
isVertical?: boolean | undefined;
|
5
5
|
level?: number | undefined;
|
6
6
|
isOpen?: boolean | undefined;
|
7
|
-
|
7
|
+
isDisabled?: boolean | undefined;
|
8
8
|
} & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"li">, never>;
|
9
9
|
export declare const StyledMenuItemContent: import("styled-components").StyledComponent<"a", import("@elliemae/ds-system").Theme, {
|
10
10
|
hasChildren?: boolean | undefined;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@elliemae/ds-menu-button",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.40.0-rc.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ICE MT - Dimsum - Menu Button",
|
6
6
|
"files": [
|
@@ -38,21 +38,21 @@
|
|
38
38
|
"dependencies": {
|
39
39
|
"@xstyled/styled-components": "~3.6.0",
|
40
40
|
"uid": "^2.0.2",
|
41
|
-
"@elliemae/ds-
|
42
|
-
"@elliemae/ds-
|
43
|
-
"@elliemae/ds-icons": "3.
|
44
|
-
"@elliemae/ds-
|
45
|
-
"@elliemae/ds-
|
46
|
-
"@elliemae/ds-
|
47
|
-
"@elliemae/ds-
|
48
|
-
"@elliemae/ds-hooks-keyboard-navigation": "3.
|
41
|
+
"@elliemae/ds-button-v2": "3.40.0-rc.0",
|
42
|
+
"@elliemae/ds-grid": "3.40.0-rc.0",
|
43
|
+
"@elliemae/ds-icons": "3.40.0-rc.0",
|
44
|
+
"@elliemae/ds-props-helpers": "3.40.0-rc.0",
|
45
|
+
"@elliemae/ds-system": "3.40.0-rc.0",
|
46
|
+
"@elliemae/ds-typescript-helpers": "3.40.0-rc.0",
|
47
|
+
"@elliemae/ds-typography": "3.40.0-rc.0",
|
48
|
+
"@elliemae/ds-hooks-keyboard-navigation": "3.40.0-rc.0"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
51
|
"@elliemae/pui-cli": "9.0.0-next.50",
|
52
52
|
"@xstyled/system": "3.7.0",
|
53
53
|
"lodash": "^4.17.21",
|
54
54
|
"styled-components": "~5.3.9",
|
55
|
-
"@elliemae/ds-monorepo-devops": "3.
|
55
|
+
"@elliemae/ds-monorepo-devops": "3.40.0-rc.0"
|
56
56
|
},
|
57
57
|
"peerDependencies": {
|
58
58
|
"lodash": "^4.17.21",
|