@diplodoc/client 5.2.6 → 5.2.7

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.
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CustomPage: () => React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { DocBasePageData } from '@diplodoc/components';
2
+ import type { PageData } from './index';
3
+ import type { Props as HeaderControlsProps } from '../HeaderControls';
4
+ import type { Settings } from '../../utils';
5
+ export type CustomPageProps = Settings & Partial<HeaderControlsProps>;
6
+ export interface PageContextProps {
7
+ data: DocBasePageData & PageData;
8
+ props: CustomPageProps;
9
+ hasLayout: boolean;
10
+ }
11
+ export declare const PageProvider: import("react").Provider<PageContextProps | null>;
12
+ export declare function usePageContext(): PageContextProps;
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = ({
3
- 1485(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
+ 11701(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
4
  "use strict";
5
5
  // ESM COMPAT FLAG
6
6
  __webpack_require__.r(__webpack_exports__);
@@ -852,117 +852,6 @@ function useFeedback(param) {
852
852
  var leading_page_links = __webpack_require__(66008);
853
853
  // EXTERNAL MODULE: ./node_modules/@gravity-ui/page-constructor/build/esm/index.js + 1311 modules
854
854
  var esm = __webpack_require__(47576);
855
- ;// CONCATENATED MODULE: ./src/components/Layout/Layout.scss
856
-
857
- ;// CONCATENATED MODULE: ./src/components/Layout/index.tsx
858
-
859
-
860
-
861
-
862
-
863
- var Layout_b = (0,lib["default"])('Layout');
864
- function Header() {
865
- return null;
866
- }
867
- function Content() {
868
- return null;
869
- }
870
- function Footer() {
871
- return null;
872
- }
873
- var defaults = {
874
- doc: false
875
- };
876
- var Layout = function(props) {
877
- var _$_object_spread = (0,_object_spread._)({}, defaults, props), children = _$_object_spread.children, doc = _$_object_spread.doc, _object_spread_headerHeight = _$_object_spread.headerHeight, headerHeight = _object_spread_headerHeight === void 0 ? 0 : _object_spread_headerHeight;
878
- var header, content, footer;
879
- react.Children.forEach(children, function(child) {
880
- switch(child.type){
881
- case Header:
882
- header = child.props.children;
883
- break;
884
- case Content:
885
- content = child.props.children;
886
- break;
887
- case Footer:
888
- footer = child.props.children;
889
- break;
890
- }
891
- });
892
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
893
- className: Layout_b({
894
- 'full-header': headerHeight > 0
895
- }),
896
- children: [
897
- header && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
898
- className: Layout_b('header'),
899
- children: header
900
- }),
901
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
902
- className: Layout_b('body'),
903
- children: [
904
- content && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
905
- className: Layout_b('content'),
906
- children: content
907
- }),
908
- footer && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
909
- className: Layout_b('footer', {
910
- doc: doc
911
- }),
912
- children: footer
913
- })
914
- ]
915
- })
916
- ]
917
- });
918
- };
919
- Layout.displayName = 'Layout';
920
- Layout.Header = Header;
921
- Layout.Content = Content;
922
- Layout.Footer = Footer;
923
-
924
- ;// CONCATENATED MODULE: ./src/components/ConstructorPage/index.tsx
925
-
926
-
927
-
928
-
929
-
930
-
931
- var bPC = (0,lib["default"])('pc-page-constructor');
932
- var bPCRow = (0,lib["default"])('pc-constructor-row');
933
- var ConstructorRow = function(param) {
934
- var children = param.children;
935
- return children ? /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .Row */.fI1, {
936
- className: bPCRow(),
937
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .Col */.fvL, {
938
- children: children
939
- })
940
- }) : null;
941
- };
942
- function ConstructorPage(param) {
943
- var background = param.background, blocks = param.blocks;
944
- var theme = (0,esm/* .useTheme */.DPo)();
945
- var themedBackground = (0,esm/* .getThemedValue */.dgY)(background, theme);
946
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
947
- className: bPC('docs'),
948
- children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
949
- className: bPC('wrapper'),
950
- children: [
951
- blocks && themedBackground && /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .BackgroundMedia */.bGR, (0,_object_spread_props._)((0,_object_spread._)({}, themedBackground), {
952
- className: bPC('background')
953
- })),
954
- /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .Grid */.xA9, {
955
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorRow, {
956
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .ConstructorBlocks */.FA7, {
957
- items: blocks
958
- })
959
- })
960
- })
961
- ]
962
- })
963
- });
964
- }
965
-
966
855
  ;// CONCATENATED MODULE: ./src/components/ConstructorPage/useContent.tsx
