@nicorp/nui 0.7.0 → 0.8.0
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/dist/index.cjs.js +10 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +54 -8
- package/dist/index.es.js +2590 -2553
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -910,6 +910,11 @@ export declare interface MessageActionsProps extends React_2.HTMLAttributes<HTML
|
|
|
910
910
|
|
|
911
911
|
export declare type MessageActionType = "copy" | "retry" | "edit" | "like" | "dislike" | "share";
|
|
912
912
|
|
|
913
|
+
/** Recursive JSON dictionary — values are strings or nested objects. */
|
|
914
|
+
export declare type MessageDictionary = {
|
|
915
|
+
[key: string]: string | MessageDictionary;
|
|
916
|
+
};
|
|
917
|
+
|
|
913
918
|
export declare function MetricCard({ title, value, description, trend, trendLabel, icon, className, ...props }: MetricCardProps): JSX_2.Element;
|
|
914
919
|
|
|
915
920
|
declare interface MetricCardProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
@@ -1394,6 +1399,9 @@ export declare const textVariants: (props?: ({
|
|
|
1394
1399
|
leading?: "normal" | "tight" | "relaxed" | null | undefined;
|
|
1395
1400
|
} & ClassProp) | undefined) => string;
|
|
1396
1401
|
|
|
1402
|
+
/** Translation function returned by `useLocale()`. */
|
|
1403
|
+
export declare type TFunction = (key: string, vars?: Record<string, string | number>) => string;
|
|
1404
|
+
|
|
1397
1405
|
export declare type Theme = "dark" | "light" | "system";
|
|
1398
1406
|
|
|
1399
1407
|
export declare function ThemeProvider({ children, defaultTheme, storageKey, attribute, enableSystem, disableTransitionOnChange, forcedTheme, nonce, }: ThemeProviderProps): JSX_2.Element;
|
|
@@ -1493,46 +1501,84 @@ export declare const TooltipTrigger: React_2.ForwardRefExoticComponent<TooltipPr
|
|
|
1493
1501
|
*
|
|
1494
1502
|
* @example
|
|
1495
1503
|
* ```ts
|
|
1496
|
-
*
|
|
1504
|
+
* tpl("Calling {name}...", { name: "search" })
|
|
1497
1505
|
* // → "Calling search..."
|
|
1498
1506
|
* ```
|
|
1499
1507
|
*/
|
|
1500
1508
|
export declare function tpl(template: string, vars: Record<string, string | number>): string;
|
|
1501
1509
|
|
|
1502
1510
|
/**
|
|
1503
|
-
* Provides
|
|
1511
|
+
* Provides i18n for both NUI components **and** your own app strings.
|
|
1504
1512
|
*
|
|
1505
|
-
* @example
|
|
1513
|
+
* @example NUI-only (component translations)
|
|
1506
1514
|
* ```tsx
|
|
1507
1515
|
* <TranslateProvider locale="ru">
|
|
1508
1516
|
* <App />
|
|
1509
1517
|
* </TranslateProvider>
|
|
1510
1518
|
* ```
|
|
1511
1519
|
*
|
|
1512
|
-
* @example
|
|
1520
|
+
* @example With user JSON dictionaries
|
|
1513
1521
|
* ```tsx
|
|
1514
|
-
*
|
|
1522
|
+
* import en from "./locales/en.json"
|
|
1523
|
+
* import ru from "./locales/ru.json"
|
|
1524
|
+
*
|
|
1525
|
+
* <TranslateProvider locale="ru" messages={{ en, ru }}>
|
|
1515
1526
|
* <App />
|
|
1516
1527
|
* </TranslateProvider>
|
|
1517
1528
|
* ```
|
|
1518
1529
|
*/
|
|
1519
|
-
declare function TranslateProvider({ locale, children }: TranslateProviderProps): JSX_2.Element;
|
|
1530
|
+
declare function TranslateProvider({ locale, messages, children }: TranslateProviderProps): JSX_2.Element;
|
|
1520
1531
|
export { TranslateProvider as NUIProvider }
|
|
1521
1532
|
export { TranslateProvider }
|
|
1522
1533
|
|
|
1523
1534
|
export declare interface TranslateProviderProps {
|
|
1524
|
-
/** Built-in locale key ("en" | "ru") or a custom (partial) locale dictionary.
|
|
1535
|
+
/** Built-in locale key ("en" | "ru") or a custom (partial) NUI locale dictionary.
|
|
1525
1536
|
* Missing keys fall back to English. */
|
|
1526
1537
|
locale?: "en" | "ru" | (string & {}) | Partial<NUILocale>;
|
|
1538
|
+
/**
|
|
1539
|
+
* User JSON dictionaries for app-level translations.
|
|
1540
|
+
*
|
|
1541
|
+
* @example
|
|
1542
|
+
* ```tsx
|
|
1543
|
+
* import en from "./locales/en.json"
|
|
1544
|
+
* import ru from "./locales/ru.json"
|
|
1545
|
+
*
|
|
1546
|
+
* <TranslateProvider locale="ru" messages={{ en, ru }}>
|
|
1547
|
+
* <App />
|
|
1548
|
+
* </TranslateProvider>
|
|
1549
|
+
* ```
|
|
1550
|
+
*/
|
|
1551
|
+
messages?: Record<string, MessageDictionary>;
|
|
1527
1552
|
children: React_2.ReactNode;
|
|
1528
1553
|
}
|
|
1529
1554
|
|
|
1530
1555
|
declare type UseCarouselParameters = Parameters<typeof default_2>;
|
|
1531
1556
|
|
|
1557
|
+
/**
|
|
1558
|
+
* Returns `{ t, lang }` for translating your own app strings.
|
|
1559
|
+
*
|
|
1560
|
+
* `t("profile.save")` resolves dot-paths in your JSON dictionaries.
|
|
1561
|
+
* Variables: `t("greeting", { name: "Alex" })` → replaces `{name}`.
|
|
1562
|
+
*
|
|
1563
|
+
* Fallback chain: **active lang → "en" → raw key**.
|
|
1564
|
+
*
|
|
1565
|
+
* @example
|
|
1566
|
+
* ```tsx
|
|
1567
|
+
* function MyButton() {
|
|
1568
|
+
* const { t } = useLocale()
|
|
1569
|
+
* return <button>{t("profile.save")}</button>
|
|
1570
|
+
* }
|
|
1571
|
+
* ```
|
|
1572
|
+
*/
|
|
1573
|
+
export declare function useLocale(): {
|
|
1574
|
+
t: TFunction;
|
|
1575
|
+
lang: string;
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1532
1578
|
export declare function useTheme(): ThemeProviderState;
|
|
1533
1579
|
|
|
1534
1580
|
/**
|
|
1535
|
-
* Returns the current NUI locale dictionary.
|
|
1581
|
+
* Returns the current NUI locale dictionary (built-in component strings).
|
|
1536
1582
|
* Falls back to English when used outside a `<TranslateProvider>`.
|
|
1537
1583
|
*/
|
|
1538
1584
|
declare function useTranslate(): NUILocale;
|