@bds-web/ui 1.5.0 → 1.7.0

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.
@@ -0,0 +1,8 @@
1
+ interface DropdownPortalProps {
2
+ children: React.ReactNode;
3
+ containerRef: React.RefObject<HTMLElement | null>;
4
+ isOpen: boolean;
5
+ }
6
+ export declare const DropdownPortal: ({ children, containerRef, isOpen }: DropdownPortalProps) => import("react").ReactPortal | null;
7
+ export {};
8
+ //# sourceMappingURL=DropdownPortal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownPortal.d.ts","sourceRoot":"","sources":["../../../src/Dropdown/ui/DropdownPortal.tsx"],"names":[],"mappings":"AAIA,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,cAAc,GAAI,oCAAoC,mBAAmB,uCAgCrF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ export const DropdownPortal = ({ children, containerRef, isOpen }) => {
5
+ const [position, setPosition] = useState({ top: 0, left: 0, width: 0 });
6
+ const portalRef = useRef(null);
7
+ useEffect(() => {
8
+ if (isOpen && containerRef.current) {
9
+ const rect = containerRef.current.getBoundingClientRect();
10
+ setPosition({
11
+ top: rect.bottom + window.scrollY,
12
+ left: rect.left + window.scrollX,
13
+ width: rect.width,
14
+ });
15
+ }
16
+ }, [isOpen, containerRef]);
17
+ if (!isOpen)
18
+ return null;
19
+ return createPortal(_jsx("div", { ref: portalRef, style: {
20
+ position: "absolute",
21
+ top: position.top,
22
+ left: position.left,
23
+ width: position.width,
24
+ zIndex: 1000,
25
+ }, children: children }), document.body);
26
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Dropdown/ui/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,eAAO,MAAM,QAAQ,GAAI,uDAMtB,aAAa,4CA+Bf,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Dropdown/ui/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,eAAO,MAAM,QAAQ,GAAI,uDAMtB,aAAa,4CAkCf,CAAC"}
@@ -4,8 +4,9 @@ import { TriangleIcon } from "../../TriangleIcon";
4
4
  import { useDropdown } from "../hooks/useDropdown";
5
5
  import * as S from "./style";
6
6
  import { useOutsideClick } from "../hooks/useOutsideClick";
7
+ import { DropdownPortal } from "./DropdownPortal";
7
8
  export const Dropdown = ({ dropdownSize = "small", onSelect, options, selected, width = "auto", }) => {
8
9
  const { isOpen, closeDropdown, toggleDropdown } = useDropdown();
9
10
  const containerRef = useOutsideClick(isOpen, closeDropdown);
10
- return (_jsxs(S.Container, { ref: containerRef, "$size": dropdownSize, "$width": width, onClick: toggleDropdown, children: [_jsxs(S.SelectedItem, { children: [_jsx(S.SelectedText, { children: selected ? selected.name : "선택해주세요." }), _jsx(TriangleIcon, {})] }), isOpen && (_jsx(S.OptionsList, { "$size": dropdownSize, "$isOpen": true, children: options.map((option, idx) => (_jsx(S.OptionItem, { "$isSelected": selected?.value === option.value, "$size": dropdownSize, onClick: () => onSelect(option), children: option.name }, idx))) }))] }));
11
+ return (_jsxs(S.Container, { ref: containerRef, "$size": dropdownSize, "$width": width, onClick: toggleDropdown, style: { position: "relative" }, children: [_jsxs(S.SelectedItem, { children: [_jsx(S.SelectedText, { children: selected ? selected.name : "선택해주세요." }), _jsx(TriangleIcon, {})] }), _jsx(DropdownPortal, { containerRef: containerRef, isOpen: isOpen, children: _jsx(S.OptionsList, { "$size": dropdownSize, "$isOpen": isOpen, children: options.map((option, idx) => (_jsx(S.OptionItem, { "$isSelected": selected?.value === option.value, "$size": dropdownSize, onClick: () => onSelect(option), children: option.name }, idx))) }) })] }));
11
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/Dropdown/ui/style.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,eAAO,MAAM,SAAS;;;;WAAuB,YAAY;YAAU,MAAM;yGASxE,CAAC;AAEF,eAAO,MAAM,YAAY;;;yGAQxB,CAAC;AAEF,eAAO,MAAM,YAAY;;;2GAIxB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;WAAsB,YAAY;aAAW,OAAO;6GAkB3E,CAAC;AAEF,eAAO,MAAM,UAAU;;;;WACd,YAAY;iBACN,OAAO;yGAerB,CAAC"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/Dropdown/ui/style.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,eAAO,MAAM,SAAS;;;;WAAuB,YAAY;YAAU,MAAM;yGASxE,CAAC;AAEF,eAAO,MAAM,YAAY;;;yGAQxB,CAAC;AAEF,eAAO,MAAM,YAAY;;;2GAIxB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;WAAsB,YAAY;aAAW,OAAO;6GAgB3E,CAAC;AAEF,eAAO,MAAM,UAAU;;;;WACd,YAAY;iBACN,OAAO;yGAerB,CAAC"}
@@ -38,9 +38,7 @@ export const OptionsList = styled.ul `
38
38
  : `
