@doyourjob/gravity-ui-page-constructor 5.31.61 → 5.31.63
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/README.md +1 -1
- package/build/cjs/blocks/Reports/Reports.css +19 -0
- package/build/cjs/blocks/Reports/Reports.d.ts +3 -0
- package/build/cjs/blocks/Reports/Reports.js +46 -0
- package/build/cjs/blocks/Reports/ReportsItem/ReportsItem.css +49 -0
- package/build/cjs/blocks/Reports/ReportsItem/ReportsItem.d.ts +3 -0
- package/build/cjs/blocks/Reports/ReportsItem/ReportsItem.js +18 -0
- package/build/cjs/blocks/Reports/schema.d.ts +50 -0
- package/build/cjs/blocks/Reports/schema.js +24 -0
- package/build/cjs/blocks/index.d.ts +1 -0
- package/build/cjs/blocks/index.js +3 -1
- package/build/cjs/components/Paginator/Paginator.css +61 -0
- package/build/cjs/components/Paginator/Paginator.d.ts +3 -0
- package/build/cjs/components/Paginator/Paginator.js +87 -0
- package/build/cjs/components/Paginator/components/NavigationButton.d.ts +6 -0
- package/build/cjs/components/Paginator/components/NavigationButton.js +22 -0
- package/build/cjs/components/Paginator/components/PaginatorItem.d.ts +2 -0
- package/build/cjs/components/Paginator/components/PaginatorItem.js +15 -0
- package/build/cjs/components/Paginator/i18n/en.json +4 -0
- package/build/cjs/components/Paginator/i18n/index.d.ts +1 -0
- package/build/cjs/components/Paginator/i18n/index.js +9 -0
- package/build/cjs/components/Paginator/i18n/ru.json +4 -0
- package/build/cjs/components/Paginator/types.d.ts +28 -0
- package/build/cjs/components/Paginator/types.js +8 -0
- package/build/cjs/components/Paginator/utils.d.ts +3 -0
- package/build/cjs/components/Paginator/utils.js +71 -0
- package/build/cjs/components/ReportFile/ReportFile.css +27 -0
- package/build/cjs/components/ReportFile/ReportFile.d.ts +3 -0
- package/build/cjs/components/ReportFile/ReportFile.js +10 -0
- package/build/cjs/components/Select/Select.css +22 -0
- package/build/cjs/components/Select/Select.d.ts +6 -0
- package/build/cjs/components/Select/Select.js +15 -0
- package/build/cjs/components/index.d.ts +3 -0
- package/build/cjs/components/index.js +7 -1
- package/build/cjs/constructor-items.d.ts +1 -0
- package/build/cjs/constructor-items.js +1 -0
- package/build/cjs/context/reportsContext/ReportsContext.d.ts +16 -0
- package/build/cjs/context/reportsContext/ReportsContext.js +6 -0
- package/build/cjs/context/reportsContext/index.d.ts +1 -0
- package/build/cjs/context/reportsContext/index.js +4 -0
- package/build/cjs/icons/ArrowLeftIcon.d.ts +2 -0
- package/build/cjs/icons/ArrowLeftIcon.js +9 -0
- package/build/cjs/icons/ArrowRightIcon.d.ts +2 -0
- package/build/cjs/icons/ArrowRightIcon.js +9 -0
- package/build/cjs/icons/index.d.ts +2 -0
- package/build/cjs/icons/index.js +2 -0
- package/build/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +1 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +20 -2
- package/build/cjs/models/constructor-items/blocks.js +1 -0
- package/build/cjs/models/constructor-items/common.d.ts +15 -0
- package/build/cjs/schema/constants.js +2 -1
- package/build/cjs/schema/validators/blocks.d.ts +1 -0
- package/build/cjs/schema/validators/blocks.js +1 -0
- package/build/esm/blocks/Reports/Reports.css +19 -0
- package/build/esm/blocks/Reports/Reports.d.ts +4 -0
- package/build/esm/blocks/Reports/Reports.js +42 -0
- package/build/esm/blocks/Reports/ReportsItem/ReportsItem.css +49 -0
- package/build/esm/blocks/Reports/ReportsItem/ReportsItem.d.ts +4 -0
- package/build/esm/blocks/Reports/ReportsItem/ReportsItem.js +14 -0
- package/build/esm/blocks/Reports/schema.d.ts +50 -0
- package/build/esm/blocks/Reports/schema.js +21 -0
- package/build/esm/blocks/index.d.ts +1 -0
- package/build/esm/blocks/index.js +1 -0
- package/build/esm/components/Paginator/Paginator.css +61 -0
- package/build/esm/components/Paginator/Paginator.d.ts +4 -0
- package/build/esm/components/Paginator/Paginator.js +84 -0
- package/build/esm/components/Paginator/components/NavigationButton.d.ts +6 -0
- package/build/esm/components/Paginator/components/NavigationButton.js +17 -0
- package/build/esm/components/Paginator/components/PaginatorItem.d.ts +2 -0
- package/build/esm/components/Paginator/components/PaginatorItem.js +10 -0
- package/build/esm/components/Paginator/i18n/en.json +4 -0
- package/build/esm/components/Paginator/i18n/index.d.ts +1 -0
- package/build/esm/components/Paginator/i18n/index.js +5 -0
- package/build/esm/components/Paginator/i18n/ru.json +4 -0
- package/build/esm/components/Paginator/types.d.ts +28 -0
- package/build/esm/components/Paginator/types.js +5 -0
- package/build/esm/components/Paginator/utils.d.ts +3 -0
- package/build/esm/components/Paginator/utils.js +66 -0
- package/build/esm/components/ReportFile/ReportFile.css +27 -0
- package/build/esm/components/ReportFile/ReportFile.d.ts +4 -0
- package/build/esm/components/ReportFile/ReportFile.js +6 -0
- package/build/esm/components/Select/Select.css +22 -0
- package/build/esm/components/Select/Select.d.ts +7 -0
- package/build/esm/components/Select/Select.js +11 -0
- package/build/esm/components/index.d.ts +3 -0
- package/build/esm/components/index.js +3 -0
- package/build/esm/constructor-items.d.ts +1 -0
- package/build/esm/constructor-items.js +2 -1
- package/build/esm/context/reportsContext/ReportsContext.d.ts +16 -0
- package/build/esm/context/reportsContext/ReportsContext.js +2 -0
- package/build/esm/context/reportsContext/index.d.ts +1 -0
- package/build/esm/context/reportsContext/index.js +1 -0
- package/build/esm/icons/ArrowLeftIcon.d.ts +2 -0
- package/build/esm/icons/ArrowLeftIcon.js +4 -0
- package/build/esm/icons/ArrowRightIcon.d.ts +2 -0
- package/build/esm/icons/ArrowRightIcon.js +4 -0
- package/build/esm/icons/index.d.ts +2 -0
- package/build/esm/icons/index.js +2 -0
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/models/constructor-items/blocks.d.ts +20 -2
- package/build/esm/models/constructor-items/blocks.js +1 -0
- package/build/esm/models/constructor-items/common.d.ts +15 -0
- package/build/esm/schema/constants.js +3 -2
- package/build/esm/schema/validators/blocks.d.ts +1 -0
- package/build/esm/schema/validators/blocks.js +1 -0
- package/package.json +1 -1
- package/schema/index.js +1 -1
- package/server/models/constructor-items/blocks.d.ts +20 -2
- package/server/models/constructor-items/blocks.js +1 -0
- package/server/models/constructor-items/common.d.ts +15 -0
- package/widget/index.js +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @gravity-ui/page-constructor · [](https://www.npmjs.com/package/@gravity-ui/page-constructor) [](https://github.com/gravity-ui/page-constructor/actions/workflows/ci.yml?query=branch:main) [](https://github.com/gravity-ui/page-constructor/actions/workflows/release.yml?query=branch:main) [](https://
|
|
1
|
+
# @gravity-ui/page-constructor · [](https://www.npmjs.com/package/@gravity-ui/page-constructor) [](https://github.com/gravity-ui/page-constructor/actions/workflows/ci.yml?query=branch:main) [](https://github.com/gravity-ui/page-constructor/actions/workflows/release.yml?query=branch:main) [](https://doyourjob-agency.github.io/page-constructor/main/)
|
|
2
2
|
|
|
3
3
|
## Page constructor
|
|
4
4
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-reports-block__title {
|
|
4
|
+
margin-bottom: 24px;
|
|
5
|
+
}
|
|
6
|
+
.pc-reports-block__select {
|
|
7
|
+
margin-bottom: 32px;
|
|
8
|
+
}
|
|
9
|
+
.pc-reports-block__empty {
|
|
10
|
+
font-size: var(--g-text-body-2-font-size, var(--pc-text-body-2-font-size));
|
|
11
|
+
line-height: var(--g-text-body-2-line-height, var(--pc-text-body-2-line-height));
|
|
12
|
+
height: 128px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
background-color: var(--g-color-private-blue-50);
|
|
15
|
+
border-radius: 24px;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportsBlock = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const components_1 = require("../../components");
|
|
7
|
+
const reportsContext_1 = require("../../context/reportsContext");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const ReportsItem_1 = tslib_1.__importDefault(require("./ReportsItem/ReportsItem"));
|
|
10
|
+
const b = (0, utils_1.block)('reports-block');
|
|
11
|
+
const titleColSizes = {
|
|
12
|
+
all: 12,
|
|
13
|
+
};
|
|
14
|
+
const ReportsBlock = ({ title, typeKey, empty }) => {
|
|
15
|
+
const data = (0, react_1.useContext)(reportsContext_1.ReportsContext);
|
|
16
|
+
const [page, setPage] = (0, react_1.useState)(1);
|
|
17
|
+
const { selects, items, itemsPerPage, filesOutline } = (0, react_1.useMemo)(() => data[typeKey], [data, typeKey]);
|
|
18
|
+
const initFilters = (0, react_1.useMemo)(() => (selects === null || selects === void 0 ? void 0 : selects.reduce((acc, select) => (Object.assign(Object.assign({}, acc), { [select.name]: select.init })), {})) || {}, [selects]);
|
|
19
|
+
const [localFilters, setLocalFilters] = (0, react_1.useState)(initFilters);
|
|
20
|
+
const handleChange = (0, react_1.useCallback)((name, value) => setLocalFilters((prev) => (Object.assign(Object.assign({}, prev), { [name]: value }))), []);
|
|
21
|
+
const filteredItems = (0, react_1.useMemo)(() => Object.keys(localFilters).length
|
|
22
|
+
? items.filter((item) => Object.entries(localFilters).reduce((acc, [key, value]) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if ((_b = (_a = item.filters) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.includes(value)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return acc;
|
|
28
|
+
}, false))
|
|
29
|
+
: items, [items, localFilters]);
|
|
30
|
+
const paginatedItems = (0, react_1.useMemo)(() => {
|
|
31
|
+
if (!itemsPerPage)
|
|
32
|
+
return filteredItems;
|
|
33
|
+
const startIndex = (page - 1) * itemsPerPage;
|
|
34
|
+
return filteredItems.slice(startIndex, startIndex + itemsPerPage);
|
|
35
|
+
}, [filteredItems, itemsPerPage, page]);
|
|
36
|
+
const titleProps = !title || typeof title === 'string'
|
|
37
|
+
? { text: title, textSize: 'm' }
|
|
38
|
+
: title;
|
|
39
|
+
return (react_1.default.createElement("div", { className: b() },
|
|
40
|
+
title && react_1.default.createElement(components_1.Title, { className: b('title'), title: titleProps, colSizes: titleColSizes }),
|
|
41
|
+
(selects === null || selects === void 0 ? void 0 : selects.length) && (react_1.default.createElement("div", { className: b('select') }, selects.map(({ name, options }) => (react_1.default.createElement(components_1.Select, { key: name, name: name, options: options, onChange: handleChange }))))),
|
|
42
|
+
paginatedItems.length ? (paginatedItems.map((item, index) => (react_1.default.createElement(ReportsItem_1.default, Object.assign({ key: index }, item, { filesOutline: filesOutline }))))) : (react_1.default.createElement("div", { className: b('empty') }, empty)),
|
|
43
|
+
itemsPerPage && (react_1.default.createElement(components_1.Paginator, { page: page, itemsPerPage: itemsPerPage, totalItems: filteredItems.length, maxPages: Infinity, onPageChange: setPage }))));
|
|
44
|
+
};
|
|
45
|
+
exports.ReportsBlock = ReportsBlock;
|
|
46
|
+
exports.default = exports.ReportsBlock;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-reports-item {
|
|
4
|
+
padding: 24px 32px;
|
|
5
|
+
border-radius: 24px;
|
|
6
|
+
transition: box-shadow 0.3s ease-in-out;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
.pc-reports-item__wrap {
|
|
11
|
+
flex: 1;
|
|
12
|
+
}
|
|
13
|
+
.pc-reports-item__title {
|
|
14
|
+
font-size: var(--g-text-body-2-font-size, var(--pc-text-body-2-font-size));
|
|
15
|
+
line-height: var(--g-text-body-2-line-height, var(--pc-text-body-2-line-height));
|
|
16
|
+
}
|
|
17
|
+
.pc-reports-item__info {
|
|
18
|
+
font-size: var(--g-text-body-1-font-size, var(--pc-text-body-1-font-size));
|
|
19
|
+
line-height: var(--g-text-body-1-line-height, var(--pc-text-body-1-line-height));
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 8px;
|
|
23
|
+
color: var(--g-color-private-cool-grey-600-solid);
|
|
24
|
+
margin-top: 8px;
|
|
25
|
+
}
|
|
26
|
+
.pc-reports-item__dot {
|
|
27
|
+
background-color: var(--g-color-private-cool-grey-400);
|
|
28
|
+
border-radius: 100%;
|
|
29
|
+
width: 5px;
|
|
30
|
+
height: 5px;
|
|
31
|
+
}
|
|
32
|
+
.pc-reports-item__files {
|
|
33
|
+
display: flex;
|
|
34
|
+
gap: 8px;
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
}
|
|
37
|
+
.pc-reports-item:hover {
|
|
38
|
+
box-shadow: 0 4px 24px var(--pc-color-sfx-shadow), 0 2px 8px var(--pc-color-sfx-shadow);
|
|
39
|
+
}
|
|
40
|
+
@media (max-width: 769px) {
|
|
41
|
+
.pc-reports-item {
|
|
42
|
+
padding: 24px;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
}
|
|
46
|
+
.pc-reports-item__files {
|
|
47
|
+
margin-top: 24px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportsItem = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const components_1 = require("../../../components");
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
const b = (0, utils_1.block)('reports-item');
|
|
9
|
+
const ReportsItem = ({ title, date, text, files, filesOutline }) => (react_1.default.createElement("div", { className: b() },
|
|
10
|
+
react_1.default.createElement("div", { className: b('wrap') },
|
|
11
|
+
react_1.default.createElement("div", { className: b('title') }, title),
|
|
12
|
+
(date || text) && (react_1.default.createElement("div", { className: b('info') },
|
|
13
|
+
date && react_1.default.createElement("div", { className: b('date') }, date),
|
|
14
|
+
date && text && react_1.default.createElement("div", { className: b('dot') }),
|
|
15
|
+
text && react_1.default.createElement("div", { className: b('text') }, text)))),
|
|
16
|
+
(files === null || files === void 0 ? void 0 : files.length) && (react_1.default.createElement("div", { className: b('files') }, files.map((file) => (react_1.default.createElement(components_1.ReportFile, Object.assign({ key: file.link }, file, { outline: filesOutline }))))))));
|
|
17
|
+
exports.ReportsItem = ReportsItem;
|
|
18
|
+
exports.default = exports.ReportsItem;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const ReportsBlock: {
|
|
2
|
+
'reports-block': {
|
|
3
|
+
additionalProperties: boolean;
|
|
4
|
+
required: string[];
|
|
5
|
+
properties: {
|
|
6
|
+
title: {
|
|
7
|
+
oneOf: ({
|
|
8
|
+
type: string;
|
|
9
|
+
contentType: string;
|
|
10
|
+
optionName: string;
|
|
11
|
+
} | {
|
|
12
|
+
optionName: string;
|
|
13
|
+
type: string;
|
|
14
|
+
additionalProperties: boolean;
|
|
15
|
+
required: string[];
|
|
16
|
+
properties: {
|
|
17
|
+
text: {
|
|
18
|
+
type: string;
|
|
19
|
+
contentType: string;
|
|
20
|
+
};
|
|
21
|
+
textSize: {
|
|
22
|
+
type: string;
|
|
23
|
+
enum: string[];
|
|
24
|
+
};
|
|
25
|
+
url: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
urlTitle: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
resetMargin: {
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
contentType?: undefined;
|
|
36
|
+
})[];
|
|
37
|
+
};
|
|
38
|
+
typeKey: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
empty: {
|
|
42
|
+
type: string;
|
|
43
|
+
};
|
|
44
|
+
type: {};
|
|
45
|
+
when: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportsBlock = void 0;
|
|
4
|
+
const common_1 = require("./../../schema/validators/common");
|
|
5
|
+
exports.ReportsBlock = {
|
|
6
|
+
'reports-block': {
|
|
7
|
+
additionalProperties: false,
|
|
8
|
+
required: ['typeKey'],
|
|
9
|
+
properties: Object.assign(Object.assign({}, common_1.BaseProps), { title: {
|
|
10
|
+
oneOf: [
|
|
11
|
+
{
|
|
12
|
+
type: 'string',
|
|
13
|
+
contentType: 'text',
|
|
14
|
+
optionName: 'text',
|
|
15
|
+
},
|
|
16
|
+
Object.assign(Object.assign({}, common_1.TitleProps), { optionName: 'options' }),
|
|
17
|
+
],
|
|
18
|
+
}, typeKey: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
}, empty: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
} }),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -21,6 +21,7 @@ export { default as MarqueeLinksBlock } from './MarqueeLinks/MarqueeLinks';
|
|
|
21
21
|
export { default as SolutionsBlock } from './Solutions/Solutions';
|
|
22
22
|
export { default as ServicesBlock } from './Services/Services';
|
|
23
23
|
export { default as QuotesBlock } from './Quotes/Quotes';
|
|
24
|
+
export { default as ReportsBlock } from './Reports/Reports';
|
|
24
25
|
export { default as FormWallBlock } from './FormWallBlock/FormWallBlock';
|
|
25
26
|
export { default as LinkTableBlock } from './LinkTable/LinkTable';
|
|
26
27
|
export { default as EventsFeedBlock } from './EventsFeed/EventsFeed';
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HighlightTableBlock = exports.PressReleasesBlock = exports.RelevantPostsBlock = exports.BlogFeedBlock = exports.EventsFeedBlock = exports.LinkTableBlock = exports.FormWallBlock = exports.QuotesBlock = exports.ServicesBlock = exports.SolutionsBlock = exports.MarqueeLinksBlock = exports.FormBlock = exports.FilterBlock = exports.ShareBlock = exports.ContentLayoutBlock = exports.CardLayoutBlock = exports.HeaderSliderBlock = exports.IconsBlock = exports.HeaderBlock = exports.TabsBlock = exports.TableBlock = exports.QuestionsBlock = exports.PromoFeaturesBlock = exports.ExtendedFeaturesBlock = exports.SliderBlock = exports.MapBlock = exports.MediaBlock = exports.InfoBlock = exports.CompaniesBlock = exports.BannerBlock = void 0;
|
|
6
|
+
exports.HighlightTableBlock = exports.PressReleasesBlock = exports.RelevantPostsBlock = exports.BlogFeedBlock = exports.EventsFeedBlock = exports.LinkTableBlock = exports.FormWallBlock = exports.ReportsBlock = exports.QuotesBlock = exports.ServicesBlock = exports.SolutionsBlock = exports.MarqueeLinksBlock = exports.FormBlock = exports.FilterBlock = exports.ShareBlock = exports.ContentLayoutBlock = exports.CardLayoutBlock = exports.HeaderSliderBlock = exports.IconsBlock = exports.HeaderBlock = exports.TabsBlock = exports.TableBlock = exports.QuestionsBlock = exports.PromoFeaturesBlock = exports.ExtendedFeaturesBlock = exports.SliderBlock = exports.MapBlock = exports.MediaBlock = exports.InfoBlock = exports.CompaniesBlock = exports.BannerBlock = void 0;
|
|
7
7
|
var Banner_1 = require("./Banner/Banner");
|
|
8
8
|
Object.defineProperty(exports, "BannerBlock", { enumerable: true, get: function () { return __importDefault(Banner_1).default; } });
|
|
9
9
|
var Companies_1 = require("./Companies/Companies");
|
|
@@ -50,6 +50,8 @@ var Services_1 = require("./Services/Services");
|
|
|
50
50
|
Object.defineProperty(exports, "ServicesBlock", { enumerable: true, get: function () { return __importDefault(Services_1).default; } });
|
|
51
51
|
var Quotes_1 = require("./Quotes/Quotes");
|
|
52
52
|
Object.defineProperty(exports, "QuotesBlock", { enumerable: true, get: function () { return __importDefault(Quotes_1).default; } });
|
|
53
|
+
var Reports_1 = require("./Reports/Reports");
|
|
54
|
+
Object.defineProperty(exports, "ReportsBlock", { enumerable: true, get: function () { return __importDefault(Reports_1).default; } });
|
|
53
55
|
var FormWallBlock_1 = require("./FormWallBlock/FormWallBlock");
|
|
54
56
|
Object.defineProperty(exports, "FormWallBlock", { enumerable: true, get: function () { return __importDefault(FormWallBlock_1).default; } });
|
|
55
57
|
var LinkTable_1 = require("./LinkTable/LinkTable");
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-paginator {
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 0;
|
|
6
|
+
list-style: none;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
flex-wrap: wrap;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
}
|
|
12
|
+
.pc-paginator__item {
|
|
13
|
+
font-size: var(--g-text-body-2-font-size, var(--pc-text-body-2-font-size));
|
|
14
|
+
line-height: var(--g-text-body-2-line-height, var(--pc-text-body-2-line-height));
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
min-width: 52px;
|
|
19
|
+
min-height: 52px;
|
|
20
|
+
margin: 0 4px;
|
|
21
|
+
padding: 16px 20px;
|
|
22
|
+
border: none;
|
|
23
|
+
border-radius: 8px;
|
|
24
|
+
background: transparent;
|
|
25
|
+
color: var(--g-color-text-primary);
|
|
26
|
+
}
|
|
27
|
+
.pc-paginator__item:hover {
|
|
28
|
+
background-color: var(--g-color-private-blue-50);
|
|
29
|
+
}
|
|
30
|
+
.pc-paginator__item_type_page {
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
33
|
+
.pc-paginator__item_type_page.pc-paginator__item_active {
|
|
34
|
+
background-color: var(--g-color-private-blue-200-solid);
|
|
35
|
+
cursor: default;
|
|
36
|
+
}
|
|
37
|
+
.pc-paginator__item_type_prev, .pc-paginator__item_type_next {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
gap: 8px;
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
}
|
|
42
|
+
.pc-paginator__pagination {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-flow: row wrap;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
47
|
+
width: 100%;
|
|
48
|
+
gap: 8px;
|
|
49
|
+
}
|
|
50
|
+
@media (max-width: 577px) {
|
|
51
|
+
.pc-paginator__pagination {
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
.pc-paginator__pagination-block {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: row;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
align-items: center;
|
|
60
|
+
margin-bottom: 4px;
|
|
61
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Paginator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const cn_1 = require("../../utils/cn");
|
|
7
|
+
const NavigationButton_1 = require("./components/NavigationButton");
|
|
8
|
+
const PaginatorItem_1 = require("./components/PaginatorItem");
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const b = (0, cn_1.block)('paginator');
|
|
12
|
+
const DEFAULT_PAGE_COUNT_FOR_SHOW_SUPPORT_BUTTONS = 5;
|
|
13
|
+
const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className, onPageChange, pageCountForShowSupportButtons = DEFAULT_PAGE_COUNT_FOR_SHOW_SUPPORT_BUTTONS, }) => {
|
|
14
|
+
const [pagesCount, setPagesCount] = (0, react_1.useState)((0, utils_1.getPagesCount)({ itemsPerPage, totalItems, maxPages }));
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
const count = (0, utils_1.getPagesCount)({ itemsPerPage, totalItems, maxPages });
|
|
17
|
+
setPagesCount(count);
|
|
18
|
+
}, [itemsPerPage, totalItems, maxPages]);
|
|
19
|
+
const handlePageChange = (pageIndex) => onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(pageIndex);
|
|
20
|
+
const isShowSupportButtons = (0, react_1.useMemo)(() => pagesCount > pageCountForShowSupportButtons, [pageCountForShowSupportButtons, pagesCount]);
|
|
21
|
+
if (pagesCount <= 1) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const handleArrowClick = (type) => {
|
|
25
|
+
let newPage = page;
|
|
26
|
+
if (type === 'prev' && page > 1) {
|
|
27
|
+
newPage = page - 1;
|
|
28
|
+
}
|
|
29
|
+
else if (type === 'next' && page < pagesCount) {
|
|
30
|
+
newPage = page + 1;
|
|
31
|
+
}
|
|
32
|
+
if (newPage !== page) {
|
|
33
|
+
handlePageChange(newPage);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const handlePageClick = (index) => {
|
|
37
|
+
if (index !== page && typeof index === 'number') {
|
|
38
|
+
handlePageChange(index);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const paginatorItems = (0, utils_1.getPageConfigs)({
|
|
42
|
+
page,
|
|
43
|
+
pagesCount,
|
|
44
|
+
handlePageClick,
|
|
45
|
+
});
|
|
46
|
+
if (page > 1 && isShowSupportButtons) {
|
|
47
|
+
paginatorItems.unshift({
|
|
48
|
+
key: types_1.ArrowType.Prev,
|
|
49
|
+
dataKey: types_1.ArrowType.Prev,
|
|
50
|
+
mods: { type: types_1.ArrowType.Prev },
|
|
51
|
+
onClick: handleArrowClick,
|
|
52
|
+
index: 0,
|
|
53
|
+
content: react_1.default.createElement(NavigationButton_1.NavigationButton, { arrowType: types_1.ArrowType.Prev }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (page < pagesCount && isShowSupportButtons) {
|
|
57
|
+
paginatorItems.push({
|
|
58
|
+
key: types_1.ArrowType.Next,
|
|
59
|
+
dataKey: types_1.ArrowType.Next,
|
|
60
|
+
mods: { type: types_1.ArrowType.Next },
|
|
61
|
+
index: page + 1,
|
|
62
|
+
onClick: handleArrowClick,
|
|
63
|
+
content: react_1.default.createElement(NavigationButton_1.NavigationButton, { arrowType: types_1.ArrowType.Next }),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const renderPaginatorItem = (item) => {
|
|
67
|
+
const { key } = item, rest = tslib_1.__rest(item, ["key"]);
|
|
68
|
+
return react_1.default.createElement(PaginatorItem_1.PaginatorItem, Object.assign({ key: `page_${key}` }, rest));
|
|
69
|
+
};
|
|
70
|
+
return (react_1.default.createElement("div", { className: b('pagination') },
|
|
71
|
+
page > 1 && isShowSupportButtons && (react_1.default.createElement("div", { className: b('pagination-block') },
|
|
72
|
+
react_1.default.createElement("ul", { className: b(null, className) }, paginatorItems.slice(0, 1).map(renderPaginatorItem)))),
|
|
73
|
+
react_1.default.createElement("div", { className: b('pagination-block') },
|
|
74
|
+
react_1.default.createElement("ul", { className: b(null, className) }, isShowSupportButtons
|
|
75
|
+
? paginatorItems
|
|
76
|
+
.slice(page > 1 ? 1 : 0, page < pagesCount
|
|
77
|
+
? paginatorItems.length - 1
|
|
78
|
+
: paginatorItems.length)
|
|
79
|
+
.map(renderPaginatorItem)
|
|
80
|
+
: paginatorItems.map(renderPaginatorItem))),
|
|
81
|
+
page < pagesCount && isShowSupportButtons && (react_1.default.createElement("div", { className: b('pagination-block') },
|
|
82
|
+
react_1.default.createElement("ul", { className: b(null, className) }, paginatorItems
|
|
83
|
+
.slice(paginatorItems.length - 1, paginatorItems.length)
|
|
84
|
+
.map(renderPaginatorItem))))));
|
|
85
|
+
};
|
|
86
|
+
exports.Paginator = Paginator;
|
|
87
|
+
exports.default = exports.Paginator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationButton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const icons_1 = require("../../../icons");
|
|
7
|
+
const i18n_1 = require("../i18n");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const NavigationButton = ({ arrowType, disabled }) => {
|
|
10
|
+
if (disabled) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (arrowType === types_1.ArrowType.Prev) {
|
|
14
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
15
|
+
react_1.default.createElement(icons_1.ArrowLeftIcon, null),
|
|
16
|
+
react_1.default.createElement("span", null, (0, i18n_1.i18n)('prev'))));
|
|
17
|
+
}
|
|
18
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
19
|
+
react_1.default.createElement("span", null, (0, i18n_1.i18n)('next')),
|
|
20
|
+
react_1.default.createElement(icons_1.ArrowRightIcon, null)));
|
|
21
|
+
};
|
|
22
|
+
exports.NavigationButton = NavigationButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaginatorItem = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const cn_1 = require("../../../utils/cn");
|
|
7
|
+
const b = (0, cn_1.block)('paginator');
|
|
8
|
+
const PaginatorItem = ({ dataKey, mods, content, onClick }) => {
|
|
9
|
+
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
|
10
|
+
const handleClick = (0, react_1.useCallback)(() => {
|
|
11
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(itemKey);
|
|
12
|
+
}, [itemKey, onClick]);
|
|
13
|
+
return (react_1.default.createElement("button", { className: b('item', mods), onClick: handleClick }, content));
|
|
14
|
+
};
|
|
15
|
+
exports.PaginatorItem = PaginatorItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const i18n: (key: "prev" | "next", params?: import("@gravity-ui/i18n").Params | undefined) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.i18n = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const i18n_1 = require("@gravity-ui/uikit/i18n");
|
|
6
|
+
const cn_1 = require("../../../utils/cn");
|
|
7
|
+
const en_json_1 = tslib_1.__importDefault(require("./en.json"));
|
|
8
|
+
const ru_json_1 = tslib_1.__importDefault(require("./ru.json"));
|
|
9
|
+
exports.i18n = (0, i18n_1.addComponentKeysets)({ en: en_json_1.default, ru: ru_json_1.default }, `${cn_1.NAMESPACE}Paginator`);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { NoStrictEntityMods } from '@bem-react/classname';
|
|
3
|
+
import type { ClassNameProps } from '../../models/common';
|
|
4
|
+
export interface PaginatorItemProps {
|
|
5
|
+
key: string | ArrowType;
|
|
6
|
+
dataKey: string | ArrowType;
|
|
7
|
+
mods: NoStrictEntityMods;
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
onClick?: (key: number | ArrowType) => void;
|
|
10
|
+
index: number;
|
|
11
|
+
}
|
|
12
|
+
export type PaginatorProps = {
|
|
13
|
+
page: number;
|
|
14
|
+
totalItems: number;
|
|
15
|
+
itemsPerPage: number;
|
|
16
|
+
maxPages: number;
|
|
17
|
+
onPageChange: (page: number) => void;
|
|
18
|
+
pageCountForShowSupportButtons?: number;
|
|
19
|
+
} & ClassNameProps;
|
|
20
|
+
export declare enum ArrowType {
|
|
21
|
+
Prev = "prev",
|
|
22
|
+
Next = "next"
|
|
23
|
+
}
|
|
24
|
+
export type GetPageConfigParams = {
|
|
25
|
+
page: number;
|
|
26
|
+
pagesCount: number;
|
|
27
|
+
handlePageClick: (key: number | ArrowType) => void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrowType = void 0;
|
|
4
|
+
var ArrowType;
|
|
5
|
+
(function (ArrowType) {
|
|
6
|
+
ArrowType["Prev"] = "prev";
|
|
7
|
+
ArrowType["Next"] = "next";
|
|
8
|
+
})(ArrowType = exports.ArrowType || (exports.ArrowType = {}));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GetPageConfigParams, PaginatorItemProps, PaginatorProps } from './types';
|
|
2
|
+
export declare const getPageConfigs: ({ page, pagesCount, handlePageClick }: GetPageConfigParams) => PaginatorItemProps[];
|
|
3
|
+
export declare const getPagesCount: (props: Pick<PaginatorProps, 'totalItems' | 'itemsPerPage' | 'maxPages'>) => number;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPagesCount = exports.getPageConfigs = void 0;
|
|
4
|
+
const getPageConfigs = ({ page, pagesCount, handlePageClick }) => {
|
|
5
|
+
const paginatorItems = [];
|
|
6
|
+
const showLeftDots = page > 4;
|
|
7
|
+
const showRightDots = page < pagesCount - 3;
|
|
8
|
+
const addPage = (i) => {
|
|
9
|
+
paginatorItems.push({
|
|
10
|
+
key: String(i),
|
|
11
|
+
dataKey: String(i),
|
|
12
|
+
index: i,
|
|
13
|
+
mods: { type: 'page', active: page === i },
|
|
14
|
+
onClick: handlePageClick,
|
|
15
|
+
content: i,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
if (pagesCount <= 5) {
|
|
19
|
+
for (let i = 1; i <= pagesCount; i++) {
|
|
20
|
+
addPage(i);
|
|
21
|
+
}
|
|
22
|
+
return paginatorItems;
|
|
23
|
+
}
|
|
24
|
+
// Всегда добавляем первую
|
|
25
|
+
addPage(1);
|
|
26
|
+
// Левые троеточия
|
|
27
|
+
if (showLeftDots) {
|
|
28
|
+
paginatorItems.push({
|
|
29
|
+
key: 'ellipsis',
|
|
30
|
+
dataKey: 'ellipsis',
|
|
31
|
+
index: -1,
|
|
32
|
+
mods: { type: 'ellipsis' },
|
|
33
|
+
content: '…',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Центральный блок
|
|
37
|
+
let start = Math.max(2, page - 1);
|
|
38
|
+
let end = Math.min(pagesCount - 1, page + 1);
|
|
39
|
+
if (!showLeftDots) {
|
|
40
|
+
start = 2;
|
|
41
|
+
end = 5;
|
|
42
|
+
}
|
|
43
|
+
else if (!showRightDots) {
|
|
44
|
+
start = pagesCount - 4;
|
|
45
|
+
end = pagesCount - 1;
|
|
46
|
+
}
|
|
47
|
+
for (let i = start; i <= end; i++) {
|
|
48
|
+
addPage(i);
|
|
49
|
+
}
|
|
50
|
+
// Правые троеточия
|
|
51
|
+
if (showRightDots) {
|
|
52
|
+
paginatorItems.push({
|
|
53
|
+
key: 'ellipsis',
|
|
54
|
+
dataKey: 'ellipsis',
|
|
55
|
+
index: -2,
|
|
56
|
+
mods: { type: 'ellipsis' },
|
|
57
|
+
content: '…',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Последняя страница
|
|
61
|
+
if (pagesCount > 1) {
|
|
62
|
+
addPage(pagesCount);
|
|
63
|
+
}
|
|
64
|
+
return paginatorItems;
|
|
65
|
+
};
|
|
66
|
+
exports.getPageConfigs = getPageConfigs;
|
|
67
|
+
const getPagesCount = (props) => {
|
|
68
|
+
const totalPages = Math.ceil(props.totalItems / props.itemsPerPage);
|
|
69
|
+
return Number.isFinite(props.maxPages) ? Math.min(totalPages, props.maxPages) : totalPages;
|
|
70
|
+
};
|
|
71
|
+
exports.getPagesCount = getPagesCount;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-report-file {
|
|
4
|
+
font-size: var(--g-text-body-2-font-size, var(--pc-text-body-2-font-size));
|
|
5
|
+
line-height: var(--g-text-body-2-line-height, var(--pc-text-body-2-line-height));
|
|
6
|
+
border-width: 1px;
|
|
7
|
+
border-style: solid;
|
|
8
|
+
border-color: transparent;
|
|
9
|
+
border-radius: 100px;
|
|
10
|
+
padding: 10px 24px;
|
|
11
|
+
text-transform: uppercase;
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
color: inherit;
|
|
14
|
+
display: flex;
|
|
15
|
+
transition: background-color 0.3s ease-in-out;
|
|
16
|
+
background-color: var(--g-color-private-blue-50);
|
|
17
|
+
}
|
|
18
|
+
.pc-report-file:hover {
|
|
19
|
+
background-color: var(--g-color-private-cool-grey-400);
|
|
20
|
+
}
|
|
21
|
+
.pc-report-file_outline {
|
|
22
|
+
border-color: var(--g-color-private-cool-grey-400);
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
}
|
|
25
|
+
.pc-report-file_outline:hover {
|
|
26
|
+
background-color: var(--g-color-private-blue-50);
|
|
27
|
+
}
|