1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _propTypes = require("prop-types");
|
8 |
|
9 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
10 |
|
11 | var _AbstractPureComponent = require("./AbstractPureComponent");
|
12 |
|
13 | var _AbstractPureComponent2 = _interopRequireDefault(_AbstractPureComponent);
|
14 |
|
15 | var _MetaManager = require("../meta/MetaManager");
|
16 |
|
17 | var _MetaManager2 = _interopRequireDefault(_MetaManager);
|
18 |
|
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20 |
|
21 | const PRIVATE = {
|
22 | masterElementId: Symbol('masterElementId')
|
23 | };
|
24 |
|
25 | if (typeof $Debug !== 'undefined' && $Debug) {
|
26 | Object.freeze(PRIVATE);
|
27 | } // @server-side class AbstractDocumentView extends __VARIABLE__ {__CLEAR__}\nexports.default = AbstractDocumentView;
|
28 |
|
29 | /**
|
30 | * The base class for document view components. The document view components
|
31 | * create the basic markup, i.e. the {@code html} or {@code head} elements,
|
32 | * along with an element that will contain the view associated with the current
|
33 | * route.
|
34 | *
|
35 | * Note that the document views are always rendered only at the server-side and
|
36 | * cannot be switched at the client-side. Because of this, the document view
|
37 | * component must be pure and cannot contain a state.
|
38 | *
|
39 | * @abstract
|
40 | */
|
41 |
|
42 |
|
43 | class AbstractDocumentView extends _AbstractPureComponent2.default {
|
44 | /**
|
45 | * Returns the ID of the element (the value of the {@code id} attribute)
|
46 | * generated by this component that will contain the rendered page view.
|
47 | *
|
48 | * @abstract
|
49 | * @return {string} The ID of the element generated by this component that
|
50 | * will contain the rendered page view.
|
51 | */
|
52 | static get masterElementId() {
|
53 | if (this[PRIVATE.masterElementId] !== undefined) {
|
54 | return this[PRIVATE.masterElementId];
|
55 | }
|
56 |
|
57 | throw new Error('The masterElementId getter is abstract and must be overridden');
|
58 | }
|
59 | /**
|
60 | * Setter for the ID of the element (the value of the {@code id} attribute)
|
61 | * generated by this component that will contain the rendered page view.
|
62 | *
|
63 | * This setter is used only for compatibility with the public class fields
|
64 | * and can only be used once per component.
|
65 | *
|
66 | * @param {string} masterElementId The ID of the element generated by this
|
67 | * component that will contain the rendered page view.
|
68 | */
|
69 |
|
70 |
|
71 | static set masterElementId(masterElementId) {
|
72 | if ($Debug) {
|
73 | if (this[PRIVATE.masterElementId] !== undefined) {
|
74 | throw new Error('The masterElementId can be set only once and cannot be ' + 'reconfigured');
|
75 | }
|
76 | }
|
77 |
|
78 | this[PRIVATE.masterElementId] = masterElementId;
|
79 | }
|
80 | /**
|
81 | * Returns the expected types of the props passed to this component.
|
82 | *
|
83 | * The {@code metaManager} is used to generate the {@code meta} tags in the
|
84 | * {@code head} and the content of the {@code title} element. The
|
85 | * {@code page} contains the rendered HTML of the current view. The
|
86 | * {@code revivalSettings} contains a JavaScript snippet that initializes
|
87 | * the configuration of the IMA platform at the client-side.
|
88 | *
|
89 | * @return {{metaManager: *, page: *, revivalSettings: *}} The expected
|
90 | * types of the props passed to this component.
|
91 | */
|
92 |
|
93 |
|
94 | static get propTypes() {
|
95 | return {
|
96 | metaManager: _propTypes2.default.instanceOf(_MetaManager2.default).isRequired,
|
97 | page: _propTypes2.default.string.isRequired,
|
98 | revivalSettings: _propTypes2.default.string.isRequired,
|
99 | $Utils: _propTypes2.default.object.isRequired
|
100 | };
|
101 | }
|
102 | /**
|
103 | * @inheritdoc
|
104 | */
|
105 |
|
106 |
|
107 | static get contextTypes() {
|
108 | return {};
|
109 | }
|
110 |
|
111 | }
|
112 |
|
113 | exports.default = AbstractDocumentView;
|
114 |
|
115 | typeof $IMA !== 'undefined' && $IMA !== null && $IMA.Loader && $IMA.Loader.register('ima/page/AbstractDocumentView', [], function (_export, _context) {
|
116 | ;
|
117 | return {
|
118 | setters: [],
|
119 | execute: function () {
|
120 | _export('default', exports.default);
|
121 | }
|
122 | };
|
123 | });
|