@patternfly/quickstarts 2.3.2 → 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 (41) 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/ConsoleShared/src/components/status/NotStartedIcon.d.ts +0 -1
  7. package/dist/index.es.js +106 -30
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/index.js +104 -28
  10. package/dist/index.js.map +1 -1
  11. package/dist/patternfly-docs/quick-starts/design-guidelines/design-guidelines.md +1 -1
  12. package/dist/patternfly-docs/quick-starts/examples/about.md +28 -21
  13. package/dist/patternfly-docs/quick-starts/examples/basic.md +7 -5
  14. package/dist/patternfly-docs/quick-starts/examples/help-topics.md +8 -5
  15. package/dist/patternfly-global.css +890 -419
  16. package/dist/patternfly-nested.css +12484 -7322
  17. package/dist/quickstarts-base.css +870 -671
  18. package/dist/quickstarts-full.es.js +6466 -6194
  19. package/dist/quickstarts-full.es.js.map +1 -1
  20. package/dist/quickstarts-standalone.css +854 -622
  21. package/dist/quickstarts-standalone.min.css +2 -2
  22. package/dist/quickstarts-vendor.css +84 -55
  23. package/dist/quickstarts.css +953 -726
  24. package/dist/quickstarts.min.css +1 -1
  25. package/dist/utils/quick-start-types.d.ts +0 -1
  26. package/package.json +16 -13
  27. package/src/ConsoleInternal/components/catalog/_catalog.scss +7 -5
  28. package/src/ConsoleInternal/components/markdown-view.tsx +34 -50
  29. package/src/ConsoleShared/src/components/markdown-extensions/accordion-extension.tsx +52 -0
  30. package/src/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.tsx +60 -0
  31. package/src/ConsoleShared/src/components/markdown-extensions/const.ts +2 -0
  32. package/src/ConsoleShared/src/components/markdown-extensions/index.ts +2 -0
  33. package/src/HelpTopicPanelContent.tsx +1 -1
  34. package/src/QuickStartMarkdownView.tsx +5 -0
  35. package/src/QuickStartPanelContent.tsx +17 -2
  36. package/src/catalog/QuickStartTileHeader.tsx +2 -1
  37. package/src/controller/QuickStartTaskHeader.tsx +12 -1
  38. package/src/declaration.d.ts +1 -0
  39. package/src/styles/legacy-bootstrap/_code.scss +4 -2
  40. package/src/styles/legacy-bootstrap/_type.scss +8 -6
  41. package/src/styles/patternfly-nested.scss +9 -9
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');
@@ -914,7 +914,7 @@ class CatalogTile extends React__namespace.Component {
914
914
  const _a = this.props, { id, className, featured, onClick, href, icon, iconImg, iconAlt, iconClass, badges, title, vendor, description, footer,
915
915
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
916
916
  ref, children } = _a, props = tslib.__rest(_a, ["id", "className", "featured", "onClick", "href", "icon", "iconImg", "iconAlt", "iconClass", "badges", "title", "vendor", "description", "footer", "ref", "children"]);
917
- return (React__namespace.createElement(reactCore.Card, Object.assign({ component: href || onClick ? 'a' : 'div', id: id, href: href || '#', className: reactStyles.css('catalog-tile-pf', { featured }, className), onClick: e => this.handleClick(e), isHoverable: true }, props),
917
+ return (React__namespace.createElement(reactCore.Card, Object.assign({ component: href || onClick ? 'a' : 'div', id: id, href: href || '#', className: reactStyles.css('catalog-tile-pf', { featured }, className), onClick: e => this.handleClick(e), isSelectable: true }, props),
918
918
  (badges.length > 0 || iconImg || iconClass || icon) && (React__namespace.createElement(reactCore.CardHeader, null,
919
919
  iconImg && React__namespace.createElement("img", { className: "catalog-tile-pf-icon", src: iconImg, alt: iconAlt }),
920
920
  !iconImg && (iconClass || icon) && React__namespace.createElement("span", { className: `catalog-tile-pf-icon ${iconClass}` }, 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) {
@@ -1711,7 +1764,8 @@ const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, }) =
1711
1764
  [exports.QuickStartStatus.NOT_STARTED]: getResource('Not started'),
1712
1765
  };
1713
1766
  return (React__namespace.createElement("div", { className: "pfext-quick-start-tile-header" },
1714
- React__namespace.createElement(reactCore.Title, { headingLevel: "h3", "data-test": "title", id: quickStartId }, name),
1767
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
1768
+ React__namespace.createElement(QuickStartMarkdownView, { content: name })),
1715
1769
  React__namespace.createElement("div", { className: "pfext-quick-start-tile-header__status" },
1716
1770
  type && (React__namespace.createElement(reactCore.Label, { className: "pfext-quick-start-tile-header--margin", color: type.color }, type.text)),
1717
1771
  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))),
@@ -2000,12 +2054,22 @@ const TaskIcon = ({ taskIndex, taskStatus }) => {
2000
2054
  };
2001
2055
  const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
2002
2056
  const titleRef = React__namespace.useRef(null);
2057
+ const [parsedTitle, setParsedTitle] = React__namespace.useState('');
2003
2058
  React__namespace.useEffect(() => {
2004
2059
  if (isActiveTask) {
2005
2060
  // Focus the WizardNavItem button element that contains the title
2006
2061
  titleRef.current.parentNode.focus();
2007
2062
  }
2008
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]);
2009
2073
  const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
2010
2074
  'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2011
2075
  'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
@@ -2021,7 +2085,7 @@ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, is
2021
2085
  const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
2022
2086
  React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
2023
2087
  React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
2024
- React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
2088
+ React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: parsedTitle } }),
2025
2089
  isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
2026
2090
  ' ',
2027
2091
  subtitle))),
@@ -2228,6 +2292,7 @@ const QuickStartPanelContent = (_a) => {
2228
2292
  const titleRef = React__namespace.useRef(null);
2229
2293
  const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
2230
2294
  const [contentRef, setContentRef] = React__namespace.useState();
2295
+ const [displayName, setDisplayName] = React__namespace.useState('');
2231
2296
  const shadows = useScrollShadows(contentRef);
2232
2297
  const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
2233
2298
  const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
@@ -2255,12 +2320,23 @@ const QuickStartPanelContent = (_a) => {
2255
2320
  titleRef.current.focus();
2256
2321
  }
2257
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]);
2258
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),
2259
2333
  React__namespace.createElement("div", { className: headerClasses },
2260
2334
  React__namespace.createElement(reactCore.DrawerHead, null,
2261
2335
  React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
2262
- React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } }, quickStart === null || quickStart === void 0 ? void 0 :
2263
- quickStart.spec.displayName,
2336
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } },
2337
+ React__namespace.createElement("span", { dangerouslySetInnerHTML: {
2338
+ __html: displayName,
2339
+ } }),
2264
2340
  ' ',
2265
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)
2266
2342
  .replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
@@ -2426,7 +2502,7 @@ const HelpTopicPanelContent = (_a) => {
2426
2502
  setActiveHelpTopicByName(topicName);
2427
2503
  toggleHelpTopicMenu();
2428
2504
  };
2429
- const menuItems = filteredHelpTopics.length > 0 &&
2505
+ const menuItems = filteredHelpTopics.length > 1 &&
2430
2506
  filteredHelpTopics.map((topic) => {
2431
2507
  return (React__namespace.createElement(reactCore.OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2432
2508
  });