@edu-tosel/design 1.0.77 → 1.0.79
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/card/template/ProgressCard/Large.js +3 -5
- package/interface/widget/Select.d.ts +12 -3
- package/interface/widget/Select.js +9 -1
- package/interface/widget/index.d.ts +3 -7
- package/interface/widget/index.js +1 -0
- package/package.json +1 -1
- package/tailwind.config.ts +2 -1
- package/version.txt +1 -1
- package/widget/template/Select/Handle.d.ts +1 -1
- package/widget/template/Select/Handle.js +6 -4
- package/widget/template/Select/Select.LG.d.ts +1 -1
- package/widget/template/Select/Select.LG.js +11 -9
- package/widget/template/Select/Select.d.ts +1 -1
- package/widget/template/Select/Select.js +12 -10
- package/widget/template/Select/Switch.d.ts +1 -1
- package/widget/template/Select/Switch.js +3 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { widthSizes } from "../../../asset/sizes";
|
|
2
3
|
import SVG from "../../../asset/SVG";
|
|
3
4
|
import { cn } from "../../../util";
|
|
4
5
|
import CardDesign from "../../design/Card.design";
|
|
@@ -31,12 +32,9 @@ export default function ProgressCardLG({ titles, checks, displays, theme, }) {
|
|
|
31
32
|
positions: "absolute top-12 right-12",
|
|
32
33
|
displays: "flex flex-col items-end gap-y-3",
|
|
33
34
|
};
|
|
34
|
-
const occupied =
|
|
35
|
-
checks.map((value) => !!value).length,
|
|
36
|
-
displays.length,
|
|
37
|
-
].join("/");
|
|
35
|
+
const occupied = Math.round((checks.filter((value) => !!value).length / displays.length) * 100);
|
|
38
36
|
return (_jsxs(CardDesign, { option: {
|
|
39
37
|
width: "2xl",
|
|
40
38
|
height: "2xs",
|
|
41
|
-
}, children: [_jsx("div", { className: cn(progressBox), children: displays.map(({ title }, index) => (_jsxs("div", { className: cn(stepBox(checks[index])), children: [_jsx("div", { children: title }), _jsx(SVG.Operation.Checked, { flag: checks[index], size: 25, theme: theme })] }, title))) }), _jsxs("div", { className: cn(titleBox), children: [_jsx("div", { className: `text-xl leading-none font-pretendard-bold ${text[theme ?? "green"]}`, children: titles.title }), _jsx("div", { className: "text-base leading-none", children: titles.subtitle })] }), _jsx("div", { className: "absolute bottom-0 left-0 bg-gray-light w-full h-2.5", children: _jsx("div", { className: `h-full
|
|
39
|
+
}, children: [_jsx("div", { className: cn(progressBox), children: displays.map(({ title }, index) => (_jsxs("div", { className: cn(stepBox(checks[index])), children: [_jsx("div", { children: title }), _jsx(SVG.Operation.Checked, { flag: checks[index], size: 25, theme: theme })] }, title))) }), _jsxs("div", { className: cn(titleBox), children: [_jsx("div", { className: `text-xl leading-none font-pretendard-bold ${text[theme ?? "green"]}`, children: titles.title }), _jsx("div", { className: "text-base leading-none", children: titles.subtitle })] }), _jsx("div", { className: "absolute bottom-0 left-0 bg-gray-light w-full h-2.5", children: _jsx("div", { className: `h-full ${widthSizes[occupied]} ${bg[theme ?? "green"]}` }) })] }));
|
|
42
40
|
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import { Widget } from ".";
|
|
1
2
|
import { Size, State } from "../Property";
|
|
2
|
-
|
|
3
|
+
type SelectOptionTuple<T> = [T, string];
|
|
4
|
+
export interface SelectOption<T> {
|
|
3
5
|
title: string;
|
|
4
6
|
value: T;
|
|
5
7
|
icon?: string;
|
|
6
8
|
}
|
|
9
|
+
export type SelectOptionInput<T> = SelectOption<T> | SelectOptionTuple<T>;
|
|
10
|
+
export declare function toSelectOption<T>(option: SelectOptionInput<T>): SelectOption<T>;
|
|
11
|
+
export interface SelectWidget<T> extends Widget {
|
|
12
|
+
state: State<T>;
|
|
13
|
+
selectOptions?: SelectOptionInput<T>[];
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
}
|
|
7
16
|
export interface SelectSwitchProps<T> {
|
|
8
17
|
state: State<T>;
|
|
9
|
-
selectOptions:
|
|
18
|
+
selectOptions: SelectOptionInput<T>[];
|
|
10
19
|
option?: {
|
|
11
20
|
size?: Size;
|
|
12
21
|
text?: string;
|
|
@@ -15,7 +24,7 @@ export interface SelectSwitchProps<T> {
|
|
|
15
24
|
}
|
|
16
25
|
export interface SelectHandleProps<T> {
|
|
17
26
|
state: State<T>;
|
|
18
|
-
|
|
27
|
+
selectOptions: SelectOptionInput<T>[];
|
|
19
28
|
option?: {
|
|
20
29
|
className?: string;
|
|
21
30
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Color } from "../Color";
|
|
2
2
|
import { Disabled, OnClick, Size, State } from "../Property";
|
|
3
|
+
import { SelectOptionInput } from "./Select";
|
|
3
4
|
export * from "./Carousel";
|
|
4
5
|
export * from "./Switch";
|
|
6
|
+
export * from "./Select";
|
|
5
7
|
export declare const WidgetType: {
|
|
6
8
|
readonly TEXT: "text";
|
|
7
9
|
readonly BUTTON: "button";
|
|
@@ -27,12 +29,6 @@ export interface LabelWidget extends Widget {
|
|
|
27
29
|
hoverState?: State<boolean>;
|
|
28
30
|
onClick?: OnClick;
|
|
29
31
|
}
|
|
30
|
-
export type SelectOption<T> = [T, string];
|
|
31
|
-
export interface SelectWidget<T> extends Widget {
|
|
32
|
-
state: State<T>;
|
|
33
|
-
selectOptions?: SelectOption<T>[];
|
|
34
|
-
placeholder?: string;
|
|
35
|
-
}
|
|
36
32
|
type InputType = "text" | "password" | "date" | "email" | "phone" | "number";
|
|
37
33
|
export interface InputWidget extends Widget {
|
|
38
34
|
state: State<string> | State<string | undefined>;
|
|
@@ -53,7 +49,7 @@ export interface WidgetFrame {
|
|
|
53
49
|
title: string;
|
|
54
50
|
type: WidgetType;
|
|
55
51
|
state: State<any>;
|
|
56
|
-
selectOptions?:
|
|
52
|
+
selectOptions?: SelectOptionInput<string | number>[];
|
|
57
53
|
labels?: [string | boolean, string][];
|
|
58
54
|
disabled?: Disabled;
|
|
59
55
|
onClick?: OnClick;
|
package/package.json
CHANGED
package/tailwind.config.ts
CHANGED
|
@@ -56,9 +56,10 @@ export default {
|
|
|
56
56
|
"red-crimson": "#760023",
|
|
57
57
|
"red-velvet": "#AC647A",
|
|
58
58
|
"green-dark": "#105652",
|
|
59
|
-
"green-light": "#
|
|
59
|
+
"green-light": "#DFE5E4",
|
|
60
60
|
"blue-sky": "#44C5F3",
|
|
61
61
|
"blue-navy": "#173A8B",
|
|
62
|
+
"blue-navy-light": "#E1E4EB",
|
|
62
63
|
"blue-pastel": "#CED6E6",
|
|
63
64
|
"violet-light": "#9979F6",
|
|
64
65
|
"gray-light": "#F0F0F0",
|
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.79
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SelectHandleProps } from "../../../interface/widget/Select";
|
|
2
|
-
export default function SelectHandle<T>({ state,
|
|
2
|
+
export default function SelectHandle<T>({ state, selectOptions: selectOptionsInput, option, }: SelectHandleProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { widthSizes } from "../../../asset/sizes";
|
|
3
|
+
import { toSelectOption, } from "../../../interface/widget/Select";
|
|
3
4
|
import { cn, gradient } from "../../../util";
|
|
4
|
-
export default function SelectHandle({ state,
|
|
5
|
+
export default function SelectHandle({ state, selectOptions: selectOptionsInput, option, }) {
|
|
6
|
+
const selectOptions = selectOptionsInput?.map(toSelectOption);
|
|
5
7
|
const { className } = option ?? {};
|
|
6
|
-
const length =
|
|
7
|
-
const valueIndex = Object.values(
|
|
8
|
+
const length = selectOptions?.length;
|
|
9
|
+
const valueIndex = Object.values(selectOptions)
|
|
8
10
|
.map(({ value }) => value)
|
|
9
11
|
?.indexOf(state?.[0]);
|
|
10
12
|
const container = {
|
|
@@ -24,7 +26,7 @@ export default function SelectHandle({ state, options, option, }) {
|
|
|
24
26
|
sizes: "w-5 h-5",
|
|
25
27
|
styles: "rounded-full bg-white",
|
|
26
28
|
};
|
|
27
|
-
return (_jsxs("div", { className: cn(container), children: [_jsx("div", { className: cn(area), children: _jsx("div", { className: cn(handle) }) }), _jsx("div", { className: "absolute flex w-full h-full top-0 left-0", children:
|
|
29
|
+
return (_jsxs("div", { className: cn(container), children: [_jsx("div", { className: cn(area), children: _jsx("div", { className: cn(handle) }) }), _jsx("div", { className: "absolute flex w-full h-full top-0 left-0", children: selectOptions?.map(({ value }) => (_jsx("button", { onClick: () => {
|
|
28
30
|
return state?.[1](value);
|
|
29
31
|
}, className: "flex flex-1 h-10 " }, value))) })] }));
|
|
30
32
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SelectWidget } from "../../../interface";
|
|
2
|
-
export default function SelectLG<T>({ state, selectOptions, placeholder, option, }: SelectWidget<T>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function SelectLG<T>({ state, selectOptions: selectOptionsInput, placeholder, option, }: SelectWidget<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toSelectOption, } from "../../../interface";
|
|
2
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
4
|
import { useActionStore } from "../../../store";
|
|
4
5
|
import { useFlag } from "../../../hook";
|
|
@@ -14,7 +15,8 @@ const heightSize = {
|
|
|
14
15
|
xs: "h-6.5",
|
|
15
16
|
sm: "h-9",
|
|
16
17
|
};
|
|
17
|
-
export default function SelectLG({ state, selectOptions, placeholder, option, }) {
|
|
18
|
+
export default function SelectLG({ state, selectOptions: selectOptionsInput, placeholder, option, }) {
|
|
19
|
+
const selectOptions = selectOptionsInput?.map(toSelectOption);
|
|
18
20
|
const id = useId();
|
|
19
21
|
const { isDark } = option ?? {};
|
|
20
22
|
const { setIsOwn, setIsOwnId } = useActionStore();
|
|
@@ -23,7 +25,7 @@ export default function SelectLG({ state, selectOptions, placeholder, option, })
|
|
|
23
25
|
const [search, setSearch] = useState("");
|
|
24
26
|
const [isOpen, setIsOpen] = useState(false);
|
|
25
27
|
const [isHover, setIsHover] = useState(false);
|
|
26
|
-
const [filteredOptions, setFilterdOptions] = useState(
|
|
28
|
+
const [filteredOptions, setFilterdOptions] = useState();
|
|
27
29
|
const [index, setIndex] = useState();
|
|
28
30
|
const listRef = useRef(null);
|
|
29
31
|
const itemRefs = useRef([]);
|
|
@@ -34,8 +36,8 @@ export default function SelectLG({ state, selectOptions, placeholder, option, })
|
|
|
34
36
|
if (typeof index === "undefined")
|
|
35
37
|
return setIndex(0);
|
|
36
38
|
if (e.key === "Enter") {
|
|
37
|
-
setText(filteredOptions[index]
|
|
38
|
-
return setValue(filteredOptions[index]
|
|
39
|
+
setText(filteredOptions[index]?.title);
|
|
40
|
+
return setValue(filteredOptions[index]?.value);
|
|
39
41
|
}
|
|
40
42
|
if (e.key === "ArrowDown") {
|
|
41
43
|
setIndex((index + 1) % filteredOptions.length);
|
|
@@ -45,7 +47,7 @@ export default function SelectLG({ state, selectOptions, placeholder, option, })
|
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
49
|
useEffect(() => {
|
|
48
|
-
setFilterdOptions(selectOptions?.filter((
|
|
50
|
+
setFilterdOptions(selectOptions?.filter(({ title }) => title.includes(search)));
|
|
49
51
|
}, [search, selectOptions]);
|
|
50
52
|
useEffect(() => {
|
|
51
53
|
if (typeof index === "number" && itemRefs.current[index]) {
|
|
@@ -103,12 +105,12 @@ export default function SelectLG({ state, selectOptions, placeholder, option, })
|
|
|
103
105
|
leave: { top: isLong ? 88 : 44 },
|
|
104
106
|
config: { duration: 0 },
|
|
105
107
|
});
|
|
106
|
-
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(false)), children: selectOptions?.find((option) => value === option
|
|
108
|
+
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(false)), children: selectOptions?.find((option) => value === option.value)?.title })) : (_jsx("div", { className: "text-xs pl-1", children: placeholder ?? "선택해주세요" })) }), inputTransition((styles, item) => isLong &&
|
|
107
109
|
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) => {
|
|
108
|
-
return (item && (_jsx(animated.div, { style: styles, className: cn(body), ref: listRef, children: filteredOptions?.map((
|
|
110
|
+
return (item && (_jsx(animated.div, { style: styles, className: cn(body), ref: listRef, children: filteredOptions?.map(({ value, title }, order) => (_jsx("section", { children: _jsx("button", { ref: (el) => (itemRefs.current[order] = el), onClick: () => {
|
|
109
111
|
setValue(value);
|
|
110
|
-
setText(
|
|
112
|
+
setText(title);
|
|
111
113
|
return setIsOpen(false);
|
|
112
|
-
}, className: cn(label(order === index)), children:
|
|
114
|
+
}, className: cn(label(order === index)), children: title }) }, id + value))) })));
|
|
113
115
|
})] }));
|
|
114
116
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SelectWidget } from "../../../interface";
|
|
2
|
-
export default function Select<T>({ state, selectOptions, placeholder, option, }: SelectWidget<T>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function Select<T>({ state, selectOptions: selectOptionsInput, placeholder, option, }: SelectWidget<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { toSelectOption, } from "../../../interface";
|
|
3
4
|
import { cn } from "../../../util";
|
|
4
5
|
import { useTransition, animated } from "react-spring";
|
|
5
6
|
import { useActionStore } from "../../../store";
|
|
@@ -13,7 +14,8 @@ const widthSize = {
|
|
|
13
14
|
const heightSize = {
|
|
14
15
|
xs: "h-6.5",
|
|
15
16
|
};
|
|
16
|
-
export default function Select({ state, selectOptions, placeholder, option, }) {
|
|
17
|
+
export default function Select({ state, selectOptions: selectOptionsInput, placeholder, option, }) {
|
|
18
|
+
const selectOptions = selectOptionsInput?.map(toSelectOption);
|
|
17
19
|
const id = useId();
|
|
18
20
|
const { setIsOwn, setIsOwnId } = useActionStore();
|
|
19
21
|
const [value, setValue] = state;
|
|
@@ -21,7 +23,7 @@ export default function Select({ state, selectOptions, placeholder, option, }) {
|
|
|
21
23
|
const [search, setSearch] = useState("");
|
|
22
24
|
const [isOpen, setIsOpen] = useState(false);
|
|
23
25
|
const [isHover, setIsHover] = useState(false);
|
|
24
|
-
const [filteredOptions, setFilterdOptions] = useState(
|
|
26
|
+
const [filteredOptions, setFilterdOptions] = useState();
|
|
25
27
|
const [index, setIndex] = useState();
|
|
26
28
|
useFlag({ state: [false, setIsOpen], safe: "overlay" });
|
|
27
29
|
const onKeyDown = (e) => {
|
|
@@ -30,8 +32,8 @@ export default function Select({ state, selectOptions, placeholder, option, }) {
|
|
|
30
32
|
if (typeof index === "undefined")
|
|
31
33
|
return setIndex(0);
|
|
32
34
|
if (e.key === "Enter") {
|
|
33
|
-
setText(filteredOptions[index]
|
|
34
|
-
return setValue(filteredOptions[index]
|
|
35
|
+
setText(filteredOptions[index]?.title);
|
|
36
|
+
return setValue(filteredOptions[index]?.value);
|
|
35
37
|
}
|
|
36
38
|
if (e.key === "ArrowDown")
|
|
37
39
|
return setIndex((index + 1) % filteredOptions.length);
|
|
@@ -39,9 +41,9 @@ export default function Select({ state, selectOptions, placeholder, option, }) {
|
|
|
39
41
|
return setIndex((index - 1 + filteredOptions.length) % filteredOptions.length);
|
|
40
42
|
};
|
|
41
43
|
useEffect(() => {
|
|
42
|
-
setFilterdOptions(selectOptions?.filter((
|
|
44
|
+
setFilterdOptions(selectOptions?.filter(({ title }) => text.includes(title)));
|
|
43
45
|
}, [search, selectOptions]);
|
|
44
|
-
//
|
|
46
|
+
// scrollIntoViews
|
|
45
47
|
const listRef = useRef(null);
|
|
46
48
|
const itemRefs = useRef([]);
|
|
47
49
|
useEffect(() => {
|
|
@@ -107,12 +109,12 @@ export default function Select({ state, selectOptions, placeholder, option, }) {
|
|
|
107
109
|
duration: 0,
|
|
108
110
|
},
|
|
109
111
|
});
|
|
110
|
-
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
|
|
112
|
+
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.value)?.title })) : (_jsx("div", { className: "text-xs pl-1", children: placeholder ?? "선택해주세요" })) }), inputTransition((styles, item) => isLong &&
|
|
111
113
|
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) => {
|
|
112
|
-
return (item && (_jsx(animated.div, { style: styles, className: cn(body), ref: listRef, children: filteredOptions?.map((
|
|
114
|
+
return (item && (_jsx(animated.div, { style: styles, className: cn(body), ref: listRef, children: filteredOptions?.map(({ value, title }, order) => (_jsx("section", { children: _jsx("button", { ref: (el) => (itemRefs.current[order] = el), onClick: () => {
|
|
113
115
|
setValue(value);
|
|
114
|
-
setText(
|
|
116
|
+
setText(title);
|
|
115
117
|
return setIsOpen(false);
|
|
116
|
-
}, className: cn(label, order === index ? "w-full" : "w-auto"), children:
|
|
118
|
+
}, className: cn(label, order === index ? "w-full" : "w-auto"), children: title }) }, id + value))) })));
|
|
117
119
|
})] }));
|
|
118
120
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SelectSwitchProps } from "../../../interface/widget/Select";
|
|
2
|
-
declare function SelectSwitch<T>({ state, selectOptions, option, }: SelectSwitchProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function SelectSwitch<T>({ state, selectOptions: selectOptionsInput, option, }: SelectSwitchProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default SelectSwitch;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toSelectOption, } from "../../../interface/widget/Select";
|
|
2
3
|
import { cn } from "../../../util";
|
|
3
4
|
const paddingSize = {
|
|
4
5
|
md: "p-1.5",
|
|
@@ -20,7 +21,8 @@ const textSize = {
|
|
|
20
21
|
md: "text-sm",
|
|
21
22
|
lg: "text-base",
|
|
22
23
|
};
|
|
23
|
-
function SelectSwitch({ state, selectOptions, option, }) {
|
|
24
|
+
function SelectSwitch({ state, selectOptions: selectOptionsInput, option, }) {
|
|
25
|
+
const selectOptions = selectOptionsInput.map(toSelectOption);
|
|
24
26
|
const { text, size, className } = option ?? {};
|
|
25
27
|
const container = {
|
|
26
28
|
sizes: `${widthSize[size ?? "md"]} ${heightSize[size ?? "md"]}`,
|