@gravity-ui/dashkit 8.21.1-beta.0 → 8.22.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.
Files changed (65) hide show
  1. package/build/cjs/components/DashKit/DashKit.d.ts +16 -14
  2. package/build/cjs/components/DashKit/DashKit.js +6 -2
  3. package/build/cjs/components/DashKitDnDWrapper/DashKitDnDWrapper.js +2 -2
  4. package/build/cjs/components/DashKitView/DashKitView.js +2 -2
  5. package/build/cjs/components/GridItem/GridItem.js +2 -2
  6. package/build/cjs/components/GridLayout/GridLayout.d.ts +2 -2
  7. package/build/cjs/components/GridLayout/GridLayout.js +12 -6
  8. package/build/cjs/components/Item/Item.d.ts +1 -2
  9. package/build/cjs/components/MobileLayout/MobileLayout.d.ts +21 -28
  10. package/build/cjs/components/MobileLayout/MobileLayout.js +47 -60
  11. package/build/cjs/components/OverlayControls/OverlayControls.d.ts +16 -4
  12. package/build/cjs/components/OverlayControls/OverlayControls.js +9 -8
  13. package/build/cjs/context/DashKitContext.d.ts +3 -30
  14. package/build/cjs/context/DashKitContext.js +6 -2
  15. package/build/cjs/hocs/prepareItem.d.ts +1 -2
  16. package/build/cjs/hocs/prepareItem.js +2 -2
  17. package/build/cjs/hocs/withContext.js +20 -23
  18. package/build/cjs/hooks/useDnDItemProps.js +2 -2
  19. package/build/cjs/i18n/en.json +1 -1
  20. package/build/cjs/i18n/index.d.ts +5 -1
  21. package/build/cjs/plugins/Title/Title.css +4 -0
  22. package/build/cjs/plugins/Title/Title.d.ts +2 -1
  23. package/build/cjs/shared/modules/helpers.d.ts +1 -1
  24. package/build/cjs/shared/modules/helpers.js +1 -1
  25. package/build/cjs/shared/types/state-and-params.d.ts +1 -2
  26. package/build/cjs/typings/config.d.ts +0 -1
  27. package/build/esm/components/DashKit/DashKit.d.ts +16 -14
  28. package/build/esm/components/DashKit/DashKit.js +5 -1
  29. package/build/esm/components/DashKitDnDWrapper/DashKitDnDWrapper.js +1 -1
  30. package/build/esm/components/DashKitView/DashKitView.js +1 -1
  31. package/build/esm/components/GridItem/GridItem.js +1 -1
  32. package/build/esm/components/GridLayout/GridLayout.d.ts +2 -2
  33. package/build/esm/components/GridLayout/GridLayout.js +11 -5
  34. package/build/esm/components/Item/Item.d.ts +1 -2
  35. package/build/esm/components/MobileLayout/MobileLayout.d.ts +21 -29
  36. package/build/esm/components/MobileLayout/MobileLayout.js +46 -59
  37. package/build/esm/components/OverlayControls/OverlayControls.d.ts +16 -4
  38. package/build/esm/components/OverlayControls/OverlayControls.js +8 -7
  39. package/build/esm/context/DashKitContext.d.ts +3 -30
  40. package/build/esm/context/DashKitContext.js +4 -2
  41. package/build/esm/hocs/prepareItem.d.ts +1 -2
  42. package/build/esm/hocs/prepareItem.js +1 -1
  43. package/build/esm/hocs/withContext.js +17 -20
  44. package/build/esm/hooks/useDnDItemProps.js +1 -1
  45. package/build/esm/i18n/en.json +1 -1
  46. package/build/esm/i18n/index.d.ts +5 -1
  47. package/build/esm/plugins/Title/Title.css +4 -0
  48. package/build/esm/plugins/Title/Title.d.ts +2 -1
  49. package/build/esm/shared/modules/helpers.d.ts +1 -1
  50. package/build/esm/shared/modules/helpers.js +1 -1
  51. package/build/esm/shared/types/state-and-params.d.ts +1 -2
  52. package/build/esm/typings/config.d.ts +0 -1
  53. package/package.json +4 -4
  54. package/build/cjs/context/DashKitDnDContext.d.ts +0 -10
  55. package/build/cjs/context/DashKitDnDContext.js +0 -6
  56. package/build/cjs/context/DashkitOverlayControlsContext.d.ts +0 -13
  57. package/build/cjs/context/DashkitOverlayControlsContext.js +0 -6
  58. package/build/cjs/context/index.d.ts +0 -3
  59. package/build/cjs/context/index.js +0 -6
  60. package/build/esm/context/DashKitDnDContext.d.ts +0 -10
  61. package/build/esm/context/DashKitDnDContext.js +0 -2
  62. package/build/esm/context/DashkitOverlayControlsContext.d.ts +0 -13
  63. package/build/esm/context/DashkitOverlayControlsContext.js +0 -2
  64. package/build/esm/context/index.d.ts +0 -3
  65. package/build/esm/context/index.js +0 -3
