@edu-tosel/design 1.0.54 → 1.0.55

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.
package/asset/SVG.d.ts CHANGED
@@ -33,6 +33,7 @@ declare const SVG: {
33
33
  size?: number | undefined;
34
34
  theme?: import("../interface/Theme").Theme | undefined;
35
35
  }) => import("react/jsx-runtime").JSX.Element;
36
+ RightArrow: ({ onClick }: Operation) => import("react/jsx-runtime").JSX.Element;
36
37
  };
37
38
  Phone: typeof Phone;
38
39
  Profile: typeof Profile;
@@ -10,9 +10,11 @@ declare function Checked({ flag, size, theme, }: {
10
10
  size?: number;
11
11
  theme?: Theme;
12
12
  }): import("react/jsx-runtime").JSX.Element;
13
+ declare function RightArrow({ onClick }: Operation): import("react/jsx-runtime").JSX.Element;
13
14
  declare const Operation: {
14
15
  Plus: typeof Plus;
15
16
  Minus: typeof Minus;
16
17
  Checked: typeof Checked;
18
+ RightArrow: typeof RightArrow;
17
19
  };
18
20
  export default Operation;
@@ -16,9 +16,13 @@ function Checked({ flag, size, theme, }) {
16
16
  };
17
17
  return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: size ?? "40", height: size ?? "40", viewBox: "0 0 48 48", fill: "none", children: [_jsx("path", { d: "M42 24C42 26.3638 41.5344 28.7044 40.6298 30.8883C39.7253 33.0722 38.3994 35.0565 36.7279 36.7279C35.0565 38.3994 33.0722 39.7253 30.8883 40.6298C28.7044 41.5344 26.3638 42 24 42C21.6362 42 19.2956 41.5344 17.1117 40.6298C14.9278 39.7253 12.9435 38.3994 11.2721 36.7279C9.60062 35.0565 8.27475 33.0722 7.37017 30.8883C6.46558 28.7044 6 26.3638 6 24C6 19.2261 7.89642 14.6477 11.2721 11.2721C14.6477 7.89642 19.2261 6 24 6C28.7739 6 33.3523 7.89642 36.7279 11.2721C40.1036 14.6477 42 19.2261 42 24Z", fill: flag ? color[theme ?? "green"] : "#F0F0F0" }), _jsx("path", { d: "M30.5 18.5L24 30.5L18 24", stroke: "white", "stroke-width": "3", "stroke-linecap": "round", "stroke-linejoin": "round" })] }));
18
18
  }
