@edu-tosel/design 1.0.73 → 1.0.75
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/design/TableCard.design.d.ts +1 -1
- package/card/design/TableCard.design.js +1 -1
- package/card/template/TableCard.d.ts +2 -2
- package/interface/Action.d.ts +5 -5
- package/interface/Card.d.ts +2 -2
- package/interface/Data.d.ts +2 -3
- package/layout/design/Row.design/SelectRoll.d.ts +3 -4
- package/layout/design/Row.design/SelectRoll.js +6 -15
- package/layout/design/Row.design/index.d.ts +1 -1
- package/layout/design/Row.design/index.js +9 -6
- package/layout/template/Row.d.ts +3 -3
- package/layout/template/Row.js +2 -2
- package/package.json +1 -1
- package/store/index.d.ts +5 -2
- package/store/index.js +5 -0
- package/version.txt +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TableCardProps } from "../../interface";
|
|
2
|
-
export default function TableCardDesign<T
|
|
2
|
+
export default function TableCardDesign<T>({ dataSet, dataField, option, }: TableCardProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,7 +21,7 @@ export default function TableCardDesign({ dataSet, dataField, option, }) {
|
|
|
21
21
|
height: height ?? "3xl",
|
|
22
22
|
overflow: "overflow-y-scroll overflow-x-hidden",
|
|
23
23
|
noPadding: true,
|
|
24
|
-
}, children: _jsxs(Action.Replace, { actions: dataSet?.replaces, children: [sortByOrder({ items: dataSet?.items, orders }).map((item, index) => dataSet.renderItem ? (dataSet.renderItem(item)) : (_jsx(Row.Card, { item: item,
|
|
24
|
+
}, children: _jsxs(Action.Replace, { actions: dataSet?.replaces, children: [sortByOrder({ items: dataSet?.items, orders }).map((item, index) => dataSet.renderItem ? (dataSet.renderItem(item)) : (_jsx(Row.Card, { item: item, onClick: () => dataSet.onClick?.(item), dataField: dataField, height: option?.rowHeight, noHover: option?.noHover, noPadding: option?.noRowPadding }, id + index))), _jsx(Obstacle, { disabled: isDisabled }), _jsx(Obstacle.Blur, { disabled: isDisabled, option: {
|
|
25
25
|
position: "top-10",
|
|
26
26
|
}, children: _jsx(Lock, { script: disabledScript }) })] }) }));
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableCardProps } from "../../interface";
|
|
2
|
-
declare function TableCard<T
|
|
2
|
+
declare function TableCard<T>(props: TableCardProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
declare namespace TableCard {
|
|
4
|
-
var Log: <T
|
|
4
|
+
var Log: <T>(props: TableCardProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
}
|
|
6
6
|
export default TableCard;
|
package/interface/Action.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LabelWidget } from "./widget";
|
|
2
|
-
import { OnClick, Size
|
|
2
|
+
import { OnClick, Size } from "./Property";
|
|
3
3
|
import { DataField, DataFieldType } from "./Data";
|
|
4
4
|
import { Color } from "./Color";
|
|
5
5
|
export interface ActionEvent {
|
|
@@ -29,9 +29,9 @@ export interface DataFieldProps<T> {
|
|
|
29
29
|
padding?: string;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export interface RowProps<T
|
|
32
|
+
export interface RowProps<T> {
|
|
33
33
|
item: T;
|
|
34
|
-
|
|
34
|
+
stateAction?: (item: T) => void;
|
|
35
35
|
dataField?: DataField<T>;
|
|
36
36
|
onClick?: OnClick<T>;
|
|
37
37
|
buttons?: LabelWidget[];
|
|
@@ -46,10 +46,10 @@ export interface RowProps<T, S> {
|
|
|
46
46
|
className?: string;
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
export interface RowElementProps<T
|
|
49
|
+
export interface RowElementProps<T> {
|
|
50
50
|
item: T;
|
|
51
51
|
entry: [string, unknown];
|
|
52
|
-
|
|
52
|
+
stateAction?: (item: T) => void;
|
|
53
53
|
data?: DataFieldType;
|
|
54
54
|
}
|
|
55
55
|
export {};
|
package/interface/Card.d.ts
CHANGED
|
@@ -116,8 +116,8 @@ export interface AddCardProps extends Omit<CardProps, "children"> {
|
|
|
116
116
|
icon?: string;
|
|
117
117
|
onClick: OnClick;
|
|
118
118
|
}
|
|
119
|
-
export interface TableCardProps<T
|
|
120
|
-
dataSet: Flexify<DataSet<T
|
|
119
|
+
export interface TableCardProps<T> extends Omit<CardProps, "children"> {
|
|
120
|
+
dataSet: Flexify<DataSet<T>, "renderItem">;
|
|
121
121
|
dataField?: DataField<T>;
|
|
122
122
|
option?: CardOption & {
|
|
123
123
|
className?: string;
|
package/interface/Data.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Replace } from "./Action";
|
|
2
|
-
import { OnClick,
|
|
2
|
+
import { OnClick, Titles } from "./Property";
|
|
3
3
|
export interface DataPackage<T> {
|
|
4
4
|
dataField: DataField<T>;
|
|
5
5
|
dataSet: Omit<DataSet<T>, "renderItem">;
|
|
6
6
|
}
|
|
7
|
-
export type DataSet<T = any
|
|
7
|
+
export type DataSet<T = any> = {
|
|
8
8
|
items?: T[];
|
|
9
|
-
state?: State<S[] | undefined>;
|
|
10
9
|
renderItem: (item: T, index?: number) => React.ReactNode;
|
|
11
10
|
titles?: Titles;
|
|
12
11
|
interaction?: React.ReactNode;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { DataSelectRoll
|
|
2
|
-
interface SelectRollProps<T
|
|
1
|
+
import { DataSelectRoll } from "../../../interface";
|
|
2
|
+
interface SelectRollProps<T> {
|
|
3
3
|
item: T;
|
|
4
4
|
entry: [string, unknown];
|
|
5
|
-
state: State<S[] | undefined>;
|
|
6
5
|
data: DataSelectRoll;
|
|
7
6
|
}
|
|
8
|
-
export default function SelectRoll<T
|
|
7
|
+
export default function SelectRoll<T>({ item, entry, data, }: SelectRollProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import { cn } from "../../../util";
|
|
4
|
-
|
|
4
|
+
import { useActionStore } from "../../../store";
|
|
5
|
+
export default function SelectRoll({ item, entry, data, }) {
|
|
6
|
+
const { updateItem } = useActionStore();
|
|
5
7
|
const { options } = data ?? {};
|
|
6
8
|
const [key, value] = entry;
|
|
7
|
-
const [rows, setRows] = state ?? [];
|
|
8
9
|
const [isHover, setIsHover] = useState(false);
|
|
9
10
|
const keys = options?.map((option) => option.key);
|
|
10
11
|
const values = options?.map((option) => option.value);
|
|
@@ -31,25 +32,15 @@ export default function SelectRoll({ item, entry, state, data, }) {
|
|
|
31
32
|
sizes: "w-[20px] h-full",
|
|
32
33
|
styles: "duration-300 text-gray-dark",
|
|
33
34
|
};
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setRows(rows?.map((row) => {
|
|
36
|
-
if (row === item) {
|
|
37
|
-
const temp = { ...row, [key]: keys[index] };
|
|
38
|
-
return temp;
|
|
39
|
-
}
|
|
40
|
-
console.log("not changed");
|
|
41
|
-
console.log("row", row);
|
|
42
|
-
console.log("item", item);
|
|
43
|
-
return row;
|
|
44
|
-
}));
|
|
45
|
-
}, [index, setIndex]);
|
|
46
35
|
return (_jsx("div", { className: cn(container), children: _jsxs("div", { className: cn(body), onMouseLeave: () => setIsHover(false), onMouseEnter: () => setIsHover(true), children: [values[index], _jsx("button", { onClick: () => {
|
|
47
36
|
if (index > 0) {
|
|
48
37
|
setIndex(index - 1);
|
|
38
|
+
updateItem({ ...item, [key]: keys[index - 1] });
|
|
49
39
|
}
|
|
50
40
|
}, className: cn(toggle, "-left-4 group-hover:left-1"), children: "-" }), _jsx("button", { onClick: () => {
|
|
51
41
|
if (index < keys.length - 1) {
|
|
52
42
|
setIndex(index + 1);
|
|
43
|
+
updateItem({ ...item, [key]: keys[index + 1] });
|
|
53
44
|
}
|
|
54
45
|
}, className: cn(toggle, "-right-4 group-hover:right-1"), children: "+" })] }) }));
|
|
55
46
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RowProps } from "../../../interface";
|
|
2
|
-
export default function RowDesign<T
|
|
2
|
+
export default function RowDesign<T>({ item, stateAction, dataField, option, onClick, buttons, dot, }: RowProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,9 +5,9 @@ import { cn } from "../../../util";
|
|
|
5
5
|
import { Label } from "../../../widget";
|
|
6
6
|
import { widthSizes } from "../../../asset/sizes";
|
|
7
7
|
import SelectRoll from "./SelectRoll";
|
|
8
|
-
export default function RowDesign({ item,
|
|
8
|
+
export default function RowDesign({ item, stateAction, dataField, option, onClick, buttons, dot, }) {
|
|
9
9
|
const { size, padding, text, noHover, className, isPointer } = option ?? {};
|
|
10
|
-
const
|
|
10
|
+
const rowId = useId();
|
|
11
11
|
const container = {
|
|
12
12
|
positions: "relative",
|
|
13
13
|
displays: "flex items-center ",
|
|
@@ -28,18 +28,21 @@ export default function RowDesign({ item, state, dataField, option, onClick, but
|
|
|
28
28
|
styles: "rounded-full",
|
|
29
29
|
};
|
|
30
30
|
return (_jsxs("div", { className: cn(container), onClick: () => onClick?.(), children: [typeof dot !== "undefined" && _jsx("div", { className: cn(flagBox) }), dataField &&
|
|
31
|
-
Object.entries(dataField).map(([key, value]) =>
|
|
31
|
+
Object.entries(dataField).map(([key, value]) => {
|
|
32
|
+
const id = useId();
|
|
33
|
+
return (_jsx("div", { className: cn(widthSizes[dataField[key]?.size], itemBox), children: _jsx(RowElement, { stateAction: stateAction, entry: [key, value], item: item, data: dataField[key]?.data }) }, id));
|
|
34
|
+
}), _jsx("div", { className: "absolute right-4 xl:right-8 flex gap-4", children: buttons?.map(({ title, onClick, option }) => (_jsx(Label.Button, { title: title, onClick: onClick, option: {
|
|
32
35
|
background: option?.background ?? "bg-crimson-dark",
|
|
33
36
|
text: option?.text ?? "text-white",
|
|
34
37
|
width: "xs",
|
|
35
38
|
height: "xs",
|
|
36
|
-
} },
|
|
39
|
+
} }, rowId + title))) })] }));
|
|
37
40
|
}
|
|
38
41
|
function RowElement(props) {
|
|
39
42
|
const { item, data } = props;
|
|
40
43
|
const [key, value] = props.entry;
|
|
41
|
-
if (isDataSelectRoll(data)
|
|
42
|
-
return
|
|
44
|
+
if (isDataSelectRoll(data)) {
|
|
45
|
+
return _jsx(SelectRoll, { item: item, entry: props.entry, data: data });
|
|
43
46
|
}
|
|
44
47
|
if (isDataButton(data))
|
|
45
48
|
return (_jsx(Label.Button, { title: item[key], hoverTitle: data.hoverTitle, onClick: data.onClick, option: { ...data.option, width: "xs", height: "xs" } }));
|
package/layout/template/Row.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RowProps } from "../../interface";
|
|
2
|
-
declare function Row<T
|
|
2
|
+
declare function Row<T>({ item, dataField, onClick, buttons, dot }: RowProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
declare namespace Row {
|
|
4
|
-
var Card: <T
|
|
4
|
+
var Card: <T>({ item, dataField, stateAction, onClick, buttons, height, noPadding, noHover, dot, }: Omit<RowProps<T>, "option"> & {
|
|
5
5
|
height?: string | undefined;
|
|
6
6
|
noPadding?: boolean | undefined;
|
|
7
7
|
noHover?: boolean | undefined;
|
|
8
8
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
var Board: <T
|
|
9
|
+
var Board: <T>({ item, dataField, onClick, buttons, dot, option, }: RowProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
}
|
|
11
11
|
export default Row;
|
package/layout/template/Row.js
CHANGED
|
@@ -18,9 +18,9 @@ function Board({ item, dataField, onClick, buttons, dot, option, }) {
|
|
|
18
18
|
text: "text-xl",
|
|
19
19
|
} }, id));
|
|
20
20
|
}
|
|
21
|
-
function Card({ item, dataField,
|
|
21
|
+
function Card({ item, dataField, stateAction, onClick, buttons, height, noPadding, noHover, dot, }) {
|
|
22
22
|
const id = useId();
|
|
23
|
-
return (_jsx(RowDesign, { onClick: onClick, item: item,
|
|
23
|
+
return (_jsx(RowDesign, { onClick: onClick, item: item, stateAction: stateAction, dataField: dataField, buttons: buttons, dot: dot, option: {
|
|
24
24
|
size: `w-full ${height ?? "h-15"}`,
|
|
25
25
|
padding: !noPadding ? "px-2 xs:px-4 xl:px-5" : "",
|
|
26
26
|
text: "text-base",
|
package/package.json
CHANGED
package/store/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Order, ActionEvent } from "../interface";
|
|
2
|
-
interface ActionProps {
|
|
2
|
+
interface ActionProps<T = any> {
|
|
3
3
|
events: ActionEvent[];
|
|
4
4
|
setView: (prop: string) => void;
|
|
5
5
|
removeView: (prop: string) => void;
|
|
@@ -21,6 +21,9 @@ interface ActionProps {
|
|
|
21
21
|
isDark: boolean;
|
|
22
22
|
dark: () => void;
|
|
23
23
|
setDark: () => void;
|
|
24
|
+
items: T[];
|
|
25
|
+
setItems: (prop: T[]) => void;
|
|
26
|
+
updateItem: (prop: T) => void;
|
|
24
27
|
}
|
|
25
|
-
export declare const useActionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ActionProps
|
|
28
|
+
export declare const useActionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ActionProps<any>>>;
|
|
26
29
|
export {};
|
package/store/index.js
CHANGED
|
@@ -67,4 +67,9 @@ export const useActionStore = create((set) => ({
|
|
|
67
67
|
isDark: false,
|
|
68
68
|
dark: () => set(() => ({ isDark: true })),
|
|
69
69
|
setDark: () => set((state) => ({ isDark: !state.isDark })),
|
|
70
|
+
items: [],
|
|
71
|
+
setItems: (prop) => set({ items: prop }),
|
|
72
|
+
updateItem: (item) => set((state) => ({
|
|
73
|
+
items: state.items.map((prevItem) => prevItem.id === item.id ? item : prevItem),
|
|
74
|
+
})),
|
|
70
75
|
}));
|
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.75
|