@umituz/react-native-ai-generation-content 1.58.0 → 1.58.2
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 +1 -1
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderSelectionStep.tsx +10 -5
- package/src/domains/generation/wizard/presentation/hooks/useWizardFlowHandlers.ts +21 -5
- package/src/domains/generation/wizard/presentation/hooks/useWizardGeneration.ts +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.58.
|
|
3
|
+
"version": "1.58.2",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
package/src/domains/generation/wizard/presentation/components/step-renderers/renderSelectionStep.tsx
CHANGED
|
@@ -26,8 +26,14 @@ export function renderSelectionStep({
|
|
|
26
26
|
const selectionConfig = getSelectionConfig(step.config);
|
|
27
27
|
const titleKey = selectionConfig?.titleKey ?? `wizard.steps.${step.id}.title`;
|
|
28
28
|
const subtitleKey = selectionConfig?.subtitleKey ?? `wizard.steps.${step.id}.subtitle`;
|
|
29
|
-
const existingValue = customData[step.id] as string | string[] | undefined;
|
|
30
29
|
const options = selectionConfig?.options ?? [];
|
|
30
|
+
const isRequired = step.required ?? true;
|
|
31
|
+
|
|
32
|
+
// Priority: existing value > config default > auto-select single option
|
|
33
|
+
const existingValue = customData[step.id] as string | string[] | undefined;
|
|
34
|
+
const configDefault = selectionConfig?.defaultValue;
|
|
35
|
+
const autoSelectValue = isRequired && options.length === 1 ? options[0].id : undefined;
|
|
36
|
+
const initialValue = existingValue ?? configDefault ?? autoSelectValue;
|
|
31
37
|
|
|
32
38
|
return (
|
|
33
39
|
<SelectionScreen
|
|
@@ -46,13 +52,12 @@ export function renderSelectionStep({
|
|
|
46
52
|
}))}
|
|
47
53
|
config={{
|
|
48
54
|
multiSelect: selectionConfig?.multiSelect ?? false,
|
|
49
|
-
required:
|
|
55
|
+
required: isRequired,
|
|
50
56
|
}}
|
|
51
|
-
initialValue={
|
|
57
|
+
initialValue={initialValue}
|
|
52
58
|
onBack={onBack}
|
|
53
59
|
onContinue={(value) => {
|
|
54
|
-
|
|
55
|
-
onPhotoContinue(step.id, { uri: String(value), selection: value, previewUrl: "" } as unknown as any);
|
|
60
|
+
onPhotoContinue(step.id, { uri: String(value), selection: value, previewUrl: "" } as UploadedImage);
|
|
56
61
|
}}
|
|
57
62
|
/>
|
|
58
63
|
);
|
|
@@ -73,13 +73,18 @@ export function useWizardFlowHandlers(props: UseWizardFlowHandlersProps) {
|
|
|
73
73
|
|
|
74
74
|
const handleGenerationError = useCallback(
|
|
75
75
|
(errorMessage: string) => {
|
|
76
|
+
// Ensure we have a meaningful error message
|
|
77
|
+
const safeErrorMessage = errorMessage?.trim() || "error.generation.unknown";
|
|
76
78
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
77
|
-
console.log("[WizardFlowHandlers] Generation error:",
|
|
79
|
+
console.log("[WizardFlowHandlers] Generation error:", {
|
|
80
|
+
original: errorMessage,
|
|
81
|
+
safe: safeErrorMessage,
|
|
82
|
+
});
|
|
78
83
|
}
|
|
79
84
|
// Translate error key if it looks like a translation key
|
|
80
|
-
const displayMessage =
|
|
81
|
-
? t(
|
|
82
|
-
:
|
|
85
|
+
const displayMessage = safeErrorMessage.startsWith("error.")
|
|
86
|
+
? t(safeErrorMessage)
|
|
87
|
+
: safeErrorMessage;
|
|
83
88
|
// Show error alert to user
|
|
84
89
|
alert.show(
|
|
85
90
|
AlertType.ERROR,
|
|
@@ -88,7 +93,7 @@ export function useWizardFlowHandlers(props: UseWizardFlowHandlersProps) {
|
|
|
88
93
|
displayMessage,
|
|
89
94
|
);
|
|
90
95
|
// Notify parent component
|
|
91
|
-
onGenerationError?.(
|
|
96
|
+
onGenerationError?.(safeErrorMessage);
|
|
92
97
|
// Close the wizard
|
|
93
98
|
onBack?.();
|
|
94
99
|
},
|
|
@@ -115,7 +120,18 @@ export function useWizardFlowHandlers(props: UseWizardFlowHandlersProps) {
|
|
|
115
120
|
|
|
116
121
|
const handleNextStep = useCallback(() => {
|
|
117
122
|
const nextStepDef = flowSteps[currentStepIndex + 1];
|
|
123
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
124
|
+
console.log("[WizardFlowHandlers] handleNextStep", {
|
|
125
|
+
currentStepIndex,
|
|
126
|
+
nextStepType: nextStepDef?.type,
|
|
127
|
+
isGenerating: nextStepDef?.type === StepType.GENERATING,
|
|
128
|
+
hasOnGenerationStart: !!onGenerationStart,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
118
131
|
if (nextStepDef?.type === StepType.GENERATING && onGenerationStart) {
|
|
132
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
133
|
+
console.log("[WizardFlowHandlers] Calling onGenerationStart callback");
|
|
134
|
+
}
|
|
119
135
|
onGenerationStart(customData, nextStep);
|
|
120
136
|
return;
|
|
121
137
|
}
|
|
@@ -164,11 +164,12 @@ export const useWizardGeneration = (
|
|
|
164
164
|
dispatch({ type: "COMPLETE" });
|
|
165
165
|
})
|
|
166
166
|
.catch((error) => {
|
|
167
|
+
const errorMsg = error?.message || "error.generation.unknown";
|
|
167
168
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
168
|
-
console.error("[WizardGeneration] Build input error:", error
|
|
169
|
+
console.error("[WizardGeneration] Build input error:", errorMsg, error);
|
|
169
170
|
}
|
|
170
|
-
dispatch({ type: "ERROR", error:
|
|
171
|
-
onError?.(
|
|
171
|
+
dispatch({ type: "ERROR", error: errorMsg });
|
|
172
|
+
onError?.(errorMsg);
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
|