@splunk/react-page 6.2.0 → 6.3.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/CHANGELOG.md +5 -0
- package/lib/index.js +74 -24
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
Change Log
|
|
2
2
|
============
|
|
3
3
|
|
|
4
|
+
6.3.0 - August 1, 2023
|
|
5
|
+
----------
|
|
6
|
+
New Features:
|
|
7
|
+
* `options.onLayoutComplete` parameter supports a callback function which executes after layout API is fetched and compiled.
|
|
8
|
+
|
|
4
9
|
6.2.0 - July 27, 2023
|
|
5
10
|
----------
|
|
6
11
|
New Features:
|
package/lib/index.js
CHANGED
|
@@ -107,19 +107,19 @@ module.exports = require("styled-components");
|
|
|
107
107
|
/* 3 */
|
|
108
108
|
/***/ (function(module, exports) {
|
|
109
109
|
|
|
110
|
-
module.exports = require("
|
|
110
|
+
module.exports = require("prop-types");
|
|
111
111
|
|
|
112
112
|
/***/ }),
|
|
113
113
|
/* 4 */
|
|
114
114
|
/***/ (function(module, exports) {
|
|
115
115
|
|
|
116
|
-
module.exports = require("
|
|
116
|
+
module.exports = require("@splunk/themes/SplunkThemeProvider");
|
|
117
117
|
|
|
118
118
|
/***/ }),
|
|
119
119
|
/* 5 */
|
|
120
120
|
/***/ (function(module, exports) {
|
|
121
121
|
|
|
122
|
-
module.exports = require("
|
|
122
|
+
module.exports = require("react-dom");
|
|
123
123
|
|
|
124
124
|
/***/ }),
|
|
125
125
|
/* 6 */
|
|
@@ -159,13 +159,13 @@ module.exports = require("@splunk/ui-utils/i18n");
|
|
|
159
159
|
// ESM COMPAT FLAG
|
|
160
160
|
__webpack_require__.r(__webpack_exports__);
|
|
161
161
|
|
|
162
|
+
// EXTERNAL MODULE: external "react-dom"
|
|
163
|
+
var external_react_dom_ = __webpack_require__(5);
|
|
164
|
+
|
|
162
165
|
// EXTERNAL MODULE: external "react"
|
|
163
166
|
var external_react_ = __webpack_require__(0);
|
|
164
167
|
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
165
168
|
|
|
166
|
-
// EXTERNAL MODULE: external "react-dom"
|
|
167
|
-
var external_react_dom_ = __webpack_require__(3);
|
|
168
|
-
|
|
169
169
|
// EXTERNAL MODULE: external "scriptjs"
|
|
170
170
|
var external_scriptjs_ = __webpack_require__(6);
|
|
171
171
|
var external_scriptjs_default = /*#__PURE__*/__webpack_require__.n(external_scriptjs_);
|
|
@@ -177,7 +177,7 @@ var Layer_ = __webpack_require__(7);
|
|
|
177
177
|
var url_ = __webpack_require__(8);
|
|
178
178
|
|
|
179
179
|
// EXTERNAL MODULE: external "@splunk/themes/SplunkThemeProvider"
|
|
180
|
-
var SplunkThemeProvider_ = __webpack_require__(
|
|
180
|
+
var SplunkThemeProvider_ = __webpack_require__(4);
|
|
181
181
|
var SplunkThemeProvider_default = /*#__PURE__*/__webpack_require__.n(SplunkThemeProvider_);
|
|
182
182
|
|
|
183
183
|
// EXTERNAL MODULE: external "styled-components"
|
|
@@ -271,7 +271,7 @@ var Dot = external_styled_components_default.a.div(_templateObject6(), blink, th
|
|
|
271
271
|
}));
|
|
272
272
|
|
|
273
273
|
// EXTERNAL MODULE: external "prop-types"
|
|
274
|
-
var external_prop_types_ = __webpack_require__(
|
|
274
|
+
var external_prop_types_ = __webpack_require__(3);
|
|
275
275
|
var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_);
|
|
276
276
|
|
|
277
277
|
// EXTERNAL MODULE: external "@splunk/react-ui/ScreenReaderContent"
|
|
@@ -314,7 +314,7 @@ function Loading(_ref) {
|
|
|
314
314
|
Loading.propTypes = propTypes;
|
|
315
315
|
Loading.defaultProps = defaultProps;
|
|
316
316
|
/* harmony default export */ var src_Loading = (Loading);
|
|
317
|
-
// CONCATENATED MODULE: ./src/
|
|
317
|
+
// CONCATENATED MODULE: ./src/baseLayout.jsx
|
|
318
318
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
319
319
|
|
|
320
320
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -326,7 +326,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
326
326
|
|
|
327
327
|
|
|
328
328
|
|
|
329
|
-
|
|
330
329
|
var LIGHT_LAYOUT = 'build/api/layout.js';
|
|
331
330
|
var DARK_LAYOUT = 'build/api/layout-dark.js';
|
|
332
331
|
var HEADER_SELECTOR = 'header[data-view="splunkjs/mvc/headerview"]';
|
|
@@ -366,6 +365,7 @@ function getLayoutApi(theme, callback) {
|
|
|
366
365
|
* renders body element and attaches it to container node in DOM
|
|
367
366
|
*
|
|
368
367
|
* @param {element} element
|
|
368
|
+
* @param {element} render - A render function that returns an unmount() function.
|
|
369
369
|
* @param {HTMLDivElement} container
|
|
370
370
|
* @param {boolean} useGlobalLayerStack
|
|
371
371
|
* @param {object} splunkTheme
|
|
@@ -373,16 +373,17 @@ function getLayoutApi(theme, callback) {
|
|
|
373
373
|
*/
|
|
374
374
|
|
|
375
375
|
|
|
376
|
-
function renderBody(element, container) {
|
|
377
|
-
var useGlobalLayerStack = arguments.length >
|
|
378
|
-
var splunkTheme = arguments.length >
|
|
376
|
+
function renderBody(element, render, container) {
|
|
377
|
+
var useGlobalLayerStack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
378
|
+
var splunkTheme = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
379
379
|
var wrappedElement = useGlobalLayerStack ? /*#__PURE__*/external_react_default.a.createElement(Layer_["LayerStackGlobalProvider"], null, /*#__PURE__*/external_react_default.a.createElement(SplunkThemeProvider_default.a, splunkTheme, element)) : /*#__PURE__*/external_react_default.a.createElement(SplunkThemeProvider_default.a, splunkTheme, element);
|
|
380
|
-
|
|
380
|
+
return render(wrappedElement, container);
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
383
|
* Renders a React element into the Layout API.
|
|
384
384
|
* @public
|
|
385
385
|
* @param {element} element - A React element.
|
|
386
|
+
* @param {element} render - A render function that returns an unmount() function.
|
|
386
387
|
* @param {object} [options]
|
|
387
388
|
* @param {string} [options.pageTitle] - Changes the page title.
|
|
388
389
|
* @param {Boolean} [options.hideAppBar = false] - Hides the app bar.
|
|
@@ -401,11 +402,12 @@ function renderBody(element, container) {
|
|
|
401
402
|
* @param {Boolean} [options.lazyLoadLayout = false] - Prioritizes loading the React element and lazily fetches and compiles the layout API (navigation bar).
|
|
402
403
|
* @param {element} [options.SplunkBarFallback = SplunkBar] - A React element used as a placeholder for the splunk bar while the navigation bar is loading.
|
|
403
404
|
* @param {element} [options.AppBarFallback = AppBar] - A React element used as a placeholder for the app bar while the navigation bar is loading.
|
|
405
|
+
* @param {function} [options.onLayoutComplete] - A callback function which executes after layout API is fetched and compiled.
|
|
404
406
|
*/
|
|
405
407
|
|
|
406
408
|
|
|
407
|
-
function layout(element) {
|
|
408
|
-
var _ref2 = arguments.length >
|
|
409
|
+
function layout(element, render) {
|
|
410
|
+
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
409
411
|
|
|
410
412
|
var _ref2$useGlobalLayerS = _ref2.useGlobalLayerStack,
|
|
411
413
|
useGlobalLayerStack = _ref2$useGlobalLayerS === void 0 ? true : _ref2$useGlobalLayerS,
|
|
@@ -428,7 +430,8 @@ function layout(element) {
|
|
|
428
430
|
_layoutAPIOptions$App = layoutAPIOptions.AppBarFallback,
|
|
429
431
|
AppBarFallback = _layoutAPIOptions$App === void 0 ? AppBar : _layoutAPIOptions$App,
|
|
430
432
|
_layoutAPIOptions$laz = layoutAPIOptions.lazyLoadLayout,
|
|
431
|
-
lazyLoadLayout = _layoutAPIOptions$laz === void 0 ? false : _layoutAPIOptions$laz
|
|
433
|
+
lazyLoadLayout = _layoutAPIOptions$laz === void 0 ? false : _layoutAPIOptions$laz,
|
|
434
|
+
onLayoutComplete = layoutAPIOptions.onLayoutComplete;
|
|
432
435
|
var bodyContainer = document.createElement('div');
|
|
433
436
|
var headerContainer = document.createElement('div'); // The "theme" in enterprise used to be "enterprise" instead of "light"...
|
|
434
437
|
|
|
@@ -438,19 +441,21 @@ function layout(element) {
|
|
|
438
441
|
colorScheme: colorScheme,
|
|
439
442
|
density: 'comfortable'
|
|
440
443
|
};
|
|
444
|
+
var bodyRoot;
|
|
445
|
+
var headerRoot;
|
|
441
446
|
|
|
442
447
|
if (lazyLoadLayout) {
|
|
443
448
|
// render the React app immediately without waiting for layout API
|
|
444
449
|
document.body.appendChild(headerContainer);
|
|
445
|
-
|
|
450
|
+
headerRoot = render( /*#__PURE__*/external_react_default.a.createElement(external_react_default.a.Fragment, null, !hideChrome && !hideSplunkBar && /*#__PURE__*/external_react_default.a.createElement(SplunkBarFallback, null), !hideChrome && !hideAppBar && /*#__PURE__*/external_react_default.a.createElement(AppBarFallback, null)), headerContainer); // explicitly set height of header container to avoid layout shift when fallback gets replaced
|
|
446
451
|
|
|
447
452
|
var headerHeight = headerContainer.offsetHeight;
|
|
448
453
|
headerContainer.style.cssText = "height: ".concat(headerHeight, "px");
|
|
449
454
|
document.body.appendChild(bodyContainer);
|
|
450
|
-
renderBody(element, bodyContainer, useGlobalLayerStack, splunkTheme);
|
|
455
|
+
bodyRoot = renderBody(element, render, bodyContainer, useGlobalLayerStack, splunkTheme);
|
|
451
456
|
} else {
|
|
452
457
|
document.body.appendChild(bodyContainer);
|
|
453
|
-
|
|
458
|
+
bodyRoot = render( /*#__PURE__*/external_react_default.a.createElement(SplunkThemeProvider_default.a, splunkTheme, /*#__PURE__*/external_react_default.a.createElement(src_Loading, layoutAPIOptions)), bodyContainer);
|
|
454
459
|
}
|
|
455
460
|
|
|
456
461
|
getLayoutApi(theme, function (layoutApi) {
|
|
@@ -488,17 +493,19 @@ function layout(element) {
|
|
|
488
493
|
|
|
489
494
|
if (lazyLoadLayout) {
|
|
490
495
|
// replace placeholder nav bar with real nav bar
|
|
491
|
-
|
|
496
|
+
headerRoot.unmount(headerContainer);
|
|
492
497
|
var header = document.querySelector(HEADER_SELECTOR);
|
|
493
498
|
var containerHeight = (!hideChrome && !hideSplunkBar ? SPLUNKBAR_HEIGHT : 0) + (!hideChrome && !hideAppBar ? APPBAR_HEIGHT : 0);
|
|
494
499
|
headerContainer.style.cssText = "height: ".concat(containerHeight, "px");
|
|
495
500
|
headerContainer.appendChild(header);
|
|
496
501
|
containerEl.appendChild(bodyContainer);
|
|
502
|
+
onLayoutComplete === null || onLayoutComplete === void 0 ? void 0 : onLayoutComplete();
|
|
497
503
|
} else {
|
|
498
504
|
setTimeout(function () {
|
|
499
|
-
|
|
500
|
-
renderBody(element, bodyContainer, useGlobalLayerStack, splunkTheme);
|
|
505
|
+
bodyRoot.unmount(bodyContainer);
|
|
506
|
+
bodyRoot = renderBody(element, render, bodyContainer, useGlobalLayerStack, splunkTheme);
|
|
501
507
|
containerEl.appendChild(bodyContainer);
|
|
508
|
+
onLayoutComplete === null || onLayoutComplete === void 0 ? void 0 : onLayoutComplete();
|
|
502
509
|
}, 30);
|
|
503
510
|
}
|
|
504
511
|
}, {
|
|
@@ -506,7 +513,50 @@ function layout(element) {
|
|
|
506
513
|
});
|
|
507
514
|
}
|
|
508
515
|
|
|
509
|
-
/* harmony default export */ var
|
|
516
|
+
/* harmony default export */ var baseLayout = (layout);
|
|
517
|
+
// CONCATENATED MODULE: ./src/index.jsx
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
var src_renderShim = function renderShim(elementToRender, container) {
|
|
522
|
+
Object(external_react_dom_["render"])(elementToRender, container);
|
|
523
|
+
return {
|
|
524
|
+
unmount: function unmount() {
|
|
525
|
+
return Object(external_react_dom_["unmountComponentAtNode"])(container);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Renders a React element into the Layout API.
|
|
531
|
+
* @public
|
|
532
|
+
* @param {element} element - A React element.
|
|
533
|
+
* @param {object} [options]
|
|
534
|
+
* @param {string} [options.pageTitle] - Changes the page title.
|
|
535
|
+
* @param {Boolean} [options.hideAppBar = false] - Hides the app bar.
|
|
536
|
+
* @param {Boolean} [options.hideAppsList = false] - Hides the app list in
|
|
537
|
+
* the Splunk bar.
|
|
538
|
+
* @param {Boolean} [options.hideChrome = false] - Renders only the main content, hiding
|
|
539
|
+
* the Splunk bar, app bar, and footer.
|
|
540
|
+
* @param {Boolean} [options.hideFooter = false] - Hides the footer.
|
|
541
|
+
* @param {Boolean} [options.hideSplunkBar = false] - Hides the Splunk bar.
|
|
542
|
+
* @param {string} [options.layout = 'scrolling'] - Set to `fixed` to fix all navigation bars
|
|
543
|
+
* to the edge of the page.
|
|
544
|
+
* @param {Boolean} [options.useGlobalLayerStack = true] - Wraps elements in @splunk/react-ui's LayerStackGlobalProvider.
|
|
545
|
+
* @param {String} [options.theme = 'light'] - Used to theme UI elements. Ex. "light" or "dark".
|
|
546
|
+
* @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
|
|
547
|
+
* Change this only if the default loader does not work for your application.
|
|
548
|
+
* @param {Boolean} [options.lazyLoadLayout = false] - Prioritizes loading the React element and lazily fetches and compiles the layout API (navigation bar).
|
|
549
|
+
* @param {element} [options.SplunkBarFallback = SplunkBar] - A React element used as a placeholder for the splunk bar while the navigation bar is loading.
|
|
550
|
+
* @param {element} [options.AppBarFallback = AppBar] - A React element used as a placeholder for the app bar while the navigation bar is loading.
|
|
551
|
+
* @param {function} [options.onLayoutComplete] - A callback function which executes after layout API is fetched and compiled.
|
|
552
|
+
*/
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
function src_layout(element, options) {
|
|
556
|
+
baseLayout(element, src_renderShim, options);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/* harmony default export */ var src = __webpack_exports__["default"] = (src_layout);
|
|
510
560
|
|
|
511
561
|
/***/ })
|
|
512
562
|
/******/ ]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splunk/react-page",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "Load React components into the latest layout from Splunk Enterprise",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test:cypress:ci": "node src/tests/run-cypress-tests.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@splunk/react-ui": "^4.
|
|
25
|
+
"@splunk/react-ui": "^4.19.0",
|
|
26
26
|
"@splunk/splunk-utils": "^2.3.4",
|
|
27
27
|
"@splunk/themes": "^0.16.1",
|
|
28
28
|
"@splunk/ui-utils": "^1.6.0",
|