@splunk/react-page 7.0.0 → 8.0.0-beta.2

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.
@@ -61,10 +61,10 @@
61
61
  e.r(n);
62
62
  // EXPORTS
63
63
  e.d(n, {
64
- default: () => /* binding */ X
64
+ default: () => /* binding */ W
65
65
  });
66
- // CONCATENATED MODULE: external "react-dom"
67
- const r = require("react-dom");
66
+ // CONCATENATED MODULE: external "react-dom/client"
67
+ const r = require("react-dom/client");
68
68
  // CONCATENATED MODULE: external "react"
69
69
  const t = require("react");
70
70
  var a = e.n(t);
@@ -127,95 +127,79 @@
127
127
  return e;
128
128
  }
129
129
  function k(e, n) {
130
- if (!n) {
131
- n = e.slice(0);
132
- }
133
- return Object.freeze(Object.defineProperties(e, {
130
+ return n || (n = e.slice(0)), Object.freeze(Object.defineProperties(e, {
134
131
  raw: {
135
132
  value: Object.freeze(n)
136
133
  }
137
134
  }));
138
135
  }
139
136
  var S = 45;
140
- var j = 34;
141
- var w = (0, p.keyframes)(g());
142
- var E = s().div(y(), v.variables.backgroundColorPage);
137
+ var w = 34;
138
+ var E = (0, p.keyframes)(g());
139
+ var j = s().div(y(), v.variables.backgroundColorPage);
143
140
  var C = s().div(b(), (0, v.pick)({
144
141
  prisma: v.variables.backgroundColorSection,
145
142
  enterprise: v.variables.gray20
146
- }), j);
147
- var B = s().div(h(), (0, v.pick)({
143
+ }), w);
144
+ var q = s().div(h(), (0, v.pick)({
148
145
  prisma: v.variables.backgroundColorPopup,
149
146
  enterprise: v.variables.gray30
150
147
  }), S);
151
148
  var x = s().div(m(), v.variables.contentColorInverted);
152
- var q = s().div(f(), w, v.variables.neutral500, (0, v.pick)({
149
+ var B = s().div(f(), E, v.variables.neutral500, (0, v.pick)({
153
150
  prisma: v.variables.spacingMedium,
154
- enterprise: v.variables.spacingHalf
151
+ enterprise: v.variables.spacingSmall
155
152
  }));
156
153
  // CONCATENATED MODULE: external "prop-types"
157
154
  const O = require("prop-types");
158
- var A = e.n(O);
155
+ var P = e.n(O);
159
156
  // CONCATENATED MODULE: external "@splunk/react-ui/ScreenReaderContent"
160
- const P = require("@splunk/react-ui/ScreenReaderContent");
161
- var F = e.n(P);
157
+ const L = require("@splunk/react-ui/ScreenReaderContent");
158
+ var _ = e.n(L);
162
159
  // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
163
- const _ = require("@splunk/ui-utils/i18n");
160
+ const A = require("@splunk/ui-utils/i18n");
164
161
  // CONCATENATED MODULE: ./src/Loading.jsx
165
- var L = {
166
- hideAppBar: A().bool,
167
- hideChrome: A().bool,
168
- hideSplunkBar: A().bool,
169
- AppBarFallback: A().elementType,
170
- SplunkBarFallback: A().elementType
171
- };
172
- var T = {
173
- hideAppBar: false,
174
- hideChrome: false,
175
- hideSplunkBar: false,
176
- AppBarFallback: B,
177
- SplunkBarFallback: C
162
+ var F = {
163
+ hideAppBar: P().bool,
164
+ hideChrome: P().bool,
165
+ hideSplunkBar: P().bool,
166
+ AppBarFallback: P().elementType,
167
+ SplunkBarFallback: P().elementType
178
168
  };
179
- function H(e) {
180
- var n = e.hideAppBar, r = e.hideChrome, t = e.hideSplunkBar, i = e.SplunkBarFallback, o = e.AppBarFallback;
169
+ function T(e) {
170
+ var n = e.AppBarFallback, r = n === void 0 ? q : n, t = e.hideAppBar, i = e.hideChrome, o = e.hideSplunkBar, l = e.SplunkBarFallback, u = l === void 0 ? C : l;
181
171
 
182
- return a().createElement(E, null, !r && !t && a().createElement(i, null), !r && !n && a().createElement(o, null), a().createElement(x, null, a().createElement(q, null), a().createElement(q, null), a().createElement(q, null), a().createElement(F(), null, (0,
183
- _._)("Loading"))));
172
+ return a().createElement(j, null, !i && !o && a().createElement(u, null), !i && !t && a().createElement(r, null), a().createElement(x, null, a().createElement(B, null), a().createElement(B, null), a().createElement(B, null), a().createElement(_(), null, (0,
173
+ A._)("Loading"))));
184
174
  }
185
- H.propTypes = L;
186
- H.defaultProps = T;
187
- /* harmony default export */ const M = H;
175
+ T.propTypes = F;
176
+ /* harmony default export */ const H = T;
188
177
  // CONCATENATED MODULE: ./src/baseLayout.jsx
189
- function z(e, n) {
190
- if (e == null) return {};
191
- var r = G(e, n);
192
- var t, a;
178
+ function M(e, n) {
179
+ if (null == e) return {};
180
+ var r, t, a = z(e, n);
193
181
  if (Object.getOwnPropertySymbols) {
194
182
  var i = Object.getOwnPropertySymbols(e);
195
- for (a = 0; a < i.length; a++) {
196
- t = i[a];
197
- if (n.indexOf(t) >= 0) continue;
198
- if (!Object.prototype.propertyIsEnumerable.call(e, t)) continue;
199
- r[t] = e[t];
183
+ for (t = 0; t < i.length; t++) {
184
+ r = i[t], n.includes(r) || {}.propertyIsEnumerable.call(e, r) && (a[r] = e[r]);
200
185
  }
201
186
  }
202
- return r;
187
+ return a;
203
188
  }
204
- function G(e, n) {
205
- if (e == null) return {};
189
+ function z(e, n) {
190
+ if (null == e) return {};
206
191
  var r = {};
207
- var t = Object.keys(e);
208
- var a, i;
209
- for (i = 0; i < t.length; i++) {
210
- a = t[i];
211
- if (n.indexOf(a) >= 0) continue;
212
- r[a] = e[a];
192
+ for (var t in e) {
193
+ if ({}.hasOwnProperty.call(e, t)) {
194
+ if (n.includes(t)) continue;
195
+ r[t] = e[t];
196
+ }
213
197
  }
214
198
  return r;
215
199
  }
216
- var I = "build/api/layout.js";
217
- var R = "build/api/layout-dark.js";
218
- var U = 'header[data-view="splunkjs/mvc/headerview"]';
200
+ var G = "build/api/layout.js";
201
+ var I = "build/api/layout-dark.js";
202
+ var R = 'header[data-view="splunkjs/mvc/headerview"]';
219
203
  /**
220
204
  * Loads the layout from the server, using requirejs if available on the window and scriptjs if not.
221
205
  *
@@ -223,9 +207,9 @@
223
207
  * @param {object} [options]
224
208
  * @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
225
209
  * @private
226
- */ function N(e, n) {
210
+ */ function U(e, n) {
227
211
  var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, t = r.loader, a = t === void 0 ? "scriptjs" : t;
228
- var i = e === "dark" ? R : I;
212
+ var i = e === "dark" ? I : G;
229
213
  var l = (0, u.createStaticURL)(i);
230
214
  if (a === "scriptjs") {
231
215
  o()(l, (function() {
@@ -304,46 +288,50 @@
304
288
  * @param {function} [options.onLayoutComplete] - A callback function which executes after layout API is fetched and compiled.
305
289
  */ function K(e, n) {
306
290
  var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
307
- var t = r.useGlobalLayerStack, i = t === void 0 ? true : t, o = r.pageTitle, l = r.theme, u = l === void 0 ? "light" : l, c = r.loader, p = c === void 0 ? "scriptjs" : c, s = z(r, [ "useGlobalLayerStack", "pageTitle", "theme", "loader" ]);
291
+ var t = r.useGlobalLayerStack, i = t === void 0 ? true : t, o = r.pageTitle, l = r.theme, u = l === void 0 ? "light" : l, c = r.loader, p = c === void 0 ? "scriptjs" : c, s = M(r, [ "useGlobalLayerStack", "pageTitle", "theme", "loader" ]);
308
292
  if (o) {
309
293
  document.title = o;
310
294
  }
311
- var v = s.hideChrome, f = s.hideAppBar, m = s.hideSplunkBar, h = s.SplunkBarFallback, b = h === void 0 ? C : h, y = s.AppBarFallback, g = y === void 0 ? B : y, k = s.lazyLoadLayout, w = k === void 0 ? false : k, E = s.onLayoutComplete;
312
- var x = document.createElement("div");
313
- var q = document.createElement("div");
314
- // The "theme" in enterprise used to be "enterprise" instead of "light"...
315
- var O = u === "light" || u === "enterprise" ? "light" : "dark";
316
- var A = {
295
+ var v = s.hideChrome, f = s.hideAppBar, m = s.hideSplunkBar, h = s.SplunkBarFallback, b = h === void 0 ? C : h, y = s.AppBarFallback, g = y === void 0 ? q : y, k = s.lazyLoadLayout, E = k === void 0 ? false : k, j = s.onLayoutComplete, x = s.onLayoutStart;
296
+ var B = document.createElement("div");
297
+ var O = document.createElement("div");
298
+ x === null || x === void 0 ? void 0 : x({
299
+ headerContainer: O,
300
+ bodyContainer: B
301
+ });
302
+ // The "theme" in enterprise used to be "enterprise" instead of "light"...
303
+ var P = u === "light" || u === "enterprise" ? "light" : "dark";
304
+ var L = {
317
305
  family: "enterprise",
318
- colorScheme: O,
306
+ colorScheme: P,
319
307
  density: "comfortable"
320
308
  };
321
- var P;
322
- var F;
323
- if (w) {
309
+ var _;
310
+ var A;
311
+ if (E) {
324
312
  // render the React app immediately without waiting for layout API
325
313
  if (!v) {
326
- document.body.appendChild(q);
327
- F = n( a().createElement(a().Fragment, null, !m && a().createElement(b, null), !f && a().createElement(g, null)), q);
328
- // explicitly set height and background of header container to avoid layout and color shift when fallback gets replaced
329
- var _ = q.offsetHeight;
330
- var L = D(q, {
314
+ document.body.appendChild(O);
315
+ A = n( a().createElement(a().Fragment, null, !m && a().createElement(b, null), !f && a().createElement(g, null)), O);
316
+ // explicitly set height and background of header container to avoid layout and color shift when fallback gets replaced
317
+ var F = O.offsetHeight;
318
+ var T = D(O, {
331
319
  hideSplunkBar: m,
332
320
  hideAppBar: f,
333
- headerHeight: _,
321
+ headerHeight: F,
334
322
  AppBarFallback: g,
335
323
  SplunkBarFallback: b
336
324
  });
337
- q.style.height = "".concat(_, "px");
338
- q.style.background = "".concat(L);
325
+ O.style.height = "".concat(F, "px");
326
+ O.style.background = "".concat(T);
339
327
  }
340
- document.body.appendChild(x);
341
- P = J(e, n, x, i, A);
328
+ document.body.appendChild(B);
329
+ _ = J(e, n, B, i, L);
342
330
  } else {
343
- document.body.appendChild(x);
344
- P = n( a().createElement(d(), A, a().createElement(M, s)), x);
331
+ document.body.appendChild(B);
332
+ _ = n( a().createElement(d(), L, a().createElement(H, s)), B);
345
333
  }
346
- N(u, (function(r) {
334
+ U(u, (function(r) {
347
335
  var t;
348
336
  if (r) {
349
337
  t = r.create(s).getContainerElement();
@@ -354,12 +342,12 @@
354
342
  if (!t.style.flex || t.style.flex === "1 0 0px") {
355
343
  t.style.flex = "1 0 0%";
356
344
  }
357
- // all elements in the hierarchy must have 'overflow: hidden' for children
345
+ // all elements in the hierarchy must have 'overflow: hidden' for children
358
346
  // to support scrolling correctly.
359
347
  if (!t.style.overflow) {
360
348
  t.style.overflow = "hidden";
361
349
  }
362
- // splunk hijacks the width of the body when printing, so we have to force width to the size
350
+ // splunk hijacks the width of the body when printing, so we have to force width to the size
363
351
  // of the viewport so that things print at the correct width
364
352
  if (!t.style.width) {
365
353
  t.style.width = "100vw";
@@ -371,40 +359,37 @@
371
359
  t = document.createElement("div");
372
360
  document.body.appendChild(t);
373
361
  }
374
- if (w) {
362
+ if (E) {
375
363
  if (!v) {
376
364
  // replace placeholder nav bar with real nav bar
377
- F.unmount(q);
378
- var a = document.querySelector(U);
379
- var o = (!v && !m ? j : 0) + (!v && !f ? S : 0);
380
- // set a min-height for basic nav bar components and auto height for any additional components like global banner
381
- q.style.minHeight = "".concat(o, "px");
382
- q.style.height = "auto";
383
- q.appendChild(a);
365
+ A.unmount(O);
366
+ var a = document.querySelector(R);
367
+ var o = (!v && !m ? w : 0) + (!v && !f ? S : 0);
368
+ // set a min-height for basic nav bar components and auto height for any additional components like global banner
369
+ O.style.minHeight = "".concat(o, "px");
370
+ O.style.height = "auto";
371
+ O.appendChild(a);
384
372
  }
385
- t.appendChild(x);
386
- E === null || E === void 0 ? void 0 : E();
373
+ t.appendChild(B);
374
+ j === null || j === void 0 ? void 0 : j();
387
375
  } else {
388
376
  setTimeout((function() {
389
- P.unmount(x);
390
- P = J(e, n, x, i, A);
391
- t.appendChild(x);
392
- E === null || E === void 0 ? void 0 : E();
377
+ _.unmount(B);
378
+ _ = J(e, n, B, i, L);
379
+ t.appendChild(B);
380
+ j === null || j === void 0 ? void 0 : j();
393
381
  }), 30);
394
382
  }
395
383
  }), {
396
384
  loader: p
397
385
  });
398
386
  }
399
- /* harmony default export */ const Q = K;
400
- // CONCATENATED MODULE: ./src/index.jsx
401
- var V = function e(n, t) {
402
- (0, r.render)(n, t);
403
- return {
404
- unmount: function e() {
405
- return (0, r.unmountComponentAtNode)(t);
406
- }
407
- };
387
+ /* harmony default export */ const N = K;
388
+ // CONCATENATED MODULE: ./src/18.jsx
389
+ var Q = function e(n, t) {
390
+ var a = (0, r.createRoot)(t);
391
+ a.render(n);
392
+ return a;
408
393
  };
409
394
  /**
410
395
  * Renders a React element into the Layout API.
@@ -429,9 +414,9 @@
429
414
  * @param {element} [options.SplunkBarFallback = SplunkBar] - A React element used as a placeholder for the splunk bar while the navigation bar is loading.
430
415
  * @param {element} [options.AppBarFallback = AppBar] - A React element used as a placeholder for the app bar while the navigation bar is loading.
431
416
  * @param {function} [options.onLayoutComplete] - A callback function which executes after layout API is fetched and compiled.
432
- */ function W(e, n) {
433
- Q(e, V, n);
417
+ */ function V(e, n) {
418
+ N(e, Q, n);
434
419
  }
435
- /* harmony default export */ const X = W;
420
+ /* harmony default export */ const W = V;
436
421
  module.exports = n;
437
422
  /******/})();
package/CHANGELOG.md CHANGED
@@ -1,9 +1,30 @@
1
1
  Change Log
2
2
  ============
3
3
 
4
+ 8.0.0-beta.2 - March 5, 2025
5
+ ----------
6
+ * Public release of `8.0.0-beta.1`
7
+
8
+ 8.0.0-beta.1 - February 20, 2025
9
+ ----------
10
+ New Features:
11
+ * Added support for using the `createRoot` API if the consuming application is using `react-dom@18`.
12
+
13
+ API Changes:
14
+ * `react` and `react-dom` peer dependencies are now `"^16.8.0 || ^17.0.0 || ^18.0.0"`.
15
+
16
+ 7.1.0 - July 8, 2024
17
+ ----------
18
+ New Features:
19
+ * Added a new `onLayoutStart` callback (SPL-254150).
20
+ * `AppBar` and `SplunkBar` default placeholder elements are now exported (SPL-254150).
21
+
22
+ API Changes:
23
+ * Internal changes to built output to support multiple exports in future versions. (SUI-6279)
24
+
4
25
  7.0.0 - February 6, 2024
5
26
  ----------
6
- API Changes:
27
+ API Changes:
7
28
  * `@splunk/splunk-utils` dependency has been updated to `3.0.0`.
8
29
  * `3.0.0` no longer supports Search V1 for some endpoints and has had the fallback behavior for older versions of Splunk removed (SUI-5957).
9
30
  * `react-page` does not use these endpoints directly but apps leveraging `react-page` and search endpoints should use search V2. See the `@splunk/splunk-utils` CHANGELOG and [Semantic API Versioning](https://docs.splunk.com/Documentation/Splunk/9.1.2/RESTREF/RESTsearch#Semantic_API_versioning) for more details.
package/README.md CHANGED
@@ -29,3 +29,13 @@ import MyPage from 'pages/MyPage';
29
29
 
30
30
  layout(<MyPage />, { pageTitle: 'A React Page', hideFooter: true, layout: 'fixed' });
31
31
  ```
32
+
33
+ ### React 18
34
+ To use the new [createRoot](https://react.dev/reference/react-dom/client/createRoot#createroot) functionality introducted in React 18, use the `'@splunk/react-page/18'` import instead of `@splunk/react-page`.
35
+
36
+ ```js
37
+ import layout from '@splunk/react-page/18';
38
+ import MyPage from 'pages/MyPage';
39
+
40
+ layout(<MyPage />, { pageTitle: 'A React Page', hideFooter: true, layout: 'fixed' });
41
+ ```
package/index.js ADDED
@@ -0,0 +1,428 @@
1
+ /******/ (() => {
2
+ // webpackBootstrap
3
+ /******/ "use strict";
4
+ /******/ // The require scope
5
+ /******/ var e = {};
6
+ /******/
7
+ /************************************************************************/
8
+ /******/ /* webpack/runtime/compat get default export */
9
+ /******/ (() => {
10
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
11
+ /******/ e.n = n => {
12
+ /******/ var r = n && n.__esModule ?
13
+ /******/ () => n["default"]
14
+ /******/ : () => n
15
+ /******/;
16
+ e.d(r, {
17
+ a: r
18
+ });
19
+ /******/ return r;
20
+ /******/ };
21
+ /******/ })();
22
+ /******/
23
+ /******/ /* webpack/runtime/define property getters */
24
+ /******/ (() => {
25
+ /******/ // define getter functions for harmony exports
26
+ /******/ e.d = (n, r) => {
27
+ /******/ for (var t in r) {
28
+ /******/ if (e.o(r, t) && !e.o(n, t)) {
29
+ /******/ Object.defineProperty(n, t, {
30
+ enumerable: true,
31
+ get: r[t]
32
+ });
33
+ /******/ }
34
+ /******/ }
35
+ /******/ };
36
+ /******/ })();
37
+ /******/
38
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
39
+ /******/ (() => {
40
+ /******/ e.o = (e, n) => Object.prototype.hasOwnProperty.call(e, n)
41
+ /******/;
42
+ })();
43
+ /******/
44
+ /******/ /* webpack/runtime/make namespace object */
45
+ /******/ (() => {
46
+ /******/ // define __esModule on exports
47
+ /******/ e.r = e => {
48
+ /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
49
+ /******/ Object.defineProperty(e, Symbol.toStringTag, {
50
+ value: "Module"
51
+ });
52
+ /******/ }
53
+ /******/ Object.defineProperty(e, "__esModule", {
54
+ value: true
55
+ });
56
+ /******/ };
57
+ /******/ })();
58
+ /******/
59
+ /************************************************************************/ var n = {};
60
+ // ESM COMPAT FLAG
61
+ e.r(n);
62
+ // EXPORTS
63
+ e.d(n, {
64
+ AppBar: () => /* reexport */ y,
65
+ SplunkBar: () => /* reexport */ b,
66
+ default: () => /* binding */ W
67
+ });
68
+ // CONCATENATED MODULE: external "react-dom"
69
+ const r = require("react-dom");
70
+ // CONCATENATED MODULE: external "styled-components"
71
+ const t = require("styled-components");
72
+ var a = e.n(t);
73
+ // CONCATENATED MODULE: external "@splunk/themes"
74
+ const i = require("@splunk/themes");
75
+ // CONCATENATED MODULE: ./src/LoadingStyles.js
76
+ function o() {
77
+ var e = s([ "\n animation-name: ", ";\n animation-duration: 1.4s;\n animation-iteration-count: infinite;\n animation-fill-mode: both;\n background-color: ", ";\n width: 10px;\n height: 10px;\n border-radius: 5px;\n display: inline-block;\n margin-right: ", ";\n\n &:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n &:nth-child(3) {\n animation-delay: 0.4s;\n }\n" ]);
78
+ o = function n() {
79
+ return e;
80
+ };
81
+ return e;
82
+ }
83
+ function l() {
84
+ var e = s([ "\n color: ", ";\n padding-top: 30vh;\n text-align: center;\n min-height: 400px;\n" ]);
85
+ l = function n() {
86
+ return e;
87
+ };
88
+ return e;
89
+ }
90
+ function u() {
91
+ var e = s([ "\n background-color: ", ";\n min-height: ", "px;\n" ]);
92
+ u = function n() {
93
+ return e;
94
+ };
95
+ return e;
96
+ }
97
+ function c() {
98
+ var e = s([ "\n padding: 0;\n background-color: ", ";\n height: ", "px;\n" ]);
99
+ c = function n() {
100
+ return e;
101
+ };
102
+ return e;
103
+ }
104
+ function d() {
105
+ var e = s([ "\n background-color: ", ";\n position: fixed;\n opacity: 1;\n z-index: 10000;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n" ]);
106
+ d = function n() {
107
+ return e;
108
+ };
109
+ return e;
110
+ }
111
+ function p() {
112
+ var e = s([ "\n 0% {\n opacity: 0.2;\n }\n\n 20% {\n opacity: 1;\n }\n\n 100% {\n opacity: 0.2;\n }\n" ]);
113
+ p = function n() {
114
+ return e;
115
+ };
116
+ return e;
117
+ }
118
+ function s(e, n) {
119
+ return n || (n = e.slice(0)), Object.freeze(Object.defineProperties(e, {
120
+ raw: {
121
+ value: Object.freeze(n)
122
+ }
123
+ }));
124
+ }
125
+ var v = 45;
126
+ var f = 34;
127
+ var m = (0, t.keyframes)(p());
128
+ var h = a().div(d(), i.variables.backgroundColorPage);
129
+ var b = a().div(c(), (0, i.pick)({
130
+ prisma: i.variables.backgroundColorSection,
131
+ enterprise: i.variables.gray20
132
+ }), f);
133
+ var y = a().div(u(), (0, i.pick)({
134
+ prisma: i.variables.backgroundColorPopup,
135
+ enterprise: i.variables.gray30
136
+ }), v);
137
+ var g = a().div(l(), i.variables.contentColorInverted);
138
+ var k = a().div(o(), m, i.variables.neutral500, (0, i.pick)({
139
+ prisma: i.variables.spacingMedium,
140
+ enterprise: i.variables.spacingSmall
141
+ }));
142
+ // CONCATENATED MODULE: external "react"
143
+ const S = require("react");
144
+ var w = e.n(S);
145
+ // CONCATENATED MODULE: external "scriptjs"
146
+ const C = require("scriptjs");
147
+ var E = e.n(C);
148
+ // CONCATENATED MODULE: external "@splunk/react-ui/Layer"
149
+ const j = require("@splunk/react-ui/Layer");
150
+ // CONCATENATED MODULE: external "@splunk/splunk-utils/url"
151
+ const B = require("@splunk/splunk-utils/url");
152
+ // CONCATENATED MODULE: external "@splunk/themes/SplunkThemeProvider"
153
+ const q = require("@splunk/themes/SplunkThemeProvider");
154
+ var x = e.n(q);
155
+ // CONCATENATED MODULE: external "prop-types"
156
+ const O = require("prop-types");
157
+ var P = e.n(O);
158
+ // CONCATENATED MODULE: external "@splunk/react-ui/ScreenReaderContent"
159
+ const A = require("@splunk/react-ui/ScreenReaderContent");
160
+ var L = e.n(A);
161
+ // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
162
+ const _ = require("@splunk/ui-utils/i18n");
163
+ // CONCATENATED MODULE: ./src/Loading.jsx
164
+ var F = {
165
+ hideAppBar: P().bool,
166
+ hideChrome: P().bool,
167
+ hideSplunkBar: P().bool,
168
+ AppBarFallback: P().elementType,
169
+ SplunkBarFallback: P().elementType
170
+ };
171
+ function T(e) {
172
+ var n = e.AppBarFallback, r = n === void 0 ? y : n, t = e.hideAppBar, a = e.hideChrome, i = e.hideSplunkBar, o = e.SplunkBarFallback, l = o === void 0 ? b : o;
173
+
174
+ return w().createElement(h, null, !a && !i && w().createElement(l, null), !a && !t && w().createElement(r, null), w().createElement(g, null, w().createElement(k, null), w().createElement(k, null), w().createElement(k, null), w().createElement(L(), null, (0,
175
+ _._)("Loading"))));
176
+ }
177
+ T.propTypes = F;
178
+ /* harmony default export */ const H = T;
179
+ // CONCATENATED MODULE: ./src/baseLayout.jsx
180
+ function M(e, n) {
181
+ if (null == e) return {};
182
+ var r, t, a = z(e, n);
183
+ if (Object.getOwnPropertySymbols) {
184
+ var i = Object.getOwnPropertySymbols(e);
185
+ for (t = 0; t < i.length; t++) {
186
+ r = i[t], n.includes(r) || {}.propertyIsEnumerable.call(e, r) && (a[r] = e[r]);
187
+ }
188
+ }
189
+ return a;
190
+ }
191
+ function z(e, n) {
192
+ if (null == e) return {};
193
+ var r = {};
194
+ for (var t in e) {
195
+ if ({}.hasOwnProperty.call(e, t)) {
196
+ if (n.includes(t)) continue;
197
+ r[t] = e[t];
198
+ }
199
+ }
200
+ return r;
201
+ }
202
+ var G = "build/api/layout.js";
203
+ var I = "build/api/layout-dark.js";
204
+ var R = 'header[data-view="splunkjs/mvc/headerview"]';
205
+ /**
206
+ * Loads the layout from the server, using requirejs if available on the window and scriptjs if not.
207
+ *
208
+ * @param {Function} callback - A callback invoked with the layout module once resolved.
209
+ * @param {object} [options]
210
+ * @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
211
+ * @private
212
+ */ function U(e, n) {
213
+ var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, t = r.loader, a = t === void 0 ? "scriptjs" : t;
214
+ var i = e === "dark" ? I : G;
215
+ var o = (0, B.createStaticURL)(i);
216
+ if (a === "scriptjs") {
217
+ E()(o, (function() {
218
+ // eslint-disable-next-line no-underscore-dangle
219
+ n(window.__splunk_layout__);
220
+ }));
221
+ } else if (a === "requirejs") {
222
+ if (window.requirejs) {
223
+ window.requirejs([ o ], n);
224
+ } else {
225
+ throw new Error('Error in react-page: options.loader = "requirejs" was set but window.requirejs does not exist.');
226
+ }
227
+ } else {
228
+ throw new Error('Invalid options.loader configuration: must be "scriptjs" or "requirejs".');
229
+ }
230
+ }
231
+ /**
232
+ * Computes the background css of the header container during lazy loading
233
+ *
234
+ * @param {HTMLDivElement} headerContainer
235
+ * @param {object} [options]
236
+ * @private
237
+ */ function N(e) {
238
+ var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
239
+ var r = n.hideSplunkBar, t = n.hideAppBar, a = n.headerHeight;
240
+ var i = e.children[0];
241
+ var o = i && getComputedStyle(i).backgroundColor;
242
+ if (!(r || t)) {
243
+ // compute background color to be same as both fallback components
244
+ var l = i === null || i === void 0 ? void 0 : i.offsetHeight;
245
+ var u = e.children[1];
246
+ var c = u && getComputedStyle(u).backgroundColor;
247
+ var d = Math.round(l / a * 100);
248
+ return "linear-gradient(\n ".concat(o, " 0%,\n ").concat(o, " ").concat(d, "%,\n ").concat(c, " ").concat(d, "%,\n ").concat(c, " 100%\n )");
249
+ }
250
+ return o;
251
+ }
252
+ /**
253
+ * renders body element and attaches it to container node in DOM
254
+ *
255
+ * @param {element} element
256
+ * @param {element} render - A render function that returns an unmount() function.
257
+ * @param {HTMLDivElement} container
258
+ * @param {boolean} useGlobalLayerStack
259
+ * @param {object} splunkTheme
260
+ * @private
261
+ */ function D(e, n, r) {
262
+ var t = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
263
+ var a = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
264
+ var i = t ? w().createElement(j.LayerStackGlobalProvider, null, w().createElement(x(), a, e)) : w().createElement(x(), a, e);
265
+ return n(i, r);
266
+ }
267
+ /**
268
+ * Renders a React element into the Layout API.
269
+ * @public
270
+ * @param {element} element - A React element.
271
+ * @param {element} render - A render function that returns an unmount() function.
272
+ * @param {object} [options]
273
+ * @param {string} [options.pageTitle] - Changes the page title.
274
+ * @param {Boolean} [options.hideAppBar = false] - Hides the app bar.
275
+ * @param {Boolean} [options.hideAppsList = false] - Hides the app list in
276
+ * the Splunk bar.
277
+ * @param {Boolean} [options.hideChrome = false] - Renders only the main content, hiding
278
+ * the Splunk bar, app bar, and footer.
279
+ * @param {Boolean} [options.hideFooter = false] - Hides the footer.
280
+ * @param {Boolean} [options.hideSplunkBar = false] - Hides the Splunk bar.
281
+ * @param {string} [options.layout = 'scrolling'] - Set to `fixed` to fix all navigation bars
282
+ * to the edge of the page.
283
+ * @param {Boolean} [options.useGlobalLayerStack = true] - Wraps elements in @splunk/react-ui's LayerStackGlobalProvider.
284
+ * @param {String} [options.theme = 'light'] - Used to theme UI elements. Ex. "light" or "dark".
285
+ * @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
286
+ * Change this only if the default loader does not work for your application.
287
+ * @param {Boolean} [options.lazyLoadLayout = false] - Prioritizes loading the React element and lazily fetches and compiles the layout API (navigation bar).
288
+ * @param {element} [options.SplunkBarFallback = SplunkBar] - A React element used as a placeholder for the splunk bar while the navigation bar is loading.
289
+ * @param {element} [options.AppBarFallback = AppBar] - A React element used as a placeholder for the app bar while the navigation bar is loading.
290
+ * @param {function} [options.onLayoutComplete] - A callback function which executes after layout API is fetched and compiled.
291
+ */ function J(e, n) {
292
+ var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
293
+ var t = r.useGlobalLayerStack, a = t === void 0 ? true : t, i = r.pageTitle, o = r.theme, l = o === void 0 ? "light" : o, u = r.loader, c = u === void 0 ? "scriptjs" : u, d = M(r, [ "useGlobalLayerStack", "pageTitle", "theme", "loader" ]);
294
+ if (i) {
295
+ document.title = i;
296
+ }
297
+ var p = d.hideChrome, s = d.hideAppBar, m = d.hideSplunkBar, h = d.SplunkBarFallback, g = h === void 0 ? b : h, k = d.AppBarFallback, S = k === void 0 ? y : k, C = d.lazyLoadLayout, E = C === void 0 ? false : C, j = d.onLayoutComplete, B = d.onLayoutStart;
298
+ var q = document.createElement("div");
299
+ var O = document.createElement("div");
300
+ B === null || B === void 0 ? void 0 : B({
301
+ headerContainer: O,
302
+ bodyContainer: q
303
+ });
304
+ // The "theme" in enterprise used to be "enterprise" instead of "light"...
305
+ var P = l === "light" || l === "enterprise" ? "light" : "dark";
306
+ var A = {
307
+ family: "enterprise",
308
+ colorScheme: P,
309
+ density: "comfortable"
310
+ };
311
+ var L;
312
+ var _;
313
+ if (E) {
314
+ // render the React app immediately without waiting for layout API
315
+ if (!p) {
316
+ document.body.appendChild(O);
317
+ _ = n( w().createElement(w().Fragment, null, !m && w().createElement(g, null), !s && w().createElement(S, null)), O);
318
+ // explicitly set height and background of header container to avoid layout and color shift when fallback gets replaced
319
+ var F = O.offsetHeight;
320
+ var T = N(O, {
321
+ hideSplunkBar: m,
322
+ hideAppBar: s,
323
+ headerHeight: F,
324
+ AppBarFallback: S,
325
+ SplunkBarFallback: g
326
+ });
327
+ O.style.height = "".concat(F, "px");
328
+ O.style.background = "".concat(T);
329
+ }
330
+ document.body.appendChild(q);
331
+ L = D(e, n, q, a, A);
332
+ } else {
333
+ document.body.appendChild(q);
334
+ L = n( w().createElement(x(), A, w().createElement(H, d)), q);
335
+ }
336
+ U(l, (function(r) {
337
+ var t;
338
+ if (r) {
339
+ t = r.create(d).getContainerElement();
340
+ if (d.layout === "fixed") {
341
+ // the above create method adds flex: 1 0 0
342
+ // IE 11 disregards 0px shorthand for flex-basis component.
343
+ // flex-basis 0% is better than 0px because css minification can remove px
344
+ if (!t.style.flex || t.style.flex === "1 0 0px") {
345
+ t.style.flex = "1 0 0%";
346
+ }
347
+ // all elements in the hierarchy must have 'overflow: hidden' for children
348
+ // to support scrolling correctly.
349
+ if (!t.style.overflow) {
350
+ t.style.overflow = "hidden";
351
+ }
352
+ // splunk hijacks the width of the body when printing, so we have to force width to the size
353
+ // of the viewport so that things print at the correct width
354
+ if (!t.style.width) {
355
+ t.style.width = "100vw";
356
+ }
357
+ }
358
+ } else {
359
+ // eslint-disable-next-line no-console
360
+ console.error("Unable to load layout.");
361
+ t = document.createElement("div");
362
+ document.body.appendChild(t);
363
+ }
364
+ if (E) {
365
+ if (!p) {
366
+ // replace placeholder nav bar with real nav bar
367
+ _.unmount(O);
368
+ var i = document.querySelector(R);
369
+ var o = (!p && !m ? f : 0) + (!p && !s ? v : 0);
370
+ // set a min-height for basic nav bar components and auto height for any additional components like global banner
371
+ O.style.minHeight = "".concat(o, "px");
372
+ O.style.height = "auto";
373
+ O.appendChild(i);
374
+ }
375
+ t.appendChild(q);
376
+ j === null || j === void 0 ? void 0 : j();
377
+ } else {
378
+ setTimeout((function() {
379
+ L.unmount(q);
380
+ L = D(e, n, q, a, A);
381
+ t.appendChild(q);
382
+ j === null || j === void 0 ? void 0 : j();
383
+ }), 30);
384
+ }
385
+ }), {
386
+ loader: c
387
+ });
388
+ }
389
+ /* harmony default export */ const K = J;
390
+ // CONCATENATED MODULE: ./src/index.jsx
391
+ var Q = function e(n, t) {
392
+ (0, r.render)(n, t);
393
+ return {
394
+ unmount: function e() {
395
+ return (0, r.unmountComponentAtNode)(t);
396
+ }
397
+ };
398
+ };
399
+ /**
400
+ * Renders a React element into the Layout API.
401
+ * @public
402
+ * @param {element} element - A React element.
403
+ * @param {object} [options]
404
+ * @param {string} [options.pageTitle] - Changes the page title.
405
+ * @param {Boolean} [options.hideAppBar = false] - Hides the app bar.
406
+ * @param {Boolean} [options.hideAppsList = false] - Hides the app list in
407
+ * the Splunk bar.
408
+ * @param {Boolean} [options.hideChrome = false] - Renders only the main content, hiding
409
+ * the Splunk bar, app bar, and footer.
410
+ * @param {Boolean} [options.hideFooter = false] - Hides the footer.
411
+ * @param {Boolean} [options.hideSplunkBar = false] - Hides the Splunk bar.
412
+ * @param {string} [options.layout = 'scrolling'] - Set to `fixed` to fix all navigation bars
413
+ * to the edge of the page.
414
+ * @param {Boolean} [options.useGlobalLayerStack = true] - Wraps elements in @splunk/react-ui's LayerStackGlobalProvider.
415
+ * @param {String} [options.theme = 'light'] - Used to theme UI elements. Ex. "light" or "dark".
416
+ * @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
417
+ * Change this only if the default loader does not work for your application.
418
+ * @param {Boolean} [options.lazyLoadLayout = false] - Prioritizes loading the React element and lazily fetches and compiles the layout API (navigation bar).
419
+ * @param {element} [options.SplunkBarFallback = SplunkBar] - A React element used as a placeholder for the splunk bar while the navigation bar is loading.
420
+ * @param {element} [options.AppBarFallback = AppBar] - A React element used as a placeholder for the app bar while the navigation bar is loading.
421
+ * @param {function} [options.onLayoutComplete] - A callback function which executes after layout API is fetched and compiled.
422
+ * @param {function} [options.onLayoutStart] - A callback function which executes once the layout starts to render
423
+ */ function V(e, n) {
424
+ K(e, Q, n);
425
+ }
426
+ /* harmony default export */ const W = V;
427
+ module.exports = n;
428
+ /******/})();
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@splunk/react-page",
3
- "version": "7.0.0",
3
+ "version": "8.0.0-beta.2",
4
4
  "description": "Load React components into the latest layout from Splunk Enterprise",
5
- "main": "lib/index.js",
6
5
  "license": "Apache-2.0",
7
6
  "author": "Splunk Inc.",
8
7
  "scripts": {
@@ -22,45 +21,46 @@
22
21
  "test:cypress:ci": "node src/tests/run-cypress-tests.js"
23
22
  },
24
23
  "dependencies": {
25
- "@splunk/react-ui": "^4.25.0",
26
- "@splunk/splunk-utils": "^3.0.0",
27
- "@splunk/themes": "^0.16.4",
28
- "@splunk/ui-utils": "^1.6.0",
24
+ "@splunk/react-ui": "5.0.0-beta.2",
25
+ "@splunk/splunk-utils": "^3.2.0",
26
+ "@splunk/themes": "1.0.0-beta.2",
27
+ "@splunk/ui-utils": "^1.8.0",
29
28
  "prop-types": "^15.6.2",
30
29
  "scriptjs": "^2.5.8"
31
30
  },
32
31
  "devDependencies": {
33
- "@babel/core": "^7.2.0",
32
+ "@babel/core": "^7.16.0",
33
+ "@babel/eslint-parser": "^7.16.0",
34
34
  "@splunk/babel-preset": "^4.0.0",
35
- "@splunk/eslint-config": "^4.0.0",
36
- "@splunk/stylelint-config": "^4.0.0",
35
+ "@splunk/eslint-config": "^5.0.0",
36
+ "@splunk/react-docs": "1.0.0-beta.21.v5.2",
37
+ "@splunk/stylelint-config": "^5.0.0",
37
38
  "@splunk/webpack-configs": "^7.0.2",
38
- "babel-eslint": "^10.1.0",
39
39
  "babel-loader": "^8.3.0",
40
40
  "babel-plugin-transform-imports": "^2.0.0",
41
41
  "cross-env": "^6.0.3",
42
42
  "cypress": "^12.17.1",
43
- "eslint": "^7.14.0",
44
- "eslint-config-airbnb": "^18.2.1",
45
- "eslint-config-prettier": "^6.15.0",
43
+ "eslint": "^8.57.1",
44
+ "eslint-config-airbnb": "^19.0.4",
45
+ "eslint-config-prettier": "^9.1.0",
46
46
  "eslint-import-resolver-webpack": "^0.13.4",
47
- "eslint-plugin-import": "^2.22.1",
48
- "eslint-plugin-jsx-a11y": "^6.4.1",
49
- "eslint-plugin-react": "^7.21.5",
50
- "eslint-plugin-react-hooks": "^4.2.0",
47
+ "eslint-plugin-import": "^2.30.1",
48
+ "eslint-plugin-jsx-a11y": "^6.10.0",
49
+ "eslint-plugin-react": "^7.36.1",
50
+ "eslint-plugin-react-hooks": "^4.6.2",
51
51
  "execa": "^4.0.0",
52
- "react": "^16.12.0",
53
- "react-dom": "^16.12.0",
52
+ "react": "^18.2.0",
53
+ "react-dom": "^18.2.0",
54
54
  "styled-components": "^5.3.10",
55
- "stylelint": "^13.0.0",
55
+ "stylelint": "^15.11.0",
56
56
  "webpack": "^5.88.2",
57
57
  "webpack-cli": "^5.1.4",
58
58
  "webpack-dev-server": "^4.15.1",
59
59
  "webpack-merge": "^5.9.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "react": "^16.8",
63
- "react-dom": "^16.8",
62
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
63
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
64
64
  "styled-components": "^5.3.10"
65
65
  },
66
66
  "engines": {