@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/README.md CHANGED
@@ -262,12 +262,21 @@ The quickstarts package is being extended to support a side panel that displays
262
262
  ### Help Topic type definition
263
263
 
264
264
  ```ts
265
+ type HelpTopicLink = {
266
+ href: string;
267
+ text?: string;
268
+ // open link in new tab
269
+ newTab?: boolean;
270
+ // add PF icon indicating link is external
271
+ isExternal?: boolean;
272
+ };
273
+
265
274
  type HelpTopic = {
266
- name: string; // unique identifier
267
- title: string; // displayed in header of side panel
268
- tags: string[]; // metadata to filter/add relationships between HelpTopics and some piece of data in your application
269
- content: string; // main content of topic, supports markdown
270
- links: string[]; // list of related information, use markdown link syntax
275
+ name: string;
276
+ title: string;
277
+ tags: string[];
278
+ content: string;
279
+ links: HelpTopicLink[];
271
280
  };
272
281
  ```
273
282
 
@@ -283,21 +292,12 @@ type HelpTopic = {
283
292
 
284
293
  Etiam viverra et tortor et maximus. Aliquam quis scelerisque metus. Proin luctus pretium sodales. Mauris nibh nibh, auctor eu scelerisque et, hendrerit a metus. Vivamus pharetra bibendum finibus. Sed a pulvinar ipsum. Fusce pharetra venenatis porttitor. Praesent justo metus, consectetur quis erat id, congue varius metus. Suspendisse dui est, tempor nec diam quis, facilisis sodales erat. Curabitur viverra convallis ex. Ut egestas condimentum augue, id euismod leo volutpat vitae. Quisque aliquet ac dolor quis pretium. Nunc at nibh quis arcu maximus elementum vel a mi.
285
294
  links:
286
- - '[Creating quick starts](https://docs.openshift.com/container-platform/4.9/web_console/creating-quick-start-tutorials.html)'
287
- - '[Redhat Console](https://console.redhat.com/)'
288
- - name: workspace
289
- tags:
290
- - page-1
291
- - page-2
292
- - page-3
293
- title: Workspace
294
- content: |-
295
- **A Workspace** is...
296
-
297
- Fusce nunc risus, vehicula feugiat pellentesque sit amet, pretium non urna. Phasellus nibh mi, ornare quis euismod a, iaculis et eros. Vivamus auctor nunc odio, quis porttitor diam pellentesque nec. In et varius tellus, eget porta urna. Etiam bibendum, est eget mollis lobortis, velit risus efficitur lacus, sed pulvinar sem est vel libero. In sodales placerat tincidunt. Proin vitae risus elit. Ut lobortis ligula est, cursus rhoncus enim scelerisque ac. Donec lacus nisl, tempor porta hendrerit nec, volutpat vitae arcu. Curabitur ornare ullamcorper mi in tincidunt. Aenean efficitur posuere auctor. Pellentesque accumsan mauris vel arcu congue, nec sagittis nisl condimentum. Suspendisse mauris nulla, dignissim at viverra sed, fringilla eu purus.
298
- links:
299
- - '[Creating quick starts](https://docs.openshift.com/container-platform/4.9/web_console/creating-quick-start-tutorials.html)'
300
- - '[Redhat Console](https://console.redhat.com/)'
295
+ - text: 'Creating quick starts (external)'
296
+ href: 'https://docs.openshift.com/container-platform/4.9/web_console/creating-quick-start-tutorials.html'
297
+ isExternal: true
298
+ - text: 'Redhat Console (opens in new tab)'
299
+ href: 'https://console.redhat.com'
300
+ newTab: true
301
301
  ```
302
302
 
303
303
  ### Usage Example
@@ -308,7 +308,7 @@ See the [HelpTopicDemo](https://github.com/patternfly/patternfly-quickstarts/blo
308
308
  - Load yaml defined `HelpTopic` array
309
309
  - Pass `HelpTopicContainerProps`, including loaded `HelpTopics` to the `<HelpTopicContainer/>`
310
310
 
311
- ```ts
311
+ ```tsx
312
312
  import './App.css';
313
313
  import { Page } from '@patternfly/react-core';
314
314
  import { LoadingBox, HelpTopicContainerProps, HelpTopicContainer } from '@patternfly/quickstarts';
@@ -359,7 +359,7 @@ In the example above `<HelpTopicContainer />` wraps the `<Page/>` element as wel
359
359
 
360
360
  Live [preview](https://deploy-preview-140--quickstarts.netlify.app/in-context-help) of code below:
361
361
 
362
- ```ts
362
+ ```tsx
363
363
  import * as React from 'react';
364
364
  import {
365
365
  Banner,
@@ -0,0 +1,7 @@
1
+ import './showdown-extension.scss';
2
+ declare const useCodeShowdownExtension: () => {
3
+ type: string;
4
+ regex: RegExp;
5
+ replace: (text: string, content: string) => string;
6
+ };
7
+ export default useCodeShowdownExtension;
@@ -2,3 +2,4 @@ export { default as MarkdownCopyClipboard } from './MarkdownCopyClipboard';
2
2
  export { default as useInlineCopyClipboardShowdownExtension } from './inline-clipboard-extension';
3
3
  export { default as useMultilineCopyClipboardShowdownExtension } from './multiline-clipboard-extension';
4
4
  export { default as useAdmonitionShowdownExtension } from './admonition-extension';
5
+ export { default as useCodeShowdownExtension } from './code-extension';
@@ -5,6 +5,7 @@ declare type HelpTopicPanelContentProps = {
5
5
  activeHelpTopic: HelpTopic;
6
6
  filteredHelpTopics?: HelpTopic[];
7
7
  isResizable?: boolean;
8
+ onClose: () => void;
8
9
  };
9
10
  declare const HelpTopicPanelContent: React.FC<HelpTopicPanelContentProps>;
10
11
  export default HelpTopicPanelContent;
package/dist/index.d.ts CHANGED
@@ -11,5 +11,6 @@ export * from './utils/help-topic-context';
11
11
  export * from './utils/help-topic-types';
12
12
  export * from './utils/quick-start-utils';
13
13
  export * from './utils/useLocalStorage';
14
+ export * from './utils/asciidoc-procedure-parser';
14
15
  export { default as QuickStartPanelContent } from './QuickStartPanelContent';
15
16
  export { default as QuickStartCloseModal } from './QuickStartCloseModal';
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { createContext, useCallback, useEffect, useState } from 'react';
3
- import { Card, CardHeader, CardActions, CardTitle, CardBody, CardFooter, Modal as Modal$1, Tooltip, Alert, Popover, PopoverPosition, Button, Text, TextVariants, TextList, TextListItem, Flex, FlexItem, Title, Label, Gallery, GalleryItem, ToolbarItem, SearchInput, Select, SelectVariant, SelectOption, Toolbar, ToolbarContent, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStatePrimary, Divider, ModalVariant, WizardNavItem, List, ExpandableSection, ListItem, Radio, DrawerPanelContent, DrawerHead, DrawerActions, DrawerCloseButton, DrawerPanelBody, Drawer, DrawerContent, DrawerContentBody, OptionsMenuItem, OptionsMenu, OptionsMenuToggle, Stack, StackItem } from '@patternfly/react-core';
3
+ import { Card, CardHeader, CardActions, CardTitle, CardBody, CardFooter, Modal as Modal$1, Tooltip, Alert, CodeBlock, Popover, PopoverPosition, Button, Text, TextVariants, TextList, TextListItem, Flex, FlexItem, Title, Label, Gallery, GalleryItem, ToolbarItem, SearchInput, Select, SelectVariant, SelectOption, Toolbar, ToolbarContent, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStatePrimary, Divider, ModalVariant, WizardNavItem, List, ExpandableSection, ListItem, Radio, DrawerPanelContent, DrawerHead, DrawerActions, DrawerCloseButton, DrawerPanelBody, Drawer, DrawerContent, DrawerContentBody, OptionsMenuItem, Stack, StackItem, OptionsMenu, OptionsMenuToggle } from '@patternfly/react-core';
4
4
  import SearchIcon from '@patternfly/react-icons/dist/js/icons/search-icon';
5
5
  import { css } from '@patternfly/react-styles';
6
6
  import RocketIcon from '@patternfly/react-icons/dist/js/icons/rocket-icon';
@@ -1315,6 +1315,20 @@ const useAdmonitionShowdownExtension = () => {
1315
1315
  }), []);
1316
1316
  };
1317
1317
 
1318
+ const useCodeShowdownExtension = () => {
1319
+ return React.useMemo(() => ({
1320
+ type: 'output',
1321
+ regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
1322
+ replace: (text, content) => {
1323
+ if (!content) {
1324
+ return text;
1325
+ }
1326
+ const pfCodeBlock = React.createElement(CodeBlock, null, content);
1327
+ return removeTemplateWhitespace(renderToStaticMarkup(pfCodeBlock));
1328
+ },
1329
+ }), []);
1330
+ };
1331
+
1318
1332
  const FallbackImg = ({ src, alt, className, fallback }) => {
1319
1333
  const [isSrcValid, setIsSrcValid] = React.useState(true);
1320
1334
  if (src && isSrcValid) {
@@ -1555,6 +1569,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1555
1569
  const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
1556
1570
  const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1557
1571
  const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1572
+ const codeShowdownExtension = useCodeShowdownExtension();
1558
1573
  return (React.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1559
1574
  {
1560
1575
  type: 'lang',
@@ -1577,6 +1592,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1577
1592
  inlineCopyClipboardShowdownExtension,
1578
1593
  multilineCopyClipboardShowdownExtension,
1579
1594
  admonitionShowdownExtension,
1595
+ codeShowdownExtension,
1580
1596
  ...(markdown ? markdown.extensions : []),
1581
1597
  ], renderExtension: (docContext, rootSelector) => (React.createElement(React.Fragment, null,
1582
1598
  React.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
@@ -1696,7 +1712,7 @@ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, })
1696
1712
 
1697
1713
  const QuickStartCatalog = ({ quickStarts }) => {
1698
1714
  const { activeQuickStartID, allQuickStartStates } = React.useContext(QuickStartContext);
1699
- return (React.createElement("div", { className: "pfext-page-layout__content pfext-is-dark" },
1715
+ return (React.createElement("div", { className: "pfext-page-layout__content" },
1700
1716
  React.createElement(Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
1701
1717
  const { metadata: { name: id }, } = quickStart;
1702
1718
  return (React.createElement(GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
@@ -1901,7 +1917,7 @@ const QuickStartCatalogHeader = ({ title, hint, }) => (React.createElement("div"
1901
1917
  React.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
1902
1918
  hint && React.createElement("div", { className: "pfext-page-layout__hint" }, hint)));
1903
1919
 
1904
- const QuickStartCatalogSection = ({ children }) => (React.createElement("div", { className: "pfext-page-layout__content pfext-is-dark" }, children));
1920
+ const QuickStartCatalogSection = ({ children }) => (React.createElement("div", { className: "pfext-page-layout__content" }, children));
1905
1921
 
1906
1922
  const QuickStartCatalogToolbar = ({ children }) => (React.createElement(Toolbar, { usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, children));
1907
1923
 
@@ -2298,6 +2314,7 @@ const QuickStartDrawer = (_a) => {
2298
2314
 
2299
2315
  const HelpTopicContextDefaults = {
2300
2316
  helpTopics: [],
2317
+ setHelpTopics: () => { },
2301
2318
  activeHelpTopic: null,
2302
2319
  setActiveHelpTopicByName: () => { },
2303
2320
  filteredHelpTopics: [],
@@ -2324,6 +2341,7 @@ const useValuesForHelpTopicContext = (value = {}) => {
2324
2341
  const [filteredHelpTopics, setFilteredHelpTopics] = React__default.useState(combinedValue.filteredHelpTopics || []);
2325
2342
  return {
2326
2343
  helpTopics,
2344
+ setHelpTopics,
2327
2345
  activeHelpTopic,
2328
2346
  setActiveHelpTopicByName,
2329
2347
  filteredHelpTopics,
@@ -2334,7 +2352,8 @@ const useValuesForHelpTopicContext = (value = {}) => {
2334
2352
  };
2335
2353
 
2336
2354
  const HelpTopicPanelContent = (_a) => {
2337
- var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true } = _a, props = __rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable"]);
2355
+ var _b, _c;
2356
+ var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = __rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
2338
2357
  const { setActiveHelpTopicByName } = React.useContext(HelpTopicContext);
2339
2358
  const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React.useState(false);
2340
2359
  const toggleHelpTopicMenu = () => {
@@ -2345,24 +2364,28 @@ const HelpTopicPanelContent = (_a) => {
2345
2364
  setActiveHelpTopicByName(topicName);
2346
2365
  toggleHelpTopicMenu();
2347
2366
  };
2348
- const menuItems = filteredHelpTopics.map((topic) => {
2349
- return (React.createElement(OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2350
- });
2367
+ const menuItems = filteredHelpTopics.length > 0 &&
2368
+ filteredHelpTopics.map((topic) => {
2369
+ return (React.createElement(OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2370
+ });
2371
+ const paddingContainer = (children) => React.createElement("div", { style: { padding: '24px' } }, children);
2372
+ const panelBodyItems = (React.createElement(React.Fragment, null,
2373
+ paddingContainer(React.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2374
+ ((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React.createElement(Divider, null),
2375
+ paddingContainer(React.createElement(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) => {
2376
+ return (React.createElement(StackItem, { key: index },
2377
+ React.createElement(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.createElement(ExternalLinkAltIcon, null) : null, iconPosition: "right", style: { fontSize: 'inherit' } }, text || href)));
2378
+ })))));
2351
2379
  const content = (React.createElement(DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
2352
2380
  React.createElement("div", null,
2353
2381
  React.createElement(DrawerHead, null,
2354
2382
  React.createElement("div", { className: "pfext-quick-start-panel-content__title" },
2355
- React.createElement(OptionsMenu, { id: 'helptopics', isPlain: true, isOpen: isHelpTopicMenuOpen, toggle: React.createElement(OptionsMenuToggle, { onToggle: toggleHelpTopicMenu, toggleTemplate: React.createElement(BarsIcon, null) }), menuItems: menuItems }),
2356
- React.createElement(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))),
2383
+ menuItems && (React.createElement(OptionsMenu, { id: 'helptopics', isPlain: true, isOpen: isHelpTopicMenuOpen, toggle: React.createElement(OptionsMenuToggle, { style: { paddingLeft: '0px' }, onToggle: toggleHelpTopicMenu, toggleTemplate: React.createElement(BarsIcon, null) }), menuItems: menuItems })),
2384
+ React.createElement(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)),
2385
+ React.createElement(DrawerActions, null,
2386
+ React.createElement(DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
2357
2387
  React.createElement(Divider, null),
2358
- React.createElement(DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
2359
- React.createElement(Stack, { hasGutter: true },
2360
- React.createElement(StackItem, { style: { padding: '20px' } },
2361
- React.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2362
- React.createElement(Divider, null),
2363
- React.createElement(StackItem, { style: { padding: '20px' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links.map((link) => {
2364
- return React.createElement(QuickStartMarkdownView, { key: link, content: link });
2365
- })))))));
2388
+ React.createElement(DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
2366
2389
  return content;
2367
2390
  };
2368
2391
 
@@ -2376,26 +2399,23 @@ const HelpTopicContainer = (_a) => {
2376
2399
  valuesForHelpTopicContext.setLoading(loading);
2377
2400
  }
2378
2401
  }, [loading, valuesForHelpTopicContext]);
2402
+ React.useEffect(() => {
2403
+ if (helpTopics &&
2404
+ JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
2405
+ valuesForHelpTopicContext.setHelpTopics(helpTopics);
2406
+ }
2407
+ }, [helpTopics, valuesForHelpTopicContext]);
2379
2408
  const drawerProps = Object.assign({}, props);
2380
2409
  return (React.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
2381
2410
  React.createElement(HelpTopicDrawer, Object.assign({}, drawerProps), children)));
2382
2411
  };
2383
2412
  const HelpTopicDrawer = (_a) => {
2384
- var {
2385
- // helpTopics,
2386
- children } = _a, props = __rest(_a, ["children"]);
2387
- const { activeHelpTopic, filteredHelpTopics } = React.useContext(HelpTopicContext);
2388
- // Leave here if query param is desired for help topics later
2389
- // React.useEffect(() => {
2390
- // const params = new URLSearchParams(window.location.search);
2391
- // // if there is a quick start param, but the quick start is not active, set it
2392
- // // this can happen if a new browser session is opened or an incognito window for example
2393
- // const helpTopicNameFromParam = params.get(HELP_TOPIC_NAME_KEY) || '';
2394
- // if (helpTopicNameFromParam) {
2395
- // setActiveHelpTopicByName(helpTopicNameFromParam);
2396
- // }
2397
- // }, [inContextHelpTopics, setActiveHelpTopicByName]);
2398
- const panelContent = (React.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics }));
2413
+ var { children } = _a, props = __rest(_a, ["children"]);
2414
+ const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React.useContext(HelpTopicContext);
2415
+ const onClose = () => {
2416
+ setActiveHelpTopicByName('');
2417
+ };
2418
+ const panelContent = (React.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
2399
2419
  return (React.createElement(React.Fragment, null,
2400
2420
  React.createElement(Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React.createElement(DrawerContent, { panelContent: panelContent },
2401
2421
  React.createElement(DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React.createElement("div", { className: "pf-c-drawer__main" }, panelContent)))));
@@ -2438,5 +2458,105 @@ const useLocalStorage = (key, initialValue) => {
2438
2458
  return [storedValue, setValue];
2439
2459
  };
2440
2460
 
2441
- export { Box, CamelCaseWrap, EmptyBox, HELP_TOPIC_NAME_KEY, HelpTopicContainer, HelpTopicContext, HelpTopicContextDefaults, HelpTopicDrawer, Loading, LoadingBox, QUICKSTART_ID_FILTER_KEY, QUICKSTART_SEARCH_FILTER_KEY, QUICKSTART_STATUS_FILTER_KEY, QUICKSTART_TASKS_INITIAL_STATES, QUICK_START_NAME, QuickStartCatalog, QuickStartCatalogEmptyState, QuickStartCatalogFilter, QuickStartCatalogFilterCount, QuickStartCatalogFilterCountWrapper, QuickStartCatalogFilterSearch, QuickStartCatalogFilterSearchWrapper, QuickStartCatalogFilterSelect, QuickStartCatalogFilterStatusWrapper, QuickStartCatalogHeader, QuickStartCatalogPage, QuickStartCatalogSection, QuickStartCatalogToolbar, QuickStartCloseModal, QuickStartContainer, QuickStartContext, QuickStartContextDefaults, QuickStartContextProvider, QuickStartDrawer, QuickStartPanelContent, QuickStartStatus, QuickStartTaskStatus, QuickStartTile, QuickStartTileDescription, QuickStartTileFooter, QuickStartTileFooterExternal, QuickStartTileHeader, camelize, clearFilterParams, equalsIgnoreOrder, filterQuickStarts, getDefaultQuickStartState, getDisabledQuickStarts, getQuickStartByName, getQuickStartStatus, getQuickStartStatusCount, getResource, getTaskStatusKey, history, isDisabledQuickStart, removeQueryArgument, setQueryArgument, useLocalStorage, useValuesForHelpTopicContext, useValuesForQuickStartContext };
2461
+ /* eslint-disable */
2462
+ // Brought in from dev to publish this with QS module
2463
+ // Dev now imports from here
2464
+ const ProcQuickStartParser = (quickStart, environmentVariables) => {
2465
+ var _a;
2466
+ const replaceEnvironmentVariables = (s) => s === null || s === void 0 ? void 0 : s.replace(/\${(\w+)}/, (substring, name) => {
2467
+ return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
2468
+ });
2469
+ quickStart.spec.tasks = (_a = quickStart.spec.tasks) === null || _a === void 0 ? void 0 : _a.map((task, index) => {
2470
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2471
+ let proc;
2472
+ let answer;
2473
+ if (typeof task === 'string') {
2474
+ proc = task;
2475
+ answer = {};
2476
+ }
2477
+ else {
2478
+ // @ts-ignore
2479
+ proc = task.proc;
2480
+ answer = task;
2481
+ // @ts-ignore
2482
+ delete task.proc;
2483
+ }
2484
+ let description = '', procedure, verification, title, summaryFailed, success, reviewFailed, prerequisites;
2485
+ if (proc) {
2486
+ const taskDOM = document.createElement('div');
2487
+ taskDOM.innerHTML = proc;
2488
+ // remove the screencapture images
2489
+ taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
2490
+ var _a;
2491
+ (_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(node);
2492
+ });
2493
+ title = (_a = taskDOM
2494
+ .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();
2495
+ let sectionBody = taskDOM.querySelector('.sectionbody');
2496
+ if (!(sectionBody === null || sectionBody === void 0 ? void 0 : sectionBody.hasChildNodes())) {
2497
+ // possibly in other templates, where we want to look for article
2498
+ sectionBody = taskDOM.querySelector('article');
2499
+ }
2500
+ if (sectionBody) {
2501
+ for (let i = 0; i < sectionBody.children.length || 0; i++) {
2502
+ /**
2503
+ child typically looks like:
2504
+
2505
+ <div class="paragraph|olist|ulist|admonitionblock">
2506
+ <div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
2507
+ <ol|ul class="arabic">
2508
+ <li>
2509
+ <li>...
2510
+ </ol|ul>
2511
+ </div>
2512
+
2513
+ And the below code extracts the <ol> or <ul>
2514
+ Except for when there is no <div class="title|heading"/>, then the description is extracted
2515
+ in the else if below
2516
+ */
2517
+ const child = sectionBody.children.item(i);
2518
+ // find the title
2519
+ const sectionTitle = child === null || child === void 0 ? void 0 : child.querySelector('.heading,.title');
2520
+ // should this section be assigned to a specific section
2521
+ const sectionTitleText = (_b = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _b === void 0 ? void 0 : _b.trim();
2522
+ const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes((_c = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim());
2523
+ if (isKnownSection) {
2524
+ switch (sectionTitleText) {
2525
+ case 'Procedure':
2526
+ procedure = (_d = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _d === void 0 ? void 0 : _d.outerHTML.trim();
2527
+ break;
2528
+ case 'Verification':
2529
+ verification = (_e = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _e === void 0 ? void 0 : _e.outerHTML.trim();
2530
+ break;
2531
+ case 'Prerequisites':
2532
+ prerequisites = (_f = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _f === void 0 ? void 0 : _f.outerHTML.trim();
2533
+ break;
2534
+ }
2535
+ }
2536
+ else if (!procedure) {
2537
+ // Otherwise if it comes before a procedure it's part of the description
2538
+ description = description + (child === null || child === void 0 ? void 0 : child.outerHTML.trim());
2539
+ }
2540
+ }
2541
+ }
2542
+ success = (_g = taskDOM.querySelector('.qs-summary.success')) === null || _g === void 0 ? void 0 : _g.innerHTML.trim();
2543
+ reviewFailed = (_h = taskDOM.querySelector('.qs-review.failed')) === null || _h === void 0 ? void 0 : _h.innerHTML.trim();
2544
+ summaryFailed = (_j = taskDOM.querySelector('.qs-summary.failed')) === null || _j === void 0 ? void 0 : _j.innerHTML.trim();
2545
+ }
2546
+ answer.title = replaceEnvironmentVariables(answer.title || title);
2547
+ answer.description = replaceEnvironmentVariables(answer.description || `${description} ${prerequisites || ''} ${procedure}`);
2548
+ answer.review = answer.review || {};
2549
+ answer.review.instructions = replaceEnvironmentVariables(((_k = answer.review) === null || _k === void 0 ? void 0 : _k.instructions) || verification || 'Have you completed these steps?');
2550
+ answer.review.failedTaskHelp = replaceEnvironmentVariables(answer.review.failedTaskHelp ||
2551
+ reviewFailed ||
2552
+ 'This task isn’t verified yet. Try the task again.');
2553
+ answer.summary = answer.summary || {};
2554
+ answer.summary.success = replaceEnvironmentVariables(answer.summary.success || success || 'You have completed this task!');
2555
+ answer.summary.failed = replaceEnvironmentVariables(answer.summary.failed || summaryFailed || 'Try the steps again.');
2556
+ return answer;
2557
+ });
2558
+ return quickStart;
2559
+ };
2560
+
2561
+ export { Box, CamelCaseWrap, EmptyBox, HELP_TOPIC_NAME_KEY, HelpTopicContainer, HelpTopicContext, HelpTopicContextDefaults, HelpTopicDrawer, Loading, LoadingBox, ProcQuickStartParser, QUICKSTART_ID_FILTER_KEY, QUICKSTART_SEARCH_FILTER_KEY, QUICKSTART_STATUS_FILTER_KEY, QUICKSTART_TASKS_INITIAL_STATES, QUICK_START_NAME, QuickStartCatalog, QuickStartCatalogEmptyState, QuickStartCatalogFilter, QuickStartCatalogFilterCount, QuickStartCatalogFilterCountWrapper, QuickStartCatalogFilterSearch, QuickStartCatalogFilterSearchWrapper, QuickStartCatalogFilterSelect, QuickStartCatalogFilterStatusWrapper, QuickStartCatalogHeader, QuickStartCatalogPage, QuickStartCatalogSection, QuickStartCatalogToolbar, QuickStartCloseModal, QuickStartContainer, QuickStartContext, QuickStartContextDefaults, QuickStartContextProvider, QuickStartDrawer, QuickStartPanelContent, QuickStartStatus, QuickStartTaskStatus, QuickStartTile, QuickStartTileDescription, QuickStartTileFooter, QuickStartTileFooterExternal, QuickStartTileHeader, camelize, clearFilterParams, equalsIgnoreOrder, filterQuickStarts, getDefaultQuickStartState, getDisabledQuickStarts, getQuickStartByName, getQuickStartStatus, getQuickStartStatusCount, getResource, getTaskStatusKey, history, isDisabledQuickStart, removeQueryArgument, setQueryArgument, useLocalStorage, useValuesForHelpTopicContext, useValuesForQuickStartContext };
2442
2562
  //# sourceMappingURL=index.es.js.map