@diplodoc/client 3.12.0 → 4.0.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.
@@ -1,14 +1,8 @@
1
- import type { PropsWithChildren } from 'react';
2
- import type { AppProps, PageData, WithNavigation } from './index';
1
+ import type { AppProps, PageData } from './index';
3
2
  import type { Settings } from '../../utils';
4
3
  import type { DocBasePageData } from '@diplodoc/components';
5
4
  import type { Props as HeaderControlsProps } from '../HeaderControls';
6
5
  import React from 'react';
7
- type Props = PropsWithChildren<Partial<AppProps> & {
8
- data: PageData;
9
- headerHeight: number;
10
- }>;
11
- export declare function Page({ data, ...pageProps }: Props): React.JSX.Element;
12
6
  type PageProps<T extends {} = {}> = {
13
7
  data: DocBasePageData<T> & PageData;
14
8
  props: {
@@ -16,6 +10,5 @@ type PageProps<T extends {} = {}> = {
16
10
  } & Settings;
17
11
  controls: HeaderControlsProps;
18
12
  };
19
- export declare function LegacyNavPage({ data, props, controls }: PageProps): React.JSX.Element;
20
- export declare function RichNavPage({ data, props, controls }: PageProps<WithNavigation>): React.JSX.Element;
13
+ export declare function Page({ data, props, controls }: PageProps): React.JSX.Element;
21
14
  export {};
@@ -22,7 +22,7 @@ export interface AppProps {
22
22
  viewerInterface?: Record<string, boolean>;
23
23
  }
24
24
  export type WithNavigation = {
25
- navigation: NavigationData;
25
+ navigation?: NavigationData;
26
26
  };
27
27
  export type DocContentPageData = DocContentPageDataBase<PageContent>;
28
28
  export type PageData = DocPageData | DocLeadingPageData | DocContentPageData;
@@ -16,6 +16,8 @@ export declare const useNavigation: (data: DocBasePageData<WithNavigation>, cont
16
16
  renderNavigation: () => React.JSX.Element;
17
17
  logo: {
18
18
  icon: import("@gravity-ui/page-constructor").ImageProps;
19
+ } | {
20
+ icon: import("@gravity-ui/page-constructor").ImageProps;
19
21
  text?: string;
20
22
  url?: string;
21
23
  urlTitle?: string;
@@ -28,6 +30,6 @@ export declare const useNavigation: (data: DocBasePageData<WithNavigation>, cont
28
30
  alt?: string;
29
31
  light: import("@gravity-ui/page-constructor").NavigationLogoData;
30
32
  };
31
- };
33
+ } | undefined;
32
34
  withControls: boolean;
33
35
  };
@@ -787,8 +787,6 @@ function useSearch() {
787
787
 
788
788
  // EXTERNAL MODULE: ./src/interceptors/leading-page-links.js
789
789
  var leading_page_links = __webpack_require__(90101);
790
- // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_object_without_properties.js + 1 modules
791
- var _object_without_properties = __webpack_require__(98848);
792
790
  // EXTERNAL MODULE: ./node_modules/@gravity-ui/page-constructor/build/esm/containers/PageConstructor/Provider.js
793
791
  var Provider = __webpack_require__(77725);
794
792
  // EXTERNAL MODULE: ./node_modules/@gravity-ui/page-constructor/build/esm/containers/PageConstructor/PageConstructor.js + 18 modules
@@ -1067,11 +1065,15 @@ function findItem(right, left, type) {
1067
1065
  return item.type === type;
1068
1066
  });
1069
1067
  }