967
856
 
968
857
 
@@ -1212,14 +1101,160 @@ var useNavigation = function(data, controls, CustomControls, CustomSuggest, view
1212
1101
  return config;
1213
1102
  };
1214
1103
 
1215
- ;// CONCATENATED MODULE: ./src/components/App/Page.tsx
1104
+ ;// CONCATENATED MODULE: ./src/components/App/PageContext.tsx
1105
+
1106
+ var PageContext = /*#__PURE__*/ (0,react.createContext)(null);
1107
+ var PageProvider = PageContext.Provider;
1108
+ function usePageContext() {
1109
+ var context = (0,react.useContext)(PageContext);
1110
+ if (!context) {
1111
+ throw new Error('usePageContext must be used within PageProvider');
1112
+ }
1113
+ return context;
1114
+ }
1115
+
1116
+ ;// CONCATENATED MODULE: ./src/components/Layout/Layout.scss
1117
+
1118
+ ;// CONCATENATED MODULE: ./src/components/Layout/index.tsx
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+ var Layout_b = (0,lib["default"])('Layout');
1125
+ function Header() {
1126
+ return null;
1127
+ }
1128
+ function Content() {
1129
+ return null;
1130
+ }
1131
+ function Footer() {
1132
+ return null;
1133
+ }
1134
+ var defaults = {
1135
+ doc: false
1136
+ };
1137
+ var Layout = function(props) {
1138
+ var _$_object_spread = (0,_object_spread._)({}, defaults, props), children = _$_object_spread.children, doc = _$_object_spread.doc, _object_spread_headerHeight = _$_object_spread.headerHeight, headerHeight = _object_spread_headerHeight === void 0 ? 0 : _object_spread_headerHeight;
1139
+ var header, content, footer;
1140
+ react.Children.forEach(children, function(child) {
1141
+ switch(child.type){
1142
+ case Header:
1143
+ header = child.props.children;
1144
+ break;
1145
+ case Content:
1146
+ content = child.props.children;
1147
+ break;
1148
+ case Footer:
1149
+ footer = child.props.children;
1150
+ break;
1151
+ }
1152
+ });
1153
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
1154
+ className: Layout_b({
1155
+ 'full-header': headerHeight > 0
1156
+ }),
1157
+ children: [
1158
+ header && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
1159
+ className: Layout_b('header'),
1160
+ children: header
1161
+ }),
1162
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
1163
+ className: Layout_b('body'),
1164
+ children: [
1165
+ content && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
1166
+ className: Layout_b('content'),
1167
+ children: content
1168
+ }),
1169
+ footer && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
1170
+ className: Layout_b('footer', {
1171
+ doc: doc
1172
+ }),
1173
+ children: footer
1174
+ })
1175
+ ]
1176
+ })
1177
+ ]
1178
+ });
1179
+ };
1180
+ Layout.displayName = 'Layout';
1181
+ Layout.Header = Header;
1182
+ Layout.Content = Content;
1183
+ Layout.Footer = Footer;
1216
1184
 
1185
+ ;// CONCATENATED MODULE: ./src/components/ConstructorPage/index.tsx
1217
1186
 
1218
1187
 
1219
1188
 
1220
1189
 
1221
1190
 
1222
1191
 
