@gravity-ui/dashkit 8.23.0 → 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/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/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/package.json +1 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Plugin, PluginWidgetProps } from '../../typings';
|
|
3
|
-
|
|
3
|
+
import type { PluginTitleSize, TitleFontParams } from './types';
|
|
4
4
|
export interface PluginTitleProps extends PluginWidgetProps {
|
|
5
5
|
data: {
|
|
6
|
-
size: PluginTitleSize;
|
|
6
|
+
size: PluginTitleSize | TitleFontParams;
|
|
7
7
|
text: string;
|
|
8
8
|
showInTOC: boolean;
|
|
9
9
|
} & PluginWidgetProps['data'];
|
|
10
10
|
}
|
|
11
|
-
export declare
|
|
12
|
-
render(): JSX.Element;
|
|
13
|
-
}
|
|
11
|
+
export declare const PluginTitle: React.ForwardRefExoticComponent<PluginTitleProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
12
|
declare const plugin: Plugin<PluginTitleProps>;
|
|
15
13
|
export default plugin;
|
|
@@ -5,22 +5,28 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const cn_1 = require("../../utils/cn");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
|
+
const constants_2 = require("./constants");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
8
10
|
const b = (0, cn_1.cn)('dashkit-plugin-title');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
exports.PluginTitle = react_1.default.forwardRef(function PluginTitleForwardRef(props, ref) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const { data } = props;
|
|
14
|
+
const text = data.text ? data.text : '';
|
|
15
|
+
const size = (0, utils_1.isCustomSize)(data.size) ? false : data.size;
|
|
16
|
+
const styles = (0, utils_1.isCustomSize)(data.size) && ((_a = data.size) === null || _a === void 0 ? void 0 : _a.fontSize)
|
|
17
|
+
? {
|
|
18
|
+
fontSize: data.size.fontSize,
|
|
19
|
+
lineHeight: (_b = data.size.lineHeight) !== null && _b !== void 0 ? _b : constants_2.RECCOMMENDED_LINE_HEIGHT_MULTIPLIER,
|
|
20
|
+
}
|
|
21
|
+
: undefined;
|
|
22
|
+
const id = data.showInTOC && text ? encodeURIComponent(text) : undefined;
|
|
23
|
+
return (react_1.default.createElement("div", { ref: ref, id: id, style: styles, className: b({ size }), [constants_1.PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
|
|
24
|
+
});
|
|
19
25
|
const plugin = {
|
|
20
26
|
type: 'title',
|
|
21
27
|
defaultLayout: { w: 36, h: 2 },
|
|
22
28
|
renderer(props, forwardedRef) {
|
|
23
|
-
return react_1.default.createElement(PluginTitle, Object.assign({}, props, { ref: forwardedRef }));
|
|
29
|
+
return react_1.default.createElement(exports.PluginTitle, Object.assign({}, props, { ref: forwardedRef }));
|
|
24
30
|
},
|
|
25
31
|
};
|
|
26
32
|
exports.default = plugin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = exports.TITLE_DEFAULT_SIZES = void 0;
|
|
4
|
+
exports.TITLE_DEFAULT_SIZES = {
|
|
5
|
+
xl: {
|
|
6
|
+
fontSize: '32px',
|
|
7
|
+
lineHeight: '40px',
|
|
8
|
+
},
|
|
9
|
+
l: {
|
|
10
|
+
fontSize: '24px',
|
|
11
|
+
lineHeight: '28px',
|
|
12
|
+
},
|
|
13
|
+
m: {
|
|
14
|
+
fontSize: '20px',
|
|
15
|
+
lineHeight: '24px',
|
|
16
|
+
},
|
|
17
|
+
s: {
|
|
18
|
+
fontSize: '17px',
|
|
19
|
+
lineHeight: '24px',
|
|
20
|
+
},
|
|
21
|
+
xs: {
|
|
22
|
+
fontSize: '15px',
|
|
23
|
+
lineHeight: '20px',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
exports.RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = 1.25;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginTitle = void 0;
|
|
3
|
+
exports.TITLE_DEFAULT_SIZES = exports.pluginTitle = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./Title"), exports);
|
|
6
6
|
var Title_1 = require("./Title");
|
|
7
7
|
Object.defineProperty(exports, "pluginTitle", { enumerable: true, get: function () { return tslib_1.__importDefault(Title_1).default; } });
|
|
8
|
+
var constants_1 = require("./constants");
|
|
9
|
+
Object.defineProperty(exports, "TITLE_DEFAULT_SIZES", { enumerable: true, get: function () { return constants_1.TITLE_DEFAULT_SIZES; } });
|
|
@@ -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 {};
|