@patternfly/quickstarts 2.2.0 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1357,6 +1357,20 @@ const useAdmonitionShowdownExtension = () => {
1357
1357
  }), []);
1358
1358
  };
1359
1359
 
1360
+ const useCodeShowdownExtension = () => {
1361
+ return React__namespace.useMemo(() => ({
1362
+ type: 'output',
1363
+ regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
1364
+ replace: (text, content) => {
1365
+ if (!content) {
1366
+ return text;
1367
+ }
1368
+ const pfCodeBlock = React__namespace.createElement(reactCore.CodeBlock, null, content);
1369
+ return removeTemplateWhitespace(server.renderToStaticMarkup(pfCodeBlock));
1370
+ },
1371
+ }), []);
1372
+ };
1373
+
1360
1374
  const FallbackImg = ({ src, alt, className, fallback }) => {
1361
1375
  const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
1362
1376
  if (src && isSrcValid) {
@@ -1597,6 +1611,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1597
1611
  const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
1598
1612
  const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1599
1613
  const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1614
+ const codeShowdownExtension = useCodeShowdownExtension();
1600
1615
  return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1601
1616
  {
1602
1617
  type: 'lang',
@@ -1619,6 +1634,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1619
1634
  inlineCopyClipboardShowdownExtension,
1620
1635
  multilineCopyClipboardShowdownExtension,
1621
1636
  admonitionShowdownExtension,
1637
+ codeShowdownExtension,
1622
1638
  ...(markdown ? markdown.extensions : []),
1623
1639
  ], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
1624
1640
  React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
@@ -1738,7 +1754,7 @@ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, })
1738
1754
 
