@klyftig/mobile-ui 1.2.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klyftig/mobile-ui",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "scripts": {
5
5
  "pack-install": "npm pack && mv klyftig-ui-*.tgz /tmp/klyftig-ui-local.tgz && cd ../../mobile && npm install /tmp/klyftig-ui-local.tgz"
6
6
  },
@@ -0,0 +1,95 @@
1
+ import React from 'react';
2
+ import {
3
+ Text,
4
+ StyleSheet,
5
+ TouchableOpacity,
6
+ StyleProp,
7
+ ViewStyle,
8
+ } from 'react-native';
9
+ import { MaterialCommunityIcons as Icon } from '@expo/vector-icons';
10
+ import { useTheme } from '../hooks/useTheme';
11
+
12
+ export interface DisclaimerPillProps {
13
+ message: string;
14
+ linkLabel?: string;
15
+ onPress?: () => void;
16
+ iconName?: React.ComponentProps<typeof Icon>['name'];
17
+ style?: StyleProp<ViewStyle>;
18
+ }
19
+
20
+ /**
21
+ * Compact footer pill with optional inline link. Used for medical/AI disclaimers
22
+ * that link to a sources/citations screen. Consumer wires up navigation via onPress.
23
+ */
24
+ export function DisclaimerPill({
25
+ message,
26
+ linkLabel,
27
+ onPress,
28
+ iconName = 'information-outline',
29
+ style,
30
+ }: DisclaimerPillProps) {
31
+ const { colors } = useTheme();
32
+ const content = (
33
+ <>
34
+ <Icon name={iconName} size={14} color={colors.text.tertiary} />
35
+ <Text style={[styles.text, { color: colors.text.tertiary }]}>
36
+ {message}
37
+ {linkLabel ? (
38
+ <>
39
+ {' '}
40
+ <Text
41
+ style={[
42
+ styles.link,
43
+ { color: colors.text.secondary },
44
+ ]}
45
+ >
46
+ {linkLabel}
47
+ </Text>
48
+ </>
49
+ ) : null}
50
+ </Text>
51
+ </>
52
+ );
53
+
54
+ if (onPress) {
55
+ return (
56
+ <TouchableOpacity
57
+ onPress={onPress}
58
+ activeOpacity={0.7}
59
+ accessibilityRole="button"
60
+ accessibilityLabel={linkLabel ? `${message} Tap to ${linkLabel}.` : message}
61
+ style={[styles.container, style]}
62
+ >
63
+ {content}
64
+ </TouchableOpacity>
65
+ );
66
+ }
67
+ return (
68
+ <TouchableOpacity
69
+ disabled
70
+ accessibilityLabel={message}
71
+ style={[styles.container, style]}
72
+ >
73
+ {content}
74
+ </TouchableOpacity>
75
+ );
76
+ }
77
+
78
+ const styles = StyleSheet.create({
79
+ container: {
80
+ flexDirection: 'row',
81
+ alignItems: 'center',
82
+ gap: 6,
83
+ paddingVertical: 8,
84
+ paddingHorizontal: 12,
85
+ },
86
+ text: {
87
+ flex: 1,
88
+ fontSize: 11,
89
+ lineHeight: 15,
90
+ },
91
+ link: {
92
+ fontWeight: '600',
93
+ textDecorationLine: 'underline',
94
+ },
95
+ });
@@ -11,12 +11,19 @@ interface GlassInputProps {
11
11
  secureTextEntry?: boolean;
12
12
  keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad';
13
13
  autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
14
+ // Off by default for fields where iOS would otherwise replace partially-edited
15
+ // multi-word values with its autocorrect suggestion and snap the caret to end.
16
+ autoCorrect?: boolean;
17
+ spellCheck?: boolean;
14
18
  disabled?: boolean;
15
19
  icon?: string;
16
20
  showPasswordToggle?: boolean;
17
21
  rightText?: string;
18
22
  textContentType?: 'none' | 'password' | 'newPassword' | 'emailAddress' | 'username' | 'oneTimeCode';
19
23
  autoComplete?: string;
24
+ onFocus?: () => void;
25
+ onBlur?: () => void;
26
+ selectTextOnFocus?: boolean;
20
27
  }
21
28
 
22
29
  const GlassInputComponent: React.FC<GlassInputProps> = ({
@@ -27,12 +34,17 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
27
34
  secureTextEntry = false,
28
35
  keyboardType = 'default',
29
36
  autoCapitalize = 'sentences',
37
+ autoCorrect,
38
+ spellCheck,
30
39
  disabled = false,
31
40
  icon,
32
41
  showPasswordToggle = false,
33
42
  rightText,
34
43
  textContentType,
35
44
  autoComplete,
45
+ onFocus,
46
+ onBlur,
47
+ selectTextOnFocus,
36
48
  }) => {
37
49
  const { colors } = useTheme();
38
50
  const [isSecure, setIsSecure] = useState(secureTextEntry);
@@ -40,11 +52,13 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
40
52
 
41
53
  const handleFocus = useCallback(() => {
42
54
  setIsFocused(true);
43
- }, []);
55
+ onFocus?.();
56
+ }, [onFocus]);
44
57
 
45
58
  const handleBlur = useCallback(() => {
46
59
  setIsFocused(false);
47
- }, []);
60
+ onBlur?.();
61
+ }, [onBlur]);
48
62
 
