@edu-tosel/design 1.0.29 → 1.0.31

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,2 +1,2 @@
1
1
  import { CanvasBoardProps } from "../../interface/Board";
2
- export default function CanvasBoard({ header, children, options, widgets, buttons, }: CanvasBoardProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function CanvasBoard<B>({ header, children, options, widgets, buttons, }: CanvasBoardProps<B>): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import { ManageBoardProps } from "../../interface/Board";
2
- export default function ManageBoard<K extends string, T extends {
2
+ export default function ManageBoard<B, K extends string, T extends {
3
3
  [p in K]: any;
4
- }>({ header, dataSets, dataField, widgets, options, buttons, }: ManageBoardProps<T>): import("react/jsx-runtime").JSX.Element;
4
+ }>({ header, dataSets, dataField, widgets, options, buttons, }: ManageBoardProps<B, K, T>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { PaperBoardProps } from "../../interface/Board";
2
- export default function PaperBoard({ children, debug, options, }: PaperBoardProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function PaperBoard<B>({ children, debug, options, }: PaperBoardProps<B>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { BoardProps } from "../../interface/Board";
2
- export declare function Board({ children, widgets, options, debug, buttons, }: BoardProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Board<B>({ children, widgets, options, debug, buttons, }: BoardProps<B>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { BoardHeaderProps } from "./../../interface/Board";
2
- export default function BoardHeader({ titles, tag, options, }: BoardHeaderProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function BoardHeader<B>({ titles, tag, options, }: BoardHeaderProps<B>): import("react/jsx-runtime").JSX.Element;
@@ -10,7 +10,7 @@ export default function BoardHeader({ titles, tag, options, }) {
10
10
  textColor: "black",
11
11
  };
12
12
  const container = {
13
- positions: "fixed top-15 xl:top-0 left-0 z-20 xl:relative flex items-center",
13
+ positions: "fixed top-15 xl:top-0 left-0 z-30 xl:relative flex items-center",
14
14
  paddings: "px-7.5",
15
15
  styles: `${bgColor} ${textColor}`,
16
16
  sizes: "w-full h-19",
package/hook/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as useEase } from "./useEase";
2
2
  export { default as useEvents } from "./useEvents";
3
+ export { default as useFlag } from "./useFlag";
package/hook/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as useEase } from "./useEase";
2
2
  export { default as useEvents } from "./useEvents";
3
+ export { default as useFlag } from "./useFlag";
@@ -0,0 +1,2 @@
1
+ import { State } from "../interface";
2
+ export default function useFlag<T>(state: State<T>): void;
@@ -0,0 +1,12 @@
1
+ import { useEffect } from "react";
2
+ import { useWidgetStore } from "../store";
3
+ export default function useFlag(state) {
4
+ const [value, action] = state;
5
+ const { flag, isOwn, setIsOwn } = useWidgetStore();
6
+ useEffect(() => {
7
+ if (isOwn) {
8
+ return setIsOwn(false);
9
+ }
10
+ return action(value);
11
+ }, [flag]);
12
+ }
@@ -1,3 +1,3 @@
1
1
  import { HTMLSelectElement } from "../../interface";
2
- declare function Select<T extends string>(props: HTMLSelectElement<T>): import("react/jsx-runtime").JSX.Element;
2
+ declare function Select<T>(props: HTMLSelectElement<T>): import("react/jsx-runtime").JSX.Element;
3
3
  export default Select;
@@ -1,2 +1,2 @@
1
1
  import { HTMLSelectElement } from "../../interface";
2
- export default function SelectDesign<T extends string>({ state, selectOptions, placeholder, options, }: HTMLSelectElement<T>): import("react/jsx-runtime").JSX.Element;
2
+ export default function SelectDesign<T>({ state, selectOptions, placeholder, options, }: HTMLSelectElement<T>): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useState } from "react";
3
- import { cn } from "../../util";
3
+ import { cn, useFlag } from "../../util";
4
4
  import { useTransition, animated } from "react-spring";
5
+ import { useWidgetStore } from "../../store";
5
6
  const widthSize = {
6
7
  xs: "w-10",
7
8
  sm: "w-22.5",
@@ -13,12 +14,14 @@ const heightSize = {
13
14
  };
14
15
  export default function SelectDesign({ state, selectOptions, placeholder, options, }) {
15
16
  const id = useId();
17
+ const { setIsOwn } = useWidgetStore();
16
18
  const [value, setValue] = state;
17
19
  const [text, setText] = useState("");
18
20
  const [search, setSearch] = useState("");
19
21
  const [isOpen, setIsOpen] = useState(false);
20
22
  const [filteredOptions, setFilterdOptions] = useState([]);
21
23
  const [index, setIndex] = useState();
24
+ useFlag([false, setIsOpen]);
22
25
  const onKeyDown = (e) => {
23
26
  if (!filteredOptions)
24
27
  return;
@@ -97,7 +100,7 @@ export default function SelectDesign({ state, selectOptions, placeholder, option
97
100
  config: { duration: 0 },
98
101
  },
99
102
  });
100
- return (_jsxs("div", { className: cn(container), onKeyDown: onKeyDown, children: [_jsx("button", { onClick: () => setIsOpen(!isOpen), className: cn(button), 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 &&
103
+ return (_jsxs("div", { className: cn(container), onKeyDown: onKeyDown, onClick: () => setIsOwn(true), children: [_jsx("button", { onClick: () => setIsOpen(!isOpen), className: cn(button), 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 &&
101
104
  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) => {
102
105
  return (item && (_jsx(animated.div, { style: styles, className: cn(body), children: filteredOptions?.map(([value, text], order) => (_jsx("section", { children: _jsx("button", { onClick: () => {
103
106
  setValue(value);
@@ -9,20 +9,20 @@ interface OptionsProps {
9
9
  isRounded?: boolean;
10
10
  noPadding?: boolean;
11
11
  }
12
- export interface BoardProps {
13
- header?: BoardHeaderProps;
12
+ export interface BoardProps<B> {
13
+ header?: BoardHeaderProps<B>;
14
14
  children?: React.ReactNode;
15
15
  widgets?: EventsProps;
16
16
  options?: OptionsProps;
17
17
  debug?: string;
18
18
  buttons?: HTMLLabelElement[];
19
19
  }
20
- export interface BoardHeaderProps {
20
+ export interface BoardHeaderProps<B> {
21
21
  titles?: Omit<Titles, "subtitle"> & {
22
22
  icon?: string;
23
23
  };
24
24
  tag?: {
25
- selects?: HTMLSelectElement<unknown>[];
25
+ selects?: HTMLSelectElement<B>[];
26
26
  inputs?: HTMLInputElement[];
27
27
  };
28
28
  options?: {
@@ -32,9 +32,11 @@ export interface BoardHeaderProps {
32
32
  };
33
33
  };
34
34
  }
35
- export interface CanvasBoardProps extends BoardProps {
35
+ export interface CanvasBoardProps<B> extends BoardProps<B> {
36
36
  }
37
- export interface ManageBoardProps<T> extends BoardProps {
37
+ export interface ManageBoardProps<B, K extends string, T extends {
38
+ [p in K]: any;
39
+ }> extends BoardProps<B> {
38
40
  dataSets: {
39
41
  items: T[] | undefined;
40
42
  renderItem: (item: T) => React.ReactNode;
@@ -45,6 +47,6 @@ export interface ManageBoardProps<T> extends BoardProps {
45
47
  [p in keyof T]?: Partial<DataField>;
46
48
  };
47
49
  }
48
- export interface PaperBoardProps extends BoardProps {
50
+ export interface PaperBoardProps<B> extends BoardProps<B> {
49
51
  }
50
52
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edu-tosel/design",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "UI components for International TOSEL Committee",
5
5
  "keywords": [
6
6
  "jsx",
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.29
1
+ 1.0.31