@patternfly/quickstarts 2.3.3 → 2.4.1

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
@@ -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);
@@ -1501,6 +1503,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1501
1503
  const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1502
1504
  const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1503
1505
  const codeShowdownExtension = useCodeShowdownExtension();
1506
+ const accordionShowdownExtension = useAccordionShowdownExtension();
1504
1507
  return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1505
1508
  {
1506
1509
  type: 'lang',
@@ -1524,8 +1527,10 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1524
1527
  multilineCopyClipboardShowdownExtension,
1525
1528
  admonitionShowdownExtension,
1526
1529
  codeShowdownExtension,
1530
+ accordionShowdownExtension,
1527
1531
  ...(markdown ? markdown.extensions : []),
1528
1532
  ], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
1533
+ React__namespace.createElement(AccordionRenderExtension, { docContext: docContext }),
1529
1534
  React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
1530
1535
  React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
1531
1536
  markdown &&
@@ -1581,6 +1586,45 @@ const useCodeShowdownExtension = () => {
1581
1586
  }), []);
1582
1587
  };
1583
1588
 
1589
+ const useAccordionShowdownExtension = () => {
1590
+ return React__namespace.useMemo(() => ({
1591
+ type: 'lang',
1592
+ regex: /\[(.+)]{{(accordion) ("(.*?)")}}/g,
1593
+ replace: (_text, accordionContent, _command, accordionHeading) => {
1594
+ const accordionId = new String(accordionHeading).replace(/\s/g, '-');
1595
+ return removeTemplateWhitespace(server.renderToStaticMarkup(React__namespace.createElement(reactCore.Accordion, { asDefinitionList: true },
1596
+ React__namespace.createElement(reactCore.AccordionItem, null,
1597
+ React__namespace.createElement(reactCore.AccordionToggle, { isExpanded: false, id: `${ACCORDION_MARKDOWN_BUTTON_ID}-${accordionId}` }, accordionHeading),
1598
+ React__namespace.createElement(reactCore.AccordionContent, { id: `${ACCORDION_MARKDOWN_CONTENT_ID}-${accordionId}`, isHidden: !false }, accordionContent)))));
1599
+ },
1600
+ }), []);
1601
+ };
1602
+
1603
+ const AccordionShowdownHandler = ({ buttonElement, contentElement, }) => {
1604
+ const [expanded, setExpanded] = React__namespace.useState(false);
1605
+ const handleClick = () => {
1606
+ const expandedModifier = 'pf-m-expanded';
1607
+ buttonElement.className = `pf-c-accordion__toggle ${!expanded ? expandedModifier : ''}`;
1608
+ contentElement.hidden = expanded;
1609
+ contentElement.className = `pf-c-accordion__expanded-content ${!expanded ? expandedModifier : ''}`;
1610
+ setExpanded(!expanded);
1611
+ };
1612
+ useEventListener(buttonElement, 'click', handleClick);
1613
+ return React__namespace.createElement(React__namespace.Fragment, null);
1614
+ };
1615
+ const AccordionRenderExtension = ({ docContext }) => {
1616
+ const buttonElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_BUTTON_ID}]`);
1617
+ const contentElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_CONTENT_ID}]`);
1618
+ return buttonElements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(buttonElements).map((elm) => {
1619
+ const content = Array.from(contentElements).find((elm2) => {
1620
+ const elmId = elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1];
1621
+ const elm2Id = elm2.id.split(ACCORDION_MARKDOWN_CONTENT_ID)[1];
1622
+ return elmId === elm2Id;
1623
+ });
1624
+ return (React__namespace.createElement(AccordionShowdownHandler, { key: elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1], buttonElement: elm, contentElement: content }));
1625
+ }))) : null;
1626
+ };
1627
+
1584
1628
  const FallbackImg = ({ src, alt, className, fallback }) => {
1585
1629
  const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
1586
1630
  if (src && isSrcValid) {
@@ -2260,7 +2304,7 @@ const QuickStartPanelContent = (_a) => {
2260
2304
  React__namespace.createElement("div", { className: headerClasses },
2261
2305
  React__namespace.createElement(reactCore.DrawerHead, null,
2262
2306
  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)' } },
2307
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } },
2264
2308
  React__namespace.createElement("span", { dangerouslySetInnerHTML: {
2265
2309
  __html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
2266
2310
  } }),
@@ -2429,7 +2473,7 @@ const HelpTopicPanelContent = (_a) => {
2429
2473
  setActiveHelpTopicByName(topicName);
2430
2474
  toggleHelpTopicMenu();
2431
2475
  };
2432
- const menuItems = filteredHelpTopics.length > 0 &&
2476
+ const menuItems = filteredHelpTopics.length > 1 &&
2433
2477
  filteredHelpTopics.map((topic) => {
2434
2478
  return (React__namespace.createElement(reactCore.OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2435
2479
  });