@gravity-ui/dashkit 8.22.1 → 8.24.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 (77) hide show
  1. package/build/cjs/components/DashKit/DashKit.d.ts +14 -12
  2. package/build/cjs/components/DashKit/DashKit.js +2 -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 +1 -1
  7. package/build/cjs/components/GridLayout/GridLayout.js +3 -2
  8. package/build/cjs/components/Item/Item.d.ts +2 -1
  9. package/build/cjs/components/MobileLayout/MobileLayout.d.ts +28 -21
  10. package/build/cjs/components/MobileLayout/MobileLayout.js +60 -47
  11. package/build/cjs/components/OverlayControls/OverlayControls.d.ts +4 -16
  12. package/build/cjs/components/OverlayControls/OverlayControls.js +8 -9
  13. package/build/cjs/context/DashKitContext.d.ts +30 -3
  14. package/build/cjs/context/DashKitContext.js +2 -6
  15. package/build/cjs/context/DashKitDnDContext.d.ts +10 -0
  16. package/build/cjs/context/DashKitDnDContext.js +6 -0
  17. package/build/cjs/context/DashkitOverlayControlsContext.d.ts +13 -0
  18. package/build/cjs/context/DashkitOverlayControlsContext.js +6 -0
  19. package/build/cjs/context/index.d.ts +3 -0
  20. package/build/cjs/context/index.js +6 -0
  21. package/build/cjs/hocs/prepareItem.d.ts +2 -1
  22. package/build/cjs/hocs/prepareItem.js +2 -2
  23. package/build/cjs/hocs/withContext.js +23 -20
  24. package/build/cjs/hooks/useDnDItemProps.js +2 -2
  25. package/build/cjs/plugins/Title/Title.d.ts +3 -5
  26. package/build/cjs/plugins/Title/Title.js +17 -11
  27. package/build/cjs/plugins/Title/constants.d.ts +3 -0
  28. package/build/cjs/plugins/Title/constants.js +26 -0
  29. package/build/cjs/plugins/Title/index.d.ts +2 -0
  30. package/build/cjs/plugins/Title/index.js +3 -1
  31. package/build/cjs/plugins/Title/types.d.ts +5 -0
  32. package/build/cjs/plugins/Title/types.js +2 -0
  33. package/build/cjs/plugins/Title/utils.d.ts +2 -0
  34. package/build/cjs/plugins/Title/utils.js +7 -0
  35. package/build/cjs/shared/modules/helpers.d.ts +1 -1
  36. package/build/cjs/shared/modules/helpers.js +1 -1
  37. package/build/cjs/shared/types/state-and-params.d.ts +2 -1
  38. package/build/cjs/typings/config.d.ts +1 -0
  39. package/build/esm/components/DashKit/DashKit.d.ts +14 -12
  40. package/build/esm/components/DashKit/DashKit.js +1 -1
  41. package/build/esm/components/DashKitDnDWrapper/DashKitDnDWrapper.js +1 -1
  42. package/build/esm/components/DashKitView/DashKitView.js +1 -1
  43. package/build/esm/components/GridItem/GridItem.js +1 -1
  44. package/build/esm/components/GridLayout/GridLayout.d.ts +1 -1
  45. package/build/esm/components/GridLayout/GridLayout.js +2 -1
  46. package/build/esm/components/Item/Item.d.ts +2 -1
  47. package/build/esm/components/MobileLayout/MobileLayout.d.ts +29 -21
  48. package/build/esm/components/MobileLayout/MobileLayout.js +59 -46
  49. package/build/esm/components/OverlayControls/OverlayControls.d.ts +4 -16
  50. package/build/esm/components/OverlayControls/OverlayControls.js +7 -8
  51. package/build/esm/context/DashKitContext.d.ts +30 -3
  52. package/build/esm/context/DashKitContext.js +2 -4
  53. package/build/esm/context/DashKitDnDContext.d.ts +10 -0
  54. package/build/esm/context/DashKitDnDContext.js +2 -0
  55. package/build/esm/context/DashkitOverlayControlsContext.d.ts +13 -0
  56. package/build/esm/context/DashkitOverlayControlsContext.js +2 -0
  57. package/build/esm/context/index.d.ts +3 -0
  58. package/build/esm/context/index.js +3 -0
  59. package/build/esm/hocs/prepareItem.d.ts +2 -1
  60. package/build/esm/hocs/prepareItem.js +1 -1
  61. package/build/esm/hocs/withContext.js +20 -17
  62. package/build/esm/hooks/useDnDItemProps.js +1 -1
  63. package/build/esm/plugins/Title/Title.d.ts +3 -5
  64. package/build/esm/plugins/Title/Title.js +16 -9
  65. package/build/esm/plugins/Title/constants.d.ts +3 -0
  66. package/build/esm/plugins/Title/constants.js +23 -0
  67. package/build/esm/plugins/Title/index.d.ts +2 -0
  68. package/build/esm/plugins/Title/index.js +1 -0
  69. package/build/esm/plugins/Title/types.d.ts +5 -0
  70. package/build/esm/plugins/Title/types.js +1 -0
  71. package/build/esm/plugins/Title/utils.d.ts +2 -0
  72. package/build/esm/plugins/Title/utils.js +3 -0
  73. package/build/esm/shared/modules/helpers.d.ts +1 -1
  74. package/build/esm/shared/modules/helpers.js +1 -1
  75. package/build/esm/shared/types/state-and-params.d.ts +2 -1
  76. package/build/esm/typings/config.d.ts +1 -0
  77. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ButtonSize, ButtonView, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { type ConfigItem, type ConfigLayout, type ItemState, type ItemsStateAndParamsBase, type PluginBase, type StringParams } from '../../shared';
