react-native-adjust-numbers 0.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/dist/NumberAdjuster.d.ts +4 -0
- package/dist/NumberAdjuster.d.ts.map +1 -0
- package/dist/NumberAdjuster.js +126 -0
- package/dist/NumberAdjuster.js.map +1 -0
- package/dist/__tests__/haptics.test.d.ts +1 -0
- package/dist/__tests__/haptics.test.d.ts.map +1 -0
- package/dist/__tests__/haptics.test.js +38 -0
- package/dist/__tests__/haptics.test.js.map +1 -0
- package/dist/__tests__/valueHelpers.test.d.ts +2 -0
- package/dist/__tests__/valueHelpers.test.d.ts.map +1 -0
- package/dist/__tests__/valueHelpers.test.js +107 -0
- package/dist/__tests__/valueHelpers.test.js.map +1 -0
- package/dist/components/DigitWheel.d.ts +12 -0
- package/dist/components/DigitWheel.d.ts.map +1 -0
- package/dist/components/DigitWheel.js +130 -0
- package/dist/components/DigitWheel.js.map +1 -0
- package/dist/components/SeparatorControl.d.ts +15 -0
- package/dist/components/SeparatorControl.d.ts.map +1 -0
- package/dist/components/SeparatorControl.js +57 -0
- package/dist/components/SeparatorControl.js.map +1 -0
- package/dist/hooks/useHaptics.d.ts +4 -0
- package/dist/hooks/useHaptics.d.ts.map +1 -0
- package/dist/hooks/useHaptics.js +28 -0
- package/dist/hooks/useHaptics.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/defaultTheme.d.ts +14 -0
- package/dist/theme/defaultTheme.d.ts.map +1 -0
- package/dist/theme/defaultTheme.js +19 -0
- package/dist/theme/defaultTheme.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/valueHelpers.d.ts +4 -0
- package/dist/valueHelpers.d.ts.map +1 -0
- package/dist/valueHelpers.js +21 -0
- package/dist/valueHelpers.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NumberAdjusterProps } from './types';
|
|
3
|
+
export declare function NumberAdjuster({ value, onChange, useComma, digitColor, backgroundColor, style, }: NumberAdjusterProps): React.JSX.Element;
|
|
4
|
+
//# sourceMappingURL=NumberAdjuster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberAdjuster.d.ts","sourceRoot":"","sources":["../src/NumberAdjuster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAOrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMnD,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,UAAU,EACV,eAAe,EACf,KAAK,GACN,EAAE,mBAAmB,qBAyHrB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { LayoutAnimation, Platform, ScrollView, StyleSheet, TouchableOpacity, Text, UIManager, View } from 'react-native';
|
|
3
|
+
import { defaultTheme } from './theme/defaultTheme';
|
|
4
|
+
import { DigitWheel } from './components/DigitWheel';
|
|
5
|
+
import { SeparatorControl, SeparatorGap } from './components/SeparatorControl';
|
|
6
|
+
import { hapticMedium } from './hooks/useHaptics';
|
|
7
|
+
import { parseValue, serializeValue } from './valueHelpers';
|
|
8
|
+
if (Platform.OS === 'android' && UIManager.setLayoutAnimationEnabledExperimental) {
|
|
9
|
+
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
10
|
+
}
|
|
11
|
+
export function NumberAdjuster({ value, onChange, useComma = false, digitColor, backgroundColor, style, }) {
|
|
12
|
+
const [placementMode, setPlacementMode] = useState(false);
|
|
13
|
+
const resolvedBg = backgroundColor ?? defaultTheme.backgroundColor;
|
|
14
|
+
const resolvedDigitColor = digitColor ?? defaultTheme.digitColor;
|
|
15
|
+
const parsed = parseValue(value, useComma);
|
|
16
|
+
const { digits, separatorIndex, separatorChar } = parsed;
|
|
17
|
+
const emit = useCallback((nextDigits, nextSepIndex) => {
|
|
18
|
+
onChange(serializeValue({ digits: nextDigits, separatorIndex: nextSepIndex, separatorChar }));
|
|
19
|
+
}, [onChange, separatorChar]);
|
|
20
|
+
const handleIncrement = (idx) => {
|
|
21
|
+
const next = [...digits];
|
|
22
|
+
next[idx] = (next[idx] + 1) % 10;
|
|
23
|
+
emit(next, separatorIndex);
|
|
24
|
+
};
|
|
25
|
+
const handleDecrement = (idx) => {
|
|
26
|
+
const next = [...digits];
|
|
27
|
+
next[idx] = (next[idx] + 9) % 10;
|
|
28
|
+
emit(next, separatorIndex);
|
|
29
|
+
};
|
|
30
|
+
const handleAddLeft = () => {
|
|
31
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
32
|
+
hapticMedium();
|
|
33
|
+
const next = [0, ...digits];
|
|
34
|
+
const nextSep = separatorIndex !== null ? separatorIndex + 1 : null;
|
|
35
|
+
emit(next, nextSep);
|
|
36
|
+
};
|
|
37
|
+
const handleAddRight = () => {
|
|
38
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
39
|
+
hapticMedium();
|
|
40
|
+
emit([...digits, 0], separatorIndex);
|
|
41
|
+
};
|
|
42
|
+
const handleDeleteDigit = (idx) => {
|
|
43
|
+
if (digits.length <= 1)
|
|
44
|
+
return;
|
|
45
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
46
|
+
const next = digits.filter((_, i) => i !== idx);
|
|
47
|
+
let nextSep = separatorIndex;
|
|
48
|
+
if (nextSep !== null) {
|
|
49
|
+
if (idx < nextSep)
|
|
50
|
+
nextSep -= 1;
|
|
51
|
+
if (nextSep <= 0 || nextSep >= next.length)
|
|
52
|
+
nextSep = null;
|
|
53
|
+
}
|
|
54
|
+
emit(next, nextSep);
|
|
55
|
+
};
|
|
56
|
+
const handleSeparatorToggle = () => {
|
|
57
|
+
setPlacementMode((m) => !m);
|
|
58
|
+
};
|
|
59
|
+
const handleGapPress = (gapIndex) => {
|
|
60
|
+
hapticMedium();
|
|
61
|
+
setPlacementMode(false);
|
|
62
|
+
emit(digits, gapIndex);
|
|
63
|
+
};
|
|
64
|
+
return (<View style={[styles.outer, { backgroundColor: resolvedBg }, style]}>
|
|
65
|
+
{/* Left add button */}
|
|
66
|
+
<TouchableOpacity onPress={handleAddLeft} style={styles.addButton} activeOpacity={0.7}>
|
|
67
|
+
<Text style={[styles.addLabel, { color: resolvedDigitColor }]}>+</Text>
|
|
68
|
+
</TouchableOpacity>
|
|
69
|
+
|
|
70
|
+
{/* Digit row */}
|
|
71
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.digitRow} scrollEnabled={true}>
|
|
72
|
+
{digits.map((digit, idx) => (<React.Fragment key={idx}>
|
|
73
|
+
{/* Gap before each digit (except first) for separator placement */}
|
|
74
|
+
{idx > 0 && (<SeparatorGap visible={placementMode} onPress={() => handleGapPress(idx)}/>)}
|
|
75
|
+
|
|
76
|
+
{/* Inline separator rendered between digits */}
|
|
77
|
+
{separatorIndex === idx && !placementMode && (<Text style={[styles.inlineSep, { color: resolvedDigitColor, fontFamily: defaultTheme.fontFamily }]}>
|
|
78
|
+
{separatorChar}
|
|
79
|
+
</Text>)}
|
|
80
|
+
|
|
81
|
+
<DigitWheel value={digit} digitColor={resolvedDigitColor} onIncrement={() => handleIncrement(idx)} onDecrement={() => handleDecrement(idx)} onLongPressDelete={() => handleDeleteDigit(idx)} canDelete={digits.length > 1}/>
|
|
82
|
+
</React.Fragment>))}
|
|
83
|
+
</ScrollView>
|
|
84
|
+
|
|
85
|
+
{/* Separator toggle */}
|
|
86
|
+
<SeparatorControl separatorChar={separatorChar} isPlacementMode={placementMode} onToggle={handleSeparatorToggle} visible={digits.length > 1}/>
|
|
87
|
+
|
|
88
|
+
{/* Right add button */}
|
|
89
|
+
<TouchableOpacity onPress={handleAddRight} style={styles.addButton} activeOpacity={0.7}>
|
|
90
|
+
<Text style={[styles.addLabel, { color: resolvedDigitColor }]}>+</Text>
|
|
91
|
+
</TouchableOpacity>
|
|
92
|
+
</View>);
|
|
93
|
+
}
|
|
94
|
+
const styles = StyleSheet.create({
|
|
95
|
+
outer: {
|
|
96
|
+
flexDirection: 'row',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
alignSelf: 'center',
|
|
99
|
+
borderRadius: 8,
|
|
100
|
+
padding: 8,
|
|
101
|
+
},
|
|
102
|
+
digitRow: {
|
|
103
|
+
flexDirection: 'row',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
},
|
|
106
|
+
addButton: {
|
|
107
|
+
width: defaultTheme.addButtonSize,
|
|
108
|
+
height: defaultTheme.addButtonSize,
|
|
109
|
+
borderRadius: defaultTheme.addButtonSize / 2,
|
|
110
|
+
borderWidth: 1,
|
|
111
|
+
borderColor: defaultTheme.addButtonBorderColor,
|
|
112
|
+
justifyContent: 'center',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
marginHorizontal: 4,
|
|
115
|
+
},
|
|
116
|
+
addLabel: {
|
|
117
|
+
fontSize: 18,
|
|
118
|
+
lineHeight: 22,
|
|
119
|
+
},
|
|
120
|
+
inlineSep: {
|
|
121
|
+
fontSize: defaultTheme.fontSize,
|
|
122
|
+
alignSelf: 'center',
|
|
123
|
+
marginHorizontal: 2,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=NumberAdjuster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberAdjuster.js","sourceRoot":"","sources":["../src/NumberAdjuster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,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AAE,YAAY,CAAC,oBAAoB;QAC9C,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,gBAAgB,EAAE,CAAC;KACpB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;KACf;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,YAAY,CAAC,QAAQ;QAC/B,SAAS,EAAE,QAAQ;QACnB,gBAAgB,EAAE,CAAC;KACpB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=haptics.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"haptics.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/haptics.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
jest.mock('expo-haptics', () => ({
|
|
3
|
+
impactAsync: jest.fn().mockResolvedValue(undefined),
|
|
4
|
+
ImpactFeedbackStyle: { Light: 'Light', Medium: 'Medium', Heavy: 'Heavy' },
|
|
5
|
+
}));
|
|
6
|
+
jest.mock('react-native', () => ({
|
|
7
|
+
Platform: { OS: 'ios' },
|
|
8
|
+
}));
|
|
9
|
+
describe('haptics wrapper', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.clearAllMocks();
|
|
12
|
+
jest.resetModules();
|
|
13
|
+
});
|
|
14
|
+
it('calls expo-haptics impactAsync on native', async () => {
|
|
15
|
+
jest.mock('react-native', () => ({ Platform: { OS: 'ios' } }));
|
|
16
|
+
const { hapticLight } = await import('../hooks/useHaptics');
|
|
17
|
+
await expect(hapticLight()).resolves.not.toThrow();
|
|
18
|
+
const ExpoHaptics = require('expo-haptics');
|
|
19
|
+
expect(ExpoHaptics.impactAsync).toHaveBeenCalledWith('Light');
|
|
20
|
+
});
|
|
21
|
+
it('is a no-op on web — does not call impactAsync', async () => {
|
|
22
|
+
jest.mock('react-native', () => ({ Platform: { OS: 'web' } }));
|
|
23
|
+
const { hapticLight } = await import('../hooks/useHaptics');
|
|
24
|
+
await expect(hapticLight()).resolves.not.toThrow();
|
|
25
|
+
const ExpoHaptics = require('expo-haptics');
|
|
26
|
+
expect(ExpoHaptics.impactAsync).not.toHaveBeenCalled();
|
|
27
|
+
});
|
|
28
|
+
it('does not throw if expo-haptics throws', async () => {
|
|
29
|
+
jest.mock('expo-haptics', () => ({
|
|
30
|
+
impactAsync: jest.fn().mockRejectedValue(new Error('haptics unavailable')),
|
|
31
|
+
ImpactFeedbackStyle: { Light: 'Light', Medium: 'Medium', Heavy: 'Heavy' },
|
|
32
|
+
}));
|
|
33
|
+
jest.mock('react-native', () => ({ Platform: { OS: 'ios' } }));
|
|
34
|
+
const { hapticLight } = await import('../hooks/useHaptics');
|
|
35
|
+
await expect(hapticLight()).resolves.not.toThrow();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=haptics.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"haptics.test.js","sourceRoot":"","sources":["../../src/__tests__/haptics.test.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/B,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;IACnD,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;CAC1E,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/B,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE;CACxB,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa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/B,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC1E,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;SAC1E,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC/D,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAC5D,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueHelpers.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/valueHelpers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { parseValue, serializeValue } from '../valueHelpers';
|
|
2
|
+
describe('parseValue', () => {
|
|
3
|
+
it('parses integer value with no separator', () => {
|
|
4
|
+
const result = parseValue('12345', false);
|
|
5
|
+
expect(result.digits).toEqual([1, 2, 3, 4, 5]);
|
|
6
|
+
expect(result.separatorIndex).toBeNull();
|
|
7
|
+
expect(result.separatorChar).toBe('.');
|
|
8
|
+
});
|
|
9
|
+
it('parses decimal value with period separator', () => {
|
|
10
|
+
const result = parseValue('1234.5', false);
|
|
11
|
+
expect(result.digits).toEqual([1, 2, 3, 4, 5]);
|
|
12
|
+
expect(result.separatorIndex).toBe(4);
|
|
13
|
+
expect(result.separatorChar).toBe('.');
|
|
14
|
+
});
|
|
15
|
+
it('parses decimal value with comma separator', () => {
|
|
16
|
+
const result = parseValue('1234,5', true);
|
|
17
|
+
expect(result.digits).toEqual([1, 2, 3, 4, 5]);
|
|
18
|
+
expect(result.separatorIndex).toBe(4);
|
|
19
|
+
expect(result.separatorChar).toBe(',');
|
|
20
|
+
});
|
|
21
|
+
it('uses comma char when useComma is true', () => {
|
|
22
|
+
const result = parseValue('99', true);
|
|
23
|
+
expect(result.separatorChar).toBe(',');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('serializeValue', () => {
|
|
27
|
+
it('serializes integer (no separator)', () => {
|
|
28
|
+
expect(serializeValue({ digits: [1, 2, 3], separatorIndex: null, separatorChar: '.' })).toBe('123');
|
|
29
|
+
});
|
|
30
|
+
it('serializes decimal with period', () => {
|
|
31
|
+
expect(serializeValue({ digits: [1, 2, 3, 4, 5], separatorIndex: 4, separatorChar: '.' })).toBe('1234.5');
|
|
32
|
+
});
|
|
33
|
+
it('serializes decimal with comma', () => {
|
|
34
|
+
expect(serializeValue({ digits: [1, 2, 3, 4, 5], separatorIndex: 4, separatorChar: ',' })).toBe('1234,5');
|
|
35
|
+
});
|
|
36
|
+
it('round-trips integer value', () => {
|
|
37
|
+
const input = '98765';
|
|
38
|
+
expect(serializeValue(parseValue(input, false))).toBe(input);
|
|
39
|
+
});
|
|
40
|
+
it('round-trips decimal value', () => {
|
|
41
|
+
const input = '123.45';
|
|
42
|
+
expect(serializeValue(parseValue(input, false))).toBe(input);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('digit wrap logic', () => {
|
|
46
|
+
it('increments with wrap at 9', () => {
|
|
47
|
+
const parsed = parseValue('9', false);
|
|
48
|
+
const next = [...parsed.digits];
|
|
49
|
+
next[0] = (next[0] + 1) % 10;
|
|
50
|
+
expect(next[0]).toBe(0);
|
|
51
|
+
});
|
|
52
|
+
it('decrements with wrap at 0', () => {
|
|
53
|
+
const parsed = parseValue('0', false);
|
|
54
|
+
const next = [...parsed.digits];
|
|
55
|
+
next[0] = (next[0] + 9) % 10;
|
|
56
|
+
expect(next[0]).toBe(9);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('digit add/remove constraints', () => {
|
|
60
|
+
it('enforces minimum one digit on remove', () => {
|
|
61
|
+
const digits = [5];
|
|
62
|
+
const canDelete = digits.length > 1;
|
|
63
|
+
expect(canDelete).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
it('allows remove when more than one digit', () => {
|
|
66
|
+
const digits = [1, 2];
|
|
67
|
+
const canDelete = digits.length > 1;
|
|
68
|
+
expect(canDelete).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
it('add left inserts 0 at index 0', () => {
|
|
71
|
+
const digits = [1, 2, 3];
|
|
72
|
+
const next = [0, ...digits];
|
|
73
|
+
expect(next).toEqual([0, 1, 2, 3]);
|
|
74
|
+
});
|
|
75
|
+
it('add right appends 0', () => {
|
|
76
|
+
const digits = [1, 2, 3];
|
|
77
|
+
const next = [...digits, 0];
|
|
78
|
+
expect(next).toEqual([1, 2, 3, 0]);
|
|
79
|
+
});
|
|
80
|
+
it('separator index shifts right when digit added at left', () => {
|
|
81
|
+
const separatorIndex = 2;
|
|
82
|
+
const nextSep = separatorIndex + 1;
|
|
83
|
+
expect(nextSep).toBe(3);
|
|
84
|
+
});
|
|
85
|
+
it('separator becomes null if it would be at invalid position after delete', () => {
|
|
86
|
+
const digits = [1, 2];
|
|
87
|
+
let separatorIndex = 1;
|
|
88
|
+
const deleteIdx = 0;
|
|
89
|
+
const next = digits.filter((_, i) => i !== deleteIdx);
|
|
90
|
+
if (separatorIndex !== null) {
|
|
91
|
+
if (deleteIdx < separatorIndex)
|
|
92
|
+
separatorIndex -= 1;
|
|
93
|
+
if (separatorIndex <= 0 || separatorIndex >= next.length)
|
|
94
|
+
separatorIndex = null;
|
|
95
|
+
}
|
|
96
|
+
expect(separatorIndex).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe('separator movement', () => {
|
|
100
|
+
it('moves separator to new gap index', () => {
|
|
101
|
+
const digits = [1, 2, 3, 4];
|
|
102
|
+
const newSepIndex = 2;
|
|
103
|
+
const result = serializeValue({ digits, separatorIndex: newSepIndex, separatorChar: '.' });
|
|
104
|
+
expect(result).toBe('12.34');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=valueHelpers.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueHelpers.test.js","sourceRoot":"","sources":["../../src/__tests__/valueHelpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE7D,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC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AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,MAAM,WAAW,GAAG,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3F,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
value: number;
|
|
4
|
+
digitColor: string;
|
|
5
|
+
onIncrement: () => void;
|
|
6
|
+
onDecrement: () => void;
|
|
7
|
+
onLongPressDelete: () => void;
|
|
8
|
+
canDelete: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function DigitWheel({ value, digitColor, onIncrement, onDecrement, onLongPressDelete, canDelete, }: Props): React.JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=DigitWheel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DigitWheel.d.ts","sourceRoot":"","sources":["../../src/components/DigitWheel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAKtC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,SAAS,GACV,EAAE,KAAK,qBA+HP"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { Animated, PanResponder, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { defaultTheme } from '../theme/defaultTheme';
|
|
4
|
+
import { hapticLight } from '../hooks/useHaptics';
|
|
5
|
+
export function DigitWheel({ value, digitColor, onIncrement, onDecrement, onLongPressDelete, canDelete, }) {
|
|
6
|
+
const translateY = useRef(new Animated.Value(0)).current;
|
|
7
|
+
const accumulatedDrag = useRef(0);
|
|
8
|
+
const longPressTimer = useRef(null);
|
|
9
|
+
const above = (value + 1) % 10;
|
|
10
|
+
const below = (value + 9) % 10;
|
|
11
|
+
const panResponder = useRef(PanResponder.create({
|
|
12
|
+
onStartShouldSetPanResponder: () => true,
|
|
13
|
+
onMoveShouldSetPanResponder: () => true,
|
|
14
|
+
onPanResponderGrant: () => {
|
|
15
|
+
accumulatedDrag.current = 0;
|
|
16
|
+
longPressTimer.current = setTimeout(() => {
|
|
17
|
+
if (canDelete) {
|
|
18
|
+
hapticHeavy();
|
|
19
|
+
onLongPressDelete();
|
|
20
|
+
}
|
|
21
|
+
longPressTimer.current = null;
|
|
22
|
+
}, 2000);
|
|
23
|
+
},
|
|
24
|
+
onPanResponderMove: (_evt, gestureState) => {
|
|
25
|
+
if (longPressTimer.current) {
|
|
26
|
+
clearTimeout(longPressTimer.current);
|
|
27
|
+
longPressTimer.current = null;
|
|
28
|
+
}
|
|
29
|
+
translateY.setValue(gestureState.dy);
|
|
30
|
+
accumulatedDrag.current = gestureState.dy;
|
|
31
|
+
},
|
|
32
|
+
onPanResponderRelease: () => {
|
|
33
|
+
if (longPressTimer.current) {
|
|
34
|
+
clearTimeout(longPressTimer.current);
|
|
35
|
+
longPressTimer.current = null;
|
|
36
|
+
}
|
|
37
|
+
const drag = accumulatedDrag.current;
|
|
38
|
+
if (Math.abs(drag) >= defaultTheme.scrollThreshold) {
|
|
39
|
+
if (drag < 0) {
|
|
40
|
+
hapticLight();
|
|
41
|
+
onIncrement();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
hapticLight();
|
|
45
|
+
onDecrement();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
Animated.spring(translateY, {
|
|
49
|
+
toValue: 0,
|
|
50
|
+
useNativeDriver: true,
|
|
51
|
+
}).start();
|
|
52
|
+
accumulatedDrag.current = 0;
|
|
53
|
+
},
|
|
54
|
+
onPanResponderTerminate: () => {
|
|
55
|
+
if (longPressTimer.current) {
|
|
56
|
+
clearTimeout(longPressTimer.current);
|
|
57
|
+
longPressTimer.current = null;
|
|
58
|
+
}
|
|
59
|
+
Animated.spring(translateY, {
|
|
60
|
+
toValue: 0,
|
|
61
|
+
useNativeDriver: true,
|
|
62
|
+
}).start();
|
|
63
|
+
accumulatedDrag.current = 0;
|
|
64
|
+
},
|
|
65
|
+
})).current;
|
|
66
|
+
const cellH = defaultTheme.digitCellHeight;
|
|
67
|
+
const cellW = defaultTheme.digitCellWidth;
|
|
68
|
+
return (<View style={[styles.container, { width: cellW, height: cellH }]} {...panResponder.panHandlers}>
|
|
69
|
+
{/* Neighbour above */}
|
|
70
|
+
<Text style={[
|
|
71
|
+
styles.digit,
|
|
72
|
+
{
|
|
73
|
+
color: digitColor,
|
|
74
|
+
fontFamily: defaultTheme.fontFamily,
|
|
75
|
+
fontSize: defaultTheme.fontSize,
|
|
76
|
+
opacity: defaultTheme.neighbourOpacity,
|
|
77
|
+
position: 'absolute',
|
|
78
|
+
top: -cellH,
|
|
79
|
+
width: cellW,
|
|
80
|
+
textAlign: 'center',
|
|
81
|
+
},
|
|
82
|
+
]}>
|
|
83
|
+
{above}
|
|
84
|
+
</Text>
|
|
85
|
+
|
|
86
|
+
{/* Current digit */}
|
|
87
|
+
<Animated.Text style={[
|
|
88
|
+
styles.digit,
|
|
89
|
+
{
|
|
90
|
+
color: digitColor,
|
|
91
|
+
fontFamily: defaultTheme.fontFamily,
|
|
92
|
+
fontSize: defaultTheme.fontSize,
|
|
93
|
+
transform: [{ translateY }],
|
|
94
|
+
},
|
|
95
|
+
]}>
|
|
96
|
+
{value}
|
|
97
|
+
</Animated.Text>
|
|
98
|
+
|
|
99
|
+
{/* Neighbour below */}
|
|
100
|
+
<Text style={[
|
|
101
|
+
styles.digit,
|
|
102
|
+
{
|
|
103
|
+
color: digitColor,
|
|
104
|
+
fontFamily: defaultTheme.fontFamily,
|
|
105
|
+
fontSize: defaultTheme.fontSize,
|
|
106
|
+
opacity: defaultTheme.neighbourOpacity,
|
|
107
|
+
position: 'absolute',
|
|
108
|
+
top: cellH,
|
|
109
|
+
width: cellW,
|
|
110
|
+
textAlign: 'center',
|
|
111
|
+
},
|
|
112
|
+
]}>
|
|
113
|
+
{below}
|
|
114
|
+
</Text>
|
|
115
|
+
</View>);
|
|
116
|
+
}
|
|
117
|
+
function hapticHeavy() {
|
|
118
|
+
import('../hooks/useHaptics').then(({ hapticHeavy: h }) => h());
|
|
119
|
+
}
|
|
120
|
+
const styles = StyleSheet.create({
|
|
121
|
+
container: {
|
|
122
|
+
overflow: 'hidden',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
justifyContent: 'center',
|
|
125
|
+
},
|
|
126
|
+
digit: {
|
|
127
|
+
textAlign: 'center',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=DigitWheel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DigitWheel.js","sourceRoot":"","sources":["../../src/components/DigitWheel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC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AC/B,OAAO,EAAE,YAAY,CAAC,gBAAgB;gBACtC,QAAQ,EAAE,UAAU;gBACpB,GAAG,EAAE,KAAK;gBACV,KAAK,EAAE,KAAK;gBACZ,SAAS,EAAE,QAAQ;aACpB;SACF,CAAC,CAEF;QAAA,CAAC,KAAK,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,SAAS,EAAE,QAAQ;KACpB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
separatorChar: string;
|
|
4
|
+
isPlacementMode: boolean;
|
|
5
|
+
onToggle: () => void;
|
|
6
|
+
visible: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function SeparatorControl({ separatorChar, isPlacementMode, onToggle, visible }: Props): React.JSX.Element | null;
|
|
9
|
+
type GapProps = {
|
|
10
|
+
onPress: () => void;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function SeparatorGap({ onPress, visible }: GapProps): React.JSX.Element | null;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=SeparatorControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeparatorControl.d.ts","sourceRoot":"","sources":["../../src/components/SeparatorControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,KAAK,KAAK,GAAG;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,KAAK,4BAU5F;AAED,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,QAAQ,4BAO1D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { defaultTheme } from '../theme/defaultTheme';
|
|
4
|
+
export function SeparatorControl({ separatorChar, isPlacementMode, onToggle, visible }) {
|
|
5
|
+
if (!visible)
|
|
6
|
+
return null;
|
|
7
|
+
return (<TouchableOpacity onPress={onToggle} style={styles.wrapper} activeOpacity={0.7}>
|
|
8
|
+
<View style={[styles.button, isPlacementMode && styles.active]}>
|
|
9
|
+
<Text style={styles.label}>{separatorChar}</Text>
|
|
10
|
+
</View>
|
|
11
|
+
</TouchableOpacity>);
|
|
12
|
+
}
|
|
13
|
+
export function SeparatorGap({ onPress, visible }) {
|
|
14
|
+
if (!visible)
|
|
15
|
+
return null;
|
|
16
|
+
return (<TouchableOpacity onPress={onPress} style={styles.gap} activeOpacity={0.5}>
|
|
17
|
+
<View style={styles.gapLine}/>
|
|
18
|
+
</TouchableOpacity>);
|
|
19
|
+
}
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
wrapper: {
|
|
22
|
+
marginHorizontal: 4,
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
},
|
|
26
|
+
button: {
|
|
27
|
+
width: 28,
|
|
28
|
+
height: 28,
|
|
29
|
+
borderRadius: 14,
|
|
30
|
+
borderWidth: 1,
|
|
31
|
+
borderColor: defaultTheme.separatorColor,
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
},
|
|
35
|
+
active: {
|
|
36
|
+
backgroundColor: defaultTheme.separatorColor,
|
|
37
|
+
},
|
|
38
|
+
label: {
|
|
39
|
+
color: defaultTheme.backgroundColor,
|
|
40
|
+
fontSize: 14,
|
|
41
|
+
fontFamily: defaultTheme.fontFamily,
|
|
42
|
+
},
|
|
43
|
+
gap: {
|
|
44
|
+
width: 16,
|
|
45
|
+
height: defaultTheme.digitCellHeight,
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
},
|
|
49
|
+
gapLine: {
|
|
50
|
+
width: 2,
|
|
51
|
+
height: 20,
|
|
52
|
+
backgroundColor: defaultTheme.separatorColor,
|
|
53
|
+
opacity: 0.6,
|
|
54
|
+
borderRadius: 1,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=SeparatorControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeparatorControl.js","sourceRoot":"","sources":["../../src/components/SeparatorControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AASrD,MAAM,UAAU,gBAAgB,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAS;IAC3F,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,OAAO,CACL,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CA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AAC,eAAe;QACnC,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY,CAAC,UAAU;KACpC;IACD,GAAG,EAAE;QACH,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,YAAY,CAAC,eAAe;QACpC,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;IACD,OAAO,EAAE;QACP,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,EAAE;QACV,eAAe,EAAE,YAAY,CAAC,cAAc;QAC5C,OAAO,EAAE,GAAG;QACZ,YAAY,EAAE,CAAC;KAChB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHaptics.d.ts","sourceRoot":"","sources":["../../src/hooks/useHaptics.ts"],"names":[],"mappings":"AAKA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAKlD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as ExpoHaptics from 'expo-haptics';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
const isWeb = Platform.OS === 'web';
|
|
4
|
+
export async function hapticLight() {
|
|
5
|
+
if (isWeb)
|
|
6
|
+
return;
|
|
7
|
+
try {
|
|
8
|
+
await ExpoHaptics.impactAsync(ExpoHaptics.ImpactFeedbackStyle.Light);
|
|
9
|
+
}
|
|
10
|
+
catch { }
|
|
11
|
+
}
|
|
12
|
+
export async function hapticMedium() {
|
|
13
|
+
if (isWeb)
|
|
14
|
+
return;
|
|
15
|
+
try {
|
|
16
|
+
await ExpoHaptics.impactAsync(ExpoHaptics.ImpactFeedbackStyle.Medium);
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
}
|
|
20
|
+
export async function hapticHeavy() {
|
|
21
|
+
if (isWeb)
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
await ExpoHaptics.impactAsync(ExpoHaptics.ImpactFeedbackStyle.Heavy);
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=useHaptics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHaptics.js","sourceRoot":"","sources":["../../src/hooks/useHaptics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,KAAK;QAAE,OAAO;IAClB,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAAC,MAAM,CAAC,CAAC,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,IAAI,KAAK;QAAE,OAAO;IAClB,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC,CAAC,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,KAAK;QAAE,OAAO;IAClB,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAAC,MAAM,CAAC,CAAC,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const defaultTheme: {
|
|
2
|
+
backgroundColor: string;
|
|
3
|
+
digitColor: string;
|
|
4
|
+
separatorColor: string;
|
|
5
|
+
addButtonBorderColor: string;
|
|
6
|
+
digitCellHeight: number;
|
|
7
|
+
digitCellWidth: number;
|
|
8
|
+
fontSize: number;
|
|
9
|
+
fontFamily: string;
|
|
10
|
+
addButtonSize: number;
|
|
11
|
+
neighbourOpacity: number;
|
|
12
|
+
scrollThreshold: number;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=defaultTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTheme.d.ts","sourceRoot":"","sources":["../../src/theme/defaultTheme.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;gBAYjB,MAAM;;;;CAIb,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
export const defaultTheme = {
|
|
3
|
+
backgroundColor: '#1A1A1A',
|
|
4
|
+
digitColor: '#FFFDE7',
|
|
5
|
+
separatorColor: '#FFFDE7',
|
|
6
|
+
addButtonBorderColor: '#FFFDE7',
|
|
7
|
+
digitCellHeight: 56,
|
|
8
|
+
digitCellWidth: 40,
|
|
9
|
+
fontSize: 32,
|
|
10
|
+
fontFamily: Platform.select({
|
|
11
|
+
ios: 'Courier New',
|
|
12
|
+
android: 'monospace',
|
|
13
|
+
default: 'monospace',
|
|
14
|
+
}),
|
|
15
|
+
addButtonSize: 32,
|
|
16
|
+
neighbourOpacity: 0.25,
|
|
17
|
+
scrollThreshold: 28,
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=defaultTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTheme.js","sourceRoot":"","sources":["../../src/theme/defaultTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe,EAAE,SAAS;IAC1B,UAAU,EAAE,SAAS;IACrB,cAAc,EAAE,SAAS;IACzB,oBAAoB,EAAE,SAAS;IAC/B,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,EAAE;IAClB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC;QAC1B,GAAG,EAAE,aAAa;QAClB,OAAO,EAAE,WAAW;QACpB,OAAO,EAAE,WAAW;KACrB,CAAW;IACZ,aAAa,EAAE,EAAE;IACjB,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,EAAE;CACpB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
export type ParsedValue = {
|
|
3
|
+
digits: number[];
|
|
4
|
+
separatorIndex: number | null;
|
|
5
|
+
separatorChar: '.' | ',';
|
|
6
|
+
};
|
|
7
|
+
export type NumberAdjusterProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (next: string) => void;
|
|
10
|
+
useComma?: boolean;
|
|
11
|
+
digitColor?: string;
|
|
12
|
+
backgroundColor?: string;
|
|
13
|
+
style?: ViewStyle;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,GAAG,GAAG,GAAG,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueHelpers.d.ts","sourceRoot":"","sources":["../src/valueHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,WAAW,CAYxE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAQ1D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function parseValue(value, useComma) {
|
|
2
|
+
const separatorChar = useComma ? ',' : '.';
|
|
3
|
+
const sepIndex = value.indexOf(separatorChar);
|
|
4
|
+
if (sepIndex !== -1) {
|
|
5
|
+
const raw = value.replace(separatorChar, '');
|
|
6
|
+
const digits = raw.split('').map(Number);
|
|
7
|
+
return { digits, separatorIndex: sepIndex, separatorChar };
|
|
8
|
+
}
|
|
9
|
+
const digits = value.split('').map(Number);
|
|
10
|
+
return { digits, separatorIndex: null, separatorChar };
|
|
11
|
+
}
|
|
12
|
+
export function serializeValue(parsed) {
|
|
13
|
+
const { digits, separatorIndex, separatorChar } = parsed;
|
|
14
|
+
if (separatorIndex === null) {
|
|
15
|
+
return digits.join('');
|
|
16
|
+
}
|
|
17
|
+
const left = digits.slice(0, separatorIndex).join('');
|
|
18
|
+
const right = digits.slice(separatorIndex).join('');
|
|
19
|
+
return `${left}${separatorChar}${right}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=valueHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueHelpers.js","sourceRoot":"","sources":["../src/valueHelpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,QAAiB;IACzD,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE9C,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC7D,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAmB;IAChD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACzD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,OAAO,GAAG,IAAI,GAAG,aAAa,GAAG,KAAK,EAAE,CAAC;AAC3C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-adjust-numbers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Touch-first odometer-style number adjuster for React Native / Expo",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc --project tsconfig.json",
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"test": "jest"
|
|
16
|
+
},
|
|
17
|
+
"jest": {
|
|
18
|
+
"preset": "ts-jest",
|
|
19
|
+
"testEnvironment": "node",
|
|
20
|
+
"transformIgnorePatterns": [
|
|
21
|
+
"node_modules/(?!(react-native|expo-haptics)/)"
|
|
22
|
+
],
|
|
23
|
+
"moduleNameMapper": {
|
|
24
|
+
"^react-native$": "<rootDir>/node_modules/react-native"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"expo": ">=54",
|
|
29
|
+
"expo-haptics": ">=14",
|
|
30
|
+
"react": ">=18",
|
|
31
|
+
"react-native": ">=0.76",
|
|
32
|
+
"react-native-gesture-handler": ">=2",
|
|
33
|
+
"react-native-reanimated": ">=3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/jest": "^29.0.0",
|
|
37
|
+
"@types/react": "^18.0.0",
|
|
38
|
+
"@types/react-native": "^0.73.0",
|
|
39
|
+
"expo-haptics": "^14.0.0",
|
|
40
|
+
"jest": "^29.0.0",
|
|
41
|
+
"react": "18.3.1",
|
|
42
|
+
"react-native": "0.76.5",
|
|
43
|
+
"ts-jest": "^29.0.0",
|
|
44
|
+
"typescript": "^5.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|