39
39
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.05);
40
40
  `};
41
- position: absolute;
42
- top: calc(100% + ${({ $size }) => ($size === "small" ? "4px" : "10px")});
43
- left: -1px;
41
+ position: static;
44
42
  box-sizing: border-box;
45
43
  z-index: ${({ $isOpen }) => ($isOpen ? 100 : -1)};
46
44
  overflow: hidden;
@@ -1,3 +1,3 @@
1
1
  import { TextInputProps } from "../types/props";
2
- export declare const TextInput: ({ label, errorMessage, ...props }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TextInput: ({ label, errorMessage, width, id, name, ...props }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TextInput/ui/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,eAAO,MAAM,SAAS,GAAI,mCAAmC,cAAc,4CAQ1E,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TextInput/ui/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,eAAO,MAAM,SAAS,GAAI,oDAAqD,cAAc,4CAQ5F,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as S from "./style";
4
- export const TextInput = ({ label, errorMessage, ...props }) => {
5
- return (_jsxs(S.Container, { children: [label && _jsx(S.Label, { children: label }), _jsx(S.TextInput, { "$isError": !!errorMessage, ...props }), errorMessage && _jsx(S.ErrorMessage, { children: errorMessage })] }));
4
+ export const TextInput = ({ label, errorMessage, width, id, name, ...props }) => {
5
+ return (_jsxs(S.Container, { "$width": width, children: [label && _jsx(S.Label, { htmlFor: id, children: label }), _jsx(S.TextInput, { id: id, name: name, "$isError": !!errorMessage, ...props }), errorMessage && _jsx(S.ErrorMessage, { children: errorMessage })] }));
6
6
  };
@@ -1,6 +1,8 @@
1
1
  export declare const Container: import("@emotion/styled").StyledComponent<{
2
2
  theme?: import("@emotion/react").Theme;
3
3
  as?: React.ElementType;
4
+ } & {
5
+ $width?: string | number;
4
6
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
7
  export declare const TextInput: import("@emotion/styled").StyledComponent<{
6
8
  theme?: import("@emotion/react").Theme;
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/TextInput/ui/style.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;yGAKrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;cAA4B,OAAO;kHA+BxD,CAAC;AAEF,eAAO,MAAM,KAAK;;;kHAGjB,CAAC;AAEF,eAAO,MAAM,YAAY;;;2GAGxB,CAAC"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/TextInput/ui/style.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;aAAyB,MAAM,GAAG,MAAM;yGAM7D,CAAC;AAEF,eAAO,MAAM,SAAS;;;;cAA4B,OAAO;kHAgCxD,CAAC;AAEF,eAAO,MAAM,KAAK;;;kHAGjB,CAAC;AAEF,eAAO,MAAM,YAAY;;;2GAGxB,CAAC"}
@@ -3,12 +3,14 @@ import { shapes } from "@bds-web/shapes";
3
3
  import { typoCss } from "@bds-web/typography";
4
4
  import styled from "@emotion/styled";
5
5
  export const Container = styled.div `
6
+ width: ${({ $width }) => $width};
6
7
  display: flex;
7
8
  flex-direction: column;
8
9
  align-items: flex-start;
9
10
  gap: 4px;
10
11
  `;
11
12
  export const TextInput = styled.input `
13
+ width: 100%;
12
14
  ${typoCss("Body")};
13
15
  height: 48px;
14
16
  border-radius: ${shapes.medium};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bds-web/ui",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",