@akin-travel/partner-sdk 1.0.5

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.
Files changed (204) hide show
  1. package/README.md +1204 -0
  2. package/dist/account/components/AccountInfoSection.d.ts +46 -0
  3. package/dist/account/components/AccountInfoSection.d.ts.map +1 -0
  4. package/dist/account/components/AccountInfoSection.js +52 -0
  5. package/dist/account/components/AccountInfoSection.js.map +1 -0
  6. package/dist/account/components/NotificationPreferencesSection.d.ts +40 -0
  7. package/dist/account/components/NotificationPreferencesSection.d.ts.map +1 -0
  8. package/dist/account/components/NotificationPreferencesSection.js +116 -0
  9. package/dist/account/components/NotificationPreferencesSection.js.map +1 -0
  10. package/dist/account/components/PasskeySection.d.ts +49 -0
  11. package/dist/account/components/PasskeySection.d.ts.map +1 -0
  12. package/dist/account/components/PasskeySection.js +298 -0
  13. package/dist/account/components/PasskeySection.js.map +1 -0
  14. package/dist/account/hooks/useAccountForm.d.ts +23 -0
  15. package/dist/account/hooks/useAccountForm.d.ts.map +1 -0
  16. package/dist/account/hooks/useAccountForm.js +133 -0
  17. package/dist/account/hooks/useAccountForm.js.map +1 -0
  18. package/dist/account/index.d.ts +10 -0
  19. package/dist/account/index.d.ts.map +1 -0
  20. package/dist/account/index.js +21 -0
  21. package/dist/account/index.js.map +1 -0
  22. package/dist/auth/AkinAuthProvider.d.ts +31 -0
  23. package/dist/auth/AkinAuthProvider.d.ts.map +1 -0
  24. package/dist/auth/AkinAuthProvider.js +632 -0
  25. package/dist/auth/AkinAuthProvider.js.map +1 -0
  26. package/dist/auth/components/LoginForm.d.ts +63 -0
  27. package/dist/auth/components/LoginForm.d.ts.map +1 -0
  28. package/dist/auth/components/LoginForm.js +230 -0
  29. package/dist/auth/components/LoginForm.js.map +1 -0
  30. package/dist/auth/components/MagicLinkForm.d.ts +41 -0
  31. package/dist/auth/components/MagicLinkForm.d.ts.map +1 -0
  32. package/dist/auth/components/MagicLinkForm.js +88 -0
  33. package/dist/auth/components/MagicLinkForm.js.map +1 -0
  34. package/dist/auth/components/RequireAuth.d.ts +62 -0
  35. package/dist/auth/components/RequireAuth.d.ts.map +1 -0
  36. package/dist/auth/components/RequireAuth.js +63 -0
  37. package/dist/auth/components/RequireAuth.js.map +1 -0
  38. package/dist/auth/components/RequireGuest.d.ts +60 -0
  39. package/dist/auth/components/RequireGuest.d.ts.map +1 -0
  40. package/dist/auth/components/RequireGuest.js +64 -0
  41. package/dist/auth/components/RequireGuest.js.map +1 -0
  42. package/dist/auth/components/SignupForm.d.ts +45 -0
  43. package/dist/auth/components/SignupForm.d.ts.map +1 -0
  44. package/dist/auth/components/SignupForm.js +167 -0
  45. package/dist/auth/components/SignupForm.js.map +1 -0
  46. package/dist/auth/index.d.ts +10 -0
  47. package/dist/auth/index.d.ts.map +1 -0
  48. package/dist/auth/index.js +21 -0
  49. package/dist/auth/index.js.map +1 -0
  50. package/dist/client.d.ts +17 -0
  51. package/dist/client.d.ts.map +1 -0
  52. package/dist/client.js +136 -0
  53. package/dist/client.js.map +1 -0
  54. package/dist/components/PhoneInput.d.ts +62 -0
  55. package/dist/components/PhoneInput.d.ts.map +1 -0
  56. package/dist/components/PhoneInput.js +65 -0
  57. package/dist/components/PhoneInput.js.map +1 -0
  58. package/dist/components/index.d.ts +2 -0
  59. package/dist/components/index.d.ts.map +1 -0
  60. package/dist/components/index.js +9 -0
  61. package/dist/components/index.js.map +1 -0
  62. package/dist/config.d.ts +111 -0
  63. package/dist/config.d.ts.map +1 -0
  64. package/dist/config.js +56 -0
  65. package/dist/config.js.map +1 -0
  66. package/dist/constants/preferences.d.ts +22 -0
  67. package/dist/constants/preferences.d.ts.map +1 -0
  68. package/dist/constants/preferences.js +52 -0
  69. package/dist/constants/preferences.js.map +1 -0
  70. package/dist/currency/CurrencyProvider.d.ts +46 -0
  71. package/dist/currency/CurrencyProvider.d.ts.map +1 -0
  72. package/dist/currency/CurrencyProvider.js +145 -0
  73. package/dist/currency/CurrencyProvider.js.map +1 -0
  74. package/dist/currency/components/CurrencySelector.d.ts +43 -0
  75. package/dist/currency/components/CurrencySelector.d.ts.map +1 -0
  76. package/dist/currency/components/CurrencySelector.js +58 -0
  77. package/dist/currency/components/CurrencySelector.js.map +1 -0
  78. package/dist/currency/exchangeRates.d.ts +40 -0
  79. package/dist/currency/exchangeRates.d.ts.map +1 -0
  80. package/dist/currency/exchangeRates.js +90 -0
  81. package/dist/currency/exchangeRates.js.map +1 -0
  82. package/dist/currency/index.d.ts +6 -0
  83. package/dist/currency/index.d.ts.map +1 -0
  84. package/dist/currency/index.js +20 -0
  85. package/dist/currency/index.js.map +1 -0
  86. package/dist/header/components/CurrencyAccordion.d.ts +45 -0
  87. package/dist/header/components/CurrencyAccordion.d.ts.map +1 -0
  88. package/dist/header/components/CurrencyAccordion.js +54 -0
  89. package/dist/header/components/CurrencyAccordion.js.map +1 -0
  90. package/dist/header/components/HeaderMenu.d.ts +49 -0
  91. package/dist/header/components/HeaderMenu.d.ts.map +1 -0
  92. package/dist/header/components/HeaderMenu.js +95 -0
  93. package/dist/header/components/HeaderMenu.js.map +1 -0
  94. package/dist/header/components/LanguageAccordion.d.ts +45 -0
  95. package/dist/header/components/LanguageAccordion.d.ts.map +1 -0
  96. package/dist/header/components/LanguageAccordion.js +54 -0
  97. package/dist/header/components/LanguageAccordion.js.map +1 -0
  98. package/dist/header/components/UserAvatar.d.ts +26 -0
  99. package/dist/header/components/UserAvatar.d.ts.map +1 -0
  100. package/dist/header/components/UserAvatar.js +46 -0
  101. package/dist/header/components/UserAvatar.js.map +1 -0
  102. package/dist/header/index.d.ts +10 -0
  103. package/dist/header/index.d.ts.map +1 -0
  104. package/dist/header/index.js +13 -0
  105. package/dist/header/index.js.map +1 -0
  106. package/dist/i18n/I18nProvider.d.ts +57 -0
  107. package/dist/i18n/I18nProvider.d.ts.map +1 -0
  108. package/dist/i18n/I18nProvider.js +205 -0
  109. package/dist/i18n/I18nProvider.js.map +1 -0
  110. package/dist/i18n/components/LanguageSelector.d.ts +43 -0
  111. package/dist/i18n/components/LanguageSelector.d.ts.map +1 -0
  112. package/dist/i18n/components/LanguageSelector.js +57 -0
  113. package/dist/i18n/components/LanguageSelector.js.map +1 -0
  114. package/dist/i18n/index.d.ts +5 -0
  115. package/dist/i18n/index.d.ts.map +1 -0
  116. package/dist/i18n/index.js +14 -0
  117. package/dist/i18n/index.js.map +1 -0
  118. package/dist/i18n/translations/en.json +283 -0
  119. package/dist/i18n/translations/es.json +283 -0
  120. package/dist/index.d.ts +81 -0
  121. package/dist/index.d.ts.map +1 -0
  122. package/dist/index.js +191 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/loyalty/AkinLoyaltyProvider.d.ts +18 -0
  125. package/dist/loyalty/AkinLoyaltyProvider.d.ts.map +1 -0
  126. package/dist/loyalty/AkinLoyaltyProvider.js +399 -0
  127. package/dist/loyalty/AkinLoyaltyProvider.js.map +1 -0
  128. package/dist/loyalty/components/LoyaltyCard.d.ts +48 -0
  129. package/dist/loyalty/components/LoyaltyCard.d.ts.map +1 -0
  130. package/dist/loyalty/components/LoyaltyCard.js +140 -0
  131. package/dist/loyalty/components/LoyaltyCard.js.map +1 -0
  132. package/dist/loyalty/components/PointsDisplay.d.ts +40 -0
  133. package/dist/loyalty/components/PointsDisplay.d.ts.map +1 -0
  134. package/dist/loyalty/components/PointsDisplay.js +32 -0
  135. package/dist/loyalty/components/PointsDisplay.js.map +1 -0
  136. package/dist/loyalty/components/PreviousStays.d.ts +59 -0
  137. package/dist/loyalty/components/PreviousStays.d.ts.map +1 -0
  138. package/dist/loyalty/components/PreviousStays.js +101 -0
  139. package/dist/loyalty/components/PreviousStays.js.map +1 -0
  140. package/dist/loyalty/components/SimpleTierCards.d.ts +51 -0
  141. package/dist/loyalty/components/SimpleTierCards.d.ts.map +1 -0
  142. package/dist/loyalty/components/SimpleTierCards.js +96 -0
  143. package/dist/loyalty/components/SimpleTierCards.js.map +1 -0
  144. package/dist/loyalty/components/TierCard.d.ts +30 -0
  145. package/dist/loyalty/components/TierCard.d.ts.map +1 -0
  146. package/dist/loyalty/components/TierCard.js +41 -0
  147. package/dist/loyalty/components/TierCard.js.map +1 -0
  148. package/dist/loyalty/components/TierProgress.d.ts +32 -0
  149. package/dist/loyalty/components/TierProgress.d.ts.map +1 -0
  150. package/dist/loyalty/components/TierProgress.js +41 -0
  151. package/dist/loyalty/components/TierProgress.js.map +1 -0
  152. package/dist/loyalty/components/TierRequirementsTable.d.ts +54 -0
  153. package/dist/loyalty/components/TierRequirementsTable.d.ts.map +1 -0
  154. package/dist/loyalty/components/TierRequirementsTable.js +104 -0
  155. package/dist/loyalty/components/TierRequirementsTable.js.map +1 -0
  156. package/dist/loyalty/components/TransactionList.d.ts +44 -0
  157. package/dist/loyalty/components/TransactionList.d.ts.map +1 -0
  158. package/dist/loyalty/components/TransactionList.js +112 -0
  159. package/dist/loyalty/components/TransactionList.js.map +1 -0
  160. package/dist/loyalty/components/UpcomingStays.d.ts +49 -0
  161. package/dist/loyalty/components/UpcomingStays.d.ts.map +1 -0
  162. package/dist/loyalty/components/UpcomingStays.js +60 -0
  163. package/dist/loyalty/components/UpcomingStays.js.map +1 -0
  164. package/dist/loyalty/index.d.ts +12 -0
  165. package/dist/loyalty/index.d.ts.map +1 -0
  166. package/dist/loyalty/index.js +27 -0
  167. package/dist/loyalty/index.js.map +1 -0
  168. package/dist/types/account.d.ts +108 -0
  169. package/dist/types/account.d.ts.map +1 -0
  170. package/dist/types/account.js +3 -0
  171. package/dist/types/account.js.map +1 -0
  172. package/dist/types/auth.d.ts +205 -0
  173. package/dist/types/auth.d.ts.map +1 -0
  174. package/dist/types/auth.js +3 -0
  175. package/dist/types/auth.js.map +1 -0
  176. package/dist/types/currency.d.ts +102 -0
  177. package/dist/types/currency.d.ts.map +1 -0
  178. package/dist/types/currency.js +3 -0
  179. package/dist/types/currency.js.map +1 -0
  180. package/dist/types/header.d.ts +105 -0
  181. package/dist/types/header.d.ts.map +1 -0
  182. package/dist/types/header.js +3 -0
  183. package/dist/types/header.js.map +1 -0
  184. package/dist/types/i18n.d.ts +90 -0
  185. package/dist/types/i18n.d.ts.map +1 -0
  186. package/dist/types/i18n.js +3 -0
  187. package/dist/types/i18n.js.map +1 -0
  188. package/dist/types/index.d.ts +3 -0
  189. package/dist/types/index.d.ts.map +1 -0
  190. package/dist/types/index.js +3 -0
  191. package/dist/types/index.js.map +1 -0
  192. package/dist/types/loyalty.d.ts +312 -0
  193. package/dist/types/loyalty.d.ts.map +1 -0
  194. package/dist/types/loyalty.js +3 -0
  195. package/dist/types/loyalty.js.map +1 -0
  196. package/dist/utils/index.d.ts +2 -0
  197. package/dist/utils/index.d.ts.map +1 -0
  198. package/dist/utils/index.js +10 -0
  199. package/dist/utils/index.js.map +1 -0
  200. package/dist/utils/tierLabels.d.ts +27 -0
  201. package/dist/utils/tierLabels.d.ts.map +1 -0
  202. package/dist/utils/tierLabels.js +110 -0
  203. package/dist/utils/tierLabels.js.map +1 -0
  204. package/package.json +60 -0
