@npm-questionpro/wick-ui-lib 1.49.0 → 1.49.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.
@@ -1,12 +1,33 @@
1
1
  import { default as React } from 'react';
2
2
  export type IWuDictionary = Record<string, string>;
3
+ /** Shape of the POST /translate API response for non-English locales. */
4
+ export interface IWuTranslateApiResponse {
5
+ data: {
6
+ data: IWuDictionary;
7
+ isRtl?: boolean;
8
+ characterSet?: string;
9
+ };
10
+ }
3
11
  interface IWuTranslateContextProps {
4
12
  dictionary: IWuDictionary;
5
13
  locale: string;
6
14
  setLocale: (locale: string) => void;
7
15
  isLoading: boolean;
16
+ isRtl: boolean;
17
+ characterSet: string;
18
+ /** Reactive alternative to `wt()`. Use inside components to avoid stale values on reload. */
19
+ translate: (key: string) => string;
8
20
  }
9
21
  export declare const useTranslate: () => IWuTranslateContextProps;
22
+ /**
23
+ * Reactive translate hook for use inside components.
24
+ * Re-renders the component when the dictionary updates.
25
+ *
26
+ * @example
27
+ * const t = useWt()
28
+ * return <button>{t('Submit')}</button>
29
+ */
30
+ export declare const useWt: () => ((key: string) => string);
10
31
  export interface IWuTranslateProviderProps {
11
32
  children: React.ReactNode;
12
33
  defaultLocale?: string;
@@ -1,3 +1,3 @@
1
1
  export { WuTranslate, type IWuTranslateProps } from './WuTranslate';
2
- export { wt } from './wt';
3
- export { useTranslate as useWickuiTranslate, WuTranslateProvider, } from './WuTranslateContext';
2
+ export { wt, wtIsRtl, wtCharacterSet } from './wt';
3
+ export { useTranslate as useWickuiTranslate, useWt, WuTranslateProvider, type IWuDictionary, type IWuTranslateApiResponse, type IWuTranslateProviderProps, } from './WuTranslateContext';
@@ -1,13 +1,16 @@
1
1
  export declare const setWtDictionary: (dict: Record<string, string>) => void;
2
+ export declare const setWtMeta: (isRtl: boolean, characterSet: string) => void;
2
3
  /**
3
4
  * Translate a key to the current locale string.
4
5
  * Falls back to the key itself if no translation is found.
5
- *
6
- * Can be used anywhere inside or outside React components.
6
+ * Non-reactive — safe for event handlers and non-React code.
7
+ * Inside components prefer `useWt()` to avoid stale values on page reload.
7
8
  *
8
9
  * @example
9
- * import { wt } from '@npm-questionpro/wick-ui-lib'
10
- * window.alert(wt('Are you sure?'))
11
10
  * placeholder={wt('Enter name')}
12
11
  */
13
12
  export declare const wt: (key: string) => string;
13
+ /** Non-reactive RTL flag from the last translation API response. */
14
+ export declare const wtIsRtl: () => boolean;
15
+ /** Non-reactive character set from the last translation API response. */
16
+ export declare const wtCharacterSet: () => string;