19
+ function RightArrow({ onClick }) {
20
+ return (_jsxs("svg", { className: cn(container), onClick: onClick, xmlns: "http://www.w3.org/2000/svg", width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", children: [_jsx("path", { d: "M42 24C42 26.3638 41.5344 28.7044 40.6298 30.8883C39.7253 33.0722 38.3994 35.0565 36.7279 36.7279C35.0565 38.3994 33.0722 39.7253 30.8883 40.6298C28.7044 41.5344 26.3638 42 24 42C21.6362 42 19.2956 41.5344 17.1117 40.6298C14.9278 39.7253 12.9435 38.3994 11.2721 36.7279C9.60062 35.0565 8.27475 33.0722 7.37017 30.8883C6.46558 28.7044 6 26.3638 6 24C6 19.2261 7.89642 14.6477 11.2721 11.2721C14.6477 7.89642 19.2261 6 24 6C28.7739 6 33.3523 7.89642 36.7279 11.2721C40.1036 14.6477 42 19.2261 42 24Z", fill: "#105652" }), _jsx("path", { d: "M20 24H28M24 20L28 24L24 28", stroke: "white", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] }));
21
+ }
19
22
  const Operation = {
20
23
  Plus,
21
24
  Minus,
22
25
  Checked,
26
+ RightArrow,
23
27
  };
24
28
  export default Operation;
@@ -95,10 +95,36 @@ function Checked({
95
95
  </svg>
96
96
  );
97
97
  }
98
+ function RightArrow({ onClick }: Operation) {
99
+ return (
100
+ <svg
101
+ className={cn(container)}
102
+ onClick={onClick}
103
+ xmlns="http://www.w3.org/2000/svg"
104
+ width="48"
105
+ height="48"
106
+ viewBox="0 0 48 48"
107
+ fill="none"
108
+ >
109
+ <path
110
+ d="M42 24C42 26.3638 41.5344 28.7044 40.6298 30.8883C39.7253 33.0722 38.3994 35.0565 36.7279 36.7279C35.0565 38.3994 33.0722 39.7253 30.8883 40.6298C28.7044 41.5344 26.3638 42 24 42C21.6362 42 19.2956 41.5344 17.1117 40.6298C14.9278 39.7253 12.9435 38.3994 11.2721 36.7279C9.60062 35.0565 8.27475 33.0722 7.37017 30.8883C6.46558 28.7044 6 26.3638 6 24C6 19.2261 7.89642 14.6477 11.2721 11.2721C14.6477 7.89642 19.2261 6 24 6C28.7739 6 33.3523 7.89642 36.7279 11.2721C40.1036 14.6477 42 19.2261 42 24Z"
111
+ fill="#105652"
112
+ />
113
+ <path
114
+ d="M20 24H28M24 20L28 24L24 28"
115
+ stroke="white"
116
+ strokeWidth="3"
117
+ strokeLinecap="round"
118
+ strokeLinejoin="round"
119
+ />
120
+ </svg>
121
+ );
122
+ }
98
123
 
99
124
  const Operation = {
100
125
  Plus,
101
126
  Minus,
102
127
  Checked,
128
+ RightArrow,
103
129
  };
104
130
  export default Operation;
@@ -1,2 +1,2 @@
1
1
  import { RollCardProps } from "../../interface";
2
- export default function RollCardDesign({ titles, state, isDisabled, isFixed, children, }: RollCardProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function RollCardDesign({ titles, state, disabled, isFixed, children, }: RollCardProps): import("react/jsx-runtime").JSX.Element;
@@ -5,8 +5,9 @@ import { Action, Shelf } from "../../layout";
5
5
  import Card from "./Card.design";
6
6
  import { useEffect, useState } from "react";
7
7
  import { cn } from "../../util";
8
- export default function RollCardDesign({ titles, state, isDisabled, isFixed, children, }) {
8
+ export default function RollCardDesign({ titles, state, disabled, isFixed, children, }) {
9
9
  const [isOpen, setIsOpen] = state;
10
+ const [isDisabled, disabledFn] = disabled || [false, () => { }];
10
11
  const [flag, setFlag] = useState(false);
11
12
  useEffect(() => {
12
13
  if (isFixed) {
@@ -24,13 +25,19 @@ export default function RollCardDesign({ titles, state, isDisabled, isFixed, chi
24
25
  return (_jsxs(Card, { options: {
25
26
  width: "2xl",
26
27
  height: !isFixed && isOpen ? "xs" : "3xs",
27
- background: flag ? "bg-green-dark/10" : "bg-white",
28
+ background: isDisabled || flag ? "bg-green-dark/10" : "bg-white",
28
29
  className: "p-7.5 flex flex-col gap-y-6",
29
- }, children: [_jsxs(Shelf.Row, { className: "justify-between", children: [_jsxs(Shelf.Col, { className: "gap-y-2.5", children: [_jsxs(Shelf.Row, { className: "gap-x-2.5 items-center", children: [titles.icon && _jsx("img", { src: titles.icon, alt: "icon" }), _jsx("div", { className: "text-xl leading-none font-pretendard-bold text-green-dark", children: titles.title })] }), _jsx("div", { className: "leading-none", children: titles.subtitle })] }), _jsxs("div", { className: "flex gap-3.5 items-center", children: [_jsx(Label, { title: isFixed ? (flag ? "추가됨" : "수정하기") : "접수중", options: {
30
- background: flag ? "bg-green-dark" : "bg-green-dark/10",
31
- text: flag ? "text-white" : "bg-green-dark",
30
+ }, children: [_jsxs(Shelf.Row, { className: "justify-between", children: [_jsxs(Shelf.Col, { className: "gap-y-2.5", children: [_jsxs(Shelf.Row, { className: "gap-x-2.5 items-center", children: [titles.icon && _jsx("img", { src: titles.icon, alt: "icon" }), _jsx("div", { className: "text-xl leading-none font-pretendard-bold text-green-dark", children: titles.title })] }), _jsx("div", { className: "leading-none", children: titles.subtitle })] }), _jsxs("div", { className: "flex gap-3.5 items-center", children: [_jsx(Label, { title: !isDisabled
31
+ ? isFixed
32
+ ? flag
33
+ ? "추가됨"
34
+ : "수정하기"
35
+ : "접수중"
36
+ : "접수 완료", options: {
37
+ background: isDisabled || flag ? "bg-green-dark" : "bg-green-dark/10",
38
+ text: isDisabled || flag ? "text-white" : "bg-green-dark",
32
39
  } }), _jsx(Action.Replace, { actions: [
33
- [isDisabled, null],
40
+ [isDisabled, _jsx(SVG.Operation.RightArrow, { onClick: disabledFn })],
34
41
  [!isDisabled && isFixed, _jsx(SVG.Operation.Checked, { flag: true })],
35
42
  [
36
43
  !isDisabled && !isFixed && !isOpen,
@@ -127,6 +127,6 @@ export interface RollCardProps extends CardProps {
127
127
  };
128
128
  state: State<boolean>;
129
129
  isFixed?: boolean;
130
- isDisabled?: boolean;
130
+ disabled?: [boolean, OnClick];
131
131
  }
132
132
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edu-tosel/design",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "description": "UI components for International TOSEL Committee",
5
5
  "keywords": [
6
6
  "jsx",
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.54
1
+ 1.0.55
@@ -1,2 +1,2 @@
1
1
  import { HTMLSelectElement } from "../../../interface";
2
- export default function SelectLG<T>({ state, }: HTMLSelectElement<T>): import("react/jsx-runtime").JSX.Element;
2
+ export default function SelectLG<T>({ state, selectOptions, placeholder, options, }: HTMLSelectElement<T>): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,20 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useId, useState } from "react";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from "react";
3
3
  import { useActionStore } from "../../../store";
4
4
  import { useFlag } from "../../../hook";
5
- 0;
5
+ import { cn } from "../../../util";
6
+ import { useTransition, animated } from "react-spring";
6
7
  const widthSize = {
7
8
  xs: "w-10",
8
9
  sm: "w-22.5",
9
- md: "w-40",
10
+ md: "w-38",
10
11
  lg: "w-50",
11
12
  };
12
13
  const heightSize = {
13
14
  xs: "h-6.5",
15
+ sm: "h-9",
14
16
  };
15
- export default function SelectLG({ state, }) {
17
+ export default function SelectLG({ state, selectOptions, placeholder, options, }) {
16
18
  const id = useId();
17
19
  const { setIsOwn, setIsOwnId } = useActionStore();
18
20
  const [value, setValue] = state;
@@ -22,6 +24,8 @@ export default function SelectLG({ state, }) {
22
24
  const [isHover, setIsHover] = useState(false);
23
25
  const [filteredOptions, setFilterdOptions] = useState([]);
24
26
  const [index, setIndex] = useState();
27
+ const listRef = useRef(null);
28
+ const itemRefs = useRef([]);
25
29
  useFlag({ state: [false, setIsOpen], safe: "overlay" });
26
30
  const onKeyDown = (e) => {
27
31
  if (!filteredOptions)
@@ -32,10 +36,71 @@ export default function SelectLG({ state, }) {
32
36
  setText(filteredOptions[index][1]);
33
37
  return setValue(filteredOptions[index][0]);
34
38
  }
35
- if (e.key === "ArrowDown")
36
- return setIndex((index + 1) % filteredOptions.length);
37
- if (e.key === "ArrowUp")
38
- return setIndex((index - 1 + filteredOptions.length) % filteredOptions.length);
39
+ if (e.key === "ArrowDown") {
40
+ setIndex((index + 1) % filteredOptions.length);
41
+ }
42
+ if (e.key === "ArrowUp") {
43
+ setIndex((index - 1 + filteredOptions.length) % filteredOptions.length);
44
+ }
45
+ };
46
+ useEffect(() => {
47
+ setFilterdOptions(selectOptions?.filter(([_, text]) => text.includes(search)));
48
+ }, [search, selectOptions]);
49
+ useEffect(() => {
50
+ if (typeof index === "number" && itemRefs.current[index]) {
51
+ itemRefs.current[index]?.scrollIntoView({ block: "nearest" });
52
+ }
53
+ }, [index]);
54
+ const isLong = selectOptions && selectOptions.length >= 4;
55
+ const container = {
56
+ positions: "relative ",
57
+ displays: "flex flex-col",
58
+ };
59
+ const button = {
60
+ displays: "flex items-center",
61
+ sizes: `${widthSize[options?.width ?? "md"]} ${heightSize[options?.height ?? "sm"]}`,
62
+ styles: "pl-1 rounded-md focus:outline-none duration-100 text-gray-400",
63
+ shadow: isOpen || isHover ? "box-shadow" : "shadow-none",
64
+ };
65
+ const input = {
66
+ positions: "absolute z-30",
67
+ layouts: cn(button),
68
+ styles: "focus:outline-none text-xs pl-1.5",
69
+ };
70
+ const body = {
71
+ positions: "absolute z-30",
72
+ displays: "flex flex-col gap-1",
73
+ sizes: `${widthSize[options?.width ?? "md"]} min-h-6.5 max-h-40`,
74
+ paddings: "p-2",
75
+ styles: "bg-white box-shadow rounded-md box-shadow overflow-y-scroll",
76
+ };
77
+ const label = {
78
+ displays: "flex items-center",
79
+ sizes: "h-7 w-full",
80
+ paddings: "px-2",
81
+ styles: "rounded-sm duration-500",
82
+ fonts: "text-xs text-gray-dim hover:bg-green-dark hover:text-white",
39
83
  };
40
- return _jsx("select", { className: "w-64 h-32 border-2" });
84
+ const inputTransition = useTransition(isOpen, {
85
+ from: { top: 44 },
86
+ enter: { top: 44 },
87
+ leave: { top: 44 },
88
+ config: { duration: 0 },
89
+ });
90
+ const bodyTransitions = useTransition(isOpen, {
91
+ from: { top: isLong ? 88 : 44 },
92
+ enter: { top: isLong ? 88 : 44 },
93
+ leave: { top: isLong ? 88 : 44 },
94
+ config: { duration: 0 },
95
+ });
96
+ return (_jsxs("div", { className: cn(container), onKeyDown: onKeyDown, onClick: () => setIsOwn(true), children: [_jsx("button", { onClick: () => setIsOpen(!isOpen), className: cn(button), onMouseEnter: () => setIsHover(true), onMouseLeave: () => setIsHover(false), children: value ? (_jsx("div", { className: cn(label), children: selectOptions?.find((option) => value === option[0])?.[1] })) : (_jsx("div", { className: "text-xs pl-1", children: placeholder ?? "선택해주세요" })) }), inputTransition((styles, item) => isLong &&
97
+ item && (_jsx(animated.input, { style: styles, placeholder: "\uAC80\uC0C9\uC5B4\uB97C \uC785\uB825\uD558\uC138\uC694", className: cn(input), onChange: (e) => setSearch(e.target.value) }))), bodyTransitions((styles, item) => {
98
+ return (item && (_jsx(animated.div, { style: styles, className: cn(body), ref: listRef, children: filteredOptions?.map(([value, text], order) => (_jsx("section", { children: _jsx("button", { ref: (el) => (itemRefs.current[order] = el), onClick: () => {
99
+ setValue(value);
100
+ setText(text);
101
+ return setIsOpen(false);
102
+ }, className: cn(label, order === index
103
+ ? "bg-green-dark text-white w-full"
104
+ : "w-auto"), children: text }) }, id + value))) })));
105
+ })] }));
41
106
  }
@@ -7,7 +7,7 @@ import { useFlag } from "../../../hook";
7
7
  const widthSize = {
8
8
  xs: "w-10",
9
9
  sm: "w-22.5",
10
- md: "w-40",
10
+ md: "w-38",
11
11
  lg: "w-50",
12
12
  };
13
13
  const heightSize = {