@patternfly/quickstarts 5.0.0-prerelease.1 → 5.0.0-prerelease.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.
Files changed (116) hide show
  1. package/dist/ConsoleInternal/components/markdown-view.d.ts +19 -19
  2. package/dist/ConsoleInternal/components/utils/camel-case-wrap.d.ts +6 -6
  3. package/dist/ConsoleInternal/components/utils/index.d.ts +3 -3
  4. package/dist/ConsoleInternal/components/utils/router.d.ts +9 -9
  5. package/dist/ConsoleInternal/components/utils/status-box.d.ts +20 -20
  6. package/dist/ConsoleInternal/module/k8s/types.d.ts +42 -42
  7. package/dist/ConsoleShared/index.d.ts +1 -1
  8. package/dist/ConsoleShared/src/components/index.d.ts +7 -7
  9. package/dist/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.d.ts +13 -13
  10. package/dist/ConsoleShared/src/components/markdown-extensions/accordion-extension.d.ts +7 -7
  11. package/dist/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.d.ts +6 -6
  12. package/dist/ConsoleShared/src/components/markdown-extensions/admonition-extension.d.ts +7 -7
  13. package/dist/ConsoleShared/src/components/markdown-extensions/code-extension.d.ts +7 -7
  14. package/dist/ConsoleShared/src/components/markdown-extensions/const.d.ts +5 -5
  15. package/dist/ConsoleShared/src/components/markdown-extensions/index.d.ts +7 -7
  16. package/dist/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.d.ts +7 -7
  17. package/dist/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.d.ts +7 -7
  18. package/dist/ConsoleShared/src/components/markdown-extensions/utils.d.ts +1 -1
  19. package/dist/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.d.ts +7 -7
  20. package/dist/ConsoleShared/src/components/markdown-highlight-extension/highlight-consts.d.ts +4 -4
  21. package/dist/ConsoleShared/src/components/markdown-highlight-extension/index.d.ts +1 -1
  22. package/dist/ConsoleShared/src/components/modal/Modal.d.ts +9 -9
  23. package/dist/ConsoleShared/src/components/modal/index.d.ts +1 -1
  24. package/dist/ConsoleShared/src/components/popper/Portal.d.ts +8 -8
  25. package/dist/ConsoleShared/src/components/popper/SimplePopper.d.ts +6 -6
  26. package/dist/ConsoleShared/src/components/popper/index.d.ts +2 -2
  27. package/dist/ConsoleShared/src/components/spotlight/InteractiveSpotlight.d.ts +7 -7
  28. package/dist/ConsoleShared/src/components/spotlight/Spotlight.d.ts +7 -7
  29. package/dist/ConsoleShared/src/components/spotlight/StaticSpotlight.d.ts +7 -7
  30. package/dist/ConsoleShared/src/components/spotlight/index.d.ts +1 -1
  31. package/dist/ConsoleShared/src/components/status/GenericStatus.d.ts +12 -12
  32. package/dist/ConsoleShared/src/components/status/NotStartedIcon.d.ts +3 -3
  33. package/dist/ConsoleShared/src/components/status/PopoverStatus.d.ts +13 -13
  34. package/dist/ConsoleShared/src/components/status/Status.d.ts +11 -11
  35. package/dist/ConsoleShared/src/components/status/StatusIconAndText.d.ts +8 -8
  36. package/dist/ConsoleShared/src/components/status/icons.d.ts +9 -9
  37. package/dist/ConsoleShared/src/components/status/index.d.ts +1 -1
  38. package/dist/ConsoleShared/src/components/status/statuses.d.ts +5 -5
  39. package/dist/ConsoleShared/src/components/status/types.d.ts +9 -9
  40. package/dist/ConsoleShared/src/components/utils/FallbackImg.d.ts +9 -9
  41. package/dist/ConsoleShared/src/components/utils/index.d.ts +1 -1
  42. package/dist/ConsoleShared/src/constants/index.d.ts +1 -1
  43. package/dist/ConsoleShared/src/constants/ui.d.ts +1 -1
  44. package/dist/ConsoleShared/src/hooks/index.d.ts +6 -6
  45. package/dist/ConsoleShared/src/hooks/scroll.d.ts +8 -8
  46. package/dist/ConsoleShared/src/hooks/useBoundingClientRect.d.ts +3 -3
  47. package/dist/ConsoleShared/src/hooks/useEventListener.d.ts +1 -1
  48. package/dist/ConsoleShared/src/hooks/useForceRender.d.ts +4 -4
  49. package/dist/ConsoleShared/src/hooks/useResizeObserver.d.ts +1 -1
  50. package/dist/ConsoleShared/src/hooks/useScrollShadows.d.ts +7 -7
  51. package/dist/ConsoleShared/src/index.d.ts +4 -4
  52. package/dist/ConsoleShared/src/utils/index.d.ts +1 -1
  53. package/dist/ConsoleShared/src/utils/useCombineRefs.d.ts +2 -2
  54. package/dist/HelpTopicDrawer.d.ts +33 -33
  55. package/dist/HelpTopicPanelContent.d.ts +11 -11
  56. package/dist/QuickStartCatalogPage.d.ts +14 -14
  57. package/dist/QuickStartCloseModal.d.ts +8 -8
  58. package/dist/QuickStartController.d.ts +10 -10
  59. package/dist/QuickStartDrawer.d.ts +62 -62
  60. package/dist/QuickStartMarkdownView.d.ts +9 -9
  61. package/dist/QuickStartPanelContent.d.ts +15 -15
  62. package/dist/catalog/Catalog/QuickStartCatalogHeader.d.ts +6 -6
  63. package/dist/catalog/Catalog/QuickStartCatalogSection.d.ts +5 -5
  64. package/dist/catalog/Catalog/QuickStartCatalogToolbar.d.ts +5 -5
  65. package/dist/catalog/Catalog/index.d.ts +3 -3
  66. package/dist/catalog/QuickStartCatalog.d.ts +8 -8
  67. package/dist/catalog/QuickStartTile.d.ts +11 -11
  68. package/dist/catalog/QuickStartTileDescription.d.ts +8 -8
  69. package/dist/catalog/QuickStartTileFooter.d.ts +8 -8
  70. package/dist/catalog/QuickStartTileFooterExternal.d.ts +8 -8
  71. package/dist/catalog/QuickStartTileHeader.d.ts +12 -12
  72. package/dist/catalog/Toolbar/QuickStartCatalogFilter.d.ts +10 -10
  73. package/dist/catalog/Toolbar/QuickStartCatalogFilterItems.d.ts +31 -31
  74. package/dist/catalog/index.d.ts +9 -9
  75. package/dist/controller/QuickStartConclusion.d.ts +12 -12
  76. package/dist/controller/QuickStartContent.d.ts +14 -14
  77. package/dist/controller/QuickStartFooter.d.ts +14 -14
  78. package/dist/controller/QuickStartIntroduction.d.ts +12 -12
  79. package/dist/controller/QuickStartTaskHeader.d.ts +15 -15
  80. package/dist/controller/QuickStartTaskHeaderList.d.ts +10 -10
  81. package/dist/controller/QuickStartTaskReview.d.ts +10 -10
  82. package/dist/controller/QuickStartTasks.d.ts +12 -12
  83. package/dist/data/mocks/json/explore-pipeline-quickstart.d.ts +2 -2
  84. package/dist/data/mocks/json/explore-serverless-quickstart.d.ts +2 -2
  85. package/dist/data/mocks/json/monitor-sampleapp-quickstart.d.ts +2 -2
  86. package/dist/data/mocks/json/tour-icons.d.ts +2 -2
  87. package/dist/data/quick-start-test-data.d.ts +2 -2
  88. package/dist/data/test-utils.d.ts +8 -8
  89. package/dist/index.d.ts +16 -16
  90. package/dist/index.es.js +2296 -2291
  91. package/dist/index.es.js.map +1 -1
  92. package/dist/index.js +2296 -2291
  93. package/dist/index.js.map +1 -1
  94. package/dist/patternfly-nested.css +66 -508
  95. package/dist/quickstarts-base.css +1 -1
  96. package/dist/quickstarts-full.es.js +2528 -2557
  97. package/dist/quickstarts-full.es.js.map +1 -1
  98. package/dist/quickstarts-standalone.css +1 -1
  99. package/dist/quickstarts-standalone.min.css +2 -2
  100. package/dist/quickstarts.css +1 -1
  101. package/dist/quickstarts.min.css +1 -1
  102. package/dist/styles/patternfly-global-entry.d.ts +1 -1
  103. package/dist/styles/patternfly-nested-entry.d.ts +1 -1
  104. package/dist/styles/quickstarts-standalone-entry.d.ts +1 -1
  105. package/dist/styles/vendor-entry.d.ts +1 -1
  106. package/dist/utils/PluralResolver.d.ts +16 -16
  107. package/dist/utils/asciidoc-procedure-parser.d.ts +12 -12
  108. package/dist/utils/const.d.ts +6 -6
  109. package/dist/utils/help-topic-context.d.ts +23 -23
  110. package/dist/utils/help-topic-types.d.ts +13 -13
  111. package/dist/utils/quick-start-context.d.ts +81 -81
  112. package/dist/utils/quick-start-types.d.ts +60 -60
  113. package/dist/utils/quick-start-utils.d.ts +10 -10
  114. package/dist/utils/useLocalStorage.d.ts +1 -1
  115. package/package.json +10 -10
  116. package/src/styles/_dark-custom-override.scss +1 -1
package/dist/index.js CHANGED
@@ -96,66 +96,66 @@ m.Pop;a=b();var q=a[0],l=a[1],c=B(),e=B();null==q&&(q=0,f.replaceState(_extends(
96
96
  y(_extends({pathname:"/",search:"",hash:"",state:null,key:D()},"string"===typeof a?F(a):a));"production"!==process.env.NODE_ENV?z("/"===b.pathname.charAt(0),"Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(a)+")"):void 0;return b}),f=Math.min(Math.max(null==r?h.length-1:r,0),h.length-1),p=m.Pop,n=h[f],q=B(),l=B();return {get index(){return f},get action(){return p},get location(){return n},createHref:function(a){return "string"===typeof a?
97
97
  a:E(a)},push:v,replace:w,go:u,back:function(){u(-1);},forward:function(){u(1);},listen:function(a){return q.push(a)},block:function(a){return l.push(a)}}}
98
98
 
