@edu-tosel/design 1.0.3 → 1.0.5
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/board/template/ManageBoard.d.ts +1 -1
- package/board/template/ManageBoard.js +14 -13
- package/board/widget/Board.d.ts +1 -1
- package/board/widget/Board.js +8 -21
- package/board/widget/Tab.d.ts +4 -0
- package/board/widget/Tab.js +17 -0
- package/card/index.d.ts +5 -5
- package/card/index.js +5 -5
- package/card/template/ChartCard.d.ts +1 -1
- package/card/template/ChartCard.js +1 -1
- package/card/template/ProfileCard.d.ts +1 -1
- package/card/template/ProfileCard.js +1 -1
- package/card/template/TableCard.d.ts +1 -1
- package/card/template/TableCard.js +1 -1
- package/card/template/TrumpCard.d.ts +1 -1
- package/card/template/TrumpCard.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/interaction/Exception.d.ts +2 -0
- package/interaction/Exception.js +9 -0
- package/interaction/LoadingSpinner.d.ts +1 -0
- package/interaction/LoadingSpinner.js +5 -0
- package/interaction/NoData.d.ts +1 -0
- package/interaction/NoData.js +4 -0
- package/interaction/index.d.ts +2 -0
- package/interaction/index.js +2 -0
- package/interface/Board.d.ts +18 -10
- package/interface/Interaction.d.ts +5 -0
- package/interface/Interaction.js +1 -0
- package/package.json +4 -2
- package/tailwind.config.ts +10 -0
- package/version.txt +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ManageBoardProps } from "../../interface/Board";
|
|
2
2
|
type Item = Record<string, any>;
|
|
3
|
-
export default function ManageBoard<T extends Item>({ header, data,
|
|
3
|
+
export default function ManageBoard<T extends Item>({ header, data, widgets, }: ManageBoardProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export {};
|
|
@@ -6,22 +6,23 @@ import { Board } from "../widget/Board";
|
|
|
6
6
|
import BoardHeader from "../widget/Header";
|
|
7
7
|
import BoardDataField from "../widget/DataField";
|
|
8
8
|
import { useWidgetStore } from "../../store";
|
|
9
|
-
|
|
9
|
+
import { Exception } from "../../interaction";
|
|
10
|
+
export default function ManageBoard({ header, data, widgets, }) {
|
|
10
11
|
const { order: [orderBy, orderHow], } = useWidgetStore();
|
|
11
12
|
const { dataSets, dataField, gap } = data;
|
|
12
13
|
const positions = `flex flex-col gap-${gap ?? 0}`;
|
|
13
14
|
const sizes = `h-full ${dataField ? "xl:h-135" : "xl:h-158"}`;
|
|
14
|
-
const paddings = "pb-60 xl:pb-0 px-2 xs:px-4 xl:
|
|
15
|
+
const paddings = "pb-60 xl:pb-0 px-2 xs:px-4 xl:px-8";
|
|
15
16
|
const styles = "overflow-y-scroll";
|
|
16
|
-
return (_jsxs(Board, {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
return (_jsxs(Board, { widgets: widgets, children: [_jsx(BoardHeader, { ...header }), dataField && _jsx(BoardDataField, { dataField: dataField }), _jsx("div", { className: cn(positions, sizes, paddings, styles), children: _jsx(Exception, { exceptions: widgets?.exceptions, children: dataSets.map(({ title: deckTitle, items, renderItem }) => deckTitle ? (_jsx("div", { className: "pt-4", children: _jsx(Deck, { titles: { title: deckTitle ?? "" }, children: items?.map((item) => renderItem(item)) }) }, deckTitle)) : (items
|
|
18
|
+
?.slice()
|
|
19
|
+
.sort((a, b) => {
|
|
20
|
+
if (orderBy) {
|
|
21
|
+
if (orderHow === "asc")
|
|
22
|
+
return a[orderBy] > b[orderBy] ? 1 : -1;
|
|
23
|
+
return a[orderBy] < b[orderBy] ? 1 : -1;
|
|
24
|
+
}
|
|
25
|
+
return 0;
|
|
26
|
+
})
|
|
27
|
+
.map((item) => renderItem(item)))) }) }), widgets?.menu && _jsx(SideMenu, {})] }));
|
|
27
28
|
}
|
package/board/widget/Board.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BoardProps } from "../../interface/Board";
|
|
2
|
-
export declare function Board({ children,
|
|
2
|
+
export declare function Board({ children, widgets }: BoardProps): import("react/jsx-runtime").JSX.Element;
|
package/board/widget/Board.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useWidgetStore } from "../../store";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export function Board({ children, options }) {
|
|
3
|
+
import Tab from "./Tab";
|
|
4
|
+
export function Board({ children, widgets }) {
|
|
6
5
|
const { events } = useWidgetStore();
|
|
7
|
-
const {
|
|
6
|
+
const { components, tabs } = widgets ?? {};
|
|
8
7
|
const classNames = [
|
|
9
8
|
`h-full xl:min-h-0 `,
|
|
10
9
|
"xl:rounded-xl bg-white relative w-full z-10 overflow-hidden",
|
|
11
10
|
].join(" ");
|
|
12
|
-
return (_jsxs("div", { className: "h-full xl:min-h-0 xl:h-178 w-full relative ", children: [_jsxs("div", { className: classNames, children: [children,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const [tabsSelection, setTabsSelection] = useState(tabs.map((_, i) => i === 0));
|
|
18
|
-
const positions = "xl:absolute xl:-bottom-14 xl:left-0 z-5";
|
|
19
|
-
const displays = "hidden xl:flex xl:items-end xl:gap-4";
|
|
20
|
-
const sizes = "xl:h-16";
|
|
21
|
-
const paddings = "xl:px-8 xl:pb-2 ";
|
|
22
|
-
const styles = "bg-white/50 rounded-b-xl ";
|
|
23
|
-
return (_jsx("div", { className: cn(displays, positions, sizes, paddings, styles), children: tabs.map(([title, onClick], index) => (_jsx("button", { onClick: () => {
|
|
24
|
-
setTabsSelection(tabsSelection.map((_, i) => i === index));
|
|
25
|
-
return onClick();
|
|
26
|
-
}, className: `h-9 w-32 rounded-md ${tabsSelection[index]
|
|
27
|
-
? "border-4 border-blue-500"
|
|
28
|
-
: "border-4 border-red-500"}`, children: title }, title))) }));
|
|
11
|
+
return (_jsxs("div", { className: "h-full xl:min-h-0 xl:h-178 w-full relative ", children: [_jsxs("div", { className: classNames, children: [children, components?.map(([flag, Component]) => {
|
|
12
|
+
if (typeof flag === "boolean")
|
|
13
|
+
return flag ? _jsx(_Fragment, { children: Component }) : null;
|
|
14
|
+
return events?.some(({ event }) => event === flag) ? (_jsx(_Fragment, { children: Component })) : null;
|
|
15
|
+
})] }), tabs && _jsx(Tab, { tabs: tabs })] }));
|
|
29
16
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { cn } from "../../util";
|
|
4
|
+
export default function Tab({ tabs }) {
|
|
5
|
+
const [tabsSelection, setTabsSelection] = useState(tabs.map((_, i) => i === 0));
|
|
6
|
+
const positions = "xl:absolute xl:-bottom-14 xl:left-0 z-5";
|
|
7
|
+
const displays = "hidden xl:flex xl:items-end xl:gap-4";
|
|
8
|
+
const sizes = "xl:h-16";
|
|
9
|
+
const paddings = "xl:px-8 xl:pb-2 ";
|
|
10
|
+
const styles = "bg-white/50 rounded-b-xl ";
|
|
11
|
+
return (_jsx("div", { className: cn(displays, positions, sizes, paddings, styles), children: tabs.map(([title, onClick], index) => (_jsx("button", { onClick: () => {
|
|
12
|
+
setTabsSelection(tabsSelection.map((_, i) => i === index));
|
|
13
|
+
return onClick();
|
|
14
|
+
}, className: `h-9 w-32 rounded-md ${tabsSelection[index]
|
|
15
|
+
? "border-4 border-blue-500"
|
|
16
|
+
: "border-4 border-red-500"}`, children: title }, title))) }));
|
|
17
|
+
}
|
package/card/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { default as ProfileCard } from "./template/ProfileCard";
|
|
2
|
+
export { default as TrumpCard } from "./template/TrumpCard";
|
|
3
|
+
export { default as ChartCard } from "./template/ChartCard";
|
|
4
|
+
export { default as TableCard } from "./template/TableCard";
|
|
5
|
+
export { default as RowCard } from "./template/RowCard";
|
package/card/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { default as ProfileCard } from "./template/ProfileCard";
|
|
2
|
+
export { default as TrumpCard } from "./template/TrumpCard";
|
|
3
|
+
export { default as ChartCard } from "./template/ChartCard";
|
|
4
|
+
export { default as TableCard } from "./template/TableCard";
|
|
5
|
+
export { default as RowCard } from "./template/RowCard";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChartCardProps } from "../../interface/Card";
|
|
2
|
-
export
|
|
2
|
+
export default function ChartCard({ data, xAxis, yAxis, lines, bars, areas, }: ChartCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Area, Bar, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts";
|
|
3
3
|
import { Card } from "../widget/Card";
|
|
4
|
-
export function ChartCard({ data, xAxis, yAxis, lines, bars, areas, }) {
|
|
4
|
+
export default function ChartCard({ data, xAxis, yAxis, lines, bars, areas, }) {
|
|
5
5
|
return (_jsx(Card, { options: { width: "xl", height: "lg", text: { size: "xs" } }, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: data, children: [_jsx(XAxis, { dataKey: xAxis }), _jsx(YAxis, { dataKey: yAxis }), _jsx(Tooltip, {}), lines?.map((line) => (_jsx(Line, { ...line }, line.dataKey))), bars?.map((bar) => (_jsx(Bar, { ...bar }, bar.dataKey))), areas?.map((area) => (_jsx(Area, { ...area }, area.dataKey)))] }) }) }));
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card } from "../widget/Card";
|
|
3
3
|
import { colorsByLevel } from "../../util";
|
|
4
|
-
export function ProfileCard({ info, gradeData, }) {
|
|
4
|
+
export default function ProfileCard({ info, gradeData, }) {
|
|
5
5
|
const { name, birthday, image } = info;
|
|
6
6
|
const { level, score, grade } = gradeData ?? {};
|
|
7
7
|
return (_jsx(Card, { options: { width: "sm" }, children: _jsxs("div", { className: "flex", children: [_jsx("img", { src: image, alt: "profile", className: "h-20 w-20 overflow-hidden rounded-full object-cover " }), _jsxs("div", { className: "ml-auto flex flex-col gap-4", children: [_jsxs("div", { className: "flex w-52 items-end gap-2 border-b-2 border-blue-navy pb-2", children: [_jsx("div", { className: "text-xl font-bold", children: name }), _jsx("div", { children: birthday })] }), _jsxs("div", { children: [_jsx("div", { children: "\uD559\uC6D0\uC0DD" }), _jsx("div", { children: level ? colorsByLevel[level] : "" })] })] })] }) }));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TableCardProps } from "../../interface/Card";
|
|
2
|
-
export
|
|
2
|
+
export default function TableCard({ data, fields, sizes, options, }: TableCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card } from "../widget/Card";
|
|
3
|
-
export function TableCard({ data, fields, sizes, options }) {
|
|
3
|
+
export default function TableCard({ data, fields, sizes, options, }) {
|
|
4
4
|
const { color } = options ?? {};
|
|
5
5
|
const { background: bgColor, text: textColor } = color ?? {};
|
|
6
6
|
const keys = Object.keys(fields);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TrumpCardProps } from "../../interface/Card";
|
|
2
|
-
export
|
|
2
|
+
export default function TrumpCard({ titles, options }: TrumpCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { LineBreaks } from "../../text";
|
|
3
3
|
import { Card } from "../widget/Card";
|
|
4
|
-
export function TrumpCard({ titles, options }) {
|
|
4
|
+
export default function TrumpCard({ titles, options }) {
|
|
5
5
|
const { title, subTitle, color: titleColor } = titles;
|
|
6
6
|
const { onClick, width, image, subButton } = options ?? {};
|
|
7
7
|
const [buttonText, buttonBgColor, buttonAction] = subButton ?? [
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export default function Exception({ exceptions, children }) {
|
|
3
|
+
if (!exceptions)
|
|
4
|
+
return _jsx(_Fragment, { children: children });
|
|
5
|
+
const trueComponents = exceptions
|
|
6
|
+
.filter(([exception]) => exception)
|
|
7
|
+
.map(([, component]) => component);
|
|
8
|
+
return _jsx(_Fragment, { children: trueComponents.length > 0 ? trueComponents : children });
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LoadingSpinner(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// NOTE: This is Prototype code and should be replaced with a proper loading spinner
|
|
3
|
+
export default function LoadingSpinner() {
|
|
4
|
+
return (_jsx("div", { className: "w-full h-full flex items-center justify-center", children: _jsx("div", { className: "h-16 w-16 animate-spin rounded-full border-6 border-black border-r-transparent flex justify-center items-center", children: _jsx("div", { className: "h-12 w-12 animate-spin rounded-full border-6 border-red-500 border-r-transparent " }) }) }));
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function NoData(): import("react/jsx-runtime").JSX.Element;
|
package/interface/Board.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
2
|
import { Button, Size } from "./Property";
|
|
3
|
+
interface OptionsProps {
|
|
4
|
+
color?: string;
|
|
5
|
+
}
|
|
6
|
+
interface WidgetsProps {
|
|
7
|
+
exceptions?: [boolean, React.ReactNode][];
|
|
8
|
+
components?: [boolean | string, React.ReactNode][];
|
|
9
|
+
tabs?: Button[];
|
|
10
|
+
}
|
|
11
|
+
export interface BoardProps {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
widgets?: WidgetsProps;
|
|
14
|
+
options?: OptionsProps;
|
|
15
|
+
}
|
|
3
16
|
export interface BoardHeaderProps {
|
|
4
17
|
title?: string;
|
|
5
18
|
tags?: {
|
|
@@ -23,19 +36,11 @@ export interface BoardHeaderProps {
|
|
|
23
36
|
};
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
|
-
export interface BoardProps {
|
|
27
|
-
children?: React.ReactNode;
|
|
28
|
-
options?: {
|
|
29
|
-
widgets?: [string, React.ReactNode][];
|
|
30
|
-
tabs?: Button[];
|
|
31
|
-
color?: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
39
|
export interface ManageBoardProps<T> extends BoardProps {
|
|
35
40
|
data: {
|
|
36
41
|
dataSets: {
|
|
37
42
|
title?: string;
|
|
38
|
-
items: T[];
|
|
43
|
+
items: T[] | undefined;
|
|
39
44
|
renderItem: (items: T) => React.ReactNode;
|
|
40
45
|
}[];
|
|
41
46
|
dataField?: {
|
|
@@ -45,5 +50,8 @@ export interface ManageBoardProps<T> extends BoardProps {
|
|
|
45
50
|
gap?: number;
|
|
46
51
|
};
|
|
47
52
|
header?: BoardHeaderProps;
|
|
48
|
-
|
|
53
|
+
widgets?: {
|
|
54
|
+
menu?: React.ReactNode;
|
|
55
|
+
} & WidgetsProps;
|
|
49
56
|
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edu-tosel/design",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "UI components for International TOSEL Committee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsx",
|
|
7
|
+
"tsx",
|
|
7
8
|
"tailwindcss",
|
|
8
|
-
"ui"
|
|
9
|
+
"ui",
|
|
10
|
+
"design system"
|
|
9
11
|
],
|
|
10
12
|
"author": "International TOSEL Committee",
|
|
11
13
|
"license": "MIT",
|
package/tailwind.config.ts
CHANGED
|
@@ -214,6 +214,16 @@ export default {
|
|
|
214
214
|
60000: "60000ms",
|
|
215
215
|
300000: "300000ms",
|
|
216
216
|
},
|
|
217
|
+
borderWidth: {
|
|
218
|
+
1: "1px",
|
|
219
|
+
2: "2px",
|
|
220
|
+
3: "3px",
|
|
221
|
+
4: "4px",
|
|
222
|
+
5: "5px",
|
|
223
|
+
6: "6px",
|
|
224
|
+
7: "7px",
|
|
225
|
+
8: "8px",
|
|
226
|
+
},
|
|
217
227
|
opacity: {
|
|
218
228
|
32: ".32",
|
|
219
229
|
},
|
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.5
|