@redocly/theme 0.39.1 → 0.40.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.
@@ -9,9 +9,9 @@ const styled_components_1 = __importDefault(require("styled-components"));
9
9
  const hooks_1 = require("../../core/hooks");
10
10
  const LanguagePicker_1 = require("../../components/LanguagePicker/LanguagePicker");
11
11
  function FooterCopyright({ copyrightText = '', className, }) {
12
- const { useTranslate, useI18n } = (0, hooks_1.useThemeHooks)();
12
+ const { useTranslate, useL10n } = (0, hooks_1.useThemeHooks)();
13
13
  const { translate } = useTranslate();
14
- const { changeLanguage } = useI18n();
14
+ const { changeLanguage } = useL10n();
15
15
  return copyrightText ? (react_1.default.createElement(FooterCopyrightWrapper, { className: className, "data-component-name": "Footer/FooterCopyright", "data-translation-key": "theme.footer.copyrightText" },
16
16
  react_1.default.createElement(FooterCopyrightLabel, { "data-translation-key": "theme.footer.copyrightText" }, translate('theme.footer.copyrightText', copyrightText)),
17
17
  react_1.default.createElement(LanguagePicker_1.LanguagePicker, { onChangeLanguage: changeLanguage, placement: "top", alignment: "end" }))) : null;
@@ -40,9 +40,9 @@ const FORMATS = {
40
40
  };
41
41
  function LastUpdated(props) {
42
42
  const { markdown: { lastUpdatedBlock = {} } = {} } = (0, hooks_1.useThemeConfig)();
43
- const { useTranslate, useI18nConfig } = (0, hooks_1.useThemeHooks)();
43
+ const { useTranslate, useL10nConfig } = (0, hooks_1.useThemeHooks)();
44
44
  const { translate } = useTranslate();
45
- const { currentLocale } = useI18nConfig();
45
+ const { currentLocale } = useL10nConfig();
46
46
  if (lastUpdatedBlock === null || lastUpdatedBlock === void 0 ? void 0 : lastUpdatedBlock.hide) {
47
47
  return null;
48
48
  }
@@ -23,8 +23,8 @@ function Navbar({ className }) {
23
23
  var _a;
24
24
  const { isOpen, openMobileMenu, closeMobileMenu } = (0, hooks_1.useMobileMenu)(false);
25
25
  const themeConfig = (0, hooks_1.useThemeConfig)();
26
- const { useI18n, useTelemetry } = (0, hooks_1.useThemeHooks)();
27
- const { changeLanguage } = useI18n();
26
+ const { useL10n, useTelemetry } = (0, hooks_1.useThemeHooks)();
27
+ const { changeLanguage } = useL10n();
28
28
  const telemetry = useTelemetry();
29
29
  const menu = (_a = themeConfig.navbar) === null || _a === void 0 ? void 0 : _a.items;
30
30
  const { search: searchSettings, navbar, userMenu: userMenuSettings, logo } = themeConfig;
@@ -39,9 +39,9 @@ const Link_1 = require("../../components/Link/Link");
39
39
  const Dropdown_1 = require("../../components/Dropdown/Dropdown");
40
40
  function NavbarItem({ navItem, className }) {
41
41
  const { pathname } = (0, react_router_dom_1.useLocation)();
42
- const { useTranslate, useI18nConfig, useTelemetry } = (0, hooks_1.useThemeHooks)();
42
+ const { useTranslate, useL10nConfig, useTelemetry } = (0, hooks_1.useThemeHooks)();
43
43
  const { translate } = useTranslate();
44
- const { defaultLocale, currentLocale, locales } = useI18nConfig();
44
+ const { defaultLocale, currentLocale, locales } = useL10nConfig();
45
45
  const telemetry = useTelemetry();
46
46
  if (navItem.type !== 'link' && !navItem.items)
47
47
  return null;
@@ -14,10 +14,10 @@ export declare const useThemeHooks: jest.Mock<{
14
14
  filterTerm: string;
15
15
  setFilterTerm: jest.Mock<any, any, any>;
16
16
  }, [], any>;
17
- useI18n: jest.Mock<{
17
+ useL10n: jest.Mock<{
18
18
  changeLanguage: jest.Mock<any, any, any>;
19
19
  }, [], any>;
20
- useI18nConfig: jest.Mock<{
20
+ useL10nConfig: jest.Mock<{
21
21
  currentLocale: string;
22
22
  defaultLocale: string;
23
23
  locales: {
@@ -20,10 +20,10 @@ exports.useThemeHooks = jest.fn(() => ({
20
20
  filterTerm: '',
21
21
  setFilterTerm: jest.fn(),
22
22
  })),
23
- useI18n: jest.fn(() => ({
23
+ useL10n: jest.fn(() => ({
24
24
  changeLanguage: jest.fn(),
25
25
  })),
26
- useI18nConfig: jest.fn(() => ({
26
+ useL10nConfig: jest.fn(() => ({
27
27
  currentLocale: 'en',
28
28
  defaultLocale: 'en',
29
29
  locales: [
@@ -11,9 +11,9 @@ const MENU_SEPARATOR = {
11
11
  };
12
12
  const useMobileMenuItems = (menuType) => {
13
13
  var _a, _b, _c;
14
- const { useTranslate, useI18nConfig, useCurrentProduct, usePageVersions, useSidebarItems } = (0, hooks_1.useThemeHooks)();
14
+ const { useTranslate, useL10nConfig, useCurrentProduct, usePageVersions, useSidebarItems } = (0, hooks_1.useThemeHooks)();
15
15
  const { versions = [] } = usePageVersions() || {};
16
- const { defaultLocale, currentLocale, locales } = useI18nConfig();
16
+ const { defaultLocale, currentLocale, locales } = useL10nConfig();
17
17
  const { translate } = useTranslate();
18
18
  const activeVersion = versions.find((version) => version.active);
19
19
  const { currentItems: sidebarItems, pushDrilldownState, popDrilldownState, backLink, } = useSidebarItems(activeVersion);
@@ -1,6 +1,6 @@
1
- import type { I18nConfig } from '../../core/types';
1
+ import type { L10nConfig } from '../../core/types';
2
2
  export declare function useLanguagePicker(): {
3
- currentLocale: I18nConfig['locales'][number] | undefined;
4
- locales: I18nConfig['locales'];
3
+ currentLocale: L10nConfig['locales'][number] | undefined;
4
+ locales: L10nConfig['locales'];
5
5
  setLocale: (value: string) => void;
6
6
  };
@@ -4,9 +4,9 @@ exports.useLanguagePicker = void 0;
4
4
  const hooks_1 = require("../../core/hooks");
5
5
  const utils_1 = require("../../core/utils");
6
6
  function useLanguagePicker() {
7
- const { useI18nConfig, usePreloadHistory } = (0, hooks_1.useThemeHooks)();
7
+ const { useL10nConfig, usePreloadHistory } = (0, hooks_1.useThemeHooks)();
8
8
  const history = usePreloadHistory();
9
- const { currentLocale, locales, defaultLocale } = useI18nConfig();
9
+ const { currentLocale, locales, defaultLocale } = useL10nConfig();
10
10
  const locale = locales.find((l) => l.code === currentLocale);
11
11
  function setLocale(value) {
12
12
  const newLangPathname = (0, utils_1.withPathPrefix)((0, utils_1.getPathnameForLocale)(location.pathname, defaultLocale, value, locales));
@@ -7,10 +7,20 @@ export type ThemeHooks = {
7
7
  useTranslate: () => {
8
8
  translate: TFunction;
9
9
  };
10
+ /**
11
+ * @deprecated use `useL10n` instead
12
+ * */
10
13
  useI18n: () => {
11
14
  changeLanguage: (lng?: string | undefined, callback?: Callback | undefined) => Promise<TFunc>;
12
15
  };
13
- useI18nConfig: () => I18nConfig;
16
+ /**
17
+ * @deprecated use `useL10nConfig` instead
18
+ * */
19
+ useI18nConfig: () => L10nConfig;
20
+ useL10n: () => {
21
+ changeLanguage: (lng?: string | undefined, callback?: Callback | undefined) => Promise<TFunc>;
22
+ };
23
+ useL10nConfig: () => L10nConfig;
14
24
  useCurrentProduct: () => ProductUiConfig | undefined;
15
25
  useProducts: () => ProductUiConfig[];
16
26
  usePageVersions: () => {
@@ -62,7 +72,7 @@ export type ThemeHooks = {
62
72
  useUserTeams: () => string[];
63
73
  usePageProps: <T extends Record<string, unknown>>() => PageProps & T;
64
74
  };
65
- export type I18nConfig = {
75
+ export type L10nConfig = {
66
76
  currentLocale: string;
67
77
  defaultLocale: string;
68
78
  locales: {
@@ -1,6 +1,6 @@
1
1
  export * from '../../core/types/breadcrumb';
2
2
  export * from '../../core/types/catalog';
3
- export * from '../../core/types/i18n';
3
+ export * from '../../core/types/l10n';
4
4
  export * from '../../core/types/feedback';
5
5
  export * from '../../core/types/hooks';
6
6
  export * from '../../core/types/markdown';
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("../../core/types/breadcrumb"), exports);
18
18
  __exportStar(require("../../core/types/catalog"), exports);
19
- __exportStar(require("../../core/types/i18n"), exports);
19
+ __exportStar(require("../../core/types/l10n"), exports);
20
20
  __exportStar(require("../../core/types/feedback"), exports);
21
21
  __exportStar(require("../../core/types/hooks"), exports);
22
22
  __exportStar(require("../../core/types/markdown"), exports);
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=i18n.js.map
3
+ //# sourceMappingURL=l10n.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.39.1",
3
+ "version": "0.40.0",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -98,7 +98,7 @@
98
98
  "timeago.js": "^4.0.2",
99
99
  "i18next": "^22.4.12",
100
100
  "nprogress": "^0.2.0",
101
- "@redocly/config": "0.8.2"
101
+ "@redocly/config": "0.9.0"
102
102
  },
103
103
  "scripts": {
104
104
  "start": "npm-run-all --parallel storybook storybook:tokens:watch",
@@ -13,9 +13,9 @@ export function FooterCopyright({
13
13
  copyrightText = '',
14
14
  className,
15
15
  }: FooterCopyrightProps): JSX.Element | null {
16
- const { useTranslate, useI18n } = useThemeHooks();
16
+ const { useTranslate, useL10n } = useThemeHooks();
17
17
  const { translate } = useTranslate();
18
- const { changeLanguage } = useI18n();
18
+ const { changeLanguage } = useL10n();
19
19
 
20
20
  return copyrightText ? (
21
21
  <FooterCopyrightWrapper
@@ -23,9 +23,9 @@ export type LastUpdatedProps = {
23
23
 
24
24
  export function LastUpdated(props: LastUpdatedProps): JSX.Element | null {
25
25
  const { markdown: { lastUpdatedBlock = {} } = {} } = useThemeConfig();
26
- const { useTranslate, useI18nConfig } = useThemeHooks();
26
+ const { useTranslate, useL10nConfig } = useThemeHooks();
27
27
  const { translate } = useTranslate();
28
- const { currentLocale } = useI18nConfig();
28
+ const { currentLocale } = useL10nConfig();
29
29
 
30
30
  if (lastUpdatedBlock?.hide) {
31
31
  return null;
@@ -24,8 +24,8 @@ export type NavbarProps = {
24
24
  export function Navbar({ className }: NavbarProps): JSX.Element | null {
25
25
  const { isOpen, openMobileMenu, closeMobileMenu } = useMobileMenu(false);
26
26
  const themeConfig = useThemeConfig();
27
- const { useI18n, useTelemetry } = useThemeHooks();
28
- const { changeLanguage } = useI18n();
27
+ const { useL10n, useTelemetry } = useThemeHooks();
28
+ const { changeLanguage } = useL10n();
29
29
  const telemetry = useTelemetry();
30
30
 
31
31
  const menu = themeConfig.navbar?.items;
@@ -20,9 +20,9 @@ export type NavbarItemProps = {
20
20
 
21
21
  export function NavbarItem({ navItem, className }: NavbarItemProps): JSX.Element | null {
22
22
  const { pathname } = useLocation();
23
- const { useTranslate, useI18nConfig, useTelemetry } = useThemeHooks();
23
+ const { useTranslate, useL10nConfig, useTelemetry } = useThemeHooks();
24
24
  const { translate } = useTranslate();
25
- const { defaultLocale, currentLocale, locales } = useI18nConfig();
25
+ const { defaultLocale, currentLocale, locales } = useL10nConfig();
26
26
  const telemetry = useTelemetry();
27
27
 
28
28
  if (navItem.type !== 'link' && !navItem.items) return null;
@@ -19,10 +19,10 @@ export const useThemeHooks = jest.fn(() => ({
19
19
  filterTerm: '',
20
20
  setFilterTerm: jest.fn(),
21
21
  })),
22
- useI18n: jest.fn(() => ({
22
+ useL10n: jest.fn(() => ({
23
23
  changeLanguage: jest.fn(),
24
24
  })),
25
- useI18nConfig: jest.fn(() => ({
25
+ useL10nConfig: jest.fn(() => ({
26
26
  currentLocale: 'en',
27
27
  defaultLocale: 'en',
28
28
  locales: [
@@ -16,10 +16,10 @@ const MENU_SEPARATOR: ResolvedNavItem = {
16
16
  };
17
17
 
18
18
  export const useMobileMenuItems = (menuType: MobileMenuType) => {
19
- const { useTranslate, useI18nConfig, useCurrentProduct, usePageVersions, useSidebarItems } =
19
+ const { useTranslate, useL10nConfig, useCurrentProduct, usePageVersions, useSidebarItems } =
20
20
  useThemeHooks();
21
21
  const { versions = [] } = usePageVersions() || {};
22
- const { defaultLocale, currentLocale, locales } = useI18nConfig();
22
+ const { defaultLocale, currentLocale, locales } = useL10nConfig();
23
23
  const { translate } = useTranslate();
24
24
  const activeVersion = versions.find((version) => version.active);
25
25
  const {
@@ -1,16 +1,16 @@
1
- import type { I18nConfig } from '@redocly/theme/core/types';
1
+ import type { L10nConfig } from '@redocly/theme/core/types';
2
2
 
3
3
  import { useThemeHooks } from '@redocly/theme/core/hooks';
4
4
  import { getPathnameForLocale, withPathPrefix } from '@redocly/theme/core/utils';
5
5
 
6
6
  export function useLanguagePicker(): {
7
- currentLocale: I18nConfig['locales'][number] | undefined;
8
- locales: I18nConfig['locales'];
7
+ currentLocale: L10nConfig['locales'][number] | undefined;
8
+ locales: L10nConfig['locales'];
9
9
  setLocale: (value: string) => void;
10
10
  } {
11
- const { useI18nConfig, usePreloadHistory } = useThemeHooks();
11
+ const { useL10nConfig, usePreloadHistory } = useThemeHooks();
12
12
  const history = usePreloadHistory();
13
- const { currentLocale, locales, defaultLocale } = useI18nConfig();
13
+ const { currentLocale, locales, defaultLocale } = useL10nConfig();
14
14
 
15
15
  const locale = locales.find((l) => l.code === currentLocale);
16
16
 
@@ -15,10 +15,20 @@ import type {
15
15
 
16
16
  export type ThemeHooks = {
17
17
  useTranslate: () => { translate: TFunction };
18
+ /**
19
+ * @deprecated use `useL10n` instead
20
+ * */
18
21
  useI18n: () => {
19
22
  changeLanguage: (lng?: string | undefined, callback?: Callback | undefined) => Promise<TFunc>;
20
23
  };
21
- useI18nConfig: () => I18nConfig;
24
+ /**
25
+ * @deprecated use `useL10nConfig` instead
26
+ * */
27
+ useI18nConfig: () => L10nConfig;
28
+ useL10n: () => {
29
+ changeLanguage: (lng?: string | undefined, callback?: Callback | undefined) => Promise<TFunc>;
30
+ };
31
+ useL10nConfig: () => L10nConfig;
22
32
  useCurrentProduct: () => ProductUiConfig | undefined;
23
33
  useProducts: () => ProductUiConfig[];
24
34
  usePageVersions: () => {
@@ -66,7 +76,7 @@ export type ThemeHooks = {
66
76
  usePageProps: <T extends Record<string, unknown>>() => PageProps & T;
67
77
  };
68
78
 
69
- export type I18nConfig = {
79
+ export type L10nConfig = {
70
80
  currentLocale: string;
71
81
  defaultLocale: string;
72
82
  locales: { code: string; name: string }[];
@@ -1,6 +1,6 @@
1
1
  export * from '@redocly/theme/core/types/breadcrumb';
2
2
  export * from '@redocly/theme/core/types/catalog';
3
- export * from '@redocly/theme/core/types/i18n';
3
+ export * from '@redocly/theme/core/types/l10n';
4
4
  export * from '@redocly/theme/core/types/feedback';
5
5
  export * from '@redocly/theme/core/types/hooks';
6
6
  export * from '@redocly/theme/core/types/markdown';
File without changes
File without changes