1068
+ var EmptyNavigation = {};
1069
+ var EmptyHeader = {};
1070
+ var EmptyLeftItems = [];
1071
+ var EmptyRightItems = [];
1070
1072
  var useNavigation = function(data, controls, CustomControls, CustomSuggest, viewerInterface) {
1071
1073
  var toc = data.toc;
1072
- var navigation = toc.navigation;
1073
- var _navigation_header = navigation.header, header = _navigation_header === void 0 ? {} : _navigation_header, logo = navigation.logo;
1074
- var _header_leftItems = header.leftItems, leftItems = _header_leftItems === void 0 ? [] : _header_leftItems, _header_rightItems = header.rightItems, rightItems = _header_rightItems === void 0 ? [] : _header_rightItems;
1074
+ var navigation = toc.navigation || EmptyNavigation;
1075
+ var _navigation_header = navigation.header, header = _navigation_header === void 0 ? EmptyHeader : _navigation_header, logo = navigation.logo;
1076
+ var _header_leftItems = header.leftItems, leftItems = _header_leftItems === void 0 ? EmptyLeftItems : _header_leftItems, _header_rightItems = header.rightItems, rightItems = _header_rightItems === void 0 ? EmptyRightItems : _header_rightItems;
1075
1077
  var withControls = findItem(rightItems, leftItems, 'controls');
1076
1078
  var withSearch = findItem(rightItems, leftItems, 'search');
1077
1079
  var search = useSearch();
@@ -1118,7 +1120,7 @@ var useNavigation = function(data, controls, CustomControls, CustomSuggest, view
1118
1120
  ]);
1119
1121
  var layout = (0,react.useMemo)(function() {
1120
1122
  var _logo_icon;
1121
- return {
1123
+ return EmptyNavigation === navigation ? undefined : {
1122
1124
  header: {
1123
1125
  leftItems: []
1124
1126
  },
@@ -1141,7 +1143,8 @@ var useNavigation = function(data, controls, CustomControls, CustomSuggest, view
1141
1143
  navigationData,
1142
1144
  navigationTocData,
1143
1145
  mobileControlsData,
1144
- logo
1146
+ logo,
1147
+ navigation
1145
1148
  ]);
1146
1149
  var config = (0,react.useMemo)(function() {
1147
1150
  return {
@@ -1175,58 +1178,11 @@ var useNavigation = function(data, controls, CustomControls, CustomSuggest, view
1175
1178
 
1176
1179
 
1177
1180
 
1178
-
1179
- function App_Page_Page(_param) {
1180
- var data = _param.data, pageProps = (0,_object_without_properties._)(_param, [
1181
- "data"
1182
- ]);
1183
- var type = (0,utils/* .getPageType */.C2)(data);
1184
- var Page = (0,utils/* .getPageByType */.N7)(type);
1185
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout, {
1186
- headerHeight: pageProps.headerHeight,
1187
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout.Content, {
1188
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Page, (0,_object_spread._)({}, data, pageProps))
1189
- })
1190
- });
1191
- }
1192
- function LegacyNavPage(param) {
1193
- var data = param.data, props = param.props, controls = param.controls;
1194
- var theme = props.theme;
1195
- var CustomPage = (0,react.useCallback)(function() {
1196
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorPage, (0,_object_spread._)({}, data.data));
1197
- }, [
1198
- data
1199
- ]);
1200
- var content = useContent(data, CustomPage);
1201
- var custom = (0,react.useMemo)(function() {
1202
- return {
1203
- blocks: content.custom
1204
- };
1205
- }, [
1206
- content
1207
- ]);
1208
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(App_Page_Page, (0,_object_spread_props._)((0,_object_spread._)({
1209
- data: data,
1210
- headerHeight: 0
1211
- }, props, controls), {
1212
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Provider/* .PageConstructorProvider */.W, {
1213
- theme: theme,
1214
- projectSettings: {
1215
- disableCompress: true
1216
- },
1217
- ssrConfig: {
1218
- isServer: Boolean(false)
1219
- },
1220
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(PageConstructor/* .PageConstructor */.C, {
1221
- custom: custom,
1222
- content: content.layout
1223
- })
1224
- })
1225
- }));
1226
- }
1227
- function RichNavPage(param) {
1181
+ function App_Page_Page(param) {
1228
1182
  var data = param.data, props = param.props, controls = param.controls;
1229
1183
  var theme = props.theme, fullScreen = props.fullScreen;
1184
+ var type = (0,utils/* .getPageType */.C2)(data);
1185
+ var Page = (0,utils/* .getPageByType */.N7)(type);
1230
1186
  var CustomSuggest = (0,react.useCallback)(function() {
1231
1187
  return /*#__PURE__*/ (0,jsx_runtime.jsx)(Suggest, {});
1232
1188
  }, []);
@@ -1237,29 +1193,32 @@ function RichNavPage(param) {
1237
1193
  ]);
1238
1194
  var navigation = useNavigation(data, controls, CustomControls, CustomSuggest);
1239
1195
  var CustomPage = (0,react.useCallback)(function() {
1240
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(App_Page_Page, (0,_object_spread_props._)((0,_object_spread._)({
1241
- data: data,
1242
- headerHeight: fullScreen ? 0 : 64
1243
- }, props, navigation.withControls ? filterControls(controls, [
1244
- 'theme',
1245
- 'onChangeTheme',
1246
- 'textSize',
1247
- 'onChangeTextSize',
1248
- 'wideFormat',
1249
- 'onChangeWideFormat',
1250
- 'showMiniToc',
1251
- 'onChangeShowMiniToc',
1252
- 'langs',
1253
- 'onChangeLang'
1254
- ]) : controls), {
1255
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorPage, (0,_object_spread._)({}, data.data))
1256
- }));
1196
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout, {
1197
+ headerHeight: fullScreen || !navigation.layout ? 0 : 64,
1198
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout.Content, {
1199
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Page, (0,_object_spread_props._)((0,_object_spread._)({}, data, props, navigation.withControls ? filterControls(controls, [
1200
+ 'theme',
1201
+ 'onChangeTheme',
1202
+ 'textSize',
1203
+ 'onChangeTextSize',
1204
+ 'wideFormat',
1205
+ 'onChangeWideFormat',
1206
+ 'showMiniToc',
1207
+ 'onChangeShowMiniToc',
1208
+ 'langs',
1209
+ 'onChangeLang'
1210
+ ]) : controls), {
1211
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorPage, (0,_object_spread._)({}, data.data))
1212
+ }))
1213
+ })
1214
+ });
1257
1215
  }, [
1258
1216
  data,
1259
1217
  navigation,
1260
1218
  props,
1261
1219
  controls,
1262
- fullScreen
1220
+ fullScreen,
1221
+ Page
1263
1222
  ]);
