@nicorp/nui 0.6.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 +80 -30
- package/dist/index.es.js +2591 -2552
- 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> {
|
|
@@ -1100,32 +1105,6 @@ export declare interface NUILocale {
|
|
|
1100
1105
|
breadcrumb_more: string;
|
|
1101
1106
|
}
|
|
1102
1107
|
|
|
1103
|
-
/**
|
|
1104
|
-
* Provides a locale dictionary to every NUI AI component in the tree.
|
|
1105
|
-
*
|
|
1106
|
-
* @example
|
|
1107
|
-
* ```tsx
|
|
1108
|
-
* <NUIProvider locale="ru">
|
|
1109
|
-
* <App />
|
|
1110
|
-
* </NUIProvider>
|
|
1111
|
-
* ```
|
|
1112
|
-
*
|
|
1113
|
-
* @example Custom locale
|
|
1114
|
-
* ```tsx
|
|
1115
|
-
* <NUIProvider locale={{ chatInput_placeholder: "Ask anything…" }}>
|
|
1116
|
-
* <App />
|
|
1117
|
-
* </NUIProvider>
|
|
1118
|
-
* ```
|
|
1119
|
-
*/
|
|
1120
|
-
export declare function NUIProvider({ locale, children }: NUIProviderProps): JSX_2.Element;
|
|
1121
|
-
|
|
1122
|
-
export declare interface NUIProviderProps {
|
|
1123
|
-
/** Built-in locale key ("en" | "ru") or a custom (partial) locale dictionary.
|
|
1124
|
-
* Missing keys fall back to English. */
|
|
1125
|
-
locale?: "en" | "ru" | (string & {}) | Partial<NUILocale>;
|
|
1126
|
-
children: React_2.ReactNode;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
1108
|
export declare function NumberInput({ value, onChange, min, max, step, disabled, className, }: NumberInputProps): JSX_2.Element;
|
|
1130
1109
|
|
|
1131
1110
|
export declare interface NumberInputProps {
|
|
@@ -1420,6 +1399,9 @@ export declare const textVariants: (props?: ({
|
|
|
1420
1399
|
leading?: "normal" | "tight" | "relaxed" | null | undefined;
|
|
1421
1400
|
} & ClassProp) | undefined) => string;
|
|
1422
1401
|
|
|
1402
|
+
/** Translation function returned by `useLocale()`. */
|
|
1403
|
+
export declare type TFunction = (key: string, vars?: Record<string, string | number>) => string;
|
|
1404
|
+
|
|
1423
1405
|
export declare type Theme = "dark" | "light" | "system";
|
|
1424
1406
|
|
|
1425
1407
|
export declare function ThemeProvider({ children, defaultTheme, storageKey, attribute, enableSystem, disableTransitionOnChange, forcedTheme, nonce, }: ThemeProviderProps): JSX_2.Element;
|
|
@@ -1519,22 +1501,90 @@ export declare const TooltipTrigger: React_2.ForwardRefExoticComponent<TooltipPr
|
|
|
1519
1501
|
*
|
|
1520
1502
|
* @example
|
|
1521
1503
|
* ```ts
|
|
1522
|
-
*
|
|
1504
|
+
* tpl("Calling {name}...", { name: "search" })
|
|
1523
1505
|
* // → "Calling search..."
|
|
1524
1506
|
* ```
|
|
1525
1507
|
*/
|
|
1526
1508
|
export declare function tpl(template: string, vars: Record<string, string | number>): string;
|
|
1527
1509
|
|
|
1510
|
+
/**
|
|
1511
|
+
* Provides i18n for both NUI components **and** your own app strings.
|
|
1512
|
+
*
|
|
1513
|
+
* @example NUI-only (component translations)
|
|
1514
|
+
* ```tsx
|
|
1515
|
+
* <TranslateProvider locale="ru">
|
|
1516
|
+
* <App />
|
|
1517
|
+
* </TranslateProvider>
|
|
1518
|
+
* ```
|
|
1519
|
+
*
|
|
1520
|
+
* @example With user JSON dictionaries
|
|
1521
|
+
* ```tsx
|
|
1522
|
+
* import en from "./locales/en.json"
|
|
1523
|
+
* import ru from "./locales/ru.json"
|
|
1524
|
+
*
|
|
1525
|
+
* <TranslateProvider locale="ru" messages={{ en, ru }}>
|
|
1526
|
+
* <App />
|
|
1527
|
+
* </TranslateProvider>
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
declare function TranslateProvider({ locale, messages, children }: TranslateProviderProps): JSX_2.Element;
|
|
1531
|
+
export { TranslateProvider as NUIProvider }
|
|
1532
|
+
export { TranslateProvider }
|
|
1533
|
+
|
|
1534
|
+
export declare interface TranslateProviderProps {
|
|
1535
|
+
/** Built-in locale key ("en" | "ru") or a custom (partial) NUI locale dictionary.
|
|
1536
|
+
* Missing keys fall back to English. */
|
|
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>;
|
|
1552
|
+
children: React_2.ReactNode;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1528
1555
|
declare type UseCarouselParameters = Parameters<typeof default_2>;
|
|
1529
1556
|
|
|
1530
1557
|
/**
|
|
1531
|
-
* Returns
|
|
1532
|
-
*
|
|
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
|
+
* ```
|
|
1533
1572
|
*/
|
|
1534
|
-
export declare function
|
|
1573
|
+
export declare function useLocale(): {
|
|
1574
|
+
t: TFunction;
|
|
1575
|
+
lang: string;
|
|
1576
|
+
};
|
|
1535
1577
|
|
|
1536
1578
|
export declare function useTheme(): ThemeProviderState;
|
|
1537
1579
|
|
|
1580
|
+
/**
|
|
1581
|
+
* Returns the current NUI locale dictionary (built-in component strings).
|
|
1582
|
+
* Falls back to English when used outside a `<TranslateProvider>`.
|
|
1583
|
+
*/
|
|
1584
|
+
declare function useTranslate(): NUILocale;
|
|
1585
|
+
export { useTranslate as useNUILocale }
|
|
1586
|
+
export { useTranslate }
|
|
1587
|
+
|
|
1538
1588
|
export declare const VStack: React_2.ForwardRefExoticComponent<StackProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
1539
1589
|
|
|
1540
1590
|
export { }
|