@patternfly/quickstarts 2.3.1 → 2.3.2

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.es.js CHANGED
@@ -10,6 +10,7 @@ import { renderToStaticMarkup } from 'react-dom/server';
10
10
  import CopyIcon from '@patternfly/react-icons/dist/js/icons/copy-icon';
11
11
  import LightbulbIcon from '@patternfly/react-icons/dist/js/icons/lightbulb-icon';
12
12
  import FireIcon from '@patternfly/react-icons/dist/js/icons/fire-icon';
13
+ import { Converter } from 'showdown';
13
14
  import SyncAltIcon from '@patternfly/react-icons/dist/js/icons/sync-alt-icon';
14
15
  import CheckCircleIcon from '@patternfly/react-icons/dist/js/icons/check-circle-icon';
15
16
  import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
@@ -17,7 +18,6 @@ import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-ic
17
18
  import '@patternfly/react-tokens/dist/js/global_danger_color_100';
18
19
  import '@patternfly/react-tokens/dist/js/global_palette_blue_300';
19
20
  import { global_palette_green_500 } from '@patternfly/react-tokens/dist/js/global_palette_green_500';
20
- import { Converter } from 'showdown';
21
21
  import ExternalLinkAltIcon from '@patternfly/react-icons/dist/js/icons/external-link-alt-icon';
22
22
  import OutlinedClockIcon from '@patternfly/react-icons/dist/js/icons/outlined-clock-icon';
23
23
  import ArrowRightIcon from '@patternfly/react-icons/dist/js/icons/arrow-right-icon';
@@ -572,7 +572,7 @@ const QuickStartContextDefaults = {
572
572
  activeQuickStartState: {},
573
573
  setAllQuickStarts: () => { },
574
574
  resourceBundle: en,
575
- getResource: () => '',
575
+ getResource: (resource) => resource,
576
576
  language: 'en',
577
577
  useQueryParams: true,
578
578
  filter: {
@@ -598,7 +598,7 @@ const getResource = (resource, options, resourceBundle, lng) => {
598
598
  return resourceBundle[`${resource}_${suffix}`];
599
599
  }
600
600
  }
601
- return (resourceBundle && resourceBundle[resource]) || '';
601
+ return (resourceBundle && resourceBundle[resource]) || resource;
602
602
  };
603
603
  const useValuesForQuickStartContext = (value = {}) => {
604
604
  var _a, _b;
@@ -1283,118 +1283,6 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1283
1283
  }), [getResource]);
1284
1284
  };
1285
1285
 
