@umituz/react-native-ai-generation-content 1.17.65 → 1.17.66

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": "@umituz/react-native-ai-generation-content",
3
- "version": "1.17.65",
3
+ "version": "1.17.66",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -373,6 +373,8 @@ export type {
373
373
  AspectRatioTranslations,
374
374
  DurationOption,
375
375
  StyleTranslations,
376
+ AIGenerationFormProps,
377
+ AIGenerationFormTranslations,
376
378
  } from "./presentation/components";
377
379
 
378
380
  // Selector Factories
@@ -1,4 +1,10 @@
1
- import React, { PropsWithChildren } from "react";
1
+ import React from "react";
2
+ import { View, TouchableOpacity, StyleSheet } from "react-native";
3
+ import {
4
+ AtomicText,
5
+ AtomicIcon,
6
+ useAppDesignTokens,
7
+ } from "@umituz/react-native-design-system";
2
8
  import { StyleSelector } from "./selectors/StyleSelector";
3
9
  import { DurationSelector } from "./selectors/DurationSelector";
4
10
  import { AspectRatioSelector } from "./selectors/AspectRatioSelector";
@@ -6,143 +12,134 @@ import { PromptInput } from "./PromptInput";
6
12
  import { GenerateButton } from "./buttons/GenerateButton";
7
13
  import { ExamplePrompts } from "./prompts/ExamplePrompts";
8
14
  import { AIGenerationProgressInline } from "./AIGenerationProgressInline";
9
- import type { StyleOption } from "./selectors/types";
10
- import type { AspectRatioOption } from "./selectors/types";
11
-
12
- export interface AIGenerationFormTranslations {
13
- promptTitle?: string;
14
- promptPlaceholder?: string;
15
- styleTitle?: string;
16
- durationTitle?: string;
17
- aspectRatioTitle?: string;
18
- examplePromptsTitle?: string;
19
- generateButton: string;
20
- generatingButton: string;
21
- progressTitle?: string;
22
- progressHint?: string;
23
- }
24
-
25
- export interface AIGenerationFormProps extends PropsWithChildren {
26
- prompt?: string;
27
- onPromptChange?: (text: string) => void;
28
-
29
- // Optional: Example Prompts
30
- examplePrompts?: readonly string[];
31
- onExamplePromptSelect?: (prompt: string) => void;
32
-
33
- // Optional: Style Selection
34
- styles?: StyleOption[];
35
- selectedStyle?: string;
36
- onStyleSelect?: (styleId: string) => void;
37
-
38
- // Optional: Duration Selection
39
- duration?: number;
40
- durationOptions?: readonly number[];
41
- onDurationSelect?: (duration: number) => void;
42
- formatDurationLabel?: (duration: number) => string;
43
-
44
- // Optional: Aspect Ratio Selection
45
- aspectRatios?: AspectRatioOption[];
46
- selectedAspectRatio?: string;
47
- onAspectRatioSelect?: (ratio: string) => void;
48
-
49
- onGenerate: () => void;
50
- isGenerating: boolean;
51
- hideGenerateButton?: boolean;
52
-
53
- // Optional: Generation Progress
54
- progress?: number;
55
-
56
- // Custom Generate Button Props
57
- generateButtonProps?: {
58
- costLabel?: string;
59
- accessoryRight?: React.ReactNode;
60
- onAccessoryRightPress?: () => void;
61
- icon?: string;
62
- };
63
-
64
- translations: AIGenerationFormTranslations;
65
- }
15
+ import { StylePresetsGrid } from "./StylePresetsGrid";
16
+ import type { AIGenerationFormProps } from "./AIGenerationForm.types";
66
17
 