99
- exports.QuickStartStatus = void 0;
100
- (function (QuickStartStatus) {
101
- QuickStartStatus["COMPLETE"] = "Complete";
102
- QuickStartStatus["IN_PROGRESS"] = "In Progress";
103
- QuickStartStatus["NOT_STARTED"] = "Not started";
104
- })(exports.QuickStartStatus || (exports.QuickStartStatus = {}));
105
- exports.QuickStartTaskStatus = void 0;
106
- (function (QuickStartTaskStatus) {
107
- QuickStartTaskStatus["INIT"] = "Initial";
108
- QuickStartTaskStatus["VISITED"] = "Visited";
109
- QuickStartTaskStatus["REVIEW"] = "Review";
110
- QuickStartTaskStatus["SUCCESS"] = "Success";
111
- QuickStartTaskStatus["FAILED"] = "Failed";
99
+ exports.QuickStartStatus = void 0;
100
+ (function (QuickStartStatus) {
101
+ QuickStartStatus["COMPLETE"] = "Complete";
102
+ QuickStartStatus["IN_PROGRESS"] = "In Progress";
103
+ QuickStartStatus["NOT_STARTED"] = "Not started";
104
+ })(exports.QuickStartStatus || (exports.QuickStartStatus = {}));
105
+ exports.QuickStartTaskStatus = void 0;
106
+ (function (QuickStartTaskStatus) {
107
+ QuickStartTaskStatus["INIT"] = "Initial";
108
+ QuickStartTaskStatus["VISITED"] = "Visited";
109
+ QuickStartTaskStatus["REVIEW"] = "Review";
110
+ QuickStartTaskStatus["SUCCESS"] = "Success";
111
+ QuickStartTaskStatus["FAILED"] = "Failed";
112
112
  })(exports.QuickStartTaskStatus || (exports.QuickStartTaskStatus = {}));
113
113
 
114
- const QUICKSTART_SEARCH_FILTER_KEY = 'keyword';
115
- const QUICKSTART_STATUS_FILTER_KEY = 'status';
116
- const QUICKSTART_ID_FILTER_KEY = 'quickstart';
117
- const QUICKSTART_TASKS_INITIAL_STATES = [
118
- exports.QuickStartTaskStatus.INIT,
119
- exports.QuickStartTaskStatus.VISITED,
120
- ];
114
+ const QUICKSTART_SEARCH_FILTER_KEY = 'keyword';
115
+ const QUICKSTART_STATUS_FILTER_KEY = 'status';
116
+ const QUICKSTART_ID_FILTER_KEY = 'quickstart';
117
+ const QUICKSTART_TASKS_INITIAL_STATES = [
118
+ exports.QuickStartTaskStatus.INIT,
119
+ exports.QuickStartTaskStatus.VISITED,
120
+ ];
121
121
  const HELP_TOPIC_NAME_KEY = 'topic';
122
122
 
123
- let createHistory;
124
- try {
125
- if (process.env.NODE_ENV === 'test') {
126
- // Running in node. Can't use browser history
127
- createHistory = createMemoryHistory;
128
- }
129
- else {
130
- createHistory = createBrowserHistory;
131
- }
132
- }
133
- catch (unused) {
134
- createHistory = createBrowserHistory;
135
- }
136
- const history = createHistory();
137
- const removeQueryArgument = (k) => {
138
- const params = new URLSearchParams(window.location.search);
139
- if (params.has(k)) {
140
- params.delete(k);
141
- const url = new URL(window.location.href);
142
- history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
143
- }
144
- };
145
- const setQueryArgument = (k, v) => {
146
- if (!v) {
147
- return removeQueryArgument(k);
148
- }
149
- const params = new URLSearchParams(window.location.search);
150
- if (params.get(k) !== v) {
151
- params.set(k, v);
152
- const url = new URL(window.location.href);
153
- history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
154
- }
155
- };
156
- const clearFilterParams = () => {
157
- removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
158
- removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
123
+ let createHistory;
124
+ try {
125
+ if (process.env.NODE_ENV === 'test') {
126
+ // Running in node. Can't use browser history
127
+ createHistory = createMemoryHistory;
128
+ }
129
+ else {
130
+ createHistory = createBrowserHistory;
131
+ }
132
+ }
133
+ catch (unused) {
134
+ createHistory = createBrowserHistory;
135
+ }
136
+ const history = createHistory();
137
+ const removeQueryArgument = (k) => {
138
+ const params = new URLSearchParams(window.location.search);
139
+ if (params.has(k)) {
140
+ params.delete(k);
141
+ const url = new URL(window.location.href);
142
+ history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
143
+ }
144
+ };
145
+ const setQueryArgument = (k, v) => {
146
+ if (!v) {
147
+ return removeQueryArgument(k);
148
+ }
149
+ const params = new URLSearchParams(window.location.search);
150
+ if (params.get(k) !== v) {
151
+ params.set(k, v);
152
+ const url = new URL(window.location.href);
153
+ history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
154
+ }
155
+ };
156
+ const clearFilterParams = () => {
157
+ removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
158
+ removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
159
159
  };
160
160
 
161
161
  var Status$1 = "Status";
@@ -219,672 +219,672 @@ var en = {
219
219
  "{{type}} • {{duration, number}} minutes": "{{type}} • {{duration, number}} minutes"
220
220
  };
221
221
 
222
- /* eslint-disable */
223
- // https://github.com/i18next/i18next/blob/master/src/PluralResolver.js
224
- const sets = [
225
- {
226
- lngs: [
227
- 'ach',
228
- 'ak',
229
- 'am',
230
- 'arn',
231
- 'br',
232
- 'fil',
233
- 'gun',
234
- 'ln',
235
- 'mfe',
236
- 'mg',
237
- 'mi',
238
- 'oc',
239
- 'pt',
240
- 'pt-BR',
241
- 'tg',
242
- 'tl',
243
- 'ti',
244
- 'tr',
245
- 'uz',
246
- 'wa',
247
- ],
248
- nr: [1, 2],
249
- fc: 1,
250
- },
251
- {
252
- lngs: [
253
- 'af',
254
- 'an',
255
- 'ast',
256
- 'az',
257
- 'bg',
258
- 'bn',
259
- 'ca',
260
- 'da',
261
- 'de',
262
- 'dev',
263
- 'el',
264
- 'en',
265
- 'eo',
266
- 'es',
267
- 'et',
268
- 'eu',
269
- 'fi',
270
- 'fo',
271
- 'fur',
272
- 'fy',
273
- 'gl',
274
- 'gu',
275
- 'ha',
276
- 'hi',
277
- 'hu',
278
- 'hy',
279
- 'ia',
280
- 'it',
281
- 'kk',
282
- 'kn',
283
- 'ku',
284
- 'lb',
285
- 'mai',
286
- 'ml',
287
- 'mn',
288
- 'mr',
289
- 'nah',
290
- 'nap',
291
- 'nb',
292
- 'ne',
293
- 'nl',
294
- 'nn',
295
- 'no',
296
- 'nso',
297
- 'pa',
298
- 'pap',
299
- 'pms',
300
- 'ps',
301
- 'pt-PT',
302
- 'rm',
303
- 'sco',
304
- 'se',
305
- 'si',
306
- 'so',
307
- 'son',
308
- 'sq',
309
- 'sv',
310
- 'sw',
311
- 'ta',
312
- 'te',
313
- 'tk',
314
- 'ur',
315
- 'yo',
316
- ],
317
- nr: [1, 2],
318
- fc: 2,
319
- },
320
- {
321
- lngs: [
322
- 'ay',
323
- 'bo',
324
- 'cgg',
325
- 'fa',
326
- 'ht',
327
- 'id',
328
- 'ja',
329
- 'jbo',
330
- 'ka',
331
- 'km',
332
- 'ko',
333
- 'ky',
334
- 'lo',
335
- 'ms',
336
- 'sah',
337
- 'su',
338
- 'th',
339
- 'tt',
340
- 'ug',
341
- 'vi',
342
- 'wo',
343
- 'zh',
344
- ],
345
- nr: [1],
346
- fc: 3,
347
- },
348
- { lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'], nr: [1, 2, 5], fc: 4 },
349
- { lngs: ['ar'], nr: [0, 1, 2, 3, 11, 100], fc: 5 },
350
- { lngs: ['cs', 'sk'], nr: [1, 2, 5], fc: 6 },
351
- { lngs: ['csb', 'pl'], nr: [1, 2, 5], fc: 7 },
352
- { lngs: ['cy'], nr: [1, 2, 3, 8], fc: 8 },
353
- { lngs: ['fr'], nr: [1, 2], fc: 9 },
354
- { lngs: ['ga'], nr: [1, 2, 3, 7, 11], fc: 10 },
355
- { lngs: ['gd'], nr: [1, 2, 3, 20], fc: 11 },
356
- { lngs: ['is'], nr: [1, 2], fc: 12 },
357
- { lngs: ['jv'], nr: [0, 1], fc: 13 },
358
- { lngs: ['kw'], nr: [1, 2, 3, 4], fc: 14 },
359
- { lngs: ['lt'], nr: [1, 2, 10], fc: 15 },
360
- { lngs: ['lv'], nr: [1, 2, 0], fc: 16 },
361
- { lngs: ['mk'], nr: [1, 2], fc: 17 },
362
- { lngs: ['mnk'], nr: [0, 1, 2], fc: 18 },
363
- { lngs: ['mt'], nr: [1, 2, 11, 20], fc: 19 },
364
- { lngs: ['or'], nr: [2, 1], fc: 2 },
365
- { lngs: ['ro'], nr: [1, 2, 20], fc: 20 },
366
- { lngs: ['sl'], nr: [5, 1, 2, 3], fc: 21 },
367
- { lngs: ['he', 'iw'], nr: [1, 2, 20, 21], fc: 22 },
368
- ];
369
- const _rulesPluralsTypes = {
370
- 1: function (n) {
371
- return Number(n > 1);
372
- },
373
- 2: function (n) {
374
- return Number(n != 1);
375
- },
376
- 3: function (n) {
377
- return 0;
378
- },
379
- 4: function (n) {
380
- return Number(n % 10 == 1 && n % 100 != 11
381
- ? 0
382
- : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)
383
- ? 1
384
- : 2);
385
- },
386
- 5: function (n) {
387
- return Number(n == 0
388
- ? 0
389
- : n == 1
390
- ? 1
391
- : n == 2
392
- ? 2
393
- : n % 100 >= 3 && n % 100 <= 10
394
- ? 3
395
- : n % 100 >= 11
396
- ? 4
397
- : 5);
398
- },
399
- 6: function (n) {
400
- return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
401
- },
402
- 7: function (n) {
403
- return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
404
- },
405
- 8: function (n) {
406
- return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
407
- },
408
- 9: function (n) {
409
- return Number(n >= 2);
410
- },
411
- 10: function (n) {
412
- return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
413
- },
414
- 11: function (n) {
415
- return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
416
- },
417
- 12: function (n) {
418
- return Number(n % 10 != 1 || n % 100 == 11);
419
- },
420
- 13: function (n) {
421
- return Number(n !== 0);
422
- },
423
- 14: function (n) {
424
- return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
425
- },
426
- 15: function (n) {
427
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
428
- },
429
- 16: function (n) {
430
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
431
- },
432
- 17: function (n) {
433
- return Number(n == 1 || (n % 10 == 1 && n % 100 != 11) ? 0 : 1);
434
- },
435
- 18: function (n) {
436
- return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
437
- },
438
- 19: function (n) {
439
- return Number(n == 1
440
- ? 0
441
- : n == 0 || (n % 100 > 1 && n % 100 < 11)
442
- ? 1
443
- : n % 100 > 10 && n % 100 < 20
444
- ? 2
445
- : 3);
446
- },
447
- 20: function (n) {
448
- return Number(n == 1 ? 0 : n == 0 || (n % 100 > 0 && n % 100 < 20) ? 1 : 2);
449
- },
450
- 21: function (n) {
451
- return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
452
- },
453
- 22: function (n) {
454
- return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
455
- },
456
- };
457
- function createRules() {
458
- const rules = {};
459
- sets.forEach((set) => {
460
- set.lngs.forEach((l) => {
461
- rules[l] = {
462
- numbers: set.nr,
463
- plurals: _rulesPluralsTypes[set.fc],
464
- };
465
- });
466
- });
467
- return rules;
468
- }
469
- class PluralResolver {
470
- constructor(options = {}) {
471
- this.options = options;
472
- this.rules = createRules();
473
- }
474
- addRule(lng, obj) {
475
- this.rules[lng] = obj;
476
- }
477
- getRule(code) {
478
- return this.rules[code];
479
- }
480
- needsPlural(code) {
481
- const rule = this.getRule(code);
482
- return rule && rule.numbers.length > 1;
483
- }
484
- getPluralFormsOfKey(code, key) {
485
- return this.getSuffixes(code).map((suffix) => key + suffix);
486
- }
487
- getSuffixes(code) {
488
- const rule = this.getRule(code);
489
- if (!rule) {
490
- return [];
491
- }
492
- return rule.numbers.map((number) => this.getSuffix(code, number));
493
- }
494
- getSuffix(code, count) {
495
- const rule = this.getRule(code);
496
- if (rule) {
497
- // if (rule.numbers.length === 1) return ''; // only singular
498
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
499
- let suffix = rule.numbers[idx];
500
- // special treatment for lngs only having singular and plural
501
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
502
- if (suffix === 2) {
503
- suffix = 'plural';
504
- }
505
- else if (suffix === 1) {
506
- suffix = '';
507
- }
508
- }
509
- const returnSuffix = () => this.options.prepend && suffix.toString()
510
- ? this.options.prepend + suffix.toString()
511
- : suffix.toString();
512
- // COMPATIBILITY JSON
513
- // v1
514
- if (this.options.compatibilityJSON === 'v1') {
515
- if (suffix === 1) {
516
- return '';
517
- }
518
- if (typeof suffix === 'number') {
519
- return `_plural_${suffix.toString()}`;
520
- }
521
- return returnSuffix();
522
- }
523
- if ( /* v2 */this.options.compatibilityJSON === 'v2') {
524
- return returnSuffix();
525
- }
526
- if (
527
- /* v3 - gettext index */ this.options.simplifyPluralSuffix &&
528
- rule.numbers.length === 2 &&
529
- rule.numbers[0] === 1) {
530
- return returnSuffix();
531
- }
532
- return this.options.prepend && idx.toString()
533
- ? this.options.prepend + idx.toString()
534
- : idx.toString();
535
- }
536
- // this.logger.warn(`no plural rule found for: ${code}`);
537
- return '';
538
- }
222
+ /* eslint-disable */
223
+ // https://github.com/i18next/i18next/blob/master/src/PluralResolver.js
224
+ const sets = [
225
+ {
226
+ lngs: [
227
+ 'ach',
228
+ 'ak',
229
+ 'am',
230
+ 'arn',
231
+ 'br',
232
+ 'fil',
233
+ 'gun',
234
+ 'ln',
235
+ 'mfe',
236
+ 'mg',
237
+ 'mi',
238
+ 'oc',
239
+ 'pt',
240
+ 'pt-BR',
241
+ 'tg',
242
+ 'tl',
243
+ 'ti',
244
+ 'tr',
245
+ 'uz',
246
+ 'wa',
247
+ ],
248
+ nr: [1, 2],
249
+ fc: 1,
250
+ },
251
+ {
252
+ lngs: [
253
+ 'af',
254
+ 'an',
255
+ 'ast',
256
+ 'az',
257
+ 'bg',
258
+ 'bn',
259
+ 'ca',
260
+ 'da',
261
+ 'de',
262
+ 'dev',
263
+ 'el',
264
+ 'en',
265
+ 'eo',
266
+ 'es',
267
+ 'et',
268
+ 'eu',
269
+ 'fi',
270
+ 'fo',
271
+ 'fur',
272
+ 'fy',
273
+ 'gl',
274
+ 'gu',
275
+ 'ha',
276
+ 'hi',
277
+ 'hu',
278
+ 'hy',
279
+ 'ia',
280
+ 'it',
281
+ 'kk',
282
+ 'kn',
283
+ 'ku',
284
+ 'lb',
285
+ 'mai',
286
+ 'ml',
287
+ 'mn',
288
+ 'mr',
289
+ 'nah',
290
+ 'nap',
291
+ 'nb',
292
+ 'ne',
293
+ 'nl',
294
+ 'nn',
295
+ 'no',
296
+ 'nso',
297
+ 'pa',
298
+ 'pap',
299
+ 'pms',
300
+ 'ps',
301
+ 'pt-PT',
302
+ 'rm',
303
+ 'sco',
304
+ 'se',
305
+ 'si',
306
+ 'so',
307
+ 'son',
308
+ 'sq',
309
+ 'sv',
310
+ 'sw',
311
+ 'ta',
312
+ 'te',
313
+ 'tk',
314
+ 'ur',
315
+ 'yo',
316
+ ],
317
+ nr: [1, 2],
318
+ fc: 2,
319
+ },
320
+ {
321
+ lngs: [
322
+ 'ay',
323
+ 'bo',
324
+ 'cgg',
325
+ 'fa',
326
+ 'ht',
327
+ 'id',
328
+ 'ja',
329
+ 'jbo',
330
+ 'ka',
331
+ 'km',
332
+ 'ko',
333
+ 'ky',
334
+ 'lo',
335
+ 'ms',
336
+ 'sah',
337
+ 'su',
338
+ 'th',
339
+ 'tt',
340
+ 'ug',
341
+ 'vi',
342
+ 'wo',
343
+ 'zh',
344
+ ],
345
+ nr: [1],
346
+ fc: 3,
347
+ },
348
+ { lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'], nr: [1, 2, 5], fc: 4 },
349
+ { lngs: ['ar'], nr: [0, 1, 2, 3, 11, 100], fc: 5 },
350
+ { lngs: ['cs', 'sk'], nr: [1, 2, 5], fc: 6 },
351
+ { lngs: ['csb', 'pl'], nr: [1, 2, 5], fc: 7 },
352
+ { lngs: ['cy'], nr: [1, 2, 3, 8], fc: 8 },
353
+ { lngs: ['fr'], nr: [1, 2], fc: 9 },
354
+ { lngs: ['ga'], nr: [1, 2, 3, 7, 11], fc: 10 },
355
+ { lngs: ['gd'], nr: [1, 2, 3, 20], fc: 11 },
356
+ { lngs: ['is'], nr: [1, 2], fc: 12 },
357
+ { lngs: ['jv'], nr: [0, 1], fc: 13 },
358
+ { lngs: ['kw'], nr: [1, 2, 3, 4], fc: 14 },
359
+ { lngs: ['lt'], nr: [1, 2, 10], fc: 15 },
360
+ { lngs: ['lv'], nr: [1, 2, 0], fc: 16 },
361
+ { lngs: ['mk'], nr: [1, 2], fc: 17 },
362
+ { lngs: ['mnk'], nr: [0, 1, 2], fc: 18 },
363
+ { lngs: ['mt'], nr: [1, 2, 11, 20], fc: 19 },
364
+ { lngs: ['or'], nr: [2, 1], fc: 2 },
365
+ { lngs: ['ro'], nr: [1, 2, 20], fc: 20 },
366
+ { lngs: ['sl'], nr: [5, 1, 2, 3], fc: 21 },
367
+ { lngs: ['he', 'iw'], nr: [1, 2, 20, 21], fc: 22 },
368
+ ];
369
+ const _rulesPluralsTypes = {
370
+ 1: function (n) {
371
+ return Number(n > 1);
372
+ },
373
+ 2: function (n) {
374
+ return Number(n != 1);
375
+ },
376
+ 3: function (n) {
377
+ return 0;
378
+ },
379
+ 4: function (n) {
380
+ return Number(n % 10 == 1 && n % 100 != 11
381
+ ? 0
382
+ : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)
383
+ ? 1
384
+ : 2);
385
+ },
386
+ 5: function (n) {
387
+ return Number(n == 0
388
+ ? 0
389
+ : n == 1
390
+ ? 1
391
+ : n == 2
392
+ ? 2
393
+ : n % 100 >= 3 && n % 100 <= 10
394
+ ? 3
395
+ : n % 100 >= 11
396
+ ? 4
397
+ : 5);
398
+ },
399
+ 6: function (n) {
400
+ return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
401
+ },
402
+ 7: function (n) {
403
+ return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
404
+ },
405
+ 8: function (n) {
406
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
407
+ },
408
+ 9: function (n) {
409
+ return Number(n >= 2);
410
+ },
411
+ 10: function (n) {
412
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
413
+ },
414
+ 11: function (n) {
415
+ return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
416
+ },
417
+ 12: function (n) {
418
+ return Number(n % 10 != 1 || n % 100 == 11);
419
+ },
420
+ 13: function (n) {
421
+ return Number(n !== 0);
422
+ },
423
+ 14: function (n) {
424
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
425
+ },
426
+ 15: function (n) {
427
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
428
+ },
429
+ 16: function (n) {
430
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
431
+ },
432
+ 17: function (n) {
433
+ return Number(n == 1 || (n % 10 == 1 && n % 100 != 11) ? 0 : 1);
434
+ },
435
+ 18: function (n) {
436
+ return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
437
+ },
438
+ 19: function (n) {
439
+ return Number(n == 1
440
+ ? 0
441
+ : n == 0 || (n % 100 > 1 && n % 100 < 11)
442
+ ? 1
443
+ : n % 100 > 10 && n % 100 < 20
444
+ ? 2
445
+ : 3);
446
+ },
447
+ 20: function (n) {
448
+ return Number(n == 1 ? 0 : n == 0 || (n % 100 > 0 && n % 100 < 20) ? 1 : 2);
449
+ },
450
+ 21: function (n) {
451
+ return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
452
+ },
453
+ 22: function (n) {
454
+ return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
455
+ },
456
+ };
457
+ function createRules() {
458
+ const rules = {};
459
+ sets.forEach((set) => {
460
+ set.lngs.forEach((l) => {
461
+ rules[l] = {
462
+ numbers: set.nr,
463
+ plurals: _rulesPluralsTypes[set.fc],
464
+ };
465
+ });
466
+ });
467
+ return rules;
468
+ }
469
+ class PluralResolver {
470
+ constructor(options = {}) {
471
+ this.options = options;
472
+ this.rules = createRules();
473
+ }
474
+ addRule(lng, obj) {
475
+ this.rules[lng] = obj;
476
+ }
477
+ getRule(code) {
478
+ return this.rules[code];
479
+ }
480
+ needsPlural(code) {
481
+ const rule = this.getRule(code);
482
+ return rule && rule.numbers.length > 1;
483
+ }
484
+ getPluralFormsOfKey(code, key) {
485
+ return this.getSuffixes(code).map((suffix) => key + suffix);
486
+ }
487
+ getSuffixes(code) {
488
+ const rule = this.getRule(code);
489
+ if (!rule) {
490
+ return [];
491
+ }
492
+ return rule.numbers.map((number) => this.getSuffix(code, number));
493
+ }
494
+ getSuffix(code, count) {
495
+ const rule = this.getRule(code);
496
+ if (rule) {
497
+ // if (rule.numbers.length === 1) return ''; // only singular
498
+ const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
499
+ let suffix = rule.numbers[idx];
500
+ // special treatment for lngs only having singular and plural
501
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
502
+ if (suffix === 2) {
503
+ suffix = 'plural';
504
+ }
505
+ else if (suffix === 1) {
506
+ suffix = '';
507
+ }
508
+ }
509
+ const returnSuffix = () => this.options.prepend && suffix.toString()
510
+ ? this.options.prepend + suffix.toString()
511
+ : suffix.toString();
512
+ // COMPATIBILITY JSON
513
+ // v1
514
+ if (this.options.compatibilityJSON === 'v1') {
515
+ if (suffix === 1) {
516
+ return '';
517
+ }
518
+ if (typeof suffix === 'number') {
519
+ return `_plural_${suffix.toString()}`;
520
+ }
521
+ return returnSuffix();
522
+ }
523
+ if ( /* v2 */this.options.compatibilityJSON === 'v2') {
524
+ return returnSuffix();
525
+ }
526
+ if (
527
+ /* v3 - gettext index */ this.options.simplifyPluralSuffix &&
528
+ rule.numbers.length === 2 &&
529
+ rule.numbers[0] === 1) {
530
+ return returnSuffix();
531
+ }
532
+ return this.options.prepend && idx.toString()
533
+ ? this.options.prepend + idx.toString()
534
+ : idx.toString();
535
+ }
536
+ // this.logger.warn(`no plural rule found for: ${code}`);
537
+ return '';
538
+ }
539
539
  }
540
540
 
541
- const QUICK_START_NAME = 'console.openshift.io/name';
542
- const getQuickStartByName = (name, quickStarts) => quickStarts.find((quickStart) => quickStart.metadata.name === name);
543
- const getQuickStartStatus = (allQuickStartStates, quickStartID) => { var _a, _b; return (_b = (_a = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[quickStartID]) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : exports.QuickStartStatus.NOT_STARTED; };
544
- const getTaskStatusKey = (taskNumber) => `taskStatus${taskNumber}`;
545
- const getQuickStartStatusCount = (allQuickStartStates, quickStarts) => quickStarts.reduce((totals, item) => {
546
- totals[getQuickStartStatus(allQuickStartStates, item.metadata.name)]++;
547
- return totals;
548
- }, {
549
- [exports.QuickStartStatus.IN_PROGRESS]: 0,
550
- [exports.QuickStartStatus.COMPLETE]: 0,
551
- [exports.QuickStartStatus.NOT_STARTED]: 0,
552
- });
553
- const getDisabledQuickStarts = () => {
554
- var _a, _b;
555
- let disabledQuickStarts = [];
556
- const quickStartServerData = (_a = window.SERVER_FLAGS) === null || _a === void 0 ? void 0 : _a.quickStarts;
557
- try {
558
- if (quickStartServerData) {
559
- disabledQuickStarts = (_b = JSON.parse(quickStartServerData).disabled) !== null && _b !== void 0 ? _b : [];
560
- }
561
- }
562
- catch (e) {
563
- // eslint-disable-next-line no-console
564
- console.error('error while parsing SERVER_FLAG.quickStarts', e);
565
- }
566
- return disabledQuickStarts;
567
- };
568
- const isDisabledQuickStart = (quickstart, disabledQuickStarts) => {
569
- var _a, _b;
570
- const quickStartName = (_b = (_a = quickstart.metadata.annotations) === null || _a === void 0 ? void 0 : _a[QUICK_START_NAME]) !== null && _b !== void 0 ? _b : quickstart.metadata.name;
571
- return disabledQuickStarts.includes(quickStartName);
572
- };
573
- const filterQuickStarts = (quickStarts, filterText, statusFilters, allQuickStartStates) => {
574
- const searchText = filterText.toLowerCase();
575
- return quickStarts.filter(({ metadata: { name }, spec: { displayName, prerequisites = [], description } }) => {
576
- const matchesFilter = statusFilters.length > 0
577
- ? statusFilters.includes(getQuickStartStatus(allQuickStartStates, name))
578
- : true;
579
- const matchesText = displayName.toLowerCase().includes(searchText) ||
580
- description.toLowerCase().includes(searchText) ||
581
- prerequisites.some((text) => text.toLowerCase().includes(searchText));
582
- return matchesFilter && matchesText;
583
- });
584
- };
585
- const camelize = (str) => str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
586
- if (+match === 0) {
587
- return '';
588
- } // or if (/\s+/.test(match)) for white spaces
589
- return index === 0 ? match.toLowerCase() : match.toUpperCase();
541
+ const QUICK_START_NAME = 'console.openshift.io/name';
542
+ const getQuickStartByName = (name, quickStarts) => quickStarts.find((quickStart) => quickStart.metadata.name === name);
543
+ const getQuickStartStatus = (allQuickStartStates, quickStartID) => { var _a, _b; return (_b = (_a = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[quickStartID]) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : exports.QuickStartStatus.NOT_STARTED; };
544
+ const getTaskStatusKey = (taskNumber) => `taskStatus${taskNumber}`;
545
+ const getQuickStartStatusCount = (allQuickStartStates, quickStarts) => quickStarts.reduce((totals, item) => {
546
+ totals[getQuickStartStatus(allQuickStartStates, item.metadata.name)]++;
547
+ return totals;
548
+ }, {
549
+ [exports.QuickStartStatus.IN_PROGRESS]: 0,
550
+ [exports.QuickStartStatus.COMPLETE]: 0,
551
+ [exports.QuickStartStatus.NOT_STARTED]: 0,
552
+ });
553
+ const getDisabledQuickStarts = () => {
554
+ var _a, _b;
555
+ let disabledQuickStarts = [];
556
+ const quickStartServerData = (_a = window.SERVER_FLAGS) === null || _a === void 0 ? void 0 : _a.quickStarts;
557
+ try {
558
+ if (quickStartServerData) {
559
+ disabledQuickStarts = (_b = JSON.parse(quickStartServerData).disabled) !== null && _b !== void 0 ? _b : [];
560
+ }
561
+ }
562
+ catch (e) {
563
+ // eslint-disable-next-line no-console
564
+ console.error('error while parsing SERVER_FLAG.quickStarts', e);
565
+ }
566
+ return disabledQuickStarts;
567
+ };
568
+ const isDisabledQuickStart = (quickstart, disabledQuickStarts) => {
569
+ var _a, _b;
570
+ const quickStartName = (_b = (_a = quickstart.metadata.annotations) === null || _a === void 0 ? void 0 : _a[QUICK_START_NAME]) !== null && _b !== void 0 ? _b : quickstart.metadata.name;
571
+ return disabledQuickStarts.includes(quickStartName);
572
+ };
573
+ const filterQuickStarts = (quickStarts, filterText, statusFilters, allQuickStartStates) => {
574
+ const searchText = filterText.toLowerCase();
575
+ return quickStarts.filter(({ metadata: { name }, spec: { displayName, prerequisites = [], description } }) => {
576
+ const matchesFilter = statusFilters.length > 0
577
+ ? statusFilters.includes(getQuickStartStatus(allQuickStartStates, name))
578
+ : true;
579
+ const matchesText = displayName.toLowerCase().includes(searchText) ||
580
+ description.toLowerCase().includes(searchText) ||
581
+ prerequisites.some((text) => text.toLowerCase().includes(searchText));
582
+ return matchesFilter && matchesText;
583
+ });
584
+ };
585
+ const camelize = (str) => str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
586
+ if (+match === 0) {
587
+ return '';
588
+ } // or if (/\s+/.test(match)) for white spaces
589
+ return index === 0 ? match.toLowerCase() : match.toUpperCase();
590
590
  });
591
591
 
592
- const pluralResolver = new PluralResolver({ simplifyPluralSuffix: true });
593
- const getDefaultQuickStartState = (totalTasks, initialStatus) => {
594
- const defaultQuickStartState = {
595
- status: initialStatus || exports.QuickStartStatus.NOT_STARTED,
596
- taskNumber: -1,
597
- };
598
- if (totalTasks) {
599
- for (let i = 0; i < totalTasks; i++) {
600
- defaultQuickStartState[getTaskStatusKey(i)] = exports.QuickStartTaskStatus.INIT;
601
- }
602
- }
603
- return defaultQuickStartState;
604
- };
605
- const QuickStartContextDefaults = {
606
- allQuickStarts: [],
607
- activeQuickStartID: '',
608
- allQuickStartStates: {},
609
- activeQuickStartState: {},
610
- setAllQuickStarts: () => { },
611
- resourceBundle: en,
612
- getResource: (resource) => resource,
613
- language: 'en',
614
- useQueryParams: true,
615
- filter: {
616
- keyword: '',
617
- status: {
618
- statusTypes: {},
619
- statusFilters: [],
620
- },
621
- },
622
- setFilter: () => { },
623
- footer: null,
624
- useLegacyHeaderColors: false,
625
- markdown: null,
626
- loading: false,
627
- alwaysShowTaskReview: true,
628
- };
629
- const QuickStartContext = React.createContext(QuickStartContextDefaults);
630
- const getResource = (resource, options, resourceBundle, lng) => {
631
- if (options && !isNaN(options.count)) {
632
- const suffix = pluralResolver.getSuffix(lng, options.count);
633
- if (suffix && resourceBundle[`${resource}_${suffix}`]) {
634
- // needs plural
635
- return resourceBundle[`${resource}_${suffix}`];
636
- }
637
- }
638
- return (resourceBundle && resourceBundle[resource]) || resource;
639
- };
640
- const useValuesForQuickStartContext = (value = {}) => {
641
- var _a, _b;
642
- const combinedValue = Object.assign(Object.assign({}, QuickStartContextDefaults), value);
643
- const { activeQuickStartID, setActiveQuickStartID, setAllQuickStartStates, useQueryParams, allQuickStartStates, allQuickStarts = [], footer, useLegacyHeaderColors, markdown, } = combinedValue;
644
- const [quickStarts, setQuickStarts] = React__default['default'].useState(combinedValue.allQuickStarts || []);
645
- const [resourceBundle, setResourceBundle] = React__default['default'].useState(Object.assign(Object.assign({}, en), combinedValue.resourceBundle));
646
- const [language, setLanguage] = React__default['default'].useState(combinedValue.language);
647
- const changeResourceBundle = (bundle, lng) => {
648
- lng && setLanguage(lng);
649
- setResourceBundle(Object.assign(Object.assign({}, en), bundle));
650
- };
651
- const findResource = React.useCallback((resource, count) => getResource(resource, count !== undefined ? { count } : null, resourceBundle, language), [resourceBundle, language]);
652
- const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
653
- const [alwaysShowTaskReview, setAlwaysShowTaskReview] = React__default['default'].useState(combinedValue.alwaysShowTaskReview);
654
- const initialSearchParams = new URLSearchParams(window.location.search);
655
- const initialSearchQuery = initialSearchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
656
- const initialStatusFilters = ((_a = initialSearchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
657
- const quickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, allQuickStarts);
658
- const [statusTypes, setStatusTypes] = React__default['default'].useState({
659
- [exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
660
- [exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
661
- [exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
662
- });
663
- const [statusFilters, setStatusFilters] = React__default['default'].useState(initialStatusFilters);
664
- const [filterKeyword, setFilterKeyword] = React__default['default'].useState(initialSearchQuery);
665
- const setFilter = (type, val) => {
666
- if (type === 'keyword') {
667
- setFilterKeyword(val);
668
- }
669
- else if (type === 'status') {
670
- setStatusFilters(val);
671
- }
672
- };
673
- React__default['default'].useEffect(() => {
674
- const updatedQuickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, quickStarts);
675
- setStatusTypes({
676
- [exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
677
- [exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
678
- [exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
679
- });
680
- }, [allQuickStartStates, findResource, quickStarts]);
681
- const updateAllQuickStarts = (qs) => {
682
- setQuickStarts(qs);
683
- };
684
- const setActiveQuickStart = React.useCallback((quickStartId, totalTasks) => {
685
- setActiveQuickStartID((id) => {
686
- if (!quickStartId || id === quickStartId) {
687
- useQueryParams && removeQueryArgument(QUICKSTART_ID_FILTER_KEY);
688
- return '';
689
- }
690
- useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
691
- return quickStartId;
692
- });
693
- setAllQuickStartStates((qs) => !quickStartId || qs[quickStartId]
694
- ? qs
695
- : Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks) }));
696
- }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
697
- const startQuickStart = React.useCallback((quickStartId, totalTasks) => {
698
- setActiveQuickStartID((id) => {
699
- if (!id || id !== quickStartId) {
700
- useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
701
- return quickStartId;
702
- }
703
- useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
704
- return id;
705
- });
706
- setAllQuickStartStates((qs) => {
707
- if (qs.hasOwnProperty(quickStartId)) {
708
- return Object.assign(Object.assign({}, qs), { [quickStartId]: Object.assign(Object.assign({}, qs[quickStartId]), { status: exports.QuickStartStatus.IN_PROGRESS }) });
709
- }
710
- return Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.IN_PROGRESS) });
711
- });
712
- }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
713
- const restartQuickStart = React.useCallback((quickStartId, totalTasks) => {
714
- setActiveQuickStartID((id) => {
715
- if (!id || id !== quickStartId) {
716
- useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
717
- return quickStartId;
718
- }
719
- useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
720
- return id;
721
- });
722
- setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.NOT_STARTED) })));
723
- }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
724
- // When alwaysShowTaskReview preference is enabled, skip visited step and go directly to review
725
- const stepAfterInitial = alwaysShowTaskReview
726
- ? exports.QuickStartTaskStatus.REVIEW
727
- : exports.QuickStartTaskStatus.VISITED;
728
- const nextStep = React.useCallback((totalTasks) => {
729
- if (!activeQuickStartID) {
730
- return;
731
- }
732
- setAllQuickStartStates((qs) => {
733
- const quickStart = qs[activeQuickStartID];
734
- const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
735
- const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
736
- const taskStatus = quickStart[getTaskStatusKey(taskNumber)];
737
- let updatedStatus;
738
- let updatedTaskNumber;
739
- let updatedTaskStatus;
740
- if (status === exports.QuickStartStatus.NOT_STARTED) {
741
- updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
742
- }
743
- else if (status === exports.QuickStartStatus.IN_PROGRESS &&
744
- !QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) &&
745
- taskNumber === totalTasks - 1) {
746
- updatedStatus = exports.QuickStartStatus.COMPLETE;
747
- }
748
- if (taskStatus === exports.QuickStartTaskStatus.VISITED) {
749
- updatedTaskStatus = exports.QuickStartTaskStatus.REVIEW;
750
- }
751
- if (taskNumber < totalTasks && !updatedTaskStatus) {
752
- updatedTaskNumber = taskNumber + 1;
753
- }
754
- const markInitialStepVisitedOrReview = updatedTaskNumber > -1 &&
755
- quickStart[getTaskStatusKey(updatedTaskNumber)] === exports.QuickStartTaskStatus.INIT
756
- ? stepAfterInitial
757
- : quickStart[getTaskStatusKey(updatedTaskNumber)];
758
- const newState = Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), (updatedTaskNumber > -1
759
- ? {
760
- taskNumber: updatedTaskNumber,
761
- [getTaskStatusKey(updatedTaskNumber)]: markInitialStepVisitedOrReview,
762
- }
763
- : {})), (updatedTaskStatus ? { [getTaskStatusKey(taskNumber)]: updatedTaskStatus } : {})) });
764
- return newState;
765
- });
766
- }, [activeQuickStartID, setAllQuickStartStates, stepAfterInitial]);
767
- const previousStep = React.useCallback(() => {
768
- setAllQuickStartStates((qs) => {
769
- const quickStart = qs[activeQuickStartID];
770
- const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
771
- if (taskNumber < 0) {
772
- return qs;
773
- }
774
- return Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign({}, quickStart), { taskNumber: taskNumber - 1 }) });
775
- });
776
- }, [activeQuickStartID, setAllQuickStartStates]);
777
- const setQuickStartTaskNumber = React.useCallback((quickStartId, taskNumber) => {
778
- setAllQuickStartStates((qs) => {
779
- const quickStart = qs[quickStartId];
780
- const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
781
- let updatedStatus;
782
- if (taskNumber > -1 && status === exports.QuickStartStatus.NOT_STARTED) {
783
- updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
784
- }
785
- let updatedTaskStatus = {};
786
- for (let taskIndex = 0; taskIndex <= taskNumber; taskIndex++) {
787
- const taskStatus = quickStart[getTaskStatusKey(taskIndex)];
788
- const newTaskStatus = taskStatus === exports.QuickStartTaskStatus.INIT ? stepAfterInitial : undefined;
789
- if (newTaskStatus) {
790
- updatedTaskStatus = Object.assign(Object.assign({}, updatedTaskStatus), { [getTaskStatusKey(taskIndex)]: newTaskStatus });
791
- }
792
- }
793
- const updatedQuickStart = Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), { taskNumber }), updatedTaskStatus);
794
- return Object.assign(Object.assign({}, qs), { [quickStartId]: updatedQuickStart });
795
- });
796
- }, [setAllQuickStartStates, stepAfterInitial]);
797
- const setQuickStartTaskStatus = React.useCallback((taskStatus) => {
798
- const quickStart = allQuickStartStates[activeQuickStartID];
799
- const { taskNumber } = quickStart;
800
- const updatedQuickStart = Object.assign(Object.assign({}, quickStart), { [getTaskStatusKey(taskNumber)]: taskStatus });
801
- setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [activeQuickStartID]: updatedQuickStart })));
802
- }, [allQuickStartStates, activeQuickStartID, setAllQuickStartStates]);
803
- const activeQuickStartState = (_b = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[activeQuickStartID]) !== null && _b !== void 0 ? _b : {};
804
- const getQuickStartForId = React.useCallback((id) => allQuickStartStates[id], [
805
- allQuickStartStates,
806
- ]);
807
- return {
808
- allQuickStarts: quickStarts,
809
- setAllQuickStarts: updateAllQuickStarts,
810
- activeQuickStartID,
811
- setActiveQuickStartID,
812
- allQuickStartStates,
813
- setAllQuickStartStates,
814
- activeQuickStartState,
815
- setActiveQuickStart: value.setActiveQuickStart || setActiveQuickStart,
816
- startQuickStart: value.startQuickStart || startQuickStart,
817
- restartQuickStart: value.restartQuickStart || restartQuickStart,
818
- nextStep: value.nextStep || nextStep,
819
- previousStep: value.previousStep || previousStep,
820
- setQuickStartTaskNumber,
821
- setQuickStartTaskStatus,
822
- getQuickStartForId,
823
- footer,
824
- useLegacyHeaderColors,
825
- useQueryParams,
826
- markdown,
827
- resourceBundle,
828
- getResource: findResource,
829
- setResourceBundle: changeResourceBundle,
830
- language,
831
- setLanguage,
832
- // revisit if this should be in public context API
833
- filter: {
834
- keyword: filterKeyword,
835
- status: {
836
- statusTypes,
837
- statusFilters,
838
- },
839
- },
840
- setFilter,
841
- loading,
842
- setLoading,
843
- alwaysShowTaskReview,
844
- setAlwaysShowTaskReview,
845
- };
846
- };
592
+ const pluralResolver = new PluralResolver({ simplifyPluralSuffix: true });
593
+ const getDefaultQuickStartState = (totalTasks, initialStatus) => {
594
+ const defaultQuickStartState = {
595
+ status: initialStatus || exports.QuickStartStatus.NOT_STARTED,
596
+ taskNumber: -1,
597
+ };
598
+ if (totalTasks) {
599
+ for (let i = 0; i < totalTasks; i++) {
600
+ defaultQuickStartState[getTaskStatusKey(i)] = exports.QuickStartTaskStatus.INIT;
601
+ }
602
+ }
603
+ return defaultQuickStartState;
604
+ };
605
+ const QuickStartContextDefaults = {
606
+ allQuickStarts: [],
607
+ activeQuickStartID: '',
608
+ allQuickStartStates: {},
609
+ activeQuickStartState: {},
610
+ setAllQuickStarts: () => { },
611
+ resourceBundle: en,
612
+ getResource: (resource) => resource,
613
+ language: 'en',
614
+ useQueryParams: true,
615
+ filter: {
616
+ keyword: '',
617
+ status: {
618
+ statusTypes: {},
619
+ statusFilters: [],
620
+ },
621
+ },
622
+ setFilter: () => { },
623
+ footer: null,
624
+ useLegacyHeaderColors: false,
625
+ markdown: null,
626
+ loading: false,
627
+ alwaysShowTaskReview: true,
628
+ };
629
+ const QuickStartContext = React.createContext(QuickStartContextDefaults);
630
+ const getResource = (resource, options, resourceBundle, lng) => {
631
+ if (options && !isNaN(options.count)) {
632
+ const suffix = pluralResolver.getSuffix(lng, options.count);
633
+ if (suffix && resourceBundle[`${resource}_${suffix}`]) {
634
+ // needs plural
635
+ return resourceBundle[`${resource}_${suffix}`];
636
+ }
637
+ }
638
+ return (resourceBundle && resourceBundle[resource]) || resource;
639
+ };
640
+ const useValuesForQuickStartContext = (value = {}) => {
641
+ var _a, _b;
642
+ const combinedValue = Object.assign(Object.assign({}, QuickStartContextDefaults), value);
643
+ const { activeQuickStartID, setActiveQuickStartID, setAllQuickStartStates, useQueryParams, allQuickStartStates, allQuickStarts = [], footer, useLegacyHeaderColors, markdown, } = combinedValue;
644
+ const [quickStarts, setQuickStarts] = React__default['default'].useState(combinedValue.allQuickStarts || []);
645
+ const [resourceBundle, setResourceBundle] = React__default['default'].useState(Object.assign(Object.assign({}, en), combinedValue.resourceBundle));
646
+ const [language, setLanguage] = React__default['default'].useState(combinedValue.language);
647
+ const changeResourceBundle = (bundle, lng) => {
648
+ lng && setLanguage(lng);
649
+ setResourceBundle(Object.assign(Object.assign({}, en), bundle));
650
+ };
651
+ const findResource = React.useCallback((resource, count) => getResource(resource, count !== undefined ? { count } : null, resourceBundle, language), [resourceBundle, language]);
652
+ const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
653
+ const [alwaysShowTaskReview, setAlwaysShowTaskReview] = React__default['default'].useState(combinedValue.alwaysShowTaskReview);
654
+ const initialSearchParams = new URLSearchParams(window.location.search);
655
+ const initialSearchQuery = initialSearchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
656
+ const initialStatusFilters = ((_a = initialSearchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
657
+ const quickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, allQuickStarts);
658
+ const [statusTypes, setStatusTypes] = React__default['default'].useState({
659
+ [exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
660
+ [exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
661
+ [exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
662
+ });
663
+ const [statusFilters, setStatusFilters] = React__default['default'].useState(initialStatusFilters);
664
+ const [filterKeyword, setFilterKeyword] = React__default['default'].useState(initialSearchQuery);
665
+ const setFilter = (type, val) => {
666
+ if (type === 'keyword') {
667
+ setFilterKeyword(val);
668
+ }
669
+ else if (type === 'status') {
670
+ setStatusFilters(val);
671
+ }
672
+ };
673
+ React__default['default'].useEffect(() => {
674
+ const updatedQuickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, quickStarts);
675
+ setStatusTypes({
676
+ [exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
677
+ [exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
678
+ [exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
679
+ });
680
+ }, [allQuickStartStates, findResource, quickStarts]);
681
+ const updateAllQuickStarts = (qs) => {
682
+ setQuickStarts(qs);
683
+ };
684
+ const setActiveQuickStart = React.useCallback((quickStartId, totalTasks) => {
685
+ setActiveQuickStartID((id) => {
686
+ if (!quickStartId || id === quickStartId) {
687
+ useQueryParams && removeQueryArgument(QUICKSTART_ID_FILTER_KEY);
688
+ return '';
689
+ }
690
+ useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
691
+ return quickStartId;
692
+ });
693
+ setAllQuickStartStates((qs) => !quickStartId || qs[quickStartId]
694
+ ? qs
695
+ : Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks) }));
696
+ }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
697
+ const startQuickStart = React.useCallback((quickStartId, totalTasks) => {
698
+ setActiveQuickStartID((id) => {
699
+ if (!id || id !== quickStartId) {
700
+ useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
701
+ return quickStartId;
702
+ }
703
+ useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
704
+ return id;
705
+ });
706
+ setAllQuickStartStates((qs) => {
707
+ if (qs.hasOwnProperty(quickStartId)) {
708
+ return Object.assign(Object.assign({}, qs), { [quickStartId]: Object.assign(Object.assign({}, qs[quickStartId]), { status: exports.QuickStartStatus.IN_PROGRESS }) });
709
+ }
710
+ return Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.IN_PROGRESS) });
711
+ });
712
+ }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
713
+ const restartQuickStart = React.useCallback((quickStartId, totalTasks) => {
714
+ setActiveQuickStartID((id) => {
715
+ if (!id || id !== quickStartId) {
716
+ useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
717
+ return quickStartId;
718
+ }
719
+ useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
720
+ return id;
721
+ });
722
+ setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.NOT_STARTED) })));
723
+ }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
724
+ // When alwaysShowTaskReview preference is enabled, skip visited step and go directly to review
725
+ const stepAfterInitial = alwaysShowTaskReview
726
+ ? exports.QuickStartTaskStatus.REVIEW
727
+ : exports.QuickStartTaskStatus.VISITED;
728
+ const nextStep = React.useCallback((totalTasks) => {
729
+ if (!activeQuickStartID) {
730
+ return;
731
+ }
732
+ setAllQuickStartStates((qs) => {
733
+ const quickStart = qs[activeQuickStartID];
734
+ const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
735
+ const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
736
+ const taskStatus = quickStart[getTaskStatusKey(taskNumber)];
737
+ let updatedStatus;
738
+ let updatedTaskNumber;
739
+ let updatedTaskStatus;
740
+ if (status === exports.QuickStartStatus.NOT_STARTED) {
741
+ updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
742
+ }
743
+ else if (status === exports.QuickStartStatus.IN_PROGRESS &&
744
+ !QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) &&
745
+ taskNumber === totalTasks - 1) {
746
+ updatedStatus = exports.QuickStartStatus.COMPLETE;
747
+ }
748
+ if (taskStatus === exports.QuickStartTaskStatus.VISITED) {
749
+ updatedTaskStatus = exports.QuickStartTaskStatus.REVIEW;
750
+ }
751
+ if (taskNumber < totalTasks && !updatedTaskStatus) {
752
+ updatedTaskNumber = taskNumber + 1;
753
+ }
754
+ const markInitialStepVisitedOrReview = updatedTaskNumber > -1 &&
755
+ quickStart[getTaskStatusKey(updatedTaskNumber)] === exports.QuickStartTaskStatus.INIT
756
+ ? stepAfterInitial
757
+ : quickStart[getTaskStatusKey(updatedTaskNumber)];
758
+ const newState = Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), (updatedTaskNumber > -1
759
+ ? {
760
+ taskNumber: updatedTaskNumber,
761
+ [getTaskStatusKey(updatedTaskNumber)]: markInitialStepVisitedOrReview,
762
+ }
763
+ : {})), (updatedTaskStatus ? { [getTaskStatusKey(taskNumber)]: updatedTaskStatus } : {})) });
764
+ return newState;
765
+ });
766
+ }, [activeQuickStartID, setAllQuickStartStates, stepAfterInitial]);
767
+ const previousStep = React.useCallback(() => {
768
+ setAllQuickStartStates((qs) => {
769
+ const quickStart = qs[activeQuickStartID];
770
+ const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
771
+ if (taskNumber < 0) {
772
+ return qs;
773
+ }
774
+ return Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign({}, quickStart), { taskNumber: taskNumber - 1 }) });
775
+ });
776
+ }, [activeQuickStartID, setAllQuickStartStates]);
777
+ const setQuickStartTaskNumber = React.useCallback((quickStartId, taskNumber) => {
778
+ setAllQuickStartStates((qs) => {
779
+ const quickStart = qs[quickStartId];
780
+ const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
781
+ let updatedStatus;
782
+ if (taskNumber > -1 && status === exports.QuickStartStatus.NOT_STARTED) {
783
+ updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
784
+ }
785
+ let updatedTaskStatus = {};
786
+ for (let taskIndex = 0; taskIndex <= taskNumber; taskIndex++) {
787
+ const taskStatus = quickStart[getTaskStatusKey(taskIndex)];
788
+ const newTaskStatus = taskStatus === exports.QuickStartTaskStatus.INIT ? stepAfterInitial : undefined;
789
+ if (newTaskStatus) {
790
+ updatedTaskStatus = Object.assign(Object.assign({}, updatedTaskStatus), { [getTaskStatusKey(taskIndex)]: newTaskStatus });
791
+ }
792
+ }
793
+ const updatedQuickStart = Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), { taskNumber }), updatedTaskStatus);
794
+ return Object.assign(Object.assign({}, qs), { [quickStartId]: updatedQuickStart });
795
+ });
796
+ }, [setAllQuickStartStates, stepAfterInitial]);
797
+ const setQuickStartTaskStatus = React.useCallback((taskStatus) => {
798
+ const quickStart = allQuickStartStates[activeQuickStartID];
799
+ const { taskNumber } = quickStart;
800
+ const updatedQuickStart = Object.assign(Object.assign({}, quickStart), { [getTaskStatusKey(taskNumber)]: taskStatus });
801
+ setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [activeQuickStartID]: updatedQuickStart })));
802
+ }, [allQuickStartStates, activeQuickStartID, setAllQuickStartStates]);
803
+ const activeQuickStartState = (_b = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[activeQuickStartID]) !== null && _b !== void 0 ? _b : {};
804
+ const getQuickStartForId = React.useCallback((id) => allQuickStartStates[id], [
805
+ allQuickStartStates,
806
+ ]);
807
+ return {
808
+ allQuickStarts: quickStarts,
809
+ setAllQuickStarts: updateAllQuickStarts,
810
+ activeQuickStartID,
811
+ setActiveQuickStartID,
812
+ allQuickStartStates,
813
+ setAllQuickStartStates,
814
+ activeQuickStartState,
815
+ setActiveQuickStart: value.setActiveQuickStart || setActiveQuickStart,
816
+ startQuickStart: value.startQuickStart || startQuickStart,
817
+ restartQuickStart: value.restartQuickStart || restartQuickStart,
818
+ nextStep: value.nextStep || nextStep,
819
+ previousStep: value.previousStep || previousStep,
820
+ setQuickStartTaskNumber,
821
+ setQuickStartTaskStatus,
822
+ getQuickStartForId,
823
+ footer,
824
+ useLegacyHeaderColors,
825
+ useQueryParams,
826
+ markdown,
827
+ resourceBundle,
828
+ getResource: findResource,
829
+ setResourceBundle: changeResourceBundle,
830
+ language,
831
+ setLanguage,
832
+ // revisit if this should be in public context API
833
+ filter: {
834
+ keyword: filterKeyword,
835
+ status: {
836
+ statusTypes,
837
+ statusFilters,
838
+ },
839
+ },
840
+ setFilter,
841
+ loading,
842
+ setLoading,
843
+ alwaysShowTaskReview,
844
+ setAlwaysShowTaskReview,
845
+ };
846
+ };
847
847
  const QuickStartContextProvider = ({ children, value }) => (React__default['default'].createElement(QuickStartContext.Provider, { value: useValuesForQuickStartContext(value) }, children));
848
848
 
