@diplodoc/client 3.10.3 → 3.11.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,6 +1,6 @@
1
1
  (() => { // webpackBootstrap
2
2
  var __webpack_modules__ = ({
3
- 11301: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3
+ 13543: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4
4
  "use strict";
5
5
  // ESM COMPAT FLAG
6
6
  __webpack_require__.r(__webpack_exports__);
@@ -25,7 +25,7 @@ var server_node = __webpack_require__(9680);
25
25
  // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_object_spread_props.js
26
26
  var _object_spread_props = __webpack_require__(99282);
27
27
  // EXTERNAL MODULE: ./node_modules/@gravity-ui/uikit/build/esm/components/theme/ThemeProvider.js + 7 modules
28
- var ThemeProvider = __webpack_require__(12956);
28
+ var theme_ThemeProvider = __webpack_require__(12956);
29
29
  // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/constants.js
30
30
  var constants = __webpack_require__(53816);
31
31
  // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/models/index.js
@@ -40,8 +40,6 @@ var RenderBodyHooksContext = __webpack_require__(65848);
40
40
  var ConsentPopup = __webpack_require__(74311);
41
41
  // EXTERNAL MODULE: ./node_modules/@diplodoc/transform/dist/js/yfm.js
42
42
  var yfm = __webpack_require__(68648);
43
- // EXTERNAL MODULE: ./node_modules/bem-cn-lite/lib/index.js
44
- var lib = __webpack_require__(22853);
45
43
  ;// CONCATENATED MODULE: ./src/components/Router/index.ts
46
44
 
47
45
  var RouterContext = (0,react.createContext)({
@@ -49,36 +47,334 @@ var RouterContext = (0,react.createContext)({
49
47
  depth: 0
50
48
  });
51
49
  RouterContext.displayName = 'RouterContext';
52
- var RouterProvider = RouterContext.Provider;
50
+ var Router_RouterProvider = RouterContext.Provider;
53
51
  function Router_useRouter() {
54
52
  return (0,react.useContext)(RouterContext);
55
53
  }
56
54
 
55
+ ;// CONCATENATED MODULE: ./src/hooks/useLang.ts
56
+
57
+
58
+ var LangContext = (0,react.createContext)(models/* .Lang.En */.Uo.En);
59
+ LangContext.displayName = 'Lang';
60
+ var useLang_LangProvider = LangContext.Provider;
61
+ function useLang() {
62
+ return (0,react.useContext)(LangContext);
63
+ }
64
+
65
+ // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/utils/index.js + 63 modules
66
+ var utils = __webpack_require__(20935);
67
+ // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_to_consumable_array.js + 3 modules
68
+ var _to_consumable_array = __webpack_require__(55210);
69
+ ;// CONCATENATED MODULE: ./src/constants.ts
70
+
71
+
72
+ var HEADER_HEIGHT = 64;
73
+ var MOBILE_VIEW_WIDTH_BREAKPOINT = 769;
74
+ var DEFAULT_USER_SETTINGS = {
75
+ theme: models/* .Theme.Light */.Q2.Light,
76
+ textSize: models/* .TextSizes.M */.tF.M,
77
+ showMiniToc: true,
78
+ wideFormat: true,
79
+ fullScreen: false
80
+ };
81
+ var RTL_LANGS = [
82
+ 'ar',
83
+ 'arc',
84
+ 'ckb',
85
+ 'dv',
86
+ 'fa',
87
+ 'ha',
88
+ 'he',
89
+ 'khw',
90
+ 'ks',
91
+ 'ps',
92
+ 'sd',
93
+ 'ur',
94
+ 'uz_AF',
95
+ 'yi'
96
+ ];
97
+ var constants_TextDirection = /*#__PURE__*/ function(TextDirection) {
98
+ TextDirection["RTL"] = "rtl";
99
+ TextDirection["LTR"] = "ltr";
100
+ return TextDirection;
101
+ }({});
102
+ var LINK_KEYS_LEADING_CONFIG = [
103
+ 'href'
104
+ ];
105
+ var LINK_KEYS_PAGE_CONSTRUCTOR_CONFIG = [
106
+ 'src',
107
+ 'url',
108
+ 'href',
109
+ 'icon',
110
+ 'image',
111
+ 'desktop',
112
+ 'mobile',
113
+ 'tablet',
114
+ 'previewImg',
115
+ 'image',
116
+ 'avatar',
117
+ 'logo',
118
+ 'light',
119
+ 'dark'
120
+ ];
121
+ var LINK_KEYS = (0,_to_consumable_array._)(new Set((0,_to_consumable_array._)(LINK_KEYS_LEADING_CONFIG).concat((0,_to_consumable_array._)(LINK_KEYS_PAGE_CONSTRUCTOR_CONFIG))));
122
+
123
+ ;// CONCATENATED MODULE: ./src/utils.ts
124
+
125
+
126
+ function isBrowser() {
127
+ return typeof document !== 'undefined';
128
+ }
129
+ function utils_updateThemeClassName(param) {
130
+ var theme = param.theme;
131
+ if (typeof document === 'undefined') {
132
+ return;
133
+ }
134
+ document.querySelectorAll('.g-root').forEach(function(el) {
135
+ el.classList.toggle('g-root_theme_light', theme === 'light');
136
+ el.classList.toggle('g-root_theme_dark', theme === 'dark');
137
+ });
138
+ }
139
+ function utils_updateRootClassName(states) {
140
+ if (!isBrowser()) {
141
+ return;
142
+ }
143
+ document.body.classList.add('g-root');
144
+ var toggle = function(name, state) {
145
+ return document.body.classList.toggle(name, Boolean(state));
146
+ };
147
+ Object.keys(states).forEach(function(state) {
148
+ switch(state){
149
+ case 'wideFormat':
150
+ toggle('dc-root_wide-format', states[state]);
151
+ break;
152
+ case 'focusSearch':
153
+ toggle('dc-root_focused-search', states[state]);
154
+ break;
155
+ case 'fullScreen':
156
+ toggle('dc-root_full-screen', states[state]);
157
+ break;
158
+ case 'landingPage':
159
+ toggle('dc-root_document-page', !states[state]);
160
+ toggle('dc-root_landing-page', states[state]);
161
+ break;
162
+ case 'mobileView':
163
+ toggle('mobile', states[state]);
164
+ toggle('desktop', !states[state]);
165
+ break;
166
+ }
167
+ });
168
+ }
169
+ function utils_getDirection(lang) {
170
+ var isRTL = RTL_LANGS.includes(lang);
171
+ return isRTL ? constants_TextDirection.RTL : constants_TextDirection.LTR;
172
+ }
173
+ var toBoolean = function(str) {
174
+ if (typeof str === 'boolean') {
175
+ return str;
176
+ }
177
+ return str ? str === 'true' : false;
178
+ };
179
+ function getSettings() {
180
+ var theme = getSetting('theme');
181
+ var textSize = getSetting('textSize');
182
+ var showMiniToc = getSetting('showMiniToc');
183
+ var wideFormat = getSetting('wideFormat');
184
+ var fullScreen = getSetting('fullScreen');
185
+ return {
186
+ theme: theme,
187
+ textSize: textSize,
188
+ showMiniToc: toBoolean(showMiniToc),
189
+ wideFormat: toBoolean(wideFormat),
190
+ fullScreen: toBoolean(fullScreen)
191
+ };
192
+ }
193
+ function getLandingPage(data) {
194
+ return (0,utils/* .getPageType */.C2)(data) === 'PAGE_CONSTRUCTOR';
195
+ }
196
+ function getMobileView() {
197
+ if (!isBrowser()) {
198
+ return false;
199
+ }
200
+ return document.body.clientWidth < MOBILE_VIEW_WIDTH_BREAKPOINT;
201
+ }
202
+ function getSetting(name) {
203
+ if (!isBrowser()) {
204
+ return DEFAULT_USER_SETTINGS[name];
205
+ }
206
+ try {
207
+ return sessionStorage.getItem(name) || DEFAULT_USER_SETTINGS[name];
208
+ } catch (e) {
209
+ return DEFAULT_USER_SETTINGS[name];
210
+ }
211
+ }
212
+ function utils_setSetting(name, value) {
213
+ if (!isBrowser()) {
214
+ return;
215
+ }
216
+ try {
217
+ sessionStorage.setItem(name, String(value));
218
+ } catch (e) {}
219
+ }
220
+ function isDetailsTag(el) {
221
+ return (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === 'details';
222
+ }
223
+ function isHeaderTag(el) {
224
+ return [
225
+ 'H1',
226
+ 'H2',
227
+ 'H3',
228
+ 'H4',
229
+ 'H5',
230
+ 'H6'
231
+ ].indexOf(el.tagName) !== -1;
232
+ }
233
+ /**
234
+ * Scrolls to the element.
235
+ * If the element is a heading - simply scrolls to it, since needed offset is already in css.
236
+ * If the element is of any other type - calculate the offset form the element position in heading and scroll to it.
237
+ * @param {HTMLElement} el
238
+ */ function scrollToElement(el) {
239
+ var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 200;
240
+ if (isInViewport(el)) {
241
+ return;
242
+ }
243
+ if (isHeaderTag(el)) {
244
+ // Header already includes the offset in css
245
+ // That puts it where we want it when it's scrolled to
246
+ el.scrollIntoView();
247
+ } else {
248
+ var elementPosition = el.getBoundingClientRect().top;
249
+ var offsetPosition = elementPosition + window.scrollY - offset;
250
+ window.scrollTo({
251
+ top: offsetPosition
252
+ });
253
+ }
254
+ }
255
+ function getLangPath(lang, href) {
256
+ var path = href.replace(/^https?:\/\/[^/]+/, '').replace(/^\/[a-z]{2}\//, '/');
257
+ return "".concat(lang).concat(path);
258
+ }
259
+ function isInViewport(el) {
260
+ var rect = el.getBoundingClientRect();
261
+ return rect.top >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight);
262
+ }
263
+ function scrollToHash() {
264
+ var hash = window.location.hash.substring(1);
265
+ if (!hash) {
266
+ return;
267
+ }
268
+ var element = document.getElementById(hash);
269
+ if (!element) {
270
+ return;
271
+ }
272
+ var node = element === null || element === void 0 ? void 0 : element.parentElement;
273
+ while(node){
274
+ if (isDetailsTag(node)) {
275
+ node.open = true;
276
+ }
277
+ node = node.parentElement;
278
+ }
279
+ element.focus();
280
+ setTimeout(function() {
281
+ scrollToElement(element);
282
+ }, 10);
283
+ }
284
+
285
+ // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_define_property.js
286
+ var _define_property = __webpack_require__(27412);
57
287
  // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_sliced_to_array.js + 3 modules
58
288
  var esm_sliced_to_array = __webpack_require__(24460);
59
- ;// CONCATENATED MODULE: ./src/components/index.ts
289
+ ;// CONCATENATED MODULE: ./src/components/App/useSettings.ts
60
290
 
61
291
 
62
292
 
63
293
 
64
- ;// CONCATENATED MODULE: ./src/hooks/useLang.ts
65
294
 
295
+ var capitalize = function(string) {
296
+ return string.replace(/^./, function(ch) {
297
+ return ch.toUpperCase();
298
+ });
299
+ };
300
+ function useSettings_useSettings() {
301
+ var settings = getSettings();
302
+ var theme = useSetting('theme', settings);
303
+ var textSize = useSetting('textSize', settings);
304
+ var wideFormat = useSetting('wideFormat', settings);
305
+ var fullScreen = useSetting('fullScreen', settings);
306
+ var showMiniToc = useSetting('showMiniToc', settings);
307
+ var controls = (0,react.useMemo)(function() {
308
+ return (0,_object_spread._)({}, theme, textSize, wideFormat, showMiniToc, fullScreen);
309
+ }, [
310
+ theme,
311
+ textSize,
312
+ wideFormat,
313
+ showMiniToc,
314
+ fullScreen
315
+ ]);
316
+ return controls;
317
+ }
318
+ function useSetting(name, settings) {
319
+ var _useState = (0,esm_sliced_to_array._)((0,react.useState)(settings[name]), 2), setting = _useState[0], setSetting = _useState[1];
320
+ var onChangeSetting = (0,react.useMemo)(function() {
321
+ return withSavingSetting(name, setSetting);
322
+ }, [
323
+ name,
324
+ setSetting
325
+ ]);
326
+ return (0,react.useMemo)(function() {
327
+ var _obj;
328
+ return _obj = {}, (0,_define_property._)(_obj, name, setting), (0,_define_property._)(_obj, 'onChange' + capitalize(name), onChangeSetting), _obj;
329
+ }, [
330
+ name,
331
+ setting,
332
+ onChangeSetting
333
+ ]);
334
+ }
335
+ function withSavingSetting(settingName, onChange) {
336
+ return function(value) {
337
+ utils_setSetting(settingName, value);
338
+ onChange(value);
339
+ };
340
+ }
66
341
 
67
- var LangContext = (0,react.createContext)(models/* .Lang.En */.Uo.En);
68
- LangContext.displayName = 'Lang';
69
- var LangProvider = LangContext.Provider;
70
- function useLang() {
71
- return (0,react.useContext)(LangContext);
342
+ ;// CONCATENATED MODULE: ./src/components/App/useMobile.ts
343
+
344
+
345
+
346
+ function useMobile_useMobile() {
347
+ var _useState = (0,esm_sliced_to_array._)((0,react.useState)(getMobileView()), 2), mobileView = _useState[0], setMobileView = _useState[1];
348
+ var onResizeHandler = (0,react.useCallback)(function() {
349
+ setMobileView(getMobileView());
350
+ }, []);
351
+ (0,react.useEffect)(onResizeHandler, [
352
+ onResizeHandler
353
+ ]);
354
+ (0,react.useEffect)(function() {
355
+ window.addEventListener('resize', onResizeHandler);
356
+ return function() {
357
+ return window.removeEventListener('resize', onResizeHandler);
358
+ };
359
+ }, [
360
+ onResizeHandler
361
+ ]);
362
+ return mobileView;
72
363
  }
73
364
 
365
+ // EXTERNAL MODULE: ./node_modules/bem-cn-lite/lib/index.js
366
+ var lib = __webpack_require__(22853);
367
+ ;// CONCATENATED MODULE: ./src/components/index.ts
368
+
369
+
370
+
371
+
74
372
  // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_async_to_generator.js
75
373
  var _async_to_generator = __webpack_require__(76150);
76
374
  // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_class_call_check.js
77
375
  var _class_call_check = __webpack_require__(43830);
78
376
  // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_create_class.js
79
377
  var _create_class = __webpack_require__(52062);
80
- // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_define_property.js
81
- var _define_property = __webpack_require__(27412);
82
378
  // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_instanceof.js
83
379
  var _instanceof = __webpack_require__(41196);
84
380
  // EXTERNAL MODULE: ./node_modules/tslib/tslib.es6.mjs
@@ -317,9 +613,9 @@ function useProvider_useProvider() {
317
613
  return provider;
318
614
  }
319
615
 
320
- ;// CONCATENATED MODULE: ./src/components/Search/Search.scss
616
+ ;// CONCATENATED MODULE: ./src/components/Search/Page.scss
321
617
 
322
- ;// CONCATENATED MODULE: ./src/components/Search/Search.tsx
618
+ ;// CONCATENATED MODULE: ./src/components/Search/Page.tsx
323
619
 
324
620
 
325
621
 
@@ -355,7 +651,7 @@ function formatResults(searchResults) {
355
651
  });
356
652
  }
357
653
  var ITEMS_PER_PAGE = 10;
358
- var Search = function() {
654
+ var Page_Page = function() {
359
655
  var provider = useProvider();
360
656
  var router = useRouter();
361
657
  var _useState = _sliced_to_array(useState(''), 2), query = _useState[0], setQuery = _useState[1];
@@ -426,234 +722,67 @@ var Search = function() {
426
722
  });
427
723
  };
428
724
 
429
- ;// CONCATENATED MODULE: ./src/components/Search/index.ts
725
+ ;// CONCATENATED MODULE: ./src/components/Search/index.tsx
430
726
 
431
- var SearchContext = (0,react.createContext)(null);
432
- SearchContext.displayName = 'SearchContext';
433
- var Search_SearchProvider = SearchContext.Provider;
434
727
 
435
- function useSearch() {
436
- return (0,react.useContext)(SearchContext);
437
- }
438
728
 
439
- // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/utils/index.js + 63 modules
440
- var utils = __webpack_require__(20935);
441
- // EXTERNAL MODULE: ./node_modules/@swc/helpers/esm/_to_consumable_array.js + 3 modules
442
- var _to_consumable_array = __webpack_require__(55210);
443
- ;// CONCATENATED MODULE: ./src/constants.ts
444
729
 
445
730
 
446
- var HEADER_HEIGHT = 64;
447
- var MOBILE_VIEW_WIDTH_BREAKPOINT = 769;
448
- var DEFAULT_USER_SETTINGS = {
449
- theme: models/* .Theme.Light */.Q2.Light,
450
- textSize: models/* .TextSizes.M */.tF.M,
451
- showMiniToc: true,
452
- wideFormat: true,
453
- fullScreen: false
454
- };
455
- var RTL_LANGS = [
456
- 'ar',
457
- 'arc',
458
- 'ckb',
459
- 'dv',
460
- 'fa',
461
- 'ha',
462
- 'he',
463
- 'khw',
464
- 'ks',
465
- 'ps',
466
- 'sd',
467
- 'ur',
468
- 'uz_AF',
469
- 'yi'
470
- ];
471
- var constants_TextDirection = /*#__PURE__*/ function(TextDirection) {
472
- TextDirection["RTL"] = "rtl";
473
- TextDirection["LTR"] = "ltr";
474
- return TextDirection;
475
- }({});
476
- var LINK_KEYS_LEADING_CONFIG = [
477
- 'href'
478
- ];
479
- var LINK_KEYS_PAGE_CONSTRUCTOR_CONFIG = [
480
- 'src',
481
- 'url',
482
- 'href',
483
- 'icon',
484
- 'image',
485
- 'desktop',
486
- 'mobile',
487
- 'tablet',
488
- 'previewImg',
489
- 'image',
490
- 'avatar',
491
- 'logo',
492
- 'light',
493
- 'dark'
494
- ];
495
- var LINK_KEYS = (0,_to_consumable_array._)(new Set((0,_to_consumable_array._)(LINK_KEYS_LEADING_CONFIG).concat((0,_to_consumable_array._)(LINK_KEYS_PAGE_CONSTRUCTOR_CONFIG))));
496
731
 
497
- ;// CONCATENATED MODULE: ./src/utils.ts
498
732
 
499
733
 
500
- function isBrowser() {
501
- return typeof document !== 'undefined';
502
- }
503
- function updateThemeClassName(param) {
504
- var theme = param.theme;
505
- if (typeof document === 'undefined') {
506
- return;
507
- }
508
- document.querySelectorAll('.g-root').forEach(function(el) {
509
- el.classList.toggle('g-root_theme_light', theme === 'light');
510
- el.classList.toggle('g-root_theme_dark', theme === 'dark');
511
- });
512
- }
513
- function updateRootClassName(states) {
514
- if (!isBrowser()) {
515
- return;
516
- }
517
- document.body.classList.add('g-root');
518
- var toggle = function(name, state) {
519
- return document.body.classList.toggle(name, Boolean(state));
520
- };
521
- Object.keys(states).forEach(function(state) {
522
- switch(state){
523
- case 'wideFormat':
524
- toggle('dc-root_wide-format', states[state]);
525
- break;
526
- case 'focusSearch':
527
- toggle('dc-root_focused-search', states[state]);
528
- break;
529
- case 'fullScreen':
530
- toggle('dc-root_full-screen', states[state]);
531
- break;
532
- case 'landingPage':
533
- toggle('dc-root_document-page', !states[state]);
534
- toggle('dc-root_landing-page', states[state]);
535
- break;
536
- case 'mobileView':
537
- toggle('mobile', states[state]);
538
- toggle('desktop', !states[state]);
539
- break;
540
- }
734
+
735
+
736
+ var SearchContext = /*#__PURE__*/ (0,react.createContext)(null);
737
+ SearchContext.displayName = 'SearchContext';
738
+ var Search_SearchProvider = SearchContext.Provider;
739
+ function Search(props) {
740
+ var data = props.data, url = props.url;
741
+ var searchData = data.search;
742
+ var lang = (searchData === null || searchData === void 0 ? void 0 : searchData.lang) || Lang.En;
743
+ var settings = useSettings();
744
+ var mobileView = useMobile();
745
+ var fixedLang = SUPPORTED_LANGS.includes(lang) ? lang : Lang.En;
746
+ var direction = getDirection(fixedLang);
747
+ configure({
748
+ lang: fixedLang,
749
+ localeCode: fixedLang
541
750
  });
542
- }
543
- function getDirection(lang) {
544
- var isRTL = RTL_LANGS.includes(lang);
545
- return isRTL ? constants_TextDirection.RTL : constants_TextDirection.LTR;
546
- }
547
- var toBoolean = function(str) {
548
- if (typeof str === 'boolean') {
549
- return str;
550
- }
551
- return str ? str === 'true' : false;
552
- };
553
- function getSettings() {
554
- var theme = getSetting('theme');
555
- var textSize = getSetting('textSize');
556
- var showMiniToc = getSetting('showMiniToc');
557
- var wideFormat = getSetting('wideFormat');
558
- var fullScreen = getSetting('fullScreen');
559
- return {
560
- theme: theme,
561
- textSize: textSize,
562
- showMiniToc: toBoolean(showMiniToc),
563
- wideFormat: toBoolean(wideFormat),
564
- fullScreen: toBoolean(fullScreen)
751
+ var routerConfig = {
752
+ pathname: url.pathname,
753
+ depth: 3
565
754
  };
566
- }
567
- function getLandingPage(data) {
568
- return (0,utils/* .getPageType */.C2)(data) === 'PAGE_CONSTRUCTOR';
569
- }
570
- function getMobileView() {
571
- if (!isBrowser()) {
572
- return false;
573
- }
574
- return document.body.clientWidth < MOBILE_VIEW_WIDTH_BREAKPOINT;
575
- }
576
- function getSetting(name) {
577
- if (!isBrowser()) {
578
- return DEFAULT_USER_SETTINGS[name];
579
- }
580
- try {
581
- return sessionStorage.getItem(name) || DEFAULT_USER_SETTINGS[name];
582
- } catch (e) {
583
- return DEFAULT_USER_SETTINGS[name];
584
- }
585
- }
586
- function utils_setSetting(name, value) {
587
- if (!isBrowser()) {
588
- return;
589
- }
590
- try {
591
- sessionStorage.setItem(name, String(value));
592
- } catch (e) {}
593
- }
594
- function isDetailsTag(el) {
595
- return (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === 'details';
596
- }
597
- function isHeaderTag(el) {
598
- return [
599
- 'H1',
600
- 'H2',
601
- 'H3',
602
- 'H4',
603
- 'H5',
604
- 'H6'
605
- ].indexOf(el.tagName) !== -1;
606
- }
607
- /**
608
- * Scrolls to the element.
609
- * If the element is a heading - simply scrolls to it, since needed offset is already in css.
610
- * If the element is of any other type - calculate the offset form the element position in heading and scroll to it.
611
- * @param {HTMLElement} el
612
- */ function scrollToElement(el) {
613
- var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 200;
614
- if (isInViewport(el)) {
615
- return;
616
- }
617
- if (isHeaderTag(el)) {
618
- // Header already includes the offset in css
619
- // That puts it where we want it when it's scrolled to
620
- el.scrollIntoView();
621
- } else {
622
- var elementPosition = el.getBoundingClientRect().top;
623
- var offsetPosition = elementPosition + window.scrollY - offset;
624
- window.scrollTo({
625
- top: offsetPosition
755
+ var theme = settings.theme, wideFormat = settings.wideFormat;
756
+ useEffect(function() {
757
+ updateRootClassName({
758
+ mobileView: mobileView,
759
+ wideFormat: wideFormat
626
760
  });
627
- }
628
- }
629
- function getLangPath(lang, href) {
630
- var path = href.replace(/^https?:\/\/[^/]+/, '').replace(/^\/[a-z]{2}\//, '/');
631
- return "".concat(lang).concat(path);
632
- }
633
- function isInViewport(el) {
634
- var rect = el.getBoundingClientRect();
635
- return rect.top >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight);
761
+ updateThemeClassName({
762
+ theme: theme
763
+ });
764
+ }, [
765
+ theme,
766
+ mobileView,
767
+ wideFormat
768
+ ]);
769
+ return /*#__PURE__*/ _jsx(ThemeProvider, {
770
+ theme: theme,
771
+ direction: direction,
772
+ children: /*#__PURE__*/ _jsx(LangProvider, {
773
+ value: fixedLang,
774
+ children: /*#__PURE__*/ _jsx(RouterProvider, {
775
+ value: routerConfig,
776
+ children: /*#__PURE__*/ _jsx(Search_SearchProvider, {
777
+ value: searchData,
778
+ children: /*#__PURE__*/ _jsx(Page, {})
779
+ })
780
+ })
781
+ })
782
+ });
636
783
  }
637
- function scrollToHash() {
638
- var hash = window.location.hash.substring(1);
639
- if (!hash) {
640
- return;
641
- }
642
- var element = document.getElementById(hash);
643
- if (!element) {
644
- return;
645
- }
646
- var node = element === null || element === void 0 ? void 0 : element.parentElement;
647
- while(node){
648
- if (isDetailsTag(node)) {
649
- node.open = true;
650
- }
651
- node = node.parentElement;
652
- }
653
- element.focus();
654
- setTimeout(function() {
655
- scrollToElement(element);
656
- }, 10);
784
+ function useSearch() {
785
+ return (0,react.useContext)(SearchContext);
657
786
  }
658
787
 
659
788
  // EXTERNAL MODULE: ./src/interceptors/leading-page-links.js
@@ -855,12 +984,12 @@ function Suggest() {
855
984
  var suggest = (0,react.useRef)(null);
856
985
  var isSearchHidden = (0,useInterface/* .useInterface */.I)('search');
857
986
  var onFocus = (0,react.useCallback)(function() {
858
- updateRootClassName({
987
+ utils_updateRootClassName({
859
988
  focusSearch: true
860
989
  });
861
990
  }, []);
862
991
  var onBlur = (0,react.useCallback)(function() {
863
- updateRootClassName({
992
+ utils_updateRootClassName({
864
993
  focusSearch: false
865
994
  });
866
995
  setTimeout(function() {
@@ -1046,7 +1175,7 @@ var useNavigation = function(data, controls, CustomControls, CustomSuggest, view
1046
1175
 
1047
1176
 
1048
1177
 
1049
- function Page_Page(_param) {
1178
+ function App_Page_Page(_param) {
1050
1179
  var data = _param.data, pageProps = (0,_object_without_properties._)(_param, [
1051
1180
  "data"
1052
1181
  ]);
@@ -1075,7 +1204,7 @@ function LegacyNavPage(param) {
1075
1204
  }, [
1076
1205
  content
1077
1206
  ]);
1078
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(Page_Page, (0,_object_spread_props._)((0,_object_spread._)({
1207
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(App_Page_Page, (0,_object_spread_props._)((0,_object_spread._)({
1079
1208
  data: data,
1080
1209
  headerHeight: 0
1081
1210
  }, props, controls), {
@@ -1107,7 +1236,7 @@ function RichNavPage(param) {
1107
1236
  ]);
1108
1237
  var navigation = useNavigation(data, controls, CustomControls, CustomSuggest);
1109
1238
  var CustomPage = (0,react.useCallback)(function() {
1110
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(Page_Page, (0,_object_spread_props._)((0,_object_spread._)({
1239
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(App_Page_Page, (0,_object_spread_props._)((0,_object_spread._)({
1111
1240
  data: data,
1112
1241
  headerHeight: fullScreen ? 0 : 64
1113
1242
  }, props, navigation.withControls ? filterControls(controls, [
@@ -1230,82 +1359,6 @@ function useLangs(param) {
1230
1359
  ]);
1231
1360
  }
1232
1361
 
1233
- ;// CONCATENATED MODULE: ./src/components/App/useSettings.ts
1234
-
1235
-
1236
-
1237
-
1238
-
1239
- var capitalize = function(string) {
1240
- return string.replace(/^./, function(ch) {
1241
- return ch.toUpperCase();
1242
- });
1243
- };
1244
- function useSettings() {
1245
- var settings = getSettings();
1246
- var theme = useSetting('theme', settings);
1247
- var textSize = useSetting('textSize', settings);
1248
- var wideFormat = useSetting('wideFormat', settings);
1249
- var fullScreen = useSetting('fullScreen', settings);
1250
- var showMiniToc = useSetting('showMiniToc', settings);
1251
- var controls = (0,react.useMemo)(function() {
1252
- return (0,_object_spread._)({}, theme, textSize, wideFormat, showMiniToc, fullScreen);
1253
- }, [
1254
- theme,
1255
- textSize,
1256
- wideFormat,
1257
- showMiniToc,
1258
- fullScreen
1259
- ]);
1260
- return controls;
1261
- }
1262
- function useSetting(name, settings) {
1263
- var _useState = (0,esm_sliced_to_array._)((0,react.useState)(settings[name]), 2), setting = _useState[0], setSetting = _useState[1];
1264
- var onChangeSetting = (0,react.useMemo)(function() {
1265
- return withSavingSetting(name, setSetting);
1266
- }, [
1267
- name,
1268
- setSetting
1269
- ]);
1270
- return (0,react.useMemo)(function() {
1271
- var _obj;
1272
- return _obj = {}, (0,_define_property._)(_obj, name, setting), (0,_define_property._)(_obj, 'onChange' + capitalize(name), onChangeSetting), _obj;
1273
- }, [
1274
- name,
1275
- setting,
1276
- onChangeSetting
1277
- ]);
1278
- }
1279
- function withSavingSetting(settingName, onChange) {
1280
- return function(value) {
1281
- utils_setSetting(settingName, value);
1282
- onChange(value);
1283
- };
1284
- }
1285
-
1286
- ;// CONCATENATED MODULE: ./src/components/App/useMobile.ts
1287
-
1288
-
1289
-
1290
- function useMobile() {
1291
- var _useState = (0,esm_sliced_to_array._)((0,react.useState)(getMobileView()), 2), mobileView = _useState[0], setMobileView = _useState[1];
1292
- var onResizeHandler = (0,react.useCallback)(function() {
1293
- setMobileView(getMobileView());
1294
- }, []);
1295
- (0,react.useEffect)(onResizeHandler, [
1296
- onResizeHandler
1297
- ]);
1298
- (0,react.useEffect)(function() {
1299
- window.addEventListener('resize', onResizeHandler);
1300
- return function() {
1301
- return window.removeEventListener('resize', onResizeHandler);
1302
- };
1303
- }, [
1304
- onResizeHandler
1305
- ]);
1306
- return mobileView;
1307
- }
1308
-
1309
1362
  // EXTERNAL MODULE: ./node_modules/@diplodoc/mdx-extension/build/esm/hooks/useMdxSsr.js + 9 modules
1310
1363
  var useMdxSsr = __webpack_require__(2915);
1311
1364
  ;// CONCATENATED MODULE: ./src/components/App/withMdxInit.tsx
@@ -1369,9 +1422,9 @@ function hasNavigation(data) {
1369
1422
  function App(props) {
1370
1423
  var _analytics_gtm, _analytics_gtm1;
1371
1424
  var data = props.data, router = props.router, lang = props.lang, search = props.search, analytics = props.analytics, viewerInterface = props.viewerInterface;
1372
- var settings = useSettings();
1425
+ var settings = useSettings_useSettings();
1373
1426
  var langData = useLangs(props);
1374
- var mobileView = useMobile();
1427
+ var mobileView = useMobile_useMobile();
1375
1428
  var fixedLang = constants/* .SUPPORTED_LANGS.includes */.aP.includes(lang) ? lang : models/* .Lang.En */.Uo.En;
1376
1429
  (0,esm_config/* .configure */.jQ)({
1377
1430
  lang: fixedLang,
@@ -1418,16 +1471,16 @@ function App(props) {
1418
1471
  settings,
1419
1472
  mobileView
1420
1473
  ]);
1421
- var direction = getDirection(lang);
1474
+ var direction = utils_getDirection(lang);
1422
1475
  var landingPage = getLandingPage(data);
1423
1476
  (0,react.useEffect)(function() {
1424
- updateRootClassName({
1477
+ utils_updateRootClassName({
1425
1478
  mobileView: mobileView,
1426
1479
  wideFormat: wideFormat,
1427
1480
  fullScreen: fullScreen,
1428
1481
  landingPage: landingPage
1429
1482
  });
1430
- updateThemeClassName({
1483
+ utils_updateThemeClassName({
1431
1484
  theme: theme
1432
1485
  });
1433
1486
  scrollToHash();
@@ -1440,12 +1493,12 @@ function App(props) {
1440
1493
  ]);
1441
1494
  return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
1442
1495
  className: "App",
1443
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ThemeProvider/* .ThemeProvider */.f, {
1496
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(theme_ThemeProvider/* .ThemeProvider */.f, {
1444
1497
  theme: theme,
1445
1498
  direction: direction,
1446
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(LangProvider, {
1499
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(useLang_LangProvider, {
1447
1500
  value: lang,
1448
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(RouterProvider, {
1501
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Router_RouterProvider, {
1449
1502
  value: router,
1450
1503
  children: /*#__PURE__*/ (0,jsx_runtime.jsx)(Search_SearchProvider, {
1451
1504
  value: search,
@@ -1798,7 +1851,7 @@ __webpack_require__.m = __webpack_modules__;
1798
1851
  __webpack_require__.x = () => {
1799
1852
  // Load entry module and return exports
1800
1853
  // This entry module depends on other loaded chunks and execution need to be delayed
1801
- var __webpack_exports__ = __webpack_require__.O(undefined, ["966", "971"], function() { return __webpack_require__(11301) });
1854
+ var __webpack_exports__ = __webpack_require__.O(undefined, ["966", "971"], function() { return __webpack_require__(13543) });
1802
1855
  __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
1803
1856
  return __webpack_exports__
1804
1857
  };