@patternfly/quickstarts 2.3.3 → 2.3.4

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 (32) hide show
  1. package/dist/ConsoleInternal/components/markdown-view.d.ts +1 -1
  2. package/dist/ConsoleShared/src/components/markdown-extensions/accordion-extension.d.ts +7 -0
  3. package/dist/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.d.ts +6 -0
  4. package/dist/ConsoleShared/src/components/markdown-extensions/const.d.ts +2 -0
  5. package/dist/ConsoleShared/src/components/markdown-extensions/index.d.ts +2 -0
  6. package/dist/index.es.js +101 -28
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/index.js +99 -26
  9. package/dist/index.js.map +1 -1
  10. package/dist/patternfly-docs/quick-starts/design-guidelines/design-guidelines.md +1 -1
  11. package/dist/patternfly-docs/quick-starts/examples/about.md +28 -21
  12. package/dist/patternfly-docs/quick-starts/examples/basic.md +7 -5
  13. package/dist/patternfly-docs/quick-starts/examples/help-topics.md +8 -5
  14. package/dist/patternfly-nested.css +209 -1
  15. package/dist/quickstarts-base.css +49 -49
  16. package/dist/quickstarts-full.es.js +2928 -4373
  17. package/dist/quickstarts-full.es.js.map +1 -1
  18. package/dist/quickstarts-standalone.css +6 -0
  19. package/dist/quickstarts-standalone.min.css +2 -2
  20. package/dist/quickstarts.css +49 -49
  21. package/dist/quickstarts.min.css +1 -1
  22. package/package.json +8 -5
  23. package/src/ConsoleInternal/components/markdown-view.tsx +34 -50
  24. package/src/ConsoleShared/src/components/markdown-extensions/accordion-extension.tsx +52 -0
  25. package/src/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.tsx +60 -0
  26. package/src/ConsoleShared/src/components/markdown-extensions/const.ts +2 -0
  27. package/src/ConsoleShared/src/components/markdown-extensions/index.ts +2 -0
  28. package/src/HelpTopicPanelContent.tsx +1 -1
  29. package/src/QuickStartMarkdownView.tsx +5 -0
  30. package/src/QuickStartPanelContent.tsx +11 -2
  31. package/src/controller/QuickStartTaskHeader.tsx +12 -1
  32. package/src/declaration.d.ts +1 -0
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var server = require('react-dom/server');
13
13
  var CopyIcon = require('@patternfly/react-icons/dist/js/icons/copy-icon');
14
14
  var LightbulbIcon = require('@patternfly/react-icons/dist/js/icons/lightbulb-icon');
15
15
  var FireIcon = require('@patternfly/react-icons/dist/js/icons/fire-icon');
16
- var showdown = require('showdown');
16
+ var marked = require('marked');
17
17
  var SyncAltIcon = require('@patternfly/react-icons/dist/js/icons/sync-alt-icon');
18
18
  var CheckCircleIcon = require('@patternfly/react-icons/dist/js/icons/check-circle-icon');
19
19
  var ExclamationCircleIcon = require('@patternfly/react-icons/dist/js/icons/exclamation-circle-icon');
@@ -1237,7 +1237,9 @@ const MarkdownHighlightExtension = ({ docContext, rootSelector, }) => {
1237
1237
  };
1238
1238
 
1239
1239
  const MARKDOWN_COPY_BUTTON_ID = 'data-copy-for';
1240
- const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
1240
+ const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
1241
+ const ACCORDION_MARKDOWN_BUTTON_ID = `accordion-markdown-button-id`;
1242
+ const ACCORDION_MARKDOWN_CONTENT_ID = `accordion-markdown-content-id`;
1241
1243
 
