@akanjs/ui 1.0.14 → 1.0.16

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.
@@ -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 {};
@@ -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(fn(newOrder, clientLengths.current, newClientHeights, active, originIdx, movement));
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(fn(order.current, clientLengths.current, newClientHeights, active, originIdx, movement, true));
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: 0,
170
+ zIndex: total - index,
166
171
  shadow: 0,
167
172
  immediate: finished
168
173
  };
@@ -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(fn(newOrder, clientLengths.current, newClientHeights, active, originIdx, movement));
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(fn(order.current, clientLengths.current, newClientHeights, active, originIdx, movement, true));
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: 0,
138
+ zIndex: total - index,
134
139
  shadow: 0,
135
140
  immediate: finished
136
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/ui",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"