1192
+ var bPC = (0,lib["default"])('pc-page-constructor');
1193
+ var bPCRow = (0,lib["default"])('pc-constructor-row');
1194
+ var ConstructorRow = function(param) {
1195
+ var children = param.children;
1196
+ return children ? /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .Row */.fI1, {
1197
+ className: bPCRow(),
1198
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .Col */.fvL, {
1199
+ children: children
1200
+ })
1201
+ }) : null;
1202
+ };
1203
+ function ConstructorPage(param) {
1204
+ var background = param.background, blocks = param.blocks;
1205
+ var theme = (0,esm/* .useTheme */.DPo)();
1206
+ var themedBackground = (0,esm/* .getThemedValue */.dgY)(background, theme);
1207
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
1208
+ className: bPC('docs'),
1209
+ children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
1210
+ className: bPC('wrapper'),
1211
+ children: [
1212
+ blocks && themedBackground && /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .BackgroundMedia */.bGR, (0,_object_spread_props._)((0,_object_spread._)({}, themedBackground), {
1213
+ className: bPC('background')
1214
+ })),
1215
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .Grid */.xA9, {
1216
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorRow, {
1217
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .ConstructorBlocks */.FA7, {
1218
+ items: blocks
1219
+ })
1220
+ })
1221
+ })
1222
+ ]
1223
+ })
1224
+ });
1225
+ }
1226
+
1227
+ ;// CONCATENATED MODULE: ./src/components/App/CustomPage.tsx
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+ var CustomPage_CustomPage = function() {
1237
+ var _usePageContext = usePageContext(), data = _usePageContext.data, props = _usePageContext.props, hasLayout = _usePageContext.hasLayout;
1238
+ var type = (0,utils/* .getPageType */.M5)(data);
1239
+ var PageComponent = (0,utils/* .getPageByType */.$T)(type);
1240
+ var headerHeight = props.fullScreen || !hasLayout ? 0 : 64;
1241
+ var pageProps = (0,_object_spread._)({}, data, props);
1242
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout, {
1243
+ headerHeight: headerHeight,
1244
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout.Content, {
1245
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(PageComponent, (0,_object_spread_props._)((0,_object_spread._)({}, pageProps), {
1246
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorPage, (0,_object_spread._)({}, data.data))
1247
+ }))
1248
+ })
1249
+ }, "layout");
1250
+ };
1251
+
1252
+ ;// CONCATENATED MODULE: ./src/components/App/Page.tsx
1253
+
1254
+
1255
+
1256
+
1257
+
1223
1258
 
1224
1259
 
1225
1260
 