49
63
  const toggleSecure = useCallback(() => {
50
64
  setIsSecure(prev => !prev);
@@ -72,9 +86,12 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
72
86
  secureTextEntry={isSecure}
73
87
  keyboardType={keyboardType}
74
88
  autoCapitalize={autoCapitalize}
89
+ autoCorrect={autoCorrect}
90
+ spellCheck={spellCheck}
75
91
  editable={!disabled}
76
92
  onFocus={handleFocus}
77
93
  onBlur={handleBlur}
94
+ selectTextOnFocus={selectTextOnFocus}
78
95
  textContentType={textContentType ?? (secureTextEntry ? 'oneTimeCode' : undefined)}
79
96
  autoComplete={autoComplete as any}
80
97
  accessibilityLabel={label}
@@ -0,0 +1,126 @@
1
+ import React, { useEffect, useMemo, useRef } from 'react';
2
+ import {
3
+ ScrollView,
4
+ View,
5
+ Text,
6
+ StyleSheet,
7
+ NativeSyntheticEvent,
8
+ NativeScrollEvent,
9
+ } from 'react-native';
10
+ import { useTheme } from '../hooks/useTheme';
11
+
12
+ export interface WheelPickerProps {
13
+ values: number[];
14
+ selected: number;
15
+ onChange: (value: number) => void;
16
+ formatLabel?: (value: number) => string;
17
+ itemHeight?: number;
18
+ visibleCount?: number;
19
+ width?: number;
20
+ flex?: number;
21
+ }
22
+
23
+ const DEFAULT_ITEM_HEIGHT = 48;
24
+ const DEFAULT_VISIBLE_COUNT = 5;
25
+
26
+ export function WheelPicker({
27
+ values,
28
+ selected,
29
+ onChange,
30
+ formatLabel,
31
+ itemHeight = DEFAULT_ITEM_HEIGHT,
32
+ visibleCount = DEFAULT_VISIBLE_COUNT,
33
+ width,
34
+ flex,
35
+ }: WheelPickerProps) {
36
+ const { colors } = useTheme();
37
+ const scrollRef = useRef<ScrollView>(null);
38
+ const containerHeight = itemHeight * visibleCount;
39
+ const padding = (containerHeight - itemHeight) / 2;
40
+ const lastIndexRef = useRef<number>(-1);
41
+
42
+ const selectedIndex = useMemo(() => {
43
+ const idx = values.indexOf(selected);
44
+ return idx >= 0 ? idx : 0;
45
+ }, [values, selected]);
46
+
47
+ useEffect(() => {
48
+ if (selectedIndex !== lastIndexRef.current) {
49
+ lastIndexRef.current = selectedIndex;
50
+ requestAnimationFrame(() => {
51
+ scrollRef.current?.scrollTo({ y: selectedIndex * itemHeight, animated: false });
52
+ });
53
+ }
54
+ }, [selectedIndex, itemHeight]);
55
+
56
+ const handleMomentumEnd = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
57
+ const offsetY = e.nativeEvent.contentOffset.y;
58
+ const index = Math.round(offsetY / itemHeight);
59
+ const clamped = Math.max(0, Math.min(values.length - 1, index));
60
+ if (values[clamped] !== selected) {
61
+ onChange(values[clamped]);
62
+ }
63
+ };
64
+
65
+ return (
66
+ <View style={[styles.wrapper, { height: containerHeight, width, flex }]}>
67
+ <View
68
+ pointerEvents="none"
69
+ style={[
70
+ styles.selectionOverlay,
71
+ { top: padding, height: itemHeight, backgroundColor: 'rgba(0,0,0,0.06)' },
72
+ ]}
73
+ />
74
+ <ScrollView
75
+ ref={scrollRef}
76
+ showsVerticalScrollIndicator={false}
77
+ snapToInterval={itemHeight}
78
+ decelerationRate="fast"
79
+ contentContainerStyle={{ paddingTop: padding, paddingBottom: padding }}
80
+ onMomentumScrollEnd={handleMomentumEnd}
81
+ nestedScrollEnabled
82
+ contentOffset={{ x: 0, y: selectedIndex * itemHeight }}
83
+ >
84
+ {values.map((item, index) => {
85
+ const isSelected = index === selectedIndex;
86
+ return (
87
+ <View key={item} style={[styles.item, { height: itemHeight }]}>
88
+ <Text
89
+ style={[
90
+ styles.itemText,
91
+ {
92
+ color: isSelected ? colors.text.primary : colors.text.tertiary,
93
+ },
94
+ ]}
95
+ >
96
+ {formatLabel ? formatLabel(item) : String(item)}
97
+ </Text>
98
+ </View>
99
+ );
100
+ })}
101
+ </ScrollView>
102
+ </View>
103
+ );
104
+ }
105
+
106
+ const styles = StyleSheet.create({
107
+ wrapper: {
108
+ position: 'relative',
109
+ overflow: 'hidden',
110
+ },
111
+ selectionOverlay: {
112
+ position: 'absolute',
113
+ left: 8,
114
+ right: 8,
115
+ borderRadius: 12,
116
+ zIndex: 0,
117
+ },
118
+ item: {
119
+ alignItems: 'center',
120
+ justifyContent: 'center',
121
+ },
122
+ itemText: {
123
+ fontSize: 22,
124
+ fontWeight: '600',
125
+ },
126
+ });
package/src/index.ts CHANGED
@@ -40,6 +40,10 @@ export { ErrorState } from './components/ErrorState';
40
40
  export type { ErrorStateProps } from './components/ErrorState';
41
41
  export { LoadingState } from './components/LoadingState';
42
42
  export type { LoadingStateProps } from './components/LoadingState';
43
+ export { WheelPicker } from './components/WheelPicker';
44
+ export type { WheelPickerProps } from './components/WheelPicker';
45
+ export { DisclaimerPill } from './components/DisclaimerPill';
46
+ export type { DisclaimerPillProps } from './components/DisclaimerPill';
43
47
 
44
48
  // Progress
45
49
  export { CircularProgress } from './components/progress/CircularProgress';