@akanjs/ui 1.0.13 → 1.0.15
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/DraggableList.d.ts +4 -1
- package/cjs/DraggableList.js +16 -11
- package/cjs/Layout/Header.js +10 -13
- package/esm/DraggableList.js +16 -11
- package/esm/Layout/Header.js +11 -14
- package/package.json +1 -1
package/DraggableList.d.ts
CHANGED
|
@@ -17,11 +17,14 @@ interface Cursor {
|
|
|
17
17
|
interface ItemProps {
|
|
18
18
|
value: any;
|
|
19
19
|
children: ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
cursorClassName?: string;
|
|
20
22
|
removable?: boolean;
|
|
23
|
+
removeClassName?: string;
|
|
21
24
|
}
|
|
22
25
|
export declare const DraggableList: {
|
|
23
26
|
<V>({ className, mode, children, onChange, onRemove }: DragListProps<V>): import("react/jsx-runtime").JSX.Element;
|
|
24
27
|
Cursor({ className, children }: Cursor): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
Item: ({ value, children, removable }: ItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
Item: ({ value, children, className, cursorClassName, removable, removeClassName }: ItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
29
|
};
|
|
27
30
|
export {};
|
package/cjs/DraggableList.js
CHANGED
|
@@ -55,7 +55,8 @@ const DragList = ({ className, mode = "vertical", children, onChange, onRemove }
|
|
|
55
55
|
fn(
|
|
56
56
|
order.current,
|
|
57
57
|
new Array(children.length).fill(0),
|
|
58
|
-
new Array(children.length).fill(0)
|
|
58
|
+
new Array(children.length).fill(0),
|
|
59
|
+
children.length
|
|
59
60
|
)
|
|
60
61
|
);
|
|
61
62
|
const bind = (0, import_react.useGesture)({
|
|
@@ -81,10 +82,14 @@ const DragList = ({ className, mode = "vertical", children, onChange, onRemove }
|
|
|
81
82
|
const curRow = (0, import_lodash.default)(centerIdx, 0, children.length - 1);
|
|
82
83
|
const newOrder = (0, import_lodash_move.default)(order.current, originIdx, curRow);
|
|
83
84
|
const newClientHeights = (0, import_lodash_move.default)([...clientLengths.current], originIdx, curRow);
|
|
84
|
-
void api.start(
|
|
85
|
+
void api.start(
|
|
86
|
+
fn(newOrder, clientLengths.current, newClientHeights, children.length, active, originIdx, movement)
|
|
87
|
+
);
|
|
85
88
|
if (!active) {
|
|
86
89
|
const draggedValue = children[originIdx].props.value;
|
|
87
|
-
void api.start(
|
|
90
|
+
void api.start(
|
|
91
|
+
fn(order.current, clientLengths.current, newClientHeights, children.length, active, originIdx, movement, true)
|
|
92
|
+
);
|
|
88
93
|
onChange(
|
|
89
94
|
children.map((_, index) => children[newOrder[index]].props.value),
|
|
90
95
|
draggedValue,
|
|
@@ -93,7 +98,7 @@ const DragList = ({ className, mode = "vertical", children, onChange, onRemove }
|
|
|
93
98
|
}
|
|
94
99
|
}
|
|
95
100
|
});
|
|
96
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_client.clsx)(`flex gap-0`, { "flex-col": mode === "vertical" }, className), children: springs.map(({ zIndex, shadow, movement, scale }, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_client.clsx)(`isolate flex gap-0`, { "flex-col": mode === "vertical" }, className), children: springs.map(({ zIndex, shadow, movement, scale }, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
102
|
import_ui.animated.div,
|
|
98
103
|
{
|
|
99
104
|
ref: (el) => {
|
|
@@ -133,15 +138,15 @@ DragList.Cursor = ({ className, children }) => {
|
|
|
133
138
|
}
|
|
134
139
|
);
|
|
135
140
|
};
|
|
136
|
-
const Item = ({ value, children, removable = false }) => {
|
|
141
|
+
const Item = ({ value, children, className, cursorClassName, removable = false, removeClassName }) => {
|
|
137
142
|
const { onRemove } = useDragList();
|
|
138
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
|
|
139
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DraggableList.Cursor, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_md.MdDragIndicator, { className: "text-xl" }) }),
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("flex w-full items-center gap-2", className), children: [
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DraggableList.Cursor, { className: cursorClassName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_md.MdDragIndicator, { className: "text-xl" }) }),
|
|
140
145
|
children,
|
|
141
146
|
removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
147
|
"button",
|
|
143
148
|
{
|
|
144
|
-
className: "btn btn-xs btn-error btn-square btn-outline",
|
|
149
|
+
className: (0, import_client.clsx)("btn btn-xs btn-error btn-square btn-outline", removeClassName),
|
|
145
150
|
onClick: () => {
|
|
146
151
|
onRemove(value);
|
|
147
152
|
},
|
|
@@ -151,18 +156,18 @@ const Item = ({ value, children, removable = false }) => {
|
|
|
151
156
|
] }) });
|
|
152
157
|
};
|
|
153
158
|
DragList.Item = Item;
|
|
154
|
-
const fn = (order, heights, newHeights, active = false, originalIndex = 0, movement = 0, finished = false) => (index) => {
|
|
159
|
+
const fn = (order, heights, newHeights, total, active = false, originalIndex = 0, movement = 0, finished = false) => (index) => {
|
|
155
160
|
return active && index === originalIndex ? {
|
|
156
161
|
movement,
|
|
157
162
|
scale: 1.01,
|
|
158
|
-
zIndex: 1,
|
|
163
|
+
zIndex: total + 1,
|
|
159
164
|
// shadow: 15,
|
|
160
165
|
immediate: (key) => key === "zIndex",
|
|
161
166
|
config: (key) => key === "y" ? import_web.config.stiff : import_web.config.default
|
|
162
167
|
} : {
|
|
163
168
|
movement: index === originalIndex ? newHeights.slice(0, order.indexOf(index)).reduce((a, b) => a + b, 0) - heights.slice(0, index).reduce((a, b) => a + b, 0) : order.indexOf(index) === index ? 0 : order.indexOf(index) > index ? heights[originalIndex] : -heights[originalIndex],
|
|
164
169
|
scale: 1,
|
|
165
|
-
zIndex:
|
|
170
|
+
zIndex: total - index,
|
|
166
171
|
shadow: 0,
|
|
167
172
|
immediate: finished
|
|
168
173
|
};
|
package/cjs/Layout/Header.js
CHANGED
|
@@ -40,17 +40,14 @@ const Header = ({ className, type, children, height = 40 }) => {
|
|
|
40
40
|
window.removeEventListener("scroll", handleScroll);
|
|
41
41
|
};
|
|
42
42
|
}, []);
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
className
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
] });
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: (0, import_client.clsx)(
|
|
47
|
+
`fixed top-0 z-[9] flex duration-300 ${!visible ? "md:-translate-y-full" : ""} bg-base-100 w-full shadow-sm backdrop-blur-lg`,
|
|
48
|
+
className
|
|
49
|
+
),
|
|
50
|
+
children
|
|
51
|
+
}
|
|
52
|
+
) });
|
|
56
53
|
};
|
package/esm/DraggableList.js
CHANGED
|
@@ -23,7 +23,8 @@ const DragList = ({ className, mode = "vertical", children, onChange, onRemove }
|
|
|
23
23
|
fn(
|
|
24
24
|
order.current,
|
|
25
25
|
new Array(children.length).fill(0),
|
|
26
|
-
new Array(children.length).fill(0)
|
|
26
|
+
new Array(children.length).fill(0),
|
|
27
|
+
children.length
|
|
27
28
|
)
|
|
28
29
|
);
|
|
29
30
|
const bind = useGesture({
|
|
@@ -49,10 +50,14 @@ const DragList = ({ className, mode = "vertical", children, onChange, onRemove }
|
|
|
49
50
|
const curRow = clamp(centerIdx, 0, children.length - 1);
|
|
50
51
|
const newOrder = swap(order.current, originIdx, curRow);
|
|
51
52
|
const newClientHeights = swap([...clientLengths.current], originIdx, curRow);
|
|
52
|
-
void api.start(
|
|
53
|
+
void api.start(
|
|
54
|
+
fn(newOrder, clientLengths.current, newClientHeights, children.length, active, originIdx, movement)
|
|
55
|
+
);
|
|
53
56
|
if (!active) {
|
|
54
57
|
const draggedValue = children[originIdx].props.value;
|
|
55
|
-
void api.start(
|
|
58
|
+
void api.start(
|
|
59
|
+
fn(order.current, clientLengths.current, newClientHeights, children.length, active, originIdx, movement, true)
|
|
60
|
+
);
|
|
56
61
|
onChange(
|
|
57
62
|
children.map((_, index) => children[newOrder[index]].props.value),
|
|
58
63
|
draggedValue,
|
|
@@ -61,7 +66,7 @@ const DragList = ({ className, mode = "vertical", children, onChange, onRemove }
|
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
});
|
|
64
|
-
return /* @__PURE__ */ jsx("div", { className: clsx(`flex gap-0`, { "flex-col": mode === "vertical" }, className), children: springs.map(({ zIndex, shadow, movement, scale }, i) => /* @__PURE__ */ jsx(
|
|
69
|
+
return /* @__PURE__ */ jsx("div", { className: clsx(`isolate flex gap-0`, { "flex-col": mode === "vertical" }, className), children: springs.map(({ zIndex, shadow, movement, scale }, i) => /* @__PURE__ */ jsx(
|
|
65
70
|
animated.div,
|
|
66
71
|
{
|
|
67
72
|
ref: (el) => {
|
|
@@ -101,15 +106,15 @@ DragList.Cursor = ({ className, children }) => {
|
|
|
101
106
|
}
|
|
102
107
|
);
|
|
103
108
|
};
|
|
104
|
-
const Item = ({ value, children, removable = false }) => {
|
|
109
|
+
const Item = ({ value, children, className, cursorClassName, removable = false, removeClassName }) => {
|
|
105
110
|
const { onRemove } = useDragList();
|
|
106
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2", children: [
|
|
107
|
-
/* @__PURE__ */ jsx(DraggableList.Cursor, { children: /* @__PURE__ */ jsx(MdDragIndicator, { className: "text-xl" }) }),
|
|
111
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: clsx("flex w-full items-center gap-2", className), children: [
|
|
112
|
+
/* @__PURE__ */ jsx(DraggableList.Cursor, { className: cursorClassName, children: /* @__PURE__ */ jsx(MdDragIndicator, { className: "text-xl" }) }),
|
|
108
113
|
children,
|
|
109
114
|
removable && /* @__PURE__ */ jsx(
|
|
110
115
|
"button",
|
|
111
116
|
{
|
|
112
|
-
className: "btn btn-xs btn-error btn-square btn-outline",
|
|
117
|
+
className: clsx("btn btn-xs btn-error btn-square btn-outline", removeClassName),
|
|
113
118
|
onClick: () => {
|
|
114
119
|
onRemove(value);
|
|
115
120
|
},
|
|
@@ -119,18 +124,18 @@ const Item = ({ value, children, removable = false }) => {
|
|
|
119
124
|
] }) });
|
|
120
125
|
};
|
|
121
126
|
DragList.Item = Item;
|
|
122
|
-
const fn = (order, heights, newHeights, active = false, originalIndex = 0, movement = 0, finished = false) => (index) => {
|
|
127
|
+
const fn = (order, heights, newHeights, total, active = false, originalIndex = 0, movement = 0, finished = false) => (index) => {
|
|
123
128
|
return active && index === originalIndex ? {
|
|
124
129
|
movement,
|
|
125
130
|
scale: 1.01,
|
|
126
|
-
zIndex: 1,
|
|
131
|
+
zIndex: total + 1,
|
|
127
132
|
// shadow: 15,
|
|
128
133
|
immediate: (key) => key === "zIndex",
|
|
129
134
|
config: (key) => key === "y" ? config.stiff : config.default
|
|
130
135
|
} : {
|
|
131
136
|
movement: index === originalIndex ? newHeights.slice(0, order.indexOf(index)).reduce((a, b) => a + b, 0) - heights.slice(0, index).reduce((a, b) => a + b, 0) : order.indexOf(index) === index ? 0 : order.indexOf(index) > index ? heights[originalIndex] : -heights[originalIndex],
|
|
132
137
|
scale: 1,
|
|
133
|
-
zIndex:
|
|
138
|
+
zIndex: total - index,
|
|
134
139
|
shadow: 0,
|
|
135
140
|
immediate: finished
|
|
136
141
|
};
|
package/esm/Layout/Header.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Fragment, jsx
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { clsx } from "@akanjs/client";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
5
|
const Header = ({ className, type, children, height = 40 }) => {
|
|
@@ -18,19 +18,16 @@ const Header = ({ className, type, children, height = 40 }) => {
|
|
|
18
18
|
window.removeEventListener("scroll", handleScroll);
|
|
19
19
|
};
|
|
20
20
|
}, []);
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
className
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
] });
|
|
21
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
className: clsx(
|
|
25
|
+
`fixed top-0 z-[9] flex duration-300 ${!visible ? "md:-translate-y-full" : ""} bg-base-100 w-full shadow-sm backdrop-blur-lg`,
|
|
26
|
+
className
|
|
27
|
+
),
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
) });
|
|
34
31
|
};
|
|
35
32
|
export {
|
|
36
33
|
Header
|