@edu-tosel/design 1.0.84 → 1.0.86

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,7 +1,9 @@
1
1
  import { ReactNode } from "react";
2
2
  import { Button, Scripts, Size, State, Titles } from "./Property";
3
3
  import { ShowAction } from "./Action";
4
+ import { InputWidget, SelectSwitchProps, SelectTagProps } from "./widget";
4
5
  interface Option {
6
+ className?: string;
5
7
  width: Size;
6
8
  height: Size;
7
9
  padding: boolean;
@@ -15,12 +17,29 @@ interface ModalProps {
15
17
  titles: Titles;
16
18
  children: ReactNode;
17
19
  showAction?: ShowAction;
18
- className?: string;
19
20
  option?: Partial<Option>;
20
21
  debug?: string;
21
22
  }
22
- interface ConfirmModalProps extends ModalProps {
23
+ interface ConfirmModalProps<T = any> extends ModalProps {
23
24
  buttons: [Button, Button];
25
+ widgets?: ConfirmModalWidget<T>[];
26
+ }
27
+ type ConfirmModalWidget<T = string> = ConfirmModalSelectSwitchProps<T> | ConfirmModalSelectTagProps<T> | ConfirmModalInputFormProps | ConfirmModalNodeProps;
28
+ interface ConfirmModalSelectSwitchProps<T> {
29
+ type: "selectSwitch";
30
+ data: SelectSwitchProps<T>;
31
+ }
32
+ interface ConfirmModalSelectTagProps<T> {
33
+ type: "selectTag";
34
+ data: SelectTagProps<T>;
35
+ }
36
+ interface ConfirmModalInputFormProps {
37
+ type: "inputForm";
38
+ data: InputWidget;
39
+ }
40
+ interface ConfirmModalNodeProps {
41
+ type?: undefined;
42
+ data: ReactNode;
24
43
  }
25
44
  interface AlertModalProps extends Omit<ModalProps, "children"> {
26
45
  scripts: Scripts;
@@ -35,4 +54,4 @@ interface DaumPostcode {
35
54
  interface DaumPostcodeModalProps extends Omit<ModalProps, "titles" | "children"> {
36
55
  state: State<DaumPostcode>;
37
56
  }
38
- export type { ModalProps, ConfirmModalProps, AlertModalProps, DaumPostcodeModalProps, };
57
+ export type { ModalProps, ConfirmModalProps, ConfirmModalWidget, AlertModalProps, DaumPostcodeModalProps, };
@@ -4,6 +4,7 @@ export * from "./Card";
4
4
  export * from "./Color";
5
5
  export * from "./Data";
6
6
  export * from "./Layout";
7
+ export * from "./Modal";
7
8
  export * from "./Overlay";
8
9
  export * from "./Property";
9
10
  export * from "./Theme";
@@ -4,6 +4,7 @@ export * from "./Card";
4
4
  export * from "./Color";
5
5
  export * from "./Data";
6
6
  export * from "./Layout";
7
+ export * from "./Modal";
7
8
  export * from "./Overlay";
8
9
  export * from "./Property";
9
10
  export * from "./Theme";
@@ -22,6 +22,19 @@ export interface SelectSwitchProps<T> {
22
22
  className?: string;
23
23
  };
24
24
  }
25
+ export interface SelectTagProps<T> {
26
+ state: State<T[]>;
27
+ selectOptions: {
28
+ title: string;
29
+ value: T;
30
+ }[];
31
+ selectHow?: "one" | "plural";
32
+ option?: {
33
+ className?: string;
34
+ background?: string;
35
+ text?: string;
36
+ };
37
+ }
25
38
  export interface SelectHandleProps<T> {
26
39
  state: State<T>;
27
40
  selectOptions: SelectOptionInput<T>[];
@@ -31,12 +31,13 @@ export interface LabelWidget extends Widget {
31
31
  }
32
32
  type InputType = "text" | "password" | "date" | "email" | "phone" | "number";
33
33
  export interface InputWidget extends Widget {
34
+ title?: string;
34
35
  state: State<string> | State<string | undefined>;
35
36
  onKeyDown?: (e: React.KeyboardEvent) => void;
36
37
  placeholder?: string;
37
- isValid?: boolean;
38
+ isValid?: boolean | ((value: string) => boolean);
38
39
  type?: InputType;
39
- label?: LabelWidget;
40
+ button?: LabelWidget;
40
41
  maxLength?: number;
41
42
  disabled?: Disabled;
42
43
  }
@@ -48,7 +48,7 @@ export default function ModalDesign({ titles, showAction, children, option, debu
48
48
  };
49
49
  const titleBox = {
50
50
  displays: "flex flex-col items-end",
51
- sizes: "w-full",
51
+ sizes: "w-full min-h-[83px]",
52
52
  };
53
53
  const transitions = useTransition(isVisible, {
54
54
  from: { opacity: 0 },
@@ -3,5 +3,5 @@ import ModalDesign from "../design/Modal.design";
3
3
  export default function Alert({ titles, showAction, scripts, option, }) {
4
4
  const { script } = scripts ?? {};
5
5
  const { buttons } = option ?? {};
6
- return (_jsx(ModalDesign, { titles: titles, showAction: showAction, className: "pt-18 px-25", option: { buttons }, children: _jsx("div", { className: "flex flex-col gap-3", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx("div", { className: "h-2 w-14 rounded-full bg-pale-lavender" }), _jsx("div", { className: "text-xl font-pretendard-bold", children: script })] }) }) }));
6
+ return (_jsx(ModalDesign, { titles: titles, showAction: showAction, option: { buttons, className: "pt-18 px-25" }, children: _jsx("div", { className: "flex flex-col gap-3", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx("div", { className: "h-2 w-14 rounded-full bg-pale-lavender" }), _jsx("div", { className: "text-xl font-pretendard-bold", children: script })] }) }) }));
7
7
  }
@@ -1,2 +1,2 @@
1
1
  import { ConfirmModalProps } from "../../../interface/Modal";
2
- export default function Confirm(props: ConfirmModalProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function Confirm(props: Omit<ConfirmModalProps, "children">): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,29 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
2
3
  import { cn } from "../../../util";
4
+ import { Input, Select } from "../../../widget";
3
5
  import ConfirmModalDesign from "../../design/ConfirmModal.design";
4
6
  export default function Confirm(props) {
7
+ const { className } = props.option ?? {};
5
8
  const container = {
6
9
  displays: "flex flex-col",
7
10
  margins: "mt-2.5",
11
+ className,
8
12
  sizes: "w-full h-60",
9
13
  };
10
- return (_jsx(ConfirmModalDesign, { ...props, children: _jsx("div", { className: cn(container), children: props.children }), option: {
14
+ return (_jsx(ConfirmModalDesign, { ...props, children: _jsx("div", { className: cn(container), children: props.widgets?.map((widget, index) => (_createElement(ConfirmModalWidget, { ...widget, key: index }))) }), option: {
11
15
  width: "md",
12
16
  height: "lg",
13
17
  } }));
14
18
  }
19
+ function ConfirmModalWidget({ type, data }) {
20
+ if (type === "selectSwitch")
21
+ return _jsx(Select.Switch, { ...data });
22
+ if (type === "selectTag")
23
+ return _jsx(Select.Tag, { ...data });
24
+ if (type === "inputForm")
25
+ return _jsx(Input.Form, { ...data });
26
+ if (typeof type === "undefined")
27
+ return data;
28
+ return null;
29
+ }
@@ -1,10 +1,9 @@
1
1
  import { ConfirmModalProps } from "../../../interface/Modal";
2
- declare function ConfirmModal(props: ConfirmModalProps): import("react/jsx-runtime").JSX.Element;
2
+ declare function ConfirmModal(props: Omit<ConfirmModalProps, "children">): import("react/jsx-runtime").JSX.Element;
3
3
  declare namespace ConfirmModal {
4
4
  var Alert: typeof import("./Alert").default;
5
5
  var Input: typeof import("./Input").default;
6
6
  var Reimage: typeof import("./Reimage").default;
7
- var Switch: typeof import("./Switch").default;
8
7
  var Tag: typeof import("./Tag").default;
9
8
  }
10
9
  export default ConfirmModal;
@@ -4,13 +4,11 @@ import Alert from "./Alert";
4
4
  import Input from "./Input";
5
5
  import Reimage from "./Reimage";
6
6
  import Tag from "./Tag";
7
- import Switch from "./Switch";
8
7
  function ConfirmModal(props) {
9
8
  return _jsx(Confirm, { ...props });
10
9
  }
11
10
  ConfirmModal.Alert = Alert;
12
11
  ConfirmModal.Input = Input;
13
12
  ConfirmModal.Reimage = Reimage;
14
- ConfirmModal.Switch = Switch;
15
13
  ConfirmModal.Tag = Tag;
16
14
  export default ConfirmModal;
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import ModalDesign from "../design/Modal.design";
3
3
  export default function Input({ titles, showAction, option, state, }) {
4
4
  const { buttons } = option ?? {};
5
- return (_jsx(ModalDesign, { titles: titles, showAction: showAction, className: "pt-18 px-25", option: { buttons }, children: _jsx("input", { className: "border-2 border-black w-80 h-8", value: state[0], onChange: (e) => state[1](e.target.value) }) }));
5
+ return (_jsx(ModalDesign, { titles: titles, showAction: showAction, option: { buttons, className: "pt-18 px-25" }, children: _jsx("input", { className: "border-2 border-black w-80 h-8", value: state[0], onChange: (e) => state[1](e.target.value) }) }));
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edu-tosel/design",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "description": "UI components for International TOSEL Committee",
5
5
  "keywords": [
6
6
  "jsx",
package/store/index.d.ts CHANGED
@@ -23,7 +23,7 @@ interface ActionProps<T = any> {
23
23
  setDark: () => void;
24
24
  items: T[];
25
25
  setItems: (prop: T[]) => void;
26
- updateItem: (prop: T, key: string) => void;
26
+ updateItem: (prop: T, key: string | string[]) => void;
27
27
  }
28
28
  export declare const useActionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ActionProps<any>>>;
29
29
  export {};
package/store/index.js CHANGED
@@ -70,6 +70,17 @@ export const useActionStore = create((set) => ({
70
70
  items: [],
71
71
  setItems: (prop) => set({ items: prop }),
72
72
  updateItem: (item, key) => set((state) => ({
73
- items: state.items.map((prevItem) => prevItem.id === item.id ? { ...prevItem, [key]: item[key] } : prevItem),
73
+ items: state.items.map((prevItem) => {
74
+ if (typeof key === "string")
75
+ return prevItem.id === item.id
76
+ ? { ...prevItem, [key]: item[key] }
77
+ : prevItem;
78
+ return prevItem.id === item.id
79
+ ? {
80
+ ...prevItem,
81
+ ...key.reduce((acc, cur) => ({ ...acc, [cur]: item[cur] }), {}),
82
+ }
83
+ : prevItem;
84
+ }),
74
85
  })),
75
86
  }));
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.84
1
+ 1.0.86
@@ -1,2 +1,2 @@
1
1
  import { InputWidget } from "../../../interface";
2
- export default function LG({ state, placeholder, isValid, type, label, maxLength, disabled, }: InputWidget): import("react/jsx-runtime").JSX.Element;
2
+ export default function InputForm({ title, state, placeholder, isValid, type, button, maxLength, disabled, }: InputWidget): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { useRef, useState } from "react";
3
3
  import { cn, gradient } from "../../../util";
4
4
  import Label from "../Label";
5
5
  import Obstacle from "../Obstacle";
6
- export default function LG({ state, placeholder, isValid, type, label, maxLength, disabled, }) {
6
+ export default function InputForm({ title, state, placeholder, isValid, type, button, maxLength, disabled, }) {
7
7
  const [value, setValue] = state;
8
8
  const [onFocus, setOnFocus] = useState(false);
9
9
  const ref = useRef(null);
@@ -16,15 +16,20 @@ export default function LG({ state, placeholder, isValid, type, label, maxLength
16
16
  fonts: "leading-none text-gray-medium font-pretendard-medium",
17
17
  animation: value || onFocus ? "top-2.625 text-xs" : "top-4.375 text-base",
18
18
  };
19
- const styleByFlag = (flag) => {
20
- if (typeof flag === "undefined")
21
- return "bg-gray-light border-green-dark";
22
- if (flag)
23
- return "bg-green-dark/10 text-green-dark border-green-dark ";
24
- return "bg-crimson-burgundy/10 text-crimson-burgundy border-crimson-burgundy";
19
+ const styleByFlag = () => {
20
+ const gray = "bg-gray-light border-green-dark";
21
+ const green = "bg-green-dark/10 text-green-dark border-green-dark";
22
+ const red = "bg-crimson-burgundy/10 text-crimson-burgundy border-crimson-burgundy";
23
+ if (typeof isValid === "undefined")
24
+ return gray;
25
+ if (typeof isValid === "function")
26
+ return isValid(value ?? "") ? green : red;
27
+ if (isValid)
28
+ return green;
29
+ return red;
25
30
  };
26
31
  const inputBox = {
27
- styles: styleByFlag(isValid),
32
+ styles: styleByFlag(),
28
33
  sizes: "w-102.5 h-13.5",
29
34
  paddings: `${placeholder && "pt-3"} pl-5`,
30
35
  fonts: "text-sm",
@@ -34,16 +39,16 @@ export default function LG({ state, placeholder, isValid, type, label, maxLength
34
39
  !(isValid === false) &&
35
40
  "shadow-[0px_0px_10px_0px_rgba(16,86,82,0.38)]",
36
41
  };
37
- return (_jsxs("div", { className: cn(container), children: [_jsx("div", { onClick: () => ref.current?.focus(), className: cn(placeholderBox), children: placeholder }), _jsx("input", { ref: ref, className: cn(inputBox), value: value, onFocus: () => setOnFocus(true), onBlur: () => setOnFocus(false), onChange: (e) => {
38
- if (maxLength && e.target.value.length > maxLength)
39
- return;
40
- setValue(e.target.value);
41
- }, type: type ?? "text" }), label && (_jsx(Label.Button, { title: label.title, onClick: label.onClick, option: {
42
- width: "sm",
43
- height: "xs",
44
- className: "absolute top-3.5 right-3.75",
45
- background: label.option?.background ?? gradient.bg.greenToRed,
46
- text: label.option?.text ?? "text-white",
47
- ...label.option,
48
- } })), _jsx(Obstacle, { disabled: disabled })] }));
42
+ return (_jsxs("div", { children: [title && _jsx("div", { className: "text-gray-dark", children: title }), _jsxs("div", { className: cn(container), children: [_jsx("div", { onClick: () => ref.current?.focus(), className: cn(placeholderBox), children: placeholder }), _jsx("input", { ref: ref, className: cn(inputBox), value: value, onFocus: () => setOnFocus(true), onBlur: () => setOnFocus(false), onChange: (e) => {
43
+ if (maxLength && e.target.value.length > maxLength)
44
+ return;
45
+ setValue(e.target.value);
46
+ }, type: type ?? "text" }), button && (_jsx(Label.Button, { title: button.title, onClick: button.onClick, option: {
47
+ width: "sm",
48
+ height: "xs",
49
+ className: "absolute top-3.5 right-3.75",
50
+ background: button.option?.background ?? gradient.bg.greenToRed,
51
+ text: button.option?.text ?? "text-white",
52
+ ...button.option,
53
+ } })), _jsx(Obstacle, { disabled: disabled })] })] }));
49
54
  }
@@ -38,8 +38,6 @@ function SelectSwitch({ state, selectOptions: selectOptionsInput, option, }) {
38
38
  textSizes: textSize[size ?? "md"],
39
39
  styles: "rounded-full ",
40
40
  });
41
- return (_jsx("div", { className: cn(container), children: selectOptions?.map(({ value, icon, title }) => {
42
- return (_jsxs("button", { onClick: () => state[1](value), className: cn(button(value === state[0])), children: [icon && _jsx("img", { src: icon }), _jsx("div", { children: title })] }));
43
- }) }));
41
+ return (_jsx("div", { className: cn(container), children: selectOptions?.map(({ value, icon, title }) => (_jsxs("button", { onClick: () => state[1](value), className: cn(button(value === state[0])), children: [icon && _jsx("img", { src: icon }), _jsx("div", { children: title })] }, String(value)))) }));
44
42
  }
45
43
  export default SelectSwitch;
@@ -1,16 +1,2 @@
1
- import { State } from "../../../interface";
2
- interface SelectTagProps<T> {
3
- state: State<T[]>;
4
- selectOptions: {
5
- title: string;
6
- value: T;
7
- }[];
8
- selectHow?: "one" | "plural";
9
- option?: {
10
- className?: string;
11
- background?: string;
12
- text?: string;
13
- };
14
- }
1
+ import { SelectTagProps } from "../../../interface";
15
2
  export default function SelectTag<T>(props: SelectTagProps<T>): import("react/jsx-runtime").JSX.Element;
16
- export {};
@@ -1,7 +0,0 @@
1
- import { ConfirmModalProps } from "../../../interface/Modal";
2
- import { SelectSwitchProps } from "../../../interface/widget/Select";
3
- interface SwitchModalProps<T> extends ConfirmModalProps {
4
- switch: SelectSwitchProps<T>;
5
- }
6
- declare function SwitchModal<T>(props: SwitchModalProps<T>): import("react/jsx-runtime").JSX.Element;
7
- export default SwitchModal;
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Select } from "../../../widget";
3
- import ConfirmModalDesign from "../../design/ConfirmModal.design";
4
- import { cn } from "../../../util";
5
- function SwitchModalDesign(props) {
6
- const container = {
7
- displays: "flex flex-col justify-center items-center",
8
- sizes: "w-full",
9
- };
10
- return (_jsx(ConfirmModalDesign, { ...props, children: _jsx("div", { className: cn(container), children: props.children }) }));
11
- }
12
- function SwitchModal(props) {
13
- return (_jsx(SwitchModalDesign, { ...props, children: _jsxs(_Fragment, { children: [_jsx(Select.Switch, { ...props.switch }), props.children] }) }));
14
- }
15
- export default SwitchModal;