@patternfly/patternfly-doc-core 1.5.0 → 1.6.0
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/.astro/collections/examples.schema.json +40 -0
- package/.astro/content-modules.mjs +4 -1
- package/.astro/content.d.ts +20 -1
- package/astro.config.mjs +2 -2
- package/declarations.d.ts +2 -0
- package/dist/client/_astro/LiveExample.B7IM_dLQ.css +1 -0
- package/dist/client/_astro/LiveExample.Df-EUsee.js +40 -0
- package/dist/client/_astro/Navigation.CabjIYg4.js +1 -0
- package/dist/client/_astro/PageContext.D1pNBMhh.js +9 -0
- package/dist/client/_astro/PageSidebarBody.Y-7d6zQM.js +1 -0
- package/dist/client/_astro/PageToggle.CbfM9bJB.js +1 -0
- package/dist/client/_astro/PageToggleButton.CZ3xPbcc.js +1 -0
- package/dist/client/_astro/Toolbar.9-YSFh3P.js +1 -0
- package/dist/client/_astro/ToolbarContent.BXdFKbs9.js +1 -0
- package/dist/client/_astro/_page_.B8cBYNKa.css +1 -0
- package/dist/client/_astro/_page_.CtheD08_.css +1 -0
- package/dist/client/_astro/_tab_.DxJDkZPc.css +1 -0
- package/dist/client/_astro/_tab_.YrfmckTJ.css +1 -0
- package/dist/client/_astro/client.CTJTt880.js +1 -0
- package/dist/client/_astro/divider.DjbDHO_6.js +1 -0
- package/dist/client/_astro/index.Dhi-S4Ah.js +24 -0
- package/dist/client/_astro/index.Dkaqzkgy.js +9 -0
- package/dist/client/_astro/page.CDtWFZb5.js +1 -0
- package/dist/client/components/accordion/index.html +85 -0
- package/dist/client/design-foundations/typography/index.html +10 -8
- package/dist/client/design-foundations/usage-and-behavior/index.html +10 -8
- package/dist/client/get-started/contribute/index.html +10 -8
- package/dist/client/index.html +5 -3
- package/dist/server/_@astrojs-ssr-adapter.mjs +1 -1
- package/dist/server/chunks/{PropsTables_MQNZVYdD.mjs → PropsTables_IgCNCQTX.mjs} +147 -213
- package/dist/server/chunks/{_@astrojs-ssr-adapter_8jk9s5dg.mjs → _@astrojs-ssr-adapter_CbICuCdt.mjs} +2 -2
- package/dist/server/chunks/{_astro_assets_CmxVRFAY.mjs → _astro_assets_DaYumpRZ.mjs} +2 -2
- package/dist/server/chunks/_astro_data-layer-content_Ni7IDnLe.mjs +1 -0
- package/dist/server/chunks/{angle-down-icon_BNJvzYv-.mjs → angle-down-icon_C5YQ7k8s.mjs} +163 -213
- package/dist/server/chunks/astro/{server_zRMEhmuT.mjs → server_Cl9jPh4p.mjs} +179 -89
- package/dist/server/chunks/{astro-designed-error-pages_DRBnGamN.mjs → astro-designed-error-pages_BFveJFnQ.mjs} +1 -1
- package/dist/server/chunks/content-modules_BzUEG69n.mjs +1 -0
- package/dist/server/chunks/{sharp_BAxaBZQw.mjs → sharp_CbOL3WDk.mjs} +2 -2
- package/dist/server/entry.mjs +3 -3
- package/dist/server/{manifest_7YAgSoyv.mjs → manifest_DoNTQyvZ.mjs} +3 -3
- package/dist/server/pages/_image.astro.mjs +1 -1
- package/dist/server/renderers.mjs +63 -14
- package/package.json +5 -2
- package/src/components/Content.tsx +61 -0
- package/src/components/ExampleToolbar.tsx +296 -0
- package/src/components/LiveExample.astro +7 -0
- package/src/components/LiveExample.tsx +42 -0
- package/src/content.ts +2 -1
- package/src/pages/[section]/[page]/[...tab].astro +97 -39
- package/textContent/examples/Accordion/Accordion.mdx +45 -0
- package/textContent/examples/Accordion/AccordionBordered.tsx +141 -0
- package/textContent/examples/Accordion/AccordionDefinitionList.tsx +102 -0
- package/textContent/examples/Accordion/AccordionFixedWithMultipleExpandBehavior.tsx +128 -0
- package/textContent/examples/Accordion/AccordionSingleExpandBehavior.tsx +118 -0
- package/textContent/examples/Accordion/AccordionToggleIconAtStart.tsx +118 -0
- package/dist/client/_astro/Button.C3_jB5tC.js +0 -9
- package/dist/client/_astro/Navigation.CULUlMEB.js +0 -1
- package/dist/client/_astro/PageContext.C7BqCh9N.js +0 -1
- package/dist/client/_astro/PageToggle.DDEjruql.js +0 -1
- package/dist/client/_astro/Toolbar.TAdHxLSQ.js +0 -1
- package/dist/client/_astro/_page_.CXyz_BEo.css +0 -1
- package/dist/client/_astro/_page_.DVvr_Mfl.css +0 -1
- package/dist/client/_astro/_page_.SnUmZn2y.css +0 -1
- package/dist/client/_astro/client.CeeiqVaE.js +0 -1
- package/dist/client/_astro/divider.BSD-oFoh.js +0 -1
- package/dist/client/_astro/index.CTH3fVMn.js +0 -32
- package/dist/client/_astro/page.B65lVdBS.js +0 -1
- /package/dist/server/chunks/{_astro_data-layer-content_DDGBHvtb.mjs → Accordion_CGgMUho2.mjs} +0 -0
- /package/dist/server/chunks/{content-modules_Dz-S_Wwv.mjs → Accordion_DlM2LvlF.mjs} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
/* empty css
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { Component, useMemo, useLayoutEffect, useEffect, useRef, useState, useCallback, isValidElement, cloneElement, forwardRef, createRef, createContext, useContext } from 'react';
|
|
4
|
+
/* empty css */
|
|
5
5
|
import * as ReactDOM from 'react-dom';
|
|
6
6
|
|
|
7
7
|
/** Joins args into a className string
|
|
@@ -70,7 +70,7 @@ let currentId$1 = 0;
|
|
|
70
70
|
*/
|
|
71
71
|
function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath }) {
|
|
72
72
|
var _a;
|
|
73
|
-
return _a = class SVGIcon extends
|
|
73
|
+
return _a = class SVGIcon extends Component {
|
|
74
74
|
constructor() {
|
|
75
75
|
super(...arguments);
|
|
76
76
|
this.id = `icon-title-${currentId$1++}`;
|
|
@@ -80,9 +80,7 @@ function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath })
|
|
|
80
80
|
const classes = className ? `pf-v6-svg ${className}` : 'pf-v6-svg';
|
|
81
81
|
const hasTitle = Boolean(title);
|
|
82
82
|
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
83
|
-
return (
|
|
84
|
-
hasTitle && React.createElement("title", { id: this.id }, title),
|
|
85
|
-
React.createElement("path", { d: svgPath })));
|
|
83
|
+
return (jsxs("svg", Object.assign({ className: classes, viewBox: viewBox, fill: "currentColor", "aria-labelledby": hasTitle ? this.id : null, "aria-hidden": hasTitle ? null : true, role: "img", width: "1em", height: "1em" }, props, { children: [hasTitle && jsx("title", { id: this.id, children: title }), jsx("path", { d: svgPath })] })));
|
|
86
84
|
}
|
|
87
85
|
},
|
|
88
86
|
_a.displayName = name,
|
|
@@ -439,7 +437,7 @@ function getRandomId() {
|
|
|
439
437
|
return getUniqueId();
|
|
440
438
|
}
|
|
441
439
|
}
|
|
442
|
-
class GenerateId extends
|
|
440
|
+
class GenerateId extends Component {
|
|
443
441
|
constructor() {
|
|
444
442
|
super(...arguments);
|
|
445
443
|
this.uniqueElement = this.props.isRandom ? getRandomId() : currentId++;
|
|
@@ -2092,7 +2090,7 @@ const createPopper = popperGenerator({ defaultModifiers });
|
|
|
2092
2090
|
/**
|
|
2093
2091
|
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
2094
2092
|
*/
|
|
2095
|
-
const useIsomorphicLayoutEffect = canUseDOM ?
|
|
2093
|
+
const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
|
2096
2094
|
|
|
2097
2095
|
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
|
2098
2096
|
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -2105,14 +2103,14 @@ const fromEntries = (entries) => entries.reduce((acc, [key, value]) => {
|
|
|
2105
2103
|
}, {});
|
|
2106
2104
|
const EMPTY_MODIFIERS = [];
|
|
2107
2105
|
const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
2108
|
-
const prevOptions =
|
|
2106
|
+
const prevOptions = useRef(null);
|
|
2109
2107
|
const optionsWithDefaults = {
|
|
2110
2108
|
onFirstUpdate: options.onFirstUpdate,
|
|
2111
2109
|
placement: options.placement || 'bottom',
|
|
2112
2110
|
strategy: options.strategy || 'absolute',
|
|
2113
2111
|
modifiers: options.modifiers || EMPTY_MODIFIERS
|
|
2114
2112
|
};
|
|
2115
|
-
const [state, setState] =
|
|
2113
|
+
const [state, setState] = useState({
|
|
2116
2114
|
styles: {
|
|
2117
2115
|
popper: {
|
|
2118
2116
|
position: optionsWithDefaults.strategy,
|
|
@@ -2122,7 +2120,7 @@ const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
|
2122
2120
|
},
|
|
2123
2121
|
attributes: {}
|
|
2124
2122
|
});
|
|
2125
|
-
const updateStateModifier =
|
|
2123
|
+
const updateStateModifier = useMemo(() => ({
|
|
2126
2124
|
name: 'updateState',
|
|
2127
2125
|
enabled: true,
|
|
2128
2126
|
phase: 'write',
|
|
@@ -2136,7 +2134,7 @@ const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
|
2136
2134
|
},
|
|
2137
2135
|
requires: ['computeStyles']
|
|
2138
2136
|
}), []);
|
|
2139
|
-
const popperOptions =
|
|
2137
|
+
const popperOptions = useMemo(() => {
|
|
2140
2138
|
const newOptions = {
|
|
2141
2139
|
onFirstUpdate: optionsWithDefaults.onFirstUpdate,
|
|
2142
2140
|
placement: optionsWithDefaults.placement,
|
|
@@ -2157,7 +2155,7 @@ const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
|
2157
2155
|
optionsWithDefaults.modifiers,
|
|
2158
2156
|
updateStateModifier
|
|
2159
2157
|
]);
|
|
2160
|
-
const popperInstanceRef =
|
|
2158
|
+
const popperInstanceRef = useRef(undefined);
|
|
2161
2159
|
useIsomorphicLayoutEffect(() => {
|
|
2162
2160
|
if (popperInstanceRef && popperInstanceRef.current) {
|
|
2163
2161
|
popperInstanceRef.current.setOptions(popperOptions);
|
|
@@ -2202,22 +2200,22 @@ const getOppositePlacement = (placement) => placement.replace(/left|right|bottom
|
|
|
2202
2200
|
const getOpacityTransition = (animationDuration) => `opacity ${animationDuration}ms cubic-bezier(.54, 1.5, .38, 1.11)`;
|
|
2203
2201
|
const Popper = ({ trigger, popper, direction = 'down', position = 'start', placement, width, minWidth = 'trigger', maxWidth, appendTo = () => document.body, zIndex = 9999, isVisible = true, positionModifiers, distance = 0, onMouseEnter, onMouseLeave, onFocus, onBlur, onDocumentClick, onTriggerClick, onTriggerEnter, onPopperClick, onPopperMouseEnter, onPopperMouseLeave, onDocumentKeyDown, enableFlip = true, flipBehavior = 'flip', triggerRef, popperRef, animationDuration = 0, entryDelay = 0, exitDelay = 0, onHidden = () => { }, onHide = () => { }, onMount = () => { }, onShow = () => { }, onShown = () => { }, preventOverflow = false }) => {
|
|
2204
2202
|
var _a;
|
|
2205
|
-
const [triggerElement, setTriggerElement] =
|
|
2206
|
-
const [refElement, setRefElement] =
|
|
2207
|
-
const [popperElement, setPopperElement] =
|
|
2208
|
-
const [popperContent, setPopperContent] =
|
|
2209
|
-
const [ready, setReady] =
|
|
2210
|
-
const [opacity, setOpacity] =
|
|
2211
|
-
const [internalIsVisible, setInternalIsVisible] =
|
|
2212
|
-
const transitionTimerRef =
|
|
2213
|
-
const showTimerRef =
|
|
2214
|
-
const hideTimerRef =
|
|
2215
|
-
const prevExitDelayRef =
|
|
2203
|
+
const [triggerElement, setTriggerElement] = useState(null);
|
|
2204
|
+
const [refElement, setRefElement] = useState(null);
|
|
2205
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
2206
|
+
const [popperContent, setPopperContent] = useState(null);
|
|
2207
|
+
const [ready, setReady] = useState(false);
|
|
2208
|
+
const [opacity, setOpacity] = useState(0);
|
|
2209
|
+
const [internalIsVisible, setInternalIsVisible] = useState(isVisible);
|
|
2210
|
+
const transitionTimerRef = useRef(null);
|
|
2211
|
+
const showTimerRef = useRef(null);
|
|
2212
|
+
const hideTimerRef = useRef(null);
|
|
2213
|
+
const prevExitDelayRef = useRef(undefined);
|
|
2216
2214
|
const refOrTrigger = refElement || triggerElement;
|
|
2217
2215
|
const showPopper = isVisible || internalIsVisible;
|
|
2218
2216
|
const triggerParent = (_a = ((triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || triggerElement)) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
2219
2217
|
const languageDirection = getLanguageDirection(triggerParent);
|
|
2220
|
-
const internalPosition =
|
|
2218
|
+
const internalPosition = useMemo(() => {
|
|
2221
2219
|
const fixedPositions = { left: 'left', right: 'right', center: 'center' };
|
|
2222
2220
|
const positionMap = {
|
|
2223
2221
|
ltr: Object.assign({ start: 'left', end: 'right' }, fixedPositions),
|
|
@@ -2225,16 +2223,16 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2225
2223
|
};
|
|
2226
2224
|
return positionMap[languageDirection][position];
|
|
2227
2225
|
}, [position, languageDirection]);
|
|
2228
|
-
const onDocumentClickCallback =
|
|
2229
|
-
|
|
2226
|
+
const onDocumentClickCallback = useCallback((event) => onDocumentClick(event, refOrTrigger, popperElement), [showPopper, triggerElement, refElement, popperElement, onDocumentClick]);
|
|
2227
|
+
useEffect(() => {
|
|
2230
2228
|
setReady(true);
|
|
2231
2229
|
onMount();
|
|
2232
2230
|
}, []);
|
|
2233
2231
|
// Cancel all timers on unmount
|
|
2234
|
-
|
|
2232
|
+
useEffect(() => () => {
|
|
2235
2233
|
clearTimeouts([transitionTimerRef, hideTimerRef, showTimerRef]);
|
|
2236
2234
|
}, []);
|
|
2237
|
-
|
|
2235
|
+
useEffect(() => {
|
|
2238
2236
|
if (triggerRef) {
|
|
2239
2237
|
if (triggerRef.current) {
|
|
2240
2238
|
setRefElement(triggerRef.current);
|
|
@@ -2244,7 +2242,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2244
2242
|
}
|
|
2245
2243
|
}
|
|
2246
2244
|
}, [triggerRef, trigger]);
|
|
2247
|
-
|
|
2245
|
+
useEffect(() => {
|
|
2248
2246
|
// When the popperRef is defined or the popper visibility changes, ensure the popper element is up to date
|
|
2249
2247
|
if (popperRef) {
|
|
2250
2248
|
if (popperRef.current) {
|
|
@@ -2255,7 +2253,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2255
2253
|
}
|
|
2256
2254
|
}
|
|
2257
2255
|
}, [showPopper, popperRef]);
|
|
2258
|
-
|
|
2256
|
+
useEffect(() => {
|
|
2259
2257
|
// Trigger a Popper update when content changes.
|
|
2260
2258
|
const observer = new MutationObserver(() => {
|
|
2261
2259
|
update && update();
|
|
@@ -2275,7 +2273,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2275
2273
|
element.removeEventListener(event, listener, { capture });
|
|
2276
2274
|
}
|
|
2277
2275
|
};
|
|
2278
|
-
|
|
2276
|
+
useEffect(() => {
|
|
2279
2277
|
addEventListener(onMouseEnter, refOrTrigger, 'mouseenter');
|
|
2280
2278
|
addEventListener(onMouseLeave, refOrTrigger, 'mouseleave');
|
|
2281
2279
|
addEventListener(onFocus, refOrTrigger, 'focus');
|
|
@@ -2326,9 +2324,9 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2326
2324
|
}
|
|
2327
2325
|
return convertedPlacement;
|
|
2328
2326
|
};
|
|
2329
|
-
const getPlacementMemo =
|
|
2330
|
-
const getOppositePlacementMemo =
|
|
2331
|
-
const widthMods =
|
|
2327
|
+
const getPlacementMemo = useMemo(getPlacement, [direction, internalPosition, placement]);
|
|
2328
|
+
const getOppositePlacementMemo = useMemo(() => getOppositePlacement(getPlacement()), [direction, internalPosition, placement]);
|
|
2329
|
+
const widthMods = useMemo(() => ({
|
|
2332
2330
|
name: 'widthMods',
|
|
2333
2331
|
enabled: width !== undefined || minWidth !== undefined || maxWidth !== undefined,
|
|
2334
2332
|
phase: 'beforeWrite',
|
|
@@ -2390,7 +2388,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2390
2388
|
/** We want to forceUpdate only when a tooltip's content is dynamically updated.
|
|
2391
2389
|
* TODO: Investigate into 3rd party libraries for a less limited/specific solution
|
|
2392
2390
|
*/
|
|
2393
|
-
|
|
2391
|
+
useEffect(() => {
|
|
2394
2392
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2395
2393
|
// currentPopperContent = {tooltip children} || {dropdown children}
|
|
2396
2394
|
const currentPopperContent = ((_d = (_c = (_b = (_a = popper === null || popper === void 0 ? void 0 : popper.props) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.children) || ((_g = (_f = (_e = popper === null || popper === void 0 ? void 0 : popper.props) === null || _e === void 0 ? void 0 : _e.children) === null || _f === void 0 ? void 0 : _f.props) === null || _g === void 0 ? void 0 : _g.children);
|
|
@@ -2399,7 +2397,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2399
2397
|
forceUpdate && forceUpdate();
|
|
2400
2398
|
}
|
|
2401
2399
|
}, [popper]);
|
|
2402
|
-
|
|
2400
|
+
useEffect(() => {
|
|
2403
2401
|
if (prevExitDelayRef.current < exitDelay) {
|
|
2404
2402
|
clearTimeouts([transitionTimerRef, hideTimerRef]);
|
|
2405
2403
|
hideTimerRef.current = setTimeout(() => {
|
|
@@ -2430,7 +2428,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2430
2428
|
}, animationDuration);
|
|
2431
2429
|
}, exitDelay);
|
|
2432
2430
|
};
|
|
2433
|
-
|
|
2431
|
+
useEffect(() => {
|
|
2434
2432
|
if (isVisible) {
|
|
2435
2433
|
show();
|
|
2436
2434
|
}
|
|
@@ -2450,8 +2448,10 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2450
2448
|
const options = Object.assign({ className: css(popper.props && popper.props.className, positionModifiers && modifierFromPopperPosition()), style: Object.assign(Object.assign(Object.assign({}, ((popper.props && popper.props.style) || {})), popperStyles.popper), { zIndex,
|
|
2451
2449
|
opacity, transition: getOpacityTransition(animationDuration) }) }, attributes.popper);
|
|
2452
2450
|
const getMenuWithPopper = () => {
|
|
2453
|
-
const localPopper =
|
|
2454
|
-
return popperRef ? (localPopper) : (
|
|
2451
|
+
const localPopper = cloneElement(popper, options);
|
|
2452
|
+
return popperRef ? (localPopper) : (jsx("div", { style: { display: 'contents' }, ref: (node) => {
|
|
2453
|
+
setPopperElement(node === null || node === void 0 ? void 0 : node.firstElementChild);
|
|
2454
|
+
}, children: localPopper }));
|
|
2455
2455
|
};
|
|
2456
2456
|
const getPopper = () => {
|
|
2457
2457
|
if (appendTo === 'inline') {
|
|
@@ -2462,10 +2462,9 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2462
2462
|
return ReactDOM.createPortal(getMenuWithPopper(), target);
|
|
2463
2463
|
}
|
|
2464
2464
|
};
|
|
2465
|
-
return (
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
ready && showPopper && getPopper()));
|
|
2465
|
+
return (jsxs(Fragment, { children: [!triggerRef && trigger && isValidElement(trigger) && (jsx("div", { style: { display: 'contents' }, ref: (node) => {
|
|
2466
|
+
setTriggerElement(node === null || node === void 0 ? void 0 : node.firstElementChild);
|
|
2467
|
+
}, children: trigger })), triggerRef && trigger && isValidElement(trigger) && trigger, ready && showPopper && getPopper()] }));
|
|
2469
2468
|
};
|
|
2470
2469
|
Popper.displayName = 'Popper';
|
|
2471
2470
|
|
|
@@ -2617,7 +2616,7 @@ const onToggleArrowKeydownDefault = (event, menuRef) => {
|
|
|
2617
2616
|
}
|
|
2618
2617
|
focusableElement && focusableElement.focus();
|
|
2619
2618
|
};
|
|
2620
|
-
class KeyboardHandler extends
|
|
2619
|
+
class KeyboardHandler extends Component {
|
|
2621
2620
|
constructor() {
|
|
2622
2621
|
super(...arguments);
|
|
2623
2622
|
this.keyHandler = (event) => {
|
|
@@ -2629,7 +2628,7 @@ class KeyboardHandler extends React.Component {
|
|
|
2629
2628
|
const { isActiveElement, getFocusableElement, noVerticalArrowHandling, noHorizontalArrowHandling, noEnterHandling, noSpaceHandling, updateTabIndex, validSiblingTags, additionalKeyHandler, createNavigableElements, onlyTraverseSiblings } = this.props;
|
|
2630
2629
|
// Pass the event off to be handled by any custom handler
|
|
2631
2630
|
additionalKeyHandler && additionalKeyHandler(event);
|
|
2632
|
-
//
|
|
2631
|
+
// Initialize navigableElements from the createNavigableElements callback
|
|
2633
2632
|
const navigableElements = createNavigableElements();
|
|
2634
2633
|
if (!navigableElements) {
|
|
2635
2634
|
// eslint-disable-next-line no-console
|
|
@@ -2713,11 +2712,14 @@ const styles$4 = {
|
|
|
2713
2712
|
"noPadding": "pf-m-no-padding",
|
|
2714
2713
|
"block": "pf-m-block",
|
|
2715
2714
|
"small": "pf-m-small",
|
|
2715
|
+
"favorite": "pf-m-favorite",
|
|
2716
|
+
"favorited": "pf-m-favorited",
|
|
2716
2717
|
"clicked": "pf-m-clicked",
|
|
2717
2718
|
"disabled": "pf-m-disabled",
|
|
2718
2719
|
"ariaDisabled": "pf-m-aria-disabled",
|
|
2719
2720
|
"progress": "pf-m-progress",
|
|
2720
2721
|
"inProgress": "pf-m-in-progress",
|
|
2722
|
+
"notify": "pf-m-notify",
|
|
2721
2723
|
"start": "pf-m-start",
|
|
2722
2724
|
"end": "pf-m-end"
|
|
2723
2725
|
}};
|
|
@@ -2746,8 +2748,7 @@ var spinnerSize;
|
|
|
2746
2748
|
})(spinnerSize || (spinnerSize = {}));
|
|
2747
2749
|
const Spinner = (_a) => {
|
|
2748
2750
|
var { className = '', size = 'xl', 'aria-valuetext': ariaValueText = 'Loading...', diameter, isInline = false, 'aria-label': ariaLabel, 'aria-labelledBy': ariaLabelledBy } = _a, props = __rest(_a, ["className", "size", 'aria-valuetext', "diameter", "isInline", 'aria-label', 'aria-labelledBy']);
|
|
2749
|
-
return (
|
|
2750
|
-
React.createElement("circle", { className: styles$3.spinnerPath, cx: "50", cy: "50", r: "45", fill: "none" })));
|
|
2751
|
+
return (jsx("svg", Object.assign({ className: css(styles$3.spinner, isInline ? styles$3.modifiers.inline : styles$3.modifiers[size], className), role: "progressbar", "aria-valuetext": ariaValueText, viewBox: "0 0 100 100" }, (diameter && { style: { [c_spinner_diameter.name]: diameter } }), (ariaLabel && { 'aria-label': ariaLabel }), (ariaLabelledBy && { 'aria-labelledBy': ariaLabelledBy }), (!ariaLabel && !ariaLabelledBy && { 'aria-label': 'Contents' }), props, { children: jsx("circle", { className: styles$3.spinnerPath, cx: "50", cy: "50", r: "45", fill: "none" }) })));
|
|
2751
2752
|
};
|
|
2752
2753
|
Spinner.displayName = 'Spinner';
|
|
2753
2754
|
|
|
@@ -2762,9 +2763,7 @@ const styles$2 = {
|
|
|
2762
2763
|
|
|
2763
2764
|
const Badge = (_a) => {
|
|
2764
2765
|
var { isRead = false, isDisabled = false, className = '', children = '', screenReaderText } = _a, props = __rest(_a, ["isRead", "isDisabled", "className", "children", "screenReaderText"]);
|
|
2765
|
-
return (
|
|
2766
|
-
children,
|
|
2767
|
-
screenReaderText && React.createElement("span", { className: "pf-v6-screen-reader" }, screenReaderText)));
|
|
2766
|
+
return (jsxs("span", Object.assign({}, props, { className: css(styles$2.badge, (isRead ? styles$2.modifiers.read : styles$2.modifiers.unread), isDisabled && styles$2.modifiers.disabled, className), children: [children, screenReaderText && jsx("span", { className: "pf-v6-screen-reader", children: screenReaderText })] })));
|
|
2768
2767
|
};
|
|
2769
2768
|
Badge.displayName = 'Badge';
|
|
2770
2769
|
|
|
@@ -2819,20 +2818,13 @@ const ButtonBase = (_a) => {
|
|
|
2819
2818
|
return 0;
|
|
2820
2819
|
}
|
|
2821
2820
|
};
|
|
2822
|
-
const _icon = icon && (
|
|
2823
|
-
const _children = children &&
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
_icon)) : (React.createElement(React.Fragment, null,
|
|
2830
|
-
_icon,
|
|
2831
|
-
_children)),
|
|
2832
|
-
countOptions && (React.createElement("span", { className: css(styles$4.buttonCount, countOptions.className) },
|
|
2833
|
-
React.createElement(Badge, { isRead: countOptions.isRead, isDisabled: isDisabled }, countOptions.count)))));
|
|
2834
|
-
};
|
|
2835
|
-
const Button = React.forwardRef((props, ref) => (React.createElement(ButtonBase, Object.assign({ innerRef: ref }, props))));
|
|
2821
|
+
const _icon = icon && (jsx("span", { className: css(styles$4.buttonIcon, children && styles$4.modifiers[isIconAlignedAtEnd ? 'end' : 'start']), children: icon }));
|
|
2822
|
+
const _children = children && jsx("span", { className: css('pf-v6-c-button__text'), children: children });
|
|
2823
|
+
// We only want to render the aria-disabled attribute when true, similar to the disabled attribute natively.
|
|
2824
|
+
const shouldRenderAriaDisabled = isAriaDisabled || (!isButtonElement && isDisabled);
|
|
2825
|
+
return (jsxs(Component, Object.assign({}, props, (isAriaDisabled ? preventedEvents : null), (shouldRenderAriaDisabled && { 'aria-disabled': true }), { "aria-label": ariaLabel, className: css(styles$4.button, styles$4.modifiers[variant], isBlock && styles$4.modifiers.block, isDisabled && !isButtonElement && styles$4.modifiers.disabled, isAriaDisabled && styles$4.modifiers.ariaDisabled, isClicked && styles$4.modifiers.clicked, isInline && variant === ButtonVariant.link && styles$4.modifiers.inline, isDanger && (variant === ButtonVariant.secondary || variant === ButtonVariant.link) && styles$4.modifiers.danger, isLoading !== null && variant !== ButtonVariant.plain && styles$4.modifiers.progress, isLoading && styles$4.modifiers.inProgress, hasNoPadding && variant === ButtonVariant.plain && styles$4.modifiers.noPadding, variant === ButtonVariant.stateful && styles$4.modifiers[state], size === ButtonSize.sm && styles$4.modifiers.small, size === ButtonSize.lg && styles$4.modifiers.displayLg, className), disabled: isButtonElement ? isDisabled : null, tabIndex: tabIndex !== null ? tabIndex : getDefaultTabIdx(), type: isButtonElement || isInlineSpan ? type : null, role: isInlineSpan ? 'button' : role, ref: innerRef }, ouiaProps, { children: [isLoading && (jsx("span", { className: css(styles$4.buttonProgress), children: jsx(Spinner, { size: spinnerSize.md, isInline: isInline, "aria-valuetext": spinnerAriaValueText, "aria-label": spinnerAriaLabel, "aria-labelledby": spinnerAriaLabelledBy }) })), isIconAlignedAtEnd ? (jsxs(Fragment, { children: [_children, _icon] })) : (jsxs(Fragment, { children: [_icon, _children] })), countOptions && (jsx("span", { className: css(styles$4.buttonCount, countOptions.className), children: jsx(Badge, { isRead: countOptions.isRead, isDisabled: isDisabled, children: countOptions.count }) }))] })));
|
|
2826
|
+
};
|
|
2827
|
+
const Button = forwardRef((props, ref) => jsx(ButtonBase, Object.assign({ innerRef: ref }, props)));
|
|
2836
2828
|
Button.displayName = 'Button';
|
|
2837
2829
|
|
|
2838
2830
|
const TimesIconConfig = {
|
|
@@ -2869,13 +2861,13 @@ const styles$1 = {
|
|
|
2869
2861
|
|
|
2870
2862
|
const TooltipContent = (_a) => {
|
|
2871
2863
|
var { className, children, isLeftAligned } = _a, props = __rest(_a, ["className", "children", "isLeftAligned"]);
|
|
2872
|
-
return (
|
|
2864
|
+
return (jsx("div", Object.assign({ className: css(styles$1.tooltipContent, isLeftAligned && styles$1.modifiers.textAlignLeft, className) }, props, { children: children })));
|
|
2873
2865
|
};
|
|
2874
2866
|
TooltipContent.displayName = 'TooltipContent';
|
|
2875
2867
|
|
|
2876
2868
|
const TooltipArrow = (_a) => {
|
|
2877
2869
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
2878
|
-
return
|
|
2870
|
+
return jsx("div", Object.assign({ className: css(styles$1.tooltipArrow, className) }, props));
|
|
2879
2871
|
};
|
|
2880
2872
|
TooltipArrow.displayName = 'TooltipArrow';
|
|
2881
2873
|
|
|
@@ -2908,8 +2900,8 @@ const Tooltip = (_a) => {
|
|
|
2908
2900
|
const triggerOnFocus = trigger.includes('focus');
|
|
2909
2901
|
const triggerOnClick = trigger.includes('click');
|
|
2910
2902
|
const triggerManually = trigger === 'manual';
|
|
2911
|
-
const [visible, setVisible] =
|
|
2912
|
-
const popperRef =
|
|
2903
|
+
const [visible, setVisible] = useState(false);
|
|
2904
|
+
const popperRef = createRef();
|
|
2913
2905
|
const onDocumentKeyDown = (event) => {
|
|
2914
2906
|
if (!triggerManually) {
|
|
2915
2907
|
if (event.key === KeyTypes.Escape && visible) {
|
|
@@ -2927,7 +2919,7 @@ const Tooltip = (_a) => {
|
|
|
2927
2919
|
}
|
|
2928
2920
|
}
|
|
2929
2921
|
};
|
|
2930
|
-
|
|
2922
|
+
useEffect(() => {
|
|
2931
2923
|
if (isVisible) {
|
|
2932
2924
|
show();
|
|
2933
2925
|
}
|
|
@@ -2956,11 +2948,9 @@ const Tooltip = (_a) => {
|
|
|
2956
2948
|
'right-end': styles$1.modifiers.rightBottom
|
|
2957
2949
|
};
|
|
2958
2950
|
const hasCustomMaxWidth = maxWidth !== c_tooltip_MaxWidth.value;
|
|
2959
|
-
const content = (
|
|
2951
|
+
const content = (jsxs("div", Object.assign({ "aria-live": ariaLive, className: css(styles$1.tooltip, className), role: "tooltip", id: id, style: {
|
|
2960
2952
|
maxWidth: hasCustomMaxWidth ? maxWidth : null
|
|
2961
|
-
}, ref: popperRef }, rest),
|
|
2962
|
-
React.createElement(TooltipArrow, null),
|
|
2963
|
-
React.createElement(TooltipContent, { isLeftAligned: isContentLeftAligned }, bodyContent)));
|
|
2953
|
+
}, ref: popperRef }, rest, { children: [jsx(TooltipArrow, {}), jsx(TooltipContent, { isLeftAligned: isContentLeftAligned, children: bodyContent })] })));
|
|
2964
2954
|
const onDocumentClick = (event, triggerElement) => {
|
|
2965
2955
|
// event.currentTarget = document
|
|
2966
2956
|
// event.target could be triggerElement or something else
|
|
@@ -2976,14 +2966,14 @@ const Tooltip = (_a) => {
|
|
|
2976
2966
|
};
|
|
2977
2967
|
const addAriaToTrigger = () => {
|
|
2978
2968
|
if (aria === 'describedby' && children && children.props && !children.props['aria-describedby']) {
|
|
2979
|
-
return
|
|
2969
|
+
return cloneElement(children, { 'aria-describedby': id });
|
|
2980
2970
|
}
|
|
2981
2971
|
else if (aria === 'labelledby' && children.props && !children.props['aria-labelledby']) {
|
|
2982
|
-
return
|
|
2972
|
+
return cloneElement(children, { 'aria-labelledby': id });
|
|
2983
2973
|
}
|
|
2984
2974
|
return children;
|
|
2985
2975
|
};
|
|
2986
|
-
return (
|
|
2976
|
+
return (jsx(Popper, { trigger: aria !== 'none' && visible ? addAriaToTrigger() : children, triggerRef: triggerRef, popper: content, popperRef: popperRef, minWidth: minWidth !== undefined ? minWidth : 'revert', appendTo: appendTo, isVisible: visible, positionModifiers: positionModifiers, distance: distance, placement: position, onMouseEnter: triggerOnMouseenter && show, onMouseLeave: triggerOnMouseenter && hide, onPopperMouseEnter: triggerOnMouseenter && show, onPopperMouseLeave: triggerOnMouseenter && hide, onFocus: triggerOnFocus && show, onBlur: triggerOnFocus && hide, onDocumentClick: triggerOnClick && onDocumentClick, onDocumentKeyDown: triggerManually ? null : onDocumentKeyDown, onTriggerEnter: triggerManually ? null : onTriggerEnter, enableFlip: enableFlip, zIndex: zIndex, flipBehavior: flipBehavior, animationDuration: animationDuration, entryDelay: entryDelay, exitDelay: exitDelay, onHidden: onTooltipHidden }));
|
|
2987
2977
|
};
|
|
2988
2978
|
Tooltip.displayName = 'Tooltip';
|
|
2989
2979
|
|
|
@@ -3038,7 +3028,7 @@ const menuStyles = {
|
|
|
3038
3028
|
}
|
|
3039
3029
|
};
|
|
3040
3030
|
|
|
3041
|
-
const MenuContext =
|
|
3031
|
+
const MenuContext = createContext({
|
|
3042
3032
|
menuId: null,
|
|
3043
3033
|
parentMenu: null,
|
|
3044
3034
|
onActionClick: () => null,
|
|
@@ -3055,15 +3045,15 @@ const MenuContext = React.createContext({
|
|
|
3055
3045
|
disableHover: false,
|
|
3056
3046
|
role: 'menu'
|
|
3057
3047
|
});
|
|
3058
|
-
const MenuItemContext =
|
|
3048
|
+
const MenuItemContext = createContext({
|
|
3059
3049
|
itemId: null,
|
|
3060
3050
|
isDisabled: false
|
|
3061
3051
|
});
|
|
3062
3052
|
|
|
3063
|
-
class MenuBase extends
|
|
3053
|
+
class MenuBase extends Component {
|
|
3064
3054
|
constructor(props) {
|
|
3065
3055
|
super(props);
|
|
3066
|
-
this.menuRef =
|
|
3056
|
+
this.menuRef = createRef();
|
|
3067
3057
|
this.activeMenu = null;
|
|
3068
3058
|
this.state = {
|
|
3069
3059
|
ouiaStateId: getDefaultOUIAId(Menu.displayName),
|
|
@@ -3190,7 +3180,7 @@ class MenuBase extends React.Component {
|
|
|
3190
3180
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
3191
3181
|
props = __rest(_a, ["id", "children", "className", "onSelect", "selected", "onActionClick", "ouiaId", "ouiaSafe", "containsFlyout", "containsDrilldown", "isMenuDrilledIn", "isPlain", "isScrollable", "drilldownItemPath", "drilledInMenus", "onDrillIn", "onDrillOut", "onGetMenuHeight", "parentMenu", "activeItemId", "innerRef", "isRootMenu", "activeMenu", "role", "isNavFlyout"]);
|
|
3192
3182
|
const _isMenuDrilledIn = isMenuDrilledIn || (drilledInMenus && drilledInMenus.includes(id)) || false;
|
|
3193
|
-
return (
|
|
3183
|
+
return (jsxs(MenuContext.Provider, { value: {
|
|
3194
3184
|
menuId: id,
|
|
3195
3185
|
parentMenu: parentMenu || id,
|
|
3196
3186
|
onSelect,
|
|
@@ -3206,22 +3196,20 @@ class MenuBase extends React.Component {
|
|
|
3206
3196
|
setFlyoutRef: (flyoutRef) => this.setState({ flyoutRef }),
|
|
3207
3197
|
disableHover: this.state.disableHover,
|
|
3208
3198
|
role
|
|
3209
|
-
}
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
navigableElement.
|
|
3218
|
-
|
|
3219
|
-
navigableElement.
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
document.activeElement.tagName === 'INPUT'), noEnterHandling: true, noSpaceHandling: true })),
|
|
3224
|
-
React.createElement("div", Object.assign({ id: id, className: css(menuStyles.menu, isPlain && menuStyles.modifiers.plain, isScrollable && menuStyles.modifiers.scrollable, containsFlyout && menuStyles.modifiers.flyout, isNavFlyout && 'pf-m-nav', containsDrilldown && menuStyles.modifiers.drilldown, _isMenuDrilledIn && menuStyles.modifiers.drilledIn, className), ref: this.menuRef }, getOUIAProps(Menu.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props), children)));
|
|
3199
|
+
}, children: [isRootMenu && (jsx(KeyboardHandler, { containerRef: this.menuRef || null, additionalKeyHandler: this.handleExtraKeys, createNavigableElements: this.createNavigableElements, isActiveElement: (element) => document.activeElement.closest('li') === element || // if element is a basic MenuItem
|
|
3200
|
+
document.activeElement.parentElement === element ||
|
|
3201
|
+
document.activeElement.closest(`.${menuStyles.menuSearch}`) === element || // if element is a MenuSearch
|
|
3202
|
+
(document.activeElement.closest('ol') && document.activeElement.closest('ol').firstChild === element), getFocusableElement: (navigableElement) => {
|
|
3203
|
+
var _a, _b;
|
|
3204
|
+
return ((navigableElement === null || navigableElement === void 0 ? void 0 : navigableElement.tagName) === 'DIV' && navigableElement.querySelector('input')) || // for MenuSearchInput
|
|
3205
|
+
(((_a = navigableElement.firstChild) === null || _a === void 0 ? void 0 : _a.tagName) === 'LABEL' &&
|
|
3206
|
+
navigableElement.querySelector('input')) || // for MenuItem checkboxes
|
|
3207
|
+
(((_b = navigableElement.firstChild) === null || _b === void 0 ? void 0 : _b.tagName) === 'DIV' &&
|
|
3208
|
+
navigableElement.querySelector('a, button, input')) || // For aria-disabled element that is rendered inside a div with "display: contents" styling
|
|
3209
|
+
navigableElement.firstChild;
|
|
3210
|
+
}, noHorizontalArrowHandling: document.activeElement &&
|
|
3211
|
+
(document.activeElement.classList.contains(breadcrumbStyles.breadcrumbLink) ||
|
|
3212
|
+
document.activeElement.tagName === 'INPUT'), noEnterHandling: true, noSpaceHandling: true })), jsx("div", Object.assign({ id: id, className: css(menuStyles.menu, isPlain && menuStyles.modifiers.plain, isScrollable && menuStyles.modifiers.scrollable, containsFlyout && menuStyles.modifiers.flyout, isNavFlyout && 'pf-m-nav', containsDrilldown && menuStyles.modifiers.drilldown, _isMenuDrilledIn && menuStyles.modifiers.drilledIn, className), ref: this.menuRef }, getOUIAProps(Menu.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props, { children: children }))] }));
|
|
3225
3213
|
}
|
|
3226
3214
|
}
|
|
3227
3215
|
MenuBase.displayName = 'Menu';
|
|
@@ -3233,7 +3221,7 @@ MenuBase.defaultProps = {
|
|
|
3233
3221
|
isScrollable: false,
|
|
3234
3222
|
role: 'menu'
|
|
3235
3223
|
};
|
|
3236
|
-
const Menu =
|
|
3224
|
+
const Menu = forwardRef((props, ref) => (jsx(MenuBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3237
3225
|
Menu.displayName = 'Menu';
|
|
3238
3226
|
|
|
3239
3227
|
const c_menu__content_Height = {
|
|
@@ -3242,9 +3230,9 @@ const c_menu__content_Height = {
|
|
|
3242
3230
|
const c_menu__content_MaxHeight = {
|
|
3243
3231
|
"name": "--pf-v6-c-menu__content--MaxHeight"};
|
|
3244
3232
|
|
|
3245
|
-
const MenuContent =
|
|
3233
|
+
const MenuContent = forwardRef((props, ref) => {
|
|
3246
3234
|
const { getHeight, children, menuHeight, maxMenuHeight } = props, rest = __rest(props, ["getHeight", "children", "menuHeight", "maxMenuHeight"]);
|
|
3247
|
-
const menuContentRef =
|
|
3235
|
+
const menuContentRef = createRef();
|
|
3248
3236
|
const refCallback = (el, menuId, onGetMenuHeight) => {
|
|
3249
3237
|
if (el) {
|
|
3250
3238
|
let clientHeight = el.clientHeight;
|
|
@@ -3269,7 +3257,9 @@ const MenuContent = React.forwardRef((props, ref) => {
|
|
|
3269
3257
|
}
|
|
3270
3258
|
return ref || menuContentRef;
|
|
3271
3259
|
};
|
|
3272
|
-
return (
|
|
3260
|
+
return (jsx(MenuContext.Consumer, { children: ({ menuId, onGetMenuHeight }) => (jsx("div", Object.assign({}, rest, { className: css(menuStyles.menuContent, props.className), ref: (el) => {
|
|
3261
|
+
refCallback(el, menuId, onGetMenuHeight);
|
|
3262
|
+
}, style: Object.assign(Object.assign({}, (menuHeight && { [c_menu__content_Height.name]: menuHeight })), (maxMenuHeight && { [c_menu__content_MaxHeight.name]: maxMenuHeight })), children: children }))) }));
|
|
3273
3263
|
});
|
|
3274
3264
|
MenuContent.displayName = 'MenuContent';
|
|
3275
3265
|
|
|
@@ -3330,7 +3320,7 @@ const checkStyles = {
|
|
|
3330
3320
|
|
|
3331
3321
|
// tslint:disable-next-line:no-empty
|
|
3332
3322
|
const defaultOnChange = () => { };
|
|
3333
|
-
class Checkbox extends
|
|
3323
|
+
class Checkbox extends Component {
|
|
3334
3324
|
constructor(props) {
|
|
3335
3325
|
super(props);
|
|
3336
3326
|
this.handleChange = (event) => {
|
|
@@ -3356,22 +3346,15 @@ class Checkbox extends React.Component {
|
|
|
3356
3346
|
if ([false, true].includes(defaultChecked)) {
|
|
3357
3347
|
checkedProps.defaultChecked = defaultChecked;
|
|
3358
3348
|
}
|
|
3359
|
-
const inputRendered = (
|
|
3349
|
+
const inputRendered = (jsx("input", Object.assign({}, props, { className: css(checkStyles.checkInput, inputClassName), type: "checkbox", onChange: this.handleChange, "aria-invalid": !isValid, "aria-label": ariaLabel, disabled: isDisabled, required: isRequired, ref: (elem) => {
|
|
3350
|
+
elem && (elem.indeterminate = isChecked === null);
|
|
3351
|
+
} }, checkedProps, getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe))));
|
|
3360
3352
|
const wrapWithLabel = (isLabelWrapped && !component) || component === 'label';
|
|
3361
3353
|
const Label = wrapWithLabel ? 'span' : 'label';
|
|
3362
|
-
const labelRendered = label ? (
|
|
3363
|
-
label,
|
|
3364
|
-
isRequired && (React.createElement("span", { className: css(checkStyles.checkLabelRequired), "aria-hidden": "true" }, ASTERISK)))) : null;
|
|
3354
|
+
const labelRendered = label ? (jsxs(Label, { className: css(checkStyles.checkLabel, isDisabled && checkStyles.modifiers.disabled), htmlFor: !wrapWithLabel ? props.id : undefined, children: [label, isRequired && (jsx("span", { className: css(checkStyles.checkLabelRequired), "aria-hidden": "true", children: ASTERISK }))] })) : null;
|
|
3365
3355
|
const Component = component !== null && component !== void 0 ? component : (wrapWithLabel ? 'label' : 'div');
|
|
3366
3356
|
checkedProps.checked = checkedProps.checked === null ? false : checkedProps.checked;
|
|
3367
|
-
return (
|
|
3368
|
-
labelPosition === 'start' ? (React.createElement(React.Fragment, null,
|
|
3369
|
-
labelRendered,
|
|
3370
|
-
inputRendered)) : (React.createElement(React.Fragment, null,
|
|
3371
|
-
inputRendered,
|
|
3372
|
-
labelRendered)),
|
|
3373
|
-
description && React.createElement("span", { className: css(checkStyles.checkDescription) }, description),
|
|
3374
|
-
body && React.createElement("span", { className: css(checkStyles.checkBody) }, body)));
|
|
3357
|
+
return (jsxs(Component, { className: css(checkStyles.check, !label && checkStyles.modifiers.standalone, className), htmlFor: wrapWithLabel ? props.id : undefined, children: [labelPosition === 'start' ? (jsxs(Fragment, { children: [labelRendered, inputRendered] })) : (jsxs(Fragment, { children: [inputRendered, labelRendered] })), description && jsx("span", { className: css(checkStyles.checkDescription), children: description }), body && jsx("span", { className: css(checkStyles.checkBody), children: body })] }));
|
|
3375
3358
|
}
|
|
3376
3359
|
}
|
|
3377
3360
|
Checkbox.displayName = 'Checkbox';
|
|
@@ -3399,34 +3382,35 @@ const StarIcon = createIcon(StarIconConfig);
|
|
|
3399
3382
|
|
|
3400
3383
|
const MenuItemActionBase = (_a) => {
|
|
3401
3384
|
var { className, icon, onClick, 'aria-label': ariaLabel, isFavorited = null, isDisabled, actionId, innerRef } = _a, props = __rest(_a, ["className", "icon", "onClick", 'aria-label', "isFavorited", "isDisabled", "actionId", "innerRef"]);
|
|
3402
|
-
return (
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
}))));
|
|
3385
|
+
return (jsx(MenuContext.Consumer, { children: ({ onActionClick }) => (jsx(MenuItemContext.Consumer, { children: ({ itemId, isDisabled: isDisabledContext }) => {
|
|
3386
|
+
const onClickButton = (event) => {
|
|
3387
|
+
// event specified on the MenuItemAction
|
|
3388
|
+
onClick && onClick(event);
|
|
3389
|
+
// event specified on the Menu
|
|
3390
|
+
onActionClick && onActionClick(event, itemId, actionId);
|
|
3391
|
+
};
|
|
3392
|
+
return (jsx("div", Object.assign({ className: css(menuStyles.menuItemAction, isFavorited !== null && 'pf-m-favorite', isFavorited && menuStyles.modifiers.favorited, className) }, props, { children: jsx(Button, { "aria-label": ariaLabel, onClick: onClickButton, ref: innerRef, role: "menuitem", variant: "plain", tabIndex: -1, isDisabled: isDisabled || isDisabledContext, icon: icon === 'favorites' || isFavorited !== null ? jsx(StarIcon, {}) : icon }) })));
|
|
3393
|
+
} })) }));
|
|
3412
3394
|
};
|
|
3413
|
-
const MenuItemAction =
|
|
3395
|
+
const MenuItemAction = forwardRef((props, ref) => (jsx(MenuItemActionBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3414
3396
|
MenuItemAction.displayName = 'MenuItemAction';
|
|
3415
3397
|
|
|
3416
|
-
const FlyoutContext =
|
|
3398
|
+
const FlyoutContext = createContext({
|
|
3417
3399
|
direction: 'right'
|
|
3418
3400
|
});
|
|
3419
3401
|
const MenuItemBase = (_a) => {
|
|
3420
3402
|
var { children, className, itemId = null, to, hasCheckbox = false, isActive = null, isFavorited = null, isLoadButton = false, isLoading = false, flyoutMenu, direction, description = null, onClick = () => { }, component = 'button', isDisabled = false, isAriaDisabled = false, isExternalLink = false, isSelected = null, isFocused, isDanger = false, icon, actions, onShowFlyout, drilldownMenu, isOnPath, innerRef, id, 'aria-label': ariaLabel, tooltipProps, rel, target, download } = _a, props = __rest(_a, ["children", "className", "itemId", "to", "hasCheckbox", "isActive", "isFavorited", "isLoadButton", "isLoading", "flyoutMenu", "direction", "description", "onClick", "component", "isDisabled", "isAriaDisabled", "isExternalLink", "isSelected", "isFocused", "isDanger", "icon", "actions", "onShowFlyout", "drilldownMenu", "isOnPath", "innerRef", "id", 'aria-label', "tooltipProps", "rel", "target", "download"]);
|
|
3421
|
-
const { menuId, parentMenu, onSelect, onActionClick, activeItemId, selected, drilldownItemPath, onDrillIn, onDrillOut, flyoutRef, setFlyoutRef, disableHover, role: menuRole } =
|
|
3403
|
+
const { menuId, parentMenu, onSelect, onActionClick, activeItemId, selected, drilldownItemPath, onDrillIn, onDrillOut, flyoutRef, setFlyoutRef, disableHover, role: menuRole } = useContext(MenuContext);
|
|
3422
3404
|
let Component = (to ? 'a' : component);
|
|
3423
3405
|
if (hasCheckbox && !to) {
|
|
3424
3406
|
Component = 'label';
|
|
3425
3407
|
}
|
|
3426
|
-
const [flyoutTarget, setFlyoutTarget] =
|
|
3427
|
-
const flyoutContext =
|
|
3428
|
-
const [flyoutXDirection, setFlyoutXDirection] =
|
|
3429
|
-
const ref =
|
|
3408
|
+
const [flyoutTarget, setFlyoutTarget] = useState(null);
|
|
3409
|
+
const flyoutContext = useContext(FlyoutContext);
|
|
3410
|
+
const [flyoutXDirection, setFlyoutXDirection] = useState(flyoutContext.direction);
|
|
3411
|
+
const ref = useRef(undefined);
|
|
3412
|
+
const privateRef = useRef(undefined);
|
|
3413
|
+
const innerComponentRef = innerRef || privateRef;
|
|
3430
3414
|
const flyoutVisible = ref === flyoutRef;
|
|
3431
3415
|
const hasFlyout = flyoutMenu !== undefined;
|
|
3432
3416
|
const showFlyout = (show) => {
|
|
@@ -3477,10 +3461,10 @@ const MenuItemBase = (_a) => {
|
|
|
3477
3461
|
}
|
|
3478
3462
|
}
|
|
3479
3463
|
}, [flyoutVisible, flyoutMenu]);
|
|
3480
|
-
|
|
3464
|
+
useEffect(() => {
|
|
3481
3465
|
setFlyoutXDirection(flyoutContext.direction);
|
|
3482
3466
|
}, [flyoutContext]);
|
|
3483
|
-
|
|
3467
|
+
useEffect(() => {
|
|
3484
3468
|
if (flyoutTarget) {
|
|
3485
3469
|
if (flyoutVisible) {
|
|
3486
3470
|
const flyoutMenu = flyoutTarget.nextElementSibling;
|
|
@@ -3591,7 +3575,7 @@ const MenuItemBase = (_a) => {
|
|
|
3591
3575
|
setFlyoutRef(null);
|
|
3592
3576
|
}
|
|
3593
3577
|
};
|
|
3594
|
-
|
|
3578
|
+
useEffect(() => {
|
|
3595
3579
|
if (isFocused && ref.current) {
|
|
3596
3580
|
const itemEl = ref.current;
|
|
3597
3581
|
const parentListEl = itemEl.parentElement;
|
|
@@ -3605,53 +3589,31 @@ const MenuItemBase = (_a) => {
|
|
|
3605
3589
|
}
|
|
3606
3590
|
}, [isFocused]);
|
|
3607
3591
|
const isSelectMenu = menuRole === 'listbox';
|
|
3608
|
-
const renderItem = (
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
hasCheckbox && (React.createElement("span", { className: css(menuStyles.menuItemCheck) },
|
|
3626
|
-
React.createElement(Checkbox, { id: randomId, component: "span", isChecked: isSelected || false, onChange: (event) => onItemSelect(event, onSelect), isDisabled: isDisabled, "aria-disabled": isAriaDisabled }))),
|
|
3627
|
-
React.createElement("span", { className: css(menuStyles.menuItemText) }, children),
|
|
3628
|
-
isExternalLink && (React.createElement("span", { className: css(menuStyles.menuItemExternalIcon) },
|
|
3629
|
-
React.createElement(ExternalLinkAltIcon, { "aria-hidden": true }))),
|
|
3630
|
-
(flyoutMenu || direction === 'down') && (React.createElement("span", { className: css(menuStyles.menuItemToggleIcon) },
|
|
3631
|
-
React.createElement(AngleRightIcon, { "aria-hidden": true }))),
|
|
3632
|
-
getIsSelected() && (React.createElement("span", { className: css(menuStyles.menuItemSelectIcon) },
|
|
3633
|
-
React.createElement(CheckIcon, { "aria-hidden": true })))),
|
|
3634
|
-
description && direction !== 'up' && (React.createElement("span", { className: css(menuStyles.menuItemDescription) },
|
|
3635
|
-
React.createElement("span", null, description)))))),
|
|
3636
|
-
flyoutVisible && (React.createElement(MenuContext.Provider, { value: { disableHover } },
|
|
3637
|
-
React.createElement(FlyoutContext.Provider, { value: { direction: flyoutXDirection } }, flyoutMenu))),
|
|
3638
|
-
typeof drilldownMenu === 'function' ? drilldownMenu() : drilldownMenu,
|
|
3639
|
-
React.createElement(MenuItemContext.Provider, { value: { itemId, isDisabled } },
|
|
3640
|
-
actions,
|
|
3641
|
-
isFavorited !== null && (React.createElement(MenuItemAction, { icon: "favorites", isFavorited: isFavorited, "aria-label": isFavorited ? 'starred' : 'not starred', onClick: (event) => onActionClick(event, itemId), tabIndex: -1, actionId: "fav" })))));
|
|
3642
|
-
return (React.createElement("li", Object.assign({ className: css(menuStyles.menuListItem, isDisabled && menuStyles.modifiers.disabled, isAriaDisabled && menuStyles.modifiers.ariaDisabled, _isOnPath && menuStyles.modifiers.currentPath, isLoadButton && menuStyles.modifiers.load, isLoading && menuStyles.modifiers.loading, isFocused && 'pf-m-focus', isDanger && menuStyles.modifiers.danger, className), onMouseOver: () => {
|
|
3643
|
-
if (!isAriaDisabled) {
|
|
3644
|
-
onMouseOver();
|
|
3645
|
-
}
|
|
3646
|
-
} }, (flyoutMenu && !isAriaDisabled && { onKeyDown: handleFlyout }), { ref: ref, role: !hasCheckbox ? 'none' : 'menuitem' }, (hasCheckbox && { 'aria-label': ariaLabel }), props), tooltipProps ? React.createElement(Tooltip, Object.assign({}, tooltipProps), renderItem) : renderItem));
|
|
3592
|
+
const renderItem = (jsxs(Fragment, { children: [jsx(GenerateId, { children: (randomId) => (jsxs(Component, Object.assign({ id: id, tabIndex: -1, className: css(menuStyles.menuItem, getIsSelected() && !hasCheckbox && menuStyles.modifiers.selected, className), "aria-current": getAriaCurrent() }, (!hasCheckbox && { disabled: isDisabled, 'aria-label': ariaLabel }), (!hasCheckbox && !flyoutMenu && { role: isSelectMenu ? 'option' : 'menuitem' }), (!hasCheckbox && !flyoutMenu && isSelectMenu && { 'aria-selected': getIsSelected() }), { ref: innerComponentRef }, (!hasCheckbox && {
|
|
3593
|
+
onClick: (event) => {
|
|
3594
|
+
if (!isAriaDisabled) {
|
|
3595
|
+
onItemSelect(event, onSelect);
|
|
3596
|
+
drill && drill(event);
|
|
3597
|
+
flyoutMenu && handleFlyout(event);
|
|
3598
|
+
}
|
|
3599
|
+
else {
|
|
3600
|
+
event.preventDefault();
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
}), (hasCheckbox && { htmlFor: randomId }), additionalProps, { children: [jsxs("span", { className: css(menuStyles.menuItemMain), children: [direction === 'up' && (jsx("span", { className: css(menuStyles.menuItemToggleIcon), children: jsx(AngleLeftIcon, {}) })), icon && jsx("span", { className: css(menuStyles.menuItemIcon), children: icon }), hasCheckbox && (jsx("span", { className: css(menuStyles.menuItemCheck), children: jsx(Checkbox, { id: randomId, component: "span", isChecked: isSelected || false, onChange: (event) => onItemSelect(event, onSelect), isDisabled: isDisabled, "aria-disabled": isAriaDisabled }) })), jsx("span", { className: css(menuStyles.menuItemText), children: children }), isExternalLink && (jsx("span", { className: css(menuStyles.menuItemExternalIcon), children: jsx(ExternalLinkAltIcon, {}) })), (flyoutMenu || direction === 'down') && (jsx("span", { className: css(menuStyles.menuItemToggleIcon), children: jsx(AngleRightIcon, {}) })), getIsSelected() && (jsx("span", { className: css(menuStyles.menuItemSelectIcon), children: jsx(CheckIcon, {}) }))] }), description && direction !== 'up' && (jsx("span", { className: css(menuStyles.menuItemDescription), children: jsx("span", { children: description }) }))] }))) }), flyoutVisible && (jsx(MenuContext.Provider, { value: { disableHover }, children: jsx(FlyoutContext.Provider, { value: { direction: flyoutXDirection }, children: flyoutMenu }) })), typeof drilldownMenu === 'function' ? drilldownMenu() : drilldownMenu, jsxs(MenuItemContext.Provider, { value: { itemId, isDisabled }, children: [actions, isFavorited !== null && (jsx(MenuItemAction, { icon: "favorites", isFavorited: isFavorited, "aria-label": isFavorited ? 'starred' : 'not starred', onClick: (event) => onActionClick(event, itemId), tabIndex: -1, actionId: "fav" }))] })] }));
|
|
3604
|
+
return (jsxs(Fragment, { children: [jsx("li", Object.assign({ className: css(menuStyles.menuListItem, isDisabled && menuStyles.modifiers.disabled, isAriaDisabled && menuStyles.modifiers.ariaDisabled, _isOnPath && menuStyles.modifiers.currentPath, isLoadButton && menuStyles.modifiers.load, isLoading && menuStyles.modifiers.loading, isFocused && 'pf-m-focus', isDanger && menuStyles.modifiers.danger, className), onMouseOver: () => {
|
|
3605
|
+
if (!isAriaDisabled) {
|
|
3606
|
+
onMouseOver();
|
|
3607
|
+
}
|
|
3608
|
+
} }, (flyoutMenu && !isAriaDisabled && { onKeyDown: handleFlyout }), { ref: ref, role: !hasCheckbox ? 'none' : 'menuitem' }, (hasCheckbox && { 'aria-label': ariaLabel }), props, { children: renderItem })), tooltipProps && jsx(Tooltip, Object.assign({}, tooltipProps, { triggerRef: innerComponentRef }))] }));
|
|
3647
3609
|
};
|
|
3648
|
-
const MenuItem =
|
|
3610
|
+
const MenuItem = forwardRef((props, ref) => (jsx(MenuItemBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3649
3611
|
MenuItem.displayName = 'MenuItem';
|
|
3650
3612
|
|
|
3651
3613
|
const MenuList = (_a) => {
|
|
3652
3614
|
var { children = null, className, isAriaMultiselectable = false, 'aria-label': ariaLabel } = _a, props = __rest(_a, ["children", "className", "isAriaMultiselectable", 'aria-label']);
|
|
3653
|
-
const { role } =
|
|
3654
|
-
return (
|
|
3615
|
+
const { role } = useContext(MenuContext);
|
|
3616
|
+
return (jsx("ul", Object.assign({ role: role }, (role === 'listbox' && { 'aria-multiselectable': isAriaMultiselectable }), { className: css(menuStyles.menuList, className), "aria-label": ariaLabel }, props, { children: children })));
|
|
3655
3617
|
};
|
|
3656
3618
|
MenuList.displayName = 'MenuList';
|
|
3657
3619
|
|
|
@@ -3706,7 +3668,7 @@ var MenuToggleSize;
|
|
|
3706
3668
|
MenuToggleSize["default"] = "default";
|
|
3707
3669
|
MenuToggleSize["sm"] = "sm";
|
|
3708
3670
|
})(MenuToggleSize || (MenuToggleSize = {}));
|
|
3709
|
-
class MenuToggleBase extends
|
|
3671
|
+
class MenuToggleBase extends Component {
|
|
3710
3672
|
constructor() {
|
|
3711
3673
|
super(...arguments);
|
|
3712
3674
|
this.displayName = 'MenuToggleBase';
|
|
@@ -3724,38 +3686,27 @@ class MenuToggleBase extends React.Component {
|
|
|
3724
3686
|
if (!statusIcon) {
|
|
3725
3687
|
switch (status) {
|
|
3726
3688
|
case MenuToggleStatus.success:
|
|
3727
|
-
_statusIcon =
|
|
3689
|
+
_statusIcon = jsx(CheckCircleIcon, {});
|
|
3728
3690
|
break;
|
|
3729
3691
|
case MenuToggleStatus.warning:
|
|
3730
|
-
_statusIcon =
|
|
3692
|
+
_statusIcon = jsx(ExclamationTriangleIcon, {});
|
|
3731
3693
|
break;
|
|
3732
3694
|
case MenuToggleStatus.danger:
|
|
3733
|
-
_statusIcon =
|
|
3695
|
+
_statusIcon = jsx(ExclamationCircleIcon, {});
|
|
3734
3696
|
break;
|
|
3735
3697
|
}
|
|
3736
3698
|
}
|
|
3737
|
-
const toggleControls = (
|
|
3738
|
-
|
|
3739
|
-
React.createElement("span", { className: css(styles.menuToggleToggleIcon) },
|
|
3740
|
-
React.createElement(CaretDownIcon, { "aria-hidden": true }))));
|
|
3741
|
-
const content = (React.createElement(React.Fragment, null,
|
|
3742
|
-
icon && React.createElement("span", { className: css(styles.menuToggleIcon) }, icon),
|
|
3743
|
-
isTypeahead ? children : children && React.createElement("span", { className: css(styles.menuToggleText) }, children),
|
|
3744
|
-
React.isValidElement(badge) && React.createElement("span", { className: css(styles.menuToggleCount) }, badge),
|
|
3745
|
-
isTypeahead ? (React.createElement("button", Object.assign({ type: "button", className: css(styles.menuToggleButton), "aria-expanded": isExpanded, onClick: onClick, "aria-label": ariaLabel || 'Menu toggle', tabIndex: -1 }, ouiaProps), toggleControls)) : (!isPlain && toggleControls)));
|
|
3699
|
+
const toggleControls = (jsxs("span", { className: css(styles.menuToggleControls), children: [status !== undefined && jsx("span", { className: css(styles.menuToggleStatusIcon), children: _statusIcon }), jsx("span", { className: css(styles.menuToggleToggleIcon), children: jsx(CaretDownIcon, {}) })] }));
|
|
3700
|
+
const content = (jsxs(Fragment, { children: [icon && jsx("span", { className: css(styles.menuToggleIcon), children: icon }), isTypeahead ? children : children && jsx("span", { className: css(styles.menuToggleText), children: children }), isValidElement(badge) && jsx("span", { className: css(styles.menuToggleCount), children: badge }), isTypeahead ? (jsx("button", Object.assign({ type: "button", className: css(styles.menuToggleButton), "aria-expanded": isExpanded, onClick: onClick, "aria-label": ariaLabel || 'Menu toggle', tabIndex: -1 }, ouiaProps, { children: toggleControls }))) : (!isPlain && toggleControls)] }));
|
|
3746
3701
|
const commonStyles = css(styles.menuToggle, isExpanded && styles.modifiers.expanded, variant === 'primary' && styles.modifiers.primary, variant === 'secondary' && styles.modifiers.secondary, status && styles.modifiers[status], (isPlain || isPlainText) && styles.modifiers.plain, isPlainText && 'pf-m-text', isFullHeight && styles.modifiers.fullHeight, isFullWidth && styles.modifiers.fullWidth, isDisabled && styles.modifiers.disabled, isPlaceholder && styles.modifiers.placeholder, size === MenuToggleSize.sm && styles.modifiers.small, className);
|
|
3747
3702
|
const componentProps = Object.assign(Object.assign({ children: content }, (isDisabled && { disabled: true })), otherProps);
|
|
3748
3703
|
if (isTypeahead) {
|
|
3749
|
-
return (
|
|
3704
|
+
return (jsx("div", Object.assign({ ref: innerRef, className: css(commonStyles, styles.modifiers.typeahead) }, componentProps)));
|
|
3750
3705
|
}
|
|
3751
3706
|
if (splitButtonItems) {
|
|
3752
|
-
return (
|
|
3753
|
-
splitButtonItems,
|
|
3754
|
-
React.createElement("button", Object.assign({ className: css(styles.menuToggleButton, children && styles.modifiers.text), type: "button", "aria-expanded": isExpanded, "aria-label": ariaLabel, disabled: isDisabled, onClick: onClick }, otherProps, ouiaProps),
|
|
3755
|
-
children && React.createElement("span", { className: css(styles.menuToggleText) }, children),
|
|
3756
|
-
toggleControls)));
|
|
3707
|
+
return (jsxs("div", { ref: innerRef, className: css(commonStyles, styles.modifiers.splitButton), children: [splitButtonItems, jsxs("button", Object.assign({ className: css(styles.menuToggleButton, children && styles.modifiers.text), type: "button", "aria-expanded": isExpanded, "aria-label": ariaLabel, disabled: isDisabled, onClick: onClick }, otherProps, ouiaProps, { children: [children && jsx("span", { className: css(styles.menuToggleText), children: children }), toggleControls] }))] }));
|
|
3757
3708
|
}
|
|
3758
|
-
return (
|
|
3709
|
+
return (jsx("button", Object.assign({ className: css(commonStyles), type: "button", "aria-label": ariaLabel, "aria-expanded": isExpanded, ref: innerRef, disabled: isDisabled, onClick: onClick }, componentProps, ouiaProps)));
|
|
3759
3710
|
}
|
|
3760
3711
|
}
|
|
3761
3712
|
MenuToggleBase.defaultProps = {
|
|
@@ -3768,7 +3719,7 @@ MenuToggleBase.defaultProps = {
|
|
|
3768
3719
|
size: 'default',
|
|
3769
3720
|
ouiaSafe: true
|
|
3770
3721
|
};
|
|
3771
|
-
const MenuToggle =
|
|
3722
|
+
const MenuToggle = forwardRef((props, ref) => (jsx(MenuToggleBase, Object.assign({ innerRef: ref }, props))));
|
|
3772
3723
|
MenuToggle.displayName = 'MenuToggle';
|
|
3773
3724
|
|
|
3774
3725
|
const dividerStyles = {
|
|
@@ -3857,21 +3808,21 @@ var DividerVariant;
|
|
|
3857
3808
|
const Divider = (_a) => {
|
|
3858
3809
|
var { className, component = DividerVariant.hr, inset, orientation } = _a, props = __rest(_a, ["className", "component", "inset", "orientation"]);
|
|
3859
3810
|
const Component = component;
|
|
3860
|
-
return (
|
|
3811
|
+
return (jsx(Component, Object.assign({ className: css(dividerStyles.divider, formatBreakpointMods(inset, dividerStyles), formatBreakpointMods(orientation, dividerStyles), className) }, (component !== 'hr' && { role: 'separator' }), props)));
|
|
3861
3812
|
};
|
|
3862
3813
|
Divider.displayName = 'Divider';
|
|
3863
3814
|
|
|
3864
3815
|
const DropdownBase = (_a) => {
|
|
3865
3816
|
var { children, className, onSelect, isOpen, toggle, shouldFocusToggleOnSelect = false, onOpenChange, onToggleKeydown, isPlain, isScrollable, innerRef, ouiaId, ouiaSafe = true, zIndex = 9999, popperProps, onOpenChangeKeys = ['Escape', 'Tab'], menuHeight, maxMenuHeight, shouldFocusFirstItemOnOpen = false, shouldPreventScrollOnItemFocus = true, focusTimeoutDelay = 0 } = _a, props = __rest(_a, ["children", "className", "onSelect", "isOpen", "toggle", "shouldFocusToggleOnSelect", "onOpenChange", "onToggleKeydown", "isPlain", "isScrollable", "innerRef", "ouiaId", "ouiaSafe", "zIndex", "popperProps", "onOpenChangeKeys", "menuHeight", "maxMenuHeight", "shouldFocusFirstItemOnOpen", "shouldPreventScrollOnItemFocus", "focusTimeoutDelay"]);
|
|
3866
|
-
const localMenuRef =
|
|
3867
|
-
const localToggleRef =
|
|
3817
|
+
const localMenuRef = useRef(undefined);
|
|
3818
|
+
const localToggleRef = useRef(undefined);
|
|
3868
3819
|
const ouiaProps = useOUIAProps(Dropdown.displayName, ouiaId, ouiaSafe);
|
|
3869
3820
|
const menuRef = innerRef || localMenuRef;
|
|
3870
3821
|
const toggleRef = typeof toggle === 'function' || (typeof toggle !== 'function' && !toggle.toggleRef)
|
|
3871
3822
|
? localToggleRef
|
|
3872
3823
|
: toggle === null || toggle === void 0 ? void 0 : toggle.toggleRef;
|
|
3873
|
-
const prevIsOpen =
|
|
3874
|
-
|
|
3824
|
+
const prevIsOpen = useRef(isOpen);
|
|
3825
|
+
useEffect(() => {
|
|
3875
3826
|
// menu was opened, focus on first menu item
|
|
3876
3827
|
if (prevIsOpen.current === false && isOpen === true && shouldFocusFirstItemOnOpen) {
|
|
3877
3828
|
setTimeout(() => {
|
|
@@ -3883,7 +3834,7 @@ const DropdownBase = (_a) => {
|
|
|
3883
3834
|
prevIsOpen.current = isOpen;
|
|
3884
3835
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3885
3836
|
}, [isOpen]);
|
|
3886
|
-
|
|
3837
|
+
useEffect(() => {
|
|
3887
3838
|
const handleMenuKeys = (event) => {
|
|
3888
3839
|
var _a, _b, _c, _d;
|
|
3889
3840
|
// Close the menu on tab or escape if onOpenChange is provided
|
|
@@ -3931,28 +3882,27 @@ const DropdownBase = (_a) => {
|
|
|
3931
3882
|
focusTimeoutDelay
|
|
3932
3883
|
]);
|
|
3933
3884
|
const scrollable = maxMenuHeight !== undefined || menuHeight !== undefined || isScrollable;
|
|
3934
|
-
const menu = (
|
|
3885
|
+
const menu = (jsx(Menu, Object.assign({ className: css(className), ref: menuRef, onSelect: (event, value) => {
|
|
3935
3886
|
var _a;
|
|
3936
3887
|
onSelect && onSelect(event, value);
|
|
3937
3888
|
shouldFocusToggleOnSelect && ((_a = toggleRef.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
3938
|
-
}, isPlain: isPlain, isScrollable: scrollable }, props, ouiaProps)
|
|
3939
|
-
|
|
3940
|
-
return (React__default.createElement(Popper, Object.assign({ trigger: typeof toggle === 'function' ? toggle(toggleRef) : toggle.toggleNode, triggerRef: toggleRef, popper: menu, popperRef: menuRef, isVisible: isOpen, zIndex: zIndex }, popperProps)));
|
|
3889
|
+
}, isPlain: isPlain, isScrollable: scrollable }, props, ouiaProps, { children: jsx(MenuContent, { menuHeight: menuHeight, maxMenuHeight: maxMenuHeight, children: children }) })));
|
|
3890
|
+
return (jsx(Popper, Object.assign({ trigger: typeof toggle === 'function' ? toggle(toggleRef) : toggle.toggleNode, triggerRef: toggleRef, popper: menu, popperRef: menuRef, isVisible: isOpen, zIndex: zIndex }, popperProps)));
|
|
3941
3891
|
};
|
|
3942
|
-
const Dropdown =
|
|
3892
|
+
const Dropdown = forwardRef((props, ref) => (jsx(DropdownBase, Object.assign({ innerRef: ref }, props))));
|
|
3943
3893
|
Dropdown.displayName = 'Dropdown';
|
|
3944
3894
|
|
|
3945
3895
|
const DropdownItemBase = (_a) => {
|
|
3946
3896
|
var { children, className, description, isDisabled, isAriaDisabled, value, onClick, ouiaId, ouiaSafe, innerRef, tooltipProps } = _a, props = __rest(_a, ["children", "className", "description", "isDisabled", "isAriaDisabled", "value", "onClick", "ouiaId", "ouiaSafe", "innerRef", "tooltipProps"]);
|
|
3947
3897
|
const ouiaProps = useOUIAProps(DropdownItem.displayName, ouiaId, ouiaSafe);
|
|
3948
|
-
return (
|
|
3898
|
+
return (jsx(MenuItem, Object.assign({ className: css(className), description: description, isDisabled: isDisabled, isAriaDisabled: isAriaDisabled, itemId: value, onClick: onClick, tooltipProps: tooltipProps, ref: innerRef }, ouiaProps, props, { children: children })));
|
|
3949
3899
|
};
|
|
3950
|
-
const DropdownItem =
|
|
3900
|
+
const DropdownItem = forwardRef((props, ref) => (jsx(DropdownItemBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3951
3901
|
DropdownItem.displayName = 'DropdownItem';
|
|
3952
3902
|
|
|
3953
3903
|
const DropdownList = (_a) => {
|
|
3954
3904
|
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
3955
|
-
return (
|
|
3905
|
+
return (jsx(MenuList, Object.assign({ className: css(className) }, props, { children: children })));
|
|
3956
3906
|
};
|
|
3957
3907
|
DropdownList.displayName = 'DropdownList';
|
|
3958
3908
|
|