@edu-tosel/design 1.0.3 → 1.0.4

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,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, subWidget, options, }: ManageBoardProps<T>): import("react/jsx-runtime").JSX.Element;
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
- export default function ManageBoard({ header, data, subWidget, options, }) {
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:pl-8";
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, { options: options, children: [_jsx(BoardHeader, { ...header }), dataField && _jsx(BoardDataField, { dataField: dataField }), _jsx("div", { className: cn(positions, sizes, paddings, styles), 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
17
- .slice()
18
- .sort((a, b) => {
19
- if (orderBy) {
20
- if (orderHow === "asc")
21
- return a[orderBy] > b[orderBy] ? 1 : -1;
22
- return a[orderBy] < b[orderBy] ? 1 : -1;
23
- }
24
- return 0;
25
- })
26
- .map((item) => renderItem(item)))) }), subWidget && _jsx(SideMenu, {})] }));
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
  }
@@ -1,2 +1,2 @@
1
1
  import { BoardProps } from "../../interface/Board";
2
- export declare function Board({ children, options }: BoardProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Board({ children, widgets }: BoardProps): import("react/jsx-runtime").JSX.Element;
@@ -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 { cn } from "../../util";
4
- import { useState } from "react";
5
- export function Board({ children, options }) {
3
+ import Tab from "./Tab";
4
+ export function Board({ children, widgets }) {
6
5
  const { events } = useWidgetStore();
7
- const { widgets, tabs } = options ?? {};
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, widgets?.map(([widgetEvent, Component]) => {
13
- return events?.some(({ event }) => event === widgetEvent) ? (_jsx(_Fragment, { children: Component })) : null;
14
- })] }), tabs && _jsx(BottomTab, { tabs: tabs })] }));
15
- }
16
- function BottomTab({ tabs }) {
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,4 @@
1
+ import { Button } from "../../interface";
2
+ export default function Tab({ tabs }: {
3
+ tabs: Button[];
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -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 * from "./template/ProfileCard";
2
- export * from "./template/TrumpCard";
3
- export * from "./template/ChartCard";
4
- export * from "./template/TableCard";
5
- export * from "./template/RowCard";
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 * from "./template/ProfileCard";
2
- export * from "./template/TrumpCard";
3
- export * from "./template/ChartCard";
4
- export * from "./template/TableCard";
5
- export * from "./template/RowCard";
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 declare function ChartCard({ data, xAxis, yAxis, lines, bars, areas, }: ChartCardProps): import("react/jsx-runtime").JSX.Element;
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,5 +1,5 @@
1
1
  type Level = "PS" | "ST" | "BA" | "JR" | "HJ";
2
- export declare function ProfileCard({ info, gradeData, }: {
2
+ export default function ProfileCard({ info, gradeData, }: {
3
3
  info: {
4
4
  name: string;
5
5
  birthday: string;
@@ -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 declare function TableCard({ data, fields, sizes, options }: TableCardProps): import("react/jsx-runtime").JSX.Element;
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 declare function TrumpCard({ titles, options }: TrumpCardProps): import("react/jsx-runtime").JSX.Element;
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
@@ -3,6 +3,7 @@ export * from "./board";
3
3
  export * from "./card";
4
4
  export * from "./deck";
5
5
  export * from "./layout";
6
+ export * from "./interaction";
6
7
  export * from "./menu";
7
8
  export * from "./modal";
8
9
  export * from "./navigation";
package/index.js CHANGED
@@ -3,6 +3,7 @@ export * from "./board";
3
3
  export * from "./card";
4
4
  export * from "./deck";
5
5
  export * from "./layout";
6
+ export * from "./interaction";
6
7
  export * from "./menu";
7
8
  export * from "./modal";
8
9
  export * from "./navigation";
@@ -0,0 +1,2 @@
1
+ import { ExceptionProps } from "../interface/Interaction";
2
+ export default function Exception({ exceptions, children }: ExceptionProps): import("react/jsx-runtime").JSX.Element;
@@ -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,2 @@
1
+ export { default as Exception } from "./Exception";
2
+ export { default as LoadingSpinner } from "./LoadingSpinner";
@@ -0,0 +1,2 @@
1
+ export { default as Exception } from "./Exception";
2
+ export { default as LoadingSpinner } from "./LoadingSpinner";
@@ -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,14 +36,6 @@ 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: {
@@ -45,5 +50,8 @@ export interface ManageBoardProps<T> extends BoardProps {
45
50
  gap?: number;
46
51
  };
47
52
  header?: BoardHeaderProps;
48
- subWidget?: React.ReactNode;
53
+ widgets?: {
54
+ menu?: React.ReactNode;
55
+ } & WidgetsProps;
49
56
  }
57
+ export {};
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export interface ExceptionProps {
3
+ exceptions?: [boolean, React.ReactNode][];
4
+ children: React.ReactNode;
5
+ }
@@ -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",
3
+ "version": "1.0.4",
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",
@@ -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.3
1
+ 1.0.4