@@ -1228,46 +1263,33 @@ var useNavigation = function(data, controls, CustomControls, CustomSuggest, view
1228
1263
  function App_Page_Page(param) {
1229
1264
  var data = param.data, props = param.props, controls = param.controls;
1230
1265
  var theme = props.theme, fullScreen = props.fullScreen;
1231
- var type = (0,utils/* .getPageType */.M5)(data);
1232
- var Page = (0,utils/* .getPageByType */.$T)(type);
1233
- var CustomSuggest = (0,react.useCallback)(function() {
1234
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(Suggest, {});
1235
- }, []);
1236
1266
  var CustomControls = (0,react.useCallback)(function() {
1237
1267
  return /*#__PURE__*/ (0,jsx_runtime.jsx)(HeaderControls, (0,_object_spread._)({}, controls));
1238
1268
  }, [
1239
1269
  controls
1240
1270
  ]);
1241
- var navigation = useNavigation(data, controls, CustomControls, CustomSuggest);
1242
- var CustomPage = (0,react.useCallback)(function() {
1243
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout, {
1244
- headerHeight: fullScreen || !navigation.layout ? 0 : 64,
1245
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Layout.Content, {
1246
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Page, (0,_object_spread_props._)((0,_object_spread._)({}, data, props, navigation.withControls ? filterControls(controls, [
1247
- 'theme',
1248
- 'onChangeTheme',
1249
- 'textSize',
1250
- 'onChangeTextSize',
1251
- 'wideFormat',
1252
- 'onChangeWideFormat',
1253
- 'showMiniToc',
1254
- 'onChangeShowMiniToc',
1255
- 'langs',
1256
- 'onChangeLang'
1257
- ]) : controls), {
1258
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ConstructorPage, (0,_object_spread._)({}, data.data))
1259
- }))
1260
- })
1261
- });
1271
+ var navigation = useNavigation(data, controls, CustomControls, Suggest);
1272
+ var content = useContent(data, CustomPage_CustomPage);
1273
+ var headerControls = (0,react.useMemo)(function() {
1274
+ if (navigation.withControls) {
1275
+ return filterControls(controls, [
1276
+ 'theme',
1277
+ 'onChangeTheme',
1278
+ 'textSize',
1279
+ 'onChangeTextSize',
1280
+ 'wideFormat',
1281
+ 'onChangeWideFormat',
1282
+ 'showMiniToc',
1283
+ 'onChangeShowMiniToc',
1284
+ 'langs',
1285
+ 'onChangeLang'
1286
+ ]);
1287
+ }
1288
+ return controls;
1262
1289
  }, [
1263
- data,
1264
- navigation,
1265
- props,
1266
- controls,
1267
- fullScreen,
1268
- Page
1290
+ navigation.withControls,
1291
+ controls
1269
1292
  ]);
1270
- var content = useContent(data, CustomPage);
1271
1293
  var custom = (0,react.useMemo)(function() {
1272
1294
  return {
1273
1295
  navigation: navigation.custom,
@@ -1277,18 +1299,35 @@ function App_Page_Page(param) {
1277
1299
  navigation,
1278
1300
  content
1279
1301
  ]);
1280
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .PageConstructorProvider */.ZzZ, {
1281
- theme: theme,
1282
- projectSettings: {
1283
- disableCompress: true
1284
- },
1285
- ssrConfig: {
1286
- isServer: Boolean(false)
1287
- },
1288
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .PageConstructor */.i$, {
1289
- custom: custom,
1290
- content: content.layout,
1291
- navigation: fullScreen ? undefined : navigation.layout
1302
+ var hasLayout = Boolean(navigation.layout);
1303
+ var pageContext = (0,react.useMemo)(function() {
1304
+ var pageProps = (0,_object_spread._)({}, props, headerControls);
1305
+ return {
1306
+ data: data,
1307
+ props: pageProps,
1308
+ hasLayout: hasLayout
1309
+ };
1310
+ }, [
1311
+ data,
1312
+ hasLayout,
1313
+ headerControls,
1314
+ props
1315
+ ]);
1316
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(PageProvider, {
1317
+ value: pageContext,
1318
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .PageConstructorProvider */.ZzZ, {
1319
+ theme: theme,
1320
+ projectSettings: {
1321
+ disableCompress: true
1322
+ },
1323
+ ssrConfig: {
1324
+ isServer: Boolean(false)
1325
+ },
1326
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm/* .PageConstructor */.i$, {
1327
+ custom: custom,
1328
+ content: content.layout,
1329
+ navigation: fullScreen ? undefined : navigation.layout
1330
+ })
1292
1331
  })
1293
1332
  });
1294
1333
  }
@@ -1931,7 +1970,7 @@ __webpack_require__.m = __webpack_modules__;
1931
1970
  __webpack_require__.x = () => {
1932
1971
  // Load entry module and return exports
1933
1972
  // This entry module depends on other loaded chunks and execution need to be delayed
1934
- var __webpack_exports__ = __webpack_require__.O(undefined, ["85", "474"], () => __webpack_require__(1485));
1973
+ var __webpack_exports__ = __webpack_require__.O(undefined, ["85", "474"], () => __webpack_require__(11701));
1935
1974
  __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
1936
1975
  return __webpack_exports__
1937
1976
  };