1264
1223
  var content = useContent(data, CustomPage);
1265
1224
  var custom = (0,react.useMemo)(function() {
@@ -1470,9 +1429,6 @@ var withMdxInit = function(param) {
1470
1429
 
1471
1430
 
1472
1431
 
1473
- function hasNavigation(data) {
1474
- return Boolean(data.toc.navigation);
1475
- }
1476
1432
  function App(props) {
1477
1433
  var _analytics_gtm, _analytics_gtm1;
1478
1434
  var data = props.data, router = props.router, lang = props.lang, langs = props.langs, search = props.search, analytics = props.analytics, viewerInterface = props.viewerInterface;
@@ -1564,11 +1520,7 @@ function App(props) {
1564
1520
  children: [
1565
1521
  /*#__PURE__*/ (0,jsx_runtime.jsx)(RenderBodyHooksContext/* .RenderBodyHooksContext.Provider */.Y.Provider, {
1566
1522
  value: renderHooks,
1567
- children: hasNavigation(data) ? /*#__PURE__*/ (0,jsx_runtime.jsx)(RichNavPage, {
1568
- data: data,
1569
- props: page,
1570
- controls: controls
1571
- }) : /*#__PURE__*/ (0,jsx_runtime.jsx)(LegacyNavPage, {
1523
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(App_Page_Page, {
1572
1524
  data: data,
1573
1525
  props: page,
1574
1526
  controls: controls