4
- import { MenuItem } from '../../typings';
3
+ import { OverlayControlsCtxShape } from '../../context';
4
+ import { type ConfigItem, type ItemParams, type ItemState, type PluginBase } from '../../shared';
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: StringParams, state: ItemState) => void;
28
+ handler?: (item: ConfigItem, params: ItemParams, state: ItemState) => void;
29
29
  visible?: (item: ConfigItem) => boolean;
30
30
  className?: string;
31
31
  qa?: string;
@@ -51,21 +51,9 @@ 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
- }
66
54
  type OverlayControlsCtx = React.Context<OverlayControlsCtxShape>;
67
55
  declare class OverlayControls extends React.Component<OverlayControlsProps> {
68
- static contextType: React.Context<any>;
56
+ static contextType: React.Context<void | OverlayControlsCtxShape>;
69
57
  static defaultProps: OverlayControlsDefaultProps;
70
58
  context: React.ContextType<OverlayControlsCtx>;
71
59
  render(): JSX.Element;
@@ -3,7 +3,7 @@ import { Ellipsis, Gear, Xmark } from '@gravity-ui/icons';
3
3
  import { Button, DropdownMenu, Icon, } from '@gravity-ui/uikit';
4
4
  import noop from 'lodash/noop';
5
5
  import { COPIED_WIDGET_STORE_KEY, DRAGGABLE_CANCEL_CLASS_NAME, MenuItems, OVERLAY_CONTROLS_CLASS_NAME, OVERLAY_ICON_SIZE, } from '../../constants';
6
- import { DashkitOvelayControlsContext } from '../../context/DashKitContext';
6
+ import { DashkitOvelayControlsContext } from '../../context';
7
7
  import { i18n } from '../../i18n';
8
8
  import { isItemWithTabs, resolveItemInnerId, } from '../../shared';
9
9
  import { cn } from '../../utils/cn';
@@ -119,9 +119,9 @@ class OverlayControls extends React.Component {
119
119
  (_l = (_k = this.props).onItemClick) === null || _l === void 0 ? void 0 : _l.call(_k);
120
120
  };
121
121
  this.onEditItem = () => {
122
- var _a, _b;
123
- this.context.editItem(this.props.configItem);
124
- (_b = (_a = this.props).onItemClick) === null || _b === void 0 ? void 0 : _b.call(_a);
122
+ var _a, _b, _c, _d;
123
+ (_b = (_a = this.context).editItem) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.configItem);
124
+ (_d = (_c = this.props).onItemClick) === null || _d === void 0 ? void 0 : _d.call(_c);
125
125
  };