@@ -6,7 +6,7 @@ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
7
7
  const pick_1 = tslib_1.__importDefault(require("lodash/pick"));
8
8
  const common_1 = require("../constants/common");
9
- const context_1 = require("../context");
9
+ const DashKitContext_1 = require("../context/DashKitContext");
10
10
  const useDeepEqualMemo_1 = require("../hooks/useDeepEqualMemo");
11
11
  const shared_1 = require("../shared");
12
12
  const utils_1 = require("../utils");
@@ -22,7 +22,7 @@ function useMemoStateContext(props) {
22
22
  const nowrapAdjustedLayouts = react_1.default.useRef({});
23
23
  const [temporaryLayout, setTemporaryLayout] = react_1.default.useState(null);
24
24
  const resetTemporaryLayout = react_1.default.useCallback(() => setTemporaryLayout(null), [setTemporaryLayout]);
25
- const dndContext = react_1.default.useContext(context_1.DashKitDnDContext);
25
+ const dndContext = react_1.default.useContext(DashKitContext_1.DashKitDnDContext);
26
26
  const outerDnDEnable = Boolean(dndContext);
27
27
  // TODO: need move originalLayouts, adjustedLayouts to state
28
28
  const [layoutUpdateCounter, forceUpdateLayout] = react_1.default.useState(0);
@@ -286,7 +286,6 @@ function useMemoStateContext(props) {
286
286
  }
287
287
  return itemLayout;
288
288
  }, [
289
- props.registerManager,
290
289
  resetTemporaryLayout,
291
290
  temporaryLayout,
292
291
  dragOverPlugin,
@@ -315,6 +314,8 @@ function useMemoStateContext(props) {
315
314
  });
316
315
  }, [dragPropsContext, onDropProp, setTemporaryLayout, resetTemporaryLayout]);