1286
- var AdmonitionType;
1287
- (function (AdmonitionType) {
1288
- AdmonitionType["TIP"] = "TIP";
1289
- AdmonitionType["NOTE"] = "NOTE";
1290
- AdmonitionType["IMPORTANT"] = "IMPORTANT";
1291
- AdmonitionType["WARNING"] = "WARNING";
1292
- AdmonitionType["CAUTION"] = "CAUTION";
1293
- })(AdmonitionType || (AdmonitionType = {}));
1294
- const admonitionToAlertVariantMap = {
1295
- [AdmonitionType.NOTE]: { variant: 'info' },
1296
- [AdmonitionType.TIP]: { variant: 'default', customIcon: React.createElement(LightbulbIcon, null) },
1297
- [AdmonitionType.IMPORTANT]: { variant: 'danger' },
1298
- [AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React.createElement(FireIcon, null) },
1299
- [AdmonitionType.WARNING]: { variant: 'warning' },
1300
- };
1301
- const useAdmonitionShowdownExtension = () => {
1302
- // const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
1303
- return React.useMemo(() => ({
1304
- type: 'lang',
1305
- regex: /\[(.+)]{{(admonition) ([\w-]+)}}/g,
1306
- replace: (text, content, admonitionLabel, admonitionType, groupId) => {
1307
- if (!content || !admonitionLabel || !admonitionType || !groupId) {
1308
- return text;
1309
- }
1310
- admonitionType = admonitionType.toUpperCase();
1311
- const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
1312
- const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
1313
- const pfAlert = (React.createElement(Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, content));
1314
- return removeTemplateWhitespace(renderToStaticMarkup(pfAlert));
1315
- },
1316
- }), []);
1317
- };
1318
-
1319
- const useCodeShowdownExtension = () => {
1320
- return React.useMemo(() => ({
1321
- type: 'output',
1322
- regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
1323
- replace: (text, content) => {
1324
- if (!content) {
1325
- return text;
1326
- }
1327
- const pfCodeBlock = React.createElement(CodeBlock, null, content);
1328
- return removeTemplateWhitespace(renderToStaticMarkup(pfCodeBlock));
1329
- },
1330
- }), []);
1331
- };
1332
-
1333
- const FallbackImg = ({ src, alt, className, fallback }) => {
1334
- const [isSrcValid, setIsSrcValid] = React.useState(true);
1335
- if (src && isSrcValid) {
1336
- return React.createElement("img", { className: className, src: src, alt: alt, onError: () => setIsSrcValid(false) });
1337
- }
1338
- return React.createElement(React.Fragment, null, fallback);
1339
- };
1340
-
1341
- const DASH = '-';
1342
-
1343
- const PopoverStatus = ({ hideHeader, children, isVisible = null, shouldClose = null, statusBody, title, onHide, onShow, }) => {
1344
- return (React.createElement(Popover, { position: PopoverPosition.right, headerContent: hideHeader ? null : title, bodyContent: children, "aria-label": title, onHide: onHide, onShow: onShow, isVisible: isVisible, shouldClose: shouldClose },
1345
- React.createElement(Button, { variant: "link", isInline: true }, statusBody)));
1346
- };
1347
-
1348
- const StatusIconAndText = ({ icon, title, spin, iconOnly, noTooltip, className, }) => {
1349
- if (!title) {
1350
- return React.createElement(React.Fragment, null, DASH);
1351
- }
1352
- return (React.createElement("span", { className: css('pfext-icon-and-text', className), title: iconOnly && !noTooltip ? title : undefined },
1353
- icon &&
1354
- React.cloneElement(icon, {
1355
- className: css(spin && 'fa-spin', icon.props.className, !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child'),
1356
- }),
1357
- !iconOnly && React.createElement(CamelCaseWrap, { value: title, dataTest: "status-text" })));
1358
- };
1359
-
1360
- const GenericStatus = (props) => {
1361
- const { Icon, children, popoverTitle, title, noTooltip, iconOnly } = props, restProps = __rest(props, ["Icon", "children", "popoverTitle", "title", "noTooltip", "iconOnly"]);
1362
- const renderIcon = iconOnly && !noTooltip ? React.createElement(Icon, { title: title }) : React.createElement(Icon, null);
1363
- const statusBody = (React.createElement(StatusIconAndText, Object.assign({}, restProps, { noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon })));
1364
- return React.Children.toArray(children).length ? (React.createElement(PopoverStatus, Object.assign({ title: popoverTitle || title }, restProps, { statusBody: statusBody }), children)) : (statusBody);
1365
- };
1366
-
1367
- // import { global_warning_color_100 as warningColor } from '@patternfly/react-tokens/dist/js/global_warning_color_100';
1368
- const GreenCheckCircleIcon = ({ className, title, size }) => (React.createElement(CheckCircleIcon, { "data-test": "success-icon", size: size, color: global_palette_green_500.value, className: className, title: title }));
1369
-
1370
- // export const PendingStatus: React.FC<StatusComponentProps> = (props) => (
1371
- // <GenericStatus {...props} Icon={HourglassHalfIcon} title={props.title || 'Pending'} />
1372
- // );
1373
- // PendingStatus.displayName = 'PendingStatus';
1374
- // export const ProgressStatus: React.FC<StatusComponentProps> = (props) => (
1375
- // <GenericStatus {...props} Icon={InProgressIcon} title={props.title || 'In progress'} />
1376
- // );
1377
- // ProgressStatus.displayName = 'ProgressStatus';
1378
- const SuccessStatus = (props) => (React.createElement(GenericStatus, Object.assign({}, props, { Icon: GreenCheckCircleIcon, title: props.title || 'Healthy' })));
1379
- SuccessStatus.displayName = 'SuccessStatus';
1380
- // export const WarningStatus: React.FC<StatusComponentProps> = (props) => (
1381
- // <GenericStatus {...props} Icon={YellowExclamationTriangleIcon} title={props.title || 'Warning'} />
1382
- // );
1383
- // WarningStatus.displayName = 'WarningStatus';
1384
-
1385
- const Status = ({ status, title, iconOnly, noTooltip, className, }) => {
1386
- const statusProps = { title: title || status, iconOnly, noTooltip, className };
1387
- switch (status) {
1388
- case 'In Progress':
1389
- return React.createElement(StatusIconAndText, Object.assign({}, statusProps, { icon: React.createElement(SyncAltIcon, null) }));
1390
- case 'Complete':
1391
- return React.createElement(SuccessStatus, Object.assign({}, statusProps));
1392
- default:
1393
- return React.createElement(React.Fragment, null, status || DASH);
1394
- }
1395
- };
1396
- const StatusIcon = ({ status }) => (React.createElement(Status, { status: status, iconOnly: true }));
1397
-
1398
1286
  // eslint-disable-next-line @typescript-eslint/no-require-imports
1399
1287
  const DOMPurify = require('dompurify');
1400
1288
  const markdownConvert = (markdown, extensions) => {
@@ -1603,6 +1491,119 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1603
1491
  markdown.renderExtension(docContext, rootSelector))), className: className }));
