@qafka/react-native 2.0.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/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +22 -0
- package/README.md +109 -0
- package/SECURITY.md +67 -0
- package/android/build.gradle +35 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/qafka/attestation/QafkaAttestationModule.kt +92 -0
- package/android/src/main/java/com/qafka/attestation/QafkaAttestationPackage.kt +22 -0
- package/android/src/main/java/com/qafka/audio/QafkaAudioModule.kt +290 -0
- package/android/src/main/java/com/qafka/clipboard/QafkaClipboardModule.kt +28 -0
- package/android/src/main/java/com/qafka/storage/QafkaStorageModule.kt +80 -0
- package/app.plugin.js +1 -0
- package/dist/QafkaSDK.d.ts +174 -0
- package/dist/QafkaSDK.js +461 -0
- package/dist/cards/bindings/resolveFieldName.d.ts +25 -0
- package/dist/cards/bindings/resolveFieldName.js +82 -0
- package/dist/cards/cta/CardContext.d.ts +16 -0
- package/dist/cards/cta/CardContext.js +58 -0
- package/dist/cards/cta/dispatcher.d.ts +7 -0
- package/dist/cards/cta/dispatcher.js +90 -0
- package/dist/cards/cta/types.d.ts +66 -0
- package/dist/cards/cta/types.js +2 -0
- package/dist/cards/index.d.ts +20 -0
- package/dist/cards/index.js +34 -0
- package/dist/cards/primitives/QButton.d.ts +10 -0
- package/dist/cards/primitives/QButton.js +115 -0
- package/dist/cards/primitives/QDivider.d.ts +7 -0
- package/dist/cards/primitives/QDivider.js +17 -0
- package/dist/cards/primitives/QIcon.d.ts +13 -0
- package/dist/cards/primitives/QIcon.js +26 -0
- package/dist/cards/primitives/QImage.d.ts +9 -0
- package/dist/cards/primitives/QImage.js +22 -0
- package/dist/cards/primitives/QText.d.ts +9 -0
- package/dist/cards/primitives/QText.js +30 -0
- package/dist/cards/primitives/QView.d.ts +8 -0
- package/dist/cards/primitives/QView.js +19 -0
- package/dist/cards/renderer/CardRenderer.d.ts +19 -0
- package/dist/cards/renderer/CardRenderer.js +64 -0
- package/dist/cards/renderer/renderNode.d.ts +13 -0
- package/dist/cards/renderer/renderNode.js +42 -0
- package/dist/cards/types.d.ts +110 -0
- package/dist/cards/types.js +6 -0
- package/dist/components/ActionResultBadge.d.ts +12 -0
- package/dist/components/ActionResultBadge.js +58 -0
- package/dist/components/ChatPage.d.ts +44 -0
- package/dist/components/ChatPage.js +84 -0
- package/dist/components/DataChip.d.ts +8 -0
- package/dist/components/DataChip.js +80 -0
- package/dist/components/DataChipList.d.ts +13 -0
- package/dist/components/DataChipList.js +21 -0
- package/dist/components/FloatingButton.d.ts +11 -0
- package/dist/components/FloatingButton.js +162 -0
- package/dist/components/InputArea.d.ts +57 -0
- package/dist/components/InputArea.js +142 -0
- package/dist/components/MarkdownText.d.ts +15 -0
- package/dist/components/MarkdownText.js +283 -0
- package/dist/components/MessageBubble.d.ts +134 -0
- package/dist/components/MessageBubble.js +384 -0
- package/dist/components/NavigationSuggestion.d.ts +11 -0
- package/dist/components/NavigationSuggestion.js +109 -0
- package/dist/components/Qafka.d.ts +39 -0
- package/dist/components/Qafka.handlers.d.ts +21 -0
- package/dist/components/Qafka.handlers.js +54 -0
- package/dist/components/Qafka.js +493 -0
- package/dist/components/Qafka.styles.d.ts +19 -0
- package/dist/components/Qafka.styles.js +101 -0
- package/dist/components/Qafka.types.d.ts +744 -0
- package/dist/components/Qafka.types.js +2 -0
- package/dist/components/Qafka.utils.d.ts +7 -0
- package/dist/components/Qafka.utils.js +34 -0
- package/dist/components/QafkaProvider.d.ts +12 -0
- package/dist/components/QafkaProvider.js +87 -0
- package/dist/components/QuickReplies.d.ts +14 -0
- package/dist/components/QuickReplies.js +48 -0
- package/dist/components/StepProgressIndicator.d.ts +12 -0
- package/dist/components/StepProgressIndicator.js +48 -0
- package/dist/components/SuggestionButton.d.ts +42 -0
- package/dist/components/SuggestionButton.js +67 -0
- package/dist/components/ToolStatusPill.d.ts +20 -0
- package/dist/components/ToolStatusPill.js +43 -0
- package/dist/components/TypingIndicator.d.ts +28 -0
- package/dist/components/TypingIndicator.js +109 -0
- package/dist/components/VoicePage.d.ts +48 -0
- package/dist/components/VoicePage.js +683 -0
- package/dist/components/defaults/DefaultCard.d.ts +14 -0
- package/dist/components/defaults/DefaultCard.js +156 -0
- package/dist/components/defaults/DefaultDetail.d.ts +14 -0
- package/dist/components/defaults/DefaultDetail.js +138 -0
- package/dist/components/defaults/DefaultList.d.ts +12 -0
- package/dist/components/defaults/DefaultList.js +98 -0
- package/dist/components/defaults/DefaultTable.d.ts +14 -0
- package/dist/components/defaults/DefaultTable.js +204 -0
- package/dist/components/defaults/index.d.ts +14 -0
- package/dist/components/defaults/index.js +25 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +36 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +13 -0
- package/dist/hooks/useChatMessages.d.ts +72 -0
- package/dist/hooks/useChatMessages.js +505 -0
- package/dist/hooks/useContextManager.d.ts +12 -0
- package/dist/hooks/useContextManager.js +46 -0
- package/dist/hooks/useProjectTheme.d.ts +19 -0
- package/dist/hooks/useProjectTheme.js +163 -0
- package/dist/hooks/useSDK.d.ts +31 -0
- package/dist/hooks/useSDK.js +103 -0
- package/dist/hooks/useVoiceChat.d.ts +110 -0
- package/dist/hooks/useVoiceChat.js +436 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +59 -0
- package/dist/native/QafkaAttestation.d.ts +23 -0
- package/dist/native/QafkaAttestation.js +70 -0
- package/dist/native/QafkaAudio.d.ts +14 -0
- package/dist/native/QafkaAudio.js +31 -0
- package/dist/native/QafkaClipboard.d.ts +11 -0
- package/dist/native/QafkaClipboard.js +14 -0
- package/dist/native/QafkaStorage.d.ts +15 -0
- package/dist/native/QafkaStorage.js +12 -0
- package/dist/resolve-project-config.d.ts +35 -0
- package/dist/resolve-project-config.js +41 -0
- package/dist/runtime-config-loader.d.ts +37 -0
- package/dist/runtime-config-loader.js +53 -0
- package/dist/services/AttestationManager.d.ts +38 -0
- package/dist/services/AttestationManager.js +296 -0
- package/dist/services/BackendService.d.ts +156 -0
- package/dist/services/BackendService.js +755 -0
- package/dist/services/ConversationManager.d.ts +43 -0
- package/dist/services/ConversationManager.js +96 -0
- package/dist/services/NavigationHandler.d.ts +29 -0
- package/dist/services/NavigationHandler.js +70 -0
- package/dist/services/RealtimeService.d.ts +83 -0
- package/dist/services/RealtimeService.js +203 -0
- package/dist/services/storage.d.ts +11 -0
- package/dist/services/storage.js +15 -0
- package/dist/services/storageCore.d.ts +17 -0
- package/dist/services/storageCore.js +46 -0
- package/dist/themes/dark.d.ts +5 -0
- package/dist/themes/dark.js +129 -0
- package/dist/themes/index.d.ts +12 -0
- package/dist/themes/index.js +33 -0
- package/dist/themes/light.d.ts +5 -0
- package/dist/themes/light.js +129 -0
- package/dist/themes/types.d.ts +155 -0
- package/dist/themes/types.js +5 -0
- package/dist/types/chat.d.ts +126 -0
- package/dist/types/chat.js +5 -0
- package/dist/types/components.d.ts +56 -0
- package/dist/types/components.js +16 -0
- package/dist/types/external-navigation.d.ts +19 -0
- package/dist/types/external-navigation.js +8 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +25 -0
- package/dist/types/navigation.d.ts +86 -0
- package/dist/types/navigation.js +5 -0
- package/dist/types/sdk.d.ts +36 -0
- package/dist/types/sdk.js +5 -0
- package/dist/utils/deepMerge.d.ts +46 -0
- package/dist/utils/deepMerge.js +70 -0
- package/dist/utils/fontUtils.d.ts +8 -0
- package/dist/utils/fontUtils.js +16 -0
- package/dist/validate-end-user.d.ts +18 -0
- package/dist/validate-end-user.js +74 -0
- package/expo-plugin/withQafkaAttestation.js +57 -0
- package/ios/QafkaAttestation.m +25 -0
- package/ios/QafkaAttestation.swift +128 -0
- package/ios/QafkaAudio.m +23 -0
- package/ios/QafkaAudio.swift +519 -0
- package/ios/QafkaClipboard.m +10 -0
- package/ios/QafkaClipboard.swift +21 -0
- package/ios/QafkaReactImports.h +2 -0
- package/ios/QafkaStorage.m +26 -0
- package/ios/QafkaStorage.swift +118 -0
- package/package.json +82 -0
- package/qafka.config.d.ts +9 -0
- package/qafka.config.js +9 -0
- package/react-native-qafka.podspec +28 -0
- package/react-native.config.js +14 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DefaultCard Component
|
|
3
|
+
*
|
|
4
|
+
* Generic card component for displaying single data items.
|
|
5
|
+
* Used as fallback when no custom component is registered.
|
|
6
|
+
*
|
|
7
|
+
* Displays:
|
|
8
|
+
* - Title (from first string field or 'title', 'name', 'label')
|
|
9
|
+
* - Description (from 'description', 'subtitle', 'content')
|
|
10
|
+
* - Key-value pairs for remaining fields
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { ToolComponentProps } from '../../types/components';
|
|
14
|
+
export declare function DefaultCard({ data, theme }: ToolComponentProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DefaultCard Component
|
|
4
|
+
*
|
|
5
|
+
* Generic card component for displaying single data items.
|
|
6
|
+
* Used as fallback when no custom component is registered.
|
|
7
|
+
*
|
|
8
|
+
* Displays:
|
|
9
|
+
* - Title (from first string field or 'title', 'name', 'label')
|
|
10
|
+
* - Description (from 'description', 'subtitle', 'content')
|
|
11
|
+
* - Key-value pairs for remaining fields
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DefaultCard = DefaultCard;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const react_native_1 = require("react-native");
|
|
20
|
+
function DefaultCard({ data, theme }) {
|
|
21
|
+
if (!data || typeof data !== 'object') {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
// Helper: Get value from possible field names
|
|
25
|
+
const getField = (possibleNames) => {
|
|
26
|
+
for (const name of possibleNames) {
|
|
27
|
+
if (data[name] !== undefined && data[name] !== null) {
|
|
28
|
+
return data[name];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
// Extract common fields
|
|
34
|
+
const title = getField(['title', 'name', 'label', 'heading']);
|
|
35
|
+
const description = getField(['description', 'subtitle', 'content', 'text', 'body']);
|
|
36
|
+
const imageUrl = getField(['imageUrl', 'image', 'thumbnail', 'photo', 'picture']);
|
|
37
|
+
// Get remaining fields (exclude known fields)
|
|
38
|
+
const excludedFields = [
|
|
39
|
+
'id', '_id', 'title', 'name', 'label', 'heading',
|
|
40
|
+
'description', 'subtitle', 'content', 'text', 'body',
|
|
41
|
+
'imageUrl', 'image', 'thumbnail', 'photo', 'picture',
|
|
42
|
+
'createdAt', 'updatedAt', '__v'
|
|
43
|
+
];
|
|
44
|
+
const remainingFields = Object.keys(data)
|
|
45
|
+
.filter(key => !excludedFields.includes(key))
|
|
46
|
+
.slice(0, 5); // Max 5 additional fields
|
|
47
|
+
const spacing = theme?.spacing?.md || 12;
|
|
48
|
+
const borderRadius = theme?.borderRadius?.md || 8;
|
|
49
|
+
return (<react_native_1.View style={[
|
|
50
|
+
styles.container,
|
|
51
|
+
{
|
|
52
|
+
backgroundColor: theme?.colors?.surface || '#f5f5f5',
|
|
53
|
+
padding: spacing,
|
|
54
|
+
borderRadius,
|
|
55
|
+
borderWidth: 1,
|
|
56
|
+
borderColor: theme?.colors?.border || '#e0e0e0',
|
|
57
|
+
}
|
|
58
|
+
]}>
|
|
59
|
+
{/* Title */}
|
|
60
|
+
{title && (<react_native_1.Text style={[
|
|
61
|
+
styles.title,
|
|
62
|
+
{
|
|
63
|
+
color: theme?.colors?.text || '#000000',
|
|
64
|
+
fontSize: theme?.typography?.fontSize?.md || 16,
|
|
65
|
+
fontWeight: theme?.typography?.fontWeight?.semibold || '600',
|
|
66
|
+
}
|
|
67
|
+
]}>
|
|
68
|
+
{String(title)}
|
|
69
|
+
</react_native_1.Text>)}
|
|
70
|
+
|
|
71
|
+
{/* Description */}
|
|
72
|
+
{description && (<react_native_1.Text style={[
|
|
73
|
+
styles.description,
|
|
74
|
+
{
|
|
75
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
76
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
77
|
+
marginTop: theme?.spacing?.xs || 4,
|
|
78
|
+
}
|
|
79
|
+
]} numberOfLines={3}>
|
|
80
|
+
{String(description)}
|
|
81
|
+
</react_native_1.Text>)}
|
|
82
|
+
|
|
83
|
+
{/* Image placeholder */}
|
|
84
|
+
{imageUrl && (<react_native_1.View style={[
|
|
85
|
+
styles.imagePlaceholder,
|
|
86
|
+
{
|
|
87
|
+
marginTop: theme?.spacing?.sm || 8,
|
|
88
|
+
padding: theme?.spacing?.sm || 8,
|
|
89
|
+
backgroundColor: theme?.colors?.background || '#ffffff',
|
|
90
|
+
borderRadius: theme?.borderRadius?.sm || 4,
|
|
91
|
+
}
|
|
92
|
+
]}>
|
|
93
|
+
<react_native_1.Text style={{
|
|
94
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
95
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
96
|
+
}}>
|
|
97
|
+
🖼️ {String(imageUrl).substring(0, 40)}...
|
|
98
|
+
</react_native_1.Text>
|
|
99
|
+
</react_native_1.View>)}
|
|
100
|
+
|
|
101
|
+
{/* Additional Fields */}
|
|
102
|
+
{remainingFields.length > 0 && (<react_native_1.View style={{ marginTop: theme?.spacing?.sm || 8 }}>
|
|
103
|
+
{remainingFields.map(key => {
|
|
104
|
+
const value = data[key];
|
|
105
|
+
if (value === undefined || value === null)
|
|
106
|
+
return null;
|
|
107
|
+
return (<react_native_1.View key={key} style={styles.fieldRow}>
|
|
108
|
+
<react_native_1.Text style={[
|
|
109
|
+
styles.fieldLabel,
|
|
110
|
+
{
|
|
111
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
112
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
113
|
+
}
|
|
114
|
+
]}>
|
|
115
|
+
{key}:
|
|
116
|
+
</react_native_1.Text>
|
|
117
|
+
<react_native_1.Text style={[
|
|
118
|
+
styles.fieldValue,
|
|
119
|
+
{
|
|
120
|
+
color: theme?.colors?.text || '#000000',
|
|
121
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
122
|
+
}
|
|
123
|
+
]} numberOfLines={1}>
|
|
124
|
+
{typeof value === 'object' ? JSON.stringify(value) : String(value)}
|
|
125
|
+
</react_native_1.Text>
|
|
126
|
+
</react_native_1.View>);
|
|
127
|
+
})}
|
|
128
|
+
</react_native_1.View>)}
|
|
129
|
+
</react_native_1.View>);
|
|
130
|
+
}
|
|
131
|
+
const styles = react_native_1.StyleSheet.create({
|
|
132
|
+
container: {
|
|
133
|
+
width: '100%',
|
|
134
|
+
},
|
|
135
|
+
title: {
|
|
136
|
+
marginBottom: 4,
|
|
137
|
+
},
|
|
138
|
+
description: {
|
|
139
|
+
lineHeight: 20,
|
|
140
|
+
},
|
|
141
|
+
imagePlaceholder: {
|
|
142
|
+
alignItems: 'center',
|
|
143
|
+
justifyContent: 'center',
|
|
144
|
+
},
|
|
145
|
+
fieldRow: {
|
|
146
|
+
flexDirection: 'row',
|
|
147
|
+
marginTop: 4,
|
|
148
|
+
},
|
|
149
|
+
fieldLabel: {
|
|
150
|
+
fontWeight: '500',
|
|
151
|
+
marginRight: 4,
|
|
152
|
+
},
|
|
153
|
+
fieldValue: {
|
|
154
|
+
flex: 1,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DefaultDetail Component
|
|
3
|
+
*
|
|
4
|
+
* Generic detail component for displaying single object with all fields.
|
|
5
|
+
* Used as fallback when no custom component is registered.
|
|
6
|
+
*
|
|
7
|
+
* Displays:
|
|
8
|
+
* - All key-value pairs in a detailed view
|
|
9
|
+
* - Nested objects are stringified
|
|
10
|
+
* - Special formatting for dates, numbers, booleans
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { ToolComponentProps } from '../../types/components';
|
|
14
|
+
export declare function DefaultDetail({ data, theme }: ToolComponentProps): React.JSX.Element;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DefaultDetail Component
|
|
4
|
+
*
|
|
5
|
+
* Generic detail component for displaying single object with all fields.
|
|
6
|
+
* Used as fallback when no custom component is registered.
|
|
7
|
+
*
|
|
8
|
+
* Displays:
|
|
9
|
+
* - All key-value pairs in a detailed view
|
|
10
|
+
* - Nested objects are stringified
|
|
11
|
+
* - Special formatting for dates, numbers, booleans
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DefaultDetail = DefaultDetail;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const react_native_1 = require("react-native");
|
|
20
|
+
function DefaultDetail({ data, theme }) {
|
|
21
|
+
if (!data || typeof data !== 'object') {
|
|
22
|
+
return (<react_native_1.Text style={{
|
|
23
|
+
color: theme?.colors?.text || '#000000',
|
|
24
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
25
|
+
}}>
|
|
26
|
+
{String(data)}
|
|
27
|
+
</react_native_1.Text>);
|
|
28
|
+
}
|
|
29
|
+
// Format value for display
|
|
30
|
+
const formatValue = (value) => {
|
|
31
|
+
if (value === null || value === undefined) {
|
|
32
|
+
return 'N/A';
|
|
33
|
+
}
|
|
34
|
+
// Boolean
|
|
35
|
+
if (typeof value === 'boolean') {
|
|
36
|
+
return value ? '✓ Yes' : '✗ No';
|
|
37
|
+
}
|
|
38
|
+
// Number
|
|
39
|
+
if (typeof value === 'number') {
|
|
40
|
+
return value.toLocaleString();
|
|
41
|
+
}
|
|
42
|
+
// Date
|
|
43
|
+
if (value instanceof Date) {
|
|
44
|
+
return value.toLocaleString();
|
|
45
|
+
}
|
|
46
|
+
// Array
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
return `[${value.length} items]`;
|
|
49
|
+
}
|
|
50
|
+
// Object
|
|
51
|
+
if (typeof value === 'object') {
|
|
52
|
+
return JSON.stringify(value, null, 2);
|
|
53
|
+
}
|
|
54
|
+
return String(value);
|
|
55
|
+
};
|
|
56
|
+
// Format field name (camelCase to Title Case)
|
|
57
|
+
const formatFieldName = (key) => {
|
|
58
|
+
return key
|
|
59
|
+
.replace(/([A-Z])/g, ' $1')
|
|
60
|
+
.replace(/^./, str => str.toUpperCase())
|
|
61
|
+
.trim();
|
|
62
|
+
};
|
|
63
|
+
// Get all fields (excluding internal fields)
|
|
64
|
+
const excludedFields = ['_id', '__v'];
|
|
65
|
+
const fields = Object.keys(data).filter(key => !excludedFields.includes(key));
|
|
66
|
+
const spacing = theme?.spacing?.md || 12;
|
|
67
|
+
const borderRadius = theme?.borderRadius?.md || 8;
|
|
68
|
+
return (<react_native_1.View style={[
|
|
69
|
+
styles.container,
|
|
70
|
+
{
|
|
71
|
+
backgroundColor: theme?.colors?.surface || '#f5f5f5',
|
|
72
|
+
padding: spacing,
|
|
73
|
+
borderRadius,
|
|
74
|
+
borderWidth: 1,
|
|
75
|
+
borderColor: theme?.colors?.border || '#e0e0e0',
|
|
76
|
+
}
|
|
77
|
+
]}>
|
|
78
|
+
<react_native_1.ScrollView style={styles.scrollView} nestedScrollEnabled showsVerticalScrollIndicator={false}>
|
|
79
|
+
{fields.map((key, index) => {
|
|
80
|
+
const value = data[key];
|
|
81
|
+
const isObject = typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
82
|
+
return (<react_native_1.View key={key} style={[
|
|
83
|
+
styles.field,
|
|
84
|
+
{
|
|
85
|
+
marginBottom: theme?.spacing?.sm || 8,
|
|
86
|
+
paddingBottom: theme?.spacing?.sm || 8,
|
|
87
|
+
borderBottomWidth: index < fields.length - 1 ? 1 : 0,
|
|
88
|
+
borderBottomColor: theme?.colors?.border || '#e0e0e0',
|
|
89
|
+
}
|
|
90
|
+
]}>
|
|
91
|
+
{/* Field Label */}
|
|
92
|
+
<react_native_1.Text style={[
|
|
93
|
+
styles.fieldLabel,
|
|
94
|
+
{
|
|
95
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
96
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
97
|
+
fontWeight: theme?.typography?.fontWeight?.medium || '500',
|
|
98
|
+
}
|
|
99
|
+
]}>
|
|
100
|
+
{formatFieldName(key)}
|
|
101
|
+
</react_native_1.Text>
|
|
102
|
+
|
|
103
|
+
{/* Field Value */}
|
|
104
|
+
<react_native_1.Text style={[
|
|
105
|
+
styles.fieldValue,
|
|
106
|
+
{
|
|
107
|
+
color: theme?.colors?.text || '#000000',
|
|
108
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
109
|
+
marginTop: theme?.spacing?.xs || 4,
|
|
110
|
+
fontFamily: isObject ? 'monospace' : undefined,
|
|
111
|
+
}
|
|
112
|
+
]}>
|
|
113
|
+
{formatValue(value)}
|
|
114
|
+
</react_native_1.Text>
|
|
115
|
+
</react_native_1.View>);
|
|
116
|
+
})}
|
|
117
|
+
</react_native_1.ScrollView>
|
|
118
|
+
</react_native_1.View>);
|
|
119
|
+
}
|
|
120
|
+
const styles = react_native_1.StyleSheet.create({
|
|
121
|
+
container: {
|
|
122
|
+
width: '100%',
|
|
123
|
+
maxHeight: 400,
|
|
124
|
+
},
|
|
125
|
+
scrollView: {
|
|
126
|
+
flex: 1,
|
|
127
|
+
},
|
|
128
|
+
field: {
|
|
129
|
+
width: '100%',
|
|
130
|
+
},
|
|
131
|
+
fieldLabel: {
|
|
132
|
+
textTransform: 'uppercase',
|
|
133
|
+
letterSpacing: 0.5,
|
|
134
|
+
},
|
|
135
|
+
fieldValue: {
|
|
136
|
+
lineHeight: 20,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DefaultList Component
|
|
3
|
+
*
|
|
4
|
+
* Generic list component for displaying array of items.
|
|
5
|
+
* Used as fallback when no custom component is registered.
|
|
6
|
+
*
|
|
7
|
+
* Renders each item as a simple text representation or
|
|
8
|
+
* uses DefaultCard for object items.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { ToolComponentProps } from '../../types/components';
|
|
12
|
+
export declare function DefaultList({ data, theme }: ToolComponentProps): React.JSX.Element;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DefaultList Component
|
|
4
|
+
*
|
|
5
|
+
* Generic list component for displaying array of items.
|
|
6
|
+
* Used as fallback when no custom component is registered.
|
|
7
|
+
*
|
|
8
|
+
* Renders each item as a simple text representation or
|
|
9
|
+
* uses DefaultCard for object items.
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DefaultList = DefaultList;
|
|
16
|
+
const react_1 = __importDefault(require("react"));
|
|
17
|
+
const react_native_1 = require("react-native");
|
|
18
|
+
const DefaultCard_1 = require("./DefaultCard");
|
|
19
|
+
function DefaultList({ data, theme }) {
|
|
20
|
+
// If data is not an array, try to render as single item
|
|
21
|
+
if (!Array.isArray(data)) {
|
|
22
|
+
if (typeof data === 'object' && data !== null) {
|
|
23
|
+
return <DefaultCard_1.DefaultCard data={data} theme={theme}/>;
|
|
24
|
+
}
|
|
25
|
+
return (<react_native_1.Text style={{
|
|
26
|
+
color: theme?.colors?.text || '#000000',
|
|
27
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
28
|
+
}}>
|
|
29
|
+
{String(data)}
|
|
30
|
+
</react_native_1.Text>);
|
|
31
|
+
}
|
|
32
|
+
// Empty list
|
|
33
|
+
if (data.length === 0) {
|
|
34
|
+
return (<react_native_1.View style={[
|
|
35
|
+
styles.emptyContainer,
|
|
36
|
+
{
|
|
37
|
+
padding: theme?.spacing?.md || 12,
|
|
38
|
+
backgroundColor: theme?.colors?.surface || '#f5f5f5',
|
|
39
|
+
borderRadius: theme?.borderRadius?.md || 8,
|
|
40
|
+
}
|
|
41
|
+
]}>
|
|
42
|
+
<react_native_1.Text style={{
|
|
43
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
44
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
45
|
+
textAlign: 'center',
|
|
46
|
+
}}>
|
|
47
|
+
No items found
|
|
48
|
+
</react_native_1.Text>
|
|
49
|
+
</react_native_1.View>);
|
|
50
|
+
}
|
|
51
|
+
return (<react_native_1.View style={styles.container}>
|
|
52
|
+
{data.map((item, index) => {
|
|
53
|
+
// Render object items as cards
|
|
54
|
+
if (typeof item === 'object' && item !== null) {
|
|
55
|
+
return (<react_native_1.View key={index} style={{
|
|
56
|
+
marginBottom: theme?.spacing?.sm || 8
|
|
57
|
+
}}>
|
|
58
|
+
<DefaultCard_1.DefaultCard data={item} theme={theme}/>
|
|
59
|
+
</react_native_1.View>);
|
|
60
|
+
}
|
|
61
|
+
// Render primitive items as list items with bullets
|
|
62
|
+
return (<react_native_1.View key={index} style={[
|
|
63
|
+
styles.listItem,
|
|
64
|
+
{
|
|
65
|
+
marginBottom: theme?.spacing?.xs || 4,
|
|
66
|
+
}
|
|
67
|
+
]}>
|
|
68
|
+
<react_native_1.Text style={{
|
|
69
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
70
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
71
|
+
marginRight: theme?.spacing?.xs || 4,
|
|
72
|
+
}}>
|
|
73
|
+
•
|
|
74
|
+
</react_native_1.Text>
|
|
75
|
+
<react_native_1.Text style={{
|
|
76
|
+
color: theme?.colors?.text || '#000000',
|
|
77
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
78
|
+
flex: 1,
|
|
79
|
+
}}>
|
|
80
|
+
{String(item)}
|
|
81
|
+
</react_native_1.Text>
|
|
82
|
+
</react_native_1.View>);
|
|
83
|
+
})}
|
|
84
|
+
</react_native_1.View>);
|
|
85
|
+
}
|
|
86
|
+
const styles = react_native_1.StyleSheet.create({
|
|
87
|
+
container: {
|
|
88
|
+
width: '100%',
|
|
89
|
+
},
|
|
90
|
+
emptyContainer: {
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
justifyContent: 'center',
|
|
93
|
+
},
|
|
94
|
+
listItem: {
|
|
95
|
+
flexDirection: 'row',
|
|
96
|
+
alignItems: 'flex-start',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DefaultTable Component
|
|
3
|
+
*
|
|
4
|
+
* Generic table component for displaying array of objects in tabular format.
|
|
5
|
+
* Used as fallback when no custom component is registered.
|
|
6
|
+
*
|
|
7
|
+
* Displays:
|
|
8
|
+
* - Column headers (from first object keys)
|
|
9
|
+
* - Rows with data
|
|
10
|
+
* - Horizontal scrolling for wide tables
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { ToolComponentProps } from '../../types/components';
|
|
14
|
+
export declare function DefaultTable({ data, theme }: ToolComponentProps): React.JSX.Element;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DefaultTable Component
|
|
4
|
+
*
|
|
5
|
+
* Generic table component for displaying array of objects in tabular format.
|
|
6
|
+
* Used as fallback when no custom component is registered.
|
|
7
|
+
*
|
|
8
|
+
* Displays:
|
|
9
|
+
* - Column headers (from first object keys)
|
|
10
|
+
* - Rows with data
|
|
11
|
+
* - Horizontal scrolling for wide tables
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DefaultTable = DefaultTable;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const react_native_1 = require("react-native");
|
|
20
|
+
function DefaultTable({ data, theme }) {
|
|
21
|
+
// Validate data is array
|
|
22
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
23
|
+
return (<react_native_1.View style={[
|
|
24
|
+
styles.emptyContainer,
|
|
25
|
+
{
|
|
26
|
+
padding: theme?.spacing?.md || 12,
|
|
27
|
+
backgroundColor: theme?.colors?.surface || '#f5f5f5',
|
|
28
|
+
borderRadius: theme?.borderRadius?.md || 8,
|
|
29
|
+
}
|
|
30
|
+
]}>
|
|
31
|
+
<react_native_1.Text style={{
|
|
32
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
33
|
+
fontSize: theme?.typography?.fontSize?.sm || 14,
|
|
34
|
+
textAlign: 'center',
|
|
35
|
+
}}>
|
|
36
|
+
No data to display
|
|
37
|
+
</react_native_1.Text>
|
|
38
|
+
</react_native_1.View>);
|
|
39
|
+
}
|
|
40
|
+
// Get columns from first object
|
|
41
|
+
const firstItem = data[0];
|
|
42
|
+
if (typeof firstItem !== 'object' || firstItem === null) {
|
|
43
|
+
return (<react_native_1.View style={{
|
|
44
|
+
padding: theme?.spacing?.md || 12,
|
|
45
|
+
}}>
|
|
46
|
+
<react_native_1.Text style={{
|
|
47
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
48
|
+
}}>
|
|
49
|
+
Table requires array of objects
|
|
50
|
+
</react_native_1.Text>
|
|
51
|
+
</react_native_1.View>);
|
|
52
|
+
}
|
|
53
|
+
// Extract column names (exclude internal fields)
|
|
54
|
+
const excludedFields = ['_id', '__v', 'id'];
|
|
55
|
+
const columns = Object.keys(firstItem)
|
|
56
|
+
.filter(key => !excludedFields.includes(key))
|
|
57
|
+
.slice(0, 5); // Max 5 columns for mobile
|
|
58
|
+
// Format column name
|
|
59
|
+
const formatColumnName = (key) => {
|
|
60
|
+
return key
|
|
61
|
+
.replace(/([A-Z])/g, ' $1')
|
|
62
|
+
.replace(/^./, str => str.toUpperCase())
|
|
63
|
+
.trim();
|
|
64
|
+
};
|
|
65
|
+
// Format cell value
|
|
66
|
+
const formatValue = (value) => {
|
|
67
|
+
if (value === null || value === undefined)
|
|
68
|
+
return '-';
|
|
69
|
+
if (typeof value === 'boolean')
|
|
70
|
+
return value ? '✓' : '✗';
|
|
71
|
+
if (typeof value === 'number')
|
|
72
|
+
return value.toLocaleString();
|
|
73
|
+
if (Array.isArray(value))
|
|
74
|
+
return `[${value.length}]`;
|
|
75
|
+
if (typeof value === 'object')
|
|
76
|
+
return '{...}';
|
|
77
|
+
const str = String(value);
|
|
78
|
+
return str.length > 30 ? str.substring(0, 27) + '...' : str;
|
|
79
|
+
};
|
|
80
|
+
const spacing = theme?.spacing || { xs: 4, sm: 8, md: 12 };
|
|
81
|
+
const borderColor = theme?.colors?.border || '#e0e0e0';
|
|
82
|
+
return (<react_native_1.ScrollView horizontal showsHorizontalScrollIndicator={false} style={styles.container}>
|
|
83
|
+
<react_native_1.View style={[
|
|
84
|
+
styles.table,
|
|
85
|
+
{
|
|
86
|
+
borderWidth: 1,
|
|
87
|
+
borderColor,
|
|
88
|
+
borderRadius: theme?.borderRadius?.md || 8,
|
|
89
|
+
backgroundColor: theme?.colors?.surface || '#f5f5f5',
|
|
90
|
+
}
|
|
91
|
+
]}>
|
|
92
|
+
{/* Header Row */}
|
|
93
|
+
<react_native_1.View style={[
|
|
94
|
+
styles.headerRow,
|
|
95
|
+
{
|
|
96
|
+
backgroundColor: theme?.colors?.primary || '#3b82f6',
|
|
97
|
+
borderTopLeftRadius: theme?.borderRadius?.md || 8,
|
|
98
|
+
borderTopRightRadius: theme?.borderRadius?.md || 8,
|
|
99
|
+
}
|
|
100
|
+
]}>
|
|
101
|
+
{columns.map((column, index) => (<react_native_1.View key={column} style={[
|
|
102
|
+
styles.headerCell,
|
|
103
|
+
{
|
|
104
|
+
paddingHorizontal: spacing.sm,
|
|
105
|
+
paddingVertical: spacing.sm,
|
|
106
|
+
borderRightWidth: index < columns.length - 1 ? 1 : 0,
|
|
107
|
+
borderRightColor: 'rgba(255, 255, 255, 0.2)',
|
|
108
|
+
}
|
|
109
|
+
]}>
|
|
110
|
+
<react_native_1.Text style={[
|
|
111
|
+
styles.headerText,
|
|
112
|
+
{
|
|
113
|
+
color: '#ffffff',
|
|
114
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
115
|
+
fontWeight: theme?.typography?.fontWeight?.semibold || '600',
|
|
116
|
+
}
|
|
117
|
+
]}>
|
|
118
|
+
{formatColumnName(column)}
|
|
119
|
+
</react_native_1.Text>
|
|
120
|
+
</react_native_1.View>))}
|
|
121
|
+
</react_native_1.View>
|
|
122
|
+
|
|
123
|
+
{/* Data Rows */}
|
|
124
|
+
{data.slice(0, 10).map((row, rowIndex) => (<react_native_1.View key={rowIndex} style={[
|
|
125
|
+
styles.dataRow,
|
|
126
|
+
{
|
|
127
|
+
backgroundColor: rowIndex % 2 === 0
|
|
128
|
+
? theme?.colors?.background || '#ffffff'
|
|
129
|
+
: theme?.colors?.surface || '#f9fafb',
|
|
130
|
+
borderTopWidth: 1,
|
|
131
|
+
borderTopColor: borderColor,
|
|
132
|
+
}
|
|
133
|
+
]}>
|
|
134
|
+
{columns.map((column, colIndex) => (<react_native_1.View key={`${rowIndex}-${column}`} style={[
|
|
135
|
+
styles.dataCell,
|
|
136
|
+
{
|
|
137
|
+
paddingHorizontal: spacing.sm,
|
|
138
|
+
paddingVertical: spacing.sm,
|
|
139
|
+
borderRightWidth: colIndex < columns.length - 1 ? 1 : 0,
|
|
140
|
+
borderRightColor: borderColor,
|
|
141
|
+
}
|
|
142
|
+
]}>
|
|
143
|
+
<react_native_1.Text style={[
|
|
144
|
+
styles.cellText,
|
|
145
|
+
{
|
|
146
|
+
color: theme?.colors?.text || '#000000',
|
|
147
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
148
|
+
}
|
|
149
|
+
]}>
|
|
150
|
+
{formatValue(row[column])}
|
|
151
|
+
</react_native_1.Text>
|
|
152
|
+
</react_native_1.View>))}
|
|
153
|
+
</react_native_1.View>))}
|
|
154
|
+
|
|
155
|
+
{/* Show more indicator */}
|
|
156
|
+
{data.length > 10 && (<react_native_1.View style={{
|
|
157
|
+
padding: spacing.sm,
|
|
158
|
+
alignItems: 'center',
|
|
159
|
+
borderTopWidth: 1,
|
|
160
|
+
borderTopColor: borderColor,
|
|
161
|
+
}}>
|
|
162
|
+
<react_native_1.Text style={{
|
|
163
|
+
color: theme?.colors?.textSecondary || '#666666',
|
|
164
|
+
fontSize: theme?.typography?.fontSize?.xs || 12,
|
|
165
|
+
}}>
|
|
166
|
+
... and {data.length - 10} more rows
|
|
167
|
+
</react_native_1.Text>
|
|
168
|
+
</react_native_1.View>)}
|
|
169
|
+
</react_native_1.View>
|
|
170
|
+
</react_native_1.ScrollView>);
|
|
171
|
+
}
|
|
172
|
+
const styles = react_native_1.StyleSheet.create({
|
|
173
|
+
container: {
|
|
174
|
+
width: '100%',
|
|
175
|
+
},
|
|
176
|
+
table: {
|
|
177
|
+
minWidth: '100%',
|
|
178
|
+
},
|
|
179
|
+
headerRow: {
|
|
180
|
+
flexDirection: 'row',
|
|
181
|
+
},
|
|
182
|
+
headerCell: {
|
|
183
|
+
minWidth: 100,
|
|
184
|
+
justifyContent: 'center',
|
|
185
|
+
},
|
|
186
|
+
headerText: {
|
|
187
|
+
textTransform: 'uppercase',
|
|
188
|
+
letterSpacing: 0.5,
|
|
189
|
+
},
|
|
190
|
+
dataRow: {
|
|
191
|
+
flexDirection: 'row',
|
|
192
|
+
},
|
|
193
|
+
dataCell: {
|
|
194
|
+
minWidth: 100,
|
|
195
|
+
justifyContent: 'center',
|
|
196
|
+
},
|
|
197
|
+
cellText: {
|
|
198
|
+
// Default styles
|
|
199
|
+
},
|
|
200
|
+
emptyContainer: {
|
|
201
|
+
alignItems: 'center',
|
|
202
|
+
justifyContent: 'center',
|
|
203
|
+
},
|
|
204
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Components
|
|
3
|
+
* Export all default components for Tool Registry
|
|
4
|
+
*/
|
|
5
|
+
export { DefaultCard } from './DefaultCard';
|
|
6
|
+
export { DefaultList } from './DefaultList';
|
|
7
|
+
export { DefaultDetail } from './DefaultDetail';
|
|
8
|
+
export { DefaultTable } from './DefaultTable';
|
|
9
|
+
/**
|
|
10
|
+
* Default component registry
|
|
11
|
+
* Can be used as fallback or merged with custom components
|
|
12
|
+
*/
|
|
13
|
+
import { ComponentRegistry } from '../../types/components';
|
|
14
|
+
export declare const defaultComponentRegistry: ComponentRegistry;
|