@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.
- package/build/cjs/components/DashKit/DashKit.d.ts +14 -12
- package/build/cjs/components/DashKit/DashKit.js +2 -2
- package/build/cjs/components/DashKitDnDWrapper/DashKitDnDWrapper.js +2 -2
- package/build/cjs/components/DashKitView/DashKitView.js +2 -2
- package/build/cjs/components/GridItem/GridItem.js +2 -2
- package/build/cjs/components/GridLayout/GridLayout.d.ts +1 -1
- package/build/cjs/components/GridLayout/GridLayout.js +3 -2
- package/build/cjs/components/Item/Item.d.ts +2 -1
- package/build/cjs/components/MobileLayout/MobileLayout.d.ts +28 -21
- package/build/cjs/components/MobileLayout/MobileLayout.js +60 -47
- package/build/cjs/components/OverlayControls/OverlayControls.d.ts +4 -16
- package/build/cjs/components/OverlayControls/OverlayControls.js +8 -9
- package/build/cjs/context/DashKitContext.d.ts +30 -3
- package/build/cjs/context/DashKitContext.js +2 -6
- package/build/cjs/context/DashKitDnDContext.d.ts +10 -0
- package/build/cjs/context/DashKitDnDContext.js +6 -0
- package/build/cjs/context/DashkitOverlayControlsContext.d.ts +13 -0
- package/build/cjs/context/DashkitOverlayControlsContext.js +6 -0
- package/build/cjs/context/index.d.ts +3 -0
- package/build/cjs/context/index.js +6 -0
- package/build/cjs/hocs/prepareItem.d.ts +2 -1
- package/build/cjs/hocs/prepareItem.js +2 -2
- package/build/cjs/hocs/withContext.js +23 -20
- package/build/cjs/hooks/useDnDItemProps.js +2 -2
- package/build/cjs/plugins/Title/Title.d.ts +3 -5
- package/build/cjs/plugins/Title/Title.js +17 -11
- package/build/cjs/plugins/Title/constants.d.ts +3 -0
- package/build/cjs/plugins/Title/constants.js +26 -0
- package/build/cjs/plugins/Title/index.d.ts +2 -0
- package/build/cjs/plugins/Title/index.js +3 -1
- package/build/cjs/plugins/Title/types.d.ts +5 -0
- package/build/cjs/plugins/Title/types.js +2 -0
- package/build/cjs/plugins/Title/utils.d.ts +2 -0
- package/build/cjs/plugins/Title/utils.js +7 -0
- package/build/cjs/shared/modules/helpers.d.ts +1 -1
- package/build/cjs/shared/modules/helpers.js +1 -1
- package/build/cjs/shared/types/state-and-params.d.ts +2 -1
- package/build/cjs/typings/config.d.ts +1 -0
- package/build/esm/components/DashKit/DashKit.d.ts +14 -12
- package/build/esm/components/DashKit/DashKit.js +1 -1
- package/build/esm/components/DashKitDnDWrapper/DashKitDnDWrapper.js +1 -1
- package/build/esm/components/DashKitView/DashKitView.js +1 -1
- package/build/esm/components/GridItem/GridItem.js +1 -1
- package/build/esm/components/GridLayout/GridLayout.d.ts +1 -1
- package/build/esm/components/GridLayout/GridLayout.js +2 -1
- package/build/esm/components/Item/Item.d.ts +2 -1
- package/build/esm/components/MobileLayout/MobileLayout.d.ts +29 -21
- package/build/esm/components/MobileLayout/MobileLayout.js +59 -46
- package/build/esm/components/OverlayControls/OverlayControls.d.ts +4 -16
- package/build/esm/components/OverlayControls/OverlayControls.js +7 -8
- package/build/esm/context/DashKitContext.d.ts +30 -3
- package/build/esm/context/DashKitContext.js +2 -4
- package/build/esm/context/DashKitDnDContext.d.ts +10 -0
- package/build/esm/context/DashKitDnDContext.js +2 -0
- package/build/esm/context/DashkitOverlayControlsContext.d.ts +13 -0
- package/build/esm/context/DashkitOverlayControlsContext.js +2 -0
- package/build/esm/context/index.d.ts +3 -0
- package/build/esm/context/index.js +3 -0
- package/build/esm/hocs/prepareItem.d.ts +2 -1
- package/build/esm/hocs/prepareItem.js +1 -1
- package/build/esm/hocs/withContext.js +20 -17
- package/build/esm/hooks/useDnDItemProps.js +1 -1
- package/build/esm/plugins/Title/Title.d.ts +3 -5
- package/build/esm/plugins/Title/Title.js +16 -9
- package/build/esm/plugins/Title/constants.d.ts +3 -0
- package/build/esm/plugins/Title/constants.js +23 -0
- package/build/esm/plugins/Title/index.d.ts +2 -0
- package/build/esm/plugins/Title/index.js +1 -0
- package/build/esm/plugins/Title/types.d.ts +5 -0
- package/build/esm/plugins/Title/types.js +1 -0
- package/build/esm/plugins/Title/utils.d.ts +2 -0
- package/build/esm/plugins/Title/utils.js +3 -0
- package/build/esm/shared/modules/helpers.d.ts +1 -1
- package/build/esm/shared/modules/helpers.js +1 -1
- package/build/esm/shared/types/state-and-params.d.ts +2 -1
- package/build/esm/typings/config.d.ts +1 -0
- 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 {
|
|
4
|
-
import {
|
|
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:
|
|
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<
|
|
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
|
|
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
|
-
(
|
|
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,
|
|
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 = (
|
|
201
|
-
const 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
|
-
|
|
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
|
-
|
|
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,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>;
|
|
@@ -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<
|
|
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
|
|
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
|
|
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
|
-
|
|
339
|
-
|
|
334
|
+
itemsState,
|
|
335
|
+
itemsParams,
|
|
336
|
+
onItemStateAndParamsChange,
|
|
337
|
+
getItemsMeta,
|
|
338
|
+
reloadItems,
|
|
339
|
+
onDrop,
|
|
340
|
+
onDropDragOver,
|
|
340
341
|
outerDnDEnable,
|
|
341
342
|
dragOverPlugin,
|
|
342
|
-
/* default
|
|
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
|
|
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
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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,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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
|
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?:
|
|
20
|
+
params?: ItemParams;
|
|
20
21
|
state?: ItemState;
|
|
21
22
|
};
|
|
22
23
|
export type ItemStateAndParamsChangeOptions = {
|