1604
1492
  };
1605
1493
 
1494
+ var AdmonitionType;
1495
+ (function (AdmonitionType) {
1496
+ AdmonitionType["TIP"] = "TIP";
1497
+ AdmonitionType["NOTE"] = "NOTE";
1498
+ AdmonitionType["IMPORTANT"] = "IMPORTANT";
1499
+ AdmonitionType["WARNING"] = "WARNING";
1500
+ AdmonitionType["CAUTION"] = "CAUTION";
1501
+ })(AdmonitionType || (AdmonitionType = {}));
1502
+ const admonitionToAlertVariantMap = {
1503
+ [AdmonitionType.NOTE]: { variant: 'info' },
1504
+ [AdmonitionType.TIP]: { variant: 'default', customIcon: React.createElement(LightbulbIcon, null) },
1505
+ [AdmonitionType.IMPORTANT]: { variant: 'danger' },
1506
+ [AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React.createElement(FireIcon, null) },
1507
+ [AdmonitionType.WARNING]: { variant: 'warning' },
1508
+ };
1509
+ const useAdmonitionShowdownExtension = () => {
1510
+ // const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
1511
+ return React.useMemo(() => ({
1512
+ type: 'lang',
1513
+ regex: /\[(.+)]{{(admonition) ([\w-]+)}}/g,
1514
+ replace: (text, content, admonitionLabel, admonitionType, groupId) => {
1515
+ if (!content || !admonitionLabel || !admonitionType || !groupId) {
1516
+ return text;
1517
+ }
1518
+ admonitionType = admonitionType.toUpperCase();
1519
+ const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
1520
+ const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
1521
+ const mdContent = React.createElement(QuickStartMarkdownView, { content: content });
1522
+ const pfAlert = (React.createElement(Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, mdContent));
1523
+ return removeTemplateWhitespace(renderToStaticMarkup(pfAlert));
1524
+ },
1525
+ }), []);
1526
+ };
1527
+
1528
+ const useCodeShowdownExtension = () => {
1529
+ return React.useMemo(() => ({
1530
+ type: 'output',
1531
+ regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
1532
+ replace: (text, content) => {
1533
+ if (!content) {
1534
+ return text;
1535
+ }
1536
+ const pfCodeBlock = React.createElement(CodeBlock, null, content);
1537
+ return removeTemplateWhitespace(renderToStaticMarkup(pfCodeBlock));
1538
+ },
1539
+ }), []);
1540
+ };
1541
+
1542
+ const FallbackImg = ({ src, alt, className, fallback }) => {
1543
+ const [isSrcValid, setIsSrcValid] = React.useState(true);
1544
+ if (src && isSrcValid) {
1545
+ return React.createElement("img", { className: className, src: src, alt: alt, onError: () => setIsSrcValid(false) });
1546
+ }
1547
+ return React.createElement(React.Fragment, null, fallback);
1548
+ };
1549
+
1550
+ const DASH = '-';
1551
+
1552
+ const PopoverStatus = ({ hideHeader, children, isVisible = null, shouldClose = null, statusBody, title, onHide, onShow, }) => {
1553
+ return (React.createElement(Popover, { position: PopoverPosition.right, headerContent: hideHeader ? null : title, bodyContent: children, "aria-label": title, onHide: onHide, onShow: onShow, isVisible: isVisible, shouldClose: shouldClose },
1554
+ React.createElement(Button, { variant: "link", isInline: true }, statusBody)));
1555
+ };
1556
+
1557
+ const StatusIconAndText = ({ icon, title, spin, iconOnly, noTooltip, className, }) => {
1558
+ if (!title) {
1559
+ return React.createElement(React.Fragment, null, DASH);
1560
+ }
1561
+ return (React.createElement("span", { className: css('pfext-icon-and-text', className), title: iconOnly && !noTooltip ? title : undefined },
1562
+ icon &&
1563
+ React.cloneElement(icon, {
1564
+ className: css(spin && 'fa-spin', icon.props.className, !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child'),
1565
+ }),
1566
+ !iconOnly && React.createElement(CamelCaseWrap, { value: title, dataTest: "status-text" })));
1567
+ };
1568
+
1569
+ const GenericStatus = (props) => {
1570
+ const { Icon, children, popoverTitle, title, noTooltip, iconOnly } = props, restProps = __rest(props, ["Icon", "children", "popoverTitle", "title", "noTooltip", "iconOnly"]);
1571
+ const renderIcon = iconOnly && !noTooltip ? React.createElement(Icon, { title: title }) : React.createElement(Icon, null);
1572
+ const statusBody = (React.createElement(StatusIconAndText, Object.assign({}, restProps, { noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon })));
1573
+ return React.Children.toArray(children).length ? (React.createElement(PopoverStatus, Object.assign({ title: popoverTitle || title }, restProps, { statusBody: statusBody }), children)) : (statusBody);
1574
+ };
1575
+
1576
+ // import { global_warning_color_100 as warningColor } from '@patternfly/react-tokens/dist/js/global_warning_color_100';
1577
+ const GreenCheckCircleIcon = ({ className, title, size }) => (React.createElement(CheckCircleIcon, { "data-test": "success-icon", size: size, color: global_palette_green_500.value, className: className, title: title }));
1578
+
1579
+ // export const PendingStatus: React.FC<StatusComponentProps> = (props) => (
1580
+ // <GenericStatus {...props} Icon={HourglassHalfIcon} title={props.title || 'Pending'} />
1581
+ // );
1582
+ // PendingStatus.displayName = 'PendingStatus';
1583
+ // export const ProgressStatus: React.FC<StatusComponentProps> = (props) => (
1584
+ // <GenericStatus {...props} Icon={InProgressIcon} title={props.title || 'In progress'} />
1585
+ // );
1586
+ // ProgressStatus.displayName = 'ProgressStatus';
1587
+ const SuccessStatus = (props) => (React.createElement(GenericStatus, Object.assign({}, props, { Icon: GreenCheckCircleIcon, title: props.title || 'Healthy' })));
1588
+ SuccessStatus.displayName = 'SuccessStatus';
1589
+ // export const WarningStatus: React.FC<StatusComponentProps> = (props) => (
1590
+ // <GenericStatus {...props} Icon={YellowExclamationTriangleIcon} title={props.title || 'Warning'} />
1591
+ // );
1592
+ // WarningStatus.displayName = 'WarningStatus';
1593
+
1594
+ const Status = ({ status, title, iconOnly, noTooltip, className, }) => {
1595
+ const statusProps = { title: title || status, iconOnly, noTooltip, className };
1596
+ switch (status) {
1597
+ case 'In Progress':
1598
+ return React.createElement(StatusIconAndText, Object.assign({}, statusProps, { icon: React.createElement(SyncAltIcon, null) }));
1599
+ case 'Complete':
1600
+ return React.createElement(SuccessStatus, Object.assign({}, statusProps));
1601
+ default:
1602
+ return React.createElement(React.Fragment, null, status || DASH);
1603
+ }
1604
+ };
1605
+ const StatusIcon = ({ status }) => (React.createElement(Status, { status: status, iconOnly: true }));
1606
+
1606
1607
  const QuickStartTileDescription = ({ description, prerequisites, }) => {
1607
1608
  const { getResource } = React.useContext(QuickStartContext);
1608
1609
  const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
@@ -1706,9 +1707,14 @@ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, })
1706
1707
  // @ts-ignore
