@team-monolith/cds 1.99.13 → 1.99.15

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.
@@ -1,3 +1,14 @@
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
+ };
1
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
13
  import styled from "@emotion/styled";
3
14
  import { useRef, useState } from "react";
@@ -7,6 +18,7 @@ import { Tooltip } from "./Tooltip";
7
18
  * 공간이 부족하면 ...으로 표시하고 툴팁으로 전체 내용을 노출합니다.
8
19
  */
9
20
  export function OverflowTooltip(props) {
21
+ const { divProps } = props, tooltipProps = __rest(props, ["divProps"]);
10
22
  const tooltipRef = useRef(null);
11
23
  const [isTooltipOpen, setIsTooltipOpen] = useState(false);
12
24
  const getIsOverflow = () => {
@@ -23,7 +35,7 @@ export function OverflowTooltip(props) {
23
35
  const handleClose = () => {
24
36
  setIsTooltipOpen(false);
25
37
  };
26
- return (_jsx(Tooltip, Object.assign({ open: isTooltipOpen, onOpen: handleOpen, onClose: handleClose }, props, { children: _jsx(OverflowDiv, Object.assign({ css: props.childrenCss, ref: tooltipRef, onMouseOver: handleOpen }, props.divProps, { children: props.text })) })));
38
+ return (_jsx(Tooltip, Object.assign({ open: isTooltipOpen, onOpen: handleOpen, onClose: handleClose }, tooltipProps, { children: _jsx(OverflowDiv, Object.assign({}, divProps, { css: props.childrenCss, ref: tooltipRef, onMouseOver: handleOpen }, { children: props.text })) })));
27
39
  }
28
40
  const OverflowDiv = styled.div `
29
41
  overflow: hidden;
@@ -11,7 +11,7 @@ export function Accordion(props) {
11
11
  display: flex;
12
12
  flex-direction: column;
13
13
  gap: 2px;
14
- `, className: wrapperClassName }, { children: [_jsxs(Container, Object.assign({ className: className, onClick: onClick, "aria-expanded": open, "aria-label": buttonLabel }, { children: [_jsxs(Title, { children: [icon, title] }), open ? _jsx(ArrowUpSLineIcon, {}) : _jsx(ArrowDownSLineIcon, {})] })), open && children] })));
14
+ `, className: wrapperClassName }, { children: [_jsxs(Container, Object.assign({ type: "button", className: className, onClick: onClick, "aria-expanded": open, "aria-label": buttonLabel }, { children: [_jsxs(Title, { children: [icon, title] }), open ? _jsx(ArrowUpSLineIcon, {}) : _jsx(ArrowDownSLineIcon, {})] })), open && children] })));
15
15
  }
16
16
  const Title = styled.div(({ theme }) => css `
17
17
  display: flex;
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
14
14
  import { css } from "@emotion/react";
15
15
  import * as React from "react";
16
16
  import styled from "@emotion/styled";
17
- import { CheckboxInput, ArrowRightSLineIcon, HOVER, } from "../../..";
17
+ import { CheckboxInput, ArrowRightSLineIcon, HOVER, RESET_BUTTON, } from "../../..";
18
18
  import { useContext, useId, useRef } from "react";
19
19
  import { DropdownMenu } from "../DropdownMenu";
20
20
  import { DropdownContext } from "../DropdownContext";
@@ -27,7 +27,7 @@ const TYPE_TO_COLOR = (theme, type) => ({
27
27
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?type=design&node-id=106-1900&t=FwczLZ1IVvskUVbT-0)
28
28
  */
29
29
  const DropdownItem = React.forwardRef(function DropdownItem(props, ref) {
30
- const { className, index, labelCss, component: Component = "div", type = "default", checkbox, checkboxProps = { checked: false }, startIcon, label, endIcon, preserveIconColor = false, disabled, active, onMouseEnter, onMouseLeave, onClick, subMenuProps, children } = props, other = __rest(props, ["className", "index", "labelCss", "component", "type", "checkbox", "checkboxProps", "startIcon", "label", "endIcon", "preserveIconColor", "disabled", "active", "onMouseEnter", "onMouseLeave", "onClick", "subMenuProps", "children"]);
30
+ const { className, index, labelCss, component: Component = "button", type = "default", checkbox, checkboxProps = { checked: false }, startIcon, label, endIcon, preserveIconColor = false, disabled, active, onMouseEnter, onMouseLeave, onClick, subMenuProps, children } = props, other = __rest(props, ["className", "index", "labelCss", "component", "type", "checkbox", "checkboxProps", "startIcon", "label", "endIcon", "preserveIconColor", "disabled", "active", "onMouseEnter", "onMouseLeave", "onClick", "subMenuProps", "children"]);
31
31
  const itemRef = useRef(null);
32
32
  const { open, onCloseOnItemClick, nestedIndex, itemState, setItemState } = useContext(DropdownContext);
33
33
  const dropdownMenuId = `dropdown-menu-${useId()}`;
@@ -50,7 +50,15 @@ const DropdownItem = React.forwardRef(function DropdownItem(props, ref) {
50
50
  setSelected(setItemState, absItemIndex);
51
51
  }
52
52
  };
53
- 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, { "aria-expanded": isSubMenuExist ? isSubMenuShowed : undefined, "aria-controls": isSubMenuExist ? dropdownMenuId : undefined }, { 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
+ 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, { "aria-expanded": isSubMenuExist ? isSubMenuShowed : undefined, "aria-controls": isSubMenuExist ? dropdownMenuId : undefined }, (Component === "button"
54
+ ? {
55
+ type: "button",
56
+ disabled: disabled,
57
+ css: css `
58
+ ${RESET_BUTTON}
59
+ `,
60
+ }
61
+ : {}), { 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) => {
54
62
  e.stopPropagation();
55
63
  } }))), 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: {
56
64
  open,
@@ -32,7 +32,7 @@ function useSuspenseImage(src) {
32
32
  }
33
33
  function LazyImage({ altText, className, imageRef, src, width, height, maxWidth: _maxWidth, onError, title, onClick, }) {
34
34
  useSuspenseImage(src);
35
- return (_jsx("img", { className: className || undefined, src: src, alt: altText, ref: imageRef, style: {
35
+ return (_jsx("img", Object.assign({ className: className || undefined, src: src, alt: altText, ref: imageRef, style: {
36
36
  height,
37
37
  // 이미지로 인해 좌우로 스크롤이 생기는 것을 방지
38
38
  // maxWidth: `min(${maxWidth}px, 100%)`,
@@ -40,7 +40,15 @@ function LazyImage({ altText, className, imageRef, src, width, height, maxWidth:
40
40
  // fixme: maxWidth를 수정할 수 있게 되면 원복합니다.
41
41
  maxWidth: "100%",
42
42
  width,
43
- }, "aria-label": title, onClick: onClick, onError: onError, draggable: "false", role: onClick ? "button" : undefined }));
43
+ }, "aria-label": title, onClick: onClick, onError: onError, draggable: "false" }, (onClick ? {
44
+ role: "button",
45
+ tabIndex: 0,
46
+ onKeyDown: (event) => {
47
+ if (event.key === "Enter" || event.key === " ") {
48
+ onClick();
49
+ }
50
+ }
51
+ } : {}))));
44
52
  }
45
53
  export function ImageComponent({ src, altText, nodeKey, width, height, maxWidth, resizable, }) {
46
54
  const imageRef = useRef(null);
@@ -30,7 +30,21 @@ export const SegmentedControlButton = React.forwardRef(function SegmentedControl
30
30
  const isActive = context.multiSelect
31
31
  ? context.value.includes(props.value)
32
32
  : context.value === props.value;
33
- return (_jsx(StyledButton, Object.assign({}, other, { ref: ref, startIcon: typeof startIcon === "function" ? startIcon(isActive) : startIcon, endIcon: typeof endIcon === "function" ? endIcon(isActive) : endIcon, isActive: isActive, color: isActive ? "white" : "textNeutral", size: context.size, onClick: handleClick, disabled: context.disabled || props.disabled, "aria-selected": isActive ? "true" : undefined })));
33
+ // 화살표 (좌, ) 인접 버튼으로 포커스 이동하는 로직
34
+ const handleKeyDown = (e) => {
35
+ let sibling = null;
36
+ if (e.key === "ArrowRight") {
37
+ sibling = e.currentTarget.nextElementSibling;
38
+ }
39
+ else if (e.key === "ArrowLeft") {
40
+ sibling = e.currentTarget.previousElementSibling;
41
+ }
42
+ if (sibling instanceof HTMLButtonElement) {
43
+ e.preventDefault();
44
+ sibling.focus();
45
+ }
46
+ };
47
+ return (_jsx(StyledButton, Object.assign({}, other, { ref: ref, startIcon: typeof startIcon === "function" ? startIcon(isActive) : startIcon, endIcon: typeof endIcon === "function" ? endIcon(isActive) : endIcon, isActive: isActive, color: isActive ? "white" : "textNeutral", size: context.size, onClick: handleClick, onKeyDown: handleKeyDown, disabled: context.disabled || props.disabled, "aria-selected": isActive, role: "tab", tabIndex: isActive ? 0 : -1 })));
34
48
  });
35
49
  const StyledButton = styled(Button, {
36
50
  shouldForwardProp: (prop) => prop !== "isActive",
@@ -29,7 +29,7 @@ export const SegmentedControlGroup = React.forwardRef(function SegmentedControlG
29
29
  background-color: ${theme.color.background.neutralAlt};
30
30
  border-radius: 8px;
31
31
  border: 1px solid ${theme.color.background.neutralAltActive};
32
- ` }, { children: _jsx(Context.Provider, Object.assign({ value: Object.assign(Object.assign({}, props), { onClick: (newValue) => {
32
+ `, role: "tablist", "aria-orientation": "horizontal" }, { children: _jsx(Context.Provider, Object.assign({ value: Object.assign(Object.assign({}, props), { onClick: (newValue) => {
33
33
  var _a, _b, _c;
34
34
  if (multiSelect) {
35
35
  if (props.value.includes(newValue)) {
@@ -20,7 +20,7 @@ import { SegmentedControlGroupPropsContext, } from "./SegmentedControlGroupProps
20
20
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
21
21
  */
22
22
  export const SegmentedControlSquareButton = React.forwardRef(function SegmentedControlSquareButton(props, ref) {
23
- const { onClick, icon } = props, other = __rest(props, ["onClick", "icon"]);
23
+ const { onClick, icon, buttonProps } = props, other = __rest(props, ["onClick", "icon", "buttonProps"]);
24
24
  const context = useContext(SegmentedControlGroupPropsContext);
25
25
  const handleClick = (e) => {
26
26
  var _a;
@@ -30,7 +30,23 @@ export const SegmentedControlSquareButton = React.forwardRef(function SegmentedC
30
30
  const isActive = context.multiSelect
31
31
  ? context.value.includes(props.value)
32
32
  : context.value === props.value;
33
- return (_jsx(StyledSquareButton, Object.assign({}, other, { ref: ref, isActive: isActive, icon: typeof icon === "function" ? icon(isActive) : icon, color: isActive ? "white" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: handleClick, disabled: context.disabled || props.disabled })));
33
+ // 화살표 (좌, ) 인접 버튼으로 포커스 이동하는 로직
34
+ const handleKeyDown = (e) => {
35
+ var _a, _b, _c, _d;
36
+ let siblingButton = null;
37
+ if (e.key === "ArrowRight") {
38
+ // sibling 요소의 첫 번째 자식인 버튼에 포커스 이동 처리
39
+ siblingButton = (_b = (_a = e.currentTarget.nextElementSibling) === null || _a === void 0 ? void 0 : _a.firstElementChild) !== null && _b !== void 0 ? _b : null;
40
+ }
41
+ else if (e.key === "ArrowLeft") {
42
+ siblingButton = (_d = (_c = e.currentTarget.previousElementSibling) === null || _c === void 0 ? void 0 : _c.firstElementChild) !== null && _d !== void 0 ? _d : null;
43
+ }
44
+ if (siblingButton instanceof HTMLButtonElement) {
45
+ e.preventDefault();
46
+ siblingButton.focus();
47
+ }
48
+ };
49
+ return (_jsx(StyledSquareButton, Object.assign({}, other, { ref: ref, isActive: isActive, icon: typeof icon === "function" ? icon(isActive) : icon, color: isActive ? "white" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: handleClick, onKeyDown: handleKeyDown, disabled: context.disabled || props.disabled, buttonProps: Object.assign(Object.assign({}, buttonProps), { "aria-selected": isActive, role: "tab", tabIndex: isActive ? 0 : -1 }) })));
34
50
  });
35
51
  const StyledSquareButton = styled(SquareButton, {
36
52
  shouldForwardProp: (prop) => prop !== "isActive",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.99.13",
3
+ "version": "1.99.15",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,