@pallasoft/ps-mobile-components 1.8.0 → 1.8.1

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.
@@ -33,8 +33,6 @@ export const PsSortableGrid = ({ getItemSpan, isDisabled = false, items, labels,
33
33
  const rects = useMemo(() => PsSortableGridService.layout(order.map((item) => getItemSpan(item)), PsSortableGridService.heights(ids, measured), width), [getItemSpan, ids, measured, order, width]);
34
34
  const extras = useMemo(() => PsSortableGridService.extras(rects, PsSortableGridService.heights(ids, measured)), [ids, measured, rects]);
35
35
  const isReady = PsSortableGridService.isMeasured(ids, measured, width);
36
- const applied = useRef({});
37
- applied.current = Object.fromEntries(ids.map((id, index) => [id, isReady ? extras[index] : 0]));
38
36
  const latest = useRef({ items, onReorder, order, rects, scroll, windowHeight, insets });
39
37
  latest.current = { insets, items, onReorder, order, rects, scroll, windowHeight };
40
38
  useEffect(() => {
@@ -134,9 +132,10 @@ export const PsSortableGrid = ({ getItemSpan, isDisabled = false, items, labels,
134
132
  notify(next);
135
133
  PsHapticService.play('selection', hasHaptics);
136
134
  }, [hasHaptics]);
137
- const measure = useCallback((id, total) => {
138
- const natural = PsSortableGridService.natural(total, applied.current[id] === undefined ? 0 : applied.current[id]);
139
- setMeasured((current) => current[id] !== undefined && Math.abs(current[id] - natural) < 0.5
135
+ const measure = useCallback((id, total, renderedExtra) => {
136
+ const natural = PsSortableGridService.natural(total, renderedExtra);
137
+ setMeasured((current) => current[id] !== undefined &&
138
+ Math.abs(current[id] - natural) < PsSortableGridConfig.measureTolerance
140
139
  ? current
141
140
  : { ...current, [id]: natural });
142
141
  }, []);
@@ -16,7 +16,7 @@ export interface PsSortableItemProps {
16
16
  label: string;
17
17
  labels: PsSortableGridLabels;
18
18
  onEnd: () => void;
19
- onMeasure: (id: string, height: number) => void;
19
+ onMeasure: (id: string, height: number, renderedExtra: number) => void;
20
20
  onMove: (id: string, delta: number) => void;
21
21
  onStart: (id: string, absoluteY: number) => void;
22
22
  onUpdate: (translationX: number, translationY: number, absoluteY: number) => void;
@@ -54,7 +54,7 @@ export const PsSortableItem = ({ canMoveDown, canMoveUp, children, dragX, dragY,
54
54
  : [
55
55
  ...(canMoveUp ? [{ label: labels.moveUp, name: 'moveUp' }] : []),
56
56
  ...(canMoveDown ? [{ label: labels.moveDown, name: 'moveDown' }] : []),
57
- ], accessibilityLabel: label, accessible: !isDisabled, collapsable: false, onAccessibilityAction: (event) => onMove(id, event.nativeEvent.actionName === 'moveUp' ? -1 : 1), onLayout: (event) => onMeasure(id, event.nativeEvent.layout.height), style: [
57
+ ], accessibilityLabel: label, accessible: !isDisabled, collapsable: false, onAccessibilityAction: (event) => onMove(id, event.nativeEvent.actionName === 'moveUp' ? -1 : 1), onLayout: (event) => onMeasure(id, event.nativeEvent.layout.height, isReady ? extra : 0), style: [
58
58
  {
59
59
  borderRadius: PsSortableGridConfig.radius,
60
60
  opacity: isReady ? 1 : 0,
@@ -6,6 +6,7 @@ export declare const PsSortableGridConfig: {
6
6
  readonly holdTolerance: 8;
7
7
  readonly longPressMs: 400;
8
8
  readonly maxScrollStep: 18;
9
+ readonly measureTolerance: 1;
9
10
  readonly moveMs: 220;
10
11
  readonly outlineOffset: 0;
11
12
  readonly outlineWidth: 2;
@@ -8,6 +8,7 @@ export const PsSortableGridConfig = {
8
8
  holdTolerance: 8,
9
9
  longPressMs: 400,
10
10
  maxScrollStep: 18,
11
+ measureTolerance: 1,
11
12
  moveMs: 220,
12
13
  outlineOffset: 0,
13
14
  outlineWidth: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-mobile-components",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "private": false,
5
5
  "description": "Native iOS (SwiftUI) and Android (Jetpack Compose) Ps components for Pallasoft mobile apps",
6
6
  "main": "./dist/index.js",