@team-monolith/cds 1.83.0 → 1.83.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,7 @@ const DropdownItem = React.forwardRef(function DropdownItem(props, ref) {
49
49
  setSelected(setItemState, absItemIndex);
50
50
  }
51
51
  };
52
- return (_jsxs(_Fragment, { children: [_jsx(Component, Object.assign({ className: className, ref: ref, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onClick: handleClick, "aria-disabled": disabled }, other, { children: _jsxs(Item, Object.assign({ ref: itemRef, disabled: disabled, selected: isSubMenuShowed || Boolean(active) }, { children: [_jsxs(LeftWrapper, { children: [checkbox && (_jsx(StyledCheckboxInput, Object.assign({}, checkboxProps, { disabled: disabled, onClick: (e) => {
52
+ return (_jsxs(_Fragment, { children: [_jsx(Component, Object.assign({ className: className, ref: ref, tabIndex: disabled ? -1 : 0, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onClick: handleClick, "aria-disabled": disabled }, other, { children: _jsxs(Item, Object.assign({ ref: itemRef, disabled: disabled, selected: isSubMenuShowed || Boolean(active) }, { children: [_jsxs(LeftWrapper, { children: [checkbox && (_jsx(StyledCheckboxInput, Object.assign({}, checkboxProps, { disabled: disabled, onClick: (e) => {
53
53
  e.stopPropagation();
54
54
  } }))), startIcon && (_jsx(IconDiv, Object.assign({ type: type, preserveIconColor: preserveIconColor }, { children: startIcon }))), _jsx(LabelDiv, Object.assign({ css: labelCss, type: type }, { children: label }))] }), endIcon && (_jsx(IconDiv, Object.assign({ type: type, preserveIconColor: preserveIconColor }, { children: endIcon }))), !endIcon && isSubMenuExist && (_jsx(IconDiv, Object.assign({ type: type, preserveIconColor: preserveIconColor }, { children: _jsx(ArrowRightSLineIcon, {}) })))] })) })), isSubMenuExist && (_jsx(DropdownContext.Provider, Object.assign({ value: {
55
55
  open,
@@ -1,24 +1,15 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx } from "@emotion/react/jsx-runtime";
13
2
  /** @jsxImportSource @emotion/react */
14
3
  import { css } from "@emotion/react";
15
4
  import React, { useContext } from "react";
16
5
  import { shadows } from "../../..";
17
- import { Popover, Portal } from "@mui/material";
18
- import { ORIGIN_PROPS_TO_POSITION } from "./style";
6
+ import { Popover } from "@mui/material";
7
+ import { ORIGIN_PROPS_TO_MARGIN } from "./style";
19
8
  import { DropdownContext } from "../DropdownContext";
9
+ import styled from "@emotion/styled";
20
10
  export const DROPDOWN_MENU_WIDTH = 132;
21
11
  export const DROPDOWN_MENU_MAX_HEIGHT = 160;
12
+ const EMPTY_MAP = Object.freeze(new Map());
22
13
  /**
23
14
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?type=design&node-id=106-1921&t=FwczLZ1IVvskUVbT-0)
24
15
  */
@@ -29,29 +20,18 @@ const DropdownMenu = React.forwardRef(function DropdownMenu(props, ref) {
29
20
  }, transformOrigin = {
30
21
  vertical: "top",
31
22
  horizontal: "left",
32
- }, closeOnItemClick, children, menuCss, itemState = new Map(), setItemState = () => { } } = props, _other = __rest(props, ["className", "open", "anchorEl", "onClose", "isNestedMenu", "anchorOrigin", "transformOrigin", "closeOnItemClick", "children", "menuCss", "itemState", "setItemState"]);
23
+ }, closeOnItemClick, children, menuCss, itemState = EMPTY_MAP, setItemState = () => { }, } = props;
33
24
  const { nestedIndex, onCloseOnItemClick } = useContext(DropdownContext);
34
25
  // 드롭다운 메뉴 위치 조정
35
- const menuStyle = (theme) => css `
26
+ const menuStyle = css `
36
27
  .MuiPaper-root {
37
- position: fixed;
38
- display: flex;
39
- flex-direction: column;
40
- gap: 2px;
41
- padding: 4px;
42
- background-color: ${theme.color.background.neutralBase};
43
- box-shadow: ${shadows.shadow04};
44
- border-radius: 8px;
45
- width: ${DROPDOWN_MENU_WIDTH}px;
46
- max-height: ${DROPDOWN_MENU_MAX_HEIGHT}px;
47
- overflow-y: auto;
48
- overflow-x: hidden;
49
- // 최상위 메뉴의 mui modal 백드롭의 z-index는 1300입니다.
50
- z-index: 1300;
51
28
  ${menuCss}
52
- ${ORIGIN_PROPS_TO_POSITION(anchorOrigin)}
29
+ ${ORIGIN_PROPS_TO_MARGIN(anchorOrigin, isNestedMenu)}
53
30
  }
54
31
  `;
32
+ if (!anchorEl) {
33
+ return _jsx(_Fragment, {});
34
+ }
55
35
  // 최상위 드롭다운 메뉴
56
36
  if (!isNestedMenu) {
57
37
  return (_jsx(DropdownContext.Provider, Object.assign({ value: {
@@ -60,30 +40,45 @@ const DropdownMenu = React.forwardRef(function DropdownMenu(props, ref) {
60
40
  nestedIndex,
61
41
  itemState,
62
42
  setItemState,
63
- } }, { children: _jsx(Popover, Object.assign({ className: className, open: open, onClose: onClose, anchorEl: anchorEl, anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, ref: ref, css: menuStyle }, { children: children })) })));
43
+ } }, { children: _jsx(Menu, Object.assign({ className: className, open: open, onClose: onClose, anchorEl: anchorEl, anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, ref: ref, css: menuStyle }, { children: children })) })));
64
44
  }
65
45
  // 중첩 드롭다운 메뉴
66
- // Portal을 사용하여 DOM이 중첩되지 않고 최상단에 렌더링 됩니다.
67
- // 드롭다운 메뉴에서 메뉴가 열리고 닫힐 때 애니메이션을 위해 Grow를 사용하고 있습니다.
68
- // Grow에서는 transform속성이 있는데, 자식에 배치되는 Menu에서는 position: fixed 속성이 있습니다.
69
- // position: fixed는 뷰포트를 기준으로 요소를 배치하는데, 부모가 transform속성을 지니면 fixed동작이 제대로 이루어지지 않습니다.
70
- // 아이템이 열리고 닫힐 때 transform속성이 생기고, 그 아이템의 자식인 서브메뉴는 position: fixed이므로 문제가 발생합니다.
71
- // https://stackoverflow.com/questions/2637058/position-fixed-doesnt-work-when-using-webkit-transform
72
- // 그래서 중첩구조를 파괴하기 위해 Portal을 사용하여 중첩 드롭다운 메뉴를 최상단에 렌더링합니다.
73
- return (_jsx(Portal, { children: _jsx(DropdownContext.Provider, Object.assign({ value: {
74
- open,
75
- // 중첩 드롭다운 메뉴의 onCloseOnItemClick은 상위 드롭다운 메뉴에서 전달된 값 사용
76
- onCloseOnItemClick,
77
- nestedIndex,
78
- itemState,
79
- setItemState,
80
- } }, { children: _jsx(Popover, Object.assign({ className: className, open: open, onClose: onCloseOnItemClick, anchorEl: anchorEl, anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, ref: ref, css: menuStyle, slotProps: {
81
- root: {
82
- sx: {
83
- // root slot의 dom 요소를 생성하지 않도록 하여 다른 상위 메뉴를 선택할 수 있도록 처리
84
- display: "contents",
85
- },
86
- },
87
- } }, { children: children })) })) }));
46
+ return (_jsx(DropdownContext.Provider, Object.assign({ value: {
47
+ open,
48
+ // 중첩 드롭다운 메뉴의 onCloseOnItemClick은 상위 드롭다운 메뉴에서 전달된 사용
49
+ onCloseOnItemClick,
50
+ nestedIndex,
51
+ itemState,
52
+ setItemState,
53
+ } }, { children: _jsx(Menu, Object.assign({ className: className, open: open, onClose: onCloseOnItemClick, anchorEl: anchorEl, anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, ref: ref,
54
+ // 중첩된 드롭다운의 경우 상위 메뉴에 대한 마우스 호버, 클릭 이벤트가 동작하지 않는 문제 해결
55
+ // 실제 드롭다운 메뉴 영역에서만 포인터 이벤트를 감지하도록 처리
56
+ css: [
57
+ menuStyle,
58
+ css `
59
+ pointer-events: none;
60
+ .MuiPaper-root {
61
+ pointer-events: auto;
62
+ }
63
+ `,
64
+ ] }, { children: children })) })));
88
65
  });
89
66
  export { DropdownMenu };
67
+ const Menu = styled(Popover)(({ theme }) => css `
68
+ .MuiPaper-root {
69
+ position: fixed;
70
+ display: flex;
71
+ flex-direction: column;
72
+ gap: 2px;
73
+ padding: 4px;
74
+ background-color: ${theme.color.background.neutralBase};
75
+ box-shadow: ${shadows.shadow04};
76
+ border-radius: 8px;
77
+ width: ${DROPDOWN_MENU_WIDTH}px;
78
+ max-height: ${DROPDOWN_MENU_MAX_HEIGHT}px;
79
+ overflow-y: auto;
80
+ overflow-x: hidden;
81
+ // 최상위 메뉴의 mui modal 백드롭의 z-index는 1300입니다.
82
+ z-index: 1300;
83
+ }
84
+ `);
@@ -6,4 +6,4 @@ export interface OriginProps {
6
6
  * anchor를 기준으로 드롭다운 메뉴 원점 위치 스타일을 리턴합니다.
7
7
  * position의 경우 Popover 컴포넌트의 내부에서 계산되므로 margin값만 반환합니다.
8
8
  */
9
- export declare const ORIGIN_PROPS_TO_POSITION: (anchorOrigin: OriginProps) => import("@emotion/utils").SerializedStyles;
9
+ export declare const ORIGIN_PROPS_TO_MARGIN: (anchorOrigin: OriginProps, nested?: boolean) => import("@emotion/utils").SerializedStyles;
@@ -3,7 +3,7 @@ import { css } from "@emotion/react";
3
3
  * anchor를 기준으로 드롭다운 메뉴 원점 위치 스타일을 리턴합니다.
4
4
  * position의 경우 Popover 컴포넌트의 내부에서 계산되므로 margin값만 반환합니다.
5
5
  */
6
- export const ORIGIN_PROPS_TO_POSITION = (anchorOrigin) => {
6
+ export const ORIGIN_PROPS_TO_MARGIN = (anchorOrigin, nested) => {
7
7
  const { vertical, horizontal } = anchorOrigin;
8
8
  return {
9
9
  top: {
@@ -14,7 +14,7 @@ export const ORIGIN_PROPS_TO_POSITION = (anchorOrigin) => {
14
14
  margin-bottom: 8px;
15
15
  `,
16
16
  right: css `
17
- margin-left: 4px;
17
+ margin-left: ${nested ? 8 : 4}px;
18
18
  `,
19
19
  },
20
20
  center: {
@@ -312,6 +312,7 @@ export function ComponentPickerMenuPlugin(props) {
312
312
  (regex.test(option.title) ||
313
313
  option.keywords.some((keyword) => regex.test(keyword)))),
314
314
  ];
315
+ // eslint-disable-next-line react-hooks/exhaustive-deps
315
316
  }, [editor, queryString, setOpen]);
316
317
  const onSelectOption = useCallback((selectedOption, nodeToRemove, closeMenu, matchingString) => {
317
318
  if (selectedOption instanceof ComponentDrawerOption) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.83.0",
3
+ "version": "1.83.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,
@@ -78,6 +78,7 @@
78
78
  "eslint": "^8.57.0",
79
79
  "eslint-plugin-import": "^2.29.1",
80
80
  "eslint-plugin-react": "^7.34.4",
81
+ "eslint-plugin-react-hooks": "^4.6.2",
81
82
  "eslint-plugin-storybook": "^0.8.0",
82
83
  "globals": "^15.8.0",
83
84
  "pascalcase": "^2.0.0",