67
18
  export const AIGenerationForm: React.FC<AIGenerationFormProps> = ({
68
19
  prompt,
69
20
  onPromptChange,
70
-
71
21
  examplePrompts,
72
22
  onExamplePromptSelect,
73
-
74
- styles,
23
+ styles: styleOptions,
75
24
  selectedStyle,
76
25
  onStyleSelect,
77
-
78
26
  duration,
79
27
  durationOptions,
80
28
  onDurationSelect,
81
29
  formatDurationLabel,
82
-
83
30
  aspectRatios,
84
31
  selectedAspectRatio,
85
32
  onAspectRatioSelect,
86
-
87
33
  onGenerate,
88
34
  isGenerating,
89
35
  hideGenerateButton,
90
36
  progress,
91
-
92
37
  generateButtonProps,
93
-
38
+ showAdvanced,
39
+ onAdvancedToggle,
40
+ presets,
41
+ onPresetPress,
94
42
  translations,
95
43
  children,
96
44
  }) => {
45
+ const tokens = useAppDesignTokens();
46
+ const isAdvancedVisible = showAdvanced !== undefined ? showAdvanced : true;
47
+
97
48
  return (
98
49
  <>
99
- {onPromptChange && translations.promptTitle && (
100
- <PromptInput
101
- title={translations.promptTitle}
102
- placeholder={translations.promptPlaceholder}
103
- value={prompt || ""}
104
- onChangeText={onPromptChange}
105
- />
106
- )}
107
-
108
- {examplePrompts && examplePrompts.length > 0 && onExamplePromptSelect && (
109
- <ExamplePrompts
110
- prompts={examplePrompts}
111
- onSelectPrompt={onExamplePromptSelect}
112
- title={translations.examplePromptsTitle}
50
+ {presets && presets.length > 0 && onPresetPress && (
51
+ <StylePresetsGrid
52
+ presets={presets}
53
+ onPresetPress={onPresetPress}
54
+ disabled={isGenerating}
55
+ title={translations.presetsTitle}
113
56
  />
114
57
  )}
115
-
116
- {styles && styles.length > 0 && selectedStyle && onStyleSelect && translations.styleTitle && (
117
- <StyleSelector
118
- styles={styles}
119
- selectedStyle={selectedStyle}
120
- onStyleSelect={onStyleSelect}
121
- title={translations.styleTitle}
122
- />
123
- )}
124
-
125
- {aspectRatios && aspectRatios.length > 0 && selectedAspectRatio && onAspectRatioSelect && translations.aspectRatioTitle && (
126
- <AspectRatioSelector
127
- ratios={aspectRatios}
128
- selectedRatio={selectedAspectRatio}
129
- onRatioSelect={onAspectRatioSelect}
130
- title={translations.aspectRatioTitle}
131
- />
58
+
59
+ {onAdvancedToggle && (
60
+ <TouchableOpacity
61
+ style={[
62
+ styles.toggleButton,
63
+ { backgroundColor: tokens.colors.backgroundSecondary },
64
+ ]}
65
+ onPress={() => onAdvancedToggle(!showAdvanced)}
66
+ >
67
+ <AtomicText type="bodyMedium" style={{ color: tokens.colors.textPrimary }}>
68
+ {showAdvanced ? translations.hideAdvancedLabel : translations.showAdvancedLabel}
69
+ </AtomicText>
70
+ <AtomicIcon
71
+ name={showAdvanced ? "chevron-up" : "chevron-down"}
72
+ size="sm"
73
+ color={tokens.colors.textSecondary}
74
+ />
75
+ </TouchableOpacity>
132
76
  )}
133
-
134
- {duration && durationOptions && onDurationSelect && translations.durationTitle && (
135
- <DurationSelector
136
- duration={duration}
137
- durationOptions={durationOptions}
138
- onDurationSelect={onDurationSelect}
139
- title={translations.durationTitle}
140
- formatLabel={formatDurationLabel}
141
- />
77
+
78
+ {isAdvancedVisible && (
79
+ <>
80
+ {onPromptChange && translations.promptTitle && (
81
+ <PromptInput
82
+ title={translations.promptTitle}
83
+ placeholder={translations.promptPlaceholder}
84
+ value={prompt || ""}
85
+ onChangeText={onPromptChange}
86
+ />
87
+ )}
88
+
89
+ {examplePrompts && examplePrompts.length > 0 && onExamplePromptSelect && (
90
+ <ExamplePrompts
91
+ prompts={examplePrompts}
92
+ onSelectPrompt={onExamplePromptSelect}
93
+ title={translations.examplePromptsTitle}
94
+ />
95
+ )}
96
+
97
+ {styleOptions && styleOptions.length > 0 && selectedStyle && onStyleSelect && translations.styleTitle && (
98
+ <StyleSelector
99
+ styles={styleOptions}
100
+ selectedStyle={selectedStyle}
101
+ onStyleSelect={onStyleSelect}
102
+ title={translations.styleTitle}
103
+ />
104
+ )}
105
+
106
+ {aspectRatios && aspectRatios.length > 0 && selectedAspectRatio && onAspectRatioSelect && translations.aspectRatioTitle && (
107
+ <AspectRatioSelector
108
+ ratios={aspectRatios}
109
+ selectedRatio={selectedAspectRatio}
110
+ onRatioSelect={onAspectRatioSelect}
111
+ title={translations.aspectRatioTitle}
112
+ />
113
+ )}
114
+
115
+ {duration && durationOptions && onDurationSelect && translations.durationTitle && (
116
+ <DurationSelector
117
+ duration={duration}
118
+ durationOptions={durationOptions}
119
+ onDurationSelect={onDurationSelect}
120
+ title={translations.durationTitle}
121
+ formatLabel={formatDurationLabel}
122
+ />
123
+ )}
124
+
125
+ {children}
126
+
127
+ {!hideGenerateButton && (
128
+ <GenerateButton
129
+ onPress={onGenerate}
130
+ isProcessing={isGenerating}
131
+ isDisabled={onPromptChange ? !prompt?.trim() : false}
132
+ text={translations.generateButton}
133
+ processingText={translations.generatingButton}
134
+ variant="solid"
135
+ icon={generateButtonProps?.icon || "sparkles-outline"}
136
+ costLabel={generateButtonProps?.costLabel}
137
+ accessoryRight={generateButtonProps?.accessoryRight}
138
+ onAccessoryRightPress={generateButtonProps?.onAccessoryRightPress}
139
+ />
140
+ )}
141
+ </>
142
142
  )}
143
-
144
- {/* Custom children injected here */}
145
- {children}
146
143
 
147
144
  {isGenerating && progress !== undefined && (
148
145
  <AIGenerationProgressInline
@@ -151,21 +148,19 @@ export const AIGenerationForm: React.FC<AIGenerationFormProps> = ({
151
148
  hint={translations.progressHint}
152
149
  />
153
150
  )}
154
-
155
- {!hideGenerateButton && (
156
- <GenerateButton
157
- onPress={onGenerate}
158
- isProcessing={isGenerating}
159
- isDisabled={onPromptChange ? !prompt?.trim() : false}
160
- text={translations.generateButton}
161
- processingText={translations.generatingButton}
162
- variant="solid"
163
- icon={generateButtonProps?.icon || "sparkles-outline"}
164
- costLabel={generateButtonProps?.costLabel}
165
- accessoryRight={generateButtonProps?.accessoryRight}
166
- onAccessoryRightPress={generateButtonProps?.onAccessoryRightPress}
167
- />
168
- )}
169
151
  </>
170
152
  );
171
153
  };
154
+
155
+ const styles = StyleSheet.create({
156
+ toggleButton: {
157
+ flexDirection: "row",
158
+ alignItems: "center",
159
+ justifyContent: "center",
160
+ padding: 12,
161
+ marginHorizontal: 16,
162
+ borderRadius: 12,
163
+ gap: 8,
164
+ marginVertical: 12,
165
+ },
166
+ });
@@ -0,0 +1,74 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import type { StyleOption, AspectRatioOption, StylePreset } from "./selectors/types";
3
+
4
+ /**
5
+ * Translations for AIGenerationForm
6
+ */
7
+ export interface AIGenerationFormTranslations {
8
+ promptTitle?: string;
9
+ promptPlaceholder?: string;
10
+ styleTitle?: string;
11
+ durationTitle?: string;
12
+ aspectRatioTitle?: string;
13
+ examplePromptsTitle?: string;
14
+ generateButton: string;
15
+ generatingButton: string;
16
+ progressTitle?: string;
17
+ progressHint?: string;
18
+ presetsTitle?: string;
19
+ showAdvancedLabel?: string;
20
+ hideAdvancedLabel?: string;
21
+ }
22
+
23
+ /**
24
+ * Props for AIGenerationForm
25
+ */
26
+ export interface AIGenerationFormProps extends PropsWithChildren {
27
+ prompt?: string;
28
+ onPromptChange?: (text: string) => void;
29
+
30
+ // Optional: Example Prompts
31
+ examplePrompts?: readonly string[];
32
+ onExamplePromptSelect?: (prompt: string) => void;
33
+
34
+ // Optional: Style Selection
35
+ styles?: StyleOption[];
36
+ selectedStyle?: string;
37
+ onStyleSelect?: (styleId: string) => void;
38
+
39
+ // Optional: Duration Selection
40
+ duration?: number;
41
+ durationOptions?: readonly number[];
42
+ onDurationSelect?: (duration: number) => void;
43
+ formatDurationLabel?: (duration: number) => string;
44
+
45
+ // Optional: Aspect Ratio Selection
46
+ aspectRatios?: AspectRatioOption[];
47
+ selectedAspectRatio?: string;
48
+ onAspectRatioSelect?: (ratio: string) => void;
49
+
50
+ onGenerate: () => void;
51
+ isGenerating: boolean;
52
+ hideGenerateButton?: boolean;
53
+
54
+ // Optional: Generation Progress
55
+ progress?: number;
56
+
57
+ // Custom Generate Button Props
58
+ generateButtonProps?: {
59
+ costLabel?: string;
60
+ accessoryRight?: React.ReactNode;
61
+ onAccessoryRightPress?: () => void;
62
+ icon?: string;
63
+ };
64
+
65
+ // Optional: Advanced Options Toggle
66
+ showAdvanced?: boolean;
67
+ onAdvancedToggle?: (show: boolean) => void;
68
+
69
+ // Optional: Style Presets
70
+ presets?: readonly StylePreset[];
71
+ onPresetPress?: (preset: StylePreset) => void;
72
+
73
+ translations: AIGenerationFormTranslations;
74
+ }
@@ -9,6 +9,7 @@ export { PromptInput } from "./PromptInput";
9
9
  export { AIGenerationHero } from "./AIGenerationHero";
10
10
  export * from "./StylePresetsGrid";
11
11
  export * from "./AIGenerationForm";
12
+ export * from "./AIGenerationForm.types";
12
13
 
13
14
  export type {
14
15
  GenerationProgressModalProps,