1242
1244
  const CopyClipboard = ({ element, rootSelector, docContext, }) => {
1243
1245
  const { getResource } = React__namespace.useContext(QuickStartContext);
@@ -1327,16 +1329,7 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1327
1329
 
1328
1330
  // eslint-disable-next-line @typescript-eslint/no-require-imports
1329
1331
  const DOMPurify = require('dompurify');
1330
- const markdownConvert = (markdown, extensions) => {
1331
- const converter = new showdown.Converter({
1332
- tables: true,
1333
- openLinksInNewWindow: true,
1334
- strikethrough: true,
1335
- emoji: false,
1336
- });
1337
- if (extensions) {
1338
- converter.addExtension(extensions);
1339
- }
1332
+ const markdownConvert = (markdown, extensions) => tslib.__awaiter(void 0, void 0, void 0, function* () {
1340
1333
  DOMPurify.addHook('beforeSanitizeElements', function (node) {
1341
1334
  // nodeType 1 = element type
1342
1335
  // transform anchor tags
@@ -1363,20 +1356,38 @@ const markdownConvert = (markdown, extensions) => {
1363
1356
  node.setAttribute('xlink:show', 'new');
1364
1357
  }
1365
1358
  });
1366
- return DOMPurify.sanitize(converter.makeHtml(markdown), {
1367
- USE_PROFILES: {
1368
- html: true,
1369
- svg: true,
1370
- },
1371
- });
1372
- };
1359
+ // Replace code fences with non markdown formatting relates tokens so that marked doesn't try to parse them as code spans
1360
+ const markdownWithSubstitutedCodeFences = markdown.replace(/```/g, '@@@');
1361
+ const parsedMarkdown = yield marked.marked.parse(markdownWithSubstitutedCodeFences);
1362
+ // Swap the temporary tokens back to code fences before we run the extensions
1363
+ let md = parsedMarkdown.replace(/@@@/g, '```');
1364
+ if (extensions) {
1365
+ // Convert code spans back to md format before we run the custom extension regexes
1366
+ md = md.replace(/<code>(.*)<\/code>/g, '`$1`');
1367
+ extensions.forEach(({ regex, replace }) => {
1368
+ if (regex) {
1369
+ md = md.replace(regex, replace);
1370
+ }
1371
+ });
1372
+ // Convert any remaining backticks back into code spans
1373
+ md = md.replace(/`(.*)`/g, '<code>$1</code>');
1374
+ }
1375
+ return DOMPurify.sanitize(md);
1376
+ });
1373
1377
  const SyncMarkdownView = ({
1374
1378
  // truncateContent,
1375
1379
  content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
1376
1380
  const { getResource } = React__namespace.useContext(QuickStartContext);
1377
- const markup = React__namespace.useMemo(() => {
1378
- return markdownConvert(content || emptyMsg || getResource('Not available'), extensions);
1379
- }, [content, emptyMsg, extensions, getResource]);
1381
+ const [markup, setMarkup] = React__namespace.useState('');
1382
+ React__namespace.useEffect(() => {
1383
+ function getMd() {
1384
+ return tslib.__awaiter(this, void 0, void 0, function* () {
1385
+ const md = yield markdownConvert(content || emptyMsg || getResource('Not available'), extensions);
1386
+ setMarkup(md);
1387
+ });
1388
+ }
1389
+ getMd();
1390
+ }, [content, emptyMsg, getResource, extensions]);
1380
1391
  const innerProps = {
1381
1392
  renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
1382
1393
  exactHeight,
@@ -1501,6 +1512,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1501
1512
  const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1502
1513
  const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1503
1514
  const codeShowdownExtension = useCodeShowdownExtension();
1515
+ const accordionShowdownExtension = useAccordionShowdownExtension();
1504
1516
  return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1505
1517
  {
1506
1518
  type: 'lang',
@@ -1524,8 +1536,10 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1524
1536
  multilineCopyClipboardShowdownExtension,
1525
1537
  admonitionShowdownExtension,
1526
1538
  codeShowdownExtension,
1539
+ accordionShowdownExtension,
1527
1540
  ...(markdown ? markdown.extensions : []),
1528
1541
  ], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
1542
+ React__namespace.createElement(AccordionRenderExtension, { docContext: docContext }),
1529
1543
  React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
1530
1544
  React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
1531
1545
  markdown &&
@@ -1581,6 +1595,45 @@ const useCodeShowdownExtension = () => {
1581
1595
  }), []);
1582
1596
  };
1583
1597
 
1598
+ const useAccordionShowdownExtension = () => {
1599
+ return React__namespace.useMemo(() => ({
1600
+ type: 'lang',
1601
+ regex: /\[(.+)]{{(accordion) ("(.*?)")}}/g,
1602
+ replace: (_text, accordionContent, _command, accordionHeading) => {
1603
+ const accordionId = new String(accordionHeading).replace(/\s/g, '-');
1604
+ return removeTemplateWhitespace(server.renderToStaticMarkup(React__namespace.createElement(reactCore.Accordion, { asDefinitionList: true },
1605
+ React__namespace.createElement(reactCore.AccordionItem, null,
1606
+ React__namespace.createElement(reactCore.AccordionToggle, { isExpanded: false, id: `${ACCORDION_MARKDOWN_BUTTON_ID}-${accordionId}` }, accordionHeading),
1607
+ React__namespace.createElement(reactCore.AccordionContent, { id: `${ACCORDION_MARKDOWN_CONTENT_ID}-${accordionId}`, isHidden: !false }, accordionContent)))));
1608
+ },
1609
+ }), []);
1610
+ };
1611
+
1612
+ const AccordionShowdownHandler = ({ buttonElement, contentElement, }) => {
1613
+ const [expanded, setExpanded] = React__namespace.useState(false);
1614
+ const handleClick = () => {
1615
+ const expandedModifier = 'pf-m-expanded';
1616
+ buttonElement.className = `pf-c-accordion__toggle ${!expanded ? expandedModifier : ''}`;
1617
+ contentElement.hidden = expanded;
1618
+ contentElement.className = `pf-c-accordion__expanded-content ${!expanded ? expandedModifier : ''}`;
1619
+ setExpanded(!expanded);
1620
+ };
1621
+ useEventListener(buttonElement, 'click', handleClick);
1622
+ return React__namespace.createElement(React__namespace.Fragment, null);
1623
+ };
1624
+ const AccordionRenderExtension = ({ docContext }) => {
1625
+ const buttonElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_BUTTON_ID}]`);
1626
+ const contentElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_CONTENT_ID}]`);
1627
+ return buttonElements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(buttonElements).map((elm) => {
1628
+ const content = Array.from(contentElements).find((elm2) => {
1629
+ const elmId = elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1];
1630
+ const elm2Id = elm2.id.split(ACCORDION_MARKDOWN_CONTENT_ID)[1];
1631
+ return elmId === elm2Id;
1632
+ });
1633
+ return (React__namespace.createElement(AccordionShowdownHandler, { key: elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1], buttonElement: elm, contentElement: content }));
1634
+ }))) : null;
1635
+ };
1636
+
1584
1637
  const FallbackImg = ({ src, alt, className, fallback }) => {
1585
1638
  const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
1586
1639
  if (src && isSrcValid) {
@@ -2001,12 +2054,22 @@ const TaskIcon = ({ taskIndex, taskStatus }) => {
2001
2054
  };
2002
2055
  const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
2003
2056
  const titleRef = React__namespace.useRef(null);
2057
+ const [parsedTitle, setParsedTitle] = React__namespace.useState('');
2004
2058
  React__namespace.useEffect(() => {
2005
2059
  if (isActiveTask) {
2006
2060
  // Focus the WizardNavItem button element that contains the title
2007
2061
  titleRef.current.parentNode.focus();
2008
2062
  }
2009
2063
  }, [isActiveTask]);
2064
+ React__namespace.useEffect(() => {
2065
+ function getParsedTitle() {
2066
+ return tslib.__awaiter(this, void 0, void 0, function* () {
2067
+ const convertedMdTitle = yield markdownConvert(title);
2068
+ setParsedTitle(removeParagraphWrap(convertedMdTitle));
2069
+ });
2070
+ }
2071
+ getParsedTitle();
2072
+ }, [title]);
2010
2073
  const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
2011
2074
  'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2012
2075
  'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
@@ -2022,7 +2085,7 @@ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, is
2022
2085
  const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
2023
2086
  React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
2024
2087
  React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
2025
- React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
2088
+ React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: parsedTitle } }),
2026
2089
  isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
