react-crud-mobile 1.3.557 → 1.3.560
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 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/elements/core/UIButton.tsx +1 -1
- package/src/elements/core/UIModal.tsx +1 -1
- package/src/elements/core/UIOrder.tsx +235 -271
package/dist/index.js
CHANGED
|
@@ -502,7 +502,7 @@ function UIButton(props) {
|
|
|
502
502
|
if (!label) {
|
|
503
503
|
def = { ...def, borderRadius: 20 };
|
|
504
504
|
}
|
|
505
|
-
let css = style("button"
|
|
505
|
+
let css = { ...def, ...style("button") };
|
|
506
506
|
if (!css.width) {
|
|
507
507
|
let h = css.height;
|
|
508
508
|
if (typeof h === "number") css.minWidth = h;
|
|
@@ -1523,7 +1523,7 @@ function UIModal(props) {
|
|
|
1523
1523
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UIToast, {})
|
|
1524
1524
|
] });
|
|
1525
1525
|
};
|
|
1526
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_react_native17.Modal, { animationType: "slide",
|
|
1526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_react_native17.Modal, { animationType: "slide", visible: true, onRequestClose: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ModalInner, {}) }, key);
|
|
1527
1527
|
}
|
|
1528
1528
|
var styles9 = import_react_native17.StyleSheet.create({
|
|
1529
1529
|
modalTop: {
|
|
@@ -1685,9 +1685,7 @@ function UIOrder(props) {
|
|
|
1685
1685
|
const [items, setItems] = (0, import_react17.useState)(initial);
|
|
1686
1686
|
const [draggingId, setDraggingId] = (0, import_react17.useState)(null);
|
|
1687
1687
|
const positions = (0, import_react17.useRef)(
|
|
1688
|
-
Object.fromEntries(
|
|
1689
|
-
initial.map((it, i) => [it.value, new import_react_native20.Animated.Value(i * ITEM_HEIGHT)])
|
|
1690
|
-
)
|
|
1688
|
+
Object.fromEntries(initial.map((it, i) => [it.value, new import_react_native20.Animated.Value(i * ITEM_HEIGHT)]))
|
|
1691
1689
|
).current;
|
|
1692
1690
|
const panRespondersRef = (0, import_react17.useRef)({});
|
|
1693
1691
|
const activeItem = (0, import_react17.useRef)(null);
|
|
@@ -1699,8 +1697,7 @@ function UIOrder(props) {
|
|
|
1699
1697
|
}, [items]);
|
|
1700
1698
|
(0, import_react17.useEffect)(() => {
|
|
1701
1699
|
items.forEach((it, idx) => {
|
|
1702
|
-
if (!positions[it.value])
|
|
1703
|
-
positions[it.value] = new import_react_native20.Animated.Value(idx * ITEM_HEIGHT);
|
|
1700
|
+
if (!positions[it.value]) positions[it.value] = new import_react_native20.Animated.Value(idx * ITEM_HEIGHT);
|
|
1704
1701
|
import_react_native20.Animated.spring(positions[it.value], {
|
|
1705
1702
|
toValue: idx * ITEM_HEIGHT,
|
|
1706
1703
|
useNativeDriver: false
|
|
@@ -1722,35 +1719,26 @@ function UIOrder(props) {
|
|
|
1722
1719
|
onStartShouldSetPanResponder: () => true,
|
|
1723
1720
|
onPanResponderGrant: () => {
|
|
1724
1721
|
const currentItems = itemsRef.current;
|
|
1725
|
-
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value))
|
|
1726
|
-
return;
|
|
1722
|
+
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value)) return;
|
|
1727
1723
|
activeItem.current = item;
|
|
1728
|
-
activeIndex.current = currentItems.findIndex(
|
|
1729
|
-
(it) => it.value === item.value
|
|
1730
|
-
);
|
|
1724
|
+
activeIndex.current = currentItems.findIndex((it) => it.value === item.value);
|
|
1731
1725
|
offsetY.current = positions[item.value]._value;
|
|
1732
1726
|
setDraggingId(item.value);
|
|
1733
1727
|
},
|
|
1734
1728
|
onPanResponderMove: (_, gesture) => {
|
|
1735
1729
|
const currentItems = itemsRef.current;
|
|
1736
|
-
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value))
|
|
1737
|
-
return;
|
|
1730
|
+
if (!positions[item.value] || !currentItems.find((it) => it.value === item.value)) return;
|
|
1738
1731
|
const y = offsetY.current + gesture.dy;
|
|
1739
1732
|
positions[item.value].setValue(y);
|
|
1740
1733
|
const targetIndex = Math.max(
|
|
1741
1734
|
0,
|
|
1742
|
-
Math.min(
|
|
1743
|
-
currentItems.length - 1,
|
|
1744
|
-
Math.floor((y + ITEM_HEIGHT / 2) / ITEM_HEIGHT)
|
|
1745
|
-
)
|
|
1735
|
+
Math.min(currentItems.length - 1, Math.floor((y + ITEM_HEIGHT / 2) / ITEM_HEIGHT))
|
|
1746
1736
|
);
|
|
1747
1737
|
currentItems.forEach((other, idx) => {
|
|
1748
1738
|
if (other.value === item.value || !positions[other.value]) return;
|
|
1749
1739
|
let targetY = idx * ITEM_HEIGHT;
|
|
1750
|
-
if (idx > activeIndex.current && idx <= targetIndex)
|
|
1751
|
-
|
|
1752
|
-
else if (idx < activeIndex.current && idx >= targetIndex)
|
|
1753
|
-
targetY = (idx + 1) * ITEM_HEIGHT;
|
|
1740
|
+
if (idx > activeIndex.current && idx <= targetIndex) targetY = (idx - 1) * ITEM_HEIGHT;
|
|
1741
|
+
else if (idx < activeIndex.current && idx >= targetIndex) targetY = (idx + 1) * ITEM_HEIGHT;
|
|
1754
1742
|
import_react_native20.Animated.timing(positions[other.value], {
|
|
1755
1743
|
toValue: targetY,
|
|
1756
1744
|
duration: 120,
|
|
@@ -1761,15 +1749,11 @@ function UIOrder(props) {
|
|
|
1761
1749
|
onPanResponderRelease: () => {
|
|
1762
1750
|
const moved = activeItem.current;
|
|
1763
1751
|
const currentItems = itemsRef.current;
|
|
1764
|
-
if (!moved || !positions[moved.value] || !currentItems.find((it) => it.value === moved.value))
|
|
1765
|
-
return;
|
|
1752
|
+
if (!moved || !positions[moved.value] || !currentItems.find((it) => it.value === moved.value)) return;
|
|
1766
1753
|
const finalY = positions[moved.value]._value;
|
|
1767
1754
|
const newIndex = Math.max(
|
|
1768
1755
|
0,
|
|
1769
|
-
Math.min(
|
|
1770
|
-
currentItems.length - 1,
|
|
1771
|
-
Math.floor((finalY + ITEM_HEIGHT / 2) / ITEM_HEIGHT)
|
|
1772
|
-
)
|
|
1756
|
+
Math.min(currentItems.length - 1, Math.floor((finalY + ITEM_HEIGHT / 2) / ITEM_HEIGHT))
|
|
1773
1757
|
);
|
|
1774
1758
|
const oldIndex = activeIndex.current;
|
|
1775
1759
|
const updated = [...currentItems];
|
|
@@ -1821,7 +1805,7 @@ function UIOrder(props) {
|
|
|
1821
1805
|
};
|
|
1822
1806
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react_native20.View, { style: styles11.container, children: [
|
|
1823
1807
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Empty, {}),
|
|
1824
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.View, { style: { height: items.length * ITEM_HEIGHT, width: "100%" }, children: items.map((item) => {
|
|
1808
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.View, { style: { height: items.length * ITEM_HEIGHT, width: "100%", ...scope.getStyle("container") }, children: items.map((item) => {
|
|
1825
1809
|
const y = positions[item.value];
|
|
1826
1810
|
if (!y) return null;
|
|
1827
1811
|
const isDragging = draggingId === item.value;
|
|
@@ -1845,14 +1829,7 @@ function UIOrder(props) {
|
|
|
1845
1829
|
children: [
|
|
1846
1830
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.View, { style: styles11.handle, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.Text, { style: styles11.handleText, children: "\u2261" }) }),
|
|
1847
1831
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.Text, { style: styles11.itemText, children: item.label }),
|
|
1848
|
-
element.remove && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1849
|
-
import_react_native20.TouchableOpacity,
|
|
1850
|
-
{
|
|
1851
|
-
onPress: () => removeItem(item.value),
|
|
1852
|
-
style: styles11.del,
|
|
1853
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.Text, { style: { color: "#fff" }, children: "X" })
|
|
1854
|
-
}
|
|
1855
|
-
)
|
|
1832
|
+
element.remove && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.TouchableOpacity, { onPress: () => removeItem(item.value), style: styles11.del, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native20.Text, { style: { color: "#fff" }, children: "X" }) })
|
|
1856
1833
|
]
|
|
1857
1834
|
},
|
|
1858
1835
|
item.value
|