@idealyst/components 1.2.58 → 1.2.60
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 +3 -3
- package/src/Keyboard/Keyboard.native.ts +18 -0
- package/src/Keyboard/Keyboard.web.ts +80 -0
- package/src/Keyboard/index.native.ts +13 -0
- package/src/Keyboard/index.ts +13 -0
- package/src/Keyboard/types.ts +117 -0
- package/src/index.native.ts +12 -0
- package/src/index.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.60",
|
|
4
4
|
"description": "Shared component library for React and React Native",
|
|
5
5
|
"documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/components#readme",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"publish:npm": "npm publish"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@idealyst/theme": "^1.2.
|
|
59
|
+
"@idealyst/theme": "^1.2.60",
|
|
60
60
|
"@mdi/js": ">=7.0.0",
|
|
61
61
|
"@mdi/react": ">=1.0.0",
|
|
62
62
|
"@react-native-vector-icons/common": ">=12.0.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@idealyst/blur": "^1.2.40",
|
|
110
|
-
"@idealyst/theme": "^1.2.
|
|
110
|
+
"@idealyst/theme": "^1.2.60",
|
|
111
111
|
"@idealyst/tooling": "^1.2.30",
|
|
112
112
|
"@mdi/react": "^1.6.1",
|
|
113
113
|
"@types/react": "^19.1.0",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native implementation - re-exports the React Native Keyboard module.
|
|
3
|
+
*/
|
|
4
|
+
export { Keyboard } from 'react-native';
|
|
5
|
+
|
|
6
|
+
// Re-export types for convenience
|
|
7
|
+
export type {
|
|
8
|
+
KeyboardMetrics,
|
|
9
|
+
KeyboardEventEasing,
|
|
10
|
+
BaseKeyboardEvent,
|
|
11
|
+
AndroidKeyboardEvent,
|
|
12
|
+
IOSKeyboardEvent,
|
|
13
|
+
KeyboardEvent,
|
|
14
|
+
KeyboardEventName,
|
|
15
|
+
KeyboardEventListener,
|
|
16
|
+
KeyboardSubscription,
|
|
17
|
+
KeyboardStatic,
|
|
18
|
+
} from './types';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
KeyboardStatic,
|
|
3
|
+
KeyboardEventName,
|
|
4
|
+
KeyboardEventListener,
|
|
5
|
+
KeyboardSubscription,
|
|
6
|
+
KeyboardEvent,
|
|
7
|
+
KeyboardMetrics,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Web implementation of the Keyboard API.
|
|
12
|
+
* This is a noop implementation since web doesn't have a virtual keyboard API
|
|
13
|
+
* in the same way as React Native.
|
|
14
|
+
*
|
|
15
|
+
* All methods are safe to call but have no effect on web.
|
|
16
|
+
*/
|
|
17
|
+
export const Keyboard: KeyboardStatic = {
|
|
18
|
+
/**
|
|
19
|
+
* Noop on web - there's no virtual keyboard to dismiss.
|
|
20
|
+
* On web, you can blur the active element instead: document.activeElement?.blur()
|
|
21
|
+
*/
|
|
22
|
+
dismiss(): void {
|
|
23
|
+
// Noop on web
|
|
24
|
+
// Optionally blur the active element to simulate keyboard dismiss
|
|
25
|
+
if (typeof document !== 'undefined' && document.activeElement) {
|
|
26
|
+
(document.activeElement as HTMLElement).blur?.();
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Noop on web - returns a subscription that does nothing.
|
|
32
|
+
* The VirtualKeyboard API exists in some browsers but has limited support.
|
|
33
|
+
*/
|
|
34
|
+
addListener(
|
|
35
|
+
_eventType: KeyboardEventName,
|
|
36
|
+
_listener: KeyboardEventListener
|
|
37
|
+
): KeyboardSubscription {
|
|
38
|
+
// Return a noop subscription
|
|
39
|
+
return {
|
|
40
|
+
remove: () => {
|
|
41
|
+
// Noop
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Noop on web - no keyboard animations to sync with.
|
|
48
|
+
*/
|
|
49
|
+
scheduleLayoutAnimation(_event: KeyboardEvent): void {
|
|
50
|
+
// Noop on web
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Always returns false on web - no virtual keyboard visibility tracking.
|
|
55
|
+
*/
|
|
56
|
+
isVisible(): boolean {
|
|
57
|
+
return false;
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Always returns undefined on web - no keyboard metrics available.
|
|
62
|
+
*/
|
|
63
|
+
metrics(): KeyboardMetrics | undefined {
|
|
64
|
+
return undefined;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Re-export types for convenience
|
|
69
|
+
export type {
|
|
70
|
+
KeyboardMetrics,
|
|
71
|
+
KeyboardEventEasing,
|
|
72
|
+
BaseKeyboardEvent,
|
|
73
|
+
AndroidKeyboardEvent,
|
|
74
|
+
IOSKeyboardEvent,
|
|
75
|
+
KeyboardEvent,
|
|
76
|
+
KeyboardEventName,
|
|
77
|
+
KeyboardEventListener,
|
|
78
|
+
KeyboardSubscription,
|
|
79
|
+
KeyboardStatic,
|
|
80
|
+
} from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Keyboard } from './Keyboard.native';
|
|
2
|
+
export type {
|
|
3
|
+
KeyboardMetrics,
|
|
4
|
+
KeyboardEventEasing,
|
|
5
|
+
BaseKeyboardEvent,
|
|
6
|
+
AndroidKeyboardEvent,
|
|
7
|
+
IOSKeyboardEvent,
|
|
8
|
+
KeyboardEvent,
|
|
9
|
+
KeyboardEventName,
|
|
10
|
+
KeyboardEventListener,
|
|
11
|
+
KeyboardSubscription,
|
|
12
|
+
KeyboardStatic,
|
|
13
|
+
} from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Keyboard } from './Keyboard.web';
|
|
2
|
+
export type {
|
|
3
|
+
KeyboardMetrics,
|
|
4
|
+
KeyboardEventEasing,
|
|
5
|
+
BaseKeyboardEvent,
|
|
6
|
+
AndroidKeyboardEvent,
|
|
7
|
+
IOSKeyboardEvent,
|
|
8
|
+
KeyboardEvent,
|
|
9
|
+
KeyboardEventName,
|
|
10
|
+
KeyboardEventListener,
|
|
11
|
+
KeyboardSubscription,
|
|
12
|
+
KeyboardStatic,
|
|
13
|
+
} from './types';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard metrics describing the keyboard position and size.
|
|
3
|
+
*/
|
|
4
|
+
export interface KeyboardMetrics {
|
|
5
|
+
screenX: number;
|
|
6
|
+
screenY: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Easing values for keyboard animations.
|
|
13
|
+
*/
|
|
14
|
+
export type KeyboardEventEasing =
|
|
15
|
+
| 'easeIn'
|
|
16
|
+
| 'easeInEaseOut'
|
|
17
|
+
| 'easeOut'
|
|
18
|
+
| 'linear'
|
|
19
|
+
| 'keyboard';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base keyboard event properties available on all platforms.
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseKeyboardEvent {
|
|
25
|
+
duration: number;
|
|
26
|
+
easing: KeyboardEventEasing;
|
|
27
|
+
endCoordinates: KeyboardMetrics;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Android-specific keyboard event (duration is always 0).
|
|
32
|
+
*/
|
|
33
|
+
export interface AndroidKeyboardEvent extends BaseKeyboardEvent {
|
|
34
|
+
duration: 0;
|
|
35
|
+
easing: 'keyboard';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* iOS-specific keyboard event with additional properties.
|
|
40
|
+
*/
|
|
41
|
+
export interface IOSKeyboardEvent extends BaseKeyboardEvent {
|
|
42
|
+
startCoordinates: KeyboardMetrics;
|
|
43
|
+
isEventFromThisApp: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Keyboard event passed to listeners.
|
|
48
|
+
*/
|
|
49
|
+
export type KeyboardEvent = AndroidKeyboardEvent | IOSKeyboardEvent;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Keyboard event names.
|
|
53
|
+
* Note: 'keyboardWillShow' and 'keyboardWillHide' are iOS-only.
|
|
54
|
+
* On Android with adjustResize/adjustNothing, only 'keyboardDidShow' and 'keyboardDidHide' fire.
|
|
55
|
+
*/
|
|
56
|
+
export type KeyboardEventName =
|
|
57
|
+
| 'keyboardWillShow'
|
|
58
|
+
| 'keyboardDidShow'
|
|
59
|
+
| 'keyboardWillHide'
|
|
60
|
+
| 'keyboardDidHide'
|
|
61
|
+
| 'keyboardWillChangeFrame'
|
|
62
|
+
| 'keyboardDidChangeFrame';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Listener function for keyboard events.
|
|
66
|
+
*/
|
|
67
|
+
export type KeyboardEventListener = (event: KeyboardEvent) => void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Subscription returned by addListener, used to unsubscribe.
|
|
71
|
+
*/
|
|
72
|
+
export interface KeyboardSubscription {
|
|
73
|
+
remove(): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Static Keyboard API interface.
|
|
78
|
+
*/
|
|
79
|
+
export interface KeyboardStatic {
|
|
80
|
+
/**
|
|
81
|
+
* Dismisses the active keyboard and removes focus.
|
|
82
|
+
*/
|
|
83
|
+
dismiss(): void;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Connects a JavaScript function to an identified native keyboard notification event.
|
|
87
|
+
* Returns a subscription that can be used to unsubscribe.
|
|
88
|
+
*
|
|
89
|
+
* @param eventType - The keyboard event to listen for
|
|
90
|
+
* @param listener - Callback function when the event fires
|
|
91
|
+
* @returns Subscription with remove() method
|
|
92
|
+
*/
|
|
93
|
+
addListener(
|
|
94
|
+
eventType: KeyboardEventName,
|
|
95
|
+
listener: KeyboardEventListener
|
|
96
|
+
): KeyboardSubscription;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Useful for syncing TextInput (or other keyboard accessory view) size
|
|
100
|
+
* or position changes with keyboard movements.
|
|
101
|
+
*
|
|
102
|
+
* @param event - The keyboard event to schedule animation for
|
|
103
|
+
*/
|
|
104
|
+
scheduleLayoutAnimation(event: KeyboardEvent): void;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns whether the keyboard is last known to be visible.
|
|
108
|
+
*/
|
|
109
|
+
isVisible(): boolean;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns the metrics of the soft-keyboard if visible.
|
|
113
|
+
*
|
|
114
|
+
* @returns KeyboardMetrics if keyboard is visible, undefined otherwise
|
|
115
|
+
*/
|
|
116
|
+
metrics(): KeyboardMetrics | undefined;
|
|
117
|
+
}
|
package/src/index.native.ts
CHANGED
|
@@ -113,6 +113,9 @@ export * from './Link/types';
|
|
|
113
113
|
export { default as Platform } from './Platform';
|
|
114
114
|
export * from './Platform/types';
|
|
115
115
|
|
|
116
|
+
export { Keyboard } from './Keyboard';
|
|
117
|
+
export * from './Keyboard/types';
|
|
118
|
+
|
|
116
119
|
export type { ButtonProps } from './Button/types';
|
|
117
120
|
export type { IconButtonProps } from './IconButton/types';
|
|
118
121
|
export type { TextProps } from './Text/types';
|
|
@@ -149,6 +152,15 @@ export type { ChipProps, ChipSize, ChipIntent } from './Chip/types';
|
|
|
149
152
|
export type { BreadcrumbProps, BreadcrumbItem } from './Breadcrumb/types';
|
|
150
153
|
export type { LinkProps } from './Link/types';
|
|
151
154
|
export type { PlatformAPI, PlatformSystem, PlatformSelectSpec } from './Platform/types';
|
|
155
|
+
export type {
|
|
156
|
+
KeyboardMetrics,
|
|
157
|
+
KeyboardEventEasing,
|
|
158
|
+
KeyboardEvent,
|
|
159
|
+
KeyboardEventName,
|
|
160
|
+
KeyboardEventListener,
|
|
161
|
+
KeyboardSubscription,
|
|
162
|
+
KeyboardStatic,
|
|
163
|
+
} from './Keyboard/types';
|
|
152
164
|
|
|
153
165
|
// Event utilities
|
|
154
166
|
export * from './utils/events';
|
package/src/index.ts
CHANGED
|
@@ -121,6 +121,9 @@ export * from './Breadcrumb/types';
|
|
|
121
121
|
export { default as Platform } from './Platform';
|
|
122
122
|
export * from './Platform/types';
|
|
123
123
|
|
|
124
|
+
export { Keyboard } from './Keyboard';
|
|
125
|
+
export * from './Keyboard/types';
|
|
126
|
+
|
|
124
127
|
export type { ButtonProps } from './Button/types';
|
|
125
128
|
export type { IconButtonProps } from './IconButton/types';
|
|
126
129
|
export type { TextProps } from './Text/types';
|
|
@@ -158,6 +161,15 @@ export type { SkeletonProps, SkeletonGroupProps, SkeletonShape, SkeletonAnimatio
|
|
|
158
161
|
export type { ChipProps, ChipSize, ChipIntent } from './Chip/types';
|
|
159
162
|
export type { BreadcrumbProps, BreadcrumbItem } from './Breadcrumb/types';
|
|
160
163
|
export type { PlatformAPI, PlatformSystem, PlatformSelectSpec } from './Platform/types';
|
|
164
|
+
export type {
|
|
165
|
+
KeyboardMetrics,
|
|
166
|
+
KeyboardEventEasing,
|
|
167
|
+
KeyboardEvent,
|
|
168
|
+
KeyboardEventName,
|
|
169
|
+
KeyboardEventListener,
|
|
170
|
+
KeyboardSubscription,
|
|
171
|
+
KeyboardStatic,
|
|
172
|
+
} from './Keyboard/types';
|
|
161
173
|
|
|
162
174
|
export { useMergeRefs };
|
|
163
175
|
|