2027
2090
  ' ',
2028
2091
  subtitle))),
@@ -2229,6 +2292,7 @@ const QuickStartPanelContent = (_a) => {
2229
2292
  const titleRef = React__namespace.useRef(null);
2230
2293
  const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
2231
2294
  const [contentRef, setContentRef] = React__namespace.useState();
2295
+ const [displayName, setDisplayName] = React__namespace.useState('');
2232
2296
  const shadows = useScrollShadows(contentRef);
2233
2297
  const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
2234
2298
  const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
@@ -2256,13 +2320,22 @@ const QuickStartPanelContent = (_a) => {
2256
2320
  titleRef.current.focus();
2257
2321
  }
2258
2322
  }, [quickStart]);
2323
+ React__namespace.useEffect(() => {
2324
+ function getDisplayName() {
2325
+ return tslib.__awaiter(this, void 0, void 0, function* () {
2326
+ const convertedMdDisplayName = yield markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName);
2327
+ setDisplayName(removeParagraphWrap(convertedMdDisplayName));
2328
+ });
2329
+ }
2330
+ getDisplayName();
2331
+ }, [quickStart]);
2259
2332
  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),
2260
2333
  React__namespace.createElement("div", { className: headerClasses },
2261
2334
  React__namespace.createElement(reactCore.DrawerHead, null,
2262
2335
  React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
2263
- React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } },
2336
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } },
2264
2337
  React__namespace.createElement("span", { dangerouslySetInnerHTML: {
2265
- __html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
2338
+ __html: displayName,
2266
2339
  } }),
2267
2340
  ' ',
2268
2341
  React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes) ? getResource('{{type}} • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
@@ -2429,7 +2502,7 @@ const HelpTopicPanelContent = (_a) => {
2429
2502
  setActiveHelpTopicByName(topicName);
2430
2503
  toggleHelpTopicMenu();
2431
2504
  };
2432
- const menuItems = filteredHelpTopics.length > 0 &&
2505
+ const menuItems = filteredHelpTopics.length > 1 &&
2433
2506
  filteredHelpTopics.map((topic) => {
2434
2507
  return (React__namespace.createElement(reactCore.OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2435
2508
  });