1707
1708
  component: "div", style: {
1708
1709
  cursor: 'pointer',
1709
- }, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick,
1710
+ }, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick, onKeyDown: (event) => {
1711
+ if (event.key === 'Enter' || event.key === ' ') {
1712
+ setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1713
+ onClick();
1714
+ }
1715
+ },
1710
1716
  // https://github.com/patternfly/patternfly-react/issues/7039
1711
- href: "#", "data-test": `tile ${id}`, description: React.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent })));
1717
+ href: "#", "data-test": `tile ${id}`, description: React.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0 })));
1712
1718
  };
1713
1719
 
1714
1720
  const QuickStartCatalog = ({ quickStarts }) => {
@@ -1951,6 +1957,13 @@ const TaskIcon = ({ taskIndex, taskStatus }) => {
1951
1957
  return React.createElement("span", { className: classNames }, content);
1952
1958
  };
1953
1959
  const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
1960
+ const titleRef = React.useRef(null);
1961
+ React.useEffect(() => {
1962
+ if (isActiveTask) {
1963
+ // Focus the WizardNavItem button element that contains the title
1964
+ titleRef.current.parentNode.focus();
1965
+ }
1966
+ }, [isActiveTask]);
1954
1967
  const classNames = css('pfext-quick-start-task-header__title', {
1955
1968
  'pfext-quick-start-task-header__title-success': taskStatus === QuickStartTaskStatus.SUCCESS,
1956
1969
  'pfext-quick-start-task-header__title-failed': taskStatus === (QuickStartTaskStatus.FAILED || QuickStartTaskStatus.VISITED),
@@ -1963,7 +1976,7 @@ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, is
1963
1976
  const tryAgain = failedReview && (React.createElement(React.Fragment, null,
1964
1977
  React.createElement("div", null),
1965
1978
  React.createElement("div", { className: "pfext-quick-start-task-header__tryagain" }, "Try the steps again.")));
1966
- const content = (React.createElement("div", { className: "pfext-quick-start-task-header" },
1979
+ const content = (React.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
1967
1980
  React.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
1968
1981
  React.createElement(Title, { headingLevel: "h3", size: size, className: classNames },
1969
1982
  React.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
@@ -2170,6 +2183,7 @@ const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
2170
2183
  };
2171
2184
  const QuickStartPanelContent = (_a) => {
2172
2185
  var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = __rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
2186
+ const titleRef = React.useRef(null);
2173
2187
  const { getResource, activeQuickStartState } = React.useContext(QuickStartContext);
2174
2188
  const [contentRef, setContentRef] = React.useState();
2175
2189
  const shadows = useScrollShadows(contentRef);
@@ -2194,10 +2208,15 @@ const QuickStartPanelContent = (_a) => {
2194
2208
  }
2195
2209
  return Number.parseInt(taskNumber, 10) + 1;
2196
2210
  };
2211
+ React.useEffect(() => {
2212
+ if (quickStart) {
2213
+ titleRef.current.focus();
2214
+ }
2215
+ }, [quickStart]);
2197
2216
  const content = quickStart ? (React.createElement(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),
2198
2217
  React.createElement("div", { className: headerClasses },
2199
2218
  React.createElement(DrawerHead, null,
2200
- React.createElement("div", { className: "pfext-quick-start-panel-content__title" },
2219
+ React.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
2201
2220
  React.createElement(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 :
2202
2221
  quickStart.spec.displayName,
2203
2222
  ' ',