849
- const Box = ({ children, className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-status-box', className) }, children));
850
- const Loading = ({ className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-m-loader', className) },
851
- React__namespace.createElement("div", { className: "pfext-m-loader-dot__one" }),
852
- React__namespace.createElement("div", { className: "pfext-m-loader-dot__two" }),
853
- React__namespace.createElement("div", { className: "pfext-m-loader-dot__three" })));
854
- Loading.displayName = 'Loading';
855
- const LoadingBox = ({ className, message }) => (React__namespace.createElement(Box, { className: reactStyles.css('pfext-status-box--loading', className) },
856
- React__namespace.createElement(Loading, null),
857
- message && React__namespace.createElement("div", { className: "pfext-status-box__loading-message" }, message)));
858
- LoadingBox.displayName = 'LoadingBox';
859
- const EmptyBox = ({ label }) => {
860
- const { getResource } = React__namespace.useContext(QuickStartContext);
861
- return (React__namespace.createElement(Box, null,
862
- React__namespace.createElement("div", { "data-test": "empty-message", className: "text-center" }, label
863
- ? getResource('No {{label}} found').replace('{{label}}', label)
864
- : getResource('Not found'))));
865
- };
849
+ const Box = ({ children, className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-status-box', className) }, children));
850
+ const Loading = ({ className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-m-loader', className) },
851
+ React__namespace.createElement("div", { className: "pfext-m-loader-dot__one" }),
852
+ React__namespace.createElement("div", { className: "pfext-m-loader-dot__two" }),
853
+ React__namespace.createElement("div", { className: "pfext-m-loader-dot__three" })));
854
+ Loading.displayName = 'Loading';
855
+ const LoadingBox = ({ className, message }) => (React__namespace.createElement(Box, { className: reactStyles.css('pfext-status-box--loading', className) },
856
+ React__namespace.createElement(Loading, null),
857
+ message && React__namespace.createElement("div", { className: "pfext-status-box__loading-message" }, message)));
858
+ LoadingBox.displayName = 'LoadingBox';
859
+ const EmptyBox = ({ label }) => {
860
+ const { getResource } = React__namespace.useContext(QuickStartContext);
861
+ return (React__namespace.createElement(Box, null,
862
+ React__namespace.createElement("div", { "data-test": "empty-message", className: "text-center" }, label
863
+ ? getResource('No {{label}} found').replace('{{label}}', label)
864
+ : getResource('Not found'))));
865
+ };
866
866
  EmptyBox.displayName = 'EmptyBox';
867
867
 
868
- const MEMO = {};
869
- const CamelCaseWrap = ({ value, dataTest }) => {
870
- if (!value) {
871
- return '-';
872
- }
873
- if (MEMO[value]) {
874
- return MEMO[value];
875
- }
876
- // Add word break points before capital letters (but keep consecutive capital letters together).
877
- const words = value.match(/[A-Z]+[^A-Z]*|[^A-Z]+/g);
878
- const rendered = (React__namespace.createElement("span", { "data-test": dataTest }, words.map((word, i) => (React__namespace.createElement(React__namespace.Fragment, { key: i },
879
- word,
880
- i !== words.length - 1 && React__namespace.createElement("wbr", null))))));
881
- MEMO[value] = rendered;
882
- return rendered;
868
+ const MEMO = {};
869
+ const CamelCaseWrap = ({ value, dataTest }) => {
870
+ if (!value) {
871
+ return '-';
872
+ }
873
+ if (MEMO[value]) {
874
+ return MEMO[value];
875
+ }
876
+ // Add word break points before capital letters (but keep consecutive capital letters together).
877
+ const words = value.match(/[A-Z]+[^A-Z]*|[^A-Z]+/g);
878
+ const rendered = (React__namespace.createElement("span", { "data-test": dataTest }, words.map((word, i) => (React__namespace.createElement(React__namespace.Fragment, { key: i },
879
+ word,
880
+ i !== words.length - 1 && React__namespace.createElement("wbr", null))))));
881
+ MEMO[value] = rendered;
882
+ return rendered;
883
883
  };
884
884
 
885
885
  class CatalogTile extends React__namespace.Component {
886
- constructor() {
887
- super(...arguments);
886
+ constructor(props) {
887
+ super(props);
888
888
  this.handleClick = (e) => {
889
889
  const { onClick, href } = this.props;
890
890
  if (!href) {
@@ -900,13 +900,18 @@ class CatalogTile extends React__namespace.Component {
900
900
  }
901
901
  return (React__namespace.createElement("div", { className: "catalog-tile-pf-badge-container" }, badges.map((badge, index) => (React__namespace.createElement("span", { key: `badge-${index}` }, badge)))));
902
902
  };
903
+ this.generatedId = reactCore.getUniqueId('pf-catalog-tile');
903
904
  }
904
905
  render() {
905
906
  const _a = this.props, { id, className, featured, onClick, href, icon, iconImg, iconAlt, iconClass, badges, title, vendor, description, footer,
906
907
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
907
908
  ref, children } = _a, props = tslib.__rest(_a, ["id", "className", "featured", "onClick", "href", "icon", "iconImg", "iconAlt", "iconClass", "badges", "title", "vendor", "description", "footer", "ref", "children"]);
908
- return (React__namespace.createElement(reactCore.Card, Object.assign({ component: href ? 'a' : 'div', id: id, href: href || '#', className: reactStyles.css('catalog-tile-pf', { featured }, className), isClickable: !!onClick }, props),
909
- (badges.length > 0 || iconImg || iconClass || icon || onClick) && (React__namespace.createElement(reactCore.CardHeader, { actions: { actions: badges.length > 0 && this.renderBadges(badges) }, selectableActions: onClick && { selectableActionId: id + '-input', onClickAction: (e) => this.handleClick(e), selectableActionAriaLabelledby: id } },
909
+ return (React__namespace.createElement(reactCore.Card, Object.assign({ component: href ? 'a' : 'div', id: id || this.generatedId, href: href || '#', className: reactStyles.css('catalog-tile-pf', { featured }, className), isClickable: !!onClick }, props),
910
+ (badges.length > 0 || iconImg || iconClass || icon || onClick) && (React__namespace.createElement(reactCore.CardHeader, { actions: { actions: badges.length > 0 && this.renderBadges(badges) }, selectableActions: onClick && {
911
+ selectableActionId: id + '-input',
912
+ onClickAction: (e) => this.handleClick(e),
913
+ selectableActionAriaLabelledby: id
914
+ } },
910
915
  iconImg && React__namespace.createElement("img", { className: "catalog-tile-pf-icon", src: iconImg, alt: iconAlt }),
911
916
  !iconImg && (iconClass || icon) && React__namespace.createElement("span", { className: `catalog-tile-pf-icon ${iconClass}` }, icon))),
912
917
  React__namespace.createElement(reactCore.CardTitle, { className: "catalog-tile-pf-header" },
@@ -921,7 +926,7 @@ class CatalogTile extends React__namespace.Component {
921
926
  }
922
927
  CatalogTile.displayName = 'CatalogTile';
923
928
  CatalogTile.defaultProps = {
924
- id: reactCore.getUniqueId('pf-catalog-tile'),
929
+ id: null,
925
930
  className: '',
926
931
  featured: false,
927
932
  onClick: null,
@@ -937,335 +942,335 @@ CatalogTile.defaultProps = {
937
942
  children: null
938
943
  };
939
944
 
940
- const Modal = (_a) => {
941
- var { isFullScreen = false, className } = _a, props = tslib.__rest(_a, ["isFullScreen", "className"]);
942
- return (React__namespace.createElement(reactCore.Modal, Object.assign({}, props, { className: reactStyles.css('pfext-modal', className), appendTo: () => (isFullScreen ? document.body : document.querySelector('#modal-container')) })));
943
- };
944
-
945
- const getContainer = (container) => typeof container === 'function' ? container() : container;
946
- const Portal = ({ children, container }) => {
947
- const [containerNode, setContainerNode] = React__namespace.useState();
948
- reactCore.useIsomorphicLayoutEffect(() => {
949
- setContainerNode(getContainer(container) || document.body);
950
- }, [container]);
951
- return containerNode ? ReactDOM__namespace.createPortal(children, containerNode) : null;
952
- };
953
-
954
- const SimplePopper = ({ children }) => {
955
- const openProp = true;
956
- const nodeRef = React__namespace.useRef();
957
- const popperRef = React__namespace.useRef(null);
958
- const [isOpen, setOpenState] = React__namespace.useState(openProp);
959
- const setOpen = React__namespace.useCallback((newOpen) => {
960
- setOpenState(newOpen);
961
- }, []);
962
- React__namespace.useEffect(() => {
963
- setOpen(openProp);
964
- }, [openProp, setOpen]);
965
- const onKeyDown = React__namespace.useCallback((e) => {
966
- if (e.keyCode === 27) {
967
- setOpen(false);
968
- }
969
- }, [setOpen]);
970
- const onClickOutside = React__namespace.useCallback((e) => {
971
- if (!nodeRef.current || (e.target instanceof Node && !nodeRef.current.contains(e.target))) {
972
- setOpen(false);
973
- }
974
- }, [setOpen]);
975
- const destroy = React__namespace.useCallback(() => {
976
- if (popperRef.current) {
977
- popperRef.current.destroy();
978
- document.removeEventListener('keydown', onKeyDown, true);
979
- document.removeEventListener('mousedown', onClickOutside, true);
980
- document.removeEventListener('touchstart', onClickOutside, true);
981
- }
982
- }, [onClickOutside, onKeyDown]);
983
- const initialize = React__namespace.useCallback(() => {
984
- if (!nodeRef.current || !isOpen) {
985
- return;
986
- }
987
- destroy();
988
- }, [isOpen, destroy]);
989
- const nodeRefCallback = React__namespace.useCallback((node) => {
990
- nodeRef.current = node;
991
- initialize();
992
- }, [initialize]);
993
- React__namespace.useEffect(() => {
994
- initialize();
995
- }, [initialize]);
996
- React__namespace.useEffect(() => () => {
997
- destroy();
998
- }, [destroy]);
999
- React__namespace.useEffect(() => {
1000
- if (!isOpen) {
1001
- destroy();
1002
- }
1003
- }, [destroy, isOpen]);
1004
- return isOpen ? (React__namespace.createElement(Portal, null,
1005
- React__namespace.createElement("div", { ref: nodeRefCallback, style: { zIndex: 9999, position: 'absolute', top: 0, left: 0 }, className: "pfext-quick-start__base" }, children))) : null;
1006
- };
1007
-
1008
- const isInViewport = (elementToCheck) => {
1009
- const rect = elementToCheck.getBoundingClientRect();
1010
- return (rect.top >= 0 &&
1011
- rect.left >= 0 &&
1012
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
1013
- rect.right <= (window.innerWidth || document.documentElement.clientWidth));
1014
- };
1015
- const InteractiveSpotlight = ({ element }) => {
1016
- const { top, bottom, left, right, height, width } = element.getBoundingClientRect();
1017
- const style = {
1018
- height,
1019
- width,
1020
- top,
1021
- left,
1022
- bottom,
1023
- right,
1024
- };
1025
- const [clicked, setClicked] = React__namespace.useState(false);
1026
- React__namespace.useEffect(() => {
1027
- if (!clicked) {
1028
- if (!isInViewport(element)) {
1029
- element.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' });
1030
- }
1031
- const handleClick = () => setClicked(true);
1032
- document.addEventListener('click', handleClick);
1033
- return () => {
1034
- document.removeEventListener('click', handleClick);
1035
- };
1036
- }
1037
- return () => { };
1038
- }, [element, clicked]);
1039
- if (clicked) {
1040
- return null;
1041
- }
1042
- return (React__namespace.createElement(Portal, null,
1043
- React__namespace.createElement(SimplePopper, null,
1044
- React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-animate", style: style }))));
1045
- };
1046
-
1047
- var ScrollDirection;
1048
- (function (ScrollDirection) {
1049
- ScrollDirection["scrollingUp"] = "scrolling-up";
1050
- ScrollDirection["scrollingDown"] = "scrolling-down";
1051
- ScrollDirection["scrolledToBottom"] = "scrolled-to-bottom";
1052
- ScrollDirection["scrolledToTop"] = "scrolled-to-top";
945
+ const Modal = (_a) => {
946
+ var { isFullScreen = false, className } = _a, props = tslib.__rest(_a, ["isFullScreen", "className"]);
947
+ return (React__namespace.createElement(reactCore.Modal, Object.assign({}, props, { className: reactStyles.css('pfext-modal', className), appendTo: () => (isFullScreen ? document.body : document.querySelector('#modal-container')) })));
948
+ };
949
+
950
+ const getContainer = (container) => typeof container === 'function' ? container() : container;
951
+ const Portal = ({ children, container }) => {
952
+ const [containerNode, setContainerNode] = React__namespace.useState();
953
+ reactCore.useIsomorphicLayoutEffect(() => {
954
+ setContainerNode(getContainer(container) || document.body);
955
+ }, [container]);
956
+ return containerNode ? ReactDOM__namespace.createPortal(children, containerNode) : null;
957
+ };
958
+
959
+ const SimplePopper = ({ children }) => {
960
+ const openProp = true;
961
+ const nodeRef = React__namespace.useRef();
962
+ const popperRef = React__namespace.useRef(null);
963
+ const [isOpen, setOpenState] = React__namespace.useState(openProp);
964
+ const setOpen = React__namespace.useCallback((newOpen) => {
965
+ setOpenState(newOpen);
966
+ }, []);
967
+ React__namespace.useEffect(() => {
968
+ setOpen(openProp);
969
+ }, [openProp, setOpen]);
970
+ const onKeyDown = React__namespace.useCallback((e) => {
971
+ if (e.keyCode === 27) {
972
+ setOpen(false);
973
+ }
974
+ }, [setOpen]);
975
+ const onClickOutside = React__namespace.useCallback((e) => {
976
+ if (!nodeRef.current || (e.target instanceof Node && !nodeRef.current.contains(e.target))) {
977
+ setOpen(false);
978
+ }
979
+ }, [setOpen]);
980
+ const destroy = React__namespace.useCallback(() => {
981
+ if (popperRef.current) {
982
+ popperRef.current.destroy();
983
+ document.removeEventListener('keydown', onKeyDown, true);
984
+ document.removeEventListener('mousedown', onClickOutside, true);
985
+ document.removeEventListener('touchstart', onClickOutside, true);
986
+ }
987
+ }, [onClickOutside, onKeyDown]);
988
+ const initialize = React__namespace.useCallback(() => {
989
+ if (!nodeRef.current || !isOpen) {
990
+ return;
991
+ }
992
+ destroy();
993
+ }, [isOpen, destroy]);
994
+ const nodeRefCallback = React__namespace.useCallback((node) => {
995
+ nodeRef.current = node;
996
+ initialize();
997
+ }, [initialize]);
998
+ React__namespace.useEffect(() => {
999
+ initialize();
1000
+ }, [initialize]);
1001
+ React__namespace.useEffect(() => () => {
1002
+ destroy();
1003
+ }, [destroy]);
1004
+ React__namespace.useEffect(() => {
1005
+ if (!isOpen) {
1006
+ destroy();
1007
+ }
1008
+ }, [destroy, isOpen]);
1009
+ return isOpen ? (React__namespace.createElement(Portal, null,
1010
+ React__namespace.createElement("div", { ref: nodeRefCallback, style: { zIndex: 9999, position: 'absolute', top: 0, left: 0 }, className: "pfext-quick-start__base" }, children))) : null;
1011
+ };
1012
+
1013
+ const isInViewport = (elementToCheck) => {
1014
+ const rect = elementToCheck.getBoundingClientRect();
1015
+ return (rect.top >= 0 &&
1016
+ rect.left >= 0 &&
1017
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
1018
+ rect.right <= (window.innerWidth || document.documentElement.clientWidth));
1019
+ };
1020
+ const InteractiveSpotlight = ({ element }) => {
1021
+ const { top, bottom, left, right, height, width } = element.getBoundingClientRect();
1022
+ const style = {
1023
+ height,
1024
+ width,
1025
+ top,
1026
+ left,
1027
+ bottom,
1028
+ right,
1029
+ };
1030
+ const [clicked, setClicked] = React__namespace.useState(false);
1031
+ React__namespace.useEffect(() => {
1032
+ if (!clicked) {
1033
+ if (!isInViewport(element)) {
1034
+ element.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' });
1035
+ }
1036
+ const handleClick = () => setClicked(true);
1037
+ document.addEventListener('click', handleClick);
1038
+ return () => {
1039
+ document.removeEventListener('click', handleClick);
1040
+ };
1041
+ }
1042
+ return () => { };
1043
+ }, [element, clicked]);
1044
+ if (clicked) {
1045
+ return null;
1046
+ }
1047
+ return (React__namespace.createElement(Portal, null,
1048
+ React__namespace.createElement(SimplePopper, null,
1049
+ React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-animate", style: style }))));
1050
+ };
1051
+
1052
+ var ScrollDirection;
1053
+ (function (ScrollDirection) {
1054
+ ScrollDirection["scrollingUp"] = "scrolling-up";
1055
+ ScrollDirection["scrollingDown"] = "scrolling-down";
1056
+ ScrollDirection["scrolledToBottom"] = "scrolled-to-bottom";
1057
+ ScrollDirection["scrolledToTop"] = "scrolled-to-top";
1053
1058
  })(ScrollDirection || (ScrollDirection = {}));
1054
1059
 
1055
- const useResizeObserver = (callback, targetElement, observerOptions = undefined) => {
1056
- const element = React__namespace.useMemo(() => targetElement !== null && targetElement !== void 0 ? targetElement : document.querySelector('body'), [targetElement]);
1057
- React__namespace.useEffect(() => {
1058
- const observer = new ResizeObserver(callback);
1059
- observer.observe(element, observerOptions);
1060
- return () => {
1061
- observer.disconnect();
1062
- };
1063
- }, [callback, observerOptions, element]);
1064
- };
1065
-
1066
- var Shadows;
1067
- (function (Shadows) {
1068
- Shadows["none"] = "none";
1069
- Shadows["both"] = "both";
1070
- Shadows["top"] = "top";
1071
- Shadows["bottom"] = "bottom";
1072
- })(Shadows || (Shadows = {}));
1073
- const useScrollShadows = (node) => {
1074
- const [shadows, setShadows] = React__namespace.useState(Shadows.none);
1075
- const computeShadows = React__namespace.useCallback(() => {
1076
- if (node) {
1077
- const { scrollTop, clientHeight, scrollHeight } = node;
1078
- const top = scrollTop !== 0;
1079
- const bottom = scrollTop + clientHeight < scrollHeight;
1080
- if (top && bottom) {
1081
- setShadows(Shadows.both);
1082
- }
1083
- else if (top) {
1084
- setShadows(Shadows.top);
1085
- }
1086
- else if (bottom) {
1087
- setShadows(Shadows.bottom);
1088
- }
1089
- else {
1090
- setShadows(Shadows.none);
1091
- }
1092
- }
1093
- }, [node]);
1094
- // recompute when the scroll container changes in size
1095
- useResizeObserver(computeShadows, node);
1096
- React__namespace.useEffect(() => {
1097
- if (node) {
1098
- // compute initial shadows
1099
- computeShadows();
1100
- // listen for scroll events
1101
- node.addEventListener('scroll', computeShadows);
1102
- }
1103
- return () => {
1104
- if (node) {
1105
- node.removeEventListener('scroll', computeShadows);
1106
- }
1107
- };
1108
- }, [node, computeShadows]);
1109
- return shadows;
1110
- };
1111
-
1112
- const useBoundingClientRect = (targetElement) => {
1113
- const [clientRect, setClientRect] = React__namespace.useState(() => targetElement ? targetElement.getBoundingClientRect() : null);
1114
- const observerCallback = React__namespace.useCallback(() => {
1115
- setClientRect(targetElement ? targetElement.getBoundingClientRect() : null);
1116
- }, [targetElement]);
1117
- useResizeObserver(observerCallback);
1118
- return clientRect;
1119
- };
1120
-
1121
- /**
1122
- * React hook that forces component render.
1123
- */
1060
+ const useResizeObserver = (callback, targetElement, observerOptions = undefined) => {
1061
+ const element = React__namespace.useMemo(() => targetElement !== null && targetElement !== void 0 ? targetElement : document.querySelector('body'), [targetElement]);
1062
+ React__namespace.useEffect(() => {
1063
+ const observer = new ResizeObserver(callback);
1064
+ observer.observe(element, observerOptions);
1065
+ return () => {
1066
+ observer.disconnect();
1067
+ };
1068
+ }, [callback, observerOptions, element]);
1069
+ };
1070
+
1071
+ var Shadows;
1072
+ (function (Shadows) {
1073
+ Shadows["none"] = "none";
1074
+ Shadows["both"] = "both";
1075
+ Shadows["top"] = "top";
1076
+ Shadows["bottom"] = "bottom";
1077
+ })(Shadows || (Shadows = {}));
1078
+ const useScrollShadows = (node) => {
1079
+ const [shadows, setShadows] = React__namespace.useState(Shadows.none);
1080
+ const computeShadows = React__namespace.useCallback(() => {
1081
+ if (node) {
1082
+ const { scrollTop, clientHeight, scrollHeight } = node;
1083
+ const top = scrollTop !== 0;
1084
+ const bottom = scrollTop + clientHeight < scrollHeight;
1085
+ if (top && bottom) {
1086
+ setShadows(Shadows.both);
1087
+ }
1088
+ else if (top) {
1089
+ setShadows(Shadows.top);
1090
+ }
1091
+ else if (bottom) {
1092
+ setShadows(Shadows.bottom);
1093
+ }
1094
+ else {
1095
+ setShadows(Shadows.none);
1096
+ }
1097
+ }
1098
+ }, [node]);
1099
+ // recompute when the scroll container changes in size
1100
+ useResizeObserver(computeShadows, node);
1101
+ React__namespace.useEffect(() => {
1102
+ if (node) {
1103
+ // compute initial shadows
1104
+ computeShadows();
1105
+ // listen for scroll events
1106
+ node.addEventListener('scroll', computeShadows);
1107
+ }
1108
+ return () => {
1109
+ if (node) {
1110
+ node.removeEventListener('scroll', computeShadows);
1111
+ }
1112
+ };
1113
+ }, [node, computeShadows]);
1114
+ return shadows;
1115
+ };
1116
+
1117
+ const useBoundingClientRect = (targetElement) => {
1118
+ const [clientRect, setClientRect] = React__namespace.useState(() => targetElement ? targetElement.getBoundingClientRect() : null);
1119
+ const observerCallback = React__namespace.useCallback(() => {
1120
+ setClientRect(targetElement ? targetElement.getBoundingClientRect() : null);
1121
+ }, [targetElement]);
1122
+ useResizeObserver(observerCallback);
1123
+ return clientRect;
1124
+ };
1125
+
1126
+ /**
1127
+ * React hook that forces component render.
1128
+ */
1124
1129
  const useForceRender = () => React__namespace.useReducer((s) => !s, false)[1];
1125
1130
 
1126
- const useEventListener = (target, event, callback) => {
1127
- React.useEffect(() => {
1128
- target.addEventListener(event, callback);
1129
- return () => {
1130
- target.removeEventListener(event, callback);
1131
- };
1132
- }, [target, event, callback]);
1133
- };
1134
-
1135
- const StaticSpotlight = ({ element }) => {
1136
- const clientRect = useBoundingClientRect(element);
1137
- const style = clientRect
1138
- ? {
1139
- top: clientRect.top,
1140
- left: clientRect.left,
1141
- height: clientRect.height,
1142
- width: clientRect.width,
1143
- }
1144
- : {};
1145
- return clientRect ? (React__namespace.createElement(Portal, null,
1146
- React__namespace.createElement("div", { className: "pf-v5-c-backdrop pfext-spotlight__with-backdrop" },
1147
- React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-noanimate", style: style })))) : null;
1148
- };
1149
-
1150
- const Spotlight = ({ selector, interactive }) => {
1151
- // if target element is a hidden one return null
1152
- const element = React__namespace.useMemo(() => {
1153
- const highlightElement = document.querySelector(selector);
1154
- let hiddenElement = highlightElement;
1155
- while (hiddenElement) {
1156
- const ariaHidden = hiddenElement.getAttribute('aria-hidden');
1157
- if (ariaHidden === 'true') {
1158
- return null;
1159
- }
1160
- hiddenElement = hiddenElement.parentElement;
1161
- }
1162
- return highlightElement;
1163
- }, [selector]);
1164
- if (!element) {
1165
- return null;
1166
- }
1167
- return interactive ? (React__namespace.createElement(InteractiveSpotlight, { element: element })) : (React__namespace.createElement(StaticSpotlight, { element: element }));
1168
- };
1169
-
1170
- const MarkdownHighlightExtension = ({ docContext, rootSelector, }) => {
1171
- const [selector, setSelector] = React__namespace.useState(null);
1172
- React__namespace.useEffect(() => {
1173
- const elements = docContext.querySelectorAll(`${rootSelector} [data-highlight]`);
1174
- let timeoutId;
1175
- function startHighlight(e) {
1176
- const highlightId = e.target.getAttribute('data-highlight');
1177
- if (!highlightId) {
1178
- return;
1179
- }
1180
- setSelector(null);
1181
- timeoutId = setTimeout(() => {
1182
- setSelector(`[data-quickstart-id="${highlightId}"]`);
1183
- }, 0);
1184
- }
1185
- elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
1186
- return () => {
1187
- clearTimeout(timeoutId);
1188
- elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
1189
- };
1190
- }, [docContext, rootSelector]);
1191
- React__namespace.useEffect(() => {
1192
- const elements = docContext.querySelectorAll(`${rootSelector} [class^=data-highlight__]`);
1193
- let timeoutId;
1194
- function startHighlight(e) {
1195
- e.preventDefault();
1196
- const classes = e.target.getAttribute('class').split(' ');
1197
- let highlightId;
1198
- for (const className of classes) {
1199
- if (className.startsWith('data-highlight__')) {
1200
- highlightId = className.split('__')[1];
1201
- break;
1202
- }
1203
- }
1204
- if (!highlightId) {
1205
- return;
1206
- }
1207
- setSelector(null);
1208
- timeoutId = setTimeout(() => {
1209
- setSelector(`[data-quickstart-id="${highlightId}"]`);
1210
- }, 0);
1211
- }
1212
- elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
1213
- return () => {
1214
- clearTimeout(timeoutId);
1215
- elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
1216
- };
1217
- }, [docContext, rootSelector]);
1218
- if (!selector) {
1219
- return null;
1220
- }
1221
- return React__namespace.createElement(Spotlight, { selector: selector, interactive: true });
1222
- };
1223
-
1224
- const MARKDOWN_COPY_BUTTON_ID = 'data-copy-for';
1225
- const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
1226
- const ACCORDION_MARKDOWN_BUTTON_ID = `accordion-markdown-button-id`;
1131
+ const useEventListener = (target, event, callback) => {
1132
+ React.useEffect(() => {
1133
+ target.addEventListener(event, callback);
1134
+ return () => {
1135
+ target.removeEventListener(event, callback);
1136
+ };
1137
+ }, [target, event, callback]);
1138
+ };
1139
+
1140
+ const StaticSpotlight = ({ element }) => {
1141
+ const clientRect = useBoundingClientRect(element);
1142
+ const style = clientRect
1143
+ ? {
1144
+ top: clientRect.top,
1145
+ left: clientRect.left,
1146
+ height: clientRect.height,
1147
+ width: clientRect.width,
1148
+ }
1149
+ : {};
1150
+ return clientRect ? (React__namespace.createElement(Portal, null,
1151
+ React__namespace.createElement("div", { className: "pf-v5-c-backdrop pfext-spotlight__with-backdrop" },
1152
+ React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-noanimate", style: style })))) : null;
1153
+ };
1154
+
1155
+ const Spotlight = ({ selector, interactive }) => {
1156
+ // if target element is a hidden one return null
1157
+ const element = React__namespace.useMemo(() => {
1158
+ const highlightElement = document.querySelector(selector);
1159
+ let hiddenElement = highlightElement;
1160
+ while (hiddenElement) {
1161
+ const ariaHidden = hiddenElement.getAttribute('aria-hidden');
1162
+ if (ariaHidden === 'true') {
1163
+ return null;
1164
+ }
1165
+ hiddenElement = hiddenElement.parentElement;
1166
+ }
1167
+ return highlightElement;
1168
+ }, [selector]);
1169
+ if (!element) {
1170
+ return null;
1171
+ }
1172
+ return interactive ? (React__namespace.createElement(InteractiveSpotlight, { element: element })) : (React__namespace.createElement(StaticSpotlight, { element: element }));
1173
+ };
1174
+
1175
+ const MarkdownHighlightExtension = ({ docContext, rootSelector, }) => {
1176
+ const [selector, setSelector] = React__namespace.useState(null);
1177
+ React__namespace.useEffect(() => {
1178
+ const elements = docContext.querySelectorAll(`${rootSelector} [data-highlight]`);
1179
+ let timeoutId;
1180
+ function startHighlight(e) {
1181
+ const highlightId = e.target.getAttribute('data-highlight');
1182
+ if (!highlightId) {
1183
+ return;
1184
+ }
1185
+ setSelector(null);
1186
+ timeoutId = setTimeout(() => {
1187
+ setSelector(`[data-quickstart-id="${highlightId}"]`);
1188
+ }, 0);
1189
+ }
1190
+ elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
1191
+ return () => {
1192
+ clearTimeout(timeoutId);
1193
+ elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
1194
+ };
1195
+ }, [docContext, rootSelector]);
1196
+ React__namespace.useEffect(() => {
1197
+ const elements = docContext.querySelectorAll(`${rootSelector} [class^=data-highlight__]`);
1198
+ let timeoutId;
1199
+ function startHighlight(e) {
1200
+ e.preventDefault();
1201
+ const classes = e.target.getAttribute('class').split(' ');
1202
+ let highlightId;
1203
+ for (const className of classes) {
1204
+ if (className.startsWith('data-highlight__')) {
1205
+ highlightId = className.split('__')[1];
1206
+ break;
1207
+ }
1208
+ }
1209
+ if (!highlightId) {
1210
+ return;
1211
+ }
1212
+ setSelector(null);
1213
+ timeoutId = setTimeout(() => {
1214
+ setSelector(`[data-quickstart-id="${highlightId}"]`);
1215
+ }, 0);
1216
+ }
1217
+ elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
1218
+ return () => {
1219
+ clearTimeout(timeoutId);
1220
+ elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
1221
+ };
1222
+ }, [docContext, rootSelector]);
1223
+ if (!selector) {
1224
+ return null;
1225
+ }
1226
+ return React__namespace.createElement(Spotlight, { selector: selector, interactive: true });
1227
+ };
1228
+
1229
+ const MARKDOWN_COPY_BUTTON_ID = 'data-copy-for';
1230
+ const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
1231
+ const ACCORDION_MARKDOWN_BUTTON_ID = `accordion-markdown-button-id`;
1227
1232
  const ACCORDION_MARKDOWN_CONTENT_ID = `accordion-markdown-content-id`;
1228
1233
 
1229
- const CopyClipboard = ({ element, rootSelector, docContext, }) => {
1230
- const { getResource } = React__namespace.useContext(QuickStartContext);
1231
- const [showSuccessContent, setShowSuccessContent] = React__namespace.useState(false);
1232
- const textToCopy = React__namespace.useMemo(() => {
1233
- var _a;
1234
- const copyTextId = element.getAttribute(MARKDOWN_COPY_BUTTON_ID);
1235
- return (_a = docContext.querySelector(`${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`)) === null || _a === void 0 ? void 0 : _a.innerText;
1236
- }, [element, docContext, rootSelector]);
1237
- useEventListener(element, 'click', React__namespace.useCallback(() => {
1238
- navigator.clipboard
1239
- .writeText(textToCopy.trim())
1240
- .then(() => {
1241
- setShowSuccessContent(true);
1242
- })
1243
- .catch(() => { });
1244
- }, [textToCopy]));
1245
- useEventListener(element, 'mouseleave', React__namespace.useCallback(() => {
1246
- setShowSuccessContent(false);
1247
- }, []));
1248
- return showSuccessContent ? (React__namespace.createElement(reactCore.Tooltip, { key: "after-copy", isVisible: true, triggerRef: () => element, content: getResource('Successfully copied to clipboard!'), className: "pfext-quick-start__base" })) : (React__namespace.createElement(reactCore.Tooltip, { key: "before-copy", triggerRef: () => element, content: getResource('Copy to clipboard'), className: "pfext-quick-start__base" }));
1249
- };
1250
- const MarkdownCopyClipboard = ({ docContext, rootSelector, }) => {
1251
- const elements = docContext.querySelectorAll(`${rootSelector} [${MARKDOWN_COPY_BUTTON_ID}]`);
1252
- return elements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(elements).map((elm) => {
1253
- const attributeValue = elm.getAttribute(MARKDOWN_COPY_BUTTON_ID);
1254
- return (React__namespace.createElement(CopyClipboard, { key: attributeValue, element: elm, rootSelector: rootSelector, docContext: docContext }));
1255
- }))) : null;
1234
+ const CopyClipboard = ({ element, rootSelector, docContext, }) => {
1235
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1236
+ const [showSuccessContent, setShowSuccessContent] = React__namespace.useState(false);
1237
+ const textToCopy = React__namespace.useMemo(() => {
1238
+ var _a;
1239
+ const copyTextId = element.getAttribute(MARKDOWN_COPY_BUTTON_ID);
1240
+ return (_a = docContext.querySelector(`${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`)) === null || _a === void 0 ? void 0 : _a.innerText;
1241
+ }, [element, docContext, rootSelector]);
1242
+ useEventListener(element, 'click', React__namespace.useCallback(() => {
1243
+ navigator.clipboard
1244
+ .writeText(textToCopy.trim())
1245
+ .then(() => {
1246
+ setShowSuccessContent(true);
1247
+ })
1248
+ .catch(() => { });
1249
+ }, [textToCopy]));
1250
+ useEventListener(element, 'mouseleave', React__namespace.useCallback(() => {
1251
+ setShowSuccessContent(false);
1252
+ }, []));
1253
+ return showSuccessContent ? (React__namespace.createElement(reactCore.Tooltip, { key: "after-copy", isVisible: true, triggerRef: () => element, content: getResource('Successfully copied to clipboard!'), className: "pfext-quick-start__base" })) : (React__namespace.createElement(reactCore.Tooltip, { key: "before-copy", triggerRef: () => element, content: getResource('Copy to clipboard'), className: "pfext-quick-start__base" }));
1254
+ };
1255
+ const MarkdownCopyClipboard = ({ docContext, rootSelector, }) => {
1256
+ const elements = docContext.querySelectorAll(`${rootSelector} [${MARKDOWN_COPY_BUTTON_ID}]`);
1257
+ return elements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(elements).map((elm) => {
1258
+ const attributeValue = elm.getAttribute(MARKDOWN_COPY_BUTTON_ID);
1259
+ return (React__namespace.createElement(CopyClipboard, { key: attributeValue, element: elm, rootSelector: rootSelector, docContext: docContext }));
1260
+ }))) : null;
1256
1261
  };
1257
1262
 
1258
1263
  const removeTemplateWhitespace = (template) => template.replace(/>(?:\s|\n)+</g, '><');
1259
1264
 
1260
- const useInlineCopyClipboardShowdownExtension = () => {
1261
- const { getResource } = React__namespace.useContext(QuickStartContext);
1262
- return React__namespace.useMemo(() => ({
1263
- type: 'lang',
1264
- regex: /`([^`](.*?)[^`])`{{copy}}/g,
1265
- replace: (text, group, _, groupId) => {
1266
- if (!group || isNaN(groupId)) {
1267
- return text;
1268
- }
1265
+ const useInlineCopyClipboardShowdownExtension = () => {
1266
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1267
+ return React__namespace.useMemo(() => ({
1268
+ type: 'lang',
1269
+ regex: /`([^`](.*?)[^`])`{{copy}}/g,
1270
+ replace: (text, group, _, groupId) => {
1271
+ if (!group || isNaN(groupId)) {
1272
+ return text;
1273
+ }
1269
1274
  return removeTemplateWhitespace(`<span class="pf-v5-c-clipboard-copy pf-m-inline">
1270
1275
  <span class="pf-v5-c-clipboard-copy__text" ${MARKDOWN_SNIPPET_ID}="${groupId}">${group}</span>
1271
1276
  <span class="pf-v5-c-clipboard-copy__actions">
@@ -1275,20 +1280,20 @@ const useInlineCopyClipboardShowdownExtension = () => {
1275
1280
  </button>
1276
1281
  </span>
1277
1282
  </span>
1278
- </span>`);
1279
- },
1280
- }), [getResource]);
1281
- };
1282
-
1283
- const useMultilineCopyClipboardShowdownExtension = () => {
1284
- const { getResource } = React__namespace.useContext(QuickStartContext);
1285
- return React__namespace.useMemo(() => ({
1286
- type: 'lang',
1287
- regex: /```[\n]\s*((((?!```).)*?\n)+)\s*```{{copy}}/g,
1288
- replace: (text, group, _1, _2, groupId) => {
1289
- if (!group || isNaN(groupId)) {
1290
- return text;
1291
- }
1283
+ </span>`);
1284
+ },
1285
+ }), [getResource]);
1286
+ };
1287
+
1288
+ const useMultilineCopyClipboardShowdownExtension = () => {
1289
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1290
+ return React__namespace.useMemo(() => ({
1291
+ type: 'lang',
1292
+ regex: /```[\n]\s*((((?!```).)*?\n)+)\s*```{{copy}}/g,
1293
+ replace: (text, group, _1, _2, groupId) => {
1294
+ if (!group || isNaN(groupId)) {
1295
+ return text;
1296
+ }
1292
1297
  return `<div class="pf-v5-c-code-block">
1293
1298
  <div class="pf-v5-c-code-block__header">
1294
1299
  <div class="pf-v5-c-code-block__actions">
@@ -1305,138 +1310,138 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1305
1310
  ${MARKDOWN_SNIPPET_ID}="${groupId}">${group.trim()}</code>
1306
1311
  </pre>
1307
1312
  </div>
1308
- </div>`;
1309
- },
1310
- }), [getResource]);
1311
- };
1312
-
1313
- // eslint-disable-next-line @typescript-eslint/no-require-imports
1314
- const DOMPurify = require('dompurify');
1315
- const markdownConvert = (markdown, extensions) => {
1316
- const converter = new showdown.Converter({
1317
- tables: true,
1318
- openLinksInNewWindow: true,
1319
- strikethrough: true,
1320
- emoji: false,
1321
- });
1322
- if (extensions) {
1323
- converter.addExtension(extensions);
1324
- }
1325
- DOMPurify.addHook('beforeSanitizeElements', function (node) {
1326
- // nodeType 1 = element type
1327
- // transform anchor tags
1328
- if (node.nodeType === 1 && node.nodeName.toLowerCase() === 'a') {
1329
- node.setAttribute('rel', 'noopener noreferrer');
1330
- return node;
1331
- }
1332
- // add PF class to ul and ol lists
1333
- if (node.nodeType === 1 &&
1334
- (node.nodeName.toLowerCase() === 'ul' || node.nodeName.toLowerCase() === 'ol')) {
1335
- node.setAttribute('class', 'pf-v5-c-list');
1336
- return node;
1337
- }
1338
- });
1339
- // Add a hook to make all links open a new window
1340
- DOMPurify.addHook('afterSanitizeAttributes', function (node) {
1341
- // set all elements owning target to target=_blank
1342
- if ('target' in node) {
1343
- node.setAttribute('target', '_blank');
1344
- }
1345
- // set non-HTML/MathML links to xlink:show=new
1346
- if (!node.hasAttribute('target') &&
1347
- (node.hasAttribute('xlink:href') || node.hasAttribute('href'))) {
1348
- node.setAttribute('xlink:show', 'new');
1349
- }
1350
- });
1351
- return DOMPurify.sanitize(converter.makeHtml(markdown), {
1352
- USE_PROFILES: {
1353
- html: true,
1354
- svg: true,
1355
- },
1356
- });
1357
- };
1358
- const SyncMarkdownView = ({ content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
1359
- const { getResource } = React__namespace.useContext(QuickStartContext);
1360
- const markup = React__namespace.useMemo(() => markdownConvert(content || emptyMsg || getResource('Not available'), extensions), [content, emptyMsg, extensions, getResource]);
1361
- const innerProps = {
1362
- renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
1363
- exactHeight,
1364
- markup,
1365
- isEmpty: !content,
1366
- className,
1367
- };
1368
- return inline ? React__namespace.createElement(InlineMarkdownView, Object.assign({}, innerProps)) : React__namespace.createElement(IFrameMarkdownView, Object.assign({}, innerProps));
1369
- };
1370
- const uniqueId = (function () {
1371
- let num = 0;
1372
- return function (prefix) {
1373
- const prefixStr = String(prefix) || '';
1374
- num += 1;
1375
- return prefixStr + num;
1376
- };
1377
- })();
1378
- const RenderExtension = ({ renderExtension, selector, markup, docContext, }) => {
1379
- const forceRender = useForceRender();
1380
- const markupRef = React__namespace.useRef(null);
1381
- const shouldRenderExtension = React__namespace.useCallback(() => {
1382
- if (markupRef.current === markup) {
1383
- return true;
1384
- }
1385
- markupRef.current = markup;
1386
- return false;
1387
- }, [markup]);
1388
- /**
1389
- * During a render cycle in which markup changes, renderExtension receives an old copy of document
1390
- * because react is still updating the dom using `dangerouslySetInnerHTML` with latest markdown markup
1391
- * which causes the component rendered by renderExtension to receive old copy of document
1392
- * use forceRender to delay the rendering of extension by one render cycle
1393
- */
1394
- React__namespace.useEffect(() => {
1395
- if (renderExtension) {
1396
- forceRender();
1397
- }
1398
- // eslint-disable-next-line react-hooks/exhaustive-deps
1399
- }, [markup]);
1400
- return (React__namespace.createElement(React__namespace.Fragment, null, shouldRenderExtension() ? renderExtension === null || renderExtension === void 0 ? void 0 : renderExtension(docContext !== null && docContext !== void 0 ? docContext : document, selector) : null));
1401
- };
1402
- const InlineMarkdownView = ({ markup, isEmpty, renderExtension, className, }) => {
1403
- const id = React__namespace.useMemo(() => uniqueId('markdown'), []);
1404
- return (React__namespace.createElement("div", { className: reactStyles.css('pfext-markdown-view', { 'is-empty': isEmpty }, className), id: id },
1405
- React__namespace.createElement("div", { dangerouslySetInnerHTML: { __html: markup } }),
1406
- renderExtension && (React__namespace.createElement(RenderExtension, { renderExtension: renderExtension, selector: `#${id}`, markup: markup }))));
1407
- };
1408
- const IFrameMarkdownView = ({ exactHeight, markup, isEmpty, renderExtension, className, }) => {
1409
- const [frame, setFrame] = React__namespace.useState();
1410
- const [loaded, setLoaded] = React__namespace.useState(false);
1411
- const updateTimeoutHandle = React__namespace.useRef();
1412
- const updateDimensions = React__namespace.useCallback(() => {
1413
- var _a;
1414
- if (!((_a = frame === null || frame === void 0 ? void 0 : frame.contentWindow) === null || _a === void 0 ? void 0 : _a.document.body.firstChild)) {
1415
- return;
1416
- }
1417
- frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
1418
- // Let the new height take effect, then reset again once we recompute
1419
- updateTimeoutHandle.current = setTimeout(() => {
1420
- if (exactHeight) {
1421
- frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
1422
- }
1423
- else {
1424
- // Increase by 15px for the case where a horizontal scrollbar might appear
1425
- frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight + 15}px`;
1426
- }
1427
- });
1428
- }, [frame, exactHeight]);
1429
- React__namespace.useEffect(() => () => {
1430
- clearTimeout(updateTimeoutHandle.current);
1431
- }, []);
1432
- const onLoad = React__namespace.useCallback(() => {
1433
- updateDimensions();
1434
- setLoaded(true);
1435
- }, [updateDimensions]);
1436
- // Find the app's stylesheets and inject them into the frame to ensure consistent styling.
1437
- const filteredLinks = Array.from(document.getElementsByTagName('link')).filter((l) => l.href.includes('app-bundle'));
1313
+ </div>`;
1314
+ },
1315
+ }), [getResource]);
1316
+ };
1317
+
1318
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
1319
+ const DOMPurify = require('dompurify');
1320
+ const markdownConvert = (markdown, extensions) => {
1321
+ const converter = new showdown.Converter({
1322
+ tables: true,
1323
+ openLinksInNewWindow: true,
1324
+ strikethrough: true,
1325
+ emoji: false,
1326
+ });
1327
+ if (extensions) {
1328
+ converter.addExtension(extensions);
1329
+ }
1330
+ DOMPurify.addHook('beforeSanitizeElements', function (node) {
1331
+ // nodeType 1 = element type
1332
+ // transform anchor tags
1333
+ if (node.nodeType === 1 && node.nodeName.toLowerCase() === 'a') {
1334
+ node.setAttribute('rel', 'noopener noreferrer');
1335
+ return node;
1336
+ }
1337
+ // add PF class to ul and ol lists
1338
+ if (node.nodeType === 1 &&
1339
+ (node.nodeName.toLowerCase() === 'ul' || node.nodeName.toLowerCase() === 'ol')) {
1340
+ node.setAttribute('class', 'pf-v5-c-list');
1341
+ return node;
1342
+ }
1343
+ });
1344
+ // Add a hook to make all links open a new window
1345
+ DOMPurify.addHook('afterSanitizeAttributes', function (node) {
1346
+ // set all elements owning target to target=_blank
1347
+ if ('target' in node) {
1348
+ node.setAttribute('target', '_blank');
1349
+ }
1350
+ // set non-HTML/MathML links to xlink:show=new
1351
+ if (!node.hasAttribute('target') &&
1352
+ (node.hasAttribute('xlink:href') || node.hasAttribute('href'))) {
1353
+ node.setAttribute('xlink:show', 'new');
1354
+ }
1355
+ });
1356
+ return DOMPurify.sanitize(converter.makeHtml(markdown), {
1357
+ USE_PROFILES: {
1358
+ html: true,
1359
+ svg: true,
1360
+ },
1361
+ });
1362
+ };
1363
+ const SyncMarkdownView = ({ content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
1364
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1365
+ const markup = React__namespace.useMemo(() => markdownConvert(content || emptyMsg || getResource('Not available'), extensions), [content, emptyMsg, extensions, getResource]);
1366
+ const innerProps = {
1367
+ renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
1368
+ exactHeight,
1369
+ markup,
1370
+ isEmpty: !content,
1371
+ className,
1372
+ };
1373
+ return inline ? React__namespace.createElement(InlineMarkdownView, Object.assign({}, innerProps)) : React__namespace.createElement(IFrameMarkdownView, Object.assign({}, innerProps));
1374
+ };
1375
+ const uniqueId = (function () {
1376
+ let num = 0;
1377
+ return function (prefix) {
1378
+ const prefixStr = String(prefix) || '';
1379
+ num += 1;
1380
+ return prefixStr + num;
1381
+ };
1382
+ })();
1383
+ const RenderExtension = ({ renderExtension, selector, markup, docContext, }) => {
1384
+ const forceRender = useForceRender();
1385
+ const markupRef = React__namespace.useRef(null);
1386
+ const shouldRenderExtension = React__namespace.useCallback(() => {
1387
+ if (markupRef.current === markup) {
1388
+ return true;
1389
+ }
1390
+ markupRef.current = markup;
1391
+ return false;
1392
+ }, [markup]);
1393
+ /**
1394
+ * During a render cycle in which markup changes, renderExtension receives an old copy of document
1395
+ * because react is still updating the dom using `dangerouslySetInnerHTML` with latest markdown markup
1396
+ * which causes the component rendered by renderExtension to receive old copy of document
1397
+ * use forceRender to delay the rendering of extension by one render cycle
1398
+ */
1399
+ React__namespace.useEffect(() => {
1400
+ if (renderExtension) {
1401
+ forceRender();
1402
+ }
1403
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1404
+ }, [markup]);
1405
+ return (React__namespace.createElement(React__namespace.Fragment, null, shouldRenderExtension() ? renderExtension === null || renderExtension === void 0 ? void 0 : renderExtension(docContext !== null && docContext !== void 0 ? docContext : document, selector) : null));
1406
+ };
1407
+ const InlineMarkdownView = ({ markup, isEmpty, renderExtension, className, }) => {
1408
+ const id = React__namespace.useMemo(() => uniqueId('markdown'), []);
1409
+ return (React__namespace.createElement("div", { className: reactStyles.css('pfext-markdown-view', { 'is-empty': isEmpty }, className), id: id },
1410
+ React__namespace.createElement("div", { dangerouslySetInnerHTML: { __html: markup } }),
1411
+ renderExtension && (React__namespace.createElement(RenderExtension, { renderExtension: renderExtension, selector: `#${id}`, markup: markup }))));
1412
+ };
1413
+ const IFrameMarkdownView = ({ exactHeight, markup, isEmpty, renderExtension, className, }) => {
1414
+ const [frame, setFrame] = React__namespace.useState();
1415
+ const [loaded, setLoaded] = React__namespace.useState(false);
1416
+ const updateTimeoutHandle = React__namespace.useRef();
1417
+ const updateDimensions = React__namespace.useCallback(() => {
1418
+ var _a;
1419
+ if (!((_a = frame === null || frame === void 0 ? void 0 : frame.contentWindow) === null || _a === void 0 ? void 0 : _a.document.body.firstChild)) {
1420
+ return;
1421
+ }
1422
+ frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
1423
+ // Let the new height take effect, then reset again once we recompute
1424
+ updateTimeoutHandle.current = setTimeout(() => {
1425
+ if (exactHeight) {
1426
+ frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
1427
+ }
1428
+ else {
1429
+ // Increase by 15px for the case where a horizontal scrollbar might appear
1430
+ frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight + 15}px`;
1431
+ }
1432
+ });
1433
+ }, [frame, exactHeight]);
1434
+ React__namespace.useEffect(() => () => {
1435
+ clearTimeout(updateTimeoutHandle.current);
1436
+ }, []);
1437
+ const onLoad = React__namespace.useCallback(() => {
1438
+ updateDimensions();
1439
+ setLoaded(true);
1440
+ }, [updateDimensions]);
1441
+ // Find the app's stylesheets and inject them into the frame to ensure consistent styling.
1442
+ const filteredLinks = Array.from(document.getElementsByTagName('link')).filter((l) => l.href.includes('app-bundle'));
1438
1443
  const linkRefs = filteredLinks.reduce((refs, link) => `${refs}
1439
- <link rel="stylesheet" href="${link.href}">`, '');
1444
+ <link rel="stylesheet" href="${link.href}">`, '');
1440
1445
  const contents = `
1441
1446
  ${linkRefs}
1442
1447
  <style type="text/css">
@@ -1461,1161 +1466,1161 @@ const IFrameMarkdownView = ({ exactHeight, markup, isEmpty, renderExtension, cla
1461
1466
  padding-top: 0;
1462
1467
  }
1463
1468
  </style>
1464
- <body class="pf-m-redhat-font"><div style="overflow-y: auto;">${markup}</div></body>`;
1465
- return (React__namespace.createElement(React__namespace.Fragment, null,
1466
- React__namespace.createElement("iframe", { sandbox: "allow-popups allow-popups-to-escape-sandbox allow-same-origin", srcDoc: contents, style: { border: '0px', display: 'block', width: '100%', height: '0' }, ref: (r) => setFrame(r), onLoad: () => onLoad(), className: className }),
1467
- loaded && frame && renderExtension && (React__namespace.createElement(RenderExtension, { markup: markup, selector: '', renderExtension: renderExtension, docContext: frame.contentDocument }))));
1469
+ <body class="pf-m-redhat-font"><div style="overflow-y: auto;">${markup}</div></body>`;
1470
+ return (React__namespace.createElement(React__namespace.Fragment, null,
1471
+ React__namespace.createElement("iframe", { sandbox: "allow-popups allow-popups-to-escape-sandbox allow-same-origin", srcDoc: contents, style: { border: '0px', display: 'block', width: '100%', height: '0' }, ref: (r) => setFrame(r), onLoad: () => onLoad(), className: className }),
1472
+ loaded && frame && renderExtension && (React__namespace.createElement(RenderExtension, { markup: markup, selector: '', renderExtension: renderExtension, docContext: frame.contentDocument }))));
1468
1473
  };
1469
1474
 
1470
- const LINK_LABEL = '[\\d\\w\\s-()$!]+';
1471
- const HIGHLIGHT_ACTIONS = ['highlight'];
1472
- const SELECTOR_ID = `[\\w-]+`;
1473
- // [linkLabel]{{action id}}
1475
+ const LINK_LABEL = '[\\d\\w\\s-()$!]+';
1476
+ const HIGHLIGHT_ACTIONS = ['highlight'];
1477
+ const SELECTOR_ID = `[\\w-]+`;
1478
+ // [linkLabel]{{action id}}
1474
1479
  const HIGHLIGHT_REGEXP = new RegExp(`\\[(${LINK_LABEL})]{{(${HIGHLIGHT_ACTIONS.join('|')}) (${SELECTOR_ID})}}`, 'g');
1475
1480
 
1476
- const removeParagraphWrap = (markdown) => markdown.replace(/^<p>|<\/p>$/g, '');
1477
- const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1478
- const { markdown } = React__namespace.useContext(QuickStartContext);
1479
- const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
1480
- const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1481
- const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1482
- const codeShowdownExtension = useCodeShowdownExtension();
1483
- const accordionShowdownExtension = useAccordionShowdownExtension();
1484
- return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1485
- {
1486
- type: 'lang',
1487
- regex: HIGHLIGHT_REGEXP,
1488
- replace: (text, linkLabel, linkType, linkId) => {
1489
- if (!linkLabel || !linkType || !linkId) {
1490
- return text;
1491
- }
1492
- return `<button class="pf-v5-c-button pf-m-inline pf-m-link" data-highlight="${linkId}">${linkLabel}</button>`;
1493
- },
1494
- },
1495
- {
1496
- type: 'output',
1497
- filter(text) {
1498
- // check HTML for patterns like: <em>Status: unknown</em>{#extension-requirement-status}
1499
- // and replace with <em id="extension-requirement-status">Status: unknown</em>
1500
- return text.replace(/<em>(.*)<\/em>{#(.*)}/g, '<em id="$2">$1</em>');
1501
- },
1502
- },
1503
- inlineCopyClipboardShowdownExtension,
1504
- multilineCopyClipboardShowdownExtension,
1505
- admonitionShowdownExtension,
1506
- codeShowdownExtension,
1507
- accordionShowdownExtension,
1508
- ...(markdown ? markdown.extensions : []),
1509
- ], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
1510
- React__namespace.createElement(AccordionRenderExtension, { docContext: docContext }),
1511
- React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
1512
- React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
1513
- markdown &&
1514
- markdown.renderExtension &&
1515
- markdown.renderExtension(docContext, rootSelector))), className: className }));
1516
- };
1517
-
1518
- var AdmonitionType;
1519
- (function (AdmonitionType) {
1520
- AdmonitionType["TIP"] = "TIP";
1521
- AdmonitionType["NOTE"] = "NOTE";
1522
- AdmonitionType["IMPORTANT"] = "IMPORTANT";
1523
- AdmonitionType["WARNING"] = "WARNING";
1524
- AdmonitionType["CAUTION"] = "CAUTION";
1525
- })(AdmonitionType || (AdmonitionType = {}));
1526
- const admonitionToAlertVariantMap = {
1527
- [AdmonitionType.NOTE]: { variant: 'info' },
1528
- [AdmonitionType.TIP]: { variant: 'default', customIcon: React__namespace.createElement(LightbulbIcon__default['default'], null) },
1529
- [AdmonitionType.IMPORTANT]: { variant: 'danger' },
1530
- [AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React__namespace.createElement(FireIcon__default['default'], null) },
1531
- [AdmonitionType.WARNING]: { variant: 'warning' },
1532
- };
1533
- const useAdmonitionShowdownExtension = () =>
1534
- // const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
1535
- React__namespace.useMemo(() => ({
1536
- type: 'lang',
1537
- regex: /\[(.+)]{{(admonition) ([\w-]+)}}/g,
1538
- replace: (text, content, admonitionLabel, admonitionType, groupId) => {
1539
- if (!content || !admonitionLabel || !admonitionType || !groupId) {
1540
- return text;
1541
- }
1542
- admonitionType = admonitionType.toUpperCase();
1543
- const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
1544
- const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
1545
- const mdContent = React__namespace.createElement(QuickStartMarkdownView, { content: content });
1546
- const pfAlert = (React__namespace.createElement(reactCore.Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, mdContent));
1547
- return removeTemplateWhitespace(server.renderToStaticMarkup(pfAlert));
1548
- },
1481
+ const removeParagraphWrap = (markdown) => markdown.replace(/^<p>|<\/p>$/g, '');
1482
+ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1483
+ const { markdown } = React__namespace.useContext(QuickStartContext);
1484
+ const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
1485
+ const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1486
+ const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1487
+ const codeShowdownExtension = useCodeShowdownExtension();
1488
+ const accordionShowdownExtension = useAccordionShowdownExtension();
1489
+ return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1490
+ {
1491
+ type: 'lang',
1492
+ regex: HIGHLIGHT_REGEXP,
1493
+ replace: (text, linkLabel, linkType, linkId) => {
1494
+ if (!linkLabel || !linkType || !linkId) {
1495
+ return text;
1496
+ }
1497
+ return `<button class="pf-v5-c-button pf-m-inline pf-m-link" data-highlight="${linkId}">${linkLabel}</button>`;
1498
+ },
1499
+ },
1500
+ {
1501
+ type: 'output',
1502
+ filter(text) {
1503
+ // check HTML for patterns like: <em>Status: unknown</em>{#extension-requirement-status}
1504
+ // and replace with <em id="extension-requirement-status">Status: unknown</em>
1505
+ return text.replace(/<em>(.*)<\/em>{#(.*)}/g, '<em id="$2">$1</em>');
1506
+ },
1507
+ },
1508
+ inlineCopyClipboardShowdownExtension,
1509
+ multilineCopyClipboardShowdownExtension,
1510
+ admonitionShowdownExtension,
1511
+ codeShowdownExtension,
1512
+ accordionShowdownExtension,
1513
+ ...(markdown ? markdown.extensions : []),
1514
+ ], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
1515
+ React__namespace.createElement(AccordionRenderExtension, { docContext: docContext }),
1516
+ React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
1517
+ React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
1518
+ markdown &&
1519
+ markdown.renderExtension &&
1520
+ markdown.renderExtension(docContext, rootSelector))), className: className }));
1521
+ };
1522
+
1523
+ var AdmonitionType;
1524
+ (function (AdmonitionType) {
1525
+ AdmonitionType["TIP"] = "TIP";
1526
+ AdmonitionType["NOTE"] = "NOTE";
1527
+ AdmonitionType["IMPORTANT"] = "IMPORTANT";
1528
+ AdmonitionType["WARNING"] = "WARNING";
1529
+ AdmonitionType["CAUTION"] = "CAUTION";
1530
+ })(AdmonitionType || (AdmonitionType = {}));
1531
+ const admonitionToAlertVariantMap = {
1532
+ [AdmonitionType.NOTE]: { variant: 'info' },
1533
+ [AdmonitionType.TIP]: { variant: 'default', customIcon: React__namespace.createElement(LightbulbIcon__default['default'], null) },
1534
+ [AdmonitionType.IMPORTANT]: { variant: 'danger' },
1535
+ [AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React__namespace.createElement(FireIcon__default['default'], null) },
1536
+ [AdmonitionType.WARNING]: { variant: 'warning' },
1537
+ };
1538
+ const useAdmonitionShowdownExtension = () =>
1539
+ // const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
1540
+ React__namespace.useMemo(() => ({
1541
+ type: 'lang',
1542
+ regex: /\[(.+)]{{(admonition) ([\w-]+)}}/g,
1543
+ replace: (text, content, admonitionLabel, admonitionType, groupId) => {
1544
+ if (!content || !admonitionLabel || !admonitionType || !groupId) {
1545
+ return text;
1546
+ }
1547
+ admonitionType = admonitionType.toUpperCase();
1548
+ const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
1549
+ const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
1550
+ const mdContent = React__namespace.createElement(QuickStartMarkdownView, { content: content });
1551
+ const pfAlert = (React__namespace.createElement(reactCore.Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, mdContent));
1552
+ return removeTemplateWhitespace(server.renderToStaticMarkup(pfAlert));
1553
+ },
1549
1554
  }), []);
1550
1555
 
1551
- const useCodeShowdownExtension = () => React__namespace.useMemo(() => ({
1552
- type: 'output',
1553
- regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
1554
- replace: (text, content) => {
1555
- if (!content) {
1556
- return text;
1557
- }
1558
- const pfCodeBlock = React__namespace.createElement(reactCore.CodeBlock, null, content);
1559
- return removeTemplateWhitespace(server.renderToStaticMarkup(pfCodeBlock));
1560
- },
1556
+ const useCodeShowdownExtension = () => React__namespace.useMemo(() => ({
1557
+ type: 'output',
1558
+ regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
1559
+ replace: (text, content) => {
1560
+ if (!content) {
1561
+ return text;
1562
+ }
1563
+ const pfCodeBlock = React__namespace.createElement(reactCore.CodeBlock, null, content);
1564
+ return removeTemplateWhitespace(server.renderToStaticMarkup(pfCodeBlock));
1565
+ },
1561
1566
  }), []);
1562
1567
 
1563
- const useAccordionShowdownExtension = () => React__namespace.useMemo(() => ({
1564
- type: 'lang',
1565
- regex: /\[(.+)]{{(accordion) ("(.*?)")}}/g,
1566
- replace: (_text, accordionContent, _command, accordionHeading) => {
1567
- const accordionId = String(accordionHeading).replace(/\s/g, '-');
1568
- return removeTemplateWhitespace(server.renderToStaticMarkup(React__namespace.createElement(reactCore.Accordion, { asDefinitionList: true },
1569
- React__namespace.createElement(reactCore.AccordionItem, null,
1570
- React__namespace.createElement(reactCore.AccordionToggle, { isExpanded: false, id: `${ACCORDION_MARKDOWN_BUTTON_ID}-${accordionId}` }, accordionHeading),
1571
- React__namespace.createElement(reactCore.AccordionContent, { id: `${ACCORDION_MARKDOWN_CONTENT_ID}-${accordionId}`, isHidden: !false }, accordionContent)))));
1572
- },
1568
+ const useAccordionShowdownExtension = () => React__namespace.useMemo(() => ({
1569
+ type: 'lang',
1570
+ regex: /\[(.+)]{{(accordion) ("(.*?)")}}/g,
1571
+ replace: (_text, accordionContent, _command, accordionHeading) => {
1572
+ const accordionId = String(accordionHeading).replace(/\s/g, '-');
1573
+ return removeTemplateWhitespace(server.renderToStaticMarkup(React__namespace.createElement(reactCore.Accordion, { asDefinitionList: true },
1574
+ React__namespace.createElement(reactCore.AccordionItem, null,
1575
+ React__namespace.createElement(reactCore.AccordionToggle, { isExpanded: false, id: `${ACCORDION_MARKDOWN_BUTTON_ID}-${accordionId}` }, accordionHeading),
1576
+ React__namespace.createElement(reactCore.AccordionContent, { id: `${ACCORDION_MARKDOWN_CONTENT_ID}-${accordionId}`, isHidden: !false }, accordionContent)))));
1577
+ },
1573
1578
  }), []);
1574
1579
 
1575
- const AccordionShowdownHandler = ({ buttonElement, contentElement, }) => {
1576
- const [expanded, setExpanded] = React__namespace.useState(false);
1577
- const handleClick = () => {
1578
- const expandedModifier = 'pf-m-expanded';
1579
- buttonElement.className = `pf-v5-c-accordion__toggle ${!expanded ? expandedModifier : ''}`;
1580
- contentElement.hidden = expanded;
1581
- contentElement.className = `pf-v5-c-accordion__expanded-content ${!expanded ? expandedModifier : ''}`;
1582
- setExpanded(!expanded);
1583
- };
1584
- useEventListener(buttonElement, 'click', handleClick);
1585
- return React__namespace.createElement(React__namespace.Fragment, null);
1586
- };
1587
- const AccordionRenderExtension = ({ docContext }) => {
1588
- const buttonElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_BUTTON_ID}]`);
1589
- const contentElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_CONTENT_ID}]`);
1590
- return buttonElements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(buttonElements).map((elm) => {
1591
- const content = Array.from(contentElements).find((elm2) => {
1592
- const elmId = elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1];
1593
- const elm2Id = elm2.id.split(ACCORDION_MARKDOWN_CONTENT_ID)[1];
1594
- return elmId === elm2Id;
1595
- });
1596
- return (React__namespace.createElement(AccordionShowdownHandler, { key: elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1], buttonElement: elm, contentElement: content }));
1597
- }))) : null;
1598
- };
1599
-
1600
- const FallbackImg = ({ src, alt, className, fallback }) => {
1601
- const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
1602
- if (src && isSrcValid) {
1603
- return React__namespace.createElement("img", { className: className, src: src, alt: alt, onError: () => setIsSrcValid(false) });
1604
- }
1605
- return React__namespace.createElement(React__namespace.Fragment, null, fallback);
1580
+ const AccordionShowdownHandler = ({ buttonElement, contentElement, }) => {
1581
+ const [expanded, setExpanded] = React__namespace.useState(false);
1582
+ const handleClick = () => {
1583
+ const expandedModifier = 'pf-m-expanded';
1584
+ buttonElement.className = `pf-v5-c-accordion__toggle ${!expanded ? expandedModifier : ''}`;
1585
+ contentElement.hidden = expanded;
1586
+ contentElement.className = `pf-v5-c-accordion__expanded-content ${!expanded ? expandedModifier : ''}`;
1587
+ setExpanded(!expanded);
1588
+ };
1589
+ useEventListener(buttonElement, 'click', handleClick);
1590
+ return React__namespace.createElement(React__namespace.Fragment, null);
1591
+ };
1592
+ const AccordionRenderExtension = ({ docContext }) => {
1593
+ const buttonElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_BUTTON_ID}]`);
1594
+ const contentElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_CONTENT_ID}]`);
1595
+ return buttonElements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(buttonElements).map((elm) => {
1596
+ const content = Array.from(contentElements).find((elm2) => {
1597
+ const elmId = elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1];
1598
+ const elm2Id = elm2.id.split(ACCORDION_MARKDOWN_CONTENT_ID)[1];
1599
+ return elmId === elm2Id;
1600
+ });
1601
+ return (React__namespace.createElement(AccordionShowdownHandler, { key: elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1], buttonElement: elm, contentElement: content }));
1602
+ }))) : null;
1603
+ };
1604
+
1605
+ const FallbackImg = ({ src, alt, className, fallback }) => {
1606
+ const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
1607
+ if (src && isSrcValid) {
1608
+ return React__namespace.createElement("img", { className: className, src: src, alt: alt, onError: () => setIsSrcValid(false) });
1609
+ }
1610
+ return React__namespace.createElement(React__namespace.Fragment, null, fallback);
1606
1611
  };
1607
1612
 
1608
1613
  const DASH = '-';
1609
1614
 
1610
- const PopoverStatus = ({ hideHeader, children, isVisible = null, statusBody, title, onHide, onShow, }) => (React__namespace.createElement(reactCore.Popover, { position: reactCore.PopoverPosition.right, headerContent: hideHeader ? null : title, bodyContent: children, "aria-label": title, onHide: onHide, onShow: onShow, isVisible: isVisible },
1615
+ const PopoverStatus = ({ hideHeader, children, isVisible = null, statusBody, title, onHide, onShow, }) => (React__namespace.createElement(reactCore.Popover, { position: reactCore.PopoverPosition.right, headerContent: hideHeader ? null : title, bodyContent: children, "aria-label": title, onHide: onHide, onShow: onShow, isVisible: isVisible },
1611
1616
  React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true }, statusBody)));
1612
1617
 
1613
- const StatusIconAndText = ({ icon, title, spin, iconOnly, noTooltip, className, }) => {
1614
- if (!title) {
1615
- return React__namespace.createElement(React__namespace.Fragment, null, DASH);
1616
- }
1617
- return (React__namespace.createElement("span", { className: reactStyles.css('pfext-icon-and-text', className), title: iconOnly && !noTooltip ? title : undefined },
1618
- icon &&
1619
- React__namespace.cloneElement(icon, {
1620
- className: reactStyles.css(spin && 'fa-spin', icon.props.className, !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child'),
1621
- }),
1622
- !iconOnly && React__namespace.createElement(CamelCaseWrap, { value: title, dataTest: "status-text" })));
1618
+ const StatusIconAndText = ({ icon, title, spin, iconOnly, noTooltip, className, }) => {
1619
+ if (!title) {
1620
+ return React__namespace.createElement(React__namespace.Fragment, null, DASH);
1621
+ }
1622
+ return (React__namespace.createElement("span", { className: reactStyles.css('pfext-icon-and-text', className), title: iconOnly && !noTooltip ? title : undefined },
1623
+ icon &&
1624
+ React__namespace.cloneElement(icon, {
1625
+ className: reactStyles.css(spin && 'fa-spin', icon.props.className, !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child'),
1626
+ }),
1627
+ !iconOnly && React__namespace.createElement(CamelCaseWrap, { value: title, dataTest: "status-text" })));
1623
1628
  };
1624
1629
 
1625
- const GenericStatus = (props) => {
1626
- const { Icon, children, popoverTitle, title, noTooltip, iconOnly } = props, restProps = tslib.__rest(props, ["Icon", "children", "popoverTitle", "title", "noTooltip", "iconOnly"]);
1627
- const renderIcon = iconOnly && !noTooltip ? React__namespace.createElement(Icon, { title: title }) : React__namespace.createElement(Icon, null);
1628
- const statusBody = (React__namespace.createElement(StatusIconAndText, Object.assign({}, restProps, { noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon })));
1629
- return React__namespace.Children.toArray(children).length ? (React__namespace.createElement(PopoverStatus, Object.assign({ title: popoverTitle || title }, restProps, { statusBody: statusBody }), children)) : (statusBody);
1630
+ const GenericStatus = (props) => {
1631
+ const { Icon, children, popoverTitle, title, noTooltip, iconOnly } = props, restProps = tslib.__rest(props, ["Icon", "children", "popoverTitle", "title", "noTooltip", "iconOnly"]);
1632
+ const renderIcon = iconOnly && !noTooltip ? React__namespace.createElement(Icon, { title: title }) : React__namespace.createElement(Icon, null);
1633
+ const statusBody = (React__namespace.createElement(StatusIconAndText, Object.assign({}, restProps, { noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon })));
1634
+ return React__namespace.Children.toArray(children).length ? (React__namespace.createElement(PopoverStatus, Object.assign({ title: popoverTitle || title }, restProps, { statusBody: statusBody }), children)) : (statusBody);
1630
1635
  };
1631
1636
 
1632
- const GreenCheckCircleIcon = ({ className, title, size }) => (React__namespace.createElement(reactCore.Icon, { size: size },
1637
+ const GreenCheckCircleIcon = ({ className, title, size }) => (React__namespace.createElement(reactCore.Icon, { size: size },
1633
1638
  React__namespace.createElement(CheckCircleIcon__default['default'], { "data-test": "success-icon", color: okColor__default['default'].value, className: className, title: title })));
1634
1639
 
1635
- const SuccessStatus = (props) => (React__namespace.createElement(GenericStatus, Object.assign({}, props, { Icon: GreenCheckCircleIcon, title: props.title || 'Healthy' })));
1640
+ const SuccessStatus = (props) => (React__namespace.createElement(GenericStatus, Object.assign({}, props, { Icon: GreenCheckCircleIcon, title: props.title || 'Healthy' })));
1636
1641
  SuccessStatus.displayName = 'SuccessStatus';
1637
1642
 
1638
- const Status = ({ status, title, iconOnly, noTooltip, className, }) => {
1639
- const statusProps = { title: title || status, iconOnly, noTooltip, className };
1640
- switch (status) {
1641
- case 'In Progress':
1642
- return React__namespace.createElement(StatusIconAndText, Object.assign({}, statusProps, { icon: React__namespace.createElement(SyncAltIcon__default['default'], null) }));
1643
- case 'Complete':
1644
- return React__namespace.createElement(SuccessStatus, Object.assign({}, statusProps));
1645
- default:
1646
- return React__namespace.createElement(React__namespace.Fragment, null, status || DASH);
1647
- }
1648
- };
1643
+ const Status = ({ status, title, iconOnly, noTooltip, className, }) => {
1644
+ const statusProps = { title: title || status, iconOnly, noTooltip, className };
1645
+ switch (status) {
1646
+ case 'In Progress':
1647
+ return React__namespace.createElement(StatusIconAndText, Object.assign({}, statusProps, { icon: React__namespace.createElement(SyncAltIcon__default['default'], null) }));
1648
+ case 'Complete':
1649
+ return React__namespace.createElement(SuccessStatus, Object.assign({}, statusProps));
1650
+ default:
1651
+ return React__namespace.createElement(React__namespace.Fragment, null, status || DASH);
1652
+ }
1653
+ };
1649
1654
  const StatusIcon = ({ status }) => (React__namespace.createElement(Status, { status: status, iconOnly: true }));
1650
1655
 
1651
- const QuickStartTileDescription = ({ description, prerequisites, }) => {
1652
- const { getResource } = React__namespace.useContext(QuickStartContext);
1653
- const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
1654
- return (React__namespace.createElement(React__namespace.Fragment, null,
1655
- React__namespace.createElement(QuickStartMarkdownView, { content: description, className: "pfext-quick-start-tile-description" }),
1656
- (prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement("div", { className: "pfext-quick-start-tile-prerequisites" },
1657
- React__namespace.createElement(reactCore.Text, { component: reactCore.TextVariants.h5, className: "pfext-quick-start-tile-prerequisites__text" },
1658
- getResource('Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length),
1659
- ' '),
1660
- React__namespace.createElement(reactCore.Popover, { "aria-label": getResource('Prerequisites'), headerContent: getResource('Prerequisites'), className: "pfext-quick-start__base", bodyContent: React__namespace.createElement("div", { className: "pfext-popover__base" },
1661
- React__namespace.createElement(reactCore.TextList, { "aria-label": getResource('Prerequisites'), className: "pfext-quick-start-tile-prerequisites-list" }, prereqs.map((prerequisite, index) => (
1662
- // eslint-disable-next-line react/no-array-index-key
1663
- React__namespace.createElement(reactCore.TextListItem, { key: index },
1664
- React__namespace.createElement(QuickStartMarkdownView, { content: prerequisite })))))) },
1665
- React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, className: "pfext-quick-start-tile-prerequisites__icon", "data-testid": "qs-card-prereqs", onClick: (e) => {
1666
- e.preventDefault();
1667
- e.stopPropagation();
1668
- }, "aria-label": getResource('Show prerequisites') },
1669
- React__namespace.createElement(InfoCircleIcon__default['default'], null)))))));
1670
- };
1671
-
1672
- const QuickStartTileFooter = ({ quickStartId, status, totalTasks, }) => {
1673
- const { getResource } = React__namespace.useContext(QuickStartContext);
1674
- const { activeQuickStartID, startQuickStart, restartQuickStart } = React__namespace.useContext(QuickStartContext);
1675
- const start = React__namespace.useCallback((e) => {
1676
- e.preventDefault();
1677
- e.stopPropagation();
1678
- startQuickStart(quickStartId, totalTasks);
1679
- }, [quickStartId, startQuickStart, totalTasks]);
1680
- const restart = React__namespace.useCallback((e) => {
1681
- e.preventDefault();
1682
- e.stopPropagation();
1683
- restartQuickStart(quickStartId, totalTasks);
1684
- }, [quickStartId, restartQuickStart, totalTasks]);
1685
- return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
1686
- status === exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.FlexItem, null,
1687
- React__namespace.createElement(reactCore.Button, { onClick: start, variant: "link", isInline: true, "data-testid": "qs-card-notStarted-start", id: `${quickStartId}-start`, "aria-labelledby": `${quickStartId}-start ${quickStartId}` }, getResource('Start')))),
1688
- status === exports.QuickStartStatus.IN_PROGRESS && activeQuickStartID !== quickStartId && (React__namespace.createElement(reactCore.FlexItem, null,
1689
- React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, "data-testid": "qs-card-inProgress-resume", id: `${quickStartId}-continue`, "aria-labelledby": `${quickStartId}-continue ${quickStartId}` }, getResource('Continue')))),
1690
- status === exports.QuickStartStatus.COMPLETE && (React__namespace.createElement(reactCore.FlexItem, null,
1691
- React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-complete-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart')))),
1692
- status === exports.QuickStartStatus.IN_PROGRESS && (React__namespace.createElement(reactCore.FlexItem, null,
1693
- React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-inProgress-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart'))))));
1694
- };
1695
-
1696
- const QuickStartTileFooterExternal = ({ link, quickStartId, }) => {
1697
- const { href, text } = link;
1698
- return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
1699
- React__namespace.createElement(reactCore.FlexItem, null,
1700
- React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: "_blank", rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: React__namespace.createElement(ExternalLinkAltIcon__default['default'], null), iconPosition: "right", id: quickStartId, "aria-labelledby": `${quickStartId}-external ${quickStartId}` }, text || href))));
1701
- };
1702
-
1703
- const statusColorMap = {
1704
- [exports.QuickStartStatus.COMPLETE]: 'green',
1705
- [exports.QuickStartStatus.IN_PROGRESS]: 'purple',
1706
- [exports.QuickStartStatus.NOT_STARTED]: 'grey',
1707
- };
1708
- const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, }) => {
1709
- const { getResource } = React__namespace.useContext(QuickStartContext);
1710
- const statusLocaleMap = {
1711
- [exports.QuickStartStatus.COMPLETE]: getResource('Complete'),
1712
- [exports.QuickStartStatus.IN_PROGRESS]: getResource('In progress'),
1713
- [exports.QuickStartStatus.NOT_STARTED]: getResource('Not started'),
1714
- };
1715
- return (React__namespace.createElement("div", { className: "pfext-quick-start-tile-header" },
1716
- React__namespace.createElement(reactCore.Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
1717
- React__namespace.createElement(QuickStartMarkdownView, { content: name })),
1718
- React__namespace.createElement("div", { className: "pfext-quick-start-tile-header__status" },
1719
- type && (React__namespace.createElement(reactCore.Label, { className: "pfext-quick-start-tile-header--margin", color: type.color }, type.text)),
1720
- duration && (React__namespace.createElement(reactCore.Label, { variant: "outline", "data-test": "duration", icon: React__namespace.createElement(OutlinedClockIcon__default['default'], null), className: "pfext-quick-start-tile-header--margin" }, getResource('{{duration, number}} minutes', duration).replace('{{duration, number}}', duration))),
1721
- status !== exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.Label, { variant: "outline", color: statusColorMap[status], icon: React__namespace.createElement(StatusIcon, { status: status }), "data-test": "status" }, statusLocaleMap[status])))));
1722
- };
1723
-
1724
- const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, }) => {
1725
- const { metadata: { name: id }, spec: { icon, tasks, displayName, description, durationMinutes, prerequisites, link, type }, } = quickStart;
1726
- const { setActiveQuickStart, footer } = React__namespace.useContext(QuickStartContext);
1727
- const ref = React__namespace.useRef(null);
1728
- let quickStartIcon;
1729
- if (typeof icon === 'object') {
1730
- quickStartIcon = icon;
1731
- }
1732
- else {
1733
- quickStartIcon = (React__namespace.createElement(FallbackImg, { className: "pfext-catalog-item-icon__img--large", src: icon, alt: "", fallback: React__namespace.createElement(RocketIcon__default['default'], null) }));
1734
- }
1735
- const footerComponent = React__namespace.useMemo(() => {
1736
- if (footer && footer.show === false) {
1737
- return null;
1738
- }
1739
- if (link) {
1740
- return React__namespace.createElement(QuickStartTileFooterExternal, { link: link, quickStartId: id });
1741
- }
1742
- return React__namespace.createElement(QuickStartTileFooter, { quickStartId: id, status: status, totalTasks: tasks === null || tasks === void 0 ? void 0 : tasks.length });
1743
- }, [footer, id, link, status, tasks === null || tasks === void 0 ? void 0 : tasks.length]);
1744
- const handleClick = (e) => {
1745
- var _a;
1746
- if ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
1747
- if (link) {
1748
- window.open(link.href);
1749
- }
1750
- else {
1751
- setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1752
- }
1753
- onClick();
1754
- }
1755
- };
1756
- return (React__namespace.createElement("div", { ref: ref },
1757
- React__namespace.createElement(CatalogTile, { id: id + '-catalog-tile', style: {
1758
- cursor: 'pointer',
1759
- }, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React__namespace.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick, onKeyDown: (event) => {
1760
- if (event.key === 'Enter' || event.key === ' ') {
1761
- setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1762
- onClick();
1763
- }
1764
- },
1765
- // https://github.com/patternfly/patternfly-react/issues/7039
1766
- href: link === null || link === void 0 ? void 0 : link.href, "data-test": `tile ${id}`, description: React__namespace.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0 })));
1767
- };
1768
-
1769
- const QuickStartCatalog = ({ quickStarts }) => {
1770
- const { activeQuickStartID, allQuickStartStates } = React__namespace.useContext(QuickStartContext);
1771
- return (React__namespace.createElement("div", { className: "pfext-page-layout__content" },
1772
- React__namespace.createElement(reactCore.Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
1773
- const { metadata: { name: id }, } = quickStart;
1774
- return (React__namespace.createElement(reactCore.GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
1775
- React__namespace.createElement(QuickStartTile, { quickStart: quickStart, isActive: id === activeQuickStartID, status: getQuickStartStatus(allQuickStartStates, id) })));
1776
- }))));
1777
- };
1778
-
1779
- const QuickStartCatalogFilterSearch = (_a) => {
1780
- var { searchInputText, handleTextChange } = _a, props = tslib.__rest(_a, ["searchInputText", "handleTextChange"]);
1781
- const { getResource } = React__namespace.useContext(QuickStartContext);
1782
- return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__input" },
1783
- React__namespace.createElement(reactCore.SearchInput, Object.assign({ placeholder: getResource('Filter by keyword...'), value: searchInputText, onChange: (_ev, value) => handleTextChange(value), onClear: () => handleTextChange('') }, props))));
1784
- };
1785
- const QuickStartCatalogFilterSelect = (_a) => {
1786
- var { isDropdownOpen, setIsDropdownOpen, onRowfilterSelect, selectedFilters, dropdownItems } = _a, props = tslib.__rest(_a, ["isDropdownOpen", "setIsDropdownOpen", "onRowfilterSelect", "selectedFilters", "dropdownItems"]);
1787
- const { getResource } = React__namespace.useContext(QuickStartContext);
1788
- const toggle = (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, onClick: () => setIsDropdownOpen(!isDropdownOpen), isExpanded: isDropdownOpen },
1789
- getResource('Status'),
1790
- selectedFilters.length > 0 && React__namespace.createElement(reactCore.Badge, { isRead: true }, selectedFilters.length)));
1791
- return (React__namespace.createElement(reactCore.ToolbarItem, null,
1792
- React__namespace.createElement(reactCore.Select, Object.assign({ "aria-label": getResource('Select filter'), isOpen: isDropdownOpen, selected: selectedFilters, onSelect: onRowfilterSelect, onOpenChange: (isOpen) => setIsDropdownOpen(isOpen), toggle: toggle }, props),
1793
- React__namespace.createElement(reactCore.SelectList, null, dropdownItems))));
1794
- };
1795
- const QuickStartCatalogFilterCount = ({ quickStartsCount }) => {
1796
- const { getResource } = React__namespace.useContext(QuickStartContext);
1797
- return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__count", align: { default: 'alignRight' } }, getResource('{{count, number}} item', quickStartsCount).replace('{{count, number}}', quickStartsCount)));
1798
- };
1799
- const QuickStartCatalogFilterSearchWrapper = ({ onSearchInputChange = () => { } }) => {
1800
- const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
1801
- React__namespace.useEffect(() => {
1802
- // use this effect to clear the search when a `clear all` action is performed higher up
1803
- const unlisten = history.listen(({ location }) => {
1804
- const searchParams = new URLSearchParams(location.search);
1805
- const searchQuery = searchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
1806
- if (searchQuery === '') {
1807
- setFilter('keyword', '');
1808
- onSearchInputChange('');
1809
- }
1810
- });
1811
- return () => {
1812
- unlisten();
1813
- };
1814
- }, [onSearchInputChange, setFilter]);
1815
- const handleTextChange = (val) => {
1816
- if (val.length > 0) {
1817
- useQueryParams && setQueryArgument(QUICKSTART_SEARCH_FILTER_KEY, val);
1818
- }
1819
- else {
1820
- useQueryParams && removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
1821
- }
1822
- if ((filter === null || filter === void 0 ? void 0 : filter.keyword) !== val) {
1823
- setFilter('keyword', val);
1824
- }
1825
- onSearchInputChange(val);
1826
- };
1827
- return (React__namespace.createElement(QuickStartCatalogFilterSearch, { searchInputText: filter === null || filter === void 0 ? void 0 : filter.keyword, handleTextChange: handleTextChange }));
1828
- };
1829
- // compare string/number arrays
1830
- const equalsIgnoreOrder = (a, b) => {
1831
- if (a.length !== b.length) {
1832
- return false;
1833
- }
1834
- const uniqueValues = new Set([...a, ...b]);
1835
- for (const v of uniqueValues) {
1836
- const aCount = a.filter((e) => e === v).length;
1837
- const bCount = b.filter((e) => e === v).length;
1838
- if (aCount !== bCount) {
1839
- return false;
1840
- }
1841
- }
1842
- return true;
1843
- };
1844
- const QuickStartCatalogFilterStatusWrapper = ({ onStatusChange = () => { } }) => {
1845
- const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
1846
- React__namespace.useEffect(() => {
1847
- // use this effect to clear the status when a `clear all` action is performed higher up
1848
- const unlisten = history.listen(({ location }) => {
1849
- var _a;
1850
- const searchParams = new URLSearchParams(location.search);
1851
- const updatedStatusFilters = ((_a = searchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
1852
- if (updatedStatusFilters.length === 0) {
1853
- setFilter('status', []);
1854
- onStatusChange([]);
1855
- }
1856
- });
1857
- return () => {
1858
- unlisten();
1859
- };
1860
- });
1861
- const [isDropdownOpen, setIsDropdownOpen] = React__namespace.useState(false);
1862
- const onRowfilterSelect = React__namespace.useCallback((_e, selectedValue) => {
1863
- setIsDropdownOpen(false);
1864
- const selection = Object.entries(filter.status.statusTypes).find(([_key, value]) => value === selectedValue)[0];
1865
- const selectedFiltersList = filter.status.statusFilters.includes(selection)
1866
- ? filter.status.statusFilters.filter((status) => status !== selection)
1867
- : [...filter.status.statusFilters, selection];
1868
- if (!equalsIgnoreOrder(filter.status.statusFilters, selectedFiltersList)) {
1869
- setFilter('status', selectedFiltersList);
1870
- }
1871
- if (selectedFiltersList.length > 0) {
1872
- useQueryParams && setQueryArgument('status', selectedFiltersList.join(','));
1873
- }
1874
- else {
1875
- useQueryParams && removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
1876
- }
1877
- onStatusChange(selectedFiltersList);
1878
- }, [filter.status.statusFilters, onStatusChange, setFilter, useQueryParams]);
1879
- const dropdownItems = Object.entries(filter.status.statusTypes).map(([key, value]) => (React__namespace.createElement(reactCore.SelectOption, { key: key, "data-key": key, value: value, hasCheckbox: true, isSelected: filter.status.statusFilters.includes(key) },
1880
- React__namespace.createElement(React__namespace.Fragment, null, value))));
1881
- return (React__namespace.createElement(QuickStartCatalogFilterSelect, { isDropdownOpen: isDropdownOpen, setIsDropdownOpen: setIsDropdownOpen, onRowfilterSelect: onRowfilterSelect, selectedFilters: filter.status.statusFilters, dropdownItems: dropdownItems }));
1882
- };
1656
+ const QuickStartTileDescription = ({ description, prerequisites, }) => {
1657
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1658
+ const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
1659
+ return (React__namespace.createElement(React__namespace.Fragment, null,
1660
+ React__namespace.createElement(QuickStartMarkdownView, { content: description, className: "pfext-quick-start-tile-description" }),
1661
+ (prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement("div", { className: "pfext-quick-start-tile-prerequisites" },
1662
+ React__namespace.createElement(reactCore.Text, { component: reactCore.TextVariants.h5, className: "pfext-quick-start-tile-prerequisites__text" },
1663
+ getResource('Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length),
1664
+ ' '),
1665
+ React__namespace.createElement(reactCore.Popover, { "aria-label": getResource('Prerequisites'), headerContent: getResource('Prerequisites'), className: "pfext-quick-start__base", bodyContent: React__namespace.createElement("div", { className: "pfext-popover__base" },
1666
+ React__namespace.createElement(reactCore.TextList, { "aria-label": getResource('Prerequisites'), className: "pfext-quick-start-tile-prerequisites-list" }, prereqs.map((prerequisite, index) => (
1667
+ // eslint-disable-next-line react/no-array-index-key
1668
+ React__namespace.createElement(reactCore.TextListItem, { key: index },
1669
+ React__namespace.createElement(QuickStartMarkdownView, { content: prerequisite })))))) },
1670
+ React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, className: "pfext-quick-start-tile-prerequisites__icon", "data-testid": "qs-card-prereqs", onClick: (e) => {
1671
+ e.preventDefault();
1672
+ e.stopPropagation();
1673
+ }, "aria-label": getResource('Show prerequisites') },
1674
+ React__namespace.createElement(InfoCircleIcon__default['default'], null)))))));
1675
+ };
1676
+
1677
+ const QuickStartTileFooter = ({ quickStartId, status, totalTasks, }) => {
1678
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1679
+ const { activeQuickStartID, startQuickStart, restartQuickStart } = React__namespace.useContext(QuickStartContext);
1680
+ const start = React__namespace.useCallback((e) => {
1681
+ e.preventDefault();
1682
+ e.stopPropagation();
1683
+ startQuickStart(quickStartId, totalTasks);
1684
+ }, [quickStartId, startQuickStart, totalTasks]);
1685
+ const restart = React__namespace.useCallback((e) => {
1686
+ e.preventDefault();
1687
+ e.stopPropagation();
1688
+ restartQuickStart(quickStartId, totalTasks);
1689
+ }, [quickStartId, restartQuickStart, totalTasks]);
1690
+ return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
1691
+ status === exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.FlexItem, null,
1692
+ React__namespace.createElement(reactCore.Button, { onClick: start, variant: "link", isInline: true, "data-testid": "qs-card-notStarted-start", id: `${quickStartId}-start`, "aria-labelledby": `${quickStartId}-start ${quickStartId}` }, getResource('Start')))),
1693
+ status === exports.QuickStartStatus.IN_PROGRESS && activeQuickStartID !== quickStartId && (React__namespace.createElement(reactCore.FlexItem, null,
1694
+ React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, "data-testid": "qs-card-inProgress-resume", id: `${quickStartId}-continue`, "aria-labelledby": `${quickStartId}-continue ${quickStartId}` }, getResource('Continue')))),
1695
+ status === exports.QuickStartStatus.COMPLETE && (React__namespace.createElement(reactCore.FlexItem, null,
1696
+ React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-complete-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart')))),
1697
+ status === exports.QuickStartStatus.IN_PROGRESS && (React__namespace.createElement(reactCore.FlexItem, null,
1698
+ React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-inProgress-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart'))))));
1699
+ };
1700
+
1701
+ const QuickStartTileFooterExternal = ({ link, quickStartId, }) => {
1702
+ const { href, text } = link;
1703
+ return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
1704
+ React__namespace.createElement(reactCore.FlexItem, null,
1705
+ React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: "_blank", rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: React__namespace.createElement(ExternalLinkAltIcon__default['default'], null), iconPosition: "right", id: quickStartId, "aria-labelledby": `${quickStartId}-external ${quickStartId}` }, text || href))));
1706
+ };
1707
+
1708
+ const statusColorMap = {
1709
+ [exports.QuickStartStatus.COMPLETE]: 'green',
1710
+ [exports.QuickStartStatus.IN_PROGRESS]: 'purple',
1711
+ [exports.QuickStartStatus.NOT_STARTED]: 'grey',
1712
+ };
1713
+ const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, }) => {
1714
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1715
+ const statusLocaleMap = {
1716
+ [exports.QuickStartStatus.COMPLETE]: getResource('Complete'),
1717
+ [exports.QuickStartStatus.IN_PROGRESS]: getResource('In progress'),
1718
+ [exports.QuickStartStatus.NOT_STARTED]: getResource('Not started'),
1719
+ };
1720
+ return (React__namespace.createElement("div", { className: "pfext-quick-start-tile-header" },
1721
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
1722
+ React__namespace.createElement(QuickStartMarkdownView, { content: name })),
1723
+ React__namespace.createElement("div", { className: "pfext-quick-start-tile-header__status" },
1724
+ type && (React__namespace.createElement(reactCore.Label, { className: "pfext-quick-start-tile-header--margin", color: type.color }, type.text)),
1725
+ duration && (React__namespace.createElement(reactCore.Label, { variant: "outline", "data-test": "duration", icon: React__namespace.createElement(OutlinedClockIcon__default['default'], null), className: "pfext-quick-start-tile-header--margin" }, getResource('{{duration, number}} minutes', duration).replace('{{duration, number}}', duration))),
1726
+ status !== exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.Label, { variant: "outline", color: statusColorMap[status], icon: React__namespace.createElement(StatusIcon, { status: status }), "data-test": "status" }, statusLocaleMap[status])))));
1727
+ };
1728
+
1729
+ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, }) => {
1730
+ const { metadata: { name: id }, spec: { icon, tasks, displayName, description, durationMinutes, prerequisites, link, type }, } = quickStart;
1731
+ const { setActiveQuickStart, footer } = React__namespace.useContext(QuickStartContext);
1732
+ const ref = React__namespace.useRef(null);
1733
+ let quickStartIcon;
1734
+ if (typeof icon === 'object') {
1735
+ quickStartIcon = icon;
1736
+ }
1737
+ else {
1738
+ quickStartIcon = (React__namespace.createElement(FallbackImg, { className: "pfext-catalog-item-icon__img--large", src: icon, alt: "", fallback: React__namespace.createElement(RocketIcon__default['default'], null) }));
1739
+ }
1740
+ const footerComponent = React__namespace.useMemo(() => {
1741
+ if (footer && footer.show === false) {
1742
+ return null;
1743
+ }
1744
+ if (link) {
1745
+ return React__namespace.createElement(QuickStartTileFooterExternal, { link: link, quickStartId: id });
1746
+ }
1747
+ return React__namespace.createElement(QuickStartTileFooter, { quickStartId: id, status: status, totalTasks: tasks === null || tasks === void 0 ? void 0 : tasks.length });
1748
+ }, [footer, id, link, status, tasks === null || tasks === void 0 ? void 0 : tasks.length]);
1749
+ const handleClick = (e) => {
1750
+ var _a;
1751
+ if ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
1752
+ if (link) {
1753
+ window.open(link.href);
1754
+ }
1755
+ else {
1756
+ setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1757
+ }
1758
+ onClick();
1759
+ }
1760
+ };
1761
+ return (React__namespace.createElement("div", { ref: ref },
1762
+ React__namespace.createElement(CatalogTile, { id: id + '-catalog-tile', style: {
1763
+ cursor: 'pointer',
1764
+ }, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React__namespace.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick, onKeyDown: (event) => {
1765
+ if (event.key === 'Enter' || event.key === ' ') {
1766
+ setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1767
+ onClick();
1768
+ }
1769
+ },
1770
+ // https://github.com/patternfly/patternfly-react/issues/7039
1771
+ href: link === null || link === void 0 ? void 0 : link.href, "data-test": `tile ${id}`, description: React__namespace.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0 })));
1772
+ };
1773
+
1774
+ const QuickStartCatalog = ({ quickStarts }) => {
1775
+ const { activeQuickStartID, allQuickStartStates } = React__namespace.useContext(QuickStartContext);
1776
+ return (React__namespace.createElement("div", { className: "pfext-page-layout__content" },
1777
+ React__namespace.createElement(reactCore.Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
1778
+ const { metadata: { name: id }, } = quickStart;
1779
+ return (React__namespace.createElement(reactCore.GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
1780
+ React__namespace.createElement(QuickStartTile, { quickStart: quickStart, isActive: id === activeQuickStartID, status: getQuickStartStatus(allQuickStartStates, id) })));
1781
+ }))));
1782
+ };
1783
+
1784
+ const QuickStartCatalogFilterSearch = (_a) => {
1785
+ var { searchInputText, handleTextChange } = _a, props = tslib.__rest(_a, ["searchInputText", "handleTextChange"]);
1786
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1787
+ return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__input" },
1788
+ React__namespace.createElement(reactCore.SearchInput, Object.assign({ placeholder: getResource('Filter by keyword...'), value: searchInputText, onChange: (_ev, value) => handleTextChange(value), onClear: () => handleTextChange('') }, props))));
1789
+ };
1790
+ const QuickStartCatalogFilterSelect = (_a) => {
1791
+ var { isDropdownOpen, setIsDropdownOpen, onRowfilterSelect, selectedFilters, dropdownItems } = _a, props = tslib.__rest(_a, ["isDropdownOpen", "setIsDropdownOpen", "onRowfilterSelect", "selectedFilters", "dropdownItems"]);
1792
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1793
+ const toggle = (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, onClick: () => setIsDropdownOpen(!isDropdownOpen), isExpanded: isDropdownOpen },
1794
+ getResource('Status'),
1795
+ selectedFilters.length > 0 && React__namespace.createElement(reactCore.Badge, { isRead: true }, selectedFilters.length)));
1796
+ return (React__namespace.createElement(reactCore.ToolbarItem, null,
1797
+ React__namespace.createElement(reactCore.Select, Object.assign({ "aria-label": getResource('Select filter'), isOpen: isDropdownOpen, selected: selectedFilters, onSelect: onRowfilterSelect, onOpenChange: (isOpen) => setIsDropdownOpen(isOpen), toggle: toggle }, props),
1798
+ React__namespace.createElement(reactCore.SelectList, null, dropdownItems))));
1799
+ };
1800
+ const QuickStartCatalogFilterCount = ({ quickStartsCount }) => {
1801
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1802
+ return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__count", align: { default: 'alignRight' } }, getResource('{{count, number}} item', quickStartsCount).replace('{{count, number}}', quickStartsCount)));
1803
+ };
1804
+ const QuickStartCatalogFilterSearchWrapper = ({ onSearchInputChange = () => { } }) => {
1805
+ const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
1806
+ React__namespace.useEffect(() => {
1807
+ // use this effect to clear the search when a `clear all` action is performed higher up
1808
+ const unlisten = history.listen(({ location }) => {
1809
+ const searchParams = new URLSearchParams(location.search);
1810
+ const searchQuery = searchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
1811
+ if (searchQuery === '') {
1812
+ setFilter('keyword', '');
1813
+ onSearchInputChange('');
1814
+ }
1815
+ });
1816
+ return () => {
1817
+ unlisten();
1818
+ };
1819
+ }, [onSearchInputChange, setFilter]);
1820
+ const handleTextChange = (val) => {
1821
+ if (val.length > 0) {
1822
+ useQueryParams && setQueryArgument(QUICKSTART_SEARCH_FILTER_KEY, val);
1823
+ }
1824
+ else {
1825
+ useQueryParams && removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
1826
+ }
1827
+ if ((filter === null || filter === void 0 ? void 0 : filter.keyword) !== val) {
1828
+ setFilter('keyword', val);
1829
+ }
1830
+ onSearchInputChange(val);
1831
+ };
1832
+ return (React__namespace.createElement(QuickStartCatalogFilterSearch, { searchInputText: filter === null || filter === void 0 ? void 0 : filter.keyword, handleTextChange: handleTextChange }));
1833
+ };
1834
+ // compare string/number arrays
1835
+ const equalsIgnoreOrder = (a, b) => {
1836
+ if (a.length !== b.length) {
1837
+ return false;
1838
+ }
1839
+ const uniqueValues = new Set([...a, ...b]);
1840
+ for (const v of uniqueValues) {
1841
+ const aCount = a.filter((e) => e === v).length;
1842
+ const bCount = b.filter((e) => e === v).length;
1843
+ if (aCount !== bCount) {
1844
+ return false;
1845
+ }
1846
+ }
1847
+ return true;
1848
+ };
1849
+ const QuickStartCatalogFilterStatusWrapper = ({ onStatusChange = () => { } }) => {
1850
+ const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
1851
+ React__namespace.useEffect(() => {
1852
+ // use this effect to clear the status when a `clear all` action is performed higher up
1853
+ const unlisten = history.listen(({ location }) => {
1854
+ var _a;
1855
+ const searchParams = new URLSearchParams(location.search);
1856
+ const updatedStatusFilters = ((_a = searchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
1857
+ if (updatedStatusFilters.length === 0) {
1858
+ setFilter('status', []);
1859
+ onStatusChange([]);
1860
+ }
1861
+ });
1862
+ return () => {
1863
+ unlisten();
1864
+ };
1865
+ });
1866
+ const [isDropdownOpen, setIsDropdownOpen] = React__namespace.useState(false);
1867
+ const onRowfilterSelect = React__namespace.useCallback((_e, selectedValue) => {
1868
+ setIsDropdownOpen(false);
1869
+ const selection = Object.entries(filter.status.statusTypes).find(([_key, value]) => value === selectedValue)[0];
1870
+ const selectedFiltersList = filter.status.statusFilters.includes(selection)
1871
+ ? filter.status.statusFilters.filter((status) => status !== selection)
1872
+ : [...filter.status.statusFilters, selection];
1873
+ if (!equalsIgnoreOrder(filter.status.statusFilters, selectedFiltersList)) {
1874
+ setFilter('status', selectedFiltersList);
1875
+ }
1876
+ if (selectedFiltersList.length > 0) {
1877
+ useQueryParams && setQueryArgument('status', selectedFiltersList.join(','));
1878
+ }
1879
+ else {
1880
+ useQueryParams && removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
1881
+ }
1882
+ onStatusChange(selectedFiltersList);
1883
+ }, [filter.status.statusFilters, onStatusChange, setFilter, useQueryParams]);
1884
+ const dropdownItems = Object.entries(filter.status.statusTypes).map(([key, value]) => (React__namespace.createElement(reactCore.SelectOption, { key: key, "data-key": key, value: value, hasCheckbox: true, isSelected: filter.status.statusFilters.includes(key) },
1885
+ React__namespace.createElement(React__namespace.Fragment, null, value))));
1886
+ return (React__namespace.createElement(QuickStartCatalogFilterSelect, { isDropdownOpen: isDropdownOpen, setIsDropdownOpen: setIsDropdownOpen, onRowfilterSelect: onRowfilterSelect, selectedFilters: filter.status.statusFilters, dropdownItems: dropdownItems }));
1887
+ };
1883
1888
  const QuickStartCatalogFilterCountWrapper = ({ quickStartsCount }) => React__namespace.createElement(QuickStartCatalogFilterCount, { quickStartsCount: quickStartsCount });
1884
1889
 
1885
- const QuickStartCatalogFilter = (_a) => {
1886
- var { quickStartsCount, onSearchInputChange = () => { }, onStatusChange = () => { } } = _a, props = tslib.__rest(_a, ["quickStartsCount", "onSearchInputChange", "onStatusChange"]);
1887
- return (React__namespace.createElement(reactCore.Toolbar, Object.assign({ usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, props),
1888
- React__namespace.createElement(reactCore.ToolbarContent, null,
1889
- React__namespace.createElement(QuickStartCatalogFilterSearchWrapper, { onSearchInputChange: onSearchInputChange }),
1890
- React__namespace.createElement(QuickStartCatalogFilterStatusWrapper, { onStatusChange: onStatusChange }),
1891
- React__namespace.createElement(QuickStartCatalogFilterCountWrapper, { quickStartsCount: quickStartsCount }))));
1892
- };
1893
-
1894
- const QuickStartCatalogEmptyState = ({ clearFilters }) => {
1895
- const { getResource } = React__namespace.useContext(QuickStartContext);
1896
- return (React__namespace.createElement(reactCore.EmptyState, null,
1897
- React__namespace.createElement(reactCore.EmptyStateHeader, { titleText: React__namespace.createElement(React__namespace.Fragment, null, getResource('No results found')), icon: React__namespace.createElement(reactCore.EmptyStateIcon, { icon: SearchIcon__default['default'] }), headingLevel: "h4" }),
1898
- React__namespace.createElement(reactCore.EmptyStateBody, null, getResource('No results match the filter criteria. Remove filters or clear all filters to show results.')),
1899
- React__namespace.createElement(reactCore.EmptyStateFooter, null,
1900
- React__namespace.createElement(reactCore.EmptyStateActions, null,
1901
- React__namespace.createElement(reactCore.Button, { variant: "link", onClick: clearFilters, "data-test": "clear-filter button" }, getResource('Clear all filters'))))));
1902
- };
1903
- const QuickStartCatalogPage = ({ quickStarts, showFilter, sortFnc = (q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName), title, hint, showTitle = true, }) => {
1904
- const sortFncCallback = React__namespace.useCallback(sortFnc, [sortFnc]);
1905
- const { allQuickStarts = [], setAllQuickStarts, allQuickStartStates, getResource, filter, setFilter, loading, } = React__namespace.useContext(QuickStartContext);
1906
- React__namespace.useEffect(() => {
1907
- // passed through prop, not context
1908
- if (quickStarts && JSON.stringify(quickStarts) !== JSON.stringify(allQuickStarts)) {
1909
- setAllQuickStarts(quickStarts);
1910
- }
1911
- }, [quickStarts, allQuickStarts, setAllQuickStarts]);
1912
- const initialFilteredQuickStarts = showFilter
1913
- ? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
1914
- : allQuickStarts;
1915
- const [filteredQuickStarts, setFilteredQuickStarts] = React__namespace.useState(initialFilteredQuickStarts);
1916
- React__namespace.useEffect(() => {
1917
- const filteredQs = showFilter
1918
- ? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
1919
- : allQuickStarts;
1920
- // also needs a check whether the content of the QS changed
1921
- if (filteredQs.length !== filteredQuickStarts.length ||
1922
- JSON.stringify(filteredQs) !== JSON.stringify(filteredQuickStarts)) {
1923
- setFilteredQuickStarts(filteredQs);
1924
- }
1925
- }, [
1926
- allQuickStarts,
1927
- allQuickStartStates,
1928
- showFilter,
1929
- filter.keyword,
1930
- filter.status.statusFilters,
1931
- sortFncCallback,
1932
- filteredQuickStarts,
1933
- ]);
1934
- const clearFilters = () => {
1935
- setFilter('keyword', '');
1936
- setFilter('status', []);
1937
- clearFilterParams();
1938
- setFilteredQuickStarts(allQuickStarts.sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName)));
1939
- };
1940
- const onSearchInputChange = (searchValue) => {
1941
- const result = filterQuickStarts(allQuickStarts, searchValue, filter.status.statusFilters, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
1942
- if (searchValue !== filter.keyword) {
1943
- setFilter('keyword', searchValue);
1944
- }
1945
- if (result.length !== filteredQuickStarts.length) {
1946
- setFilteredQuickStarts(result);
1947
- }
1948
- };
1949
- const onStatusChange = (statusList) => {
1950
- const result = filterQuickStarts(allQuickStarts, filter.keyword, statusList, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
1951
- if (JSON.stringify(statusList) !== JSON.stringify(filter.status)) {
1952
- setFilter('status', statusList);
1953
- }
1954
- if (result.length !== filteredQuickStarts.length) {
1955
- setFilteredQuickStarts(result);
1956
- }
1957
- };
1958
- if (loading) {
1959
- return React__namespace.createElement(LoadingBox, null);
1960
- }
1961
- if (!allQuickStarts || allQuickStarts.length === 0) {
1962
- return React__namespace.createElement(EmptyBox, { label: getResource('Quick Starts') });
1963
- }
1964
- return (React__namespace.createElement("div", { className: "pfext-quick-start__base" },
1965
- showTitle && (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
1966
- React__namespace.createElement(reactCore.Text, { component: "h1", className: "pfext-page-layout__title", "data-test": "page-title" }, title || getResource('Quick Starts')),
1967
- hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint))),
1968
- showTitle && React__namespace.createElement(reactCore.Divider, { component: "div" }),
1969
- showFilter && (React__namespace.createElement(React__namespace.Fragment, null,
1970
- React__namespace.createElement(QuickStartCatalogFilter, { quickStartsCount: filteredQuickStarts.length, onSearchInputChange: onSearchInputChange, onStatusChange: onStatusChange }),
1971
- React__namespace.createElement(reactCore.Divider, { component: "div" }))),
1972
- React__namespace.createElement(React__namespace.Fragment, null, filteredQuickStarts.length === 0 ? (React__namespace.createElement(QuickStartCatalogEmptyState, { clearFilters: clearFilters })) : (React__namespace.createElement(QuickStartCatalog, { quickStarts: filteredQuickStarts })))));
1973
- };
1974
-
1975
- const QuickStartCatalogHeader = ({ title, hint, }) => (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
1976
- React__namespace.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
1890
+ const QuickStartCatalogFilter = (_a) => {
1891
+ var { quickStartsCount, onSearchInputChange = () => { }, onStatusChange = () => { } } = _a, props = tslib.__rest(_a, ["quickStartsCount", "onSearchInputChange", "onStatusChange"]);
1892
+ return (React__namespace.createElement(reactCore.Toolbar, Object.assign({ usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, props),
1893
+ React__namespace.createElement(reactCore.ToolbarContent, null,
1894
+ React__namespace.createElement(QuickStartCatalogFilterSearchWrapper, { onSearchInputChange: onSearchInputChange }),
1895
+ React__namespace.createElement(QuickStartCatalogFilterStatusWrapper, { onStatusChange: onStatusChange }),
1896
+ React__namespace.createElement(QuickStartCatalogFilterCountWrapper, { quickStartsCount: quickStartsCount }))));
1897
+ };
1898
+
1899
+ const QuickStartCatalogEmptyState = ({ clearFilters }) => {
1900
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1901
+ return (React__namespace.createElement(reactCore.EmptyState, null,
1902
+ React__namespace.createElement(reactCore.EmptyStateHeader, { titleText: React__namespace.createElement(React__namespace.Fragment, null, getResource('No results found')), icon: React__namespace.createElement(reactCore.EmptyStateIcon, { icon: SearchIcon__default['default'] }), headingLevel: "h4" }),
1903
+ React__namespace.createElement(reactCore.EmptyStateBody, null, getResource('No results match the filter criteria. Remove filters or clear all filters to show results.')),
1904
+ React__namespace.createElement(reactCore.EmptyStateFooter, null,
1905
+ React__namespace.createElement(reactCore.EmptyStateActions, null,
1906
+ React__namespace.createElement(reactCore.Button, { variant: "link", onClick: clearFilters, "data-test": "clear-filter button" }, getResource('Clear all filters'))))));
1907
+ };
1908
+ const QuickStartCatalogPage = ({ quickStarts, showFilter, sortFnc = (q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName), title, hint, showTitle = true, }) => {
1909
+ const sortFncCallback = React__namespace.useCallback(sortFnc, [sortFnc]);
1910
+ const { allQuickStarts = [], setAllQuickStarts, allQuickStartStates, getResource, filter, setFilter, loading, } = React__namespace.useContext(QuickStartContext);
1911
+ React__namespace.useEffect(() => {
1912
+ // passed through prop, not context
1913
+ if (quickStarts && JSON.stringify(quickStarts) !== JSON.stringify(allQuickStarts)) {
1914
+ setAllQuickStarts(quickStarts);
1915
+ }
1916
+ }, [quickStarts, allQuickStarts, setAllQuickStarts]);
1917
+ const initialFilteredQuickStarts = showFilter
1918
+ ? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
1919
+ : allQuickStarts;
1920
+ const [filteredQuickStarts, setFilteredQuickStarts] = React__namespace.useState(initialFilteredQuickStarts);
1921
+ React__namespace.useEffect(() => {
1922
+ const filteredQs = showFilter
1923
+ ? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
1924
+ : allQuickStarts;
1925
+ // also needs a check whether the content of the QS changed
1926
+ if (filteredQs.length !== filteredQuickStarts.length ||
1927
+ JSON.stringify(filteredQs) !== JSON.stringify(filteredQuickStarts)) {
1928
+ setFilteredQuickStarts(filteredQs);
1929
+ }
1930
+ }, [
1931
+ allQuickStarts,
1932
+ allQuickStartStates,
1933
+ showFilter,
1934
+ filter.keyword,
1935
+ filter.status.statusFilters,
1936
+ sortFncCallback,
1937
+ filteredQuickStarts,
1938
+ ]);
1939
+ const clearFilters = () => {
1940
+ setFilter('keyword', '');
1941
+ setFilter('status', []);
1942
+ clearFilterParams();
1943
+ setFilteredQuickStarts(allQuickStarts.sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName)));
1944
+ };
1945
+ const onSearchInputChange = (searchValue) => {
1946
+ const result = filterQuickStarts(allQuickStarts, searchValue, filter.status.statusFilters, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
1947
+ if (searchValue !== filter.keyword) {
1948
+ setFilter('keyword', searchValue);
1949
+ }
1950
+ if (result.length !== filteredQuickStarts.length) {
1951
+ setFilteredQuickStarts(result);
1952
+ }
1953
+ };
1954
+ const onStatusChange = (statusList) => {
1955
+ const result = filterQuickStarts(allQuickStarts, filter.keyword, statusList, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
1956
+ if (JSON.stringify(statusList) !== JSON.stringify(filter.status)) {
1957
+ setFilter('status', statusList);
1958
+ }
1959
+ if (result.length !== filteredQuickStarts.length) {
1960
+ setFilteredQuickStarts(result);
1961
+ }
1962
+ };
1963
+ if (loading) {
1964
+ return React__namespace.createElement(LoadingBox, null);
1965
+ }
1966
+ if (!allQuickStarts || allQuickStarts.length === 0) {
1967
+ return React__namespace.createElement(EmptyBox, { label: getResource('Quick Starts') });
1968
+ }
1969
+ return (React__namespace.createElement("div", { className: "pfext-quick-start__base" },
1970
+ showTitle && (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
1971
+ React__namespace.createElement(reactCore.Text, { component: "h1", className: "pfext-page-layout__title", "data-test": "page-title" }, title || getResource('Quick Starts')),
1972
+ hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint))),
1973
+ showTitle && React__namespace.createElement(reactCore.Divider, { component: "div" }),
1974
+ showFilter && (React__namespace.createElement(React__namespace.Fragment, null,
1975
+ React__namespace.createElement(QuickStartCatalogFilter, { quickStartsCount: filteredQuickStarts.length, onSearchInputChange: onSearchInputChange, onStatusChange: onStatusChange }),
1976
+ React__namespace.createElement(reactCore.Divider, { component: "div" }))),
1977
+ React__namespace.createElement(React__namespace.Fragment, null, filteredQuickStarts.length === 0 ? (React__namespace.createElement(QuickStartCatalogEmptyState, { clearFilters: clearFilters })) : (React__namespace.createElement(QuickStartCatalog, { quickStarts: filteredQuickStarts })))));
1978
+ };
1979
+
1980
+ const QuickStartCatalogHeader = ({ title, hint, }) => (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
1981
+ React__namespace.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
1977
1982
  hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint)));
1978
1983
 
1979
1984
  const QuickStartCatalogSection = ({ children }) => (React__namespace.createElement("div", { className: "pfext-page-layout__content" }, children));
1980
1985
 
1981
1986
  const QuickStartCatalogToolbar = ({ children }) => (React__namespace.createElement(reactCore.Toolbar, { usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, children));
1982
1987
 
1983
- const QuickStartCloseModal = ({ isOpen, onConfirm, onCancel, }) => {
1984
- const { getResource } = React__namespace.useContext(QuickStartContext);
1985
- return (React__namespace.createElement(Modal, { className: "pfext-quick-start-drawer__modal pfext-quick-start__base", isOpen: isOpen, variant: reactCore.ModalVariant.small, showClose: false, "data-test": "leave-quickstart", title: getResource('Leave quick start?'), footer: React__namespace.createElement(reactCore.Flex, null,
1986
- React__namespace.createElement(reactCore.FlexItem, { align: { default: 'alignRight' } },
1987
- React__namespace.createElement(reactCore.Button, { variant: "secondary", "data-test": "cancel button", onClick: onCancel }, getResource('Cancel'))),
1988
- React__namespace.createElement(reactCore.FlexItem, null,
1989
- React__namespace.createElement(reactCore.Button, { variant: "primary", "data-test": "leave button", onClick: onConfirm }, getResource('Leave')))), isFullScreen: true }, getResource('Your progress will be saved.')));
1990
- };
1991
-
1992
- const TaskIcon = ({ taskIndex, taskStatus }) => {
1993
- const { getResource } = React__namespace.useContext(QuickStartContext);
1994
- const success = taskStatus === exports.QuickStartTaskStatus.SUCCESS;
1995
- const failed = taskStatus === exports.QuickStartTaskStatus.FAILED;
1996
- const classNames = reactStyles.css('pfext-icon-and-text__icon', {
1997
- 'pfext-quick-start-task-header__task-icon-init': !failed && !success,
1998
- });
1999
- let content;
2000
- if (success) {
2001
- content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
2002
- React__namespace.createElement(CheckCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-success" }),
2003
- ' '));
2004
- }
2005
- else if (failed) {
2006
- content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
2007
- React__namespace.createElement(ExclamationCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-failed" })));
2008
- }
2009
- else {
2010
- content = getResource('{{taskIndex, number}}', taskIndex).replace('{{taskIndex, number}}', taskIndex);
2011
- }
2012
- return React__namespace.createElement("span", { className: classNames }, content);
2013
- };
2014
- const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
2015
- const titleRef = React__namespace.useRef(null);
2016
- React__namespace.useEffect(() => {
2017
- if (isActiveTask) {
2018
- // Focus the WizardNavItem button element that contains the title
2019
- titleRef.current.parentNode.focus();
2020
- }
2021
- }, [isActiveTask]);
2022
- const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
2023
- 'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2024
- 'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
2025
- });
2026
- // const notCompleted = taskStatus === QuickStartTaskStatus.VISITED;
2027
- // const skippedReview = taskStatus === QuickStartTaskStatus.REVIEW;
2028
- const failedReview = taskStatus === exports.QuickStartTaskStatus.FAILED;
2029
- // TODO: toned down when this is shown, investigate further when we should display it
2030
- // related: https://github.com/patternfly/patternfly-quickstarts/issues/104
2031
- const tryAgain = failedReview && (React__namespace.createElement(React__namespace.Fragment, null,
2032
- React__namespace.createElement("div", null),
2033
- React__namespace.createElement("div", { className: "pfext-quick-start-task-header__tryagain" }, "Try the steps again.")));
2034
- const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
2035
- React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
2036
- React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
2037
- React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
2038
- isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
2039
- ' ',
2040
- subtitle))),
2041
- tryAgain));
2042
- return (React__namespace.createElement(reactCore.WizardNavItem, { content: content, stepIndex: taskIndex, onClick: () => onTaskSelect(taskIndex - 1), component: "button", isCurrent: isActiveTask }, children));
1988
+ const QuickStartCloseModal = ({ isOpen, onConfirm, onCancel, }) => {
1989
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1990
+ return (React__namespace.createElement(Modal, { className: "pfext-quick-start-drawer__modal pfext-quick-start__base", isOpen: isOpen, variant: reactCore.ModalVariant.small, showClose: false, "data-test": "leave-quickstart", title: getResource('Leave quick start?'), footer: React__namespace.createElement(reactCore.Flex, null,
1991
+ React__namespace.createElement(reactCore.FlexItem, { align: { default: 'alignRight' } },
1992
+ React__namespace.createElement(reactCore.Button, { variant: "secondary", "data-test": "cancel button", onClick: onCancel }, getResource('Cancel'))),
1993
+ React__namespace.createElement(reactCore.FlexItem, null,
1994
+ React__namespace.createElement(reactCore.Button, { variant: "primary", "data-test": "leave button", onClick: onConfirm }, getResource('Leave')))), isFullScreen: true }, getResource('Your progress will be saved.')));
1995
+ };
1996
+
1997
+ const TaskIcon = ({ taskIndex, taskStatus }) => {
1998
+ const { getResource } = React__namespace.useContext(QuickStartContext);
1999
+ const success = taskStatus === exports.QuickStartTaskStatus.SUCCESS;
2000
+ const failed = taskStatus === exports.QuickStartTaskStatus.FAILED;
2001
+ const classNames = reactStyles.css('pfext-icon-and-text__icon', {
2002
+ 'pfext-quick-start-task-header__task-icon-init': !failed && !success,
2003
+ });
2004
+ let content;
2005
+ if (success) {
2006
+ content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
2007
+ React__namespace.createElement(CheckCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-success" }),
2008
+ ' '));
2009
+ }
2010
+ else if (failed) {
2011
+ content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
2012
+ React__namespace.createElement(ExclamationCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-failed" })));
2013
+ }
2014
+ else {
2015
+ content = getResource('{{taskIndex, number}}', taskIndex).replace('{{taskIndex, number}}', taskIndex);
2016
+ }
2017
+ return React__namespace.createElement("span", { className: classNames }, content);
2018
+ };
2019
+ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
2020
+ const titleRef = React__namespace.useRef(null);
2021
+ React__namespace.useEffect(() => {
2022
+ if (isActiveTask) {
2023
+ // Focus the WizardNavItem button element that contains the title
2024
+ titleRef.current.parentNode.focus();
2025
+ }
2026
+ }, [isActiveTask]);
2027
+ const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
2028
+ 'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2029
+ 'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
2030
+ });
2031
+ // const notCompleted = taskStatus === QuickStartTaskStatus.VISITED;
2032
+ // const skippedReview = taskStatus === QuickStartTaskStatus.REVIEW;
2033
+ const failedReview = taskStatus === exports.QuickStartTaskStatus.FAILED;
2034
+ // TODO: toned down when this is shown, investigate further when we should display it
2035
+ // related: https://github.com/patternfly/patternfly-quickstarts/issues/104
2036
+ const tryAgain = failedReview && (React__namespace.createElement(React__namespace.Fragment, null,
2037
+ React__namespace.createElement("div", null),
2038
+ React__namespace.createElement("div", { className: "pfext-quick-start-task-header__tryagain" }, "Try the steps again.")));
2039
+ const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
2040
+ React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
2041
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
2042
+ React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
2043
+ isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
2044
+ ' ',
2045
+ subtitle))),
2046
+ tryAgain));
2047
+ return (React__namespace.createElement(reactCore.WizardNavItem, { content: content, stepIndex: taskIndex, onClick: () => onTaskSelect(taskIndex - 1), component: "button", isCurrent: isActiveTask }, children));
2043
2048
  };
2044
2049
 
2045
2050
  const QuickStartTaskHeaderList = ({ tasks, allTaskStatuses, onTaskSelect, }) => tasks.length > 0 ? (React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-task-header__list" }, tasks.map((task, index) => (React__namespace.createElement(QuickStartTaskHeader, { key: task.title, title: task.title, taskIndex: index + 1, size: "md", taskStatus: allTaskStatuses[index], onTaskSelect: onTaskSelect }))))) : null;
2046
2051
 
2047
- const QuickStartConclusion = ({ tasks, conclusion, allTaskStatuses, nextQuickStarts, onQuickStartChange, onTaskSelect, }) => {
2048
- const hasFailedTask = allTaskStatuses.includes(exports.QuickStartTaskStatus.FAILED);
2049
- const { getResource } = React__namespace.useContext(QuickStartContext);
2050
- return (React__namespace.createElement(React__namespace.Fragment, null,
2051
- React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect }),
2052
- React__namespace.createElement(QuickStartMarkdownView, { content: hasFailedTask
2053
- ? getResource('One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.')
2054
- : conclusion }),
2055
- !hasFailedTask &&
2056
- nextQuickStarts &&
2057
- nextQuickStarts.length > 0 &&
2058
- nextQuickStarts.map((nextQuickStart, index) => {
2059
- var _a;
2060
- return (React__namespace.createElement(reactCore.Button, { variant: "link", onClick: () => onQuickStartChange(nextQuickStart.metadata.name), isInline: true, isBlock: true, key: index },
2061
- getResource('Start {{nextQSDisplayName}} quick start').replace('{{nextQSDisplayName}}', (_a = nextQuickStart === null || nextQuickStart === void 0 ? void 0 : nextQuickStart.spec) === null || _a === void 0 ? void 0 : _a.displayName),
2062
- ' ',
2063
- React__namespace.createElement(ArrowRightIcon__default['default'], { style: { marginLeft: 'var(--pf-v5-global--spacer--xs)', verticalAlign: 'middle' } })));
2064
- })));
2065
- };
2066
-
2067
- const QuickStartIntroduction = ({ tasks, introduction, allTaskStatuses, prerequisites, onTaskSelect, }) => {
2068
- const { getResource } = React__namespace.useContext(QuickStartContext);
2069
- const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
2070
- const [isPrereqsExpanded, setIsPrereqsExpanded] = React__namespace.useState(false);
2071
- const prereqList = (prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement(reactCore.ExpandableSection, { toggleText: getResource('View Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length), onToggle: () => setIsPrereqsExpanded(!isPrereqsExpanded), className: "pfext-quick-start-intro__prereq" },
2072
- React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-intro__prereq-list" }, prereqs.map((pr) => (React__namespace.createElement(reactCore.ListItem, { key: pr, className: "pfext-quick-start-intro__prereq-list__item" },
2073
- React__namespace.createElement("span", { className: "pfext-quick-start-intro__prereq-list__item-content" },
2074
- React__namespace.createElement(QuickStartMarkdownView, { content: pr }))))))));
2075
- return (React__namespace.createElement(React__namespace.Fragment, null,
2076
- React__namespace.createElement(QuickStartMarkdownView, { content: introduction }),
2077
- prereqList,
2078
- React__namespace.createElement("p", { style: { marginBottom: 'var(--pf-v5-global--spacer--md)' } },
2079
- getResource('In this quick start, you will complete {{count, number}} task', tasks.length).replace('{{count, number}}', tasks.length),
2080
- ":"),
2081
- React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect })));
2082
- };
2083
-
2084
- const getAlertVariant = (status) => {
2085
- switch (status) {
2086
- case exports.QuickStartTaskStatus.SUCCESS:
2087
- return 'success';
2088
- case exports.QuickStartTaskStatus.FAILED:
2089
- return 'danger';
2090
- default:
2091
- return 'info';
2092
- }
2093
- };
2094
- const QuickStartTaskReview = ({ review, taskStatus, onTaskReview, }) => {
2095
- const { instructions, failedTaskHelp: taskHelp } = review;
2096
- const { getResource } = React__namespace.useContext(QuickStartContext);
2097
- const alertClassNames = reactStyles.css('pfext-quick-start-task-review', {
2098
- 'pfext-quick-start-task-review--success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2099
- 'pfext-quick-start-task-review--failed': taskStatus === exports.QuickStartTaskStatus.FAILED,
2100
- });
2101
- const title = React__namespace.createElement("span", { className: alertClassNames }, getResource('Check your work'));
2102
- return (React__namespace.createElement(reactCore.Alert, { className: "pfext-quick-start-task-review-alert", variant: getAlertVariant(taskStatus), title: title, isInline: true, role: "alert" },
2103
- React__namespace.createElement(QuickStartMarkdownView, { content: instructions }),
2104
- React__namespace.createElement("span", { className: "pfext-quick-start-task-review__actions" },
2105
- React__namespace.createElement(reactCore.Radio, { id: "review-success", name: "review-success", "data-testid": "qs-drawer-check-yes", label: getResource('Yes'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.SUCCESS, onChange: () => onTaskReview(exports.QuickStartTaskStatus.SUCCESS) }),
2106
- React__namespace.createElement(reactCore.Radio, { id: "review-failed", name: "review-failed", "data-testid": "qs-drawer-check-no", label: getResource('No'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.FAILED, onChange: () => onTaskReview(exports.QuickStartTaskStatus.FAILED) })),
2107
- taskStatus === exports.QuickStartTaskStatus.FAILED && taskHelp && (React__namespace.createElement(QuickStartMarkdownView, { content: taskHelp, exactHeight: true }))));
2108
- };
2109
-
2110
- const QuickStartTasks = ({ tasks, taskNumber, allTaskStatuses, onTaskReview, onTaskSelect, }) => {
2111
- const { getResource, alwaysShowTaskReview } = React__namespace.useContext(QuickStartContext);
2112
- return (React__namespace.createElement("div", { className: "pfext-quick-start-tasks__list" },
2113
- React__namespace.createElement("ul", null, tasks
2114
- .filter((_, index) => allTaskStatuses[index] !== exports.QuickStartTaskStatus.INIT)
2115
- .map((task, index) => {
2116
- const { title, description, review } = task;
2117
- const isActiveTask = index === taskNumber;
2118
- const taskStatus = allTaskStatuses[index];
2119
- const shouldShowTaskReview = (!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) || alwaysShowTaskReview) &&
2120
- review;
2121
- return (React__namespace.createElement(React__namespace.Fragment, { key: title },
2122
- React__namespace.createElement(QuickStartTaskHeader, { taskIndex: index + 1, title: title, size: "md", subtitle: getResource('{{index, number}} of {{tasks, number}}')
2123
- .replace('{{index, number}}', index + 1)
2124
- .replace('{{tasks, number}}', tasks.length), taskStatus: taskStatus, isActiveTask: isActiveTask, onTaskSelect: onTaskSelect }, isActiveTask && (React__namespace.createElement("div", { className: "pfext-quick-start-task__content" },
2125
- React__namespace.createElement(QuickStartMarkdownView, { content: description }),
2126
- shouldShowTaskReview && (React__namespace.createElement(QuickStartTaskReview, { review: review, taskStatus: taskStatus, onTaskReview: onTaskReview })))))));
2127
- }))));
2128
- };
2129
-
2130
- const QuickStartContent = React__namespace.forwardRef(({ quickStart, nextQuickStarts = [], taskNumber, allTaskStatuses, onTaskSelect, onTaskReview, onQuickStartChange, }, ref) => {
2131
- const { spec: { introduction, tasks, conclusion, prerequisites }, } = quickStart;
2132
- const totalTasks = tasks.length;
2133
- return (React__namespace.createElement("div", { className: "pfext-quick-start-content", ref: ref },
2134
- taskNumber === -1 && (React__namespace.createElement(QuickStartIntroduction, { tasks: tasks, allTaskStatuses: allTaskStatuses, introduction: introduction, prerequisites: prerequisites, onTaskSelect: onTaskSelect })),
2135
- taskNumber > -1 && taskNumber < totalTasks && (React__namespace.createElement(QuickStartTasks, { tasks: tasks, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskReview: onTaskReview, onTaskSelect: onTaskSelect })),
2136
- taskNumber === totalTasks && (React__namespace.createElement(QuickStartConclusion, { tasks: tasks, conclusion: conclusion, allTaskStatuses: allTaskStatuses, nextQuickStarts: nextQuickStarts, onQuickStartChange: onQuickStartChange, onTaskSelect: onTaskSelect }))));
2052
+ const QuickStartConclusion = ({ tasks, conclusion, allTaskStatuses, nextQuickStarts, onQuickStartChange, onTaskSelect, }) => {
2053
+ const hasFailedTask = allTaskStatuses.includes(exports.QuickStartTaskStatus.FAILED);
2054
+ const { getResource } = React__namespace.useContext(QuickStartContext);
2055
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2056
+ React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect }),
2057
+ React__namespace.createElement(QuickStartMarkdownView, { content: hasFailedTask
2058
+ ? getResource('One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.')
2059
+ : conclusion }),
2060
+ !hasFailedTask &&
2061
+ nextQuickStarts &&
2062
+ nextQuickStarts.length > 0 &&
2063
+ nextQuickStarts.map((nextQuickStart, index) => {
2064
+ var _a;
2065
+ return (React__namespace.createElement(reactCore.Button, { variant: "link", onClick: () => onQuickStartChange(nextQuickStart.metadata.name), isInline: true, isBlock: true, key: index },
2066
+ getResource('Start {{nextQSDisplayName}} quick start').replace('{{nextQSDisplayName}}', (_a = nextQuickStart === null || nextQuickStart === void 0 ? void 0 : nextQuickStart.spec) === null || _a === void 0 ? void 0 : _a.displayName),
2067
+ ' ',
2068
+ React__namespace.createElement(ArrowRightIcon__default['default'], { style: { marginLeft: 'var(--pf-v5-global--spacer--xs)', verticalAlign: 'middle' } })));
2069
+ })));
2070
+ };
2071
+
2072
+ const QuickStartIntroduction = ({ tasks, introduction, allTaskStatuses, prerequisites, onTaskSelect, }) => {
2073
+ const { getResource } = React__namespace.useContext(QuickStartContext);
2074
+ const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
2075
+ const [isPrereqsExpanded, setIsPrereqsExpanded] = React__namespace.useState(false);
2076
+ const prereqList = (prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement(reactCore.ExpandableSection, { toggleText: getResource('View Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length), onToggle: () => setIsPrereqsExpanded(!isPrereqsExpanded), className: "pfext-quick-start-intro__prereq" },
2077
+ React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-intro__prereq-list" }, prereqs.map((pr) => (React__namespace.createElement(reactCore.ListItem, { key: pr, className: "pfext-quick-start-intro__prereq-list__item" },
2078
+ React__namespace.createElement("span", { className: "pfext-quick-start-intro__prereq-list__item-content" },
2079
+ React__namespace.createElement(QuickStartMarkdownView, { content: pr }))))))));
2080
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2081
+ React__namespace.createElement(QuickStartMarkdownView, { content: introduction }),
2082
+ prereqList,
2083
+ React__namespace.createElement("p", { style: { marginBottom: 'var(--pf-v5-global--spacer--md)' } },
2084
+ getResource('In this quick start, you will complete {{count, number}} task', tasks.length).replace('{{count, number}}', tasks.length),
2085
+ ":"),
2086
+ React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect })));
2087
+ };
2088
+
2089
+ const getAlertVariant = (status) => {
2090
+ switch (status) {
2091
+ case exports.QuickStartTaskStatus.SUCCESS:
2092
+ return 'success';
2093
+ case exports.QuickStartTaskStatus.FAILED:
2094
+ return 'danger';
2095
+ default:
2096
+ return 'info';
2097
+ }
2098
+ };
2099
+ const QuickStartTaskReview = ({ review, taskStatus, onTaskReview, }) => {
2100
+ const { instructions, failedTaskHelp: taskHelp } = review;
2101
+ const { getResource } = React__namespace.useContext(QuickStartContext);
2102
+ const alertClassNames = reactStyles.css('pfext-quick-start-task-review', {
2103
+ 'pfext-quick-start-task-review--success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2104
+ 'pfext-quick-start-task-review--failed': taskStatus === exports.QuickStartTaskStatus.FAILED,
2105
+ });
2106
+ const title = React__namespace.createElement("span", { className: alertClassNames }, getResource('Check your work'));
2107
+ return (React__namespace.createElement(reactCore.Alert, { className: "pfext-quick-start-task-review-alert", variant: getAlertVariant(taskStatus), title: title, isInline: true, role: "alert" },
2108
+ React__namespace.createElement(QuickStartMarkdownView, { content: instructions }),
2109
+ React__namespace.createElement("span", { className: "pfext-quick-start-task-review__actions" },
2110
+ React__namespace.createElement(reactCore.Radio, { id: "review-success", name: "review-success", "data-testid": "qs-drawer-check-yes", label: getResource('Yes'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.SUCCESS, onChange: () => onTaskReview(exports.QuickStartTaskStatus.SUCCESS) }),
2111
+ React__namespace.createElement(reactCore.Radio, { id: "review-failed", name: "review-failed", "data-testid": "qs-drawer-check-no", label: getResource('No'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.FAILED, onChange: () => onTaskReview(exports.QuickStartTaskStatus.FAILED) })),
2112
+ taskStatus === exports.QuickStartTaskStatus.FAILED && taskHelp && (React__namespace.createElement(QuickStartMarkdownView, { content: taskHelp, exactHeight: true }))));
2113
+ };
2114
+
2115
+ const QuickStartTasks = ({ tasks, taskNumber, allTaskStatuses, onTaskReview, onTaskSelect, }) => {
2116
+ const { getResource, alwaysShowTaskReview } = React__namespace.useContext(QuickStartContext);
2117
+ return (React__namespace.createElement("div", { className: "pfext-quick-start-tasks__list" },
2118
+ React__namespace.createElement("ul", null, tasks
2119
+ .filter((_, index) => allTaskStatuses[index] !== exports.QuickStartTaskStatus.INIT)
2120
+ .map((task, index) => {
2121
+ const { title, description, review } = task;
2122
+ const isActiveTask = index === taskNumber;
2123
+ const taskStatus = allTaskStatuses[index];
2124
+ const shouldShowTaskReview = (!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) || alwaysShowTaskReview) &&
2125
+ review;
2126
+ return (React__namespace.createElement(React__namespace.Fragment, { key: title },
2127
+ React__namespace.createElement(QuickStartTaskHeader, { taskIndex: index + 1, title: title, size: "md", subtitle: getResource('{{index, number}} of {{tasks, number}}')
2128
+ .replace('{{index, number}}', index + 1)
2129
+ .replace('{{tasks, number}}', tasks.length), taskStatus: taskStatus, isActiveTask: isActiveTask, onTaskSelect: onTaskSelect }, isActiveTask && (React__namespace.createElement("div", { className: "pfext-quick-start-task__content" },
2130
+ React__namespace.createElement(QuickStartMarkdownView, { content: description }),
2131
+ shouldShowTaskReview && (React__namespace.createElement(QuickStartTaskReview, { review: review, taskStatus: taskStatus, onTaskReview: onTaskReview })))))));
2132
+ }))));
2133
+ };
2134
+
2135
+ const QuickStartContent = React__namespace.forwardRef(({ quickStart, nextQuickStarts = [], taskNumber, allTaskStatuses, onTaskSelect, onTaskReview, onQuickStartChange, }, ref) => {
2136
+ const { spec: { introduction, tasks, conclusion, prerequisites }, } = quickStart;
2137
+ const totalTasks = tasks.length;
2138
+ return (React__namespace.createElement("div", { className: "pfext-quick-start-content", ref: ref },
2139
+ taskNumber === -1 && (React__namespace.createElement(QuickStartIntroduction, { tasks: tasks, allTaskStatuses: allTaskStatuses, introduction: introduction, prerequisites: prerequisites, onTaskSelect: onTaskSelect })),
2140
+ taskNumber > -1 && taskNumber < totalTasks && (React__namespace.createElement(QuickStartTasks, { tasks: tasks, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskReview: onTaskReview, onTaskSelect: onTaskSelect })),
2141
+ taskNumber === totalTasks && (React__namespace.createElement(QuickStartConclusion, { tasks: tasks, conclusion: conclusion, allTaskStatuses: allTaskStatuses, nextQuickStarts: nextQuickStarts, onQuickStartChange: onQuickStartChange, onTaskSelect: onTaskSelect }))));
2137
2142
  });
2138
2143
 
2139
- const QuickStartFooter = ({ status, taskNumber, totalTasks, onNext, onBack, footerClass, quickStartId, }) => {
2140
- const { restartQuickStart, getResource } = React__namespace.useContext(QuickStartContext);
2141
- const PrimaryButtonText = React__namespace.useMemo(() => ({
2142
- START: getResource('Start'),
2143
- CONTINUE: getResource('Continue'),
2144
- NEXT: getResource('Next'),
2145
- CLOSE: getResource('Close'),
2146
- }), [getResource]);
2147
- const SecondaryButtonText = React__namespace.useMemo(() => ({
2148
- BACK: getResource('Back'),
2149
- RESTART: getResource('Restart'),
2150
- }), [getResource]);
2151
- const onRestart = React__namespace.useCallback((e) => {
2152
- e.preventDefault();
2153
- e.stopPropagation();
2154
- restartQuickStart(quickStartId, totalTasks);
2155
- }, [quickStartId, restartQuickStart, totalTasks]);
2156
- const getPrimaryButtonText = React__namespace.useMemo(() => {
2157
- if (status === exports.QuickStartStatus.NOT_STARTED) {
2158
- return PrimaryButtonText.START;
2159
- }
2160
- if (taskNumber === totalTasks) {
2161
- return PrimaryButtonText.CLOSE;
2162
- }
2163
- if (taskNumber > -1 && taskNumber < totalTasks) {
2164
- return PrimaryButtonText.NEXT;
2165
- }
2166
- return PrimaryButtonText.CONTINUE;
2167
- }, [taskNumber, totalTasks, PrimaryButtonText, status]);
2168
- const getPrimaryButton = React__namespace.useMemo(() => (React__namespace.createElement(reactCore.Button, { variant: "primary", className: "pfext-quick-start-footer__actionbtn", onClick: onNext, "data-testid": `qs-drawer-${camelize(getPrimaryButtonText)}`, "data-test": `${getPrimaryButtonText} button` }, getPrimaryButtonText)), [getPrimaryButtonText, onNext]);
2169
- const getSecondaryButton = React__namespace.useMemo(() => taskNumber === -1 && status !== exports.QuickStartStatus.NOT_STARTED ? (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onRestart, "data-testid": "qs-drawer-restart" }, SecondaryButtonText.RESTART)) : (taskNumber > -1 && (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onBack, "data-testid": "qs-drawer-back" }, SecondaryButtonText.BACK))), [onRestart, onBack, SecondaryButtonText, status, taskNumber]);
2170
- const getSideNoteAction = React__namespace.useMemo(() => taskNumber !== -1 && (React__namespace.createElement(reactCore.Button, { variant: "link", className: "pfext-quick-start-footer__restartbtn", onClick: onRestart, "data-testid": "qs-drawer-side-note-action" }, SecondaryButtonText.RESTART)), [taskNumber, onRestart, SecondaryButtonText.RESTART]);
2171
- return (React__namespace.createElement("div", { className: `pfext-quick-start-footer ${footerClass}` },
2172
- getPrimaryButton,
2173
- getSecondaryButton,
2174
- getSideNoteAction));
2175
- };
2176
-
2177
- const QuickStartController = ({ quickStart, nextQuickStarts, contentRef, footerClass, }) => {
2178
- const { metadata: { name }, spec: { tasks = [] }, } = quickStart;
2179
- const totalTasks = tasks === null || tasks === void 0 ? void 0 : tasks.length;
2180
- const { activeQuickStartState, setActiveQuickStart, setQuickStartTaskNumber, setQuickStartTaskStatus, nextStep, previousStep, } = React__namespace.useContext(QuickStartContext);
2181
- const status = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
2182
- const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
2183
- const allTaskStatuses = tasks.map((task, index) => activeQuickStartState[`taskStatus${index}`]);
2184
- const handleQuickStartChange = React__namespace.useCallback((quickStartId) => setActiveQuickStart(quickStartId), [setActiveQuickStart]);
2185
- const handleTaskStatusChange = React__namespace.useCallback((newTaskStatus) => setQuickStartTaskStatus(newTaskStatus), [setQuickStartTaskStatus]);
2186
- const getQuickStartActiveTask = React__namespace.useCallback(() => {
2187
- let activeTaskNumber = 0;
2188
- while (activeTaskNumber !== totalTasks &&
2189
- activeQuickStartState[`taskStatus${activeTaskNumber}`] !== exports.QuickStartTaskStatus.INIT) {
2190
- activeTaskNumber++;
2191
- }
2192
- return activeTaskNumber;
2193
- }, [totalTasks, activeQuickStartState]);
2194
- const handleQuickStartContinue = React__namespace.useCallback(() => {
2195
- const activeTaskNumber = getQuickStartActiveTask();
2196
- setQuickStartTaskNumber(name, activeTaskNumber);
2197
- }, [getQuickStartActiveTask, setQuickStartTaskNumber, name]);
2198
- const handleNext = React__namespace.useCallback(() => {
2199
- if (status === exports.QuickStartStatus.COMPLETE && taskNumber === totalTasks) {
2200
- return handleQuickStartChange('');
2201
- }
2202
- if (status !== exports.QuickStartStatus.NOT_STARTED && taskNumber === -1) {
2203
- return handleQuickStartContinue();
2204
- }
2205
- return nextStep(totalTasks);
2206
- }, [handleQuickStartChange, nextStep, status, taskNumber, totalTasks, handleQuickStartContinue]);
2207
- const handleBack = React__namespace.useCallback(() => previousStep(), [previousStep]);
2208
- const handleTaskSelect = React__namespace.useCallback((selectedTaskNumber) => {
2209
- setQuickStartTaskNumber(name, selectedTaskNumber);
2210
- }, [name, setQuickStartTaskNumber]);
2211
- return (React__namespace.createElement(React__namespace.Fragment, null,
2212
- React__namespace.createElement(QuickStartContent, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskSelect: handleTaskSelect, onTaskReview: handleTaskStatusChange, onQuickStartChange: handleQuickStartChange, ref: contentRef }),
2213
- React__namespace.createElement(QuickStartFooter, { status: status, taskNumber: taskNumber, totalTasks: totalTasks, onNext: handleNext, onBack: handleBack, footerClass: footerClass, quickStartId: quickStart.metadata.name })));
2214
- };
2215
-
2216
- const getElement = (appendTo) => {
2217
- if (typeof appendTo === 'function') {
2218
- return appendTo();
2219
- }
2220
- return appendTo;
2221
- };
2222
- const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
2223
- React__namespace.useEffect(() => {
2224
- if (node) {
2225
- node.scrollTo({ top: 0, behavior: 'smooth' });
2226
- }
2227
- }, [taskNumber, node]);
2228
- };
2229
- const QuickStartPanelContent = (_a) => {
2230
- var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = tslib.__rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
2231
- const titleRef = React__namespace.useRef(null);
2232
- const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
2233
- const [contentRef, setContentRef] = React__namespace.useState();
2234
- const shadows = useScrollShadows(contentRef);
2235
- const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
2236
- const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
2237
- useScrollTopOnTaskNumberChange(contentRef, taskNumber);
2238
- const nextQuickStarts = quickStarts.filter((qs) => { var _a; return (_a = quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.nextQuickStart) === null || _a === void 0 ? void 0 : _a.includes(qs.metadata.name); });
2239
- const headerClasses = reactStyles.css('pfext-quick-start-panel-content__header', {
2240
- 'pfext-quick-start-panel-content__header__shadow': shadows === Shadows.top || shadows === Shadows.both,
2241
- 'pfext-quick-start-panel-content__header--blue-white': headerVariant === 'blue-white',
2242
- });
2243
- const footerClass = reactStyles.css({
2244
- 'pfext-quick-start-panel-content__footer__shadow': shadows === Shadows.bottom || shadows === Shadows.both,
2245
- });
2246
- const getStep = () => {
2247
- const tasks = quickStart.spec.tasks.length;
2248
- if (Number.parseInt(taskNumber) === -1) {
2249
- return 'intro';
2250
- }
2251
- if (Number.parseInt(taskNumber) === tasks) {
2252
- return 'conclusion';
2253
- }
2254
- return Number.parseInt(taskNumber) + 1;
2255
- };
2256
- React__namespace.useEffect(() => {
2257
- if (quickStart) {
2258
- titleRef.current.focus();
2259
- }
2260
- }, [quickStart]);
2261
- const content = quickStart ? (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base", "data-testid": `qs-drawer-${camelize(quickStart.spec.displayName)}`, "data-qs": `qs-step-${getStep()}`, "data-test": "quickstart drawer" }, props),
2262
- React__namespace.createElement("div", { className: headerClasses },
2263
- React__namespace.createElement(reactCore.DrawerHead, null,
2264
- React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
2265
- React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } },
2266
- React__namespace.createElement("span", { dangerouslySetInnerHTML: {
2267
- __html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
2268
- } }),
2269
- ' ',
2270
- React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2271
- ? getResource('{{type}} • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2272
- .replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2273
- .replace('{{type}}', getResource('Type'))
2274
- : getResource('Type')))),
2275
- showClose && (React__namespace.createElement(reactCore.DrawerActions, null,
2276
- React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: handleClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))))),
2277
- React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
2278
- React__namespace.createElement(QuickStartController, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, footerClass: footerClass, contentRef: setContentRef })))) : null;
2279
- if (appendTo) {
2280
- return ReactDOM__namespace.createPortal(content, getElement(appendTo));
2281
- }
2282
- return content;
2283
- };
2284
-
2285
- const QuickStartContainer = (_a) => {
2286
- var { quickStarts, children, activeQuickStartID, allQuickStartStates, setActiveQuickStartID, setAllQuickStartStates, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress, resourceBundle, showCardFooters, useLegacyHeaderColors, language, loading = false, useQueryParams = true, markdown, contextProps, alwaysShowTaskReview = true } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "activeQuickStartID", "allQuickStartStates", "setActiveQuickStartID", "setAllQuickStartStates", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress", "resourceBundle", "showCardFooters", "useLegacyHeaderColors", "language", "loading", "useQueryParams", "markdown", "contextProps", "alwaysShowTaskReview"]);
2287
- const valuesForQuickstartContext = useValuesForQuickStartContext(Object.assign({ allQuickStarts: quickStarts, activeQuickStartID,
2288
- setActiveQuickStartID,
2289
- allQuickStartStates,
2290
- setAllQuickStartStates, footer: {
2291
- show: showCardFooters,
2292
- }, useLegacyHeaderColors,
2293
- language, resourceBundle: Object.assign({}, resourceBundle), loading,
2294
- useQueryParams,
2295
- markdown,
2296
- alwaysShowTaskReview }, contextProps));
2297
- React__namespace.useEffect(() => {
2298
- if (quickStarts &&
2299
- JSON.stringify(quickStarts) !== JSON.stringify(valuesForQuickstartContext.allQuickStarts)) {
2300
- valuesForQuickstartContext.setAllQuickStarts(quickStarts);
2301
- }
2302
- }, [quickStarts, valuesForQuickstartContext]);
2303
- React__namespace.useEffect(() => {
2304
- if (loading !== valuesForQuickstartContext.loading) {
2305
- valuesForQuickstartContext.setLoading(loading);
2306
- }
2307
- }, [loading, valuesForQuickstartContext]);
2308
- const drawerProps = Object.assign({ appendTo,
2309
- fullWidth,
2310
- onCloseInProgress,
2311
- onCloseNotInProgress }, props);
2312
- return (React__namespace.createElement(QuickStartContext.Provider, { value: valuesForQuickstartContext },
2313
- React__namespace.createElement(QuickStartDrawer, Object.assign({}, drawerProps), children)));
2314
- };
2315
- const QuickStartDrawer = (_a) => {
2316
- var { quickStarts = [], children, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress"]);
2317
- const { activeQuickStartID, setActiveQuickStart, allQuickStarts = [], activeQuickStartState, allQuickStartStates, setAllQuickStartStates, useLegacyHeaderColors, } = React__namespace.useContext(QuickStartContext);
2318
- const combinedQuickStarts = allQuickStarts.concat(quickStarts);
2319
- React__namespace.useEffect(() => {
2320
- const params = new URLSearchParams(window.location.search);
2321
- // if there is a quick start param, but the quick start is not active, set it
2322
- // this can happen if a new browser session is opened or an incognito window for example
2323
- const quickStartIdFromParam = params.get(QUICKSTART_ID_FILTER_KEY) || '';
2324
- if (quickStartIdFromParam && activeQuickStartID !== quickStartIdFromParam) {
2325
- const activeQuickStart = getQuickStartByName(quickStartIdFromParam, combinedQuickStarts);
2326
- // don't try to load a quick start that is actually just an external resource (spec.link)
2327
- if (combinedQuickStarts.length > 0 && activeQuickStart && !activeQuickStart.spec.link) {
2328
- setActiveQuickStart(quickStartIdFromParam);
2329
- }
2330
- }
2331
- }, [activeQuickStartID, combinedQuickStarts, setActiveQuickStart]);
2332
- React__namespace.useEffect(() => {
2333
- // If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
2334
- if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
2335
- setAllQuickStartStates(Object.assign(Object.assign({}, allQuickStartStates), { [activeQuickStartID]: getDefaultQuickStartState() }));
2336
- }
2337
- }, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
2338
- const [modalOpen, setModalOpen] = React__namespace.useState(false);
2339
- const activeQuickStartStatus = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
2340
- const onClose = () => setActiveQuickStart('');
2341
- const handleClose = () => {
2342
- if (activeQuickStartStatus === exports.QuickStartStatus.IN_PROGRESS) {
2343
- if (onCloseInProgress) {
2344
- onCloseInProgress();
2345
- }
2346
- else {
2347
- setModalOpen(true);
2348
- }
2349
- }
2350
- else if (onCloseNotInProgress) {
2351
- onCloseNotInProgress();
2352
- }
2353
- else {
2354
- onClose();
2355
- }
2356
- };
2357
- const onModalConfirm = () => {
2358
- setModalOpen(false);
2359
- onClose();
2360
- };
2361
- const onModalCancel = () => setModalOpen(false);
2362
- const fullWidthPanelStyle = fullWidth
2363
- ? {
2364
- style: {
2365
- flex: 1,
2366
- },
2367
- }
2368
- : {};
2369
- const fullWidthBodyStyle = fullWidth
2370
- ? {
2371
- style: {
2372
- display: activeQuickStartID ? 'none' : 'flex',
2373
- },
2374
- }
2375
- : {};
2376
- const panelContent = (React__namespace.createElement(QuickStartPanelContent, Object.assign({ quickStarts: combinedQuickStarts, handleClose: handleClose, activeQuickStartID: activeQuickStartID, appendTo: appendTo, isResizable: !fullWidth, headerVariant: useLegacyHeaderColors ? '' : 'blue-white' }, fullWidthPanelStyle)));
2377
- return (React__namespace.createElement(React__namespace.Fragment, null,
2378
- React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeQuickStartID, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, Object.assign({ panelContent: panelContent }, fullWidthBodyStyle),
2379
- React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent))),
2380
- React__namespace.createElement(QuickStartCloseModal, { isOpen: modalOpen, onConfirm: onModalConfirm, onCancel: onModalCancel })));
2381
- };
2382
-
2383
- const HelpTopicContextDefaults = {
2384
- helpTopics: [],
2385
- setHelpTopics: () => { },
2386
- activeHelpTopic: null,
2387
- setActiveHelpTopicByName: () => { },
2388
- filteredHelpTopics: [],
2389
- setFilteredHelpTopics: () => { },
2390
- loading: false,
2391
- };
2392
- const HelpTopicContext = React__default['default'].createContext(HelpTopicContextDefaults);
2393
- const useValuesForHelpTopicContext = (value = {}) => {
2394
- const combinedValue = Object.assign(Object.assign({}, HelpTopicContextDefaults), value);
2395
- const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
2396
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
2397
- const [helpTopics, setHelpTopics] = React__default['default'].useState(combinedValue.helpTopics || []);
2398
- const [activeHelpTopic, setActiveHelpTopic] = React__default['default'].useState(combinedValue.activeHelpTopic || null);
2399
- const setActiveHelpTopicByName = React__default['default'].useCallback((helpTopicName) => {
2400
- const topic = helpTopics.find((t) => t.name === helpTopicName);
2401
- if (!helpTopicName) {
2402
- setActiveHelpTopic(null);
2403
- return;
2404
- }
2405
- setActiveHelpTopic(topic);
2406
- }, [helpTopics]);
2407
- const [filteredHelpTopics, setFilteredHelpTopics] = React__default['default'].useState(combinedValue.filteredHelpTopics || []);
2408
- return {
2409
- helpTopics,
2410
- setHelpTopics,
2411
- activeHelpTopic,
2412
- setActiveHelpTopicByName,
2413
- filteredHelpTopics,
2414
- setFilteredHelpTopics,
2415
- loading,
2416
- setLoading,
2417
- };
2418
- };
2419
-
2420
- const HelpTopicPanelContent = (_a) => {
2421
- var _b, _c;
2422
- var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
2423
- const { setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2424
- const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React__namespace.useState(false);
2425
- const toggleHelpTopicMenu = () => {
2426
- setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);
2427
- };
2428
- const onSelectHelpTopic = (_event, value) => {
2429
- const topicName = value;
2430
- setActiveHelpTopicByName(topicName.toString());
2431
- toggleHelpTopicMenu();
2432
- };
2433
- const helpTopicOptions = filteredHelpTopics.length > 1 &&
2434
- filteredHelpTopics.map((topic) => (React__namespace.createElement(reactCore.SelectOption, { key: topic.name, value: topic.name }, topic.title)));
2435
- const paddingContainer = (children) => React__namespace.createElement("div", { style: { padding: '24px' } }, children);
2436
- const panelBodyItems = (React__namespace.createElement(React__namespace.Fragment, null,
2437
- paddingContainer(React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2438
- !!((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React__namespace.createElement(reactCore.Divider, null),
2439
- paddingContainer(React__namespace.createElement(reactCore.Stack, { hasGutter: true }, (_c = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _c === void 0 ? void 0 : _c.map(({ href, text, newTab, isExternal }, index) => (React__namespace.createElement(reactCore.StackItem, { key: index },
2440
- React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: newTab ? '_blank' : '', rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: isExternal ? React__namespace.createElement(ExternalLinkAltIcon__default['default'], null) : null, iconPosition: "right", style: { fontSize: 'inherit' } }, text || href))))))));
2441
- const content = (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
2442
- React__namespace.createElement("div", null,
2443
- React__namespace.createElement(reactCore.DrawerHead, null,
2444
- React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title" },
2445
- helpTopicOptions && (React__namespace.createElement(reactCore.Select, { isPlain: true, id: "help-topics-select", selected: activeHelpTopic, isOpen: isHelpTopicMenuOpen, onSelect: onSelectHelpTopic, onOpenChange: (isOpen) => setIsHelpTopicMenuOpen(isOpen), toggle: (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, icon: React__namespace.createElement(BarsIcon__default['default'], null), onClick: toggleHelpTopicMenu, isExpanded: isHelpTopicMenuOpen }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)) },
2446
- React__namespace.createElement(reactCore.SelectList, null, helpTopicOptions))),
2447
- React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
2448
- React__namespace.createElement(reactCore.DrawerActions, null,
2449
- React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
2450
- React__namespace.createElement(reactCore.Divider, null),
2451
- React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
2452
- return content;
2453
- };
2454
-
2455
- const HelpTopicContainer = (_a) => {
2456
- var { helpTopics, children, resourceBundle, language, loading = false, markdown, contextProps } = _a, props = tslib.__rest(_a, ["helpTopics", "children", "resourceBundle", "language", "loading", "markdown", "contextProps"]);
2457
- const valuesForHelpTopicContext = useValuesForHelpTopicContext(Object.assign({ helpTopics,
2458
- language, resourceBundle: Object.assign({}, resourceBundle), loading,
2459
- markdown }, contextProps));
2460
- React__namespace.useEffect(() => {
2461
- if (loading !== valuesForHelpTopicContext.loading) {
2462
- valuesForHelpTopicContext.setLoading(loading);
2463
- }
2464
- }, [loading, valuesForHelpTopicContext]);
2465
- React__namespace.useEffect(() => {
2466
- if (helpTopics &&
2467
- JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
2468
- valuesForHelpTopicContext.setHelpTopics(helpTopics);
2469
- }
2470
- }, [helpTopics, valuesForHelpTopicContext]);
2471
- return (React__namespace.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
2472
- React__namespace.createElement(HelpTopicDrawer, Object.assign({}, props), children)));
2473
- };
2474
- const HelpTopicDrawer = (_a) => {
2475
- var { children } = _a, props = tslib.__rest(_a, ["children"]);
2476
- const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2477
- const onClose = () => {
2478
- setActiveHelpTopicByName('');
2479
- };
2480
- const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
2481
- return (React__namespace.createElement(React__namespace.Fragment, null,
2482
- React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, { panelContent: panelContent },
2483
- React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent)))));
2484
- };
2485
-
2486
- const useLocalStorage = (key, initialValue) => {
2487
- // State to store our value
2488
- // Pass initial state function to useState so logic is only executed once
2489
- const [storedValue, setStoredValue] = React.useState(() => {
2490
- try {
2491
- // Get from local storage by key
2492
- const item = window.localStorage.getItem(key);
2493
- // Parse stored json or if none return initialValue
2494
- return item ? JSON.parse(item) : initialValue;
2495
- }
2496
- catch (error) {
2497
- // If error also return initialValue
2498
- // eslint-disable-next-line no-console
2499
- console.log(error);
2500
- return initialValue;
2501
- }
2502
- });
2503
- // Return a wrapped version of useState's setter function that ...
2504
- // ... persists the new value to localStorage.
2505
- const setValue = (value) => {
2506
- try {
2507
- // Allow value to be a function so we have same API as useState
2508
- const valueToStore = value instanceof Function ? value(storedValue) : value;
2509
- // Save state
2510
- setStoredValue(valueToStore);
2511
- // Save to local storage
2512
- window.localStorage.setItem(key, JSON.stringify(valueToStore));
2513
- }
2514
- catch (error) {
2515
- // A more advanced implementation would handle the error case
2516
- // eslint-disable-next-line no-console
2517
- console.log(error);
2518
- }
2519
- };
2520
- return [storedValue, setValue];
2521
- };
2522
-
2523
- /* eslint-disable */
2524
- // Brought in from dev to publish this with QS module
2525
- // Dev now imports from here
2526
- const ProcQuickStartParser = (quickStart, environmentVariables) => {
2527
- var _a;
2528
- const replaceEnvironmentVariables = (s) => s === null || s === void 0 ? void 0 : s.replace(/\${(\w+)}/, (substring, name) => {
2529
- return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
2530
- });
2531
- quickStart.spec.tasks = (_a = quickStart.spec.tasks) === null || _a === void 0 ? void 0 : _a.map((task, index) => {
2532
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2533
- let proc;
2534
- let answer;
2535
- if (typeof task === 'string') {
2536
- proc = task;
2537
- answer = {};
2538
- }
2539
- else {
2540
- proc = task.proc;
2541
- answer = task;
2542
- delete task.proc;
2543
- }
2544
- let description = '', procedure, verification, title, summaryFailed, success, reviewFailed, prerequisites;
2545
- if (proc) {
2546
- const taskDOM = document.createElement('div');
2547
- taskDOM.innerHTML = proc;
2548
- // remove the screencapture images
2549
- taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
2550
- var _a;
2551
- (_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(node);
2552
- });
2553
- title = (_a = taskDOM
2554
- .querySelector('h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child')) === null || _a === void 0 ? void 0 : _a.innerHTML.trim();
2555
- let sectionBody = taskDOM.querySelector('.sectionbody');
2556
- if (!(sectionBody === null || sectionBody === void 0 ? void 0 : sectionBody.hasChildNodes())) {
2557
- // possibly in other templates, where we want to look for article
2558
- sectionBody = taskDOM.querySelector('article');
2559
- }
2560
- if (sectionBody) {
2561
- for (let i = 0; i < sectionBody.children.length || 0; i++) {
2562
- /**
2563
- child typically looks like:
2144
+ const QuickStartFooter = ({ status, taskNumber, totalTasks, onNext, onBack, footerClass, quickStartId, }) => {
2145
+ const { restartQuickStart, getResource } = React__namespace.useContext(QuickStartContext);
2146
+ const PrimaryButtonText = React__namespace.useMemo(() => ({
2147
+ START: getResource('Start'),
2148
+ CONTINUE: getResource('Continue'),
2149
+ NEXT: getResource('Next'),
2150
+ CLOSE: getResource('Close'),
2151
+ }), [getResource]);
2152
+ const SecondaryButtonText = React__namespace.useMemo(() => ({
2153
+ BACK: getResource('Back'),
2154
+ RESTART: getResource('Restart'),
2155
+ }), [getResource]);
2156
+ const onRestart = React__namespace.useCallback((e) => {
2157
+ e.preventDefault();
2158
+ e.stopPropagation();
2159
+ restartQuickStart(quickStartId, totalTasks);
2160
+ }, [quickStartId, restartQuickStart, totalTasks]);
2161
+ const getPrimaryButtonText = React__namespace.useMemo(() => {
2162
+ if (status === exports.QuickStartStatus.NOT_STARTED) {
2163
+ return PrimaryButtonText.START;
2164
+ }
2165
+ if (taskNumber === totalTasks) {
2166
+ return PrimaryButtonText.CLOSE;
2167
+ }
2168
+ if (taskNumber > -1 && taskNumber < totalTasks) {
2169
+ return PrimaryButtonText.NEXT;
2170
+ }
2171
+ return PrimaryButtonText.CONTINUE;
2172
+ }, [taskNumber, totalTasks, PrimaryButtonText, status]);
2173
+ const getPrimaryButton = React__namespace.useMemo(() => (React__namespace.createElement(reactCore.Button, { variant: "primary", className: "pfext-quick-start-footer__actionbtn", onClick: onNext, "data-testid": `qs-drawer-${camelize(getPrimaryButtonText)}`, "data-test": `${getPrimaryButtonText} button` }, getPrimaryButtonText)), [getPrimaryButtonText, onNext]);
2174
+ const getSecondaryButton = React__namespace.useMemo(() => taskNumber === -1 && status !== exports.QuickStartStatus.NOT_STARTED ? (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onRestart, "data-testid": "qs-drawer-restart" }, SecondaryButtonText.RESTART)) : (taskNumber > -1 && (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onBack, "data-testid": "qs-drawer-back" }, SecondaryButtonText.BACK))), [onRestart, onBack, SecondaryButtonText, status, taskNumber]);
2175
+ const getSideNoteAction = React__namespace.useMemo(() => taskNumber !== -1 && (React__namespace.createElement(reactCore.Button, { variant: "link", className: "pfext-quick-start-footer__restartbtn", onClick: onRestart, "data-testid": "qs-drawer-side-note-action" }, SecondaryButtonText.RESTART)), [taskNumber, onRestart, SecondaryButtonText.RESTART]);
2176
+ return (React__namespace.createElement("div", { className: `pfext-quick-start-footer ${footerClass}` },
2177
+ getPrimaryButton,
2178
+ getSecondaryButton,
2179
+ getSideNoteAction));
2180
+ };
2181
+
2182
+ const QuickStartController = ({ quickStart, nextQuickStarts, contentRef, footerClass, }) => {
2183
+ const { metadata: { name }, spec: { tasks = [] }, } = quickStart;
2184
+ const totalTasks = tasks === null || tasks === void 0 ? void 0 : tasks.length;
2185
+ const { activeQuickStartState, setActiveQuickStart, setQuickStartTaskNumber, setQuickStartTaskStatus, nextStep, previousStep, } = React__namespace.useContext(QuickStartContext);
2186
+ const status = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
2187
+ const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
2188
+ const allTaskStatuses = tasks.map((task, index) => activeQuickStartState[`taskStatus${index}`]);
2189
+ const handleQuickStartChange = React__namespace.useCallback((quickStartId) => setActiveQuickStart(quickStartId), [setActiveQuickStart]);
2190
+ const handleTaskStatusChange = React__namespace.useCallback((newTaskStatus) => setQuickStartTaskStatus(newTaskStatus), [setQuickStartTaskStatus]);
2191
+ const getQuickStartActiveTask = React__namespace.useCallback(() => {
2192
+ let activeTaskNumber = 0;
2193
+ while (activeTaskNumber !== totalTasks &&
2194
+ activeQuickStartState[`taskStatus${activeTaskNumber}`] !== exports.QuickStartTaskStatus.INIT) {
2195
+ activeTaskNumber++;
2196
+ }
2197
+ return activeTaskNumber;
2198
+ }, [totalTasks, activeQuickStartState]);
2199
+ const handleQuickStartContinue = React__namespace.useCallback(() => {
2200
+ const activeTaskNumber = getQuickStartActiveTask();
2201
+ setQuickStartTaskNumber(name, activeTaskNumber);
2202
+ }, [getQuickStartActiveTask, setQuickStartTaskNumber, name]);
2203
+ const handleNext = React__namespace.useCallback(() => {
2204
+ if (status === exports.QuickStartStatus.COMPLETE && taskNumber === totalTasks) {
2205
+ return handleQuickStartChange('');
2206
+ }
2207
+ if (status !== exports.QuickStartStatus.NOT_STARTED && taskNumber === -1) {
2208
+ return handleQuickStartContinue();
2209
+ }
2210
+ return nextStep(totalTasks);
2211
+ }, [handleQuickStartChange, nextStep, status, taskNumber, totalTasks, handleQuickStartContinue]);
2212
+ const handleBack = React__namespace.useCallback(() => previousStep(), [previousStep]);
2213
+ const handleTaskSelect = React__namespace.useCallback((selectedTaskNumber) => {
2214
+ setQuickStartTaskNumber(name, selectedTaskNumber);
2215
+ }, [name, setQuickStartTaskNumber]);
2216
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2217
+ React__namespace.createElement(QuickStartContent, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskSelect: handleTaskSelect, onTaskReview: handleTaskStatusChange, onQuickStartChange: handleQuickStartChange, ref: contentRef }),
2218
+ React__namespace.createElement(QuickStartFooter, { status: status, taskNumber: taskNumber, totalTasks: totalTasks, onNext: handleNext, onBack: handleBack, footerClass: footerClass, quickStartId: quickStart.metadata.name })));
2219
+ };
2220
+
2221
+ const getElement = (appendTo) => {
2222
+ if (typeof appendTo === 'function') {
2223
+ return appendTo();
2224
+ }
2225
+ return appendTo;
2226
+ };
2227
+ const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
2228
+ React__namespace.useEffect(() => {
2229
+ if (node) {
2230
+ node.scrollTo({ top: 0, behavior: 'smooth' });
2231
+ }
2232
+ }, [taskNumber, node]);
2233
+ };
2234
+ const QuickStartPanelContent = (_a) => {
2235
+ var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = tslib.__rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
2236
+ const titleRef = React__namespace.useRef(null);
2237
+ const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
2238
+ const [contentRef, setContentRef] = React__namespace.useState();
2239
+ const shadows = useScrollShadows(contentRef);
2240
+ const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
2241
+ const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
2242
+ useScrollTopOnTaskNumberChange(contentRef, taskNumber);
2243
+ const nextQuickStarts = quickStarts.filter((qs) => { var _a; return (_a = quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.nextQuickStart) === null || _a === void 0 ? void 0 : _a.includes(qs.metadata.name); });
2244
+ const headerClasses = reactStyles.css('pfext-quick-start-panel-content__header', {
2245
+ 'pfext-quick-start-panel-content__header__shadow': shadows === Shadows.top || shadows === Shadows.both,
2246
+ 'pfext-quick-start-panel-content__header--blue-white': headerVariant === 'blue-white',
2247
+ });
2248
+ const footerClass = reactStyles.css({
2249
+ 'pfext-quick-start-panel-content__footer__shadow': shadows === Shadows.bottom || shadows === Shadows.both,
2250
+ });
2251
+ const getStep = () => {
2252
+ const tasks = quickStart.spec.tasks.length;
2253
+ if (Number.parseInt(taskNumber) === -1) {
2254
+ return 'intro';
2255
+ }
2256
+ if (Number.parseInt(taskNumber) === tasks) {
2257
+ return 'conclusion';
2258
+ }
2259
+ return Number.parseInt(taskNumber) + 1;
2260
+ };
2261
+ React__namespace.useEffect(() => {
2262
+ if (quickStart) {
2263
+ titleRef.current.focus();
2264
+ }
2265
+ }, [quickStart]);
2266
+ const content = quickStart ? (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base", "data-testid": `qs-drawer-${camelize(quickStart.spec.displayName)}`, "data-qs": `qs-step-${getStep()}`, "data-test": "quickstart drawer" }, props),
2267
+ React__namespace.createElement("div", { className: headerClasses },
2268
+ React__namespace.createElement(reactCore.DrawerHead, null,
2269
+ React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
2270
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } },
2271
+ React__namespace.createElement("span", { dangerouslySetInnerHTML: {
2272
+ __html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
2273
+ } }),
2274
+ ' ',
2275
+ React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2276
+ ? getResource('{{type}} • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2277
+ .replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2278
+ .replace('{{type}}', getResource('Type'))
2279
+ : getResource('Type')))),
2280
+ showClose && (React__namespace.createElement(reactCore.DrawerActions, null,
2281
+ React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: handleClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))))),
2282
+ React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
2283
+ React__namespace.createElement(QuickStartController, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, footerClass: footerClass, contentRef: setContentRef })))) : null;
2284
+ if (appendTo) {
2285
+ return ReactDOM__namespace.createPortal(content, getElement(appendTo));
2286
+ }
2287
+ return content;
2288
+ };
2289
+
2290
+ const QuickStartContainer = (_a) => {
2291
+ var { quickStarts, children, activeQuickStartID, allQuickStartStates, setActiveQuickStartID, setAllQuickStartStates, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress, resourceBundle, showCardFooters, useLegacyHeaderColors, language, loading = false, useQueryParams = true, markdown, contextProps, alwaysShowTaskReview = true } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "activeQuickStartID", "allQuickStartStates", "setActiveQuickStartID", "setAllQuickStartStates", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress", "resourceBundle", "showCardFooters", "useLegacyHeaderColors", "language", "loading", "useQueryParams", "markdown", "contextProps", "alwaysShowTaskReview"]);
2292
+ const valuesForQuickstartContext = useValuesForQuickStartContext(Object.assign({ allQuickStarts: quickStarts, activeQuickStartID,
2293
+ setActiveQuickStartID,
2294
+ allQuickStartStates,
2295
+ setAllQuickStartStates, footer: {
2296
+ show: showCardFooters,
2297
+ }, useLegacyHeaderColors,
2298
+ language, resourceBundle: Object.assign({}, resourceBundle), loading,
2299
+ useQueryParams,
2300
+ markdown,
2301
+ alwaysShowTaskReview }, contextProps));
2302
+ React__namespace.useEffect(() => {
2303
+ if (quickStarts &&
2304
+ JSON.stringify(quickStarts) !== JSON.stringify(valuesForQuickstartContext.allQuickStarts)) {
2305
+ valuesForQuickstartContext.setAllQuickStarts(quickStarts);
2306
+ }
2307
+ }, [quickStarts, valuesForQuickstartContext]);
2308
+ React__namespace.useEffect(() => {
2309
+ if (loading !== valuesForQuickstartContext.loading) {
2310
+ valuesForQuickstartContext.setLoading(loading);
2311
+ }
2312
+ }, [loading, valuesForQuickstartContext]);
2313
+ const drawerProps = Object.assign({ appendTo,
2314
+ fullWidth,
2315
+ onCloseInProgress,
2316
+ onCloseNotInProgress }, props);
2317
+ return (React__namespace.createElement(QuickStartContext.Provider, { value: valuesForQuickstartContext },
2318
+ React__namespace.createElement(QuickStartDrawer, Object.assign({}, drawerProps), children)));
2319
+ };
2320
+ const QuickStartDrawer = (_a) => {
2321
+ var { quickStarts = [], children, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress"]);
2322
+ const { activeQuickStartID, setActiveQuickStart, allQuickStarts = [], activeQuickStartState, allQuickStartStates, setAllQuickStartStates, useLegacyHeaderColors, } = React__namespace.useContext(QuickStartContext);
2323
+ const combinedQuickStarts = allQuickStarts.concat(quickStarts);
2324
+ React__namespace.useEffect(() => {
2325
+ const params = new URLSearchParams(window.location.search);
2326
+ // if there is a quick start param, but the quick start is not active, set it
2327
+ // this can happen if a new browser session is opened or an incognito window for example
2328
+ const quickStartIdFromParam = params.get(QUICKSTART_ID_FILTER_KEY) || '';
2329
+ if (quickStartIdFromParam && activeQuickStartID !== quickStartIdFromParam) {
2330
+ const activeQuickStart = getQuickStartByName(quickStartIdFromParam, combinedQuickStarts);
2331
+ // don't try to load a quick start that is actually just an external resource (spec.link)
2332
+ if (combinedQuickStarts.length > 0 && activeQuickStart && !activeQuickStart.spec.link) {
2333
+ setActiveQuickStart(quickStartIdFromParam);
2334
+ }
2335
+ }
2336
+ }, [activeQuickStartID, combinedQuickStarts, setActiveQuickStart]);
2337
+ React__namespace.useEffect(() => {
2338
+ // If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
2339
+ if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
2340
+ setAllQuickStartStates(Object.assign(Object.assign({}, allQuickStartStates), { [activeQuickStartID]: getDefaultQuickStartState() }));
2341
+ }
2342
+ }, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
2343
+ const [modalOpen, setModalOpen] = React__namespace.useState(false);
2344
+ const activeQuickStartStatus = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
2345
+ const onClose = () => setActiveQuickStart('');
2346
+ const handleClose = () => {
2347
+ if (activeQuickStartStatus === exports.QuickStartStatus.IN_PROGRESS) {
2348
+ if (onCloseInProgress) {
2349
+ onCloseInProgress();
2350
+ }
2351
+ else {
2352
+ setModalOpen(true);
2353
+ }
2354
+ }
2355
+ else if (onCloseNotInProgress) {
2356
+ onCloseNotInProgress();
2357
+ }
2358
+ else {
2359
+ onClose();
2360
+ }
2361
+ };
2362
+ const onModalConfirm = () => {
2363
+ setModalOpen(false);
2364
+ onClose();
2365
+ };
2366
+ const onModalCancel = () => setModalOpen(false);
2367
+ const fullWidthPanelStyle = fullWidth
2368
+ ? {
2369
+ style: {
2370
+ flex: 1,
2371
+ },
2372
+ }
2373
+ : {};
2374
+ const fullWidthBodyStyle = fullWidth
2375
+ ? {
2376
+ style: {
2377
+ display: activeQuickStartID ? 'none' : 'flex',
2378
+ },
2379
+ }
2380
+ : {};
2381
+ const panelContent = (React__namespace.createElement(QuickStartPanelContent, Object.assign({ quickStarts: combinedQuickStarts, handleClose: handleClose, activeQuickStartID: activeQuickStartID, appendTo: appendTo, isResizable: !fullWidth, headerVariant: useLegacyHeaderColors ? '' : 'blue-white' }, fullWidthPanelStyle)));
2382
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2383
+ React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeQuickStartID, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, Object.assign({ panelContent: panelContent }, fullWidthBodyStyle),
2384
+ React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent))),
2385
+ React__namespace.createElement(QuickStartCloseModal, { isOpen: modalOpen, onConfirm: onModalConfirm, onCancel: onModalCancel })));
2386
+ };
2387
+
2388
+ const HelpTopicContextDefaults = {
2389
+ helpTopics: [],
2390
+ setHelpTopics: () => { },
2391
+ activeHelpTopic: null,
2392
+ setActiveHelpTopicByName: () => { },
2393
+ filteredHelpTopics: [],
2394
+ setFilteredHelpTopics: () => { },
2395
+ loading: false,
2396
+ };
2397
+ const HelpTopicContext = React__default['default'].createContext(HelpTopicContextDefaults);
2398
+ const useValuesForHelpTopicContext = (value = {}) => {
2399
+ const combinedValue = Object.assign(Object.assign({}, HelpTopicContextDefaults), value);
2400
+ const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
2401
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
2402
+ const [helpTopics, setHelpTopics] = React__default['default'].useState(combinedValue.helpTopics || []);
2403
+ const [activeHelpTopic, setActiveHelpTopic] = React__default['default'].useState(combinedValue.activeHelpTopic || null);
2404
+ const setActiveHelpTopicByName = React__default['default'].useCallback((helpTopicName) => {
2405
+ const topic = helpTopics.find((t) => t.name === helpTopicName);
2406
+ if (!helpTopicName) {
2407
+ setActiveHelpTopic(null);
2408
+ return;
2409
+ }
2410
+ setActiveHelpTopic(topic);
2411
+ }, [helpTopics]);
2412
+ const [filteredHelpTopics, setFilteredHelpTopics] = React__default['default'].useState(combinedValue.filteredHelpTopics || []);
2413
+ return {
2414
+ helpTopics,
2415
+ setHelpTopics,
2416
+ activeHelpTopic,
2417
+ setActiveHelpTopicByName,
2418
+ filteredHelpTopics,
2419
+ setFilteredHelpTopics,
2420
+ loading,
2421
+ setLoading,
2422
+ };
2423
+ };
2424
+
2425
+ const HelpTopicPanelContent = (_a) => {
2426
+ var _b, _c;
2427
+ var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
2428
+ const { setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2429
+ const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React__namespace.useState(false);
2430
+ const toggleHelpTopicMenu = () => {
2431
+ setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);
2432
+ };
2433
+ const onSelectHelpTopic = (_event, value) => {
2434
+ const topicName = value;
2435
+ setActiveHelpTopicByName(topicName.toString());
2436
+ toggleHelpTopicMenu();
2437
+ };
2438
+ const helpTopicOptions = filteredHelpTopics.length > 1 &&
2439
+ filteredHelpTopics.map((topic) => (React__namespace.createElement(reactCore.SelectOption, { key: topic.name, value: topic.name }, topic.title)));
2440
+ const paddingContainer = (children) => React__namespace.createElement("div", { style: { padding: '24px' } }, children);
2441
+ const panelBodyItems = (React__namespace.createElement(React__namespace.Fragment, null,
2442
+ paddingContainer(React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2443
+ !!((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React__namespace.createElement(reactCore.Divider, null),
2444
+ paddingContainer(React__namespace.createElement(reactCore.Stack, { hasGutter: true }, (_c = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _c === void 0 ? void 0 : _c.map(({ href, text, newTab, isExternal }, index) => (React__namespace.createElement(reactCore.StackItem, { key: index },
2445
+ React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: newTab ? '_blank' : '', rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: isExternal ? React__namespace.createElement(ExternalLinkAltIcon__default['default'], null) : null, iconPosition: "right", style: { fontSize: 'inherit' } }, text || href))))))));
2446
+ const content = (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
2447
+ React__namespace.createElement("div", null,
2448
+ React__namespace.createElement(reactCore.DrawerHead, null,
2449
+ React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title" },
2450
+ helpTopicOptions && (React__namespace.createElement(reactCore.Select, { isPlain: true, id: "help-topics-select", selected: activeHelpTopic, isOpen: isHelpTopicMenuOpen, onSelect: onSelectHelpTopic, onOpenChange: (isOpen) => setIsHelpTopicMenuOpen(isOpen), toggle: (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, icon: React__namespace.createElement(BarsIcon__default['default'], null), onClick: toggleHelpTopicMenu, isExpanded: isHelpTopicMenuOpen }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)) },
2451
+ React__namespace.createElement(reactCore.SelectList, null, helpTopicOptions))),
2452
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
2453
+ React__namespace.createElement(reactCore.DrawerActions, null,
2454
+ React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
2455
+ React__namespace.createElement(reactCore.Divider, null),
2456
+ React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
2457
+ return content;
2458
+ };
2459
+
2460
+ const HelpTopicContainer = (_a) => {
2461
+ var { helpTopics, children, resourceBundle, language, loading = false, markdown, contextProps } = _a, props = tslib.__rest(_a, ["helpTopics", "children", "resourceBundle", "language", "loading", "markdown", "contextProps"]);
2462
+ const valuesForHelpTopicContext = useValuesForHelpTopicContext(Object.assign({ helpTopics,
2463
+ language, resourceBundle: Object.assign({}, resourceBundle), loading,
2464
+ markdown }, contextProps));
2465
+ React__namespace.useEffect(() => {
2466
+ if (loading !== valuesForHelpTopicContext.loading) {
2467
+ valuesForHelpTopicContext.setLoading(loading);
2468
+ }
2469
+ }, [loading, valuesForHelpTopicContext]);
2470
+ React__namespace.useEffect(() => {
2471
+ if (helpTopics &&
2472
+ JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
2473
+ valuesForHelpTopicContext.setHelpTopics(helpTopics);
2474
+ }
2475
+ }, [helpTopics, valuesForHelpTopicContext]);
2476
+ return (React__namespace.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
2477
+ React__namespace.createElement(HelpTopicDrawer, Object.assign({}, props), children)));
2478
+ };
2479
+ const HelpTopicDrawer = (_a) => {
2480
+ var { children } = _a, props = tslib.__rest(_a, ["children"]);
2481
+ const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2482
+ const onClose = () => {
2483
+ setActiveHelpTopicByName('');
2484
+ };
2485
+ const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
2486
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2487
+ React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, { panelContent: panelContent },
2488
+ React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent)))));
2489
+ };
2490
+
2491
+ const useLocalStorage = (key, initialValue) => {
2492
+ // State to store our value
2493
+ // Pass initial state function to useState so logic is only executed once
2494
+ const [storedValue, setStoredValue] = React.useState(() => {
2495
+ try {
2496
+ // Get from local storage by key
2497
+ const item = window.localStorage.getItem(key);
2498
+ // Parse stored json or if none return initialValue
2499
+ return item ? JSON.parse(item) : initialValue;
2500
+ }
2501
+ catch (error) {
2502
+ // If error also return initialValue
2503
+ // eslint-disable-next-line no-console
2504
+ console.log(error);
2505
+ return initialValue;
2506
+ }
2507
+ });
2508
+ // Return a wrapped version of useState's setter function that ...
2509
+ // ... persists the new value to localStorage.
2510
+ const setValue = (value) => {
2511
+ try {
2512
+ // Allow value to be a function so we have same API as useState
2513
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
2514
+ // Save state
2515
+ setStoredValue(valueToStore);
2516
+ // Save to local storage
2517
+ window.localStorage.setItem(key, JSON.stringify(valueToStore));
2518
+ }
2519
+ catch (error) {
2520
+ // A more advanced implementation would handle the error case
2521
+ // eslint-disable-next-line no-console
2522
+ console.log(error);
2523
+ }
2524
+ };
2525
+ return [storedValue, setValue];
2526
+ };
2527
+
2528
+ /* eslint-disable */
2529
+ // Brought in from dev to publish this with QS module
2530
+ // Dev now imports from here
2531
+ const ProcQuickStartParser = (quickStart, environmentVariables) => {
2532
+ var _a;
2533
+ const replaceEnvironmentVariables = (s) => s === null || s === void 0 ? void 0 : s.replace(/\${(\w+)}/, (substring, name) => {
2534
+ return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
2535
+ });
2536
+ quickStart.spec.tasks = (_a = quickStart.spec.tasks) === null || _a === void 0 ? void 0 : _a.map((task, index) => {
2537
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2538
+ let proc;
2539
+ let answer;
2540
+ if (typeof task === 'string') {
2541
+ proc = task;
2542
+ answer = {};
2543
+ }
2544
+ else {
2545
+ proc = task.proc;
2546
+ answer = task;
2547
+ delete task.proc;
2548
+ }
2549
+ let description = '', procedure, verification, title, summaryFailed, success, reviewFailed, prerequisites;
2550
+ if (proc) {
2551
+ const taskDOM = document.createElement('div');
2552
+ taskDOM.innerHTML = proc;
2553
+ // remove the screencapture images
2554
+ taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
2555
+ var _a;
2556
+ (_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(node);
2557
+ });
2558
+ title = (_a = taskDOM
2559
+ .querySelector('h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child')) === null || _a === void 0 ? void 0 : _a.innerHTML.trim();
2560
+ let sectionBody = taskDOM.querySelector('.sectionbody');
2561
+ if (!(sectionBody === null || sectionBody === void 0 ? void 0 : sectionBody.hasChildNodes())) {
2562
+ // possibly in other templates, where we want to look for article
2563
+ sectionBody = taskDOM.querySelector('article');
2564
+ }
2565
+ if (sectionBody) {
2566
+ for (let i = 0; i < sectionBody.children.length || 0; i++) {
2567
+ /**
2568
+ child typically looks like:
2564
2569
 
2565
- <div class="paragraph|olist|ulist|admonitionblock">
2566
- <div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
2567
- <ol|ul class="arabic">
2568
- <li>
2569
- <li>...
2570
- </ol|ul>
2571
- </div>
2570
+ <div class="paragraph|olist|ulist|admonitionblock">
2571
+ <div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
2572
+ <ol|ul class="arabic">
2573
+ <li>
2574
+ <li>...
2575
+ </ol|ul>
2576
+ </div>
2572
2577
 
2573
- And the below code extracts the <ol> or <ul>
2574
- Except for when there is no <div class="title|heading"/>, then the description is extracted
2575
- in the else if below
2576
- */
2577
- const child = sectionBody.children.item(i);
2578
- // find the title
2579
- const sectionTitle = child === null || child === void 0 ? void 0 : child.querySelector('.heading,.title');
2580
- // should this section be assigned to a specific section
2581
- const sectionTitleText = (_b = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _b === void 0 ? void 0 : _b.trim();
2582
- const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes((_c = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim());
2583
- if (isKnownSection) {
2584
- switch (sectionTitleText) {
2585
- case 'Procedure':
2586
- procedure = (_d = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _d === void 0 ? void 0 : _d.outerHTML.trim();
2587
- break;
2588
- case 'Verification':
2589
- verification = (_e = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _e === void 0 ? void 0 : _e.outerHTML.trim();
2590
- break;
2591
- case 'Prerequisites':
2592
- prerequisites = (_f = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _f === void 0 ? void 0 : _f.outerHTML.trim();
2593
- break;
2594
- }
2595
- }
2596
- else if (!procedure) {
2597
- // Otherwise if it comes before a procedure it's part of the description
2598
- description = description + (child === null || child === void 0 ? void 0 : child.outerHTML.trim());
2599
- }
2600
- }
2601
- }
2602
- success = (_g = taskDOM.querySelector('.qs-summary.success')) === null || _g === void 0 ? void 0 : _g.innerHTML.trim();
2603
- reviewFailed = (_h = taskDOM.querySelector('.qs-review.failed')) === null || _h === void 0 ? void 0 : _h.innerHTML.trim();
2604
- summaryFailed = (_j = taskDOM.querySelector('.qs-summary.failed')) === null || _j === void 0 ? void 0 : _j.innerHTML.trim();
2605
- }
2606
- answer.title = replaceEnvironmentVariables(answer.title || title);
2607
- answer.description = replaceEnvironmentVariables(answer.description || `${description} ${prerequisites || ''} ${procedure}`);
2608
- answer.review = answer.review || {};
2609
- answer.review.instructions = replaceEnvironmentVariables(((_k = answer.review) === null || _k === void 0 ? void 0 : _k.instructions) || verification || 'Have you completed these steps?');
2610
- answer.review.failedTaskHelp = replaceEnvironmentVariables(answer.review.failedTaskHelp ||
2611
- reviewFailed ||
2612
- 'This task isn’t verified yet. Try the task again.');
2613
- answer.summary = answer.summary || {};
2614
- answer.summary.success = replaceEnvironmentVariables(answer.summary.success || success || 'You have completed this task!');
2615
- answer.summary.failed = replaceEnvironmentVariables(answer.summary.failed || summaryFailed || 'Try the steps again.');
2616
- return answer;
2617
- });
2618
- return quickStart;
2578
+ And the below code extracts the <ol> or <ul>
2579
+ Except for when there is no <div class="title|heading"/>, then the description is extracted
2580
+ in the else if below
2581
+ */
2582
+ const child = sectionBody.children.item(i);
2583
+ // find the title
2584
+ const sectionTitle = child === null || child === void 0 ? void 0 : child.querySelector('.heading,.title');
2585
+ // should this section be assigned to a specific section
2586
+ const sectionTitleText = (_b = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _b === void 0 ? void 0 : _b.trim();
2587
+ const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes((_c = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim());
2588
+ if (isKnownSection) {
2589
+ switch (sectionTitleText) {
2590
+ case 'Procedure':
2591
+ procedure = (_d = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _d === void 0 ? void 0 : _d.outerHTML.trim();
2592
+ break;
2593
+ case 'Verification':
2594
+ verification = (_e = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _e === void 0 ? void 0 : _e.outerHTML.trim();
2595
+ break;
2596
+ case 'Prerequisites':
2597
+ prerequisites = (_f = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _f === void 0 ? void 0 : _f.outerHTML.trim();
2598
+ break;
2599
+ }
2600
+ }
2601
+ else if (!procedure) {
2602
+ // Otherwise if it comes before a procedure it's part of the description
2603
+ description = description + (child === null || child === void 0 ? void 0 : child.outerHTML.trim());
2604
+ }
2605
+ }
2606
+ }
2607
+ success = (_g = taskDOM.querySelector('.qs-summary.success')) === null || _g === void 0 ? void 0 : _g.innerHTML.trim();
2608
+ reviewFailed = (_h = taskDOM.querySelector('.qs-review.failed')) === null || _h === void 0 ? void 0 : _h.innerHTML.trim();
2609
+ summaryFailed = (_j = taskDOM.querySelector('.qs-summary.failed')) === null || _j === void 0 ? void 0 : _j.innerHTML.trim();
2610
+ }
2611
+ answer.title = replaceEnvironmentVariables(answer.title || title);
2612
+ answer.description = replaceEnvironmentVariables(answer.description || `${description} ${prerequisites || ''} ${procedure}`);
2613
+ answer.review = answer.review || {};
2614
+ answer.review.instructions = replaceEnvironmentVariables(((_k = answer.review) === null || _k === void 0 ? void 0 : _k.instructions) || verification || 'Have you completed these steps?');
2615
+ answer.review.failedTaskHelp = replaceEnvironmentVariables(answer.review.failedTaskHelp ||
2616
+ reviewFailed ||
2617
+ 'This task isn’t verified yet. Try the task again.');
2618
+ answer.summary = answer.summary || {};
2619
+ answer.summary.success = replaceEnvironmentVariables(answer.summary.success || success || 'You have completed this task!');
2620
+ answer.summary.failed = replaceEnvironmentVariables(answer.summary.failed || summaryFailed || 'Try the steps again.');
2621
+ return answer;
2622
+ });
2623
+ return quickStart;
2619
2624
  };
2620
2625
 
2621
2626
  exports.Box = Box;