317
316
  const dashkitContextValue = react_1.default.useMemo(() => ({
317
+ layout: resultLayout,
318
+ temporaryLayout,
318
319
  config: props.config,
319
320
  groups: props.groups,
320
321
  context: props.context,
@@ -324,26 +325,24 @@ function useMemoStateContext(props) {
324
325
  globalParams: props.globalParams,
325
326
  editMode: props.editMode,
326
327
  settings: props.settings,
327
- onItemMountChange: props.onItemMountChange,
328
- onItemRender: props.onItemRender,
329
- draggableHandleClassName: props.draggableHandleClassName,
330
- registerManager: props.registerManager,
331
- forwardedMetaRef: props.forwardedMetaRef,
332
- layout: resultLayout,
333
- temporaryLayout,
334
- layoutChange: onLayoutChange,
335
- memorizeOriginalLayout,
336
- revertToOriginalLayout,
337
328
  itemsState,
338
329
  itemsParams,
330
+ registerManager: props.registerManager,
339
331
  onItemStateAndParamsChange,
340
- getItemsMeta,
341
- reloadItems,
342
332
  onDrop,
343
333
  onDropDragOver,
334
+ onItemMountChange: props.onItemMountChange,
335
+ onItemRender: props.onItemRender,
336
+ layoutChange: onLayoutChange,
337
+ getItemsMeta,
338
+ reloadItems,
339
+ memorizeOriginalLayout,
340
+ revertToOriginalLayout,
341
+ forwardedMetaRef: props.forwardedMetaRef,
342
+ draggableHandleClassName: props.draggableHandleClassName,
344
343
  outerDnDEnable,
345
344
  dragOverPlugin,
346
- /* default handlers bypass */
345
+ /* default bypassing handlers */
347
346
  onDragStart: props.onDragStart,
348
347
  onDrag: props.onDrag,
349
348
  onDragStop: props.onDragStop,
@@ -389,15 +388,14 @@ function useMemoStateContext(props) {
389
388
  const controlsContextValue = react_1.default.useMemo(() => ({
390
389
  overlayControls: props.overlayControls,
391
390
  context: props.context,
391
+ menu: overlayMenuItems,
392
392
  itemsStateAndParams: props.itemsStateAndParams,
393
- itemsState,
394
393
  itemsParams,
395
- getPreparedCopyItemOptions: props.getPreparedCopyItemOptions,
396
- onCopyFulfill: props.onCopyFulfill,
397
- menu: overlayMenuItems,
398
394
  editItem: props.onItemEdit,
399
395
  removeItem: onItemRemove,
400
396
  getLayoutItem: getLayoutItem,
397
+ getPreparedCopyItemOptions: props.getPreparedCopyItemOptions,
398
+ onCopyFulfill: props.onCopyFulfill,
401
399
  }), [
402
400
  props.overlayControls,
403
401
  props.context,
@@ -406,7 +404,6 @@ function useMemoStateContext(props) {
406
404
  props.getPreparedCopyItemOptions,
407
405
  props.onCopyFulfill,
408
406
  overlayMenuItems,
409
- itemsState,
410
407
  itemsParams,
411
408
  onItemRemove,
412
409
  getLayoutItem,
@@ -416,8 +413,8 @@ function useMemoStateContext(props) {
416
413
  function withContext(Component) {
417
414
  const WithContext = (props) => {
418
415
  const { dashkitContextValue, controlsContextValue } = useMemoStateContext(props);
419
- return (react_1.default.createElement(context_1.DashKitContext.Provider, { value: dashkitContextValue },
420
- react_1.default.createElement(context_1.DashkitOvelayControlsContext.Provider, { value: controlsContextValue },
416
+ return (react_1.default.createElement(DashKitContext_1.DashKitContext.Provider, { value: dashkitContextValue },
417
+ react_1.default.createElement(DashKitContext_1.DashkitOvelayControlsContext.Provider, { value: controlsContextValue },
421
418
  react_1.default.createElement(Component, null))));
422
419
  };
423
420
  WithContext.displayName = `withContext(${Component.displayName || Component.name || 'Component'}`;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDnDItemProps = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
- const context_1 = require("../context");
6
+ const DashKitContext_1 = require("../context/DashKitContext");
7
7
  const useDnDItemProps = (item) => {
8
- const dragContext = react_1.default.useContext(context_1.DashKitDnDContext);
8
+ const dragContext = react_1.default.useContext(DashKitContext_1.DashKitDnDContext);
9
9
  const onDragStart = react_1.default.useCallback((e) => {
10
10
  if (dragContext && item.dragProps) {
11
11
  dragContext.onDragStart(e, item.dragProps);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "button_retry": "Repeat",
3
- "label_render-markdown-error": "Ошибка преобразования в markdown",
3
+ "label_render-markdown-error": "Markdown transformation error",
4
4
  "label_settings": "Settings",
5
5
  "label_copy": "Copy",
6
6
  "label_delete": "Delete",
@@ -1 +1,5 @@
1
- export declare const i18n: (key: "button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", params?: import("@gravity-ui/i18n").Params | undefined) => string;
1
+ export declare const i18n: ((key: "button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", params?: import("@gravity-ui/i18n").Params | undefined) => string) & {
2
+ keysetData: {
3
+ dashkit: Record<"button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", import("@gravity-ui/i18n").KeyData>;
4
+ };
5
+ };
@@ -6,6 +6,10 @@
6
6
  padding-bottom: 5px;
7
7
  padding-right: 5px;
8
8
  }
9
+ .dashkit-plugin-title_size_xl {
10
+ font-size: 32px;
11
+ line-height: 40px;
12
+ }
9
13
  .dashkit-plugin-title_size_l {
10
14
  font-size: 24px;
11
15
  line-height: 28px;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Plugin, PluginWidgetProps } from '../../typings';
3
+ export type PluginTitleSize = 'xl' | 'l' | 'm' | 's' | 'xs';
3
4
  export interface PluginTitleProps extends PluginWidgetProps {
4
5
  data: {
5
- size: 'l' | 'm' | 's' | 'xs';
6
+ size: PluginTitleSize;
6
7
  text: string;
7
8
  showInTOC: boolean;
8
9
  } & PluginWidgetProps['data'];
@@ -18,7 +18,7 @@ export declare function formQueueData({ items, itemsStateAndParams, }: {
18
18
  }): FormedQueueData[];
19
19
  export declare function resolveItemInnerId({ item, itemsStateAndParams, }: {
20
20
  item: Pick<ConfigItemWithTabs, 'data' | 'id'>;
21
- itemsStateAndParams?: ItemsStateAndParams;
21
+ itemsStateAndParams: ItemsStateAndParams;
22
22
  }): string;
23
23
  export declare function getMapItemsIgnores({ items, ignores, itemsStateAndParams, isFirstVersion, }: {
24
24
  items: (ConfigItem | ConfigItemGroup)[];
@@ -118,7 +118,7 @@ exports.formQueueData = formQueueData;
118
118
  function resolveItemInnerId({ item, itemsStateAndParams, }) {
119
119
  var _a, _b;
120
120
  const { id } = item;
121
- const stateTabId = (_b = (_a = itemsStateAndParams === null || itemsStateAndParams === void 0 ? void 0 : itemsStateAndParams[id]) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.tabId;
121
+ const stateTabId = (_b = (_a = itemsStateAndParams[id]) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.tabId;
122
122
  const { tabs } = item.data;
123
123
  if (stateTabId && tabs.some((tab) => tab.id === stateTabId)) {
124
124
  return stateTabId;
@@ -3,7 +3,6 @@ import { StringParams } from './common';
3
3
  export interface ItemState {
4
4
  [key: string]: any;
5
5
  }
6
- export type ItemParams = StringParams | Record<string, StringParams>;
7
6
  export interface QueueItem {
8
7
  id: string;
9
8
  tabId?: string;
@@ -17,7 +16,7 @@ export type StateAndParamsMeta = {
17
16
  [META_KEY]: StateAndParamsMetaData;
18
17
  };
19
18
  export type ItemStateAndParams = {
20
- params?: ItemParams;
19
+ params?: StringParams | Record<string, StringParams>;
21
20
  state?: ItemState;
22
21
  };
23
22
  export type ItemStateAndParamsChangeOptions = {
@@ -28,7 +28,6 @@ export type AddNewItemOptions = SetItemOptions & {
28
28
  export interface DashkitGroupRenderProps {
29
29
  config: Config;
30
30
  editMode: boolean;
31
- isMobile: boolean;
32
31
  items: ConfigItem[];
33
32
  layout: ConfigLayout[];
34
33
  context: any;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { Config, ConfigItem, ConfigLayout, GlobalParams, ItemDropProps, ItemsStateAndParams } from '../../shared';
3
- import type { AddNewItemOptions, ContextProps, DashKitGroup, ItemManipulationCallback, MenuItem, Plugin, SetConfigItem, Settings, SettingsProps } from '../../typings';
3
+ import { AddNewItemOptions, ContextProps, DashKitGroup, ItemManipulationCallback, MenuItem, Plugin, SetConfigItem, Settings, SettingsProps } from '../../typings';
4
4
  import GridLayout from '../GridLayout/GridLayout';
5
- import type { OverlayControlItem, PreparedCopyItemOptions } from '../OverlayControls/OverlayControls';
6
- interface DashKitGeneralProps {
5
+ import { OverlayControlItem, OverlayControlsCtxShape } from '../OverlayControls/OverlayControls';
6
+ interface DashKitGeneralProps extends Pick<OverlayControlsCtxShape, 'getPreparedCopyItemOptions' | 'onCopyFulfill'> {
7
7
  config: Config;
8
8
  editMode: boolean;
9
9
  draggableHandleClassName?: string;
@@ -11,14 +11,6 @@ interface DashKitGeneralProps {
11
11
  overlayMenuItems?: MenuItem[] | null;
12
12
  }
13
13
  interface DashKitDefaultProps {
14
- defaultGlobalParams: GlobalParams;
15
- globalParams: GlobalParams;
16
- itemsStateAndParams: ItemsStateAndParams;
17
- settings: SettingsProps;
18
- context: ContextProps;
19
- noOverlay: boolean;
20
- focusable?: boolean;
21
- groups?: DashKitGroup[];
22
14
  onItemEdit: (item: ConfigItem) => void;
23
15
  onChange: (data: {
24
16
  config: Config;
@@ -31,21 +23,27 @@ interface DashKitDefaultProps {
31
23
  isMounted: boolean;
32
24
  }) => void;
33
25
  onItemRender?: (item: ConfigItem) => void;
34
- getPreparedCopyItemOptions?: (options: PreparedCopyItemOptions) => PreparedCopyItemOptions;
35
- onCopyFulfill?: (error: null | Error, data?: PreparedCopyItemOptions) => void;
36
26
  onDragStart?: ItemManipulationCallback;
37
27
  onDrag?: ItemManipulationCallback;
38
28
  onDragStop?: ItemManipulationCallback;
39
29
  onResizeStart?: ItemManipulationCallback;
40
30
  onResize?: ItemManipulationCallback;
41
31
  onResizeStop?: ItemManipulationCallback;
32
+ defaultGlobalParams: GlobalParams;
33
+ globalParams: GlobalParams;
34
+ itemsStateAndParams: ItemsStateAndParams;
35
+ settings: SettingsProps;
36
+ context: ContextProps;
37
+ noOverlay: boolean;
38
+ focusable?: boolean;
39
+ groups?: DashKitGroup[];
42
40
  }
43
41
  export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {
44
42
  }
45
43
  type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
46
44
  export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
47
45
  static defaultProps: DashKitDefaultProps;
48
- static contextType: React.Context<void | import("../../context").DashKitDnDCtxShape>;
46
+ static contextType: React.Context<any>;
49
47
  static registerPlugins(...plugins: Plugin[]): void;
50
48
  static reloadPlugins(...plugins: Plugin[]): void;
51
49
  static setSettings(settings: Settings): void;
@@ -72,5 +70,9 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
72
70
  metaRef: React.RefObject<GridLayout>;
73
71
  render(): JSX.Element;
74
72
  getItemsMeta(): any;
73
+ reloadItems(options?: {
74
+ targetIds?: string[];
75
+ force?: boolean;
76
+ }): void;
75
77
  }
76
78
  export {};
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import noop from 'lodash/noop';
3
3
  import pick from 'lodash/pick';
4
4
  import { DEFAULT_GROUP, DEFAULT_NAMESPACE } from '../../constants';
5
- import { DashKitDnDContext } from '../../context';
5
+ import { DashKitDnDContext } from '../../context/DashKitContext';
6
6
  import { RegisterManager, UpdateManager, reflowLayout } from '../../utils';
7
7
  import { DashKitDnDWrapper } from '../DashKitDnDWrapper/DashKitDnDWrapper';
8
8
  import DashKitView from '../DashKitView/DashKitView';
@@ -87,6 +87,10 @@ export class DashKit extends React.PureComponent {
87
87
  var _a;
88
88
  return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.getItemsMeta();
89
89
  }
90
+ reloadItems(options) {
91
+ var _a;
92
+ (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.reloadItems(options);
93
+ }
90
94
  }
91
95
  DashKit.defaultProps = {
92
96
  onItemEdit: noop,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { DashKitDnDContext } from '../../context';
2
+ import { DashKitDnDContext } from '../../context/DashKitContext';
3
3
  const defaultImageSrc = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
4
4
  export const DashKitDnDWrapper = (props) => {
5
5
  const [dragProps, setDragProps] = React.useState(null);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { DashKitContext } from '../../context';
2
+ import { DashKitContext } from '../../context/DashKitContext';
3
3
  import { withContext } from '../../hocs/withContext';
4
4
  import { useCalcPropsLayout } from '../../hooks/useCalcLayout';
5
5
  import { cn } from '../../utils/cn';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FOCUSED_CLASS_NAME } from '../../constants';
4
- import { DashKitContext } from '../../context';
4
+ import { DashKitContext } from '../../context/DashKitContext';
5
5
  import { cn } from '../../utils/cn';
6
6
  import Item from '../Item/Item';
7
7
  import OverlayControls from '../OverlayControls/OverlayControls';
@@ -1,5 +1,5 @@
1
1
  export default class GridLayout extends React.PureComponent<any, any, any> {
2
- static contextType: React.Context<import("../../context").DashKitCtxShape>;
2
+ static contextType: React.Context<any>;
3
3
  constructor(props: any, context: any);
4
4
  pluginsRefs: any[];
5
5
  state: {
@@ -38,7 +38,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
38
38
  };
39
39
  getMemoForwardRefCallback: (refIndex: any) => any;
40
40
  mergeGroupsLayout(group: any, newLayout: any, temporaryItem: any): any;
41
- reloadItems(): void;
41
+ reloadItems(options: any): void;
42
42
  prepareDefaultArguments(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): {
43
43
  group: any;
44
44
  layout: any;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { COMPACT_TYPE_HORIZONTAL_NOWRAP, DEFAULT_GROUP, DRAGGABLE_CANCEL_CLASS_NAME, TEMPORARY_ITEM_ID, } from '../../constants';
3
- import { DashKitContext } from '../../context';
3
+ import { DashKitContext } from '../../context/DashKitContext';
4
4
  import { resolveLayoutGroup } from '../../utils';
5
5
  import GridItem from '../GridItem/GridItem';
6
6
  import { Layout } from './ReactGridLayout';
@@ -249,19 +249,26 @@ class GridLayout extends React.PureComponent {
249
249
  return currentItem;
250
250
  });
251
251
  }
252
- reloadItems() {
252
+ reloadItems(options) {
253
+ const { targetIds, force } = options || {};
253
254
  const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
254
255
  const { isPageHidden } = this.state;
255
256
  const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
257
+ const targetPlugins = targetIds
258
+ ? this.pluginsRefs.filter((plugin) => targetIds.includes(plugin.props.id))
259
+ : this.pluginsRefs;
256
260
  if (autoupdateIntervalMs) {
257
261
  const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
258
262
  const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
259
- if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
263
+ if (force || (!isPageHidden && !editMode && reloadIntervalRemains <= 0)) {
260
264
  this._lastReloadAt = new Date().getTime();
261
- reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
265
+ reloadItems(targetPlugins, { silentLoading, noVeil: true });
262
266
  }
263
267
  this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
264
268
  }
269
+ else if (force || (!isPageHidden && !editMode)) {
270
+ reloadItems(targetPlugins, { silentLoading, noVeil: true });
271
+ }
265
272
  }
266
273
  prepareDefaultArguments(group, layout, oldItem, newItem, placeholder, e, element) {
267
274
  return {
@@ -491,7 +498,6 @@ class GridLayout extends React.PureComponent {
491
498
  offset += items.length;
492
499
  if (group.render) {
493
500
  const groupContext = {
494
- isMobile: false,
495
501
  config,
496
502
  editMode,
497
503
  items,
@@ -66,8 +66,7 @@ declare const _default: {
66
66
  onItemMountChange: PropTypes.Requireable<(...args: any[]) => any>;
67
67
  forwardedPluginRef: PropTypes.Requireable<any>;
68
68
  };
69
- contextType: React.Context<import("../../context").DashKitCtxShape>;
69
+ contextType: React.Context<any>;
70
70
  };
71
71
  export default _default;
72
72
  import React from 'react';
73
- import PropTypes from 'prop-types';
@@ -1,31 +1,23 @@
1
- import React from 'react';
2
- import { DashKitContext } from '../../context';
3
- import { getSortedConfigItems } from './helpers';
4
- import './MobileLayout.css';
5
- type MobileLayoutProps = {};
6
- type MobileLayoutState = {
7
- itemsWithActiveAutoheight: Record<string, boolean>;
8
- };
9
- type PlugibRefObject = React.RefObject<any>;
10
- export default class MobileLayout extends React.PureComponent<MobileLayoutProps, MobileLayoutState> {
11
- static contextType: React.Context<import("../../context").DashKitCtxShape>;
12
- context: React.ContextType<typeof DashKitContext>;
13
- pluginsRefs: PlugibRefObject[];
14
- sortedLayoutItems: Record<string, ReturnType<typeof getSortedConfigItems>> | null;
15
- _memoLayout: import("../..").ConfigLayout[];
16
- _memoForwardedPluginRef: Array<(refObject: PlugibRefObject) => void>;
17
- _memoAdjustWidgetLayout: Record<string, (props: {
18
- needSetDefault: boolean;
19
- }) => void>;
20
- state: MobileLayoutState;
21
- render(): JSX.Element;
22
- getSortedLayoutItems(): Record<string, (import("../..").ConfigItem & import("../..").ConfigLayout)[]>;
23
- getMemoForwardRefCallback(refIndex: number): (refObject: PlugibRefObject) => void;
24
- adjustWidgetLayout(id: string, { needSetDefault }: {
25
- needSetDefault: boolean;
26
- }): void;
27
- getMemoAdjustWidgetLayout(id: string): (props: {
28
- needSetDefault: boolean;
1
+ export default class MobileLayout extends React.PureComponent<any, any, any> {
2
+ static contextType: React.Context<any>;
3
+ constructor(props: any);
4
+ constructor(props: any, context: any);
5
+ pluginsRefs: any[];
6
+ sortedLayoutItems: any;
7
+ _memoLayout: any;
8
+ _memoForwardedPluginRef: any[];
9
+ _memoAdjustWidgetLayout: any[];
10
+ state: {
11
+ activeTabId: null;
12
+ indexesOfItemsWithActiveAutoheight: {};
13
+ };
14
+ componentDidUpdate(prevProps: any, prevState: any): void;
15
+ getSortedLayoutItems(): any;
16
+ getMemoForwardRefCallback: (refIndex: any) => any;
17
+ adjustWidgetLayout: (index: any, { needSetDefault }: {
18
+ needSetDefault: any;
29
19
  }) => void;
20
+ getMemoAdjustWidgetLayout: (index: any) => any;
21
+ render(): JSX.Element;
30
22
  }
31
- export {};
23
+ import React from 'react';
@@ -1,7 +1,5 @@
1
1
  import React from 'react';
2
- import groupBy from 'lodash/groupBy';
3
- import { DEFAULT_GROUP } from '../../constants';
4
- import { DashKitContext } from '../../context';
2
+ import { DashKitContext } from '../../context/DashKitContext';
5
3
  import { cn } from '../../utils/cn';
6
4
  import Item from '../Item/Item';
7
5
  import { getSortedConfigItems } from './helpers';
@@ -11,40 +9,47 @@ class MobileLayout extends React.PureComponent {
11
9
  constructor() {
12
10
  super(...arguments);
13
11
  this.pluginsRefs = [];
14
- this.sortedLayoutItems = null;
15
12
  this._memoLayout = this.context.layout;
16
13
  this._memoForwardedPluginRef = [];
17
- this._memoAdjustWidgetLayout = {};
14
+ this._memoAdjustWidgetLayout = [];
18
15
  this.state = {
19
- itemsWithActiveAutoheight: {},
16
+ activeTabId: null,
17
+ indexesOfItemsWithActiveAutoheight: {},
20
18
  };
21
- }
22
- render() {
23
- const { config, layout, groups = [{ id: DEFAULT_GROUP }], context, editMode } = this.context;
24
- this.pluginsRefs.length = config.items.length;
25
- const sortedItems = this.getSortedLayoutItems();
26
- let indexOffset = 0;
27
- return (React.createElement("div", { className: b() }, groups.map((group) => {
28
- const groupId = group.id || DEFAULT_GROUP;
29
- const items = sortedItems[groupId];
30
- const children = items.map((item, index) => {
31
- const isItemWithActiveAutoheight = item.id in this.state.itemsWithActiveAutoheight;
32
- return (React.createElement("div", { className: b('item', { autoheight: isItemWithActiveAutoheight }), key: item.id },
33
- React.createElement(Item, { id: item.id, item: item, layout: layout, shouldItemUpdate: false, adjustWidgetLayout: this.getMemoAdjustWidgetLayout(item.id), forwardedPluginRef: this.getMemoForwardRefCallback(indexOffset + index), onItemMountChange: this.context.onItemMountChange, onItemRender: this.context.onItemRender })));
34
- });
35
- indexOffset += items.length;
36
- if (group.render) {
37
- return group.render(groupId, children, {
38
- isMobile: true,
39
- config,
40
- context,
41
- editMode,
42
- items,
43
- layout,
19
+ this.getMemoForwardRefCallback = (refIndex) => {
20
+ if (!this._memoForwardedPluginRef[refIndex]) {
21
+ this._memoForwardedPluginRef[refIndex] = (pluginRef) => {
22
+ this.pluginsRefs[refIndex] = pluginRef;
23
+ };
24
+ }
25
+ return this._memoForwardedPluginRef[refIndex];
26
+ };
27
+ this.adjustWidgetLayout = (index, { needSetDefault }) => {
28
+ if (needSetDefault) {
29
+ const indexesOfItemsWithActiveAutoheight = Object.assign({}, this.state.indexesOfItemsWithActiveAutoheight);
30
+ delete indexesOfItemsWithActiveAutoheight[index];
31
+ this.setState({ indexesOfItemsWithActiveAutoheight });
32
+ }
33
+ else {
34
+ this.setState({
35
+ indexesOfItemsWithActiveAutoheight: Object.assign({}, this.state.indexesOfItemsWithActiveAutoheight, { [index]: true }),
44
36
  });
45
37
  }
46
- return children;
47
- })));
38
+ };
39
+ this.getMemoAdjustWidgetLayout = (index) => {
40
+ if (!this._memoAdjustWidgetLayout[index]) {
41
+ this._memoAdjustWidgetLayout[index] = this.adjustWidgetLayout.bind(this, index);
42
+ }
43
+ return this._memoAdjustWidgetLayout[index];
44
+ };
45
+ }
46
+ componentDidUpdate(prevProps, prevState) {
47
+ if (prevState.activeTabId !== this.context.config.id) {
48
+ this.setState({
49
+ activeTabId: this.context.config.id,
50
+ indexesOfItemsWithActiveAutoheight: {},
51
+ });
52
+ }
48
53
  }
49
54
  getSortedLayoutItems() {
50
55
  if (this.sortedLayoutItems && this.context.layout === this._memoLayout) {
@@ -52,36 +57,18 @@ class MobileLayout extends React.PureComponent {
52
57
  }
53
58
  this._memoLayout = this.context.layout;
54
59
  const hasOrderId = Boolean(this.context.config.items.find((item) => item.orderId));
55
- this.sortedLayoutItems = groupBy(getSortedConfigItems(this.context.config, hasOrderId), (item) => item.parent || DEFAULT_GROUP);
60
+ this.sortedLayoutItems = getSortedConfigItems(this.context.config, hasOrderId);
56
61
  return this.sortedLayoutItems;
57
62
  }
58
- getMemoForwardRefCallback(refIndex) {
59
- if (!this._memoForwardedPluginRef[refIndex]) {
60
- this._memoForwardedPluginRef[refIndex] = (pluginRef) => {
61
- this.pluginsRefs[refIndex] = pluginRef;
62
- };
63
- }
64
- return this._memoForwardedPluginRef[refIndex];
65
- }
66
- adjustWidgetLayout(id, { needSetDefault }) {
67
- if (needSetDefault) {
68
- const indexesOfItemsWithActiveAutoheight = Object.assign({}, this.state.itemsWithActiveAutoheight);
69
- delete indexesOfItemsWithActiveAutoheight[id];
70
- this.setState({ itemsWithActiveAutoheight: indexesOfItemsWithActiveAutoheight });
71
- }
72
- else {
73
- this.setState({
74
- itemsWithActiveAutoheight: Object.assign({}, this.state.itemsWithActiveAutoheight, {
75
- [id]: true,
76
- }),
77
- });
78
- }
79
- }
80
- getMemoAdjustWidgetLayout(id) {
81
- if (!this._memoAdjustWidgetLayout[id]) {
82
- this._memoAdjustWidgetLayout[id] = this.adjustWidgetLayout.bind(this, id);
83
- }
84
- return this._memoAdjustWidgetLayout[id];
63
+ render() {
64
+ const { config, layout } = this.context;
65
+ this.pluginsRefs.length = config.items.length;
66
+ const sortedItems = this.getSortedLayoutItems();
67
+ return (React.createElement("div", { className: b() }, sortedItems.map((item, index) => {
68
+ const isItemWithActiveAutoheight = index in this.state.indexesOfItemsWithActiveAutoheight;
69
+ return (React.createElement("div", { className: b('item', { autoheight: isItemWithActiveAutoheight }), key: item.id },
70
+ React.createElement(Item, { id: item.id, item: item, layout: layout, shouldItemUpdate: false, adjustWidgetLayout: this.getMemoAdjustWidgetLayout(index), forwardedPluginRef: this.getMemoForwardRefCallback(index), onMountChange: this.onMountChange, onItemMountChange: this.context.onItemMountChange, onItemRender: this.context.onItemRender })));
71
+ })));
85
72
  }
86
73
  }
87
74
  MobileLayout.contextType = DashKitContext;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ButtonSize, ButtonView, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { OverlayControlsCtxShape } from '../../context';
4
- import { type ConfigItem, type ItemParams, type ItemState, type PluginBase } from '../../shared';
3
+ import { type ConfigItem, type ConfigLayout, type ItemState, type ItemsStateAndParamsBase, type PluginBase, type StringParams } from '../../shared';
4
+ import { MenuItem } from '../../typings';
5
5
  import './OverlayControls.css';
6
6
  export declare enum OverlayControlsPosition {
7
7
  TopRight = "top_right",
@@ -25,7 +25,7 @@ export interface OverlayCustomControlItem {
25
25
  title?: string;
26
26
  icon?: MenuItemProps['icon'];
27
27
  iconSize?: number | string;
28
- handler?: (item: ConfigItem, params: ItemParams, state: ItemState) => void;
28
+ handler?: (item: ConfigItem, params: StringParams, state: ItemState) => void;
29
29
  visible?: (item: ConfigItem) => boolean;
30
30
  className?: string;
31
31
  qa?: string;
@@ -51,9 +51,21 @@ type PreparedCopyItemOptionsArg = Pick<ConfigItem, 'data' | 'type' | 'defaults'
51
51
  export type PreparedCopyItemOptions<C extends object = {}> = PreparedCopyItemOptionsArg & {
52
52
  copyContext?: C;
53
53
  };
54
+ export interface OverlayControlsCtxShape {
55
+ overlayControls?: Record<string, OverlayControlItem[]>;
56
+ context: Record<string, any>;
57
+ menu: MenuItem[];
58
+ itemsStateAndParams: ItemsStateAndParamsBase;
59
+ itemsParams: Record<string, StringParams>;
60
+ editItem: (item: ConfigItem) => void;
61
+ removeItem: (id: string) => void;
62
+ getLayoutItem: (id: string) => ConfigLayout | void;
63
+ getPreparedCopyItemOptions?: (options: PreparedCopyItemOptions) => PreparedCopyItemOptions;
64
+ onCopyFulfill?: (error: null | Error, data?: PreparedCopyItemOptions) => void;
65
+ }
54
66
  type OverlayControlsCtx = React.Context<OverlayControlsCtxShape>;
55
67
  declare class OverlayControls extends React.Component<OverlayControlsProps> {
56
- static contextType: React.Context<void | OverlayControlsCtxShape>;
68
+ static contextType: React.Context<any>;
57
69
  static defaultProps: OverlayControlsDefaultProps;
58
70
  context: React.ContextType<OverlayControlsCtx>;
59
71
  render(): JSX.Element;