@patternfly/patternfly-doc-core 1.5.0 → 1.7.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 +56 -0
- package/.astro/collections/textContent.schema.json +16 -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/Button.IBWho7ny.js +9 -0
- package/dist/client/_astro/CSSTable.DHtMmTtQ.js +1185 -0
- package/dist/client/_astro/LiveExample.B7IM_dLQ.css +1 -0
- package/dist/client/_astro/LiveExample.CwKQ5TSc.js +33 -0
- package/dist/client/_astro/Navigation.BSSYIa2f.js +1 -0
- package/dist/client/_astro/PageContext.ipir86Hm.js +1 -0
- package/dist/client/_astro/PageSidebarBody.tzSXGYXP.js +1 -0
- package/dist/client/_astro/PageToggle.C6_rp-Bm.js +1 -0
- package/dist/client/_astro/PageToggleButton.CagcouJB.js +1 -0
- package/dist/client/_astro/SearchInput.BjY-zTwj.js +1 -0
- package/dist/client/_astro/Toolbar.D4TQG77s.js +1 -0
- package/dist/client/_astro/ToolbarContent.DzYW_pmy.js +1 -0
- package/dist/client/_astro/_page_.BWicMEzd.css +1 -0
- package/dist/client/_astro/_page_.Chv_bGyU.css +1 -0
- package/dist/client/_astro/_page_.CtheD08_.css +1 -0
- package/dist/client/_astro/_page_.DxJDkZPc.css +1 -0
- package/dist/client/_astro/client.zs76E0tG.js +1 -0
- package/dist/client/_astro/divider.DTvtnAAt.js +1 -0
- package/dist/client/_astro/help-icon.CDKTE3GW.js +8 -0
- package/dist/client/_astro/index.BQFV5hT1.js +24 -0
- package/dist/client/_astro/index.eCxJ45ll.js +9 -0
- package/dist/client/_astro/page.BTC3Kf3x.js +1 -0
- package/dist/client/components/accordion/index.html +110 -0
- package/dist/client/design-foundations/typography/index.html +35 -8
- package/dist/client/design-foundations/usage-and-behavior/index.html +35 -8
- package/dist/client/get-started/contribute/index.html +35 -8
- package/dist/client/index.html +4 -3
- package/dist/server/_@astrojs-ssr-adapter.mjs +1 -1
- package/dist/server/chunks/Button_DVSwQ8oX.mjs +639 -0
- package/dist/server/chunks/CSSTable_CG80uW98.mjs +740 -0
- package/dist/server/chunks/CSSTable_Dj2CroFz.mjs +4 -0
- package/dist/server/chunks/{PropsTables_MQNZVYdD.mjs → PropsTables_DUo7F9VR.mjs} +169 -246
- package/dist/server/chunks/Stack_Xm3fJVbK.mjs +22 -0
- 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_1EAcQtZj.mjs +1 -0
- package/dist/server/chunks/{angle-down-icon_BNJvzYv-.mjs → angle-down-icon_DtGGiMR5.mjs} +150 -832
- 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 +4 -3
- package/dist/server/{manifest_7YAgSoyv.mjs → manifest_Dpwo8Jjv.mjs} +3 -3
- package/dist/server/pages/_image.astro.mjs +1 -1
- package/dist/server/renderers.mjs +63 -14
- package/jest.config.ts +1 -1
- package/package.json +5 -2
- package/src/components/AutoLinkHeader.tsx +56 -0
- package/src/components/CSSSearch.tsx +33 -0
- package/src/components/CSSTable.astro +33 -0
- package/src/components/CSSTable.tsx +268 -0
- 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.config.ts +10 -3
- package/src/content.ts +2 -1
- package/src/layouts/Main.astro +12 -8
- package/src/pages/[section]/[...page].astro +16 -6
- package/src/pages/[section]/[page]/[...tab].astro +107 -40
- package/src/pages/index.astro +0 -1
- package/src/styles/global.scss +47 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/slugger.ts +14 -0
- package/textContent/contribute.md +19 -13
- 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,422 +1,10 @@
|
|
|
1
|
+
import { r as getUniqueId, a as canUseDOM, w as getLanguageDirection, x as clearTimeouts, c as css, b as createIcon, K as KeyTypes, g as getDefaultOUIAId, e as getOUIAProps, B as Button, d as ExclamationCircleIcon, E as ExclamationTriangleIcon, C as CheckCircleIcon, l as formatBreakpointMods, u as useOUIAProps } from './Button_DVSwQ8oX.mjs';
|
|
1
2
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
3
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { Component, useLayoutEffect, useEffect, useRef, useState, useMemo, useCallback, isValidElement, cloneElement, createRef, createContext, forwardRef, useContext } from 'react';
|
|
4
5
|
/* empty css */
|
|
5
6
|
import * as ReactDOM from 'react-dom';
|
|
6
7
|
|
|
7
|
-
/** Joins args into a className string
|
|
8
|
-
*
|
|
9
|
-
* @param {any} args list of objects, string, or arrays to reduce
|
|
10
|
-
*/
|
|
11
|
-
function css(...args) {
|
|
12
|
-
// Adapted from https://github.com/JedWatson/classnames/blob/master/index.js
|
|
13
|
-
const classes = [];
|
|
14
|
-
const hasOwn = {}.hasOwnProperty;
|
|
15
|
-
args.filter(Boolean).forEach((arg) => {
|
|
16
|
-
const argType = typeof arg;
|
|
17
|
-
if (argType === 'string' || argType === 'number') {
|
|
18
|
-
classes.push(arg);
|
|
19
|
-
}
|
|
20
|
-
else if (Array.isArray(arg) && arg.length) {
|
|
21
|
-
const inner = css(...arg);
|
|
22
|
-
if (inner) {
|
|
23
|
-
classes.push(inner);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else if (argType === 'object') {
|
|
27
|
-
for (const key in arg) {
|
|
28
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
29
|
-
classes.push(key);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return classes.join(' ');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const t_global_breakpoint_sm = {
|
|
38
|
-
"value": "36rem"};
|
|
39
|
-
|
|
40
|
-
const t_global_breakpoint_md = {
|
|
41
|
-
"value": "48rem"};
|
|
42
|
-
|
|
43
|
-
const t_global_breakpoint_lg = {
|
|
44
|
-
"value": "62rem"};
|
|
45
|
-
|
|
46
|
-
const t_global_breakpoint_xl = {
|
|
47
|
-
"value": "75rem"};
|
|
48
|
-
|
|
49
|
-
const t_global_breakpoint_2xl = {
|
|
50
|
-
"value": "90.625rem"};
|
|
51
|
-
|
|
52
|
-
const t_global_breakpoint_height_sm = {
|
|
53
|
-
"value": "0rem"};
|
|
54
|
-
|
|
55
|
-
const t_global_breakpoint_height_md = {
|
|
56
|
-
"value": "40rem"};
|
|
57
|
-
|
|
58
|
-
const t_global_breakpoint_height_lg = {
|
|
59
|
-
"value": "48rem"};
|
|
60
|
-
|
|
61
|
-
const t_global_breakpoint_height_xl = {
|
|
62
|
-
"value": "60rem"};
|
|
63
|
-
|
|
64
|
-
const t_global_breakpoint_height_2xl = {
|
|
65
|
-
"value": "80rem"};
|
|
66
|
-
|
|
67
|
-
let currentId$1 = 0;
|
|
68
|
-
/**
|
|
69
|
-
* Factory to create Icon class components for consumers
|
|
70
|
-
*/
|
|
71
|
-
function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath }) {
|
|
72
|
-
var _a;
|
|
73
|
-
return _a = class SVGIcon extends React.Component {
|
|
74
|
-
constructor() {
|
|
75
|
-
super(...arguments);
|
|
76
|
-
this.id = `icon-title-${currentId$1++}`;
|
|
77
|
-
}
|
|
78
|
-
render() {
|
|
79
|
-
const _b = this.props, { title, className } = _b, props = __rest(_b, ["title", "className"]);
|
|
80
|
-
const classes = className ? `pf-v6-svg ${className}` : 'pf-v6-svg';
|
|
81
|
-
const hasTitle = Boolean(title);
|
|
82
|
-
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
83
|
-
return (React.createElement("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),
|
|
84
|
-
hasTitle && React.createElement("title", { id: this.id }, title),
|
|
85
|
-
React.createElement("path", { d: svgPath })));
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
_a.displayName = name,
|
|
89
|
-
_a;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const CheckCircleIconConfig = {
|
|
93
|
-
name: 'CheckCircleIcon',
|
|
94
|
-
height: 512,
|
|
95
|
-
width: 512,
|
|
96
|
-
svgPath: 'M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z',
|
|
97
|
-
yOffset: 0,
|
|
98
|
-
xOffset: 0,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const CheckCircleIcon = createIcon(CheckCircleIconConfig);
|
|
102
|
-
|
|
103
|
-
const ExclamationCircleIconConfig = {
|
|
104
|
-
name: 'ExclamationCircleIcon',
|
|
105
|
-
height: 512,
|
|
106
|
-
width: 512,
|
|
107
|
-
svgPath: 'M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z',
|
|
108
|
-
yOffset: 0,
|
|
109
|
-
xOffset: 0,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const ExclamationCircleIcon = createIcon(ExclamationCircleIconConfig);
|
|
113
|
-
|
|
114
|
-
const ExclamationTriangleIconConfig = {
|
|
115
|
-
name: 'ExclamationTriangleIcon',
|
|
116
|
-
height: 512,
|
|
117
|
-
width: 576,
|
|
118
|
-
svgPath: 'M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z',
|
|
119
|
-
yOffset: 0,
|
|
120
|
-
xOffset: 0,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const ExclamationTriangleIcon = createIcon(ExclamationTriangleIconConfig);
|
|
124
|
-
|
|
125
|
-
const InfoCircleIconConfig = {
|
|
126
|
-
name: 'InfoCircleIcon',
|
|
127
|
-
height: 512,
|
|
128
|
-
width: 512,
|
|
129
|
-
svgPath: 'M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z',
|
|
130
|
-
yOffset: 0,
|
|
131
|
-
xOffset: 0,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const InfoCircleIcon = createIcon(InfoCircleIconConfig);
|
|
135
|
-
|
|
136
|
-
const BellIconConfig = {
|
|
137
|
-
name: 'BellIcon',
|
|
138
|
-
height: 1024,
|
|
139
|
-
width: 896,
|
|
140
|
-
svgPath: 'M448,0 C465.333333,0 480.333333,6.33333333 493,19 C505.666667,31.6666667 512,46.6666667 512,64 L512,106 L514.23,106.45 C587.89,121.39 648.48,157.24 696,214 C744,271.333333 768,338.666667 768,416 C768,500 780,568.666667 804,622 C818.666667,652.666667 841.333333,684 872,716 C873.773676,718.829136 875.780658,721.505113 878,724 C890,737.333333 896,752.333333 896,769 C896,785.666667 890,800.333333 878,813 C866,825.666667 850.666667,832 832,832 L63.3,832 C44.9533333,831.84 29.8533333,825.506667 18,813 C6,800.333333 0,785.666667 0,769 C0,752.333333 6,737.333333 18,724 L24,716 L25.06,714.9 C55.1933333,683.28 77.5066667,652.313333 92,622 C116,568.666667 128,500 128,416 C128,338.666667 152,271.333333 200,214 C248,156.666667 309.333333,120.666667 384,106 L384,63.31 C384.166667,46.27 390.5,31.5 403,19 C415.666667,6.33333333 430.666667,0 448,0 Z M576,896 L576,897.08 C575.74,932.6 563.073333,962.573333 538,987 C512.666667,1011.66667 482.666667,1024 448,1024 C413.333333,1024 383.333333,1011.66667 358,987 C332.666667,962.333333 320,932 320,896 L576,896 Z',
|
|
141
|
-
yOffset: 0,
|
|
142
|
-
xOffset: 0,
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const BellIcon = createIcon(BellIconConfig);
|
|
146
|
-
|
|
147
|
-
var ValidatedOptions;
|
|
148
|
-
(function (ValidatedOptions) {
|
|
149
|
-
ValidatedOptions["success"] = "success";
|
|
150
|
-
ValidatedOptions["error"] = "error";
|
|
151
|
-
ValidatedOptions["warning"] = "warning";
|
|
152
|
-
ValidatedOptions["default"] = "default";
|
|
153
|
-
})(ValidatedOptions || (ValidatedOptions = {}));
|
|
154
|
-
const KeyTypes = {
|
|
155
|
-
Space: ' ',
|
|
156
|
-
Escape: 'Escape',
|
|
157
|
-
Enter: 'Enter'};
|
|
158
|
-
const globalWidthBreakpoints = {
|
|
159
|
-
sm: parseInt(t_global_breakpoint_sm.value) * 16,
|
|
160
|
-
md: parseInt(t_global_breakpoint_md.value) * 16,
|
|
161
|
-
lg: parseInt(t_global_breakpoint_lg.value) * 16,
|
|
162
|
-
xl: parseInt(t_global_breakpoint_xl.value) * 16,
|
|
163
|
-
'2xl': parseInt(t_global_breakpoint_2xl.value) * 16
|
|
164
|
-
};
|
|
165
|
-
const globalHeightBreakpoints = {
|
|
166
|
-
sm: parseInt(t_global_breakpoint_height_sm.value) * 16,
|
|
167
|
-
md: parseInt(t_global_breakpoint_height_md.value) * 16,
|
|
168
|
-
lg: parseInt(t_global_breakpoint_height_lg.value) * 16,
|
|
169
|
-
xl: parseInt(t_global_breakpoint_height_xl.value) * 16,
|
|
170
|
-
'2xl': parseInt(t_global_breakpoint_height_2xl.value) * 16
|
|
171
|
-
};
|
|
172
|
-
const statusIcons = {
|
|
173
|
-
success: CheckCircleIcon,
|
|
174
|
-
danger: ExclamationCircleIcon,
|
|
175
|
-
warning: ExclamationTriangleIcon,
|
|
176
|
-
info: InfoCircleIcon,
|
|
177
|
-
custom: BellIcon
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @param {string} prefix - String to prefix ID with
|
|
182
|
-
*/
|
|
183
|
-
function getUniqueId(prefix = 'pf') {
|
|
184
|
-
const uid = new Date().getTime() + Math.random().toString(36).slice(2);
|
|
185
|
-
return `${prefix}-${uid}`;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* This function is a helper for turning arrays of breakpointMod objects for flex and grid into style object
|
|
189
|
-
*
|
|
190
|
-
* @param {object} mods The modifiers object
|
|
191
|
-
* @param {string} css-variable The appropriate css variable for the component
|
|
192
|
-
*/
|
|
193
|
-
const setBreakpointCssVars = (mods, cssVar) => Object.entries(mods || {}).reduce((acc, [breakpoint, value]) => breakpoint === 'default' ? Object.assign(Object.assign({}, acc), { [cssVar]: value }) : Object.assign(Object.assign({}, acc), { [`${cssVar}-on-${breakpoint}`]: value }), {});
|
|
194
|
-
/**
|
|
195
|
-
* This function is a helper for turning arrays of breakpointMod objects for data toolbar and flex into classes
|
|
196
|
-
*
|
|
197
|
-
* @param {object} mods The modifiers object
|
|
198
|
-
* @param {any} styles The appropriate styles object for the component
|
|
199
|
-
*/
|
|
200
|
-
const formatBreakpointMods = (mods, styles, stylePrefix = '', breakpoint, vertical) => {
|
|
201
|
-
if (!mods) {
|
|
202
|
-
return '';
|
|
203
|
-
}
|
|
204
|
-
if (breakpoint && !vertical) {
|
|
205
|
-
if (breakpoint in mods) {
|
|
206
|
-
return styles.modifiers[toCamel(`${stylePrefix}${mods[breakpoint]}`)];
|
|
207
|
-
}
|
|
208
|
-
// the current breakpoint is not specified in mods, so we try to find the next nearest
|
|
209
|
-
const breakpointsOrder = ['2xl', 'xl', 'lg', 'md', 'sm', 'default'];
|
|
210
|
-
const breakpointsIndex = breakpointsOrder.indexOf(breakpoint);
|
|
211
|
-
for (let i = breakpointsIndex; i < breakpointsOrder.length; i++) {
|
|
212
|
-
if (breakpointsOrder[i] in mods) {
|
|
213
|
-
return styles.modifiers[toCamel(`${stylePrefix}${mods[breakpointsOrder[i]]}`)];
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return '';
|
|
217
|
-
}
|
|
218
|
-
return Object.entries(mods || {})
|
|
219
|
-
.map(([breakpoint, mod]) => `${stylePrefix}${mod}${breakpoint !== 'default' ? `-on-${breakpoint}` : ''}${vertical && breakpoint !== 'default' ? '-height' : ''}`)
|
|
220
|
-
.map(toCamel)
|
|
221
|
-
.map((mod) => mod.replace(/-?(\dxl)/gi, (_res, group) => `_${group}`))
|
|
222
|
-
.map((modifierKey) => styles.modifiers[modifierKey])
|
|
223
|
-
.filter(Boolean)
|
|
224
|
-
.join(' ');
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Return the breakpoint for the given height
|
|
228
|
-
*
|
|
229
|
-
* @param {number | null} height The height to check
|
|
230
|
-
* @returns {'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} The breakpoint
|
|
231
|
-
*/
|
|
232
|
-
const getVerticalBreakpoint = (height) => {
|
|
233
|
-
if (height === null) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
if (height >= globalHeightBreakpoints['2xl']) {
|
|
237
|
-
return '2xl';
|
|
238
|
-
}
|
|
239
|
-
if (height >= globalHeightBreakpoints.xl) {
|
|
240
|
-
return 'xl';
|
|
241
|
-
}
|
|
242
|
-
if (height >= globalHeightBreakpoints.lg) {
|
|
243
|
-
return 'lg';
|
|
244
|
-
}
|
|
245
|
-
if (height >= globalHeightBreakpoints.md) {
|
|
246
|
-
return 'md';
|
|
247
|
-
}
|
|
248
|
-
if (height >= globalHeightBreakpoints.sm) {
|
|
249
|
-
return 'sm';
|
|
250
|
-
}
|
|
251
|
-
return 'default';
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Return the breakpoint for the given width
|
|
255
|
-
*
|
|
256
|
-
* @param {number | null} width The width to check
|
|
257
|
-
* @returns {'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} The breakpoint
|
|
258
|
-
*/
|
|
259
|
-
const getBreakpoint = (width) => {
|
|
260
|
-
if (width === null) {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
if (width >= globalWidthBreakpoints['2xl']) {
|
|
264
|
-
return '2xl';
|
|
265
|
-
}
|
|
266
|
-
if (width >= globalWidthBreakpoints.xl) {
|
|
267
|
-
return 'xl';
|
|
268
|
-
}
|
|
269
|
-
if (width >= globalWidthBreakpoints.lg) {
|
|
270
|
-
return 'lg';
|
|
271
|
-
}
|
|
272
|
-
if (width >= globalWidthBreakpoints.md) {
|
|
273
|
-
return 'md';
|
|
274
|
-
}
|
|
275
|
-
if (width >= globalWidthBreakpoints.sm) {
|
|
276
|
-
return 'sm';
|
|
277
|
-
}
|
|
278
|
-
return 'default';
|
|
279
|
-
};
|
|
280
|
-
const camelize = (s) => s.toUpperCase().replace('-', '').replace('_', '');
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
* @param {string} s string to make camelCased
|
|
284
|
-
*/
|
|
285
|
-
const toCamel = (s) => s.replace(/([-_][a-z])/gi, camelize);
|
|
286
|
-
/**
|
|
287
|
-
* Copied from exenv
|
|
288
|
-
*/
|
|
289
|
-
const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
290
|
-
/**
|
|
291
|
-
* Calculate the width of the text
|
|
292
|
-
* Example:
|
|
293
|
-
* getTextWidth('my text', node)
|
|
294
|
-
*
|
|
295
|
-
* @param {string} text The text to calculate the width for
|
|
296
|
-
* @param {HTMLElement} node The HTML element
|
|
297
|
-
*/
|
|
298
|
-
const getTextWidth = (text, node) => {
|
|
299
|
-
const computedStyle = getComputedStyle(node);
|
|
300
|
-
// Firefox returns the empty string for .font, so this function creates the .font property manually
|
|
301
|
-
const getFontFromComputedStyle = () => {
|
|
302
|
-
let computedFont = '';
|
|
303
|
-
// Firefox uses percentages for font-stretch, but Canvas does not accept percentages
|
|
304
|
-
// so convert to keywords, as listed at:
|
|
305
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch
|
|
306
|
-
const fontStretchLookupTable = {
|
|
307
|
-
'50%': 'ultra-condensed',
|
|
308
|
-
'62.5%': 'extra-condensed',
|
|
309
|
-
'75%': 'condensed',
|
|
310
|
-
'87.5%': 'semi-condensed',
|
|
311
|
-
'100%': 'normal',
|
|
312
|
-
'112.5%': 'semi-expanded',
|
|
313
|
-
'125%': 'expanded',
|
|
314
|
-
'150%': 'extra-expanded',
|
|
315
|
-
'200%': 'ultra-expanded'
|
|
316
|
-
};
|
|
317
|
-
// If the retrieved font-stretch percentage isn't found in the lookup table, use
|
|
318
|
-
// 'normal' as a last resort.
|
|
319
|
-
let fontStretch;
|
|
320
|
-
if (computedStyle.fontStretch in fontStretchLookupTable) {
|
|
321
|
-
fontStretch = fontStretchLookupTable[computedStyle.fontStretch];
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
fontStretch = 'normal';
|
|
325
|
-
}
|
|
326
|
-
computedFont =
|
|
327
|
-
computedStyle.fontStyle +
|
|
328
|
-
' ' +
|
|
329
|
-
computedStyle.fontVariant +
|
|
330
|
-
' ' +
|
|
331
|
-
computedStyle.fontWeight +
|
|
332
|
-
' ' +
|
|
333
|
-
fontStretch +
|
|
334
|
-
' ' +
|
|
335
|
-
computedStyle.fontSize +
|
|
336
|
-
'/' +
|
|
337
|
-
computedStyle.lineHeight +
|
|
338
|
-
' ' +
|
|
339
|
-
computedStyle.fontFamily;
|
|
340
|
-
return computedFont;
|
|
341
|
-
};
|
|
342
|
-
const canvas = document.createElement('canvas');
|
|
343
|
-
const context = canvas.getContext('2d');
|
|
344
|
-
context.font = computedStyle.font || getFontFromComputedStyle();
|
|
345
|
-
return context.measureText(text).width;
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* Get the inner dimensions of an element
|
|
349
|
-
*
|
|
350
|
-
* @param {HTMLElement} node HTML element to calculate the inner dimensions for
|
|
351
|
-
*/
|
|
352
|
-
const innerDimensions = (node) => {
|
|
353
|
-
const computedStyle = getComputedStyle(node);
|
|
354
|
-
let width = node.clientWidth; // width with padding
|
|
355
|
-
let height = node.clientHeight; // height with padding
|
|
356
|
-
height -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
|
|
357
|
-
width -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
|
|
358
|
-
return { height, width };
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* This function is a helper for truncating text content on the left, leaving the right side of the content in view
|
|
362
|
-
*
|
|
363
|
-
* @param {HTMLElement} node HTML element
|
|
364
|
-
* @param {string} value The original text value
|
|
365
|
-
*/
|
|
366
|
-
const trimLeft = (node, value) => {
|
|
367
|
-
const availableWidth = innerDimensions(node).width;
|
|
368
|
-
let newValue = value;
|
|
369
|
-
if (getTextWidth(value, node) > availableWidth) {
|
|
370
|
-
// we have text overflow, trim the text to the left and add ... in the front until it fits
|
|
371
|
-
while (getTextWidth(`...${newValue}`, node) > availableWidth) {
|
|
372
|
-
newValue = newValue.substring(1);
|
|
373
|
-
}
|
|
374
|
-
// replace text with our truncated text
|
|
375
|
-
if (node.value) {
|
|
376
|
-
node.value = `...${newValue}`;
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
node.innerText = `...${newValue}`;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
if (node.value) {
|
|
384
|
-
node.value = value;
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
node.innerText = value;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
/**
|
|
392
|
-
* @param {React.RefObject<any>[]} timeoutRefs - Timeout refs to clear
|
|
393
|
-
*/
|
|
394
|
-
const clearTimeouts = (timeoutRefs) => {
|
|
395
|
-
timeoutRefs.forEach((ref) => {
|
|
396
|
-
if (ref.current) {
|
|
397
|
-
clearTimeout(ref.current);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
};
|
|
401
|
-
/**
|
|
402
|
-
* Helper function to get the language direction of a given element, useful for figuring out if left-to-right
|
|
403
|
-
* or right-to-left specific logic should be applied.
|
|
404
|
-
*
|
|
405
|
-
* @param {HTMLElement} targetElement - Element the helper will get the language direction of
|
|
406
|
-
* @param {'ltr' | 'rtl'} defaultDirection - Language direction to assume if one can't be determined, defaults to 'ltr'
|
|
407
|
-
* @returns {'ltr' | 'rtl'} - The language direction of the target element
|
|
408
|
-
*/
|
|
409
|
-
const getLanguageDirection = (targetElement, defaultDirection = 'ltr') => {
|
|
410
|
-
if (!targetElement) {
|
|
411
|
-
return defaultDirection;
|
|
412
|
-
}
|
|
413
|
-
const computedDirection = getComputedStyle(targetElement).getPropertyValue('direction');
|
|
414
|
-
if (['ltr', 'rtl'].includes(computedDirection)) {
|
|
415
|
-
return computedDirection;
|
|
416
|
-
}
|
|
417
|
-
return defaultDirection;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
8
|
/** This Component can be used to wrap a functional component in order to generate a random ID
|
|
421
9
|
* Example of how to use this component
|
|
422
10
|
*
|
|
@@ -439,7 +27,7 @@ function getRandomId() {
|
|
|
439
27
|
return getUniqueId();
|
|
440
28
|
}
|
|
441
29
|
}
|
|
442
|
-
class GenerateId extends
|
|
30
|
+
class GenerateId extends Component {
|
|
443
31
|
constructor() {
|
|
444
32
|
super(...arguments);
|
|
445
33
|
this.uniqueElement = this.props.isRandom ? getRandomId() : currentId++;
|
|
@@ -457,90 +45,6 @@ GenerateId.defaultProps = {
|
|
|
457
45
|
|
|
458
46
|
const ASTERISK = '*';
|
|
459
47
|
|
|
460
|
-
let uid = 0;
|
|
461
|
-
const ouiaPrefix = 'OUIA-Generated-';
|
|
462
|
-
const ouiaIdByRoute = {};
|
|
463
|
-
/** Get props to conform to OUIA spec
|
|
464
|
-
*
|
|
465
|
-
* For functional components, use the useOUIAProps function instead
|
|
466
|
-
*
|
|
467
|
-
* In class based components, create a state variable ouiaStateId to create a static generated ID:
|
|
468
|
-
* state = {
|
|
469
|
-
* ouiaStateId: getDefaultOUIAId(Chip.displayName)
|
|
470
|
-
* }
|
|
471
|
-
* This generated ID should remain alive as long as the component is not unmounted.
|
|
472
|
-
*
|
|
473
|
-
* Then add the attributes to the component
|
|
474
|
-
* {...getOUIAProps('OverflowChip', this.props.ouiaId !== undefined ? this.props.ouiaId : this.state.ouiaStateId)}
|
|
475
|
-
*
|
|
476
|
-
* @param {string} componentType OUIA component type
|
|
477
|
-
* @param {number|string} id OUIA component id
|
|
478
|
-
* @param {boolean} ouiaSafe false if in animation
|
|
479
|
-
*/
|
|
480
|
-
function getOUIAProps(componentType, id, ouiaSafe = true) {
|
|
481
|
-
return {
|
|
482
|
-
'data-ouia-component-type': `PF6/${componentType}`,
|
|
483
|
-
'data-ouia-safe': ouiaSafe,
|
|
484
|
-
'data-ouia-component-id': id
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Hooks version of the getOUIAProps function that also memoizes the generated ID
|
|
489
|
-
* Can only be used in functional components
|
|
490
|
-
*
|
|
491
|
-
* @param {string} componentType OUIA component type
|
|
492
|
-
* @param {number|string} id OUIA component id
|
|
493
|
-
* @param {boolean} ouiaSafe false if in animation
|
|
494
|
-
* @param {string} variant Optional variant to add to the generated ID
|
|
495
|
-
*/
|
|
496
|
-
const useOUIAProps = (componentType, id, ouiaSafe = true, variant) => ({
|
|
497
|
-
'data-ouia-component-type': `PF6/${componentType}`,
|
|
498
|
-
'data-ouia-safe': ouiaSafe,
|
|
499
|
-
'data-ouia-component-id': useOUIAId(componentType, id, variant)
|
|
500
|
-
});
|
|
501
|
-
/**
|
|
502
|
-
* Returns the ID or the memoized generated ID
|
|
503
|
-
*
|
|
504
|
-
* @param {string} componentType OUIA component type
|
|
505
|
-
* @param {number|string} id OUIA component id
|
|
506
|
-
* @param {string} variant Optional variant to add to the generated ID
|
|
507
|
-
*/
|
|
508
|
-
const useOUIAId = (componentType, id, variant) => {
|
|
509
|
-
const defaultOUIAId = useMemo(() => getDefaultOUIAId(componentType, variant), [componentType, variant]);
|
|
510
|
-
return id !== null && id !== void 0 ? id : defaultOUIAId;
|
|
511
|
-
};
|
|
512
|
-
/**
|
|
513
|
-
* Returns a generated id based on the URL location
|
|
514
|
-
*
|
|
515
|
-
* @param {string} componentType OUIA component type
|
|
516
|
-
* @param {string} variant Optional variant to add to the generated ID
|
|
517
|
-
*/
|
|
518
|
-
function getDefaultOUIAId(componentType, variant) {
|
|
519
|
-
/*
|
|
520
|
-
ouiaIdByRoute = {
|
|
521
|
-
[route+componentType]: [number]
|
|
522
|
-
}
|
|
523
|
-
*/
|
|
524
|
-
try {
|
|
525
|
-
let key;
|
|
526
|
-
if (typeof window !== 'undefined') {
|
|
527
|
-
// browser environments
|
|
528
|
-
key = `${window.location.href}-${componentType}-${variant || ''}`;
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
// node/SSR environments
|
|
532
|
-
key = `${componentType}-${variant || ''}`;
|
|
533
|
-
}
|
|
534
|
-
if (!ouiaIdByRoute[key]) {
|
|
535
|
-
ouiaIdByRoute[key] = 0;
|
|
536
|
-
}
|
|
537
|
-
return `${ouiaPrefix}${componentType}-${variant ? `${variant}-` : ''}${++ouiaIdByRoute[key]}`;
|
|
538
|
-
}
|
|
539
|
-
catch (exception) {
|
|
540
|
-
return `${ouiaPrefix}${componentType}-${variant ? `${variant}-` : ''}${++uid}`;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
48
|
/**
|
|
545
49
|
* @param element
|
|
546
50
|
*/
|
|
@@ -2092,7 +1596,7 @@ const createPopper = popperGenerator({ defaultModifiers });
|
|
|
2092
1596
|
/**
|
|
2093
1597
|
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
2094
1598
|
*/
|
|
2095
|
-
const useIsomorphicLayoutEffect = canUseDOM ?
|
|
1599
|
+
const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
|
2096
1600
|
|
|
2097
1601
|
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
|
2098
1602
|
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -2105,14 +1609,14 @@ const fromEntries = (entries) => entries.reduce((acc, [key, value]) => {
|
|
|
2105
1609
|
}, {});
|
|
2106
1610
|
const EMPTY_MODIFIERS = [];
|
|
2107
1611
|
const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
2108
|
-
const prevOptions =
|
|
1612
|
+
const prevOptions = useRef(null);
|
|
2109
1613
|
const optionsWithDefaults = {
|
|
2110
1614
|
onFirstUpdate: options.onFirstUpdate,
|
|
2111
1615
|
placement: options.placement || 'bottom',
|
|
2112
1616
|
strategy: options.strategy || 'absolute',
|
|
2113
1617
|
modifiers: options.modifiers || EMPTY_MODIFIERS
|
|
2114
1618
|
};
|
|
2115
|
-
const [state, setState] =
|
|
1619
|
+
const [state, setState] = useState({
|
|
2116
1620
|
styles: {
|
|
2117
1621
|
popper: {
|
|
2118
1622
|
position: optionsWithDefaults.strategy,
|
|
@@ -2122,7 +1626,7 @@ const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
|
2122
1626
|
},
|
|
2123
1627
|
attributes: {}
|
|
2124
1628
|
});
|
|
2125
|
-
const updateStateModifier =
|
|
1629
|
+
const updateStateModifier = useMemo(() => ({
|
|
2126
1630
|
name: 'updateState',
|
|
2127
1631
|
enabled: true,
|
|
2128
1632
|
phase: 'write',
|
|
@@ -2136,7 +1640,7 @@ const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
|
2136
1640
|
},
|
|
2137
1641
|
requires: ['computeStyles']
|
|
2138
1642
|
}), []);
|
|
2139
|
-
const popperOptions =
|
|
1643
|
+
const popperOptions = useMemo(() => {
|
|
2140
1644
|
const newOptions = {
|
|
2141
1645
|
onFirstUpdate: optionsWithDefaults.onFirstUpdate,
|
|
2142
1646
|
placement: optionsWithDefaults.placement,
|
|
@@ -2157,7 +1661,7 @@ const usePopper = (referenceElement, popperElement, options = {}) => {
|
|
|
2157
1661
|
optionsWithDefaults.modifiers,
|
|
2158
1662
|
updateStateModifier
|
|
2159
1663
|
]);
|
|
2160
|
-
const popperInstanceRef =
|
|
1664
|
+
const popperInstanceRef = useRef(undefined);
|
|
2161
1665
|
useIsomorphicLayoutEffect(() => {
|
|
2162
1666
|
if (popperInstanceRef && popperInstanceRef.current) {
|
|
2163
1667
|
popperInstanceRef.current.setOptions(popperOptions);
|
|
@@ -2202,22 +1706,22 @@ const getOppositePlacement = (placement) => placement.replace(/left|right|bottom
|
|
|
2202
1706
|
const getOpacityTransition = (animationDuration) => `opacity ${animationDuration}ms cubic-bezier(.54, 1.5, .38, 1.11)`;
|
|
2203
1707
|
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
1708
|
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 =
|
|
1709
|
+
const [triggerElement, setTriggerElement] = useState(null);
|
|
1710
|
+
const [refElement, setRefElement] = useState(null);
|
|
1711
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
1712
|
+
const [popperContent, setPopperContent] = useState(null);
|
|
1713
|
+
const [ready, setReady] = useState(false);
|
|
1714
|
+
const [opacity, setOpacity] = useState(0);
|
|
1715
|
+
const [internalIsVisible, setInternalIsVisible] = useState(isVisible);
|
|
1716
|
+
const transitionTimerRef = useRef(null);
|
|
1717
|
+
const showTimerRef = useRef(null);
|
|
1718
|
+
const hideTimerRef = useRef(null);
|
|
1719
|
+
const prevExitDelayRef = useRef(undefined);
|
|
2216
1720
|
const refOrTrigger = refElement || triggerElement;
|
|
2217
1721
|
const showPopper = isVisible || internalIsVisible;
|
|
2218
1722
|
const triggerParent = (_a = ((triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || triggerElement)) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
2219
1723
|
const languageDirection = getLanguageDirection(triggerParent);
|
|
2220
|
-
const internalPosition =
|
|
1724
|
+
const internalPosition = useMemo(() => {
|
|
2221
1725
|
const fixedPositions = { left: 'left', right: 'right', center: 'center' };
|
|
2222
1726
|
const positionMap = {
|
|
2223
1727
|
ltr: Object.assign({ start: 'left', end: 'right' }, fixedPositions),
|
|
@@ -2225,16 +1729,16 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2225
1729
|
};
|
|
2226
1730
|
return positionMap[languageDirection][position];
|
|
2227
1731
|
}, [position, languageDirection]);
|
|
2228
|
-
const onDocumentClickCallback =
|
|
2229
|
-
|
|
1732
|
+
const onDocumentClickCallback = useCallback((event) => onDocumentClick(event, refOrTrigger, popperElement), [showPopper, triggerElement, refElement, popperElement, onDocumentClick]);
|
|
1733
|
+
useEffect(() => {
|
|
2230
1734
|
setReady(true);
|
|
2231
1735
|
onMount();
|
|
2232
1736
|
}, []);
|
|
2233
1737
|
// Cancel all timers on unmount
|
|
2234
|
-
|
|
1738
|
+
useEffect(() => () => {
|
|
2235
1739
|
clearTimeouts([transitionTimerRef, hideTimerRef, showTimerRef]);
|
|
2236
1740
|
}, []);
|
|
2237
|
-
|
|
1741
|
+
useEffect(() => {
|
|
2238
1742
|
if (triggerRef) {
|
|
2239
1743
|
if (triggerRef.current) {
|
|
2240
1744
|
setRefElement(triggerRef.current);
|
|
@@ -2244,7 +1748,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2244
1748
|
}
|
|
2245
1749
|
}
|
|
2246
1750
|
}, [triggerRef, trigger]);
|
|
2247
|
-
|
|
1751
|
+
useEffect(() => {
|
|
2248
1752
|
// When the popperRef is defined or the popper visibility changes, ensure the popper element is up to date
|
|
2249
1753
|
if (popperRef) {
|
|
2250
1754
|
if (popperRef.current) {
|
|
@@ -2255,7 +1759,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2255
1759
|
}
|
|
2256
1760
|
}
|
|
2257
1761
|
}, [showPopper, popperRef]);
|
|
2258
|
-
|
|
1762
|
+
useEffect(() => {
|
|
2259
1763
|
// Trigger a Popper update when content changes.
|
|
2260
1764
|
const observer = new MutationObserver(() => {
|
|
2261
1765
|
update && update();
|
|
@@ -2275,7 +1779,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2275
1779
|
element.removeEventListener(event, listener, { capture });
|
|
2276
1780
|
}
|
|
2277
1781
|
};
|
|
2278
|
-
|
|
1782
|
+
useEffect(() => {
|
|
2279
1783
|
addEventListener(onMouseEnter, refOrTrigger, 'mouseenter');
|
|
2280
1784
|
addEventListener(onMouseLeave, refOrTrigger, 'mouseleave');
|
|
2281
1785
|
addEventListener(onFocus, refOrTrigger, 'focus');
|
|
@@ -2326,9 +1830,9 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2326
1830
|
}
|
|
2327
1831
|
return convertedPlacement;
|
|
2328
1832
|
};
|
|
2329
|
-
const getPlacementMemo =
|
|
2330
|
-
const getOppositePlacementMemo =
|
|
2331
|
-
const widthMods =
|
|
1833
|
+
const getPlacementMemo = useMemo(getPlacement, [direction, internalPosition, placement]);
|
|
1834
|
+
const getOppositePlacementMemo = useMemo(() => getOppositePlacement(getPlacement()), [direction, internalPosition, placement]);
|
|
1835
|
+
const widthMods = useMemo(() => ({
|
|
2332
1836
|
name: 'widthMods',
|
|
2333
1837
|
enabled: width !== undefined || minWidth !== undefined || maxWidth !== undefined,
|
|
2334
1838
|
phase: 'beforeWrite',
|
|
@@ -2390,7 +1894,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2390
1894
|
/** We want to forceUpdate only when a tooltip's content is dynamically updated.
|
|
2391
1895
|
* TODO: Investigate into 3rd party libraries for a less limited/specific solution
|
|
2392
1896
|
*/
|
|
2393
|
-
|
|
1897
|
+
useEffect(() => {
|
|
2394
1898
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2395
1899
|
// currentPopperContent = {tooltip children} || {dropdown children}
|
|
2396
1900
|
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 +1903,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2399
1903
|
forceUpdate && forceUpdate();
|
|
2400
1904
|
}
|
|
2401
1905
|
}, [popper]);
|
|
2402
|
-
|
|
1906
|
+
useEffect(() => {
|
|
2403
1907
|
if (prevExitDelayRef.current < exitDelay) {
|
|
2404
1908
|
clearTimeouts([transitionTimerRef, hideTimerRef]);
|
|
2405
1909
|
hideTimerRef.current = setTimeout(() => {
|
|
@@ -2430,7 +1934,7 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2430
1934
|
}, animationDuration);
|
|
2431
1935
|
}, exitDelay);
|
|
2432
1936
|
};
|
|
2433
|
-
|
|
1937
|
+
useEffect(() => {
|
|
2434
1938
|
if (isVisible) {
|
|
2435
1939
|
show();
|
|
2436
1940
|
}
|
|
@@ -2450,8 +1954,10 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2450
1954
|
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
1955
|
opacity, transition: getOpacityTransition(animationDuration) }) }, attributes.popper);
|
|
2452
1956
|
const getMenuWithPopper = () => {
|
|
2453
|
-
const localPopper =
|
|
2454
|
-
return popperRef ? (localPopper) : (
|
|
1957
|
+
const localPopper = cloneElement(popper, options);
|
|
1958
|
+
return popperRef ? (localPopper) : (jsx("div", { style: { display: 'contents' }, ref: (node) => {
|
|
1959
|
+
setPopperElement(node === null || node === void 0 ? void 0 : node.firstElementChild);
|
|
1960
|
+
}, children: localPopper }));
|
|
2455
1961
|
};
|
|
2456
1962
|
const getPopper = () => {
|
|
2457
1963
|
if (appendTo === 'inline') {
|
|
@@ -2462,10 +1968,9 @@ const Popper = ({ trigger, popper, direction = 'down', position = 'start', place
|
|
|
2462
1968
|
return ReactDOM.createPortal(getMenuWithPopper(), target);
|
|
2463
1969
|
}
|
|
2464
1970
|
};
|
|
2465
|
-
return (
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
ready && showPopper && getPopper()));
|
|
1971
|
+
return (jsxs(Fragment, { children: [!triggerRef && trigger && isValidElement(trigger) && (jsx("div", { style: { display: 'contents' }, ref: (node) => {
|
|
1972
|
+
setTriggerElement(node === null || node === void 0 ? void 0 : node.firstElementChild);
|
|
1973
|
+
}, children: trigger })), triggerRef && trigger && isValidElement(trigger) && trigger, ready && showPopper && getPopper()] }));
|
|
2469
1974
|
};
|
|
2470
1975
|
Popper.displayName = 'Popper';
|
|
2471
1976
|
|
|
@@ -2617,7 +2122,7 @@ const onToggleArrowKeydownDefault = (event, menuRef) => {
|
|
|
2617
2122
|
}
|
|
2618
2123
|
focusableElement && focusableElement.focus();
|
|
2619
2124
|
};
|
|
2620
|
-
class KeyboardHandler extends
|
|
2125
|
+
class KeyboardHandler extends Component {
|
|
2621
2126
|
constructor() {
|
|
2622
2127
|
super(...arguments);
|
|
2623
2128
|
this.keyHandler = (event) => {
|
|
@@ -2629,7 +2134,7 @@ class KeyboardHandler extends React.Component {
|
|
|
2629
2134
|
const { isActiveElement, getFocusableElement, noVerticalArrowHandling, noHorizontalArrowHandling, noEnterHandling, noSpaceHandling, updateTabIndex, validSiblingTags, additionalKeyHandler, createNavigableElements, onlyTraverseSiblings } = this.props;
|
|
2630
2135
|
// Pass the event off to be handled by any custom handler
|
|
2631
2136
|
additionalKeyHandler && additionalKeyHandler(event);
|
|
2632
|
-
//
|
|
2137
|
+
// Initialize navigableElements from the createNavigableElements callback
|
|
2633
2138
|
const navigableElements = createNavigableElements();
|
|
2634
2139
|
if (!navigableElements) {
|
|
2635
2140
|
// eslint-disable-next-line no-console
|
|
@@ -2690,151 +2195,6 @@ KeyboardHandler.defaultProps = {
|
|
|
2690
2195
|
noSpaceHandling: false
|
|
2691
2196
|
};
|
|
2692
2197
|
|
|
2693
|
-
const styles$4 = {
|
|
2694
|
-
"button": "pf-v6-c-button",
|
|
2695
|
-
"buttonCount": "pf-v6-c-button__count",
|
|
2696
|
-
"buttonIcon": "pf-v6-c-button__icon",
|
|
2697
|
-
"buttonProgress": "pf-v6-c-button__progress",
|
|
2698
|
-
"modifiers": {
|
|
2699
|
-
"primary": "pf-m-primary",
|
|
2700
|
-
"unread": "pf-m-unread",
|
|
2701
|
-
"secondary": "pf-m-secondary",
|
|
2702
|
-
"danger": "pf-m-danger",
|
|
2703
|
-
"tertiary": "pf-m-tertiary",
|
|
2704
|
-
"link": "pf-m-link",
|
|
2705
|
-
"inline": "pf-m-inline",
|
|
2706
|
-
"displayLg": "pf-m-display-lg",
|
|
2707
|
-
"warning": "pf-m-warning",
|
|
2708
|
-
"control": "pf-m-control",
|
|
2709
|
-
"stateful": "pf-m-stateful",
|
|
2710
|
-
"read": "pf-m-read",
|
|
2711
|
-
"attention": "pf-m-attention",
|
|
2712
|
-
"plain": "pf-m-plain",
|
|
2713
|
-
"noPadding": "pf-m-no-padding",
|
|
2714
|
-
"block": "pf-m-block",
|
|
2715
|
-
"small": "pf-m-small",
|
|
2716
|
-
"clicked": "pf-m-clicked",
|
|
2717
|
-
"disabled": "pf-m-disabled",
|
|
2718
|
-
"ariaDisabled": "pf-m-aria-disabled",
|
|
2719
|
-
"progress": "pf-m-progress",
|
|
2720
|
-
"inProgress": "pf-m-in-progress",
|
|
2721
|
-
"start": "pf-m-start",
|
|
2722
|
-
"end": "pf-m-end"
|
|
2723
|
-
}};
|
|
2724
|
-
|
|
2725
|
-
const styles$3 = {
|
|
2726
|
-
"modifiers": {
|
|
2727
|
-
"inline": "pf-m-inline",
|
|
2728
|
-
"sm": "pf-m-sm",
|
|
2729
|
-
"md": "pf-m-md",
|
|
2730
|
-
"lg": "pf-m-lg",
|
|
2731
|
-
"xl": "pf-m-xl"
|
|
2732
|
-
},
|
|
2733
|
-
"spinner": "pf-v6-c-spinner",
|
|
2734
|
-
"spinnerPath": "pf-v6-c-spinner__path"
|
|
2735
|
-
};
|
|
2736
|
-
|
|
2737
|
-
const c_spinner_diameter = {
|
|
2738
|
-
"name": "--pf-v6-c-spinner--diameter"};
|
|
2739
|
-
|
|
2740
|
-
var spinnerSize;
|
|
2741
|
-
(function (spinnerSize) {
|
|
2742
|
-
spinnerSize["sm"] = "sm";
|
|
2743
|
-
spinnerSize["md"] = "md";
|
|
2744
|
-
spinnerSize["lg"] = "lg";
|
|
2745
|
-
spinnerSize["xl"] = "xl";
|
|
2746
|
-
})(spinnerSize || (spinnerSize = {}));
|
|
2747
|
-
const Spinner = (_a) => {
|
|
2748
|
-
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 (React.createElement("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),
|
|
2750
|
-
React.createElement("circle", { className: styles$3.spinnerPath, cx: "50", cy: "50", r: "45", fill: "none" })));
|
|
2751
|
-
};
|
|
2752
|
-
Spinner.displayName = 'Spinner';
|
|
2753
|
-
|
|
2754
|
-
const styles$2 = {
|
|
2755
|
-
"badge": "pf-v6-c-badge",
|
|
2756
|
-
"modifiers": {
|
|
2757
|
-
"read": "pf-m-read",
|
|
2758
|
-
"unread": "pf-m-unread",
|
|
2759
|
-
"disabled": "pf-m-disabled"
|
|
2760
|
-
}
|
|
2761
|
-
};
|
|
2762
|
-
|
|
2763
|
-
const Badge = (_a) => {
|
|
2764
|
-
var { isRead = false, isDisabled = false, className = '', children = '', screenReaderText } = _a, props = __rest(_a, ["isRead", "isDisabled", "className", "children", "screenReaderText"]);
|
|
2765
|
-
return (React.createElement("span", Object.assign({}, props, { className: css(styles$2.badge, (isRead ? styles$2.modifiers.read : styles$2.modifiers.unread), isDisabled && styles$2.modifiers.disabled, className) }),
|
|
2766
|
-
children,
|
|
2767
|
-
screenReaderText && React.createElement("span", { className: "pf-v6-screen-reader" }, screenReaderText)));
|
|
2768
|
-
};
|
|
2769
|
-
Badge.displayName = 'Badge';
|
|
2770
|
-
|
|
2771
|
-
var ButtonVariant;
|
|
2772
|
-
(function (ButtonVariant) {
|
|
2773
|
-
ButtonVariant["primary"] = "primary";
|
|
2774
|
-
ButtonVariant["secondary"] = "secondary";
|
|
2775
|
-
ButtonVariant["tertiary"] = "tertiary";
|
|
2776
|
-
ButtonVariant["danger"] = "danger";
|
|
2777
|
-
ButtonVariant["warning"] = "warning";
|
|
2778
|
-
ButtonVariant["link"] = "link";
|
|
2779
|
-
ButtonVariant["plain"] = "plain";
|
|
2780
|
-
ButtonVariant["control"] = "control";
|
|
2781
|
-
ButtonVariant["stateful"] = "stateful";
|
|
2782
|
-
})(ButtonVariant || (ButtonVariant = {}));
|
|
2783
|
-
var ButtonType;
|
|
2784
|
-
(function (ButtonType) {
|
|
2785
|
-
ButtonType["button"] = "button";
|
|
2786
|
-
ButtonType["submit"] = "submit";
|
|
2787
|
-
ButtonType["reset"] = "reset";
|
|
2788
|
-
})(ButtonType || (ButtonType = {}));
|
|
2789
|
-
var ButtonSize;
|
|
2790
|
-
(function (ButtonSize) {
|
|
2791
|
-
ButtonSize["default"] = "default";
|
|
2792
|
-
ButtonSize["sm"] = "sm";
|
|
2793
|
-
ButtonSize["lg"] = "lg";
|
|
2794
|
-
})(ButtonSize || (ButtonSize = {}));
|
|
2795
|
-
var ButtonState;
|
|
2796
|
-
(function (ButtonState) {
|
|
2797
|
-
ButtonState["read"] = "read";
|
|
2798
|
-
ButtonState["unread"] = "unread";
|
|
2799
|
-
ButtonState["attention"] = "attention";
|
|
2800
|
-
})(ButtonState || (ButtonState = {}));
|
|
2801
|
-
const ButtonBase = (_a) => {
|
|
2802
|
-
var { children = null, className = '', component = 'button', isClicked = false, isBlock = false, isDisabled = false, isAriaDisabled = false, isLoading = null, isDanger = false, spinnerAriaValueText, spinnerAriaLabelledBy, spinnerAriaLabel, size = ButtonSize.default, inoperableEvents = ['onClick', 'onKeyPress'], isInline = false, type = ButtonType.button, variant = ButtonVariant.primary, state = ButtonState.unread, hasNoPadding = false, iconPosition = 'start', 'aria-label': ariaLabel = null, icon = null, role, ouiaId, ouiaSafe = true, tabIndex = null, innerRef, countOptions } = _a, props = __rest(_a, ["children", "className", "component", "isClicked", "isBlock", "isDisabled", "isAriaDisabled", "isLoading", "isDanger", "spinnerAriaValueText", "spinnerAriaLabelledBy", "spinnerAriaLabel", "size", "inoperableEvents", "isInline", "type", "variant", "state", "hasNoPadding", "iconPosition", 'aria-label', "icon", "role", "ouiaId", "ouiaSafe", "tabIndex", "innerRef", "countOptions"]);
|
|
2803
|
-
const ouiaProps = useOUIAProps(Button.displayName, ouiaId, ouiaSafe, variant);
|
|
2804
|
-
const Component = component;
|
|
2805
|
-
const isButtonElement = Component === 'button';
|
|
2806
|
-
const isInlineSpan = isInline && Component === 'span';
|
|
2807
|
-
const isIconAlignedAtEnd = iconPosition === 'end' || iconPosition === 'right';
|
|
2808
|
-
const preventedEvents = inoperableEvents.reduce((handlers, eventToPrevent) => (Object.assign(Object.assign({}, handlers), { [eventToPrevent]: (event) => {
|
|
2809
|
-
event.preventDefault();
|
|
2810
|
-
} })), {});
|
|
2811
|
-
const getDefaultTabIdx = () => {
|
|
2812
|
-
if (isDisabled) {
|
|
2813
|
-
return isButtonElement ? null : -1;
|
|
2814
|
-
}
|
|
2815
|
-
else if (isAriaDisabled) {
|
|
2816
|
-
return null;
|
|
2817
|
-
}
|
|
2818
|
-
else if (isInlineSpan) {
|
|
2819
|
-
return 0;
|
|
2820
|
-
}
|
|
2821
|
-
};
|
|
2822
|
-
const _icon = icon && (React.createElement("span", { className: css(styles$4.buttonIcon, children && styles$4.modifiers[isIconAlignedAtEnd ? 'end' : 'start']) }, icon));
|
|
2823
|
-
const _children = children && React.createElement("span", { className: css('pf-v6-c-button__text') }, children);
|
|
2824
|
-
return (React.createElement(Component, Object.assign({}, props, (isAriaDisabled ? preventedEvents : null), { "aria-disabled": isAriaDisabled || (!isButtonElement && isDisabled), "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),
|
|
2825
|
-
isLoading && (React.createElement("span", { className: css(styles$4.buttonProgress) },
|
|
2826
|
-
React.createElement(Spinner, { size: spinnerSize.md, isInline: isInline, "aria-valuetext": spinnerAriaValueText, "aria-label": spinnerAriaLabel, "aria-labelledby": spinnerAriaLabelledBy }))),
|
|
2827
|
-
isIconAlignedAtEnd ? (React.createElement(React.Fragment, null,
|
|
2828
|
-
_children,
|
|
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))));
|
|
2836
|
-
Button.displayName = 'Button';
|
|
2837
|
-
|
|
2838
2198
|
const TimesIconConfig = {
|
|
2839
2199
|
name: 'TimesIcon',
|
|
2840
2200
|
height: 512,
|
|
@@ -2869,13 +2229,13 @@ const styles$1 = {
|
|
|
2869
2229
|
|
|
2870
2230
|
const TooltipContent = (_a) => {
|
|
2871
2231
|
var { className, children, isLeftAligned } = _a, props = __rest(_a, ["className", "children", "isLeftAligned"]);
|
|
2872
|
-
return (
|
|
2232
|
+
return (jsx("div", Object.assign({ className: css(styles$1.tooltipContent, isLeftAligned && styles$1.modifiers.textAlignLeft, className) }, props, { children: children })));
|
|
2873
2233
|
};
|
|
2874
2234
|
TooltipContent.displayName = 'TooltipContent';
|
|
2875
2235
|
|
|
2876
2236
|
const TooltipArrow = (_a) => {
|
|
2877
2237
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
2878
|
-
return
|
|
2238
|
+
return jsx("div", Object.assign({ className: css(styles$1.tooltipArrow, className) }, props));
|
|
2879
2239
|
};
|
|
2880
2240
|
TooltipArrow.displayName = 'TooltipArrow';
|
|
2881
2241
|
|
|
@@ -2908,8 +2268,8 @@ const Tooltip = (_a) => {
|
|
|
2908
2268
|
const triggerOnFocus = trigger.includes('focus');
|
|
2909
2269
|
const triggerOnClick = trigger.includes('click');
|
|
2910
2270
|
const triggerManually = trigger === 'manual';
|
|
2911
|
-
const [visible, setVisible] =
|
|
2912
|
-
const popperRef =
|
|
2271
|
+
const [visible, setVisible] = useState(false);
|
|
2272
|
+
const popperRef = createRef();
|
|
2913
2273
|
const onDocumentKeyDown = (event) => {
|
|
2914
2274
|
if (!triggerManually) {
|
|
2915
2275
|
if (event.key === KeyTypes.Escape && visible) {
|
|
@@ -2927,7 +2287,7 @@ const Tooltip = (_a) => {
|
|
|
2927
2287
|
}
|
|
2928
2288
|
}
|
|
2929
2289
|
};
|
|
2930
|
-
|
|
2290
|
+
useEffect(() => {
|
|
2931
2291
|
if (isVisible) {
|
|
2932
2292
|
show();
|
|
2933
2293
|
}
|
|
@@ -2956,11 +2316,9 @@ const Tooltip = (_a) => {
|
|
|
2956
2316
|
'right-end': styles$1.modifiers.rightBottom
|
|
2957
2317
|
};
|
|
2958
2318
|
const hasCustomMaxWidth = maxWidth !== c_tooltip_MaxWidth.value;
|
|
2959
|
-
const content = (
|
|
2319
|
+
const content = (jsxs("div", Object.assign({ "aria-live": ariaLive, className: css(styles$1.tooltip, className), role: "tooltip", id: id, style: {
|
|
2960
2320
|
maxWidth: hasCustomMaxWidth ? maxWidth : null
|
|
2961
|
-
}, ref: popperRef }, rest),
|
|
2962
|
-
React.createElement(TooltipArrow, null),
|
|
2963
|
-
React.createElement(TooltipContent, { isLeftAligned: isContentLeftAligned }, bodyContent)));
|
|
2321
|
+
}, ref: popperRef }, rest, { children: [jsx(TooltipArrow, {}), jsx(TooltipContent, { isLeftAligned: isContentLeftAligned, children: bodyContent })] })));
|
|
2964
2322
|
const onDocumentClick = (event, triggerElement) => {
|
|
2965
2323
|
// event.currentTarget = document
|
|
2966
2324
|
// event.target could be triggerElement or something else
|
|
@@ -2976,14 +2334,14 @@ const Tooltip = (_a) => {
|
|
|
2976
2334
|
};
|
|
2977
2335
|
const addAriaToTrigger = () => {
|
|
2978
2336
|
if (aria === 'describedby' && children && children.props && !children.props['aria-describedby']) {
|
|
2979
|
-
return
|
|
2337
|
+
return cloneElement(children, { 'aria-describedby': id });
|
|
2980
2338
|
}
|
|
2981
2339
|
else if (aria === 'labelledby' && children.props && !children.props['aria-labelledby']) {
|
|
2982
|
-
return
|
|
2340
|
+
return cloneElement(children, { 'aria-labelledby': id });
|
|
2983
2341
|
}
|
|
2984
2342
|
return children;
|
|
2985
2343
|
};
|
|
2986
|
-
return (
|
|
2344
|
+
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
2345
|
};
|
|
2988
2346
|
Tooltip.displayName = 'Tooltip';
|
|
2989
2347
|
|
|
@@ -3038,7 +2396,7 @@ const menuStyles = {
|
|
|
3038
2396
|
}
|
|
3039
2397
|
};
|
|
3040
2398
|
|
|
3041
|
-
const MenuContext =
|
|
2399
|
+
const MenuContext = createContext({
|
|
3042
2400
|
menuId: null,
|
|
3043
2401
|
parentMenu: null,
|
|
3044
2402
|
onActionClick: () => null,
|
|
@@ -3055,15 +2413,15 @@ const MenuContext = React.createContext({
|
|
|
3055
2413
|
disableHover: false,
|
|
3056
2414
|
role: 'menu'
|
|
3057
2415
|
});
|
|
3058
|
-
const MenuItemContext =
|
|
2416
|
+
const MenuItemContext = createContext({
|
|
3059
2417
|
itemId: null,
|
|
3060
2418
|
isDisabled: false
|
|
3061
2419
|
});
|
|
3062
2420
|
|
|
3063
|
-
class MenuBase extends
|
|
2421
|
+
class MenuBase extends Component {
|
|
3064
2422
|
constructor(props) {
|
|
3065
2423
|
super(props);
|
|
3066
|
-
this.menuRef =
|
|
2424
|
+
this.menuRef = createRef();
|
|
3067
2425
|
this.activeMenu = null;
|
|
3068
2426
|
this.state = {
|
|
3069
2427
|
ouiaStateId: getDefaultOUIAId(Menu.displayName),
|
|
@@ -3190,7 +2548,7 @@ class MenuBase extends React.Component {
|
|
|
3190
2548
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
3191
2549
|
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
2550
|
const _isMenuDrilledIn = isMenuDrilledIn || (drilledInMenus && drilledInMenus.includes(id)) || false;
|
|
3193
|
-
return (
|
|
2551
|
+
return (jsxs(MenuContext.Provider, { value: {
|
|
3194
2552
|
menuId: id,
|
|
3195
2553
|
parentMenu: parentMenu || id,
|
|
3196
2554
|
onSelect,
|
|
@@ -3206,22 +2564,20 @@ class MenuBase extends React.Component {
|
|
|
3206
2564
|
setFlyoutRef: (flyoutRef) => this.setState({ flyoutRef }),
|
|
3207
2565
|
disableHover: this.state.disableHover,
|
|
3208
2566
|
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)));
|
|
2567
|
+
}, 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
|
|
2568
|
+
document.activeElement.parentElement === element ||
|
|
2569
|
+
document.activeElement.closest(`.${menuStyles.menuSearch}`) === element || // if element is a MenuSearch
|
|
2570
|
+
(document.activeElement.closest('ol') && document.activeElement.closest('ol').firstChild === element), getFocusableElement: (navigableElement) => {
|
|
2571
|
+
var _a, _b;
|
|
2572
|
+
return ((navigableElement === null || navigableElement === void 0 ? void 0 : navigableElement.tagName) === 'DIV' && navigableElement.querySelector('input')) || // for MenuSearchInput
|
|
2573
|
+
(((_a = navigableElement.firstChild) === null || _a === void 0 ? void 0 : _a.tagName) === 'LABEL' &&
|
|
2574
|
+
navigableElement.querySelector('input')) || // for MenuItem checkboxes
|
|
2575
|
+
(((_b = navigableElement.firstChild) === null || _b === void 0 ? void 0 : _b.tagName) === 'DIV' &&
|
|
2576
|
+
navigableElement.querySelector('a, button, input')) || // For aria-disabled element that is rendered inside a div with "display: contents" styling
|
|
2577
|
+
navigableElement.firstChild;
|
|
2578
|
+
}, noHorizontalArrowHandling: document.activeElement &&
|
|
2579
|
+
(document.activeElement.classList.contains(breadcrumbStyles.breadcrumbLink) ||
|
|
2580
|
+
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
2581
|
}
|
|
3226
2582
|
}
|
|
3227
2583
|
MenuBase.displayName = 'Menu';
|
|
@@ -3233,7 +2589,7 @@ MenuBase.defaultProps = {
|
|
|
3233
2589
|
isScrollable: false,
|
|
3234
2590
|
role: 'menu'
|
|
3235
2591
|
};
|
|
3236
|
-
const Menu =
|
|
2592
|
+
const Menu = forwardRef((props, ref) => (jsx(MenuBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3237
2593
|
Menu.displayName = 'Menu';
|
|
3238
2594
|
|
|
3239
2595
|
const c_menu__content_Height = {
|
|
@@ -3242,9 +2598,9 @@ const c_menu__content_Height = {
|
|
|
3242
2598
|
const c_menu__content_MaxHeight = {
|
|
3243
2599
|
"name": "--pf-v6-c-menu__content--MaxHeight"};
|
|
3244
2600
|
|
|
3245
|
-
const MenuContent =
|
|
2601
|
+
const MenuContent = forwardRef((props, ref) => {
|
|
3246
2602
|
const { getHeight, children, menuHeight, maxMenuHeight } = props, rest = __rest(props, ["getHeight", "children", "menuHeight", "maxMenuHeight"]);
|
|
3247
|
-
const menuContentRef =
|
|
2603
|
+
const menuContentRef = createRef();
|
|
3248
2604
|
const refCallback = (el, menuId, onGetMenuHeight) => {
|
|
3249
2605
|
if (el) {
|
|
3250
2606
|
let clientHeight = el.clientHeight;
|
|
@@ -3269,7 +2625,9 @@ const MenuContent = React.forwardRef((props, ref) => {
|
|
|
3269
2625
|
}
|
|
3270
2626
|
return ref || menuContentRef;
|
|
3271
2627
|
};
|
|
3272
|
-
return (
|
|
2628
|
+
return (jsx(MenuContext.Consumer, { children: ({ menuId, onGetMenuHeight }) => (jsx("div", Object.assign({}, rest, { className: css(menuStyles.menuContent, props.className), ref: (el) => {
|
|
2629
|
+
refCallback(el, menuId, onGetMenuHeight);
|
|
2630
|
+
}, style: Object.assign(Object.assign({}, (menuHeight && { [c_menu__content_Height.name]: menuHeight })), (maxMenuHeight && { [c_menu__content_MaxHeight.name]: maxMenuHeight })), children: children }))) }));
|
|
3273
2631
|
});
|
|
3274
2632
|
MenuContent.displayName = 'MenuContent';
|
|
3275
2633
|
|
|
@@ -3330,7 +2688,7 @@ const checkStyles = {
|
|
|
3330
2688
|
|
|
3331
2689
|
// tslint:disable-next-line:no-empty
|
|
3332
2690
|
const defaultOnChange = () => { };
|
|
3333
|
-
class Checkbox extends
|
|
2691
|
+
class Checkbox extends Component {
|
|
3334
2692
|
constructor(props) {
|
|
3335
2693
|
super(props);
|
|
3336
2694
|
this.handleChange = (event) => {
|
|
@@ -3356,22 +2714,15 @@ class Checkbox extends React.Component {
|
|
|
3356
2714
|
if ([false, true].includes(defaultChecked)) {
|
|
3357
2715
|
checkedProps.defaultChecked = defaultChecked;
|
|
3358
2716
|
}
|
|
3359
|
-
const inputRendered = (
|
|
2717
|
+
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) => {
|
|
2718
|
+
elem && (elem.indeterminate = isChecked === null);
|
|
2719
|
+
} }, checkedProps, getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe))));
|
|
3360
2720
|
const wrapWithLabel = (isLabelWrapped && !component) || component === 'label';
|
|
3361
2721
|
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;
|
|
2722
|
+
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
2723
|
const Component = component !== null && component !== void 0 ? component : (wrapWithLabel ? 'label' : 'div');
|
|
3366
2724
|
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)));
|
|
2725
|
+
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
2726
|
}
|
|
3376
2727
|
}
|
|
3377
2728
|
Checkbox.displayName = 'Checkbox';
|
|
@@ -3399,34 +2750,35 @@ const StarIcon = createIcon(StarIconConfig);
|
|
|
3399
2750
|
|
|
3400
2751
|
const MenuItemActionBase = (_a) => {
|
|
3401
2752
|
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
|
-
}))));
|
|
2753
|
+
return (jsx(MenuContext.Consumer, { children: ({ onActionClick }) => (jsx(MenuItemContext.Consumer, { children: ({ itemId, isDisabled: isDisabledContext }) => {
|
|
2754
|
+
const onClickButton = (event) => {
|
|
2755
|
+
// event specified on the MenuItemAction
|
|
2756
|
+
onClick && onClick(event);
|
|
2757
|
+
// event specified on the Menu
|
|
2758
|
+
onActionClick && onActionClick(event, itemId, actionId);
|
|
2759
|
+
};
|
|
2760
|
+
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 }) })));
|
|
2761
|
+
} })) }));
|
|
3412
2762
|
};
|
|
3413
|
-
const MenuItemAction =
|
|
2763
|
+
const MenuItemAction = forwardRef((props, ref) => (jsx(MenuItemActionBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3414
2764
|
MenuItemAction.displayName = 'MenuItemAction';
|
|
3415
2765
|
|
|
3416
|
-
const FlyoutContext =
|
|
2766
|
+
const FlyoutContext = createContext({
|
|
3417
2767
|
direction: 'right'
|
|
3418
2768
|
});
|
|
3419
2769
|
const MenuItemBase = (_a) => {
|
|
3420
2770
|
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 } =
|
|
2771
|
+
const { menuId, parentMenu, onSelect, onActionClick, activeItemId, selected, drilldownItemPath, onDrillIn, onDrillOut, flyoutRef, setFlyoutRef, disableHover, role: menuRole } = useContext(MenuContext);
|
|
3422
2772
|
let Component = (to ? 'a' : component);
|
|
3423
2773
|
if (hasCheckbox && !to) {
|
|
3424
2774
|
Component = 'label';
|
|
3425
2775
|
}
|
|
3426
|
-
const [flyoutTarget, setFlyoutTarget] =
|
|
3427
|
-
const flyoutContext =
|
|
3428
|
-
const [flyoutXDirection, setFlyoutXDirection] =
|
|
3429
|
-
const ref =
|
|
2776
|
+
const [flyoutTarget, setFlyoutTarget] = useState(null);
|
|
2777
|
+
const flyoutContext = useContext(FlyoutContext);
|
|
2778
|
+
const [flyoutXDirection, setFlyoutXDirection] = useState(flyoutContext.direction);
|
|
2779
|
+
const ref = useRef(undefined);
|
|
2780
|
+
const privateRef = useRef(undefined);
|
|
2781
|
+
const innerComponentRef = innerRef || privateRef;
|
|
3430
2782
|
const flyoutVisible = ref === flyoutRef;
|
|
3431
2783
|
const hasFlyout = flyoutMenu !== undefined;
|
|
3432
2784
|
const showFlyout = (show) => {
|
|
@@ -3477,10 +2829,10 @@ const MenuItemBase = (_a) => {
|
|
|
3477
2829
|
}
|
|
3478
2830
|
}
|
|
3479
2831
|
}, [flyoutVisible, flyoutMenu]);
|
|
3480
|
-
|
|
2832
|
+
useEffect(() => {
|
|
3481
2833
|
setFlyoutXDirection(flyoutContext.direction);
|
|
3482
2834
|
}, [flyoutContext]);
|
|
3483
|
-
|
|
2835
|
+
useEffect(() => {
|
|
3484
2836
|
if (flyoutTarget) {
|
|
3485
2837
|
if (flyoutVisible) {
|
|
3486
2838
|
const flyoutMenu = flyoutTarget.nextElementSibling;
|
|
@@ -3591,7 +2943,7 @@ const MenuItemBase = (_a) => {
|
|
|
3591
2943
|
setFlyoutRef(null);
|
|
3592
2944
|
}
|
|
3593
2945
|
};
|
|
3594
|
-
|
|
2946
|
+
useEffect(() => {
|
|
3595
2947
|
if (isFocused && ref.current) {
|
|
3596
2948
|
const itemEl = ref.current;
|
|
3597
2949
|
const parentListEl = itemEl.parentElement;
|
|
@@ -3605,53 +2957,31 @@ const MenuItemBase = (_a) => {
|
|
|
3605
2957
|
}
|
|
3606
2958
|
}, [isFocused]);
|
|
3607
2959
|
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));
|
|
2960
|
+
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 && {
|
|
2961
|
+
onClick: (event) => {
|
|
2962
|
+
if (!isAriaDisabled) {
|
|
2963
|
+
onItemSelect(event, onSelect);
|
|
2964
|
+
drill && drill(event);
|
|
2965
|
+
flyoutMenu && handleFlyout(event);
|
|
2966
|
+
}
|
|
2967
|
+
else {
|
|
2968
|
+
event.preventDefault();
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
}), (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" }))] })] }));
|
|
2972
|
+
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: () => {
|
|
2973
|
+
if (!isAriaDisabled) {
|
|
2974
|
+
onMouseOver();
|
|
2975
|
+
}
|
|
2976
|
+
} }, (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
2977
|
};
|
|
3648
|
-
const MenuItem =
|
|
2978
|
+
const MenuItem = forwardRef((props, ref) => (jsx(MenuItemBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3649
2979
|
MenuItem.displayName = 'MenuItem';
|
|
3650
2980
|
|
|
3651
2981
|
const MenuList = (_a) => {
|
|
3652
2982
|
var { children = null, className, isAriaMultiselectable = false, 'aria-label': ariaLabel } = _a, props = __rest(_a, ["children", "className", "isAriaMultiselectable", 'aria-label']);
|
|
3653
|
-
const { role } =
|
|
3654
|
-
return (
|
|
2983
|
+
const { role } = useContext(MenuContext);
|
|
2984
|
+
return (jsx("ul", Object.assign({ role: role }, (role === 'listbox' && { 'aria-multiselectable': isAriaMultiselectable }), { className: css(menuStyles.menuList, className), "aria-label": ariaLabel }, props, { children: children })));
|
|
3655
2985
|
};
|
|
3656
2986
|
MenuList.displayName = 'MenuList';
|
|
3657
2987
|
|
|
@@ -3706,7 +3036,7 @@ var MenuToggleSize;
|
|
|
3706
3036
|
MenuToggleSize["default"] = "default";
|
|
3707
3037
|
MenuToggleSize["sm"] = "sm";
|
|
3708
3038
|
})(MenuToggleSize || (MenuToggleSize = {}));
|
|
3709
|
-
class MenuToggleBase extends
|
|
3039
|
+
class MenuToggleBase extends Component {
|
|
3710
3040
|
constructor() {
|
|
3711
3041
|
super(...arguments);
|
|
3712
3042
|
this.displayName = 'MenuToggleBase';
|
|
@@ -3724,38 +3054,27 @@ class MenuToggleBase extends React.Component {
|
|
|
3724
3054
|
if (!statusIcon) {
|
|
3725
3055
|
switch (status) {
|
|
3726
3056
|
case MenuToggleStatus.success:
|
|
3727
|
-
_statusIcon =
|
|
3057
|
+
_statusIcon = jsx(CheckCircleIcon, {});
|
|
3728
3058
|
break;
|
|
3729
3059
|
case MenuToggleStatus.warning:
|
|
3730
|
-
_statusIcon =
|
|
3060
|
+
_statusIcon = jsx(ExclamationTriangleIcon, {});
|
|
3731
3061
|
break;
|
|
3732
3062
|
case MenuToggleStatus.danger:
|
|
3733
|
-
_statusIcon =
|
|
3063
|
+
_statusIcon = jsx(ExclamationCircleIcon, {});
|
|
3734
3064
|
break;
|
|
3735
3065
|
}
|
|
3736
3066
|
}
|
|
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)));
|
|
3067
|
+
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, {}) })] }));
|
|
3068
|
+
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
3069
|
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
3070
|
const componentProps = Object.assign(Object.assign({ children: content }, (isDisabled && { disabled: true })), otherProps);
|
|
3748
3071
|
if (isTypeahead) {
|
|
3749
|
-
return (
|
|
3072
|
+
return (jsx("div", Object.assign({ ref: innerRef, className: css(commonStyles, styles.modifiers.typeahead) }, componentProps)));
|
|
3750
3073
|
}
|
|
3751
3074
|
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)));
|
|
3075
|
+
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
3076
|
}
|
|
3758
|
-
return (
|
|
3077
|
+
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
3078
|
}
|
|
3760
3079
|
}
|
|
3761
3080
|
MenuToggleBase.defaultProps = {
|
|
@@ -3768,7 +3087,7 @@ MenuToggleBase.defaultProps = {
|
|
|
3768
3087
|
size: 'default',
|
|
3769
3088
|
ouiaSafe: true
|
|
3770
3089
|
};
|
|
3771
|
-
const MenuToggle =
|
|
3090
|
+
const MenuToggle = forwardRef((props, ref) => (jsx(MenuToggleBase, Object.assign({ innerRef: ref }, props))));
|
|
3772
3091
|
MenuToggle.displayName = 'MenuToggle';
|
|
3773
3092
|
|
|
3774
3093
|
const dividerStyles = {
|
|
@@ -3857,21 +3176,21 @@ var DividerVariant;
|
|
|
3857
3176
|
const Divider = (_a) => {
|
|
3858
3177
|
var { className, component = DividerVariant.hr, inset, orientation } = _a, props = __rest(_a, ["className", "component", "inset", "orientation"]);
|
|
3859
3178
|
const Component = component;
|
|
3860
|
-
return (
|
|
3179
|
+
return (jsx(Component, Object.assign({ className: css(dividerStyles.divider, formatBreakpointMods(inset, dividerStyles), formatBreakpointMods(orientation, dividerStyles), className) }, (component !== 'hr' && { role: 'separator' }), props)));
|
|
3861
3180
|
};
|
|
3862
3181
|
Divider.displayName = 'Divider';
|
|
3863
3182
|
|
|
3864
3183
|
const DropdownBase = (_a) => {
|
|
3865
3184
|
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 =
|
|
3185
|
+
const localMenuRef = useRef(undefined);
|
|
3186
|
+
const localToggleRef = useRef(undefined);
|
|
3868
3187
|
const ouiaProps = useOUIAProps(Dropdown.displayName, ouiaId, ouiaSafe);
|
|
3869
3188
|
const menuRef = innerRef || localMenuRef;
|
|
3870
3189
|
const toggleRef = typeof toggle === 'function' || (typeof toggle !== 'function' && !toggle.toggleRef)
|
|
3871
3190
|
? localToggleRef
|
|
3872
3191
|
: toggle === null || toggle === void 0 ? void 0 : toggle.toggleRef;
|
|
3873
|
-
const prevIsOpen =
|
|
3874
|
-
|
|
3192
|
+
const prevIsOpen = useRef(isOpen);
|
|
3193
|
+
useEffect(() => {
|
|
3875
3194
|
// menu was opened, focus on first menu item
|
|
3876
3195
|
if (prevIsOpen.current === false && isOpen === true && shouldFocusFirstItemOnOpen) {
|
|
3877
3196
|
setTimeout(() => {
|
|
@@ -3883,7 +3202,7 @@ const DropdownBase = (_a) => {
|
|
|
3883
3202
|
prevIsOpen.current = isOpen;
|
|
3884
3203
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3885
3204
|
}, [isOpen]);
|
|
3886
|
-
|
|
3205
|
+
useEffect(() => {
|
|
3887
3206
|
const handleMenuKeys = (event) => {
|
|
3888
3207
|
var _a, _b, _c, _d;
|
|
3889
3208
|
// Close the menu on tab or escape if onOpenChange is provided
|
|
@@ -3931,28 +3250,27 @@ const DropdownBase = (_a) => {
|
|
|
3931
3250
|
focusTimeoutDelay
|
|
3932
3251
|
]);
|
|
3933
3252
|
const scrollable = maxMenuHeight !== undefined || menuHeight !== undefined || isScrollable;
|
|
3934
|
-
const menu = (
|
|
3253
|
+
const menu = (jsx(Menu, Object.assign({ className: css(className), ref: menuRef, onSelect: (event, value) => {
|
|
3935
3254
|
var _a;
|
|
3936
3255
|
onSelect && onSelect(event, value);
|
|
3937
3256
|
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)));
|
|
3257
|
+
}, isPlain: isPlain, isScrollable: scrollable }, props, ouiaProps, { children: jsx(MenuContent, { menuHeight: menuHeight, maxMenuHeight: maxMenuHeight, children: children }) })));
|
|
3258
|
+
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
3259
|
};
|
|
3942
|
-
const Dropdown =
|
|
3260
|
+
const Dropdown = forwardRef((props, ref) => (jsx(DropdownBase, Object.assign({ innerRef: ref }, props))));
|
|
3943
3261
|
Dropdown.displayName = 'Dropdown';
|
|
3944
3262
|
|
|
3945
3263
|
const DropdownItemBase = (_a) => {
|
|
3946
3264
|
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
3265
|
const ouiaProps = useOUIAProps(DropdownItem.displayName, ouiaId, ouiaSafe);
|
|
3948
|
-
return (
|
|
3266
|
+
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
3267
|
};
|
|
3950
|
-
const DropdownItem =
|
|
3268
|
+
const DropdownItem = forwardRef((props, ref) => (jsx(DropdownItemBase, Object.assign({}, props, { innerRef: ref }))));
|
|
3951
3269
|
DropdownItem.displayName = 'DropdownItem';
|
|
3952
3270
|
|
|
3953
3271
|
const DropdownList = (_a) => {
|
|
3954
3272
|
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
3955
|
-
return (
|
|
3273
|
+
return (jsx(MenuList, Object.assign({ className: css(className) }, props, { children: children })));
|
|
3956
3274
|
};
|
|
3957
3275
|
DropdownList.displayName = 'DropdownList';
|
|
3958
3276
|
|
|
@@ -3967,4 +3285,4 @@ const AngleDownIconConfig = {
|
|
|
3967
3285
|
|
|
3968
3286
|
const AngleDownIcon = createIcon(AngleDownIconConfig);
|
|
3969
3287
|
|
|
3970
|
-
export { ASTERISK as A,
|
|
3288
|
+
export { ASTERISK as A, CaretDownIcon as C, Divider as D, GenerateId as G, MenuToggle as M, Popper as P, StarIcon as S, TimesIcon as T, AngleDownIcon as a, Dropdown as b, DropdownList as c, DropdownItem as d, Tooltip as e, checkStyles as f, Checkbox as g, handleArrows as h, menuStyles as m, setTabIndex as s, useIsomorphicLayoutEffect as u };
|