react-crud-mobile 1.3.558 → 1.3.561
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/dist/index.js +14 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/elements/core/UIButton.tsx +2 -1
- package/src/elements/core/UIOrder.tsx +235 -271
package/dist/index.mjs
CHANGED
|
@@ -474,7 +474,8 @@ function UIButton(props) {
|
|
|
474
474
|
if (!label) {
|
|
475
475
|
def = { ...def, borderRadius: 20 };
|
|
476
476
|
}
|
|
477
|
-
let
|
|
477
|
+
let pure = style("button", {});
|
|
478
|
+
let css = { ...style("button", def), ...pure };
|
|
478
479
|
if (!css.width) {
|
|
479
480
|
let h = css.height;
|
|
480
481
|
if (typeof h === "number") css.minWidth = h;
|
|
@@ -1654,14 +1655,7 @@ import Toast2 from "react-native-toast-message";
|
|
|
1654
1655
|
// src/elements/core/UIOrder.tsx
|
|
1655
1656
|
import { useRef as useRef5, useState as useState15, useEffect as useEffect3 } from "react";
|
|
1656
1657
|
import { Utils as Utils17 } from "react-crud-utils";
|
|
1657
|
-
import {
|
|
1658
|
-
View as View12,
|
|
1659
|
-
Text as Text12,
|
|
1660
|
-
StyleSheet as StyleSheet14,
|
|
1661
|
-
Animated as Animated2,
|
|
1662
|
-
PanResponder,
|
|
1663
|
-
TouchableOpacity as TouchableOpacity7
|
|
1664
|
-
} from "react-native";
|
|
1658
|
+
import { View as View12, Text as Text12, StyleSheet as StyleSheet14, Animated as Animated2, PanResponder, TouchableOpacity as TouchableOpacity7 } from "react-native";
|
|
1665
1659
|
import { Fragment as Fragment15, jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1666
1660
|
var ITEM_HEIGHT = 70;
|
|
1667
1661
|
function UIOrder(props) {
|
|
@@ -1671,9 +1665,7 @@ function UIOrder(props) {
|
|
|
1671
1665
|
const [items, setItems] = useState15(initial);
|
|
1672
1666
|
const [draggingId, setDraggingId] = useState15(null);
|
|
1673
1667
|
const positions = useRef5(
|
|
1674
|
-
Object.fromEntries(
|
|
1675
|
-
initial.map((it, i) => [it.value, new Animated2.Value(i * ITEM_HEIGHT)])
|
|
1676
|
-
)
|
|
1668
|
+
Object.fromEntries(initial.map((it, i) => [it.value, new Animated2.Value(i * ITEM_HEIGHT)]))
|
|
1677
1669
|
).current;
|
|
1678
1670
|
const panRespondersRef = useRef5({});
|
|
1679
1671
|
const activeItem = useRef5(null);
|
|
@@ -1685,8 +1677,7 @@ function UIOrder(props) {
|
|
|
1685
1677
|
}, [items]);
|
|
1686
1678
|
useEffect3(() => {
|
|
1687
1679
|
items.forEach((it, idx) => {
|
|
1688
|
-
if (!positions[it.value])
|
|
1689
|
-
positions[it.value] = new Animated2.Value(idx * ITEM_HEIGHT);
|
|
1680
|
+
if (!positions[it.value]) positions[it.value] = new Animated2.Value(idx * ITEM_HEIGHT);
|
|
1690
1681
|
Animated2.spring(positions[it.value], {
|
|
1691
1682
|
toValue: idx * ITEM_HEIGHT,
|
|
1692
1683
|
useNativeDriver: false
|
|
@@ -1708,35 +1699,26 @@ function UIOrder(props) {
|
|
|
1708
1699
|
onStartShouldSetPanResponder: () => true,
|
|
1709
1700
|
onPanResponderGrant: () => {
|
|
1710
1701
|
const currentItems = itemsRef.current;
|
|
1711
|
-
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value))
|
|
1712
|
-
return;
|
|
1702
|
+
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value)) return;
|
|
1713
1703
|
activeItem.current = item;
|
|
1714
|
-
activeIndex.current = currentItems.findIndex(
|
|
1715
|
-
(it) => it.value === item.value
|
|
1716
|
-
);
|
|
1704
|
+
activeIndex.current = currentItems.findIndex((it) => it.value === item.value);
|
|
1717
1705
|
offsetY.current = positions[item.value]._value;
|
|
1718
1706
|
setDraggingId(item.value);
|
|
1719
1707
|
},
|
|
1720
1708
|
onPanResponderMove: (_, gesture) => {
|
|
1721
1709
|
const currentItems = itemsRef.current;
|
|
1722
|
-
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value))
|
|
1723
|
-
return;
|
|
1710
|
+
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value)) return;
|
|
1724
1711
|
const y = offsetY.current + gesture.dy;
|
|
1725
1712
|
positions[item.value].setValue(y);
|
|
1726
1713
|
const targetIndex = Math.max(
|
|
1727
1714
|
0,
|
|
1728
|
-
Math.min(
|
|
1729
|
-
currentItems.length - 1,
|
|
1730
|
-
Math.floor((y + ITEM_HEIGHT / 2) / ITEM_HEIGHT)
|
|
1731
|
-
)
|
|
1715
|
+
Math.min(currentItems.length - 1, Math.floor((y + ITEM_HEIGHT / 2) / ITEM_HEIGHT))
|
|
1732
1716
|
);
|
|
1733
1717
|
currentItems.forEach((other, idx) => {
|
|
1734
1718
|
if (other.value === item.value || !positions[other.value]) return;
|
|
1735
1719
|
let targetY = idx * ITEM_HEIGHT;
|
|
1736
|
-
if (idx > activeIndex.current && idx <= targetIndex)
|
|
1737
|
-
|
|
1738
|
-
else if (idx < activeIndex.current && idx >= targetIndex)
|
|
1739
|
-
targetY = (idx + 1) * ITEM_HEIGHT;
|
|
1720
|
+
if (idx > activeIndex.current && idx <= targetIndex) targetY = (idx - 1) * ITEM_HEIGHT;
|
|
1721
|
+
else if (idx < activeIndex.current && idx >= targetIndex) targetY = (idx + 1) * ITEM_HEIGHT;
|
|
1740
1722
|
Animated2.timing(positions[other.value], {
|
|
1741
1723
|
toValue: targetY,
|
|
1742
1724
|
duration: 120,
|
|
@@ -1747,15 +1729,11 @@ function UIOrder(props) {
|
|
|
1747
1729
|
onPanResponderRelease: () => {
|
|
1748
1730
|
const moved = activeItem.current;
|
|
1749
1731
|
const currentItems = itemsRef.current;
|
|
1750
|
-
if (!moved || !positions[moved.value] || !currentItems.find((it) => it.value === moved.value))
|
|
1751
|
-
return;
|
|
1732
|
+
if (!moved || !positions[moved.value] || !currentItems.find((it) => it.value === moved.value)) return;
|
|
1752
1733
|
const finalY = positions[moved.value]._value;
|
|
1753
1734
|
const newIndex = Math.max(
|
|
1754
1735
|
0,
|
|
1755
|
-
Math.min(
|
|
1756
|
-
currentItems.length - 1,
|
|
1757
|
-
Math.floor((finalY + ITEM_HEIGHT / 2) / ITEM_HEIGHT)
|
|
1758
|
-
)
|
|
1736
|
+
Math.min(currentItems.length - 1, Math.floor((finalY + ITEM_HEIGHT / 2) / ITEM_HEIGHT))
|
|
1759
1737
|
);
|
|
1760
1738
|
const oldIndex = activeIndex.current;
|
|
1761
1739
|
const updated = [...currentItems];
|
|
@@ -1807,7 +1785,7 @@ function UIOrder(props) {
|
|
|
1807
1785
|
};
|
|
1808
1786
|
return /* @__PURE__ */ jsxs11(View12, { style: styles11.container, children: [
|
|
1809
1787
|
/* @__PURE__ */ jsx25(Empty, {}),
|
|
1810
|
-
/* @__PURE__ */ jsx25(View12, { style: { height: items.length * ITEM_HEIGHT, width: "100%" }, children: items.map((item) => {
|
|
1788
|
+
/* @__PURE__ */ jsx25(View12, { style: { height: items.length * ITEM_HEIGHT, width: "100%", ...scope.getStyle("container") }, children: items.map((item) => {
|
|
1811
1789
|
const y = positions[item.value];
|
|
1812
1790
|
if (!y) return null;
|
|
1813
1791
|
const isDragging = draggingId === item.value;
|
|
@@ -1831,14 +1809,7 @@ function UIOrder(props) {
|
|
|
1831
1809
|
children: [
|
|
1832
1810
|
/* @__PURE__ */ jsx25(View12, { style: styles11.handle, children: /* @__PURE__ */ jsx25(Text12, { style: styles11.handleText, children: "\u2261" }) }),
|
|
1833
1811
|
/* @__PURE__ */ jsx25(Text12, { style: styles11.itemText, children: item.label }),
|
|
1834
|
-
element.remove && /* @__PURE__ */ jsx25(
|
|
1835
|
-
TouchableOpacity7,
|
|
1836
|
-
{
|
|
1837
|
-
onPress: () => removeItem(item.value),
|
|
1838
|
-
style: styles11.del,
|
|
1839
|
-
children: /* @__PURE__ */ jsx25(Text12, { style: { color: "#fff" }, children: "X" })
|
|
1840
|
-
}
|
|
1841
|
-
)
|
|
1812
|
+
element.remove && /* @__PURE__ */ jsx25(TouchableOpacity7, { onPress: () => removeItem(item.value), style: styles11.del, children: /* @__PURE__ */ jsx25(Text12, { style: { color: "#fff" }, children: "X" }) })
|
|
1842
1813
|
]
|
|
1843
1814
|
},
|
|
1844
1815
|
item.value
|