@@ -0,0 +1,57 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { LanguageOption, Translations, I18nConfig, I18nContextValue } from '../types/i18n';
3
+ /**
4
+ * Default bundled translations
5
+ */
6
+ export declare const DEFAULT_TRANSLATIONS: Translations;
7
+ /**
8
+ * Default available locales
9
+ */
10
+ export declare const DEFAULT_LOCALES: LanguageOption[];
11
+ interface I18nProviderProps {
12
+ children: ReactNode;
13
+ config?: I18nConfig;
14
+ }
15
+ /**
16
+ * Provider component for i18n context
17
+ *
18
+ * @example
19
+ * // Basic usage with defaults (English)
20
+ * <I18nProvider>
21
+ * <App />
22
+ * </I18nProvider>
23
+ *
24
+ * @example
25
+ * // With custom locale and translations
26
+ * <I18nProvider config={{
27
+ * locale: 'es',
28
+ * translations: {
29
+ * es: { custom: { greeting: 'Hola!' } }
30
+ * }
31
+ * }}>
32
+ * <App />
33
+ * </I18nProvider>
34
+ */
35
+ export declare function I18nProvider({ children, config }: I18nProviderProps): import("react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * Hook to access i18n context
38
+ *
39
+ * @example
40
+ * const { t, locale, setLocale } = useI18n();
41
+ *
42
+ * return (
43
+ * <div>
44
+ * <h1>{t('auth.login.title')}</h1>
45
+ * <p>{t('loyalty.points', { count: 100 })}</p>
46
+ * <button onClick={() => setLocale('es')}>Español</button>
47
+ * </div>
48
+ * );
49
+ */
50
+ export declare function useI18n(): I18nContextValue;
51
+ /**
52
+ * Optional context for cases where i18n might not be configured
53
+ * Returns undefined if not in provider, instead of throwing
54
+ */
55
+ export declare function useOptionalI18n(): I18nContextValue | undefined;
56
+ export {};
57
+ //# sourceMappingURL=I18nProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../src/i18n/I18nProvider.tsx"],"names":[],"mappings":"AAEA,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,cAAc,EAEd,YAAY,EACZ,UAAU,EACV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAMvB;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,YAGlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,EAG3C,CAAC;AAwEF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,iBAAiB,2CAqGnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,IAAI,gBAAgB,CAM1C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,GAAG,SAAS,CAE9D"}
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DEFAULT_LOCALES = exports.DEFAULT_TRANSLATIONS = void 0;
8
+ exports.I18nProvider = I18nProvider;
9
+ exports.useI18n = useI18n;
10
+ exports.useOptionalI18n = useOptionalI18n;
11
+ const jsx_runtime_1 = require("react/jsx-runtime");
12
+ const react_1 = require("react");
13
+ // Import bundled translations
14
+ const en_json_1 = __importDefault(require("./translations/en.json"));
15
+ const es_json_1 = __importDefault(require("./translations/es.json"));
16
+ /**
17
+ * Default bundled translations
18
+ */
19
+ exports.DEFAULT_TRANSLATIONS = {
20
+ en: en_json_1.default,
21
+ es: es_json_1.default,
22
+ };
23
+ /**
24
+ * Default available locales
25
+ */
26
+ exports.DEFAULT_LOCALES = [
27
+ { code: 'en', name: 'English', nativeName: 'English' },
28
+ { code: 'es', name: 'Spanish', nativeName: 'Español' },
29
+ ];
30
+ // Storage key for persisting locale
31
+ const LOCALE_STORAGE_KEY = 'akin_locale';
32
+ // Context
33
+ const I18nContext = (0, react_1.createContext)(undefined);
34
+ /**
35
+ * Get nested value from object using dot notation path
36
+ */
37
+ function getNestedValue(obj, path) {
38
+ const keys = path.split('.');
39
+ let current = obj;
40
+ for (const key of keys) {
41
+ if (typeof current !== 'object' || current === null) {
42
+ return undefined;
43
+ }
44
+ current = current[key];
45
+ if (current === undefined) {
46
+ return undefined;
47
+ }
48
+ }
49
+ return typeof current === 'string' ? current : undefined;
50
+ }
51
+ /**
52
+ * Interpolate parameters into a string
53
+ * Replaces {paramName} with the value from params
54
+ */
55
+ function interpolate(str, params) {
56
+ if (!params)
57
+ return str;
58
+ return str.replace(/\{(\w+)\}/g, (match, key) => {
59
+ const value = params[key];
60
+ return value !== undefined ? String(value) : match;
61
+ });
62
+ }
63
+ /**
64
+ * Deep merge two translation dictionaries
65
+ */
66
+ function mergeTranslations(base, override) {
67
+ const result = { ...base };
68
+ for (const key of Object.keys(override)) {
69
+ const baseValue = base[key];
70
+ const overrideValue = override[key];
71
+ if (typeof baseValue === 'object' &&
72
+ baseValue !== null &&
73
+ typeof overrideValue === 'object' &&
74
+ overrideValue !== null) {
75
+ result[key] = mergeTranslations(baseValue, overrideValue);
76
+ }
77
+ else {
78
+ result[key] = overrideValue;
79
+ }
80
+ }
81
+ return result;
82
+ }
83
+ /**
84
+ * Provider component for i18n context
85
+ *
86
+ * @example
87
+ * // Basic usage with defaults (English)
88
+ * <I18nProvider>
89
+ * <App />
90
+ * </I18nProvider>
91
+ *
92
+ * @example
93
+ * // With custom locale and translations
94
+ * <I18nProvider config={{
95
+ * locale: 'es',
96
+ * translations: {
97
+ * es: { custom: { greeting: 'Hola!' } }
98
+ * }
99
+ * }}>
100
+ * <App />
101
+ * </I18nProvider>
102
+ */
103
+ function I18nProvider({ children, config }) {
104
+ // Get initial locale from config, storage, or default to 'en'
105
+ const getInitialLocale = () => {
106
+ if (config?.locale)
107
+ return config.locale;
108
+ // Try to get from localStorage
109
+ if (typeof window !== 'undefined') {
110
+ const stored = localStorage.getItem(LOCALE_STORAGE_KEY);
111
+ if (stored)
112
+ return stored;
113
+ }
114
+ return 'en';
115
+ };
116
+ const [locale, setLocaleState] = (0, react_1.useState)(getInitialLocale);
117
+ // Merge custom translations with defaults
118
+ const translations = (0, react_1.useMemo)(() => {
119
+ const merged = { ...exports.DEFAULT_TRANSLATIONS };
120
+ if (config?.translations) {
121
+ for (const localeKey of Object.keys(config.translations)) {
122
+ if (merged[localeKey]) {
123
+ merged[localeKey] = mergeTranslations(merged[localeKey], config.translations[localeKey]);
124
+ }
125
+ else {
126
+ merged[localeKey] = config.translations[localeKey];
127
+ }
128
+ }
129
+ }
130
+ return merged;
131
+ }, [config?.translations]);
132
+ // Available locales
133
+ const availableLocales = (0, react_1.useMemo)(() => {
134
+ return config?.availableLocales ?? exports.DEFAULT_LOCALES;
135
+ }, [config?.availableLocales]);
136
+ // Get current language option
137
+ const currentLanguage = (0, react_1.useMemo)(() => {
138
+ return (availableLocales.find((l) => l.code === locale) ?? {
139
+ code: locale,
140
+ name: locale,
141
+ nativeName: locale,
142
+ });
143
+ }, [availableLocales, locale]);
144
+ // Set locale handler
145
+ const setLocale = (0, react_1.useCallback)((newLocale) => {
146
+ setLocaleState(newLocale);
147
+ // Persist to localStorage
148
+ if (typeof window !== 'undefined') {
149
+ localStorage.setItem(LOCALE_STORAGE_KEY, newLocale);
150
+ }
151
+ // Call external callback
152
+ config?.onLocaleChange?.(newLocale);
153
+ }, [config]);
154
+ // Translation function
155
+ const t = (0, react_1.useCallback)((key, params) => {
156
+ // Try current locale
157
+ let value = getNestedValue(translations[locale] ?? {}, key);
158
+ // Fallback to English
159
+ if (value === undefined && locale !== 'en') {
160
+ value = getNestedValue(translations.en ?? {}, key);
161
+ }
162
+ // Return key if no translation found
163
+ if (value === undefined) {
164
+ return key;
165
+ }
166
+ return interpolate(value, params);
167
+ }, [locale, translations]);
168
+ const value = (0, react_1.useMemo)(() => ({
169
+ locale,
170
+ availableLocales,
171
+ currentLanguage,
172
+ setLocale,
173
+ t,
174
+ }), [locale, availableLocales, currentLanguage, setLocale, t]);
175
+ return (0, jsx_runtime_1.jsx)(I18nContext.Provider, { value: value, children: children });
176
+ }
177
+ /**
178
+ * Hook to access i18n context
179
+ *
180
+ * @example
181
+ * const { t, locale, setLocale } = useI18n();
182
+ *
183
+ * return (
184
+ * <div>
185
+ * <h1>{t('auth.login.title')}</h1>
186
+ * <p>{t('loyalty.points', { count: 100 })}</p>
187
+ * <button onClick={() => setLocale('es')}>Español</button>
188
+ * </div>
189
+ * );
190
+ */
191
+ function useI18n() {
192
+ const context = (0, react_1.useContext)(I18nContext);
193
+ if (!context) {
194
+ throw new Error('useI18n must be used within an I18nProvider or AkinProvider');
195
+ }
196
+ return context;
197
+ }
198
+ /**
199
+ * Optional context for cases where i18n might not be configured
200
+ * Returns undefined if not in provider, instead of throwing
201
+ */
202
+ function useOptionalI18n() {
203
+ return (0, react_1.useContext)(I18nContext);
204
+ }
205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C,EACD,CAAC,MAAM,EAAE,YAAY,CAAC,CACvB,CAAC;IAEF,MAAM,KAAK,GAAqB,IAAA,eAAO,EACrC,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,gBAAgB;QAChB,eAAe;QACf,SAAS;QACT,CAAC;KACF,CAAC,EACF,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,CAC1D,CAAC;IAEF,OAAO,uBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,OAAO;IACrB,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe;IAC7B,OAAO,IAAA,kBAAU,EAAC,WAAW,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { LocaleCode, LanguageSelectorRenderProps } from '../../types/i18n';
3
+ export interface LanguageSelectorProps {
4
+ /**
5
+ * Render function receiving selector state and actions
6
+ */
7
+ children: (props: LanguageSelectorRenderProps) => ReactNode;
8
+ /**
9
+ * Callback when locale changes
10
+ */
11
+ onLocaleChange?: (locale: LocaleCode) => void;
12
+ /**
13
+ * Default open state
14
+ */
15
+ defaultOpen?: boolean;
16
+ }
17
+ /**
18
+ * Headless language selector component
19
+ *
20
+ * @example
21
+ * <LanguageSelector>
22
+ * {({ currentLanguage, availableLocales, setLocale, isOpen, toggle }) => (
23
+ * <div>
24
+ * <button onClick={toggle}>
25
+ * {currentLanguage.nativeName}
26
+ * </button>
27
+ * {isOpen && (
28
+ * <ul>
29
+ * {availableLocales.map((lang) => (
30
+ * <li key={lang.code}>
31
+ * <button onClick={() => setLocale(lang.code)}>
32
+ * {lang.nativeName}
33
+ * </button>
34
+ * </li>
35
+ * ))}
36
+ * </ul>
37
+ * )}
38
+ * </div>
39
+ * )}
40
+ * </LanguageSelector>
41
+ */
42
+ export declare function LanguageSelector({ children, onLocaleChange, defaultOpen, }: LanguageSelectorProps): import("react/jsx-runtime").JSX.Element;
43
+ //# sourceMappingURL=LanguageSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LanguageSelector.d.ts","sourceRoot":"","sources":["../../../src/i18n/components/LanguageSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,SAAS,CAAC;IAC5D;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9C;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,cAAc,EACd,WAAmB,GACpB,EAAE,qBAAqB,2CAkCvB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.LanguageSelector = LanguageSelector;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const I18nProvider_1 = require("../I18nProvider");
8
+ /**
9
+ * Headless language selector component
10
+ *
11
+ * @example
12
+ * <LanguageSelector>
13
+ * {({ currentLanguage, availableLocales, setLocale, isOpen, toggle }) => (
14
+ * <div>
15
+ * <button onClick={toggle}>
16
+ * {currentLanguage.nativeName}
17
+ * </button>
18
+ * {isOpen && (
19
+ * <ul>
20
+ * {availableLocales.map((lang) => (
21
+ * <li key={lang.code}>
22
+ * <button onClick={() => setLocale(lang.code)}>
23
+ * {lang.nativeName}
24
+ * </button>
25
+ * </li>
26
+ * ))}
27
+ * </ul>
28
+ * )}
29
+ * </div>
30
+ * )}
31
+ * </LanguageSelector>
32
+ */
33
+ function LanguageSelector({ children, onLocaleChange, defaultOpen = false, }) {
34
+ const { locale, currentLanguage, availableLocales, setLocale: setI18nLocale } = (0, I18nProvider_1.useI18n)();
35
+ const [isOpen, setIsOpen] = (0, react_1.useState)(defaultOpen);
36
+ const toggle = (0, react_1.useCallback)(() => {
37
+ setIsOpen((prev) => !prev);
38
+ }, []);
39
+ const close = (0, react_1.useCallback)(() => {
40
+ setIsOpen(false);
41
+ }, []);
42
+ const setLocale = (0, react_1.useCallback)((newLocale) => {
43
+ setI18nLocale(newLocale);
44
+ onLocaleChange?.(newLocale);
45
+ close();
46
+ }, [setI18nLocale, onLocaleChange, close]);
47
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
48
+ locale,
49
+ currentLanguage,
50
+ availableLocales,
51
+ setLocale,
52
+ isOpen,
53
+ toggle,
54
+ close,
55
+ }) }));
56
+ }
57
+ //# sourceMappingURL=LanguageSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LanguageSelector.js","sourceRoot":"","sources":["../../../src/i18n/components/LanguageSelector.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AA8Cb,4CAsCC;;AAlFD,iCAA8D;AAC9D,kDAA0C;AAkB1C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,cAAc,EACd,WAAW,GAAG,KAAK,GACG;IACtB,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAA,sBAAO,GAAE,CAAC;IAC1F,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,WAAW,CAAC,CAAC;IAElD,MAAM,MAAM,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC9B,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC7B,SAAS,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,IAAA,mBAAW,EAC3B,CAAC,SAAqB,EAAE,EAAE;QACxB,aAAa,CAAC,SAAS,CAAC,CAAC;QACzB,cAAc,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,KAAK,EAAE,CAAC;IACV,CAAC,EACD,CAAC,aAAa,EAAE,cAAc,EAAE,KAAK,CAAC,CACvC,CAAC;IAEF,OAAO,CACL,2DACG,QAAQ,CAAC;YACR,MAAM;YACN,eAAe;YACf,gBAAgB;YAChB,SAAS;YACT,MAAM;YACN,MAAM;YACN,KAAK;SACN,CAAC,GACD,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { I18nProvider, useI18n, useOptionalI18n, DEFAULT_TRANSLATIONS, DEFAULT_LOCALES, } from './I18nProvider';
2
+ export { LanguageSelector } from './components/LanguageSelector';
3
+ export type { LocaleCode, LanguageOption, TranslationDictionary, Translations, I18nConfig, I18nState, I18nActions, I18nContextValue, LanguageSelectorRenderProps, } from '../types/i18n';
4
+ export type { LanguageSelectorProps } from './components/LanguageSelector';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,YAAY,EACV,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LanguageSelector = exports.DEFAULT_LOCALES = exports.DEFAULT_TRANSLATIONS = exports.useOptionalI18n = exports.useI18n = exports.I18nProvider = void 0;
4
+ // Provider and hooks
5
+ var I18nProvider_1 = require("./I18nProvider");
6
+ Object.defineProperty(exports, "I18nProvider", { enumerable: true, get: function () { return I18nProvider_1.I18nProvider; } });
7
+ Object.defineProperty(exports, "useI18n", { enumerable: true, get: function () { return I18nProvider_1.useI18n; } });
8
+ Object.defineProperty(exports, "useOptionalI18n", { enumerable: true, get: function () { return I18nProvider_1.useOptionalI18n; } });
9
+ Object.defineProperty(exports, "DEFAULT_TRANSLATIONS", { enumerable: true, get: function () { return I18nProvider_1.DEFAULT_TRANSLATIONS; } });
10
+ Object.defineProperty(exports, "DEFAULT_LOCALES", { enumerable: true, get: function () { return I18nProvider_1.DEFAULT_LOCALES; } });
11
+ // Components
12
+ var LanguageSelector_1 = require("./components/LanguageSelector");
13
+ Object.defineProperty(exports, "LanguageSelector", { enumerable: true, get: function () { return LanguageSelector_1.LanguageSelector; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,+CAMwB;AALtB,4GAAA,YAAY,OAAA;AACZ,uGAAA,OAAO,OAAA;AACP,+GAAA,eAAe,OAAA;AACf,oHAAA,oBAAoB,OAAA;AACpB,+GAAA,eAAe,OAAA;AAGjB,aAAa;AACb,kEAAiE;AAAxD,oHAAA,gBAAgB,OAAA"}