126
126
  this.onRemoveItem = () => {
127
127
  var _a, _b;
@@ -192,13 +192,12 @@ class OverlayControls extends React.Component {
192
192
  return menu === null || menu === void 0 ? void 0 : menu.every((item) => Object.values(MenuItems).includes(String(item)));
193
193
  }
194
194
  renderDropdownMenu(isOnlyOneItem) {
195
- var _a;
196
195
  const { view, size, onItemClick } = this.props;
197
- const { menu: contextMenu, itemsParams, itemsStateAndParams } = this.context;
196
+ const { menu: contextMenu, itemsParams, itemsState } = this.context;
198
197
  const configItem = this.props.configItem;
199
198
  const itemParams = itemsParams[configItem.id];
200
- const itemState = ((_a = itemsStateAndParams[configItem.id]) === null || _a === void 0 ? void 0 : _a.state) || {};
201
- const menu = (contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.length) > 0 ? contextMenu : DEFAULT_DROPDOWN_MENU;
199
+ const itemState = (itemsState === null || itemsState === void 0 ? void 0 : itemsState[configItem.id]) || {};
200
+ const menu = contextMenu && contextMenu.length > 0 ? contextMenu : DEFAULT_DROPDOWN_MENU;
202
201
  const isDefaultMenu = this.isDefaultMenu(menu);
203
202
  const items = isDefaultMenu
204
203
  ? (menu || []).reduce((memo, name) => {
@@ -1,4 +1,31 @@
1
- export const DashKitContext: React.Context<any>;
2
- export const DashkitOvelayControlsContext: React.Context<any>;
3
- export const DashKitDnDContext: React.Context<any>;
1
+ /// <reference types="react-grid-layout" />
4
2
  import React from 'react';
3
+ import type { RegisterManager } from '..//utils';
4
+ import type { DashKitProps } from '../components/DashKit';
5
+ import type { ConfigItem, ConfigLayout, ItemParams, ItemState, ItemStateAndParams, ItemStateAndParamsChangeOptions } from '../shared';
6
+ type DashkitPropsPassedToCtx = Pick<DashKitProps, 'config' | 'groups' | 'context' | 'noOverlay' | 'focusable' | 'globalParams' | 'editMode' | 'settings' | 'onItemMountChange' | 'onItemRender' | 'draggableHandleClassName' | 'onDragStart' | 'onDrag' | 'onDragStop' | 'onResizeStart' | 'onResize' | 'onResizeStop'>;
7
+ type PluginType = string;
8
+ export type DashKitCtxShape = DashkitPropsPassedToCtx & {
9
+ registerManager: RegisterManager;
10
+ forwardedMetaRef: React.ForwardedRef<any>;
11
+ layout: ConfigLayout[];
12
+ temporaryLayout: ConfigLayout[] | null;
13
+ memorizeOriginalLayout: (widgetId: string, preAutoHeightLayout: ConfigLayout, postAutoHeightLayout: ConfigLayout) => void;
14
+ revertToOriginalLayout: (widgetId: string) => void;
15
+ itemsState?: Record<string, ItemState>;
16
+ itemsParams: Record<string, ItemParams>;
17
+ onItemStateAndParamsChange: (id: string, stateAndParams: ItemStateAndParams, options: ItemStateAndParamsChangeOptions) => void;
18
+ getItemsMeta: (pluginsRefs: Array<React.RefObject<any>>) => Array<Promise<any>>;
19
+ reloadItems: (pluginsRefs: Array<React.RefObject<any>>, data: {
20
+ silentLoading: boolean;
21
+ noVeil: boolean;
22
+ }) => void;
23
+ onDrop: (newLayout: ConfigLayout, item: ConfigItem) => void;
24
+ onDropDragOver: (e: DragEvent | MouseEvent, group: string | void, gridProps: Partial<ReactGridLayout.ReactGridLayoutProps>, groupLayout: ConfigLayout[], sharedItem: (Partial<ConfigLayout> & {
25
+ type: PluginType;
26
+ }) | void) => void | boolean;
27
+ outerDnDEnable: boolean;
28
+ dragOverPlugin: null | PluginType;
29
+ };
30
+ declare const DashKitContext: React.Context<DashKitCtxShape>;
31
+ export { DashKitContext };
@@ -1,5 +1,3 @@
1
1
  import React from 'react';
2
- const DashKitContext = React.createContext();
3
- const DashkitOvelayControlsContext = React.createContext();
4
- const DashKitDnDContext = React.createContext();
5
- export { DashKitContext, DashkitOvelayControlsContext, DashKitDnDContext };
2
+ const DashKitContext = React.createContext({});
3
+ export { DashKitContext };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { DraggedOverItem, ItemDragProps } from '../shared/types';
3
+ export type DashKitDnDCtxShape = {
4
+ dragProps: ItemDragProps | null;
5
+ dragImagePreview: HTMLImageElement;
6
+ onDragStart: (e: React.DragEvent<Element>, itemDragProps: ItemDragProps) => void;
7
+ onDragEnd: (e: React.DragEvent<Element>) => void;
8
+ onDropDragOver?: (draggedItem: DraggedOverItem, sharedItem: DraggedOverItem | null) => void | boolean;
9
+ };
10
+ export declare const DashKitDnDContext: React.Context<void | DashKitDnDCtxShape>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export const DashKitDnDContext = React.createContext(undefined);
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { DashKitProps } from '../components';
3
+ import type { ConfigLayout, ItemParams, ItemState } from '../shared';
4
+ import type { MenuItem } from '../typings';
5
+ export type OverlayControlsCtxShape = Pick<DashKitProps, 'context' | 'overlayControls' | 'itemsStateAndParams' | 'getPreparedCopyItemOptions' | 'onCopyFulfill'> & {
6
+ menu: DashKitProps['overlayMenuItems'] | MenuItem[];
7
+ itemsState?: Record<string, ItemState>;
8
+ itemsParams: Record<string, ItemParams>;
9
+ editItem: DashKitProps['onItemEdit'];
10
+ removeItem: (id: string) => void;
11
+ getLayoutItem: (id: string) => ConfigLayout | void;
12
+ };
13
+ export declare const DashkitOvelayControlsContext: React.Context<void | OverlayControlsCtxShape>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export const DashkitOvelayControlsContext = React.createContext(undefined);
@@ -0,0 +1,3 @@
1
+ export * from './DashKitContext';
2
+ export * from './DashkitOverlayControlsContext';
3
+ export * from './DashKitDnDContext';
@@ -0,0 +1,3 @@
1
+ export * from './DashKitContext';
2
+ export * from './DashkitOverlayControlsContext';
3
+ export * from './DashKitDnDContext';
@@ -66,6 +66,7 @@ export function prepareItem(Component: any): {
66
66
  onItemMountChange: PropTypes.Requireable<(...args: any[]) => any>;
67
67
  forwardedPluginRef: PropTypes.Requireable<any>;
68
68
  };
69
- contextType: React.Context<any>;
69
+ contextType: React.Context<import("../context").DashKitCtxShape>;
70
70
  };
71
71
  import React from 'react';
72
+ import PropTypes from 'prop-types';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import isEqual from 'lodash/isEqual';
3
3
  import PropTypes from 'prop-types';
4
- import { DashKitContext } from '../context/DashKitContext';
4
+ import { DashKitContext } from '../context';
5
5
  export function prepareItem(Component) {
6
6
  var _a;
7
7
  return _a = class PrepareItem extends React.Component {
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import isEqual from 'lodash/isEqual';
4
4
  import pick from 'lodash/pick';
5
5
  import { COMPACT_TYPE_HORIZONTAL_NOWRAP, DEFAULT_GROUP, DEFAULT_WIDGET_HEIGHT, DEFAULT_WIDGET_WIDTH, TEMPORARY_ITEM_ID, } from '../constants/common';
6
- import { DashKitContext, DashKitDnDContext, DashkitOvelayControlsContext, } from '../context/DashKitContext';
6
+ import { DashKitContext, DashKitDnDContext, DashkitOvelayControlsContext } from '../context';
7
7
  import { useDeepEqualMemo } from '../hooks/useDeepEqualMemo';
8
8
  import { getItemsParams, getItemsState } from '../shared';
9
9
  import { UpdateManager, resolveLayoutGroup } from '../utils';
@@ -283,6 +283,7 @@ function useMemoStateContext(props) {
283
283
  }
284
284
  return itemLayout;
285
285
  }, [
286
+ props.registerManager,
286
287
  resetTemporaryLayout,
287
288
  temporaryLayout,
288
289
  dragOverPlugin,
@@ -311,8 +312,6 @@ function useMemoStateContext(props) {
311
312
  });
312
313
  }, [dragPropsContext, onDropProp, setTemporaryLayout, resetTemporaryLayout]);
313
314
  const dashkitContextValue = React.useMemo(() => ({
314
- layout: resultLayout,
315
- temporaryLayout,
316
315
  config: props.config,
317
316
  groups: props.groups,
318
317
  context: props.context,
@@ -322,24 +321,26 @@ function useMemoStateContext(props) {
322
321
  globalParams: props.globalParams,
323
322
  editMode: props.editMode,
324
323
  settings: props.settings,
325
- itemsState,
326
- itemsParams,
327
- registerManager: props.registerManager,
328
- onItemStateAndParamsChange,
329
- onDrop,
330
- onDropDragOver,
331
324
  onItemMountChange: props.onItemMountChange,
332
325
  onItemRender: props.onItemRender,
326
+ draggableHandleClassName: props.draggableHandleClassName,
327
+ registerManager: props.registerManager,
328
+ forwardedMetaRef: props.forwardedMetaRef,
329
+ layout: resultLayout,
330
+ temporaryLayout,
333
331
  layoutChange: onLayoutChange,
334
- getItemsMeta,
335
- reloadItems,
336
332
  memorizeOriginalLayout,
337
333
  revertToOriginalLayout,
338
- forwardedMetaRef: props.forwardedMetaRef,
339
- draggableHandleClassName: props.draggableHandleClassName,
334
+ itemsState,
335
+ itemsParams,
336
+ onItemStateAndParamsChange,
337
+ getItemsMeta,
338
+ reloadItems,
339
+ onDrop,
340
+ onDropDragOver,
340
341
  outerDnDEnable,
341
342
  dragOverPlugin,
342
- /* default bypassing handlers */
343
+ /* default handlers bypass */
343
344
  onDragStart: props.onDragStart,
344
345
  onDrag: props.onDrag,
345
346
  onDragStop: props.onDragStop,
@@ -385,14 +386,15 @@ function useMemoStateContext(props) {
385
386
  const controlsContextValue = React.useMemo(() => ({
386
387
  overlayControls: props.overlayControls,
387
388
  context: props.context,
388
- menu: overlayMenuItems,
389
389
  itemsStateAndParams: props.itemsStateAndParams,
390
+ itemsState,
390
391
  itemsParams,
392
+ getPreparedCopyItemOptions: props.getPreparedCopyItemOptions,
393
+ onCopyFulfill: props.onCopyFulfill,
394
+ menu: overlayMenuItems,
391
395
  editItem: props.onItemEdit,
392
396
  removeItem: onItemRemove,
393
397
  getLayoutItem: getLayoutItem,
394
- getPreparedCopyItemOptions: props.getPreparedCopyItemOptions,
395
- onCopyFulfill: props.onCopyFulfill,
396
398
  }), [
397
399
  props.overlayControls,
398
400
  props.context,
@@ -401,6 +403,7 @@ function useMemoStateContext(props) {
401
403
  props.getPreparedCopyItemOptions,
402
404
  props.onCopyFulfill,
403
405
  overlayMenuItems,
406
+ itemsState,
404
407
  itemsParams,
405
408
  onItemRemove,
406
409
  getLayoutItem,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { DashKitDnDContext } from '../context/DashKitContext';
2
+ import { DashKitDnDContext } from '../context';
3
3
  export const useDnDItemProps = (item) => {
4
4
  const dragContext = React.useContext(DashKitDnDContext);
5
5
  const onDragStart = React.useCallback((e) => {
@@ -1,16 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Plugin, PluginWidgetProps } from '../../typings';
3
+ import type { PluginTitleSize, TitleFontParams } from './types';
3
4
  import './Title.css';
4
- export type PluginTitleSize = 'xl' | 'l' | 'm' | 's' | 'xs';
5
5
  export interface PluginTitleProps extends PluginWidgetProps {
6
6
  data: {
7
- size: PluginTitleSize;
7
+ size: PluginTitleSize | TitleFontParams;
8
8
  text: string;
9
9
  showInTOC: boolean;
10
10
  } & PluginWidgetProps['data'];
11
11
  }
12
- export declare class PluginTitle extends React.Component<PluginTitleProps> {
13
- render(): JSX.Element;
14
- }
12
+ export declare const PluginTitle: React.ForwardRefExoticComponent<PluginTitleProps & React.RefAttributes<HTMLDivElement>>;
15
13
  declare const plugin: Plugin<PluginTitleProps>;
16
14
  export default plugin;
@@ -1,17 +1,24 @@
1
1
  import React from 'react';
2
2
  import { cn } from '../../utils/cn';
3
3
  import { PLUGIN_ROOT_ATTR_NAME } from '../constants';
4
+ import { RECCOMMENDED_LINE_HEIGHT_MULTIPLIER } from './constants';
5
+ import { isCustomSize } from './utils';
4
6
  import './Title.css';
5
7
  const b = cn('dashkit-plugin-title');
6
- export class PluginTitle extends React.Component {
7
- render() {
8
- const { data } = this.props;
9
- const text = data.text ? data.text : '';
10
- const size = data.size ? data.size : false;
11
- const id = data.showInTOC && text ? encodeURIComponent(text) : undefined;
12
- return (React.createElement("div", { id: id, className: b({ size }), [PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
13
- }
14
- }
8
+ export const PluginTitle = React.forwardRef(function PluginTitleForwardRef(props, ref) {
9
+ var _a, _b;
10
+ const { data } = props;
11
+ const text = data.text ? data.text : '';
12
+ const size = isCustomSize(data.size) ? false : data.size;
13
+ const styles = isCustomSize(data.size) && ((_a = data.size) === null || _a === void 0 ? void 0 : _a.fontSize)
14
+ ? {
15
+ fontSize: data.size.fontSize,
16
+ lineHeight: (_b = data.size.lineHeight) !== null && _b !== void 0 ? _b : RECCOMMENDED_LINE_HEIGHT_MULTIPLIER,
17
+ }
18
+ : undefined;
19
+ const id = data.showInTOC && text ? encodeURIComponent(text) : undefined;
20
+ return (React.createElement("div", { ref: ref, id: id, style: styles, className: b({ size }), [PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
21
+ });
15
22
  const plugin = {
16
23
  type: 'title',
17
24
  defaultLayout: { w: 36, h: 2 },
@@ -0,0 +1,3 @@
1
+ import { PluginTitleSize, TitleFontParams } from './types';
2
+ export declare const TITLE_DEFAULT_SIZES: Record<PluginTitleSize, TitleFontParams>;
3
+ export declare const RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = 1.25;
@@ -0,0 +1,23 @@
1
+ export const TITLE_DEFAULT_SIZES = {
2
+ xl: {
3
+ fontSize: '32px',
4
+ lineHeight: '40px',
5
+ },
6
+ l: {
7
+ fontSize: '24px',
8
+ lineHeight: '28px',
9
+ },
10
+ m: {
11
+ fontSize: '20px',
12
+ lineHeight: '24px',
13
+ },
14
+ s: {
15
+ fontSize: '17px',
16
+ lineHeight: '24px',
17
+ },
18
+ xs: {
19
+ fontSize: '15px',
20
+ lineHeight: '20px',
21
+ },
22
+ };
23
+ export const RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = 1.25;
@@ -1,2 +1,4 @@
1
1
  export * from './Title';
2
2
  export { default as pluginTitle } from './Title';
3
+ export { PluginTitleSize, TitleFontParams } from './types';
4
+ export { TITLE_DEFAULT_SIZES } from './constants';
@@ -1,2 +1,3 @@
1
1
  export * from './Title';
2
2
  export { default as pluginTitle } from './Title';
3
+ export { TITLE_DEFAULT_SIZES } from './constants';
@@ -0,0 +1,5 @@
1
+ export type PluginTitleSize = 'xl' | 'l' | 'm' | 's' | 'xs';
2
+ export interface TitleFontParams {
3
+ fontSize: string;
4
+ lineHeight?: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { PluginTitleSize, TitleFontParams } from './types';
2
+ export declare function isCustomSize(size: PluginTitleSize | TitleFontParams): size is TitleFontParams;
@@ -0,0 +1,3 @@
1
+ export function isCustomSize(size) {
2
+ return typeof size === 'object';
3
+ }
@@ -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)[];
@@ -108,7 +108,7 @@ export function formQueueData({ items, itemsStateAndParams, }) {
108
108
  export function resolveItemInnerId({ item, itemsStateAndParams, }) {
109
109
  var _a, _b;
110
110
  const { id } = item;
111
- const stateTabId = (_b = (_a = itemsStateAndParams[id]) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.tabId;
111
+ 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;
112
112
  const { tabs } = item.data;
113
113
  if (stateTabId && tabs.some((tab) => tab.id === stateTabId)) {
114
114
  return stateTabId;
@@ -3,6 +3,7 @@ import { StringParams } from './common';
3
3
  export interface ItemState {
4
4
  [key: string]: any;
5
5
  }
6
+ export type ItemParams = StringParams | Record<string, StringParams>;
6
7
  export interface QueueItem {
7
8
  id: string;
8
9
  tabId?: string;
@@ -16,7 +17,7 @@ export type StateAndParamsMeta = {
16
17
  [META_KEY]: StateAndParamsMetaData;
17
18
  };
18
19
  export type ItemStateAndParams = {
19
- params?: StringParams | Record<string, StringParams>;
20
+ params?: ItemParams;
20
21
  state?: ItemState;
21
22
  };
22
23
  export type ItemStateAndParamsChangeOptions = {
@@ -28,6 +28,7 @@ export type AddNewItemOptions = SetItemOptions & {
28
28
  export interface DashkitGroupRenderProps {
29
29
  config: Config;
30
30
  editMode: boolean;
31
+ isMobile: boolean;
31
32
  items: ConfigItem[];
32
33
  layout: ConfigLayout[];
33
34
  context: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "8.22.1",
3
+ "version": "8.24.0",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {