@gravity-ui/page-constructor 3.8.3 → 3.9.1
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/CHANGELOG.md +15 -0
- package/build/cjs/blocks/Banner/schema.d.ts +9 -3
- package/build/cjs/blocks/CardLayout/schema.d.ts +6 -2
- package/build/cjs/blocks/Companies/schema.d.ts +3 -1
- package/build/cjs/blocks/ContentLayout/schema.d.ts +3 -1
- package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +6 -2
- package/build/cjs/blocks/FilterBlock/schema.d.ts +6 -2
- package/build/cjs/blocks/Header/Header.js +2 -2
- package/build/cjs/blocks/Header/schema.d.ts +3 -1
- package/build/cjs/blocks/HeaderSlider/schema.d.ts +3 -1
- package/build/cjs/blocks/Icons/schema.d.ts +6 -2
- package/build/cjs/blocks/Info/schema.d.ts +3 -1
- package/build/cjs/blocks/Map/schema.d.ts +3 -1
- package/build/cjs/blocks/Media/schema.d.ts +6 -2
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -1
- package/build/cjs/blocks/Questions/schema.d.ts +3 -1
- package/build/cjs/blocks/Share/schema.d.ts +3 -1
- package/build/cjs/blocks/Slider/schema.d.ts +3 -1
- package/build/cjs/blocks/Table/schema.d.ts +6 -2
- package/build/cjs/blocks/Tabs/schema.d.ts +6 -2
- package/build/cjs/components/Author/schema.d.ts +3 -1
- package/build/cjs/editor/containers/Editor/Editor.js +5 -5
- package/build/cjs/editor/types/index.d.ts +4 -1
- package/build/cjs/schema/constants.d.ts +18 -6
- package/build/cjs/schema/validators/common.d.ts +9 -3
- package/build/cjs/schema/validators/common.js +3 -1
- package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +3 -1
- package/build/cjs/sub-blocks/BasicCard/schema.d.ts +3 -1
- package/build/cjs/sub-blocks/Divider/schema.d.ts +3 -1
- package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +3 -1
- package/build/cjs/sub-blocks/MediaCard/schema.d.ts +3 -1
- package/build/cjs/sub-blocks/PriceDetailed/schema.d.ts +3 -1
- package/build/cjs/sub-blocks/Quote/schema.d.ts +3 -1
- package/build/cjs/text-transform/filter.d.ts +20 -0
- package/build/cjs/text-transform/filter.js +61 -0
- package/build/cjs/text-transform/index.d.ts +1 -0
- package/build/cjs/text-transform/index.js +1 -0
- package/build/cjs/text-transform/transformers.d.ts +2 -0
- package/build/cjs/text-transform/transformers.js +3 -2
- package/build/esm/blocks/Banner/schema.d.ts +9 -3
- package/build/esm/blocks/CardLayout/schema.d.ts +6 -2
- package/build/esm/blocks/Companies/schema.d.ts +3 -1
- package/build/esm/blocks/ContentLayout/schema.d.ts +3 -1
- package/build/esm/blocks/ExtendedFeatures/schema.d.ts +6 -2
- package/build/esm/blocks/FilterBlock/schema.d.ts +6 -2
- package/build/esm/blocks/Header/Header.js +2 -2
- package/build/esm/blocks/Header/schema.d.ts +3 -1
- package/build/esm/blocks/HeaderSlider/schema.d.ts +3 -1
- package/build/esm/blocks/Icons/schema.d.ts +6 -2
- package/build/esm/blocks/Info/schema.d.ts +3 -1
- package/build/esm/blocks/Map/schema.d.ts +3 -1
- package/build/esm/blocks/Media/schema.d.ts +6 -2
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -1
- package/build/esm/blocks/Questions/schema.d.ts +3 -1
- package/build/esm/blocks/Share/schema.d.ts +3 -1
- package/build/esm/blocks/Slider/schema.d.ts +3 -1
- package/build/esm/blocks/Table/schema.d.ts +6 -2
- package/build/esm/blocks/Tabs/schema.d.ts +6 -2
- package/build/esm/components/Author/schema.d.ts +3 -1
- package/build/esm/editor/containers/Editor/Editor.js +5 -5
- package/build/esm/editor/types/index.d.ts +4 -1
- package/build/esm/schema/constants.d.ts +18 -6
- package/build/esm/schema/validators/common.d.ts +9 -3
- package/build/esm/schema/validators/common.js +3 -1
- package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +3 -1
- package/build/esm/sub-blocks/BasicCard/schema.d.ts +3 -1
- package/build/esm/sub-blocks/Divider/schema.d.ts +3 -1
- package/build/esm/sub-blocks/LayoutItem/schema.d.ts +3 -1
- package/build/esm/sub-blocks/MediaCard/schema.d.ts +3 -1
- package/build/esm/sub-blocks/PriceDetailed/schema.d.ts +3 -1
- package/build/esm/sub-blocks/Quote/schema.d.ts +3 -1
- package/build/esm/text-transform/filter.d.ts +20 -0
- package/build/esm/text-transform/filter.js +56 -0
- package/build/esm/text-transform/index.d.ts +1 -0
- package/build/esm/text-transform/index.js +1 -0
- package/build/esm/text-transform/transformers.d.ts +2 -0
- package/build/esm/text-transform/transformers.js +3 -2
- package/package.json +1 -1
- package/server/text-transform/filter.d.ts +20 -0
- package/server/text-transform/filter.js +63 -0
- package/server/text-transform/index.d.ts +1 -0
- package/server/text-transform/index.js +1 -0
- package/server/text-transform/transformers.d.ts +2 -0
- package/server/text-transform/transformers.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.9.1](https://github.com/gravity-ui/page-constructor/compare/v3.9.0...v3.9.1) (2023-06-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* header description displaying with ssr ([#431](https://github.com/gravity-ui/page-constructor/issues/431)) ([9c094dc](https://github.com/gravity-ui/page-constructor/commit/9c094dc7550d483cedd6b5611e0902b0d7aa27e1))
|
|
9
|
+
|
|
10
|
+
## [3.9.0](https://github.com/gravity-ui/page-constructor/compare/v3.8.3...v3.9.0) (2023-06-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add content filtration utils ([6cf8038](https://github.com/gravity-ui/page-constructor/commit/6cf803818a222eed964f5e24960ad99a567adc1e))
|
|
16
|
+
* add transform when variables handling ([#427](https://github.com/gravity-ui/page-constructor/issues/427)) ([6cf8038](https://github.com/gravity-ui/page-constructor/commit/6cf803818a222eed964f5e24960ad99a567adc1e))
|
|
17
|
+
|
|
3
18
|
## [3.8.3](https://github.com/gravity-ui/page-constructor/compare/v3.8.2...v3.8.3) (2023-06-27)
|
|
4
19
|
|
|
5
20
|
|
|
@@ -288,7 +288,9 @@ export declare const BannerCardProps: {
|
|
|
288
288
|
type: string;
|
|
289
289
|
};
|
|
290
290
|
type: {};
|
|
291
|
-
when: {
|
|
291
|
+
when: {
|
|
292
|
+
type: string;
|
|
293
|
+
};
|
|
292
294
|
};
|
|
293
295
|
};
|
|
294
296
|
export declare const BannerBlock: {
|
|
@@ -582,7 +584,9 @@ export declare const BannerBlock: {
|
|
|
582
584
|
type: string;
|
|
583
585
|
};
|
|
584
586
|
type: {};
|
|
585
|
-
when: {
|
|
587
|
+
when: {
|
|
588
|
+
type: string;
|
|
589
|
+
};
|
|
586
590
|
};
|
|
587
591
|
};
|
|
588
592
|
};
|
|
@@ -877,7 +881,9 @@ export declare const BannerCard: {
|
|
|
877
881
|
type: string;
|
|
878
882
|
};
|
|
879
883
|
type: {};
|
|
880
|
-
when: {
|
|
884
|
+
when: {
|
|
885
|
+
type: string;
|
|
886
|
+
};
|
|
881
887
|
};
|
|
882
888
|
};
|
|
883
889
|
};
|
|
@@ -73,7 +73,9 @@ export declare const CardLayoutProps: {
|
|
|
73
73
|
type: string;
|
|
74
74
|
};
|
|
75
75
|
type: {};
|
|
76
|
-
when: {
|
|
76
|
+
when: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
77
79
|
};
|
|
78
80
|
};
|
|
79
81
|
export declare const CardLayoutBlock: {
|
|
@@ -152,7 +154,9 @@ export declare const CardLayoutBlock: {
|
|
|
152
154
|
type: string;
|
|
153
155
|
};
|
|
154
156
|
type: {};
|
|
155
|
-
when: {
|
|
157
|
+
when: {
|
|
158
|
+
type: string;
|
|
159
|
+
};
|
|
156
160
|
};
|
|
157
161
|
};
|
|
158
162
|
};
|
|
@@ -123,7 +123,9 @@ export declare const ExtendedFeaturesItem: {
|
|
|
123
123
|
})[];
|
|
124
124
|
};
|
|
125
125
|
type: {};
|
|
126
|
-
when: {
|
|
126
|
+
when: {
|
|
127
|
+
type: string;
|
|
128
|
+
};
|
|
127
129
|
};
|
|
128
130
|
};
|
|
129
131
|
icon: {
|
|
@@ -233,7 +235,9 @@ export declare const ExtendedFeaturesBlock: {
|
|
|
233
235
|
type: string;
|
|
234
236
|
};
|
|
235
237
|
type: {};
|
|
236
|
-
when: {
|
|
238
|
+
when: {
|
|
239
|
+
type: string;
|
|
240
|
+
};
|
|
237
241
|
};
|
|
238
242
|
};
|
|
239
243
|
};
|
|
@@ -126,7 +126,9 @@ export declare const FilterProps: {
|
|
|
126
126
|
type: string;
|
|
127
127
|
};
|
|
128
128
|
type: {};
|
|
129
|
-
when: {
|
|
129
|
+
when: {
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
130
132
|
};
|
|
131
133
|
};
|
|
132
134
|
export declare const FilterBlock: {
|
|
@@ -231,7 +233,9 @@ export declare const FilterBlock: {
|
|
|
231
233
|
type: string;
|
|
232
234
|
};
|
|
233
235
|
type: {};
|
|
234
|
-
when: {
|
|
236
|
+
when: {
|
|
237
|
+
type: string;
|
|
238
|
+
};
|
|
235
239
|
};
|
|
236
240
|
};
|
|
237
241
|
};
|
|
@@ -51,12 +51,12 @@ const HeaderBlock = (props) => {
|
|
|
51
51
|
'vertical-offset': curVerticalOffset,
|
|
52
52
|
}) },
|
|
53
53
|
react_1.default.createElement(grid_1.Col, { sizes: titleSizes, className: b('content-inner') },
|
|
54
|
-
overtitle && (react_1.default.createElement("
|
|
54
|
+
overtitle && (react_1.default.createElement("div", { className: b('overtitle') },
|
|
55
55
|
react_1.default.createElement(components_1.HTML, null, overtitle))),
|
|
56
56
|
react_1.default.createElement("h1", { className: b('title') },
|
|
57
57
|
status,
|
|
58
58
|
react_1.default.createElement(components_1.HTML, null, title)),
|
|
59
|
-
description && (react_1.default.createElement("
|
|
59
|
+
description && (react_1.default.createElement("div", { className: b('description') },
|
|
60
60
|
react_1.default.createElement(YFMWrapper_1.default, { content: description, modifiers: { constructor: true } }))),
|
|
61
61
|
buttons && (react_1.default.createElement("div", { className: b('buttons'), "data-qa": "header-buttons" }, buttons &&
|
|
62
62
|
buttons.map((button, index) => (react_1.default.createElement(components_1.RouterLink, { href: button.url, key: index },
|
|
@@ -59,7 +59,9 @@ export declare const IconsProps: {
|
|
|
59
59
|
type: string;
|
|
60
60
|
};
|
|
61
61
|
type: {};
|
|
62
|
-
when: {
|
|
62
|
+
when: {
|
|
63
|
+
type: string;
|
|
64
|
+
};
|
|
63
65
|
};
|
|
64
66
|
};
|
|
65
67
|
export declare const IconsBlock: {
|
|
@@ -124,7 +126,9 @@ export declare const IconsBlock: {
|
|
|
124
126
|
type: string;
|
|
125
127
|
};
|
|
126
128
|
type: {};
|
|
127
|
-
when: {
|
|
129
|
+
when: {
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
128
132
|
};
|
|
129
133
|
};
|
|
130
134
|
};
|
|
@@ -570,7 +570,9 @@ export declare const MediaBlockBaseProps: {
|
|
|
570
570
|
type: string;
|
|
571
571
|
};
|
|
572
572
|
type: {};
|
|
573
|
-
when: {
|
|
573
|
+
when: {
|
|
574
|
+
type: string;
|
|
575
|
+
};
|
|
574
576
|
};
|
|
575
577
|
export declare const MediaBlock: {
|
|
576
578
|
'media-block': {
|
|
@@ -1158,7 +1160,9 @@ export declare const MediaBlock: {
|
|
|
1158
1160
|
type: string;
|
|
1159
1161
|
};
|
|
1160
1162
|
type: {};
|
|
1161
|
-
when: {
|
|
1163
|
+
when: {
|
|
1164
|
+
type: string;
|
|
1165
|
+
};
|
|
1162
1166
|
};
|
|
1163
1167
|
};
|
|
1164
1168
|
};
|
|
@@ -43,7 +43,9 @@ export declare const TableBlock: {
|
|
|
43
43
|
enum: string[];
|
|
44
44
|
};
|
|
45
45
|
type: {};
|
|
46
|
-
when: {
|
|
46
|
+
when: {
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
anchor: {
|
|
@@ -71,7 +73,9 @@ export declare const TableBlock: {
|
|
|
71
73
|
type: string;
|
|
72
74
|
};
|
|
73
75
|
type: {};
|
|
74
|
-
when: {
|
|
76
|
+
when: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
75
79
|
};
|
|
76
80
|
};
|
|
77
81
|
};
|
|
@@ -353,7 +353,9 @@ export declare const tabsItem: {
|
|
|
353
353
|
})[];
|
|
354
354
|
};
|
|
355
355
|
type: {};
|
|
356
|
-
when: {
|
|
356
|
+
when: {
|
|
357
|
+
type: string;
|
|
358
|
+
};
|
|
357
359
|
};
|
|
358
360
|
};
|
|
359
361
|
image: {
|
|
@@ -535,7 +537,9 @@ export declare const TabsBlock: {
|
|
|
535
537
|
type: string;
|
|
536
538
|
};
|
|
537
539
|
type: {};
|
|
538
|
-
when: {
|
|
540
|
+
when: {
|
|
541
|
+
type: string;
|
|
542
|
+
};
|
|
539
543
|
};
|
|
540
544
|
};
|
|
541
545
|
};
|
|
@@ -15,8 +15,9 @@ const Form_1 = require("../Form/Form");
|
|
|
15
15
|
const Editor = (_a) => {
|
|
16
16
|
var { children, customSchema, onChange } = _a, rest = tslib_1.__rest(_a, ["children", "customSchema", "onChange"]);
|
|
17
17
|
const { content, activeBlockIndex, errorBoundaryState, viewMode, onContentUpdate, onViewModeUpdate, onAdd, onSelect, injectEditBlockProps, } = (0, store_1.useEditorState)(rest);
|
|
18
|
+
const formSpecs = (0, useFormSpec_1.default)(customSchema);
|
|
18
19
|
const isEditingMode = viewMode === types_1.ViewModeItem.Edititng;
|
|
19
|
-
const
|
|
20
|
+
const outgoingProps = (0, react_1.useMemo)(() => {
|
|
20
21
|
const custom = isEditingMode
|
|
21
22
|
? (0, utils_1.addCustomDecorator)([
|
|
22
23
|
(props) => (react_1.default.createElement(EditBlock_1.default, Object.assign({}, injectEditBlockProps(props)))),
|
|
@@ -24,17 +25,16 @@ const Editor = (_a) => {
|
|
|
24
25
|
(props) => (react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, Object.assign({}, props, { key: `${(0, utils_1.getBlockId)(props)}-${errorBoundaryState}` }))),
|
|
25
26
|
], rest.custom)
|
|
26
27
|
: rest.custom;
|
|
27
|
-
return { content, custom };
|
|
28
|
-
}, [injectEditBlockProps, content, errorBoundaryState, isEditingMode, rest.custom]);
|
|
28
|
+
return { content, custom, viewMode };
|
|
29
|
+
}, [injectEditBlockProps, content, errorBoundaryState, isEditingMode, viewMode, rest.custom]);
|
|
29
30
|
(0, react_1.useEffect)(() => {
|
|
30
31
|
onChange === null || onChange === void 0 ? void 0 : onChange(content);
|
|
31
32
|
}, [content, onChange]);
|
|
32
|
-
const formSpecs = (0, useFormSpec_1.default)(customSchema);
|
|
33
33
|
return (react_1.default.createElement(Layout_1.default, { mode: viewMode, onModeChange: onViewModeUpdate },
|
|
34
34
|
isEditingMode && (react_1.default.createElement(Layout_1.default.Left, null,
|
|
35
35
|
react_1.default.createElement(Form_1.Form, { content: content, onChange: onContentUpdate, activeBlockIndex: activeBlockIndex, onSelect: onSelect, spec: formSpecs }))),
|
|
36
36
|
react_1.default.createElement(Layout_1.default.Right, null,
|
|
37
|
-
react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { key: errorBoundaryState }, children(
|
|
37
|
+
react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { key: errorBoundaryState }, children(outgoingProps)),
|
|
38
38
|
isEditingMode && react_1.default.createElement(AddBlock_1.default, { onAdd: onAdd }))));
|
|
39
39
|
};
|
|
40
40
|
exports.Editor = Editor;
|
|
@@ -4,8 +4,11 @@ import { BlockDecorationProps, PageContent } from '../../models';
|
|
|
4
4
|
import { SchemaCustomConfig } from '../../schema';
|
|
5
5
|
import { EditBlockActions } from '../components/EditBlock/EditBlock';
|
|
6
6
|
export type EditorBlockId = number | string;
|
|
7
|
+
export interface EditorOutgoingProps extends Partial<PageConstructorProps> {
|
|
8
|
+
viewMode: ViewModeItem;
|
|
9
|
+
}
|
|
7
10
|
export interface EditorProps extends Required<Pick<PageConstructorProps, 'content'>>, Partial<Omit<PageConstructorProps, 'content'>> {
|
|
8
|
-
children: (props:
|
|
11
|
+
children: (props: EditorOutgoingProps) => React.ReactNode;
|
|
9
12
|
onChange?: (data: PageContent) => void;
|
|
10
13
|
customSchema?: SchemaCustomConfig;
|
|
11
14
|
}
|
|
@@ -91,7 +91,9 @@ export declare const cardSchemas: {
|
|
|
91
91
|
enum: string[];
|
|
92
92
|
};
|
|
93
93
|
type: {};
|
|
94
|
-
when: {
|
|
94
|
+
when: {
|
|
95
|
+
type: string;
|
|
96
|
+
};
|
|
95
97
|
};
|
|
96
98
|
};
|
|
97
99
|
quote: {
|
|
@@ -166,7 +168,9 @@ export declare const cardSchemas: {
|
|
|
166
168
|
};
|
|
167
169
|
};
|
|
168
170
|
type: {};
|
|
169
|
-
when: {
|
|
171
|
+
when: {
|
|
172
|
+
type: string;
|
|
173
|
+
};
|
|
170
174
|
};
|
|
171
175
|
};
|
|
172
176
|
'background-card': {
|
|
@@ -280,7 +284,9 @@ export declare const cardSchemas: {
|
|
|
280
284
|
enum: string[];
|
|
281
285
|
};
|
|
282
286
|
type: {};
|
|
283
|
-
when: {
|
|
287
|
+
when: {
|
|
288
|
+
type: string;
|
|
289
|
+
};
|
|
284
290
|
};
|
|
285
291
|
};
|
|
286
292
|
'price-detailed': {
|
|
@@ -372,7 +378,9 @@ export declare const cardSchemas: {
|
|
|
372
378
|
type: string;
|
|
373
379
|
};
|
|
374
380
|
type: {};
|
|
375
|
-
when: {
|
|
381
|
+
when: {
|
|
382
|
+
type: string;
|
|
383
|
+
};
|
|
376
384
|
};
|
|
377
385
|
};
|
|
378
386
|
'banner-card': {
|
|
@@ -665,7 +673,9 @@ export declare const cardSchemas: {
|
|
|
665
673
|
type: string;
|
|
666
674
|
};
|
|
667
675
|
type: {};
|
|
668
|
-
when: {
|
|
676
|
+
when: {
|
|
677
|
+
type: string;
|
|
678
|
+
};
|
|
669
679
|
};
|
|
670
680
|
};
|
|
671
681
|
'media-card': {
|
|
@@ -899,7 +909,9 @@ export declare const cardSchemas: {
|
|
|
899
909
|
enum: string[];
|
|
900
910
|
};
|
|
901
911
|
type: {};
|
|
902
|
-
when: {
|
|
912
|
+
when: {
|
|
913
|
+
type: string;
|
|
914
|
+
};
|
|
903
915
|
};
|
|
904
916
|
};
|
|
905
917
|
};
|
|
@@ -21,7 +21,9 @@ export declare const sizeNumber: {
|
|
|
21
21
|
export declare const contentThemes: string[];
|
|
22
22
|
export declare const BaseProps: {
|
|
23
23
|
type: {};
|
|
24
|
-
when: {
|
|
24
|
+
when: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
25
27
|
};
|
|
26
28
|
export declare const containerSizesObject: {
|
|
27
29
|
type: string;
|
|
@@ -412,7 +414,9 @@ export declare const LinkProps: {
|
|
|
412
414
|
})[];
|
|
413
415
|
};
|
|
414
416
|
type: {};
|
|
415
|
-
when: {
|
|
417
|
+
when: {
|
|
418
|
+
type: string;
|
|
419
|
+
};
|
|
416
420
|
};
|
|
417
421
|
};
|
|
418
422
|
export declare const FileLinkProps: {
|
|
@@ -750,7 +754,9 @@ export declare const BlockBaseProps: {
|
|
|
750
754
|
type: string;
|
|
751
755
|
};
|
|
752
756
|
type: {};
|
|
753
|
-
when: {
|
|
757
|
+
when: {
|
|
758
|
+
type: string;
|
|
759
|
+
};
|
|
754
760
|
};
|
|
755
761
|
export declare const TitleProps: {
|
|
756
762
|
type: string;
|
|
@@ -21,7 +21,9 @@ exports.sizeNumber = { type: 'number', maximum: 12, minimum: 1 };
|
|
|
21
21
|
exports.contentThemes = ['default', 'dark', 'light'];
|
|
22
22
|
exports.BaseProps = {
|
|
23
23
|
type: {},
|
|
24
|
-
when: {
|
|
24
|
+
when: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
},
|
|
25
27
|
};
|
|
26
28
|
exports.containerSizesObject = {
|
|
27
29
|
type: 'object',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContentVariables } from './transformers';
|
|
2
|
+
type WhenValue = string | boolean | undefined;
|
|
3
|
+
type OrArray<T> = T | T[];
|
|
4
|
+
type OrArrayRecord<T> = Record<string, OrArray<T>>;
|
|
5
|
+
interface FilteredContentItem extends OrArrayRecord<FilteredContentItem> {
|
|
6
|
+
}
|
|
7
|
+
type FilteredContent = OrArray<FilteredContentItem>;
|
|
8
|
+
type FilterableContentItem = FilteredContentItem & {
|
|
9
|
+
when: WhenValue;
|
|
10
|
+
};
|
|
11
|
+
export type FilterableContent = OrArray<FilterableContentItem>;
|
|
12
|
+
/**
|
|
13
|
+
* Filters content recoursively by result of it's 'when' property evaluation applied to vars argument.
|
|
14
|
+
* e.g. property {..., when: 'someVar == "someValue"' } will be included in result only if vars.someVar === 'someValue'
|
|
15
|
+
* @param {FilterableContent} content
|
|
16
|
+
* @param {ContentVariables} vars
|
|
17
|
+
* @return {FilteredContent}
|
|
18
|
+
*/
|
|
19
|
+
export declare function filterContent(content: FilterableContent | FilteredContent, vars: ContentVariables): FilteredContent;
|
|
20
|
+
export {};
|