@sincpro/mobile-ui 1.0.1 → 1.1.0
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/README.md +572 -229
- package/dist/Actions/Actions.Button.d.ts +7 -2
- package/dist/Actions/Actions.Button.js +23 -10
- package/dist/Actions/Actions.FAB.d.ts +3 -1
- package/dist/Actions/Actions.FAB.js +7 -3
- package/dist/Actions/Actions.FilterButton.d.ts +10 -2
- package/dist/Actions/Actions.FilterButton.js +21 -6
- package/dist/Actions/Actions.IconButton.d.ts +5 -2
- package/dist/Actions/Actions.IconButton.js +7 -3
- package/dist/Actions/index.d.ts +2 -2
- package/dist/Actions/index.js +1 -1
- package/dist/Dialog/Dialog.ActionSheet.d.ts +2 -1
- package/dist/Dialog/Dialog.ActionSheet.js +15 -5
- package/dist/Dialog/Dialog.Confirmation.js +3 -3
- package/dist/Dialog/Dialog.NativeSheet.d.ts +10 -0
- package/dist/Dialog/Dialog.NativeSheet.js +21 -0
- package/dist/Dialog/Dialog.Sheet.d.ts +5 -1
- package/dist/Dialog/Dialog.Sheet.js +14 -8
- package/dist/Display/Display.CopyableText.d.ts +9 -2
- package/dist/Display/Display.CopyableText.js +75 -7
- package/dist/Display/Display.Icon.js +2 -1
- package/dist/Display/Display.KeyValue.d.ts +11 -4
- package/dist/Display/Display.KeyValue.js +6 -4
- package/dist/Display/Display.ListGroup.d.ts +23 -0
- package/dist/Display/Display.ListGroup.js +17 -0
- package/dist/Display/Display.ListItem.d.ts +16 -2
- package/dist/Display/Display.ListItem.js +25 -8
- package/dist/Display/Display.SectionHeader.d.ts +11 -1
- package/dist/Display/Display.SectionHeader.js +11 -2
- package/dist/Display/Display.SwipeableRow.d.ts +3 -1
- package/dist/Display/Display.SwipeableRow.js +3 -3
- package/dist/Display/index.d.ts +4 -0
- package/dist/Display/index.js +2 -0
- package/dist/Feedback/Feedback.Banner.js +1 -1
- package/dist/Feedback/Feedback.EmptyState.d.ts +2 -1
- package/dist/Feedback/Feedback.EmptyState.js +2 -2
- package/dist/Feedback/Feedback.Error.d.ts +3 -1
- package/dist/Feedback/Feedback.Error.js +4 -3
- package/dist/Form/Form.Checkbox.d.ts +4 -1
- package/dist/Form/Form.Checkbox.js +2 -2
- package/dist/Form/Form.DatePicker.d.ts +2 -1
- package/dist/Form/Form.DatePicker.js +4 -3
- package/dist/Form/Form.FilterButton.d.ts +1 -1
- package/dist/Form/Form.Input.d.ts +5 -3
- package/dist/Form/Form.Input.js +2 -2
- package/dist/Form/Form.KeyboardForm.d.ts +11 -0
- package/dist/Form/Form.KeyboardForm.js +9 -0
- package/dist/Form/Form.KeyboardToolbar.d.ts +21 -0
- package/dist/Form/Form.KeyboardToolbar.js +70 -0
- package/dist/Form/Form.Select.d.ts +3 -1
- package/dist/Form/Form.Select.js +23 -10
- package/dist/Form/index.d.ts +6 -0
- package/dist/Form/index.js +4 -0
- package/dist/Navigation/Navigation.AppBar.d.ts +6 -2
- package/dist/Navigation/Navigation.AppBar.js +7 -7
- package/dist/Navigation/Navigation.BottomNav.d.ts +3 -1
- package/dist/Navigation/Navigation.BottomNav.js +9 -5
- package/dist/Navigation/Navigation.RowItem.d.ts +1 -1
- package/dist/Navigation/Navigation.RowItem.js +2 -2
- package/dist/Navigation/Navigation.SearchBar.d.ts +6 -1
- package/dist/Navigation/Navigation.SearchBar.js +29 -8
- package/dist/Navigation/Navigation.SearchSuggestions.d.ts +14 -0
- package/dist/Navigation/Navigation.SearchSuggestions.js +7 -0
- package/dist/Navigation/Navigation.SegmentedControl.d.ts +3 -1
- package/dist/Navigation/Navigation.SegmentedControl.js +2 -1
- package/dist/Navigation/index.d.ts +6 -2
- package/dist/Navigation/index.js +2 -0
- package/dist/Typography/Typography.Heading.js +1 -1
- package/dist/Typography/Typography.SelectableText.d.ts +10 -0
- package/dist/Typography/Typography.SelectableText.js +16 -0
- package/dist/Typography/Typography.Text.js +4 -20
- package/dist/Typography/index.d.ts +3 -0
- package/dist/Typography/index.js +3 -0
- package/dist/layouts/AuthContainer.d.ts +4 -1
- package/dist/layouts/AuthContainer.js +3 -3
- package/dist/primitives/BaseButton.d.ts +7 -2
- package/dist/primitives/BaseButton.js +19 -5
- package/dist/theme/typography.d.ts +16 -1
- package/dist/theme/typography.js +19 -0
- package/dist/utils/criteria.d.ts +56 -0
- package/dist/utils/criteria.js +99 -0
- package/dist/utils/reorder.d.ts +4 -0
- package/dist/utils/reorder.js +32 -0
- package/dist/views/AuthFormView.d.ts +4 -1
- package/dist/views/AuthFormView.js +2 -2
- package/dist/views/FormViewV2.d.ts +7 -2
- package/dist/views/FormViewV2.js +35 -16
- package/dist/views/ListViewV2.d.ts +9 -6
- package/dist/views/ListViewV2.js +34 -21
- package/dist/widgets/CollectionOptions.d.ts +15 -0
- package/dist/widgets/CollectionOptions.js +127 -0
- package/dist/widgets/FilterBar.d.ts +21 -0
- package/dist/widgets/FilterBar.js +14 -0
- package/dist/widgets/FilterBuilder.d.ts +10 -0
- package/dist/widgets/FilterBuilder.js +115 -0
- package/dist/widgets/QueryChoice.d.ts +10 -0
- package/dist/widgets/QueryChoice.js +13 -0
- package/dist/widgets/ReorderableList.d.ts +51 -0
- package/dist/widgets/ReorderableList.js +138 -0
- package/dist/widgets/index.d.ts +4 -0
- package/dist/widgets/index.js +3 -0
- package/package.json +15 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import Icon from "../Display/Display.Icon.js";
|
|
3
|
+
import Pressable from "../primitives/Pressable.js";
|
|
4
|
+
import { cn } from "../theme/tw.js";
|
|
5
|
+
import { Typography } from "../Typography/index.js";
|
|
6
|
+
import { moveCollectionEntry } from "../utils/criteria.js";
|
|
7
|
+
import { applyReorder, moveReorderItem, reorderKeys, sameOrder, } from "../utils/reorder.js";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { AccessibilityInfo, useWindowDimensions, View, } from "react-native";
|
|
10
|
+
import Sortable from "react-native-sortables";
|
|
11
|
+
export default function ReorderableList({ items, keyExtractor, getItemLabel, onChange, renderItem, renderControls, renderHandleContent, disabled = false, className, style, itemStyle, contentStyle, controlsStyle, handleStyle, actionStyle, testID, labels, onDragStart, onDragEnd, onReorderRejected, sortableProps, }) {
|
|
12
|
+
const { fontScale } = useWindowDimensions();
|
|
13
|
+
const keys = useMemo(() => reorderKeys(items, keyExtractor), [items, keyExtractor]);
|
|
14
|
+
const data = useMemo(() => [...items], [items]);
|
|
15
|
+
const dragOrder = useRef(null);
|
|
16
|
+
const [dragging, setDragging] = useState(false);
|
|
17
|
+
const [error, setError] = useState();
|
|
18
|
+
const [revision, setRevision] = useState(0);
|
|
19
|
+
const busy = disabled || dragging;
|
|
20
|
+
const commit = (order, event) => {
|
|
21
|
+
if (sameOrder(keys, order))
|
|
22
|
+
return;
|
|
23
|
+
const next = applyReorder(items, keyExtractor, order);
|
|
24
|
+
onChange(next, event);
|
|
25
|
+
AccessibilityInfo.announceForAccessibility(labels?.moved?.(getItemLabel(next[event.toIndex]), event.toIndex + 1, items.length) ??
|
|
26
|
+
`${getItemLabel(next[event.toIndex])}, posición ${event.toIndex + 1} de ${items.length}`);
|
|
27
|
+
};
|
|
28
|
+
const reject = useCallback((reason) => {
|
|
29
|
+
const message = reason === "disabled"
|
|
30
|
+
? (labels?.disabledDuringDrag ??
|
|
31
|
+
"El orden se bloqueó durante el arrastre. No se aplicó el cambio.")
|
|
32
|
+
: (labels?.changedDuringDrag ??
|
|
33
|
+
"La lista cambió durante el arrastre. Revisa el orden e inténtalo de nuevo.");
|
|
34
|
+
setError(message);
|
|
35
|
+
setRevision((value) => value + 1);
|
|
36
|
+
AccessibilityInfo.announceForAccessibility(message);
|
|
37
|
+
onReorderRejected?.(reason);
|
|
38
|
+
}, [labels?.changedDuringDrag, labels?.disabledDuringDrag, onReorderRejected]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (dragOrder.current && (disabled || !sameOrder(dragOrder.current, keys))) {
|
|
41
|
+
dragOrder.current = null;
|
|
42
|
+
setDragging(false);
|
|
43
|
+
reject(disabled ? "disabled" : "data-changed");
|
|
44
|
+
onDragEnd?.();
|
|
45
|
+
}
|
|
46
|
+
}, [disabled, keys, onDragEnd, reject]);
|
|
47
|
+
return (_jsxs(View, { className: cn("gap-2", className), style: style, testID: testID, children: [_jsx(Sortable.Grid, { activeItemScale: 1, activeItemShadowOpacity: 0, rowGap: 8, ...sortableProps, columns: 1, customHandle: true, data: data, keyExtractor: keyExtractor, onDragEnd: ({ fromIndex, toIndex }) => {
|
|
48
|
+
const started = dragOrder.current;
|
|
49
|
+
if (!started)
|
|
50
|
+
return;
|
|
51
|
+
dragOrder.current = null;
|
|
52
|
+
setDragging(false);
|
|
53
|
+
if (started && !sameOrder(started, keys))
|
|
54
|
+
reject("data-changed");
|
|
55
|
+
else if (disabled)
|
|
56
|
+
reject("disabled");
|
|
57
|
+
else if (started)
|
|
58
|
+
commit(moveReorderItem(keys, fromIndex, toIndex), {
|
|
59
|
+
key: keys[fromIndex],
|
|
60
|
+
fromIndex,
|
|
61
|
+
toIndex,
|
|
62
|
+
source: "drag",
|
|
63
|
+
});
|
|
64
|
+
onDragEnd?.();
|
|
65
|
+
}, onDragStart: ({ fromIndex }) => {
|
|
66
|
+
dragOrder.current = keys;
|
|
67
|
+
setDragging(true);
|
|
68
|
+
setError(undefined);
|
|
69
|
+
onDragStart?.(keys[fromIndex]);
|
|
70
|
+
}, renderItem: ({ item, index }) => {
|
|
71
|
+
const key = keys[index];
|
|
72
|
+
const label = getItemLabel(item);
|
|
73
|
+
const move = (direction) => {
|
|
74
|
+
if (busy || index + direction < 0 || index + direction >= items.length)
|
|
75
|
+
return;
|
|
76
|
+
setError(undefined);
|
|
77
|
+
commit(moveCollectionEntry(keys, index, direction), {
|
|
78
|
+
key,
|
|
79
|
+
fromIndex: index,
|
|
80
|
+
toIndex: index + direction,
|
|
81
|
+
source: "button",
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const context = {
|
|
85
|
+
item,
|
|
86
|
+
index,
|
|
87
|
+
canMoveUp: !busy && index > 0,
|
|
88
|
+
canMoveDown: !busy && index < items.length - 1,
|
|
89
|
+
moveUp: () => move(-1),
|
|
90
|
+
moveDown: () => move(1),
|
|
91
|
+
};
|
|
92
|
+
const dragHandle = (_jsx(Sortable.Handle, { mode: disabled ? "non-draggable" : "draggable", children: _jsx(View, { accessibilityActions: [
|
|
93
|
+
...(context.canMoveUp ? [{ name: "decrement" }] : []),
|
|
94
|
+
...(context.canMoveDown ? [{ name: "increment" }] : []),
|
|
95
|
+
], accessibilityLabel: labels?.drag?.(label) ?? `Arrastrar ${label}`, accessibilityRole: "adjustable", accessibilityState: { disabled, busy: dragging }, accessibilityValue: { min: 1, max: items.length, now: index + 1 }, accessible: true, onAccessibilityAction: ({ nativeEvent }) => {
|
|
96
|
+
if (nativeEvent.actionName === "increment")
|
|
97
|
+
move(1);
|
|
98
|
+
if (nativeEvent.actionName === "decrement")
|
|
99
|
+
move(-1);
|
|
100
|
+
}, style: [
|
|
101
|
+
{
|
|
102
|
+
minHeight: 48,
|
|
103
|
+
minWidth: 48,
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
justifyContent: "center",
|
|
106
|
+
},
|
|
107
|
+
handleStyle,
|
|
108
|
+
], testID: testID ? `${testID}-handle-${key}` : undefined, children: renderHandleContent ? (renderHandleContent(context)) : (_jsx(Icon, { name: "reorder-two-outline", size: 20 })) }) }));
|
|
109
|
+
return (_jsxs(View, { style: [
|
|
110
|
+
{
|
|
111
|
+
width: "100%",
|
|
112
|
+
flexDirection: fontScale > 1.3 ? "column" : "row",
|
|
113
|
+
alignItems: "center",
|
|
114
|
+
gap: 8,
|
|
115
|
+
},
|
|
116
|
+
itemStyle,
|
|
117
|
+
], testID: testID ? `${testID}-item-${key}` : undefined, children: [_jsx(View, { style: [
|
|
118
|
+
fontScale > 1.3 ? { alignSelf: "stretch" } : { flex: 1, minWidth: 0 },
|
|
119
|
+
contentStyle,
|
|
120
|
+
], children: renderItem(context) }), _jsx(View, { style: [{ flexDirection: "row", alignItems: "center" }, controlsStyle], children: renderControls ? (renderControls({ ...context, dragHandle })) : (_jsxs(_Fragment, { children: [dragHandle, _jsx(Pressable, { accessibilityLabel: labels?.up?.(label) ?? `Subir ${label}`, disabled: !context.canMoveUp, onPress: context.moveUp, style: [
|
|
121
|
+
{
|
|
122
|
+
minWidth: 48,
|
|
123
|
+
minHeight: 48,
|
|
124
|
+
alignItems: "center",
|
|
125
|
+
justifyContent: "center",
|
|
126
|
+
},
|
|
127
|
+
actionStyle,
|
|
128
|
+
], children: _jsx(Icon, { name: "arrow-up-outline", size: 18 }) }), _jsx(Pressable, { accessibilityLabel: labels?.down?.(label) ?? `Bajar ${label}`, disabled: !context.canMoveDown, onPress: context.moveDown, style: [
|
|
129
|
+
{
|
|
130
|
+
minWidth: 48,
|
|
131
|
+
minHeight: 48,
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
justifyContent: "center",
|
|
134
|
+
},
|
|
135
|
+
actionStyle,
|
|
136
|
+
], children: _jsx(Icon, { name: "arrow-down-outline", size: 18 }) })] })) })] }, key));
|
|
137
|
+
}, sortEnabled: !disabled, strategy: "insert" }, revision), error ? (_jsx(Typography.Text, { accessibilityRole: "alert", className: "text-danger", children: error })) : null] }));
|
|
138
|
+
}
|
package/dist/widgets/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
export type { CollectionField, CollectionQuery, CollectionSort, CriteriaCondition, CriteriaField, CriteriaGroup, CriteriaNode, CriteriaOperator, CriteriaValue, SavedCollectionQuery, } from "../utils/criteria.js";
|
|
1
2
|
export { CircleButton } from "./CircleButton.js";
|
|
3
|
+
export { default as CollectionOptions, type CollectionOptionsProps, } from "./CollectionOptions.js";
|
|
4
|
+
export { FilterBar, type FilterBarOption, type FilterBarProps, } from "./FilterBar.js";
|
|
5
|
+
export { default as FilterBuilder, type FilterBuilderProps, } from "./FilterBuilder.js";
|
|
2
6
|
export { default as GeoPermissionCard } from "./GeoPermissionCard.js";
|
|
3
7
|
export { HomeHeader } from "./HomeHeader.js";
|
|
4
8
|
export { MenuCard } from "./MenuCard.js";
|
package/dist/widgets/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { CircleButton } from "./CircleButton.js";
|
|
2
|
+
export { default as CollectionOptions, } from "./CollectionOptions.js";
|
|
3
|
+
export { FilterBar, } from "./FilterBar.js";
|
|
4
|
+
export { default as FilterBuilder, } from "./FilterBuilder.js";
|
|
2
5
|
export { default as GeoPermissionCard } from "./GeoPermissionCard.js";
|
|
3
6
|
export { HomeHeader } from "./HomeHeader.js";
|
|
4
7
|
export { MenuCard } from "./MenuCard.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/mobile-ui",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Sincpro Mobile design system: generic, presentational React Native components (no domain logic)",
|
|
5
5
|
"main": "expo/AppEntry.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"./Dialog": "./dist/Dialog/index.js",
|
|
20
20
|
"./Dialog/BottomSheet": "./dist/Dialog/BottomSheet/index.js",
|
|
21
21
|
"./Dialog/Sheet": "./dist/Dialog/Dialog.Sheet.js",
|
|
22
|
+
"./Dialog/NativeSheet": "./dist/Dialog/Dialog.NativeSheet.js",
|
|
22
23
|
"./Actions": "./dist/Actions/index.js",
|
|
23
24
|
"./Display": "./dist/Display/index.js",
|
|
24
25
|
"./Feedback": "./dist/Feedback/index.js",
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
"./primitives": "./dist/primitives/index.js",
|
|
29
30
|
"./tokens": "./dist/tokens/index.js",
|
|
30
31
|
"./widgets": "./dist/widgets/index.js",
|
|
32
|
+
"./widgets/ReorderableList": "./dist/widgets/ReorderableList.js",
|
|
31
33
|
"./views/Wizard": "./dist/views/Wizard/index.js",
|
|
32
34
|
"./tailwind.preset": "./tailwind.preset.js",
|
|
33
35
|
"./theme/globals.css": "./dist/theme/globals.css",
|
|
@@ -67,15 +69,20 @@
|
|
|
67
69
|
"react-hook-form": ">=7",
|
|
68
70
|
"react-native": ">=0.88",
|
|
69
71
|
"react-native-currency-input": ">=1.1",
|
|
72
|
+
"react-native-gesture-handler": ">=3.3",
|
|
70
73
|
"react-native-keyboard-controller": ">=1.22",
|
|
71
74
|
"react-native-reanimated": ">=4.7",
|
|
72
75
|
"react-native-safe-area-context": ">=5.11",
|
|
76
|
+
"react-native-sortables": ">=1.10.1 <2",
|
|
73
77
|
"react-native-svg": ">=15.16",
|
|
74
78
|
"react-native-worklets": ">=0.13"
|
|
75
79
|
},
|
|
76
80
|
"peerDependenciesMeta": {
|
|
77
81
|
"@expo/ui": {
|
|
78
82
|
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"react-native-sortables": {
|
|
85
|
+
"optional": true
|
|
79
86
|
}
|
|
80
87
|
},
|
|
81
88
|
"dependencies": {
|
|
@@ -86,6 +93,12 @@
|
|
|
86
93
|
"tailwind-variants": "^3.2.2"
|
|
87
94
|
},
|
|
88
95
|
"devDependencies": {
|
|
96
|
+
"@jest/globals": "^30.0.0",
|
|
97
|
+
"@testing-library/react-native": "14.1.0",
|
|
98
|
+
"@react-native/jest-preset": "^0.88.1",
|
|
99
|
+
"jest": "^30.0.0",
|
|
100
|
+
"jest-expo": "~58.0.14",
|
|
101
|
+
"test-renderer": "^1.0.0",
|
|
89
102
|
"@expo-google-fonts/ibm-plex-mono": "^0.4.1",
|
|
90
103
|
"@expo-google-fonts/ibm-plex-sans": "^0.4.1",
|
|
91
104
|
"@expo/ui": "~58.0.27",
|
|
@@ -125,6 +138,7 @@
|
|
|
125
138
|
"react-native-keyboard-controller": "1.22.7",
|
|
126
139
|
"react-native-reanimated": "4.7.1",
|
|
127
140
|
"react-native-safe-area-context": "~5.11.1",
|
|
141
|
+
"react-native-sortables": "^1.10.1",
|
|
128
142
|
"react-native-svg": "15.16.0",
|
|
129
143
|
"react-native-worklets": "0.13.0",
|
|
130
144
|
"storybook": "10.6.6",
|