1739
1755
  const QuickStartCatalog = ({ quickStarts }) => {
1740
1756
  const { activeQuickStartID, allQuickStartStates } = React__namespace.useContext(QuickStartContext);
1741
- return (React__namespace.createElement("div", { className: "pfext-page-layout__content pfext-is-dark" },
1757
+ return (React__namespace.createElement("div", { className: "pfext-page-layout__content" },
1742
1758
  React__namespace.createElement(reactCore.Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
1743
1759
  const { metadata: { name: id }, } = quickStart;
1744
1760
  return (React__namespace.createElement(reactCore.GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
@@ -1943,7 +1959,7 @@ const QuickStartCatalogHeader = ({ title, hint, }) => (React__namespace.createEl
1943
1959
  React__namespace.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
1944
1960
  hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint)));
1945
1961
 
1946
- const QuickStartCatalogSection = ({ children }) => (React__namespace.createElement("div", { className: "pfext-page-layout__content pfext-is-dark" }, children));
1962
+ const QuickStartCatalogSection = ({ children }) => (React__namespace.createElement("div", { className: "pfext-page-layout__content" }, children));
1947
1963
 
1948
1964
  const QuickStartCatalogToolbar = ({ children }) => (React__namespace.createElement(reactCore.Toolbar, { usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, children));
1949
1965
 
@@ -2340,6 +2356,7 @@ const QuickStartDrawer = (_a) => {
2340
2356
 
2341
2357
  const HelpTopicContextDefaults = {
2342
2358
  helpTopics: [],
2359
+ setHelpTopics: () => { },
2343
2360
  activeHelpTopic: null,
2344
2361
  setActiveHelpTopicByName: () => { },
2345
2362
  filteredHelpTopics: [],
@@ -2366,6 +2383,7 @@ const useValuesForHelpTopicContext = (value = {}) => {
2366
2383
  const [filteredHelpTopics, setFilteredHelpTopics] = React__default['default'].useState(combinedValue.filteredHelpTopics || []);
2367
2384
  return {
2368
2385
  helpTopics,
2386
+ setHelpTopics,
2369
2387
  activeHelpTopic,
2370
2388
  setActiveHelpTopicByName,
2371
2389
  filteredHelpTopics,
@@ -2376,7 +2394,8 @@ const useValuesForHelpTopicContext = (value = {}) => {
2376
2394
  };
2377
2395
 
2378
2396
  const HelpTopicPanelContent = (_a) => {
2379
- var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable"]);
2397
+ var _b, _c;
2398
+ var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
2380
2399
  const { setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2381
2400
  const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React__namespace.useState(false);
2382
2401
  const toggleHelpTopicMenu = () => {
@@ -2387,24 +2406,28 @@ const HelpTopicPanelContent = (_a) => {
2387
2406
  setActiveHelpTopicByName(topicName);
2388
2407
  toggleHelpTopicMenu();
2389
2408
  };
2390
- const menuItems = filteredHelpTopics.map((topic) => {
2391
- return (React__namespace.createElement(reactCore.OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2392
- });
2409
+ const menuItems = filteredHelpTopics.length > 0 &&
2410
+ filteredHelpTopics.map((topic) => {
2411
+ return (React__namespace.createElement(reactCore.OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2412
+ });
2413
+ const paddingContainer = (children) => React__namespace.createElement("div", { style: { padding: '24px' } }, children);
2414
+ const panelBodyItems = (React__namespace.createElement(React__namespace.Fragment, null,
2415
+ paddingContainer(React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2416
+ ((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React__namespace.createElement(reactCore.Divider, null),
2417
+ 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) => {
2418
+ return (React__namespace.createElement(reactCore.StackItem, { key: index },
2419
+ 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)));
2420
+ })))));
2393
2421
  const content = (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
2394
2422
  React__namespace.createElement("div", null,
2395
2423
  React__namespace.createElement(reactCore.DrawerHead, null,
2396
2424
  React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title" },
2397
- React__namespace.createElement(reactCore.OptionsMenu, { id: 'helptopics', isPlain: true, isOpen: isHelpTopicMenuOpen, toggle: React__namespace.createElement(reactCore.OptionsMenuToggle, { onToggle: toggleHelpTopicMenu, toggleTemplate: React__namespace.createElement(BarsIcon__default['default'], null) }), menuItems: menuItems }),
2398
- React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title))),
2425
+ menuItems && (React__namespace.createElement(reactCore.OptionsMenu, { id: 'helptopics', isPlain: true, isOpen: isHelpTopicMenuOpen, toggle: React__namespace.createElement(reactCore.OptionsMenuToggle, { style: { paddingLeft: '0px' }, onToggle: toggleHelpTopicMenu, toggleTemplate: React__namespace.createElement(BarsIcon__default['default'], null) }), menuItems: menuItems })),
2426
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
2427
+ React__namespace.createElement(reactCore.DrawerActions, null,
2428
+ React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
2399
2429
  React__namespace.createElement(reactCore.Divider, null),
2400
- React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
2401
- React__namespace.createElement(reactCore.Stack, { hasGutter: true },
2402
- React__namespace.createElement(reactCore.StackItem, { style: { padding: '20px' } },
2403
- React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2404
- React__namespace.createElement(reactCore.Divider, null),
2405
- React__namespace.createElement(reactCore.StackItem, { style: { padding: '20px' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links.map((link) => {
2406
- return React__namespace.createElement(QuickStartMarkdownView, { key: link, content: link });
2407
- })))))));
2430
+ React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
2408
2431
  return content;
2409
2432
  };
2410
2433
 
@@ -2418,26 +2441,23 @@ const HelpTopicContainer = (_a) => {
2418
2441
  valuesForHelpTopicContext.setLoading(loading);
2419
2442
  }
2420
2443
  }, [loading, valuesForHelpTopicContext]);
2444
+ React__namespace.useEffect(() => {
2445
+ if (helpTopics &&
2446
+ JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
2447
+ valuesForHelpTopicContext.setHelpTopics(helpTopics);
2448
+ }
2449
+ }, [helpTopics, valuesForHelpTopicContext]);
2421
2450
  const drawerProps = Object.assign({}, props);
2422
2451
  return (React__namespace.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
2423
2452
  React__namespace.createElement(HelpTopicDrawer, Object.assign({}, drawerProps), children)));
2424
2453
  };
2425
2454
  const HelpTopicDrawer = (_a) => {
2426
- var {
2427
- // helpTopics,
2428
- children } = _a, props = tslib.__rest(_a, ["children"]);
2429
- const { activeHelpTopic, filteredHelpTopics } = React__namespace.useContext(HelpTopicContext);
2430
- // Leave here if query param is desired for help topics later
2431
- // React.useEffect(() => {
2432
- // const params = new URLSearchParams(window.location.search);
2433
- // // if there is a quick start param, but the quick start is not active, set it
2434
- // // this can happen if a new browser session is opened or an incognito window for example
2435
- // const helpTopicNameFromParam = params.get(HELP_TOPIC_NAME_KEY) || '';
2436
- // if (helpTopicNameFromParam) {
2437
- // setActiveHelpTopicByName(helpTopicNameFromParam);
2438
- // }
2439
- // }, [inContextHelpTopics, setActiveHelpTopicByName]);
2440
- const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics }));
2455
+ var { children } = _a, props = tslib.__rest(_a, ["children"]);
2456
+ const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2457
+ const onClose = () => {
2458
+ setActiveHelpTopicByName('');
2459
+ };
2460
+ const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
2441
2461
  return (React__namespace.createElement(React__namespace.Fragment, null,
2442
2462
  React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, { panelContent: panelContent },
2443
2463
  React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-c-drawer__main" }, panelContent)))));
@@ -2480,6 +2500,106 @@ const useLocalStorage = (key, initialValue) => {
2480
2500
  return [storedValue, setValue];
2481
2501
  };
2482
2502
 
2503
+ /* eslint-disable */
2504
+ // Brought in from dev to publish this with QS module
2505
+ // Dev now imports from here
2506
+ const ProcQuickStartParser = (quickStart, environmentVariables) => {
2507
+ var _a;
2508
+ const replaceEnvironmentVariables = (s) => s === null || s === void 0 ? void 0 : s.replace(/\${(\w+)}/, (substring, name) => {
2509
+ return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
2510
+ });
2511
+ quickStart.spec.tasks = (_a = quickStart.spec.tasks) === null || _a === void 0 ? void 0 : _a.map((task, index) => {
2512
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2513
+ let proc;
2514
+ let answer;
2515
+ if (typeof task === 'string') {
2516
+ proc = task;
2517
+ answer = {};
2518
+ }
2519
+ else {
2520
+ // @ts-ignore
2521
+ proc = task.proc;
2522
+ answer = task;
2523
+ // @ts-ignore
2524
+ delete task.proc;
2525
+ }
2526
+ let description = '', procedure, verification, title, summaryFailed, success, reviewFailed, prerequisites;
2527
+ if (proc) {
2528
+ const taskDOM = document.createElement('div');
2529
+ taskDOM.innerHTML = proc;
2530
+ // remove the screencapture images
2531
+ taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
2532
+ var _a;
2533
+ (_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(node);
2534
+ });
2535
+ title = (_a = taskDOM
2536
+ .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();
2537
+ let sectionBody = taskDOM.querySelector('.sectionbody');
2538
+ if (!(sectionBody === null || sectionBody === void 0 ? void 0 : sectionBody.hasChildNodes())) {
2539
+ // possibly in other templates, where we want to look for article
2540
+ sectionBody = taskDOM.querySelector('article');
2541
+ }
2542
+ if (sectionBody) {
2543
+ for (let i = 0; i < sectionBody.children.length || 0; i++) {
2544
+ /**
2545
+ child typically looks like:
2546
+
2547
+ <div class="paragraph|olist|ulist|admonitionblock">
2548
+ <div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
2549
+ <ol|ul class="arabic">
2550
+ <li>
2551
+ <li>...
2552
+ </ol|ul>
2553
+ </div>
2554
+
2555
+ And the below code extracts the <ol> or <ul>
2556
+ Except for when there is no <div class="title|heading"/>, then the description is extracted
2557
+ in the else if below
2558
+ */
2559
+ const child = sectionBody.children.item(i);
2560
+ // find the title
2561
+ const sectionTitle = child === null || child === void 0 ? void 0 : child.querySelector('.heading,.title');
2562
+ // should this section be assigned to a specific section
2563
+ const sectionTitleText = (_b = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _b === void 0 ? void 0 : _b.trim();
2564
+ const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes((_c = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim());
2565
+ if (isKnownSection) {
2566
+ switch (sectionTitleText) {
2567
+ case 'Procedure':
2568
+ procedure = (_d = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _d === void 0 ? void 0 : _d.outerHTML.trim();
2569
+ break;
2570
+ case 'Verification':
2571
+ verification = (_e = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _e === void 0 ? void 0 : _e.outerHTML.trim();
2572
+ break;
2573
+ case 'Prerequisites':
2574
+ prerequisites = (_f = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _f === void 0 ? void 0 : _f.outerHTML.trim();
2575
+ break;
2576
+ }
2577
+ }
2578
+ else if (!procedure) {
2579
+ // Otherwise if it comes before a procedure it's part of the description
2580
+ description = description + (child === null || child === void 0 ? void 0 : child.outerHTML.trim());
2581
+ }
2582
+ }
2583
+ }
2584
+ success = (_g = taskDOM.querySelector('.qs-summary.success')) === null || _g === void 0 ? void 0 : _g.innerHTML.trim();
2585
+ reviewFailed = (_h = taskDOM.querySelector('.qs-review.failed')) === null || _h === void 0 ? void 0 : _h.innerHTML.trim();
2586
+ summaryFailed = (_j = taskDOM.querySelector('.qs-summary.failed')) === null || _j === void 0 ? void 0 : _j.innerHTML.trim();
2587
+ }
2588
+ answer.title = replaceEnvironmentVariables(answer.title || title);
2589
+ answer.description = replaceEnvironmentVariables(answer.description || `${description} ${prerequisites || ''} ${procedure}`);
2590
+ answer.review = answer.review || {};
2591
+ answer.review.instructions = replaceEnvironmentVariables(((_k = answer.review) === null || _k === void 0 ? void 0 : _k.instructions) || verification || 'Have you completed these steps?');
2592
+ answer.review.failedTaskHelp = replaceEnvironmentVariables(answer.review.failedTaskHelp ||
2593
+ reviewFailed ||
2594
+ 'This task isn’t verified yet. Try the task again.');
2595
+ answer.summary = answer.summary || {};
2596
+ answer.summary.success = replaceEnvironmentVariables(answer.summary.success || success || 'You have completed this task!');
2597
+ answer.summary.failed = replaceEnvironmentVariables(answer.summary.failed || summaryFailed || 'Try the steps again.');
2598
+ return answer;
2599
+ });
2600
+ return quickStart;
2601
+ };
2602
+
2483
2603
  exports.Box = Box;
2484
2604
  exports.CamelCaseWrap = CamelCaseWrap;
2485
2605
  exports.EmptyBox = EmptyBox;
@@ -2490,6 +2610,7 @@ exports.HelpTopicContextDefaults = HelpTopicContextDefaults;
2490
2610
  exports.HelpTopicDrawer = HelpTopicDrawer;
2491
2611
  exports.Loading = Loading;
2492
2612
  exports.LoadingBox = LoadingBox;
2613
+ exports.ProcQuickStartParser = ProcQuickStartParser;
2493
2614
  exports.QUICKSTART_ID_FILTER_KEY = QUICKSTART_ID_FILTER_KEY;
2494
2615
  exports.QUICKSTART_SEARCH_FILTER_KEY = QUICKSTART_SEARCH_FILTER_KEY;
2495
2616
  exports.QUICKSTART_STATUS_FILTER_KEY = QUICKSTART_STATUS_FILTER_KEY;