@umituz/react-native-ai-generation-content 1.13.0 → 1.13.1

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.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -31,7 +31,7 @@ export function CreationCard({
31
31
  const tokens = useAppDesignTokens();
32
32
  const { translatedTypes, t } = useCreationsProvider();
33
33
 
34
- const typeConfig = translatedTypes.find((t) => t.id === creation.type);
34
+ const typeConfig = translatedTypes.find((type) => type.id === creation.type);
35
35
  const icon = typeConfig?.icon;
36
36
  // Use manual name if available, otherwise use translated label from config
37
37
  const label = (creation.metadata?.names as string) || typeConfig?.labelKey || creation.type;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Creations Provider
3
+ * Context provider for creations configuration and localization
4
+ */
5
+
6
+ import React, { createContext, useContext, useMemo, type ReactNode } from "react";
7
+ import type { CreationsConfig, CreationType } from "../../domain/value-objects/CreationsConfig";
8
+ import { getTranslatedTypes } from "../utils/filterUtils";
9
+
10
+ interface CreationsContextValue {
11
+ config: CreationsConfig;
12
+ t: (key: string) => string;
13
+ translatedTypes: readonly CreationType[];
14
+ getLocalizedTitle: (typeId: string) => string;
15
+ }
16
+
17
+ const CreationsContext = createContext<CreationsContextValue | null>(null);
18
+
19
+ interface CreationsProviderProps {
20
+ config: CreationsConfig;
21
+ t: (key: string) => string;
22
+ children: ReactNode;
23
+ }
24
+
25
+ export function CreationsProvider({ config, t, children }: CreationsProviderProps) {
26
+ const translatedTypes = useMemo(() => getTranslatedTypes(config, t), [config, t]);
27
+
28
+ const getLocalizedTitle = (typeId: string): string => {
29
+ const typeConfig = translatedTypes.find((type) => type.id === typeId);
30
+ return typeConfig?.labelKey || typeId;
31
+ };
32
+
33
+ const value = useMemo<CreationsContextValue>(
34
+ () => ({
35
+ config,
36
+ t,
37
+ translatedTypes,
38
+ getLocalizedTitle,
39
+ }),
40
+ [config, t, translatedTypes]
41
+ );
42
+
43
+ return (
44
+ <CreationsContext.Provider value={value}>
45
+ {children}
46
+ </CreationsContext.Provider>
47
+ );
48
+ }
49
+
50
+ export function useCreationsProvider(): CreationsContextValue {
51
+ const context = useContext(CreationsContext);
52
+ if (!context) {
53
+ throw new Error("useCreationsProvider must be used within a CreationsProvider");
54
+ }
55
+ return context;
56
+ }
@@ -11,6 +11,7 @@ export { CreationCard } from "./CreationCard";
11
11
  export { CreationThumbnail } from "./CreationThumbnail";
12
12
  export { CreationImageViewer } from "./CreationImageViewer";
13
13
  export { CreationsGrid } from "./CreationsGrid";
14
+ export { CreationsProvider, useCreationsProvider } from "./CreationsProvider";
14
15
 
15
16
  // Detail Components
16
17
  export { DetailHeader } from "./CreationDetail/DetailHeader";