@patternfly/patternfly-doc-core 1.2.0 → 1.3.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/textContent.schema.json +6 -0
- package/README.md +11 -10
- package/astro.config.mjs +8 -1
- package/cli/buildPropsData.ts +113 -0
- package/cli/cli.ts +52 -6
- package/cli/getConfig.ts +6 -0
- package/cli/hasFile.ts +5 -0
- package/cli/templates/pf-docs.config.mjs +13 -2
- package/cli/tsDocGen.js +199 -0
- package/dist/cli/buildPropsData.js +68 -0
- package/dist/cli/cli.js +37 -4
- package/dist/cli/hasFile.js +4 -0
- package/dist/cli/templates/pf-docs.config.mjs +12 -1
- package/dist/cli/tsDocGen.js +153 -0
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/dist/client/_astro/_page_.SnUmZn2y.css +1 -0
- package/dist/client/design-foundations/typography/index.html +219 -0
- package/dist/client/design-foundations/usage-and-behavior/index.html +368 -0
- package/dist/client/get-started/contribute/index.html +115 -0
- package/dist/client/index.html +42 -0
- package/dist/server/_@astrojs-ssr-adapter.mjs +1 -0
- package/dist/server/_noop-middleware.mjs +3 -0
- package/dist/server/chunks/PropsTables_D_v4KAMn.mjs +1826 -0
- package/dist/server/chunks/_@astrojs-ssr-adapter_ByVMUK8O.mjs +3621 -0
- package/dist/server/chunks/_astro_assets_CLOMnm-3.mjs +1507 -0
- package/dist/server/chunks/_astro_data-layer-content_DDGBHvtb.mjs +1 -0
- package/dist/server/chunks/angle-down-icon_BNJvzYv-.mjs +3970 -0
- package/dist/server/chunks/astro/server_D4f31GMD.mjs +2769 -0
- package/dist/server/chunks/astro-designed-error-pages_CpHpbfhr.mjs +282 -0
- package/dist/server/chunks/consts_BmVDRGlB.mjs +32 -0
- package/dist/server/chunks/content-assets_DleWbedO.mjs +1 -0
- package/dist/server/chunks/content-modules_Dz-S_Wwv.mjs +1 -0
- package/dist/server/chunks/path_Cvt6sEOY.mjs +58 -0
- package/dist/server/chunks/sharp_BYpUyJGL.mjs +88 -0
- package/dist/server/entry.mjs +45 -0
- package/dist/server/manifest_Bln0Ib60.mjs +102 -0
- package/dist/server/pages/_image.astro.mjs +132 -0
- package/dist/server/pages/_section_/_---page_.astro.mjs +1 -0
- package/dist/server/pages/_section_/_page_/_---tab_.astro.mjs +1 -0
- package/dist/server/pages/index.astro.mjs +1 -0
- package/dist/server/pages/props.astro.mjs +25 -0
- package/dist/server/renderers.mjs +259 -0
- package/jest.config.ts +1 -1
- package/package.json +5 -2
- package/pf-docs.config.mjs +31 -0
- package/release.config.mjs +1 -1
- package/src/components/PropsTable.tsx +3 -3
- package/src/components/PropsTables.astro +38 -0
- package/src/content.config.ts +1 -0
- package/src/pages/[section]/[...page].astro +16 -8
- package/src/pages/[section]/[page]/[...tab].astro +4 -1
- package/src/pages/props.ts +17 -0
- package/textContent/contribute.md +1 -0
- package/dist/design-foundations/typography/index.html +0 -193
- package/dist/design-foundations/usage-and-behavior/index.html +0 -342
- package/dist/get-started/contribute/index.html +0 -89
- package/dist/index.html +0 -42
- /package/dist/{PF-HorizontalLogo-Color.svg → client/PF-HorizontalLogo-Color.svg} +0 -0
- /package/dist/{PF-HorizontalLogo-Reverse.svg → client/PF-HorizontalLogo-Reverse.svg} +0 -0
- /package/dist/{_astro → client/_astro}/Button.C3_jB5tC.js +0 -0
- /package/dist/{_astro → client/_astro}/ClientRouter.astro_astro_type_script_index_0_lang.Cainpjm5.js +0 -0
- /package/dist/{_astro → client/_astro}/Navigation.Cede__Ud.js +0 -0
- /package/dist/{_astro → client/_astro}/PageContext.C7BqCh9N.js +0 -0
- /package/dist/{_astro → client/_astro}/PageToggle.DDEjruql.js +0 -0
- /package/dist/{_astro → client/_astro}/RedHatDisplayVF-Italic.CRpusWc8.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatDisplayVF.CYDHf1NI.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatMonoVF-Italic.DGQo2ogW.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatMonoVF.C4fMH6Vz.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatTextVF-Italic.Dkj_WqbA.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatTextVF.wYvZ7prR.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/Toolbar.TAdHxLSQ.js +0 -0
- /package/dist/{_astro → client/_astro}/_page_.CXyz_BEo.css +0 -0
- /package/dist/{_astro → client/_astro}/_page_.DVvr_Mfl.css +0 -0
- /package/dist/{_astro → client/_astro}/client.CeeiqVaE.js +0 -0
- /package/dist/{_astro → client/_astro}/divider.BSD-oFoh.js +0 -0
- /package/dist/{_astro → client/_astro}/fa-solid-900.DguXoeIz.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/index.CTH3fVMn.js +0 -0
- /package/dist/{_astro → client/_astro}/page.B65lVdBS.js +0 -0
- /package/dist/{_astro → client/_astro}/pf-v6-pficon.Dy6oiu9u.woff2 +0 -0
- /package/dist/{avatarImg.svg → client/avatarImg.svg} +0 -0
- /package/dist/{avatarImgDark.svg → client/avatarImgDark.svg} +0 -0
- /package/dist/{content → client/content}/typography/line-height.png +0 -0
- /package/dist/{favicon.svg → client/favicon.svg} +0 -0
|
@@ -0,0 +1,1826 @@
|
|
|
1
|
+
import { c as createComponent, a as createAstro, r as renderComponent, b as renderTemplate } from './astro/server_D4f31GMD.mjs';
|
|
2
|
+
import 'kleur/colors';
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { c as css, b as createIcon, B as Button, T as TimesIcon, F as getUniqueId, P as Popper, K as KeyTypes, H as useIsomorphicLayoutEffect, I as Tooltip, J as BellIcon, L as InfoCircleIcon, d as ExclamationCircleIcon, E as ExclamationTriangleIcon, C as CheckCircleIcon, x as Dropdown, M as MenuToggle, y as DropdownList, D as Divider, z as DropdownItem, k as AngleDownIcon, N as checkStyles, O as StarIcon, Q as Checkbox, R as setTabIndex, u as useOUIAProps, U as handleArrows } from './angle-down-icon_BNJvzYv-.mjs';
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { __rest } from 'tslib';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import React__default, { useRef, useEffect, forwardRef, useImperativeHandle, useState } from 'react';
|
|
9
|
+
/* empty css */
|
|
10
|
+
import mergeWith from 'lodash/mergeWith.js';
|
|
11
|
+
import { createFocusTrap } from 'focus-trap';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A `useEffect`-like hook that only triggers when a component unmounts. Does not require a dependency list, as the effect callback will always be kept up to date.
|
|
15
|
+
*/
|
|
16
|
+
function useUnmountEffect(effect) {
|
|
17
|
+
// Always use the latest effect callback so that it can reference the latest props and state.
|
|
18
|
+
const effectRef = useRef(effect);
|
|
19
|
+
effectRef.current = effect;
|
|
20
|
+
// Trigger the effect callback when the component unmounts.
|
|
21
|
+
useEffect(() => () => {
|
|
22
|
+
effectRef.current();
|
|
23
|
+
}, []);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const FocusTrap = forwardRef(function FocusTrap(_a, forwardedRef) {
|
|
27
|
+
var { active = true, paused = false, focusTrapOptions = {}, preventScrollOnDeactivate = false } = _a, props = __rest(_a, ["active", "paused", "focusTrapOptions", "preventScrollOnDeactivate"]);
|
|
28
|
+
// Fall back to internal ref if no forwarded ref is provided.
|
|
29
|
+
const ref = useRef(null);
|
|
30
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
31
|
+
// Create focus trap instance after rendering DOM.
|
|
32
|
+
const focusTrapRef = useRef(null);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const focusTrap = createFocusTrap(ref.current, Object.assign(Object.assign({}, focusTrapOptions), { returnFocusOnDeactivate: false }));
|
|
35
|
+
focusTrapRef.current = focusTrap;
|
|
36
|
+
// Deactivate focus trap on cleanup.
|
|
37
|
+
return () => {
|
|
38
|
+
focusTrap.deactivate();
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
// Handle activation status based on 'active' prop.
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const focusTrap = focusTrapRef.current;
|
|
44
|
+
active ? focusTrap === null || focusTrap === void 0 ? void 0 : focusTrap.activate() : focusTrap === null || focusTrap === void 0 ? void 0 : focusTrap.deactivate();
|
|
45
|
+
}, [active]);
|
|
46
|
+
// Handle pause status based on 'pause' prop.
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const focusTrap = focusTrapRef.current;
|
|
49
|
+
paused ? focusTrap === null || focusTrap === void 0 ? void 0 : focusTrap.pause() : focusTrap === null || focusTrap === void 0 ? void 0 : focusTrap.unpause();
|
|
50
|
+
}, [paused]);
|
|
51
|
+
// Store the currently active element to restore focus to later.
|
|
52
|
+
const previousElementRef = useRef(typeof document !== 'undefined' ? document.activeElement : null);
|
|
53
|
+
// Restore focus to the previously active element on unmount.
|
|
54
|
+
useUnmountEffect(() => {
|
|
55
|
+
if (focusTrapOptions.returnFocusOnDeactivate !== false && previousElementRef.current instanceof HTMLElement) {
|
|
56
|
+
previousElementRef.current.focus({
|
|
57
|
+
preventScroll: preventScrollOnDeactivate
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return React__default.createElement("div", Object.assign({ ref: ref }, props));
|
|
62
|
+
});
|
|
63
|
+
FocusTrap.displayName = 'FocusTrap';
|
|
64
|
+
|
|
65
|
+
const styles$5 = {
|
|
66
|
+
"actionList": "pf-v6-c-action-list",
|
|
67
|
+
"modifiers": {
|
|
68
|
+
"icons": "pf-m-icons"
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const ActionList = (_a) => {
|
|
73
|
+
var { children, isIconList, className } = _a, props = __rest(_a, ["children", "isIconList", "className"]);
|
|
74
|
+
return (React.createElement("div", Object.assign({ className: css(styles$5.actionList, isIconList && styles$5.modifiers.icons, className) }, props), children));
|
|
75
|
+
};
|
|
76
|
+
ActionList.displayName = 'ActionList';
|
|
77
|
+
|
|
78
|
+
const ActionListItem = (_a) => {
|
|
79
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
80
|
+
return (React.createElement("div", Object.assign({ className: css(`${styles$5.actionList}__item`, className) }, props), children));
|
|
81
|
+
};
|
|
82
|
+
ActionListItem.displayName = 'ActionListItem';
|
|
83
|
+
|
|
84
|
+
const GripVerticalIconConfig = {
|
|
85
|
+
name: 'GripVerticalIcon',
|
|
86
|
+
height: 512,
|
|
87
|
+
width: 320,
|
|
88
|
+
svgPath: 'M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z',
|
|
89
|
+
yOffset: 0,
|
|
90
|
+
xOffset: 0,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const GripVerticalIcon = createIcon(GripVerticalIconConfig);
|
|
94
|
+
|
|
95
|
+
const styles$4 = {
|
|
96
|
+
"modifiers": {
|
|
97
|
+
"noPadding": "pf-m-no-padding",
|
|
98
|
+
"widthAuto": "pf-m-width-auto",
|
|
99
|
+
"top": "pf-m-top",
|
|
100
|
+
"topLeft": "pf-m-top-left",
|
|
101
|
+
"topRight": "pf-m-top-right",
|
|
102
|
+
"bottom": "pf-m-bottom",
|
|
103
|
+
"bottomLeft": "pf-m-bottom-left",
|
|
104
|
+
"bottomRight": "pf-m-bottom-right",
|
|
105
|
+
"left": "pf-m-left",
|
|
106
|
+
"leftTop": "pf-m-left-top",
|
|
107
|
+
"leftBottom": "pf-m-left-bottom",
|
|
108
|
+
"right": "pf-m-right",
|
|
109
|
+
"rightTop": "pf-m-right-top",
|
|
110
|
+
"rightBottom": "pf-m-right-bottom",
|
|
111
|
+
"danger": "pf-m-danger",
|
|
112
|
+
"warning": "pf-m-warning",
|
|
113
|
+
"success": "pf-m-success",
|
|
114
|
+
"custom": "pf-m-custom",
|
|
115
|
+
"info": "pf-m-info"
|
|
116
|
+
},
|
|
117
|
+
"popover": "pf-v6-c-popover",
|
|
118
|
+
"popoverArrow": "pf-v6-c-popover__arrow",
|
|
119
|
+
"popoverBody": "pf-v6-c-popover__body",
|
|
120
|
+
"popoverClose": "pf-v6-c-popover__close",
|
|
121
|
+
"popoverContent": "pf-v6-c-popover__content",
|
|
122
|
+
"popoverFooter": "pf-v6-c-popover__footer",
|
|
123
|
+
"popoverHeader": "pf-v6-c-popover__header",
|
|
124
|
+
"popoverTitle": "pf-v6-c-popover__title",
|
|
125
|
+
"popoverTitleIcon": "pf-v6-c-popover__title-icon",
|
|
126
|
+
"popoverTitleText": "pf-v6-c-popover__title-text"
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const PopoverContext = React.createContext({});
|
|
130
|
+
|
|
131
|
+
const PopoverContent = (_a) => {
|
|
132
|
+
var { className = null, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
133
|
+
return (React.createElement("div", Object.assign({ className: css(styles$4.popoverContent, className) }, props), children));
|
|
134
|
+
};
|
|
135
|
+
PopoverContent.displayName = 'PopoverContent';
|
|
136
|
+
|
|
137
|
+
const PopoverBody = (_a) => {
|
|
138
|
+
var { children, id, className } = _a, props = __rest(_a, ["children", "id", "className"]);
|
|
139
|
+
return (React.createElement("div", Object.assign({ className: css(styles$4.popoverBody, className), id: id }, props), children));
|
|
140
|
+
};
|
|
141
|
+
PopoverBody.displayName = 'PopoverBody';
|
|
142
|
+
|
|
143
|
+
const PopoverHeaderIcon = (_a) => {
|
|
144
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
145
|
+
return (React.createElement("span", Object.assign({ className: css(styles$4.popoverTitleIcon, className) }, props), children));
|
|
146
|
+
};
|
|
147
|
+
PopoverHeaderIcon.displayName = 'PopoverHeaderIcon';
|
|
148
|
+
|
|
149
|
+
const PopoverHeaderText = (_a) => {
|
|
150
|
+
var { children, className, headingLevel } = _a, props = __rest(_a, ["children", "className", "headingLevel"]);
|
|
151
|
+
const HeadingLevel = headingLevel;
|
|
152
|
+
return (React.createElement(HeadingLevel, Object.assign({ className: css(styles$4.popoverTitleText, className) }, props), children));
|
|
153
|
+
};
|
|
154
|
+
PopoverHeaderText.displayName = 'PopoverHeaderText';
|
|
155
|
+
|
|
156
|
+
const PopoverHeader = (_a) => {
|
|
157
|
+
var { children, icon, className, titleHeadingLevel = 'h6', alertSeverityVariant, id, alertSeverityScreenReaderText } = _a, props = __rest(_a, ["children", "icon", "className", "titleHeadingLevel", "alertSeverityVariant", "id", "alertSeverityScreenReaderText"]);
|
|
158
|
+
return (React.createElement("header", Object.assign({ className: css(styles$4.popoverHeader, className) }, props),
|
|
159
|
+
React.createElement("div", { className: css(styles$4.popoverTitle), id: id },
|
|
160
|
+
icon && React.createElement(PopoverHeaderIcon, null, icon),
|
|
161
|
+
React.createElement(PopoverHeaderText, { headingLevel: titleHeadingLevel },
|
|
162
|
+
alertSeverityVariant && alertSeverityScreenReaderText && (React.createElement("span", { className: "pf-v6-screen-reader" }, alertSeverityScreenReaderText)),
|
|
163
|
+
children))));
|
|
164
|
+
};
|
|
165
|
+
PopoverHeader.displayName = 'PopoverHeader';
|
|
166
|
+
|
|
167
|
+
const PopoverFooter = (_a) => {
|
|
168
|
+
var { children, className = '' } = _a, props = __rest(_a, ["children", "className"]);
|
|
169
|
+
return (React.createElement("footer", Object.assign({ className: css(styles$4.popoverFooter, className) }, props), children));
|
|
170
|
+
};
|
|
171
|
+
PopoverFooter.displayName = 'PopoverFooter';
|
|
172
|
+
|
|
173
|
+
const PopoverCloseButton = (_a) => {
|
|
174
|
+
var { onClose = () => undefined } = _a, props = __rest(_a, ["onClose"]);
|
|
175
|
+
return (React.createElement("div", { className: css(styles$4.popoverClose) },
|
|
176
|
+
React.createElement(Button, Object.assign({ onClick: onClose, variant: "plain", "aria-label": true }, props, { style: { pointerEvents: 'auto' }, icon: React.createElement(TimesIcon, null) }))));
|
|
177
|
+
};
|
|
178
|
+
PopoverCloseButton.displayName = 'PopoverCloseButton';
|
|
179
|
+
|
|
180
|
+
const PopoverArrow = (_a) => {
|
|
181
|
+
var { className = '' } = _a, props = __rest(_a, ["className"]);
|
|
182
|
+
return React.createElement("div", Object.assign({ className: css(styles$4.popoverArrow, className) }, props));
|
|
183
|
+
};
|
|
184
|
+
PopoverArrow.displayName = 'PopoverArrow';
|
|
185
|
+
|
|
186
|
+
const c_popover_MaxWidth = {
|
|
187
|
+
"name": "--pf-v6-c-popover--MaxWidth",
|
|
188
|
+
"value": "none",
|
|
189
|
+
"var": "var(--pf-v6-c-popover--MaxWidth)"
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const c_popover_MinWidth = {
|
|
193
|
+
"name": "--pf-v6-c-popover--MinWidth",
|
|
194
|
+
"value": "auto",
|
|
195
|
+
"var": "var(--pf-v6-c-popover--MinWidth)"
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
var PopoverPosition;
|
|
199
|
+
(function (PopoverPosition) {
|
|
200
|
+
PopoverPosition["auto"] = "auto";
|
|
201
|
+
PopoverPosition["top"] = "top";
|
|
202
|
+
PopoverPosition["bottom"] = "bottom";
|
|
203
|
+
PopoverPosition["left"] = "left";
|
|
204
|
+
PopoverPosition["right"] = "right";
|
|
205
|
+
PopoverPosition["topStart"] = "top-start";
|
|
206
|
+
PopoverPosition["topEnd"] = "top-end";
|
|
207
|
+
PopoverPosition["bottomStart"] = "bottom-start";
|
|
208
|
+
PopoverPosition["bottomEnd"] = "bottom-end";
|
|
209
|
+
PopoverPosition["leftStart"] = "left-start";
|
|
210
|
+
PopoverPosition["leftEnd"] = "left-end";
|
|
211
|
+
PopoverPosition["rightStart"] = "right-start";
|
|
212
|
+
PopoverPosition["rightEnd"] = "right-end";
|
|
213
|
+
})(PopoverPosition || (PopoverPosition = {}));
|
|
214
|
+
const alertStyle = {
|
|
215
|
+
custom: styles$4.modifiers.custom,
|
|
216
|
+
info: styles$4.modifiers.info,
|
|
217
|
+
success: styles$4.modifiers.success,
|
|
218
|
+
warning: styles$4.modifiers.warning,
|
|
219
|
+
danger: styles$4.modifiers.danger
|
|
220
|
+
};
|
|
221
|
+
const Popover = (_a) => {
|
|
222
|
+
var { children, position = 'top', enableFlip = true, className = '', isVisible = null, shouldClose = () => null, shouldOpen = () => null, 'aria-label': ariaLabel = '', bodyContent, headerContent = null, headerComponent = 'h6', headerIcon = null, alertSeverityVariant, alertSeverityScreenReaderText, footerContent = null, appendTo = () => document.body, hideOnOutsideClick = true, onHide = () => null, onHidden = () => null, onShow = () => null, onShown = () => null, onMount = () => null, zIndex = 9999, triggerAction = 'click', minWidth = c_popover_MinWidth && c_popover_MinWidth.value, maxWidth = c_popover_MaxWidth && c_popover_MaxWidth.value, closeBtnAriaLabel = 'Close', showClose = true, distance = 25, flipBehavior = [
|
|
223
|
+
'top',
|
|
224
|
+
'bottom',
|
|
225
|
+
'left',
|
|
226
|
+
'right',
|
|
227
|
+
'top-start',
|
|
228
|
+
'top-end',
|
|
229
|
+
'bottom-start',
|
|
230
|
+
'bottom-end',
|
|
231
|
+
'left-start',
|
|
232
|
+
'left-end',
|
|
233
|
+
'right-start',
|
|
234
|
+
'right-end'
|
|
235
|
+
], animationDuration = 300, id, withFocusTrap: propWithFocusTrap, triggerRef, hasNoPadding = false, hasAutoWidth = false, elementToFocus } = _a, rest = __rest(_a, ["children", "position", "enableFlip", "className", "isVisible", "shouldClose", "shouldOpen", 'aria-label', "bodyContent", "headerContent", "headerComponent", "headerIcon", "alertSeverityVariant", "alertSeverityScreenReaderText", "footerContent", "appendTo", "hideOnOutsideClick", "onHide", "onHidden", "onShow", "onShown", "onMount", "zIndex", "triggerAction", "minWidth", "maxWidth", "closeBtnAriaLabel", "showClose", "distance", "flipBehavior", "animationDuration", "id", "withFocusTrap", "triggerRef", "hasNoPadding", "hasAutoWidth", "elementToFocus"]);
|
|
236
|
+
// could make this a prop in the future (true | false | 'toggle')
|
|
237
|
+
// const hideOnClick = true;
|
|
238
|
+
const uniqueId = id || getUniqueId();
|
|
239
|
+
const triggerManually = isVisible !== null;
|
|
240
|
+
const [visible, setVisible] = React.useState(false);
|
|
241
|
+
const [focusTrapActive, setFocusTrapActive] = React.useState(Boolean(propWithFocusTrap));
|
|
242
|
+
const popoverRef = React.useRef(null);
|
|
243
|
+
React.useEffect(() => {
|
|
244
|
+
onMount();
|
|
245
|
+
}, []);
|
|
246
|
+
React.useEffect(() => {
|
|
247
|
+
if (triggerManually) {
|
|
248
|
+
if (isVisible) {
|
|
249
|
+
show(undefined, true);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
hide();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}, [isVisible, triggerManually]);
|
|
256
|
+
const show = (event, withFocusTrap) => {
|
|
257
|
+
event && onShow(event);
|
|
258
|
+
setVisible(true);
|
|
259
|
+
propWithFocusTrap !== false && withFocusTrap && setFocusTrapActive(true);
|
|
260
|
+
};
|
|
261
|
+
const hide = (event) => {
|
|
262
|
+
event && onHide(event);
|
|
263
|
+
setVisible(false);
|
|
264
|
+
};
|
|
265
|
+
const positionModifiers = {
|
|
266
|
+
top: styles$4.modifiers.top,
|
|
267
|
+
bottom: styles$4.modifiers.bottom,
|
|
268
|
+
left: styles$4.modifiers.left,
|
|
269
|
+
right: styles$4.modifiers.right,
|
|
270
|
+
'top-start': styles$4.modifiers.topLeft,
|
|
271
|
+
'top-end': styles$4.modifiers.topRight,
|
|
272
|
+
'bottom-start': styles$4.modifiers.bottomLeft,
|
|
273
|
+
'bottom-end': styles$4.modifiers.bottomRight,
|
|
274
|
+
'left-start': styles$4.modifiers.leftTop,
|
|
275
|
+
'left-end': styles$4.modifiers.leftBottom,
|
|
276
|
+
'right-start': styles$4.modifiers.rightTop,
|
|
277
|
+
'right-end': styles$4.modifiers.rightBottom
|
|
278
|
+
};
|
|
279
|
+
const hasCustomMinWidth = minWidth !== c_popover_MinWidth.value;
|
|
280
|
+
const hasCustomMaxWidth = maxWidth !== c_popover_MaxWidth.value;
|
|
281
|
+
const onDocumentKeyDown = (event) => {
|
|
282
|
+
if (event.key === KeyTypes.Escape && visible) {
|
|
283
|
+
if (triggerManually) {
|
|
284
|
+
shouldClose(event, hide);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
hide(event);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const onDocumentClick = (event, triggerElement, popperElement) => {
|
|
292
|
+
if (hideOnOutsideClick && visible) {
|
|
293
|
+
const isFromChild = popperElement && popperElement.contains(event.target);
|
|
294
|
+
const isFromTrigger = triggerElement && triggerElement.contains(event.target);
|
|
295
|
+
if (isFromChild || isFromTrigger) {
|
|
296
|
+
// if clicked within the popper or on the trigger, ignore this event
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (triggerManually) {
|
|
300
|
+
shouldClose(event, hide);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
hide(event);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
const onTriggerClick = (event) => {
|
|
308
|
+
if (triggerManually) {
|
|
309
|
+
if (visible) {
|
|
310
|
+
shouldClose(event, hide);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
shouldOpen(event, show);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
if (visible) {
|
|
318
|
+
hide(event);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
show(event, true);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const onContentMouseDown = () => {
|
|
326
|
+
if (focusTrapActive) {
|
|
327
|
+
setFocusTrapActive(false);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const onMouseEnter = (event) => {
|
|
331
|
+
if (triggerManually) {
|
|
332
|
+
shouldOpen(event, show);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
show(event, false);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const onMouseLeave = (event) => {
|
|
339
|
+
if (triggerManually) {
|
|
340
|
+
shouldClose(event, hide);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
hide(event);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const onFocus = (event) => {
|
|
347
|
+
if (triggerManually) {
|
|
348
|
+
shouldOpen(event, show);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
show(event, false);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const onBlur = (event) => {
|
|
355
|
+
if (triggerManually) {
|
|
356
|
+
shouldClose(event, hide);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
hide(event);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
const closePopover = (event) => {
|
|
363
|
+
event.stopPropagation();
|
|
364
|
+
if (triggerManually) {
|
|
365
|
+
shouldClose(event, hide);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
hide(event);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const content = (React.createElement(FocusTrap, Object.assign({ ref: popoverRef, active: focusTrapActive, focusTrapOptions: {
|
|
372
|
+
returnFocusOnDeactivate: propWithFocusTrap !== false,
|
|
373
|
+
clickOutsideDeactivates: true,
|
|
374
|
+
// FocusTrap's initialFocus can accept false as a value to prevent initial focus.
|
|
375
|
+
// We want to prevent this in case false is ever passed in.
|
|
376
|
+
initialFocus: elementToFocus || undefined,
|
|
377
|
+
checkCanFocusTrap: (containers) => new Promise((resolve) => {
|
|
378
|
+
const interval = setInterval(() => {
|
|
379
|
+
if (containers.every((container) => getComputedStyle(container).visibility !== 'hidden')) {
|
|
380
|
+
resolve();
|
|
381
|
+
clearInterval(interval);
|
|
382
|
+
}
|
|
383
|
+
}, 10);
|
|
384
|
+
}),
|
|
385
|
+
tabbableOptions: { displayCheck: 'none' },
|
|
386
|
+
fallbackFocus: () => {
|
|
387
|
+
// If the popover's trigger is focused but scrolled out of view,
|
|
388
|
+
// FocusTrap will throw an error when the Enter button is used on the trigger.
|
|
389
|
+
// That is because the Popover is hidden when its trigger is out of view.
|
|
390
|
+
// Provide a fallback in that case.
|
|
391
|
+
let node = null;
|
|
392
|
+
if (document && document.activeElement) {
|
|
393
|
+
node = document.activeElement;
|
|
394
|
+
}
|
|
395
|
+
return node;
|
|
396
|
+
}
|
|
397
|
+
}, preventScrollOnDeactivate: true, className: css(styles$4.popover, alertSeverityVariant && alertStyle[alertSeverityVariant], hasNoPadding && styles$4.modifiers.noPadding, hasAutoWidth && styles$4.modifiers.widthAuto, className), role: "dialog", "aria-modal": "true", "aria-label": headerContent ? undefined : ariaLabel, "aria-labelledby": headerContent ? `popover-${uniqueId}-header` : undefined, "aria-describedby": `popover-${uniqueId}-body`, onMouseDown: onContentMouseDown, style: {
|
|
398
|
+
minWidth: hasCustomMinWidth ? minWidth : null,
|
|
399
|
+
maxWidth: hasCustomMaxWidth ? maxWidth : null
|
|
400
|
+
} }, rest),
|
|
401
|
+
React.createElement(PopoverArrow, null),
|
|
402
|
+
React.createElement(PopoverContent, null,
|
|
403
|
+
showClose && triggerAction === 'click' && (React.createElement(PopoverCloseButton, { onClose: closePopover, "aria-label": closeBtnAriaLabel })),
|
|
404
|
+
headerContent && (React.createElement(PopoverHeader, { id: `popover-${uniqueId}-header`, icon: headerIcon, alertSeverityVariant: alertSeverityVariant, alertSeverityScreenReaderText: alertSeverityScreenReaderText || `${alertSeverityVariant} alert:`, titleHeadingLevel: headerComponent }, typeof headerContent === 'function' ? headerContent(hide) : headerContent)),
|
|
405
|
+
React.createElement(PopoverBody, { id: `popover-${uniqueId}-body` }, typeof bodyContent === 'function' ? bodyContent(hide) : bodyContent),
|
|
406
|
+
footerContent && (React.createElement(PopoverFooter, { id: `popover-${uniqueId}-footer` }, typeof footerContent === 'function' ? footerContent(hide) : footerContent)))));
|
|
407
|
+
return (React.createElement(PopoverContext.Provider, { value: { headerComponent } },
|
|
408
|
+
React.createElement(Popper, { trigger: children, triggerRef: triggerRef, popper: content, popperRef: popoverRef, minWidth: minWidth, appendTo: appendTo, isVisible: visible, onMouseEnter: triggerAction === 'hover' && onMouseEnter, onMouseLeave: triggerAction === 'hover' && onMouseLeave, onPopperMouseEnter: triggerAction === 'hover' && onMouseEnter, onPopperMouseLeave: triggerAction === 'hover' && onMouseLeave, onFocus: triggerAction === 'hover' && onFocus, onBlur: triggerAction === 'hover' && onBlur, positionModifiers: positionModifiers, distance: distance, placement: position, onTriggerClick: triggerAction === 'click' && onTriggerClick, onDocumentClick: onDocumentClick, onDocumentKeyDown: onDocumentKeyDown, enableFlip: enableFlip, zIndex: zIndex, flipBehavior: flipBehavior, animationDuration: animationDuration, onHidden: onHidden, onShown: onShown, onHide: () => setFocusTrapActive(false) })));
|
|
409
|
+
};
|
|
410
|
+
Popover.displayName = 'Popover';
|
|
411
|
+
|
|
412
|
+
const labelStyles = {
|
|
413
|
+
"label": "pf-v6-c-label",
|
|
414
|
+
"labelActions": "pf-v6-c-label__actions",
|
|
415
|
+
"labelContent": "pf-v6-c-label__content",
|
|
416
|
+
"labelIcon": "pf-v6-c-label__icon",
|
|
417
|
+
"labelText": "pf-v6-c-label__text",
|
|
418
|
+
"modifiers": {
|
|
419
|
+
"blue": "pf-m-blue",
|
|
420
|
+
"red": "pf-m-red",
|
|
421
|
+
"orange": "pf-m-orange",
|
|
422
|
+
"orangered": "pf-m-orangered",
|
|
423
|
+
"yellow": "pf-m-yellow",
|
|
424
|
+
"green": "pf-m-green",
|
|
425
|
+
"teal": "pf-m-teal",
|
|
426
|
+
"purple": "pf-m-purple",
|
|
427
|
+
"success": "pf-m-success",
|
|
428
|
+
"warning": "pf-m-warning",
|
|
429
|
+
"danger": "pf-m-danger",
|
|
430
|
+
"info": "pf-m-info",
|
|
431
|
+
"custom": "pf-m-custom",
|
|
432
|
+
"compact": "pf-m-compact",
|
|
433
|
+
"filled": "pf-m-filled",
|
|
434
|
+
"outline": "pf-m-outline",
|
|
435
|
+
"editable": "pf-m-editable",
|
|
436
|
+
"editableActive": "pf-m-editable-active",
|
|
437
|
+
"overflow": "pf-m-overflow",
|
|
438
|
+
"add": "pf-m-add",
|
|
439
|
+
"clickable": "pf-m-clickable",
|
|
440
|
+
"disabled": "pf-m-disabled"
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
const styles$3 = {
|
|
445
|
+
"modifiers": {
|
|
446
|
+
"editable": "pf-m-editable"}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const c_label__text_MaxWidth = {
|
|
450
|
+
"name": "--pf-v6-c-label__text--MaxWidth"};
|
|
451
|
+
|
|
452
|
+
const colorStyles = {
|
|
453
|
+
blue: labelStyles.modifiers.blue,
|
|
454
|
+
teal: labelStyles.modifiers.teal,
|
|
455
|
+
green: labelStyles.modifiers.green,
|
|
456
|
+
orange: labelStyles.modifiers.orange,
|
|
457
|
+
purple: labelStyles.modifiers.purple,
|
|
458
|
+
red: labelStyles.modifiers.red,
|
|
459
|
+
orangered: labelStyles.modifiers.orangered,
|
|
460
|
+
yellow: labelStyles.modifiers.yellow,
|
|
461
|
+
grey: ''
|
|
462
|
+
};
|
|
463
|
+
const statusIcons = {
|
|
464
|
+
success: React.createElement(CheckCircleIcon, null),
|
|
465
|
+
warning: React.createElement(ExclamationTriangleIcon, null),
|
|
466
|
+
danger: React.createElement(ExclamationCircleIcon, null),
|
|
467
|
+
info: React.createElement(InfoCircleIcon, null),
|
|
468
|
+
custom: React.createElement(BellIcon, null)
|
|
469
|
+
};
|
|
470
|
+
const Label = (_a) => {
|
|
471
|
+
var { children, className = '', color = 'grey', variant = 'filled', status, isCompact = false, isDisabled = false, isEditable = false, editableProps, textMaxWidth, tooltipPosition, icon, onClose, onClick: onLabelClick, onEditCancel, onEditComplete, closeBtn, closeBtnAriaLabel, closeBtnProps, href, render } = _a, props = __rest(_a, ["children", "className", "color", "variant", "status", "isCompact", "isDisabled", "isEditable", "editableProps", "textMaxWidth", "tooltipPosition", "icon", "onClose", "onClick", "onEditCancel", "onEditComplete", "closeBtn", "closeBtnAriaLabel", "closeBtnProps", "href", "render"]);
|
|
472
|
+
const [isEditableActive, setIsEditableActive] = useState(false);
|
|
473
|
+
const [currValue, setCurrValue] = useState(children);
|
|
474
|
+
const editableButtonRef = React.useRef();
|
|
475
|
+
const editableInputRef = React.useRef();
|
|
476
|
+
const isOverflowLabel = variant === 'overflow';
|
|
477
|
+
const isAddLabel = variant === 'add';
|
|
478
|
+
const isClickable = (onLabelClick && !isOverflowLabel && !isAddLabel) || href;
|
|
479
|
+
let _icon;
|
|
480
|
+
if (status) {
|
|
481
|
+
_icon = statusIcons[status];
|
|
482
|
+
}
|
|
483
|
+
if (icon) {
|
|
484
|
+
_icon = icon;
|
|
485
|
+
}
|
|
486
|
+
React.useEffect(() => {
|
|
487
|
+
document.addEventListener('mousedown', onDocMouseDown);
|
|
488
|
+
document.addEventListener('keydown', onKeyDown);
|
|
489
|
+
return () => {
|
|
490
|
+
document.removeEventListener('mousedown', onDocMouseDown);
|
|
491
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
492
|
+
};
|
|
493
|
+
});
|
|
494
|
+
React.useEffect(() => {
|
|
495
|
+
if (onLabelClick && href) {
|
|
496
|
+
// eslint-disable-next-line no-console
|
|
497
|
+
console.warn('Link labels cannot have onClick passed, this results in invalid HTML. Please remove either the href or onClick prop.');
|
|
498
|
+
}
|
|
499
|
+
else if (onLabelClick && isEditable) {
|
|
500
|
+
// eslint-disable-next-line no-console
|
|
501
|
+
console.warn('Editable labels cannot have onClick passed, clicking starts the label edit process. Please remove either the isEditable or onClick prop.');
|
|
502
|
+
}
|
|
503
|
+
}, [onLabelClick, href, isEditable]);
|
|
504
|
+
const onDocMouseDown = (event) => {
|
|
505
|
+
if (isEditableActive &&
|
|
506
|
+
editableInputRef &&
|
|
507
|
+
editableInputRef.current &&
|
|
508
|
+
!editableInputRef.current.contains(event.target)) {
|
|
509
|
+
if (editableInputRef.current.value) {
|
|
510
|
+
onEditComplete && onEditComplete(event, editableInputRef.current.value);
|
|
511
|
+
}
|
|
512
|
+
setIsEditableActive(false);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
const onKeyDown = (event) => {
|
|
516
|
+
var _a, _b;
|
|
517
|
+
const key = event.key;
|
|
518
|
+
if ((!isEditableActive &&
|
|
519
|
+
(!editableButtonRef ||
|
|
520
|
+
!editableButtonRef.current ||
|
|
521
|
+
!editableButtonRef.current.contains(event.target))) ||
|
|
522
|
+
(isEditableActive &&
|
|
523
|
+
(!editableInputRef || !editableInputRef.current || !editableInputRef.current.contains(event.target)))) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (isEditableActive && (key === 'Enter' || key === 'Tab')) {
|
|
527
|
+
event.preventDefault();
|
|
528
|
+
event.stopImmediatePropagation();
|
|
529
|
+
if (editableInputRef.current.value) {
|
|
530
|
+
onEditComplete && onEditComplete(event, editableInputRef.current.value);
|
|
531
|
+
}
|
|
532
|
+
setIsEditableActive(false);
|
|
533
|
+
(_a = editableButtonRef === null || editableButtonRef === void 0 ? void 0 : editableButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
534
|
+
}
|
|
535
|
+
if (isEditableActive && key === 'Escape') {
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
event.stopImmediatePropagation();
|
|
538
|
+
// Reset div text to initial children prop - pre-edit
|
|
539
|
+
if (editableInputRef.current.value) {
|
|
540
|
+
editableInputRef.current.value = children;
|
|
541
|
+
onEditCancel && onEditCancel(event, children);
|
|
542
|
+
}
|
|
543
|
+
setIsEditableActive(false);
|
|
544
|
+
(_b = editableButtonRef === null || editableButtonRef === void 0 ? void 0 : editableButtonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
545
|
+
}
|
|
546
|
+
if (!isEditableActive && key === 'Enter') {
|
|
547
|
+
event.preventDefault();
|
|
548
|
+
event.stopImmediatePropagation();
|
|
549
|
+
setIsEditableActive(true);
|
|
550
|
+
// Set cursor position to end of text
|
|
551
|
+
const el = event.target;
|
|
552
|
+
const range = document.createRange();
|
|
553
|
+
const sel = window.getSelection();
|
|
554
|
+
range.selectNodeContents(el);
|
|
555
|
+
range.collapse(false);
|
|
556
|
+
sel.removeAllRanges();
|
|
557
|
+
sel.addRange(range);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
const isClickableDisabled = (href || onLabelClick) && isDisabled;
|
|
561
|
+
const defaultCloseButton = (React.createElement(Button, Object.assign({ type: "button", variant: "plain", hasNoPadding: true, onClick: onClose, "aria-label": closeBtnAriaLabel || `Close ${children}` }, (isClickableDisabled && { isDisabled: true }), closeBtnProps, { icon: React.createElement(TimesIcon, null) })));
|
|
562
|
+
const closeButton = React.createElement("span", { className: css(labelStyles.labelActions) }, closeBtn || defaultCloseButton);
|
|
563
|
+
const textRef = React.createRef();
|
|
564
|
+
// ref to apply tooltip when rendered is used
|
|
565
|
+
const componentRef = React.useRef();
|
|
566
|
+
const [isTooltipVisible, setIsTooltipVisible] = React.useState(false);
|
|
567
|
+
useIsomorphicLayoutEffect(() => {
|
|
568
|
+
const currTextRef = isEditable ? editableButtonRef : textRef;
|
|
569
|
+
if (!isEditableActive) {
|
|
570
|
+
setIsTooltipVisible(currTextRef.current && currTextRef.current.offsetWidth < currTextRef.current.scrollWidth);
|
|
571
|
+
}
|
|
572
|
+
}, [isEditableActive]);
|
|
573
|
+
const content = (React.createElement(React.Fragment, null,
|
|
574
|
+
_icon && React.createElement("span", { className: css(labelStyles.labelIcon) }, _icon),
|
|
575
|
+
React.createElement("span", Object.assign({ ref: textRef, className: css(labelStyles.labelText) }, (textMaxWidth && {
|
|
576
|
+
style: {
|
|
577
|
+
[c_label__text_MaxWidth.name]: textMaxWidth
|
|
578
|
+
}
|
|
579
|
+
})), children)));
|
|
580
|
+
React.useEffect(() => {
|
|
581
|
+
if (isEditableActive && editableInputRef) {
|
|
582
|
+
editableInputRef.current && editableInputRef.current.focus();
|
|
583
|
+
}
|
|
584
|
+
}, [editableInputRef, isEditableActive]);
|
|
585
|
+
const updateVal = () => {
|
|
586
|
+
setCurrValue(editableInputRef.current.value);
|
|
587
|
+
};
|
|
588
|
+
let LabelComponentChildElement = 'span';
|
|
589
|
+
if (href) {
|
|
590
|
+
LabelComponentChildElement = 'a';
|
|
591
|
+
}
|
|
592
|
+
else if (isEditable || (onLabelClick && !isOverflowLabel && !isAddLabel)) {
|
|
593
|
+
LabelComponentChildElement = 'button';
|
|
594
|
+
}
|
|
595
|
+
const clickableLabelProps = {
|
|
596
|
+
type: 'button',
|
|
597
|
+
onClick: onLabelClick
|
|
598
|
+
};
|
|
599
|
+
const isButton = LabelComponentChildElement === 'button';
|
|
600
|
+
const labelComponentChildProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: css(labelStyles.labelContent, isClickable && labelStyles.modifiers.clickable) }, (isTooltipVisible && { tabIndex: 0 })), (href && { href })), (href && isDisabled && { onClick: (event) => event.preventDefault() })), (isButton && clickableLabelProps)), (isEditable && Object.assign({ ref: editableButtonRef, onClick: (e) => {
|
|
601
|
+
setIsEditableActive(true);
|
|
602
|
+
e.stopPropagation();
|
|
603
|
+
} }, editableProps))), (isClickableDisabled && isButton && { disabled: true })), (isClickableDisabled && href && { tabIndex: -1, 'aria-disabled': true }));
|
|
604
|
+
let labelComponentChild = (React.createElement(LabelComponentChildElement, Object.assign({}, labelComponentChildProps), content));
|
|
605
|
+
if (render) {
|
|
606
|
+
labelComponentChild = (React.createElement(React.Fragment, null,
|
|
607
|
+
isTooltipVisible && React.createElement(Tooltip, { triggerRef: componentRef, content: children, position: tooltipPosition }),
|
|
608
|
+
render({
|
|
609
|
+
className: labelStyles.labelContent,
|
|
610
|
+
content,
|
|
611
|
+
componentRef
|
|
612
|
+
})));
|
|
613
|
+
}
|
|
614
|
+
else if (isTooltipVisible) {
|
|
615
|
+
labelComponentChild = (React.createElement(Tooltip, { content: children, position: tooltipPosition }, labelComponentChild));
|
|
616
|
+
}
|
|
617
|
+
const LabelComponent = (isOverflowLabel ? 'button' : 'span');
|
|
618
|
+
return (React.createElement(LabelComponent, Object.assign({}, props, { className: css(labelStyles.label, isClickableDisabled && labelStyles.modifiers.disabled, colorStyles[color], variant === 'filled' && labelStyles.modifiers.filled, variant === 'outline' && labelStyles.modifiers.outline, status && labelStyles.modifiers[status], isOverflowLabel && labelStyles.modifiers.overflow, isCompact && labelStyles.modifiers.compact, isEditable && styles$3.modifiers.editable, isEditableActive && labelStyles.modifiers.editableActive, isClickable && labelStyles.modifiers.clickable, isAddLabel && labelStyles.modifiers.add, className), onClick: isOverflowLabel || isAddLabel ? onLabelClick : undefined }, (LabelComponent === 'button' && { type: 'button' })),
|
|
619
|
+
!isEditableActive && labelComponentChild,
|
|
620
|
+
!isEditableActive && onClose && closeButton,
|
|
621
|
+
isEditableActive && (React.createElement("input", Object.assign({ className: css(labelStyles.labelContent), type: "text", id: "editable-input", ref: editableInputRef, value: currValue, onChange: updateVal }, editableProps)))));
|
|
622
|
+
};
|
|
623
|
+
Label.displayName = 'Label';
|
|
624
|
+
|
|
625
|
+
const styles$2 = {
|
|
626
|
+
"modifiers": {
|
|
627
|
+
"gutter": "pf-m-gutter"
|
|
628
|
+
},
|
|
629
|
+
"stack": "pf-v6-l-stack"};
|
|
630
|
+
|
|
631
|
+
const Stack = (_a) => {
|
|
632
|
+
var { hasGutter = false, className = '', children = null, component = 'div' } = _a, props = __rest(_a, ["hasGutter", "className", "children", "component"]);
|
|
633
|
+
const Component = component;
|
|
634
|
+
return (React.createElement(Component, Object.assign({}, props, { className: css(styles$2.stack, hasGutter && styles$2.modifiers.gutter, className) }), children));
|
|
635
|
+
};
|
|
636
|
+
Stack.displayName = 'Stack';
|
|
637
|
+
|
|
638
|
+
const EllipsisVIconConfig = {
|
|
639
|
+
name: 'EllipsisVIcon',
|
|
640
|
+
height: 512,
|
|
641
|
+
width: 192,
|
|
642
|
+
svgPath: 'M96 184c39.8 0 72 32.2 72 72s-32.2 72-72 72-72-32.2-72-72 32.2-72 72-72zM24 80c0 39.8 32.2 72 72 72s72-32.2 72-72S135.8 8 96 8 24 40.2 24 80zm0 352c0 39.8 32.2 72 72 72s72-32.2 72-72-32.2-72-72-72-72 32.2-72 72z',
|
|
643
|
+
yOffset: 0,
|
|
644
|
+
xOffset: 0,
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
const EllipsisVIcon = createIcon(EllipsisVIconConfig);
|
|
648
|
+
|
|
649
|
+
const ActionsColumnBase = (_a) => {
|
|
650
|
+
var { items, isDisabled, rowData, extraData, actionsToggle, popperProps = {
|
|
651
|
+
position: 'end',
|
|
652
|
+
direction: 'down'
|
|
653
|
+
}, innerRef, firstActionItemRef, isOnOpenChangeDisabled = false } = _a, props = __rest(_a, ["items", "isDisabled", "rowData", "extraData", "actionsToggle", "popperProps", "innerRef", "firstActionItemRef", "isOnOpenChangeDisabled"]);
|
|
654
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
655
|
+
const onToggle = () => {
|
|
656
|
+
setIsOpen(!isOpen);
|
|
657
|
+
};
|
|
658
|
+
const onActionClick = (event, onClick) => {
|
|
659
|
+
// Only prevent default if onClick is provided. This allows href support.
|
|
660
|
+
if (onClick) {
|
|
661
|
+
event.preventDefault();
|
|
662
|
+
// tslint:disable-next-line:no-unused-expression
|
|
663
|
+
onClick(event, extraData && extraData.rowIndex, rowData, extraData);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
return (React.createElement(React.Fragment, null,
|
|
667
|
+
items
|
|
668
|
+
.filter((item) => item.isOutsideDropdown)
|
|
669
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
670
|
+
.map((_a, key) => {
|
|
671
|
+
var { title, itemKey, onClick, isOutsideDropdown } = _a, props = __rest(_a, ["title", "itemKey", "onClick", "isOutsideDropdown"]);
|
|
672
|
+
return typeof title === 'string' ? (React.createElement(Button, Object.assign({ onClick: (event) => onActionClick(event, onClick) }, props, { isDisabled: isDisabled, key: itemKey || `outside_dropdown_${key}`, "data-key": itemKey || `outside_dropdown_${key}` }), title)) : (React.cloneElement(title, Object.assign({ onClick, isDisabled }, props)));
|
|
673
|
+
}),
|
|
674
|
+
React.createElement(Dropdown, Object.assign({ isOpen: isOpen, onOpenChange: !isOnOpenChangeDisabled ? (isOpen) => setIsOpen(isOpen) : undefined, toggle: (toggleRef) => actionsToggle ? (actionsToggle({ onToggle, isOpen, isDisabled, toggleRef })) : (React.createElement(MenuToggle, { "aria-label": "Kebab toggle", ref: toggleRef, onClick: onToggle, isExpanded: isOpen, isDisabled: isDisabled, variant: "plain", icon: React.createElement(EllipsisVIcon, null) })) }, (rowData && rowData.actionProps), { ref: innerRef }, props, { popperProps: popperProps }),
|
|
675
|
+
React.createElement(DropdownList, null, items
|
|
676
|
+
.filter((item) => !item.isOutsideDropdown)
|
|
677
|
+
.map((_a, index) => {
|
|
678
|
+
var { title, itemKey, onClick, tooltipProps, isSeparator, shouldCloseOnClick = true } = _a, props = __rest(_a, ["title", "itemKey", "onClick", "tooltipProps", "isSeparator", "shouldCloseOnClick"]);
|
|
679
|
+
if (isSeparator) {
|
|
680
|
+
return React.createElement(Divider, { key: itemKey || index, "data-key": itemKey || index });
|
|
681
|
+
}
|
|
682
|
+
const item = (React.createElement(DropdownItem, Object.assign({ onClick: (event) => {
|
|
683
|
+
onActionClick(event, onClick);
|
|
684
|
+
shouldCloseOnClick && onToggle();
|
|
685
|
+
} }, props, { key: itemKey || index, "data-key": itemKey || index, ref: index === 0 ? firstActionItemRef : undefined }), title));
|
|
686
|
+
if (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content) {
|
|
687
|
+
return (React.createElement(Tooltip, Object.assign({ key: itemKey || index }, tooltipProps), item));
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
return item;
|
|
691
|
+
}
|
|
692
|
+
})))));
|
|
693
|
+
};
|
|
694
|
+
const ActionsColumn = React.forwardRef((props, ref) => (React.createElement(ActionsColumnBase, Object.assign({}, props, { innerRef: ref }))));
|
|
695
|
+
ActionsColumn.displayName = 'ActionsColumn';
|
|
696
|
+
|
|
697
|
+
const styles$1 = {
|
|
698
|
+
"modifiers": {
|
|
699
|
+
"fixed": "pf-m-fixed",
|
|
700
|
+
"stickyHeader": "pf-m-sticky-header",
|
|
701
|
+
"nestedColumnHeader": "pf-m-nested-column-header",
|
|
702
|
+
"striped": "pf-m-striped",
|
|
703
|
+
"expandable": "pf-m-expandable",
|
|
704
|
+
"stripedEven": "pf-m-striped-even",
|
|
705
|
+
"ghostRow": "pf-m-ghost-row",
|
|
706
|
+
"hidden": "pf-m-hidden",
|
|
707
|
+
"hiddenOnSm": "pf-m-hidden-on-sm",
|
|
708
|
+
"visibleOnSm": "pf-m-visible-on-sm",
|
|
709
|
+
"hiddenOnMd": "pf-m-hidden-on-md",
|
|
710
|
+
"visibleOnMd": "pf-m-visible-on-md",
|
|
711
|
+
"hiddenOnLg": "pf-m-hidden-on-lg",
|
|
712
|
+
"visibleOnLg": "pf-m-visible-on-lg",
|
|
713
|
+
"hiddenOnXl": "pf-m-hidden-on-xl",
|
|
714
|
+
"visibleOnXl": "pf-m-visible-on-xl",
|
|
715
|
+
"hiddenOn_2xl": "pf-m-hidden-on-2xl",
|
|
716
|
+
"visibleOn_2xl": "pf-m-visible-on-2xl",
|
|
717
|
+
"center": "pf-m-center",
|
|
718
|
+
"help": "pf-m-help",
|
|
719
|
+
"favorite": "pf-m-favorite",
|
|
720
|
+
"borderRight": "pf-m-border-right",
|
|
721
|
+
"borderLeft": "pf-m-border-left",
|
|
722
|
+
"noBorderRows": "pf-m-no-border-rows",
|
|
723
|
+
"expanded": "pf-m-expanded",
|
|
724
|
+
"clickable": "pf-m-clickable",
|
|
725
|
+
"selected": "pf-m-selected",
|
|
726
|
+
"firstCellOffsetReset": "pf-m-first-cell-offset-reset",
|
|
727
|
+
"dragOver": "pf-m-drag-over",
|
|
728
|
+
"truncate": "pf-m-truncate",
|
|
729
|
+
"wrap": "pf-m-wrap",
|
|
730
|
+
"nowrap": "pf-m-nowrap",
|
|
731
|
+
"fitContent": "pf-m-fit-content",
|
|
732
|
+
"breakWord": "pf-m-break-word",
|
|
733
|
+
"standalone": "pf-m-standalone",
|
|
734
|
+
"favorited": "pf-m-favorited",
|
|
735
|
+
"noPadding": "pf-m-no-padding",
|
|
736
|
+
"compact": "pf-m-compact",
|
|
737
|
+
"borderRow": "pf-m-border-row",
|
|
738
|
+
"width_10": "pf-m-width-10",
|
|
739
|
+
"width_15": "pf-m-width-15",
|
|
740
|
+
"width_20": "pf-m-width-20",
|
|
741
|
+
"width_25": "pf-m-width-25",
|
|
742
|
+
"width_30": "pf-m-width-30",
|
|
743
|
+
"width_35": "pf-m-width-35",
|
|
744
|
+
"width_40": "pf-m-width-40",
|
|
745
|
+
"width_45": "pf-m-width-45",
|
|
746
|
+
"width_50": "pf-m-width-50",
|
|
747
|
+
"width_60": "pf-m-width-60",
|
|
748
|
+
"width_70": "pf-m-width-70",
|
|
749
|
+
"width_80": "pf-m-width-80",
|
|
750
|
+
"width_90": "pf-m-width-90",
|
|
751
|
+
"width_100": "pf-m-width-100"
|
|
752
|
+
},
|
|
753
|
+
"table": "pf-v6-c-table",
|
|
754
|
+
"tableAction": "pf-v6-c-table__action",
|
|
755
|
+
"tableButton": "pf-v6-c-table__button",
|
|
756
|
+
"tableButtonContent": "pf-v6-c-table__button-content",
|
|
757
|
+
"tableCheck": "pf-v6-c-table__check",
|
|
758
|
+
"tableColumnHelp": "pf-v6-c-table__column-help",
|
|
759
|
+
"tableColumnHelpAction": "pf-v6-c-table__column-help-action",
|
|
760
|
+
"tableCompoundExpansionToggle": "pf-v6-c-table__compound-expansion-toggle",
|
|
761
|
+
"tableControlRow": "pf-v6-c-table__control-row",
|
|
762
|
+
"tableDraggable": "pf-v6-c-table__draggable",
|
|
763
|
+
"tableExpandableRow": "pf-v6-c-table__expandable-row",
|
|
764
|
+
"tableFavorite": "pf-v6-c-table__favorite",
|
|
765
|
+
"tableSort": "pf-v6-c-table__sort",
|
|
766
|
+
"tableSortIndicator": "pf-v6-c-table__sort-indicator",
|
|
767
|
+
"tableSubhead": "pf-v6-c-table__subhead",
|
|
768
|
+
"tableTbody": "pf-v6-c-table__tbody",
|
|
769
|
+
"tableTd": "pf-v6-c-table__td",
|
|
770
|
+
"tableText": "pf-v6-c-table__text",
|
|
771
|
+
"tableTh": "pf-v6-c-table__th",
|
|
772
|
+
"tableThead": "pf-v6-c-table__thead",
|
|
773
|
+
"tableToggle": "pf-v6-c-table__toggle",
|
|
774
|
+
"tableToggleIcon": "pf-v6-c-table__toggle-icon",
|
|
775
|
+
"tableTr": "pf-v6-c-table__tr"
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
const CollapseColumn = (_a) => {
|
|
779
|
+
var { className = '', children = null, isOpen, onToggle } = _a, props = __rest(_a, ["className", "children", "isOpen", "onToggle"]);
|
|
780
|
+
return (React.createElement(React.Fragment, null,
|
|
781
|
+
isOpen !== undefined && (React.createElement(Button, Object.assign({ className: css(className, isOpen && styles$1.modifiers.expanded) }, props, { variant: "plain", "aria-label": props['aria-label'] || 'Details', onClick: onToggle, "aria-expanded": isOpen, icon: React.createElement("div", { className: css(styles$1.tableToggleIcon) },
|
|
782
|
+
React.createElement(AngleDownIcon, null)) }))),
|
|
783
|
+
children));
|
|
784
|
+
};
|
|
785
|
+
CollapseColumn.displayName = 'CollapseColumn';
|
|
786
|
+
|
|
787
|
+
const DraggableCell = (_a) => {
|
|
788
|
+
var { className, onClick, 'aria-label': ariaLabel, id } = _a, props = __rest(_a, ["className", "onClick", 'aria-label', "id"]);
|
|
789
|
+
return (React.createElement(Button, Object.assign({ id: id, variant: "plain", className: className, type: "button", "aria-label": ariaLabel || `Draggable row draggable button`, onClick: onClick }, props, { icon: React.createElement(GripVerticalIcon, { "aria-hidden": true }) })));
|
|
790
|
+
};
|
|
791
|
+
DraggableCell.displayName = 'DraggableCell';
|
|
792
|
+
|
|
793
|
+
const inlineStyles = {
|
|
794
|
+
"modifiers": {
|
|
795
|
+
"inlineEditable": "pf-m-inline-editable"}
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
const HelpIconConfig = {
|
|
799
|
+
name: 'HelpIcon',
|
|
800
|
+
height: 1024,
|
|
801
|
+
width: 1024,
|
|
802
|
+
svgPath: 'M521.3,576 C627.5,576 713.7,502 713.7,413.7 C713.7,325.4 627.6,253.6 521.3,253.6 C366,253.6 334.5,337.7 329.2,407.2 C329.2,414.3 335.2,416 343.5,416 L445,416 C450.5,416 458,415.5 460.8,406.5 C460.8,362.6 582.9,357.1 582.9,413.6 C582.9,441.9 556.2,470.9 521.3,473 C486.4,475.1 447.3,479.8 447.3,521.7 L447.3,553.8 C447.3,570.8 456.1,576 472,576 C487.9,576 521.3,576 521.3,576 M575.3,751.3 L575.3,655.3 C575.313862,651.055109 573.620137,646.982962 570.6,644 C567.638831,640.947672 563.552355,639.247987 559.3,639.29884 L463.3,639.29884 C459.055109,639.286138 454.982962,640.979863 452,644 C448.947672,646.961169 447.247987,651.047645 447.29884,655.3 L447.29884,751.3 C447.286138,755.544891 448.979863,759.617038 452,762.6 C454.961169,765.652328 459.047645,767.352013 463.3,767.30116 L559.3,767.30116 C563.544891,767.313862 567.617038,765.620137 570.6,762.6 C573.659349,759.643612 575.360354,755.553963 575.3,751.3 M512,896 C300.2,896 128,723.9 128,512 C128,300.3 300.2,128 512,128 C723.8,128 896,300.2 896,512 C896,723.8 723.7,896 512,896 M512.1,0 C229.7,0 0,229.8 0,512 C0,794.2 229.8,1024 512.1,1024 C794.4,1024 1024,794.3 1024,512 C1024,229.7 794.4,0 512.1,0',
|
|
803
|
+
yOffset: 0,
|
|
804
|
+
xOffset: 0,
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
const HelpIcon = createIcon(HelpIconConfig);
|
|
808
|
+
|
|
809
|
+
var TableTextVariant;
|
|
810
|
+
(function (TableTextVariant) {
|
|
811
|
+
TableTextVariant["div"] = "div";
|
|
812
|
+
TableTextVariant["nav"] = "nav";
|
|
813
|
+
})(TableTextVariant || (TableTextVariant = {}));
|
|
814
|
+
var WrapModifier;
|
|
815
|
+
(function (WrapModifier) {
|
|
816
|
+
WrapModifier["wrap"] = "wrap";
|
|
817
|
+
WrapModifier["nowrap"] = "nowrap";
|
|
818
|
+
WrapModifier["truncate"] = "truncate";
|
|
819
|
+
WrapModifier["breakWord"] = "breakWord";
|
|
820
|
+
WrapModifier["fitContent"] = "fitContent";
|
|
821
|
+
})(WrapModifier || (WrapModifier = {}));
|
|
822
|
+
const TableText = (_a) => {
|
|
823
|
+
var { children = null, className = '', variant = 'span', wrapModifier = null, tooltip: tooltipProp = '', tooltipProps = {}, onMouseEnter: onMouseEnterProp = () => { }, focused = false, tooltipHasDefaultBehavior = false } = _a, props = __rest(_a, ["children", "className", "variant", "wrapModifier", "tooltip", "tooltipProps", "onMouseEnter", "focused", "tooltipHasDefaultBehavior"]);
|
|
824
|
+
const Component = variant;
|
|
825
|
+
const textRef = React.createRef();
|
|
826
|
+
const [tooltip, setTooltip] = React.useState(tooltipProp);
|
|
827
|
+
const onMouseEnter = (event) => {
|
|
828
|
+
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
829
|
+
setTooltip(tooltipProp || event.target.innerText);
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
setTooltip('');
|
|
833
|
+
}
|
|
834
|
+
onMouseEnterProp(event);
|
|
835
|
+
};
|
|
836
|
+
const onFocus = (element) => {
|
|
837
|
+
if (element.offsetWidth < element.scrollWidth) {
|
|
838
|
+
setTooltip(tooltipProp || element.innerText);
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
setTooltip('');
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
const text = (React.createElement(Component, Object.assign({ ref: textRef, onMouseEnter: !tooltipHasDefaultBehavior ? onMouseEnter : undefined, className: css(className, wrapModifier && styles$1.modifiers[wrapModifier], styles$1.tableText) }, props), children));
|
|
845
|
+
React.useEffect(() => {
|
|
846
|
+
if (!tooltipHasDefaultBehavior) {
|
|
847
|
+
if (focused) {
|
|
848
|
+
onFocus(textRef.current);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
setTooltip('');
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}, [focused, tooltipHasDefaultBehavior]);
|
|
855
|
+
return tooltip !== '' ? (React.createElement(Tooltip, Object.assign({ triggerRef: textRef, content: tooltip }, (!tooltipHasDefaultBehavior && { isVisible: true }), tooltipProps), text)) : (text);
|
|
856
|
+
};
|
|
857
|
+
TableText.displayName = 'TableText';
|
|
858
|
+
|
|
859
|
+
const HeaderCellInfoWrapper = ({ children, info, className, variant = 'tooltip', popoverProps, tooltipProps, ariaLabel }) => (React.createElement("div", { className: css(styles$1.tableColumnHelp, className) },
|
|
860
|
+
typeof children === 'string' ? React.createElement(TableText, null, children) : children,
|
|
861
|
+
React.createElement("span", { className: css(styles$1.tableColumnHelpAction) }, variant === 'tooltip' ? (React.createElement(Tooltip, Object.assign({ content: info }, tooltipProps),
|
|
862
|
+
React.createElement(Button, { variant: "plain", hasNoPadding: true, "aria-label": ariaLabel || (typeof info === 'string' && info) || 'More info', icon: React.createElement(HelpIcon, null) }))) : (React.createElement(Popover, Object.assign({ bodyContent: info }, popoverProps),
|
|
863
|
+
React.createElement(Button, { variant: "plain", hasNoPadding: true, "aria-label": ariaLabel || (typeof info === 'string' && info) || 'More info', icon: React.createElement(HelpIcon, null) }))))));
|
|
864
|
+
HeaderCellInfoWrapper.displayName = 'HeaderCellInfoWrapper';
|
|
865
|
+
|
|
866
|
+
const stylesGrid = {
|
|
867
|
+
"modifiers": {
|
|
868
|
+
"grid": "pf-m-grid",
|
|
869
|
+
"expandable": "pf-m-expandable",
|
|
870
|
+
"expanded": "pf-m-expanded",
|
|
871
|
+
"selected": "pf-m-selected",
|
|
872
|
+
"compact": "pf-m-compact",
|
|
873
|
+
"noPadding": "pf-m-no-padding",
|
|
874
|
+
"hoverable": "pf-m-hoverable",
|
|
875
|
+
"nowrap": "pf-m-nowrap",
|
|
876
|
+
"fitContent": "pf-m-fit-content",
|
|
877
|
+
"truncate": "pf-m-truncate",
|
|
878
|
+
"gridMd": "pf-m-grid-md",
|
|
879
|
+
"gridLg": "pf-m-grid-lg",
|
|
880
|
+
"gridXl": "pf-m-grid-xl",
|
|
881
|
+
"grid_2xl": "pf-m-grid-2xl"
|
|
882
|
+
}};
|
|
883
|
+
|
|
884
|
+
const treeViewStyles = {
|
|
885
|
+
"modifiers": {
|
|
886
|
+
"treeView": "pf-m-tree-view",
|
|
887
|
+
"noInset": "pf-m-no-inset",
|
|
888
|
+
"treeViewGrid": "pf-m-tree-view-grid",
|
|
889
|
+
"borderRight": "pf-m-border-right",
|
|
890
|
+
"treeViewDetailsExpanded": "pf-m-tree-view-details-expanded",
|
|
891
|
+
"treeViewGridMd": "pf-m-tree-view-grid-md",
|
|
892
|
+
"treeViewGridLg": "pf-m-tree-view-grid-lg",
|
|
893
|
+
"treeViewGridXl": "pf-m-tree-view-grid-xl",
|
|
894
|
+
"treeViewGrid_2xl": "pf-m-tree-view-grid-2xl"
|
|
895
|
+
},
|
|
896
|
+
"tableCheck": "pf-v6-c-table__check",
|
|
897
|
+
"tableToggle": "pf-v6-c-table__toggle",
|
|
898
|
+
"tableToggleIcon": "pf-v6-c-table__toggle-icon",
|
|
899
|
+
"tableTreeViewDetailsToggle": "pf-v6-c-table__tree-view-details-toggle",
|
|
900
|
+
"tableTreeViewIcon": "pf-v6-c-table__tree-view-icon",
|
|
901
|
+
"tableTreeViewMain": "pf-v6-c-table__tree-view-main",
|
|
902
|
+
"tableTreeViewText": "pf-v6-c-table__tree-view-text",
|
|
903
|
+
"tableTreeViewTitleCell": "pf-v6-c-table__tree-view-title-cell"
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
var RowSelectVariant;
|
|
907
|
+
(function (RowSelectVariant) {
|
|
908
|
+
RowSelectVariant["radio"] = "radio";
|
|
909
|
+
RowSelectVariant["checkbox"] = "checkbox";
|
|
910
|
+
})(RowSelectVariant || (RowSelectVariant = {}));
|
|
911
|
+
const SelectColumn = (_a) => {
|
|
912
|
+
var { children = null,
|
|
913
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
914
|
+
className, onSelect = null, selectVariant, tooltip, tooltipProps } = _a, props = __rest(_a, ["children", "className", "onSelect", "selectVariant", "tooltip", "tooltipProps"]);
|
|
915
|
+
const inputRef = React.createRef();
|
|
916
|
+
const content = (React.createElement(React.Fragment, null,
|
|
917
|
+
React.createElement("label", null,
|
|
918
|
+
React.createElement("input", Object.assign({}, props, { ref: inputRef, type: selectVariant, onChange: onSelect }))),
|
|
919
|
+
children));
|
|
920
|
+
return tooltip ? (React.createElement(Tooltip, Object.assign({ triggerRef: inputRef, content: tooltip }, tooltipProps), content)) : (content);
|
|
921
|
+
};
|
|
922
|
+
SelectColumn.displayName = 'SelectColumn';
|
|
923
|
+
|
|
924
|
+
const selectable = (label, { rowIndex, columnIndex, rowData, column, property, tooltip }) => {
|
|
925
|
+
const { extraParams: { onSelect, selectVariant, allRowsSelected, isHeaderSelectDisabled } } = column;
|
|
926
|
+
const extraData = {
|
|
927
|
+
rowIndex,
|
|
928
|
+
columnIndex,
|
|
929
|
+
column,
|
|
930
|
+
property
|
|
931
|
+
};
|
|
932
|
+
if (rowData && rowData.hasOwnProperty('parent') && !rowData.showSelect && !rowData.fullWidth) {
|
|
933
|
+
return {
|
|
934
|
+
component: 'td',
|
|
935
|
+
isVisible: true
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
const rowId = rowIndex !== undefined ? rowIndex : -1;
|
|
939
|
+
/**
|
|
940
|
+
* @param {React.FormEvent} event - React form event
|
|
941
|
+
*/
|
|
942
|
+
function selectClick(event) {
|
|
943
|
+
const selected = rowIndex === undefined ? event.currentTarget.checked : rowData && !rowData.selected;
|
|
944
|
+
// tslint:disable-next-line:no-unused-expression
|
|
945
|
+
onSelect && onSelect(event, selected, rowId, rowData, extraData);
|
|
946
|
+
}
|
|
947
|
+
const customProps = Object.assign(Object.assign(Object.assign({}, (rowId !== -1
|
|
948
|
+
? {
|
|
949
|
+
checked: rowData && !!rowData.selected,
|
|
950
|
+
'aria-label': `Select row ${rowIndex}`
|
|
951
|
+
}
|
|
952
|
+
: {
|
|
953
|
+
checked: allRowsSelected,
|
|
954
|
+
'aria-label': 'Select all rows'
|
|
955
|
+
})), (rowData &&
|
|
956
|
+
(rowData.disableCheckbox || rowData.disableSelection) && {
|
|
957
|
+
disabled: true,
|
|
958
|
+
className: checkStyles.checkInput
|
|
959
|
+
})), (!rowData && isHeaderSelectDisabled && { disabled: true }));
|
|
960
|
+
let selectName = 'check-all';
|
|
961
|
+
if (rowId !== -1 && selectVariant === RowSelectVariant.checkbox) {
|
|
962
|
+
selectName = `checkrow${rowIndex}`;
|
|
963
|
+
}
|
|
964
|
+
else if (rowId !== -1) {
|
|
965
|
+
selectName = 'radioGroup';
|
|
966
|
+
}
|
|
967
|
+
return {
|
|
968
|
+
className: css(styles$1.tableCheck),
|
|
969
|
+
component: rowId !== -1 ? 'td' : 'th',
|
|
970
|
+
isVisible: !rowData || !rowData.fullWidth,
|
|
971
|
+
children: (React.createElement(SelectColumn, Object.assign({}, customProps, { selectVariant: selectVariant, onSelect: selectClick, name: selectName, tooltip: tooltip }), label))
|
|
972
|
+
};
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
const LongArrowAltUpIconConfig = {
|
|
976
|
+
name: 'LongArrowAltUpIcon',
|
|
977
|
+
height: 512,
|
|
978
|
+
width: 256,
|
|
979
|
+
svgPath: 'M88 166.059V468c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12V166.059h46.059c21.382 0 32.09-25.851 16.971-40.971l-86.059-86.059c-9.373-9.373-24.569-9.373-33.941 0l-86.059 86.059c-15.119 15.119-4.411 40.971 16.971 40.971H88z',
|
|
980
|
+
yOffset: 0,
|
|
981
|
+
xOffset: 0,
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
const LongArrowAltUpIcon = createIcon(LongArrowAltUpIconConfig);
|
|
985
|
+
|
|
986
|
+
const LongArrowAltDownIconConfig = {
|
|
987
|
+
name: 'LongArrowAltDownIcon',
|
|
988
|
+
height: 512,
|
|
989
|
+
width: 256,
|
|
990
|
+
svgPath: 'M168 345.941V44c0-6.627-5.373-12-12-12h-56c-6.627 0-12 5.373-12 12v301.941H41.941c-21.382 0-32.09 25.851-16.971 40.971l86.059 86.059c9.373 9.373 24.569 9.373 33.941 0l86.059-86.059c15.119-15.119 4.411-40.971-16.971-40.971H168z',
|
|
991
|
+
yOffset: 0,
|
|
992
|
+
xOffset: 0,
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
const LongArrowAltDownIcon = createIcon(LongArrowAltDownIconConfig);
|
|
996
|
+
|
|
997
|
+
const ArrowsAltVIconConfig = {
|
|
998
|
+
name: 'ArrowsAltVIcon',
|
|
999
|
+
height: 512,
|
|
1000
|
+
width: 256,
|
|
1001
|
+
svgPath: 'M214.059 377.941H168V134.059h46.059c21.382 0 32.09-25.851 16.971-40.971L144.971 7.029c-9.373-9.373-24.568-9.373-33.941 0L24.971 93.088c-15.119 15.119-4.411 40.971 16.971 40.971H88v243.882H41.941c-21.382 0-32.09 25.851-16.971 40.971l86.059 86.059c9.373 9.373 24.568 9.373 33.941 0l86.059-86.059c15.12-15.119 4.412-40.971-16.97-40.971z',
|
|
1002
|
+
yOffset: 0,
|
|
1003
|
+
xOffset: 0,
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
const ArrowsAltVIcon = createIcon(ArrowsAltVIconConfig);
|
|
1007
|
+
|
|
1008
|
+
var SortByDirection;
|
|
1009
|
+
(function (SortByDirection) {
|
|
1010
|
+
SortByDirection["asc"] = "asc";
|
|
1011
|
+
SortByDirection["desc"] = "desc";
|
|
1012
|
+
})(SortByDirection || (SortByDirection = {}));
|
|
1013
|
+
const SortColumn = (_a) => {
|
|
1014
|
+
var { children = null, className = '', isSortedBy = false, onSort = null, sortDirection = '', type = 'button', tooltip, tooltipProps, tooltipHasDefaultBehavior, favoriteButtonProps } = _a, props = __rest(_a, ["children", "className", "isSortedBy", "onSort", "sortDirection", "type", "tooltip", "tooltipProps", "tooltipHasDefaultBehavior", "favoriteButtonProps"]);
|
|
1015
|
+
let SortedByIcon;
|
|
1016
|
+
const [focused, setFocused] = React.useState(false);
|
|
1017
|
+
if (isSortedBy) {
|
|
1018
|
+
SortedByIcon = sortDirection === SortByDirection.asc ? LongArrowAltUpIcon : LongArrowAltDownIcon;
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
SortedByIcon = ArrowsAltVIcon;
|
|
1022
|
+
}
|
|
1023
|
+
if (favoriteButtonProps) {
|
|
1024
|
+
return (React.createElement(ActionList, { isIconList: true },
|
|
1025
|
+
React.createElement(ActionListItem, null,
|
|
1026
|
+
React.createElement(Button, Object.assign({ variant: "plain", icon: React.createElement(StarIcon, null) }, favoriteButtonProps))),
|
|
1027
|
+
React.createElement(ActionListItem, null,
|
|
1028
|
+
React.createElement(Button, Object.assign({ variant: "plain", icon: React.createElement("span", { className: css(styles$1.tableSortIndicator) },
|
|
1029
|
+
React.createElement(SortedByIcon, null)), onClick: (event) => onSort && onSort(event) }, props)))));
|
|
1030
|
+
}
|
|
1031
|
+
return (React.createElement("button", Object.assign({}, props, { type: type, className: css(className, styles$1.tableButton), onClick: (event) => onSort && onSort(event), onFocus: () => setFocused(true), onBlur: () => setFocused(false) }),
|
|
1032
|
+
React.createElement("div", { className: css(className, styles$1.tableButtonContent) },
|
|
1033
|
+
React.createElement(TableText, { tooltip: tooltip, tooltipProps: tooltipProps, tooltipHasDefaultBehavior: tooltipHasDefaultBehavior, focused: focused }, children),
|
|
1034
|
+
React.createElement("span", { className: css(styles$1.tableSortIndicator) },
|
|
1035
|
+
React.createElement(SortedByIcon, null)))));
|
|
1036
|
+
};
|
|
1037
|
+
SortColumn.displayName = 'SortColumn';
|
|
1038
|
+
|
|
1039
|
+
const sortableFavorites = (sort) => () => {
|
|
1040
|
+
var _a;
|
|
1041
|
+
return sortable(React.createElement(StarIcon, { "aria-hidden": true }), {
|
|
1042
|
+
columnIndex: sort.columnIndex,
|
|
1043
|
+
className: styles$1.tableFavorite,
|
|
1044
|
+
ariaLabel: (_a = sort.ariaLabel) !== null && _a !== void 0 ? _a : 'Sort favorites',
|
|
1045
|
+
column: {
|
|
1046
|
+
extraParams: {
|
|
1047
|
+
sortBy: sort.sortBy,
|
|
1048
|
+
onSort: sort.onSort,
|
|
1049
|
+
favoriteButtonProps: sort.favoriteButtonProps
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
tooltip: sort.tooltip,
|
|
1053
|
+
tooltipProps: sort.tooltipProps,
|
|
1054
|
+
tooltipHasDefaultBehavior: true
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
const sortable = (label, { columnIndex, column, property, className, ariaLabel, tooltip, tooltipProps, tooltipHasDefaultBehavior }) => {
|
|
1058
|
+
const { extraParams: { sortBy, onSort, favoriteButtonProps } } = column;
|
|
1059
|
+
const extraData = {
|
|
1060
|
+
columnIndex,
|
|
1061
|
+
column,
|
|
1062
|
+
property
|
|
1063
|
+
};
|
|
1064
|
+
const isSortedBy = sortBy && columnIndex === sortBy.index;
|
|
1065
|
+
/**
|
|
1066
|
+
* @param {React.MouseEvent} event - React mouse event
|
|
1067
|
+
*/
|
|
1068
|
+
function sortClicked(event) {
|
|
1069
|
+
let reversedDirection;
|
|
1070
|
+
if (!isSortedBy) {
|
|
1071
|
+
reversedDirection = sortBy.defaultDirection ? sortBy.defaultDirection : SortByDirection.asc;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
reversedDirection = sortBy.direction === SortByDirection.asc ? SortByDirection.desc : SortByDirection.asc;
|
|
1075
|
+
}
|
|
1076
|
+
// tslint:disable-next-line:no-unused-expression
|
|
1077
|
+
onSort && onSort(event, columnIndex, reversedDirection, extraData);
|
|
1078
|
+
}
|
|
1079
|
+
return Object.assign(Object.assign({ className: css(styles$1.tableSort, isSortedBy && styles$1.modifiers.selected, className) }, (isSortedBy && { 'aria-sort': `${sortBy.direction}ending` })), { children: (React.createElement(SortColumn, { isSortedBy: isSortedBy, sortDirection: isSortedBy ? sortBy.direction : '', onSort: sortClicked, "aria-label": ariaLabel, tooltip: tooltip, tooltipProps: tooltipProps, tooltipHasDefaultBehavior: tooltipHasDefaultBehavior, favoriteButtonProps: favoriteButtonProps }, label)) });
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
const resolveOrDefault = (resolver, defaultValue, rowData, extraData) => (defaultValue);
|
|
1083
|
+
const cellActions = (actions, actionResolver, areActionsDisabled) => (label, { rowData, column, rowIndex, columnIndex, column: { extraParams: { actionsToggle, actionsPopperProps } }, property }) => {
|
|
1084
|
+
const extraData = {
|
|
1085
|
+
rowIndex,
|
|
1086
|
+
columnIndex,
|
|
1087
|
+
column,
|
|
1088
|
+
property
|
|
1089
|
+
};
|
|
1090
|
+
const resolvedActions = resolveOrDefault(actionResolver, actions);
|
|
1091
|
+
const resolvedIsDisabled = resolveOrDefault(areActionsDisabled, rowData && rowData.disableActions);
|
|
1092
|
+
const renderProps = resolvedActions && resolvedActions.length > 0
|
|
1093
|
+
? {
|
|
1094
|
+
children: (React.createElement(ActionsColumn, { items: resolvedActions, isDisabled: resolvedIsDisabled, rowData: rowData, extraData: extraData, actionsToggle: actionsToggle, popperProps: actionsPopperProps }, label))
|
|
1095
|
+
}
|
|
1096
|
+
: {};
|
|
1097
|
+
return Object.assign({ className: css(styles$1.tableAction), style: { paddingRight: 0 }, isVisible: true }, renderProps);
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
const camelize = (s) => s.toUpperCase().replace('-', '').replace('_', '');
|
|
1101
|
+
const toCamel = (s) => s.replace(/([-_][a-z])/gi, camelize);
|
|
1102
|
+
/**
|
|
1103
|
+
* @param {string} input - String to capitalize
|
|
1104
|
+
*/
|
|
1105
|
+
function capitalize(input) {
|
|
1106
|
+
return input[0].toUpperCase() + input.substring(1);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
const cellWidth = (width) => () => ({
|
|
1110
|
+
className: css(styles$1.modifiers[typeof width === 'number' ? `width_${width}` : `width${capitalize(width)}`])
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
const collapsible = (value, { rowIndex, columnIndex, rowData, column, property }) => {
|
|
1114
|
+
const { extraParams: { onCollapse, rowLabeledBy = 'simple-node', expandId = 'expand-toggle', allRowsExpanded, collapseAllAriaLabel } } = column;
|
|
1115
|
+
const extraData = {
|
|
1116
|
+
rowIndex,
|
|
1117
|
+
columnIndex,
|
|
1118
|
+
column,
|
|
1119
|
+
property
|
|
1120
|
+
};
|
|
1121
|
+
const rowId = rowIndex !== undefined ? rowIndex : -1;
|
|
1122
|
+
const customProps = Object.assign({}, (rowId !== -1
|
|
1123
|
+
? {
|
|
1124
|
+
isOpen: rowData === null || rowData === void 0 ? void 0 : rowData.isOpen,
|
|
1125
|
+
'aria-labelledby': `${rowLabeledBy}${rowId} ${expandId}${rowId}`
|
|
1126
|
+
}
|
|
1127
|
+
: {
|
|
1128
|
+
isOpen: allRowsExpanded,
|
|
1129
|
+
'aria-label': collapseAllAriaLabel || 'Expand all rows'
|
|
1130
|
+
}));
|
|
1131
|
+
/**
|
|
1132
|
+
* @param {React.MouseEvent} event - Mouse event
|
|
1133
|
+
*/
|
|
1134
|
+
function onToggle(event) {
|
|
1135
|
+
const open = rowData ? !rowData.isOpen : !allRowsExpanded;
|
|
1136
|
+
// tslint:disable-next-line:no-unused-expression
|
|
1137
|
+
onCollapse && onCollapse(event, rowIndex, open, rowData, extraData);
|
|
1138
|
+
}
|
|
1139
|
+
return {
|
|
1140
|
+
className: ((rowData === null || rowData === void 0 ? void 0 : rowData.isOpen) !== undefined || rowId === -1) && css(styles$1.tableToggle),
|
|
1141
|
+
isVisible: !(rowData === null || rowData === void 0 ? void 0 : rowData.fullWidth),
|
|
1142
|
+
children: (React.createElement(CollapseColumn, Object.assign({ "aria-labelledby": `${rowLabeledBy}${rowId} ${expandId}${rowId}`, onToggle: onToggle, id: expandId + rowId }, customProps), value))
|
|
1143
|
+
};
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
const compoundExpand = (value, { rowIndex, columnIndex, rowData, column, property }) => {
|
|
1147
|
+
if (!value) {
|
|
1148
|
+
return null;
|
|
1149
|
+
}
|
|
1150
|
+
const { title, props } = value;
|
|
1151
|
+
const { extraParams: { onExpand, expandId = 'expand-toggle' } } = column;
|
|
1152
|
+
const extraData = {
|
|
1153
|
+
rowIndex,
|
|
1154
|
+
columnIndex,
|
|
1155
|
+
column,
|
|
1156
|
+
property
|
|
1157
|
+
};
|
|
1158
|
+
/**
|
|
1159
|
+
* @param {React.MouseEvent} event - Mouse event
|
|
1160
|
+
*/
|
|
1161
|
+
function onToggle(event) {
|
|
1162
|
+
// tslint:disable-next-line:no-unused-expression
|
|
1163
|
+
onExpand && onExpand(event, rowIndex, columnIndex, props.isOpen, rowData, extraData);
|
|
1164
|
+
}
|
|
1165
|
+
return {
|
|
1166
|
+
className: css(styles$1.tableCompoundExpansionToggle, props.isOpen && styles$1.modifiers.expanded),
|
|
1167
|
+
children: props.isOpen !== undefined && (React.createElement("button", { type: "button", className: css(styles$1.tableButton), onClick: onToggle, "aria-expanded": props.isOpen, "aria-controls": props.ariaControls, id: `${expandId}-${rowIndex}-${columnIndex}` },
|
|
1168
|
+
React.createElement(TableText, null, title)))
|
|
1169
|
+
};
|
|
1170
|
+
};
|
|
1171
|
+
|
|
1172
|
+
const visibilityModifiers = [
|
|
1173
|
+
'hidden',
|
|
1174
|
+
'hiddenOnSm',
|
|
1175
|
+
'hiddenOnMd',
|
|
1176
|
+
'hiddenOnLg',
|
|
1177
|
+
'hiddenOnXl',
|
|
1178
|
+
'hiddenOn_2xl',
|
|
1179
|
+
'visibleOnSm',
|
|
1180
|
+
'visibleOnMd',
|
|
1181
|
+
'visibleOnLg',
|
|
1182
|
+
'visibleOnXl',
|
|
1183
|
+
'visibleOn_2xl'
|
|
1184
|
+
];
|
|
1185
|
+
const Visibility = visibilityModifiers
|
|
1186
|
+
.filter((key) => styles$1.modifiers[key])
|
|
1187
|
+
.reduce((acc, curr) => {
|
|
1188
|
+
const key2 = curr.replace('_2xl', '2Xl');
|
|
1189
|
+
acc[key2] = styles$1.modifiers[curr];
|
|
1190
|
+
return acc;
|
|
1191
|
+
}, {});
|
|
1192
|
+
const classNames = (...classes) => () => ({
|
|
1193
|
+
className: css(...classes)
|
|
1194
|
+
});
|
|
1195
|
+
|
|
1196
|
+
const info = ({ tooltip, tooltipProps, popover, popoverProps, className, ariaLabel }) => {
|
|
1197
|
+
const infoObj = (value) => ({
|
|
1198
|
+
className: styles$1.modifiers.help,
|
|
1199
|
+
children: tooltip ? (React.createElement(HeaderCellInfoWrapper, { variant: "tooltip", info: tooltip, tooltipProps: tooltipProps, ariaLabel: ariaLabel, className: className }, value)) : (React.createElement(HeaderCellInfoWrapper, { variant: "popover", info: popover, popoverProps: popoverProps, ariaLabel: ariaLabel, className: className }, value))
|
|
1200
|
+
});
|
|
1201
|
+
return infoObj;
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
const FavoritesCell = (_a) => {
|
|
1205
|
+
var { className = '', onFavorite, isFavorited, rowIndex } = _a, props = __rest(_a, ["className", "onFavorite", "isFavorited", "rowIndex"]);
|
|
1206
|
+
const ariaProps = rowIndex === undefined
|
|
1207
|
+
? {}
|
|
1208
|
+
: {
|
|
1209
|
+
id: `favorites-button-${rowIndex}`,
|
|
1210
|
+
'aria-labelledby': `favorites-button-${rowIndex}`
|
|
1211
|
+
};
|
|
1212
|
+
return (React.createElement(Button, Object.assign({ variant: "plain", className: className, type: "button", "aria-label": isFavorited ? 'Starred' : 'Not starred', onClick: onFavorite }, ariaProps, props, { icon: React.createElement(StarIcon, { "aria-hidden": true }) })));
|
|
1213
|
+
};
|
|
1214
|
+
FavoritesCell.displayName = 'FavoritesCell';
|
|
1215
|
+
|
|
1216
|
+
const favoritable = (value, { rowIndex, columnIndex, rowData, column, property }) => {
|
|
1217
|
+
const { extraParams: { onFavorite } } = column;
|
|
1218
|
+
const extraData = {
|
|
1219
|
+
rowIndex,
|
|
1220
|
+
columnIndex,
|
|
1221
|
+
column,
|
|
1222
|
+
property
|
|
1223
|
+
};
|
|
1224
|
+
// this is a child row which should not display the favorites icon
|
|
1225
|
+
if (rowData && rowData.hasOwnProperty('parent') && !rowData.fullWidth) {
|
|
1226
|
+
return {
|
|
1227
|
+
component: 'td',
|
|
1228
|
+
isVisible: true
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* @param {React.MouseEvent} event - Mouse event
|
|
1233
|
+
*/
|
|
1234
|
+
function favoritesClick(event) {
|
|
1235
|
+
// tslint:disable-next-line:no-unused-expression
|
|
1236
|
+
onFavorite && onFavorite(event, rowData && !rowData.favorited, rowIndex, rowData, extraData);
|
|
1237
|
+
}
|
|
1238
|
+
const additionalProps = rowData.favoritesProps || {};
|
|
1239
|
+
return {
|
|
1240
|
+
className: css(styles$1.tableFavorite, rowData && rowData.favorited && styles$1.modifiers.favorited),
|
|
1241
|
+
isVisible: !rowData || !rowData.fullWidth,
|
|
1242
|
+
children: (React.createElement(FavoritesCell, Object.assign({ rowIndex: rowIndex, onFavorite: favoritesClick, isFavorited: rowData && rowData.favorited }, additionalProps)))
|
|
1243
|
+
};
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
const EllipsisHIconConfig = {
|
|
1247
|
+
name: 'EllipsisHIcon',
|
|
1248
|
+
height: 512,
|
|
1249
|
+
width: 512,
|
|
1250
|
+
svgPath: 'M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z',
|
|
1251
|
+
yOffset: 0,
|
|
1252
|
+
xOffset: 0,
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
const EllipsisHIcon = createIcon(EllipsisHIconConfig);
|
|
1256
|
+
|
|
1257
|
+
const treeRow = (onCollapse, onCheckChange, onToggleRowDetails) => (value, { rowIndex, rowData }) => {
|
|
1258
|
+
const { isExpanded, isDetailsExpanded, 'aria-level': level, 'aria-setsize': setsize, toggleAriaLabel, checkAriaLabel, showDetailsAriaLabel, isChecked, checkboxId, icon } = rowData.props;
|
|
1259
|
+
const content = value.title || value;
|
|
1260
|
+
const text = (React.createElement("div", { className: css(treeViewStyles.tableTreeViewText), key: "tree-view-text" },
|
|
1261
|
+
icon && (React.createElement("span", { className: css(treeViewStyles.tableTreeViewIcon), key: "tree-view-text-icon" }, icon)),
|
|
1262
|
+
React.createElement("span", { className: styles$1.tableText, key: "table-text" }, content)));
|
|
1263
|
+
const onChange = (isChecked, event) => {
|
|
1264
|
+
onCheckChange(event, isChecked, rowIndex, content, rowData);
|
|
1265
|
+
};
|
|
1266
|
+
return {
|
|
1267
|
+
component: 'th',
|
|
1268
|
+
className: treeViewStyles.tableTreeViewTitleCell,
|
|
1269
|
+
children: level !== undefined ? (React.createElement("div", { className: css(treeViewStyles.tableTreeViewMain) },
|
|
1270
|
+
setsize > 0 && (React.createElement("span", { className: css(treeViewStyles.tableToggle), key: "table-toggle" },
|
|
1271
|
+
React.createElement(Button, { variant: "plain", onClick: (event) => onCollapse && onCollapse(event, rowIndex, content, rowData), className: css(isExpanded && styles$1.modifiers.expanded), "aria-expanded": isExpanded, "aria-label": toggleAriaLabel || `${isExpanded ? 'Collapse' : 'Expand'} row ${rowIndex}`, icon: React.createElement("div", { className: css(treeViewStyles.tableToggleIcon) },
|
|
1272
|
+
React.createElement(AngleDownIcon, { "aria-hidden": "true" })) }))),
|
|
1273
|
+
!!onCheckChange && (React.createElement("span", { className: css(treeViewStyles.tableCheck), key: "table-check" },
|
|
1274
|
+
React.createElement("label", { htmlFor: checkboxId || `checkbox_${rowIndex}` },
|
|
1275
|
+
React.createElement(Checkbox, { id: checkboxId || `checkbox_${rowIndex}`, "aria-label": checkAriaLabel || `Row ${rowIndex} checkbox`, isChecked: isChecked, onChange: (event, checked) => onChange(checked, event) })))),
|
|
1276
|
+
text,
|
|
1277
|
+
!!onToggleRowDetails && (React.createElement("span", { className: css(treeViewStyles.tableTreeViewDetailsToggle), key: "view-details-toggle" },
|
|
1278
|
+
React.createElement(Button, { variant: "plain", "aria-expanded": isDetailsExpanded, "aria-label": showDetailsAriaLabel || 'Show row details', onClick: (event) => onToggleRowDetails && onToggleRowDetails(event, rowIndex, content, rowData), icon: React.createElement("span", { className: `${styles$1.table}__details-toggle-icon` },
|
|
1279
|
+
React.createElement(EllipsisHIcon, { "aria-hidden": true })) }))))) : (text)
|
|
1280
|
+
};
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
var TableGridBreakpoint;
|
|
1284
|
+
(function (TableGridBreakpoint) {
|
|
1285
|
+
TableGridBreakpoint["none"] = "";
|
|
1286
|
+
TableGridBreakpoint["grid"] = "grid";
|
|
1287
|
+
TableGridBreakpoint["gridMd"] = "grid-md";
|
|
1288
|
+
TableGridBreakpoint["gridLg"] = "grid-lg";
|
|
1289
|
+
TableGridBreakpoint["gridXl"] = "grid-xl";
|
|
1290
|
+
TableGridBreakpoint["grid2xl"] = "grid-2xl";
|
|
1291
|
+
})(TableGridBreakpoint || (TableGridBreakpoint = {}));
|
|
1292
|
+
var TableVariant;
|
|
1293
|
+
(function (TableVariant) {
|
|
1294
|
+
TableVariant["compact"] = "compact";
|
|
1295
|
+
})(TableVariant || (TableVariant = {}));
|
|
1296
|
+
|
|
1297
|
+
const TableContext = React.createContext({
|
|
1298
|
+
registerSelectableRow: () => { }
|
|
1299
|
+
});
|
|
1300
|
+
const TableBase = (_a) => {
|
|
1301
|
+
var _b, _c;
|
|
1302
|
+
var { children, className, variant, borders = true, isStickyHeader = false, gridBreakPoint = TableGridBreakpoint.gridMd, 'aria-label': ariaLabel, role = 'grid', innerRef, ouiaId, ouiaSafe = true, isTreeTable = false, isNested = false, isStriped = false, isExpandable = false, hasNoInset = false,
|
|
1303
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1304
|
+
nestedHeaderColumnSpans, selectableRowCaptionText } = _a, props = __rest(_a, ["children", "className", "variant", "borders", "isStickyHeader", "gridBreakPoint", 'aria-label', "role", "innerRef", "ouiaId", "ouiaSafe", "isTreeTable", "isNested", "isStriped", "isExpandable", "hasNoInset", "nestedHeaderColumnSpans", "selectableRowCaptionText"]);
|
|
1305
|
+
const ref = React.useRef(null);
|
|
1306
|
+
const tableRef = innerRef || ref;
|
|
1307
|
+
const [hasSelectableRows, setHasSelectableRows] = React.useState(false);
|
|
1308
|
+
const [tableCaption, setTableCaption] = React.useState();
|
|
1309
|
+
React.useEffect(() => {
|
|
1310
|
+
document.addEventListener('keydown', handleKeys);
|
|
1311
|
+
// sets up roving tab-index to tree tables only
|
|
1312
|
+
if (tableRef && tableRef.current && tableRef.current.classList.contains('pf-m-tree-view')) {
|
|
1313
|
+
const tbody = tableRef.current.querySelector('tbody');
|
|
1314
|
+
tbody && setTabIndex(Array.from(tbody.querySelectorAll('button, a, input')));
|
|
1315
|
+
}
|
|
1316
|
+
return function cleanup() {
|
|
1317
|
+
document.removeEventListener('keydown', handleKeys);
|
|
1318
|
+
};
|
|
1319
|
+
}, [tableRef, tableRef.current]);
|
|
1320
|
+
React.useEffect(() => {
|
|
1321
|
+
if (selectableRowCaptionText) {
|
|
1322
|
+
setTableCaption(React.createElement("caption", null,
|
|
1323
|
+
selectableRowCaptionText,
|
|
1324
|
+
React.createElement("div", { className: "pf-v6-screen-reader" }, "This table has selectable rows. It can be navigated by row using tab, and each row can be selected using space or enter.")));
|
|
1325
|
+
}
|
|
1326
|
+
else {
|
|
1327
|
+
setTableCaption(React.createElement("caption", { className: "pf-v6-screen-reader" }, "This table has selectable rows. It can be navigated by row using tab, and each row can be selected using space or enter."));
|
|
1328
|
+
}
|
|
1329
|
+
}, [selectableRowCaptionText]);
|
|
1330
|
+
const ouiaProps = useOUIAProps('Table', ouiaId, ouiaSafe);
|
|
1331
|
+
const grid = (_b = stylesGrid.modifiers) === null || _b === void 0 ? void 0 : _b[toCamel(gridBreakPoint || '').replace(/-?2xl/, '_2xl')];
|
|
1332
|
+
const breakPointPrefix = `treeView${gridBreakPoint.charAt(0).toUpperCase() + gridBreakPoint.slice(1)}`;
|
|
1333
|
+
const treeGrid = (_c = treeViewStyles.modifiers) === null || _c === void 0 ? void 0 : _c[toCamel(breakPointPrefix || '').replace(/-?2xl/, '_2xl')];
|
|
1334
|
+
const handleKeys = (event) => {
|
|
1335
|
+
if (isNested ||
|
|
1336
|
+
!(tableRef && tableRef.current && tableRef.current.classList.contains(treeViewStyles.modifiers.treeView)) || // implements roving tab-index to tree tables only
|
|
1337
|
+
(tableRef && tableRef.current !== event.target.closest(`.${styles$1.table}:not(.pf-m-nested)`))) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const activeElement = document.activeElement;
|
|
1341
|
+
const key = event.key;
|
|
1342
|
+
const rows = Array.from(tableRef.current.querySelectorAll('tbody tr')).filter((el) => !el.classList.contains('pf-m-disabled') && !el.hidden);
|
|
1343
|
+
if (key === KeyTypes.Space || key === KeyTypes.Enter) {
|
|
1344
|
+
activeElement.click();
|
|
1345
|
+
event.preventDefault();
|
|
1346
|
+
}
|
|
1347
|
+
const getFocusableElement = (element) => element.querySelectorAll('button:not(:disabled), input:not(:disabled), a:not(:disabled)')[0];
|
|
1348
|
+
handleArrows(event, rows, (element) => element === activeElement.closest('tr'), getFocusableElement, ['button', 'input', 'a'], undefined, false, true, false);
|
|
1349
|
+
};
|
|
1350
|
+
const registerSelectableRow = () => {
|
|
1351
|
+
!hasSelectableRows && setHasSelectableRows(true);
|
|
1352
|
+
};
|
|
1353
|
+
return (React.createElement(TableContext.Provider, { value: { registerSelectableRow } },
|
|
1354
|
+
React.createElement("table", Object.assign({ "aria-label": ariaLabel, role: role, className: css(className, styles$1.table, isTreeTable ? treeGrid : grid, styles$1.modifiers[variant], !borders && styles$1.modifiers.noBorderRows, isStickyHeader && styles$1.modifiers.stickyHeader, isTreeTable && treeViewStyles.modifiers.treeView, isStriped && styles$1.modifiers.striped, isExpandable && styles$1.modifiers.expandable, hasNoInset && treeViewStyles.modifiers.noInset, isNested && 'pf-m-nested'), ref: tableRef }, (isTreeTable && { role: 'treegrid' }), ouiaProps, props),
|
|
1355
|
+
hasSelectableRows && tableCaption,
|
|
1356
|
+
children)));
|
|
1357
|
+
};
|
|
1358
|
+
const Table = React.forwardRef((props, ref) => (React.createElement(TableBase, Object.assign({}, props, { innerRef: ref }))));
|
|
1359
|
+
Table.displayName = 'Table';
|
|
1360
|
+
|
|
1361
|
+
const TrBase = (_a) => {
|
|
1362
|
+
var { children, className, isExpanded, isEditable, isHidden = false, isClickable = false, isRowSelected = false, isStriped = false, isBorderRow = false, isControlRow = false, innerRef, ouiaId, ouiaSafe = true, resetOffset = false, onRowClick, isSelectable, 'aria-label': passedAriaLabel } = _a, props = __rest(_a, ["children", "className", "isExpanded", "isEditable", "isHidden", "isClickable", "isRowSelected", "isStriped", "isBorderRow", "isControlRow", "innerRef", "ouiaId", "ouiaSafe", "resetOffset", "onRowClick", "isSelectable", 'aria-label']);
|
|
1363
|
+
const ouiaProps = useOUIAProps('TableRow', ouiaId, ouiaSafe);
|
|
1364
|
+
const [computedAriaLabel, setComputedAriaLabel] = React.useState('');
|
|
1365
|
+
let onKeyDown = null;
|
|
1366
|
+
if (onRowClick) {
|
|
1367
|
+
onKeyDown = (e) => {
|
|
1368
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1369
|
+
onRowClick(e);
|
|
1370
|
+
e.preventDefault();
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
const rowIsHidden = isHidden || (isExpanded !== undefined && !isExpanded);
|
|
1375
|
+
const { registerSelectableRow } = React.useContext(TableContext);
|
|
1376
|
+
React.useEffect(() => {
|
|
1377
|
+
if (isSelectable && !rowIsHidden) {
|
|
1378
|
+
setComputedAriaLabel(`${isRowSelected ? 'Row selected' : ''}`);
|
|
1379
|
+
registerSelectableRow();
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
setComputedAriaLabel(undefined);
|
|
1383
|
+
}
|
|
1384
|
+
}, [isRowSelected, isSelectable, registerSelectableRow, rowIsHidden]);
|
|
1385
|
+
const ariaLabel = passedAriaLabel || computedAriaLabel;
|
|
1386
|
+
return (React.createElement(React.Fragment, null,
|
|
1387
|
+
React.createElement("tr", Object.assign({ className: css(styles$1.tableTr, className, isExpanded !== undefined && styles$1.tableExpandableRow, isExpanded && styles$1.modifiers.expanded, isEditable && inlineStyles.modifiers.inlineEditable, isClickable && styles$1.modifiers.clickable, isRowSelected && styles$1.modifiers.selected, isStriped && styles$1.modifiers.striped, isBorderRow && styles$1.modifiers.borderRow, isControlRow && styles$1.tableControlRow, resetOffset && styles$1.modifiers.firstCellOffsetReset), hidden: rowIsHidden }, (isClickable && { tabIndex: 0 }), { "aria-label": ariaLabel, ref: innerRef }, (onRowClick && { onClick: onRowClick, onKeyDown }), ouiaProps, props), children)));
|
|
1388
|
+
};
|
|
1389
|
+
const Tr = React.forwardRef((props, ref) => (React.createElement(TrBase, Object.assign({}, props, { innerRef: ref }))));
|
|
1390
|
+
Tr.displayName = 'Tr';
|
|
1391
|
+
|
|
1392
|
+
const TheadBase = (_a) => {
|
|
1393
|
+
var { children, className, noWrap = false, innerRef, hasNestedHeader } = _a, props = __rest(_a, ["children", "className", "noWrap", "innerRef", "hasNestedHeader"]);
|
|
1394
|
+
return (React.createElement("thead", Object.assign({ className: css(styles$1.tableThead, className, noWrap && styles$1.modifiers.nowrap, hasNestedHeader && styles$1.modifiers.nestedColumnHeader), ref: innerRef }, props), children));
|
|
1395
|
+
};
|
|
1396
|
+
const Thead = React.forwardRef((props, ref) => (React.createElement(TheadBase, Object.assign({}, props, { innerRef: ref }))));
|
|
1397
|
+
Thead.displayName = 'Thead';
|
|
1398
|
+
|
|
1399
|
+
const TbodyBase = (_a) => {
|
|
1400
|
+
var { children, className, isExpanded, innerRef, isEvenStriped = false, isOddStriped = false } = _a, props = __rest(_a, ["children", "className", "isExpanded", "innerRef", "isEvenStriped", "isOddStriped"]);
|
|
1401
|
+
return (React.createElement("tbody", Object.assign({ role: "rowgroup", className: css(styles$1.tableTbody, className, isExpanded && styles$1.modifiers.expanded, isOddStriped && styles$1.modifiers.striped, isEvenStriped && styles$1.modifiers.stripedEven), ref: innerRef }, props), children));
|
|
1402
|
+
};
|
|
1403
|
+
const Tbody = React.forwardRef((props, ref) => (React.createElement(TbodyBase, Object.assign({}, props, { innerRef: ref }))));
|
|
1404
|
+
Tbody.displayName = 'Tbody';
|
|
1405
|
+
|
|
1406
|
+
const styles = {
|
|
1407
|
+
"modifiers": {
|
|
1408
|
+
"borderRight": "pf-m-border-right",
|
|
1409
|
+
"borderLeft": "pf-m-border-left"},
|
|
1410
|
+
"tableStickyCell": "pf-v6-c-table__sticky-cell"
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
const accessibleStyles = {
|
|
1414
|
+
"screenReader": "pf-v6-u-screen-reader"};
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* merge-props.js
|
|
1418
|
+
*
|
|
1419
|
+
* Forked from reactabular-table version 8.14.0
|
|
1420
|
+
* https://github.com/reactabular/reactabular/tree/v8.14.0/packages/reactabular-table/src
|
|
1421
|
+
*/
|
|
1422
|
+
/**
|
|
1423
|
+
* @param {any} props - Props
|
|
1424
|
+
*/
|
|
1425
|
+
function mergeProps(...props) {
|
|
1426
|
+
const firstProps = props[0];
|
|
1427
|
+
const restProps = props.slice(1);
|
|
1428
|
+
if (!restProps.length) {
|
|
1429
|
+
return mergeWith({}, firstProps);
|
|
1430
|
+
}
|
|
1431
|
+
// Avoid mutating the first prop collection
|
|
1432
|
+
return mergeWith(mergeWith({}, firstProps), ...restProps, (a, b, key) => {
|
|
1433
|
+
if (key === 'children') {
|
|
1434
|
+
if (a && b) {
|
|
1435
|
+
// compose the two
|
|
1436
|
+
return React.cloneElement(a, {
|
|
1437
|
+
children: b
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
// Children have to be merged in reverse order for Reactabular
|
|
1441
|
+
// logic to work.
|
|
1442
|
+
return Object.assign(Object.assign({}, b), a);
|
|
1443
|
+
}
|
|
1444
|
+
if (key === 'className') {
|
|
1445
|
+
// Process class names through classNames to merge properly
|
|
1446
|
+
// as a string.
|
|
1447
|
+
return css(a, b);
|
|
1448
|
+
}
|
|
1449
|
+
return undefined;
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
const c_table__sticky_cell_MinWidth = {
|
|
1454
|
+
"name": "--pf-v6-c-table__sticky-cell--MinWidth"};
|
|
1455
|
+
|
|
1456
|
+
const c_table__sticky_cell_InsetInlineStart = {
|
|
1457
|
+
"name": "--pf-v6-c-table__sticky-cell--InsetInlineStart"};
|
|
1458
|
+
|
|
1459
|
+
const c_table__sticky_cell_InsetInlineEnd = {
|
|
1460
|
+
"name": "--pf-v6-c-table__sticky-cell--InsetInlineEnd"};
|
|
1461
|
+
|
|
1462
|
+
const ThBase = (_a) => {
|
|
1463
|
+
var _b;
|
|
1464
|
+
var { children, className, component = 'th', dataLabel, scope = 'col', textCenter = false, sort = null, modifier, select = null, expand: collapse = null, tooltip = '', tooltipProps, onMouseEnter: onMouseEnterProp = () => { }, width, visibility, innerRef, info: infoProps, isStickyColumn = false, hasRightBorder = false, hasLeftBorder = false, stickyMinWidth = '120px', stickyLeftOffset, stickyRightOffset, isSubheader = false, screenReaderText, 'aria-label': ariaLabel } = _a, props = __rest(_a, ["children", "className", "component", "dataLabel", "scope", "textCenter", "sort", "modifier", "select", "expand", "tooltip", "tooltipProps", "onMouseEnter", "width", "visibility", "innerRef", "info", "isStickyColumn", "hasRightBorder", "hasLeftBorder", "stickyMinWidth", "stickyLeftOffset", "stickyRightOffset", "isSubheader", "screenReaderText", 'aria-label']);
|
|
1465
|
+
if (!children && !screenReaderText && !ariaLabel) {
|
|
1466
|
+
// eslint-disable-next-line no-console
|
|
1467
|
+
console.warn('Th: Table headers must have an accessible name. If the Th is intended to be visually empty, pass in screenReaderText. If the Th contains only non-text, interactive content such as a checkbox or expand toggle, pass in an aria-label.');
|
|
1468
|
+
}
|
|
1469
|
+
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
1470
|
+
const [truncated, setTruncated] = React.useState(false);
|
|
1471
|
+
const cellRef = innerRef ? innerRef : React.createRef();
|
|
1472
|
+
const onMouseEnter = (event) => {
|
|
1473
|
+
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
1474
|
+
!showTooltip && setShowTooltip(true);
|
|
1475
|
+
}
|
|
1476
|
+
else {
|
|
1477
|
+
showTooltip && setShowTooltip(false);
|
|
1478
|
+
}
|
|
1479
|
+
onMouseEnterProp(event);
|
|
1480
|
+
};
|
|
1481
|
+
let sortParams = null;
|
|
1482
|
+
if (sort) {
|
|
1483
|
+
if (sort.isFavorites) {
|
|
1484
|
+
sortParams = sortableFavorites({
|
|
1485
|
+
onSort: sort.onSort,
|
|
1486
|
+
columnIndex: sort.columnIndex,
|
|
1487
|
+
sortBy: sort.sortBy,
|
|
1488
|
+
tooltip: tooltip,
|
|
1489
|
+
tooltipProps,
|
|
1490
|
+
ariaLabel: sort['aria-label'],
|
|
1491
|
+
favoriteButtonProps: sort.favoriteButtonProps
|
|
1492
|
+
})();
|
|
1493
|
+
}
|
|
1494
|
+
else {
|
|
1495
|
+
sortParams = sortable(children, {
|
|
1496
|
+
columnIndex: sort.columnIndex,
|
|
1497
|
+
column: {
|
|
1498
|
+
extraParams: {
|
|
1499
|
+
sortBy: sort.sortBy,
|
|
1500
|
+
onSort: sort === null || sort === void 0 ? void 0 : sort.onSort
|
|
1501
|
+
}
|
|
1502
|
+
},
|
|
1503
|
+
tooltip: tooltip,
|
|
1504
|
+
tooltipProps
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
const selectParams = select
|
|
1509
|
+
? selectable(children, {
|
|
1510
|
+
rowData: {
|
|
1511
|
+
selected: select.isSelected,
|
|
1512
|
+
disableSelection: select === null || select === void 0 ? void 0 : select.isDisabled,
|
|
1513
|
+
props: select === null || select === void 0 ? void 0 : select.props
|
|
1514
|
+
},
|
|
1515
|
+
column: {
|
|
1516
|
+
extraParams: {
|
|
1517
|
+
onSelect: select === null || select === void 0 ? void 0 : select.onSelect,
|
|
1518
|
+
selectVariant: 'checkbox',
|
|
1519
|
+
allRowsSelected: select.isSelected,
|
|
1520
|
+
isHeaderSelectDisabled: !!select.isHeaderSelectDisabled
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
tooltip: tooltip})
|
|
1524
|
+
: null;
|
|
1525
|
+
const collapseParams = collapse
|
|
1526
|
+
? collapsible(children, {
|
|
1527
|
+
column: {
|
|
1528
|
+
extraParams: {
|
|
1529
|
+
onCollapse: collapse === null || collapse === void 0 ? void 0 : collapse.onToggle,
|
|
1530
|
+
allRowsExpanded: !collapse.areAllExpanded,
|
|
1531
|
+
collapseAllAriaLabel: ''
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
})
|
|
1535
|
+
: null;
|
|
1536
|
+
const widthParams = width ? cellWidth(width)() : null;
|
|
1537
|
+
const visibilityParams = visibility
|
|
1538
|
+
? classNames(...visibility.map((vis) => Visibility[vis]))()
|
|
1539
|
+
: null;
|
|
1540
|
+
let transformedChildren = (sortParams === null || sortParams === void 0 ? void 0 : sortParams.children) || (selectParams === null || selectParams === void 0 ? void 0 : selectParams.children) || (collapseParams === null || collapseParams === void 0 ? void 0 : collapseParams.children) || children;
|
|
1541
|
+
// info can wrap other transformedChildren
|
|
1542
|
+
let infoParams = null;
|
|
1543
|
+
if (infoProps) {
|
|
1544
|
+
infoParams = info(infoProps)(transformedChildren);
|
|
1545
|
+
transformedChildren = infoParams.children;
|
|
1546
|
+
}
|
|
1547
|
+
const merged = mergeProps(sortParams, selectParams, collapseParams, widthParams, visibilityParams, infoParams);
|
|
1548
|
+
const {
|
|
1549
|
+
// ignore the merged children since we transform them ourselves so we can wrap it with info
|
|
1550
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1551
|
+
children: mergedChildren = null,
|
|
1552
|
+
// selectable adds this but we don't want it
|
|
1553
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1554
|
+
isVisible = null, className: mergedClassName = '', component: MergedComponent = component } = merged, mergedProps = __rest(merged, ["children", "isVisible", "className", "component"]);
|
|
1555
|
+
React.useEffect(() => {
|
|
1556
|
+
setTruncated(cellRef.current.offsetWidth <
|
|
1557
|
+
cellRef.current.scrollWidth);
|
|
1558
|
+
}, [cellRef]);
|
|
1559
|
+
const cell = (React.createElement(MergedComponent, Object.assign({ tabIndex: sort || select || !truncated ? -1 : 0, onFocus: tooltip !== null ? onMouseEnter : onMouseEnterProp, onBlur: () => setShowTooltip(false), "data-label": dataLabel, onMouseEnter: tooltip !== null ? onMouseEnter : onMouseEnterProp, scope: component === 'th' ? scope : null, ref: cellRef, "aria-label": ariaLabel, className: css(styles$1.tableTh, className, textCenter && styles$1.modifiers.center, isSubheader && styles$1.tableSubhead, isStickyColumn && styles.tableStickyCell, hasRightBorder && styles.modifiers.borderRight, hasLeftBorder && styles.modifiers.borderLeft, modifier && styles$1.modifiers[modifier], ((_b = sort === null || sort === void 0 ? void 0 : sort.favoriteButtonProps) === null || _b === void 0 ? void 0 : _b.favorited) && styles$1.modifiers.favorited, mergedClassName) }, mergedProps, props, (isStickyColumn && {
|
|
1560
|
+
style: Object.assign({ [c_table__sticky_cell_MinWidth.name]: stickyMinWidth ? stickyMinWidth : undefined, [c_table__sticky_cell_InsetInlineStart.name]: stickyLeftOffset ? stickyLeftOffset : 0, [c_table__sticky_cell_InsetInlineEnd.name]: stickyRightOffset ? stickyRightOffset : 0 }, props.style)
|
|
1561
|
+
})), transformedChildren ||
|
|
1562
|
+
(screenReaderText && React.createElement("span", { className: accessibleStyles.screenReader }, screenReaderText))));
|
|
1563
|
+
const canMakeDefaultTooltip = tooltip === '' ? typeof transformedChildren === 'string' : true;
|
|
1564
|
+
const childControlsTooltip = sortParams || selectParams;
|
|
1565
|
+
return tooltip !== null && canMakeDefaultTooltip && !childControlsTooltip && showTooltip ? (React.createElement(React.Fragment, null,
|
|
1566
|
+
cell,
|
|
1567
|
+
React.createElement(Tooltip, Object.assign({ triggerRef: cellRef, content: tooltip || (tooltip === '' && children), isVisible: true }, tooltipProps)))) : (cell);
|
|
1568
|
+
};
|
|
1569
|
+
const Th = React.forwardRef((props, ref) => (React.createElement(ThBase, Object.assign({}, props, { innerRef: ref }))));
|
|
1570
|
+
Th.displayName = 'Th';
|
|
1571
|
+
|
|
1572
|
+
const draggable = (value, { rowData }) => {
|
|
1573
|
+
const { id } = rowData;
|
|
1574
|
+
return {
|
|
1575
|
+
className: '',
|
|
1576
|
+
children: React.createElement(DraggableCell, { id: id })
|
|
1577
|
+
};
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
const TdBase = (_a) => {
|
|
1581
|
+
var { children, className, isActionCell = false, component = 'td', dataLabel, textCenter = false, modifier, select = null, actions = null, expand = null, treeRow: treeRowProp = null, compoundExpand: compoundExpandProp = null, noPadding, width, visibility, innerRef, favorites = null, draggableRow: draggableRowProp = null, tooltip = '', onMouseEnter: onMouseEnterProp = () => { }, isStickyColumn = false, hasRightBorder = false, hasLeftBorder = false, stickyMinWidth = '120px', stickyLeftOffset, stickyRightOffset } = _a, props = __rest(_a, ["children", "className", "isActionCell", "component", "dataLabel", "textCenter", "modifier", "select", "actions", "expand", "treeRow", "compoundExpand", "noPadding", "width", "visibility", "innerRef", "favorites", "draggableRow", "tooltip", "onMouseEnter", "isStickyColumn", "hasRightBorder", "hasLeftBorder", "stickyMinWidth", "stickyLeftOffset", "stickyRightOffset"]);
|
|
1582
|
+
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
1583
|
+
const [truncated, setTruncated] = React.useState(false);
|
|
1584
|
+
const cellRef = innerRef ? innerRef : React.createRef();
|
|
1585
|
+
const onMouseEnter = (event) => {
|
|
1586
|
+
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
1587
|
+
!showTooltip && setShowTooltip(true);
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
showTooltip && setShowTooltip(false);
|
|
1591
|
+
}
|
|
1592
|
+
onMouseEnterProp(event);
|
|
1593
|
+
};
|
|
1594
|
+
const selectParams = select
|
|
1595
|
+
? selectable(children, {
|
|
1596
|
+
rowIndex: select.rowIndex,
|
|
1597
|
+
rowData: {
|
|
1598
|
+
selected: select.isSelected,
|
|
1599
|
+
disableSelection: select === null || select === void 0 ? void 0 : select.isDisabled,
|
|
1600
|
+
props: select === null || select === void 0 ? void 0 : select.props
|
|
1601
|
+
},
|
|
1602
|
+
column: {
|
|
1603
|
+
extraParams: {
|
|
1604
|
+
onSelect: select === null || select === void 0 ? void 0 : select.onSelect,
|
|
1605
|
+
selectVariant: select.variant || 'checkbox'
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
})
|
|
1609
|
+
: null;
|
|
1610
|
+
const favoriteParams = favorites
|
|
1611
|
+
? favoritable(null, {
|
|
1612
|
+
rowIndex: favorites === null || favorites === void 0 ? void 0 : favorites.rowIndex,
|
|
1613
|
+
rowData: {
|
|
1614
|
+
favorited: favorites.isFavorited,
|
|
1615
|
+
favoritesProps: favorites === null || favorites === void 0 ? void 0 : favorites.props
|
|
1616
|
+
},
|
|
1617
|
+
column: {
|
|
1618
|
+
extraParams: {
|
|
1619
|
+
onFavorite: favorites === null || favorites === void 0 ? void 0 : favorites.onFavorite
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
})
|
|
1623
|
+
: null;
|
|
1624
|
+
const draggableParams = draggableRowProp !== null
|
|
1625
|
+
? draggable(null, {
|
|
1626
|
+
rowData: {
|
|
1627
|
+
id: draggableRowProp.id
|
|
1628
|
+
}
|
|
1629
|
+
})
|
|
1630
|
+
: null;
|
|
1631
|
+
const actionParamsFunc = actions ? cellActions(actions.items, null, null) : null;
|
|
1632
|
+
const actionParams = actionParamsFunc
|
|
1633
|
+
? actionParamsFunc(null, {
|
|
1634
|
+
rowIndex: actions === null || actions === void 0 ? void 0 : actions.rowIndex,
|
|
1635
|
+
rowData: {
|
|
1636
|
+
disableActions: actions === null || actions === void 0 ? void 0 : actions.isDisabled
|
|
1637
|
+
},
|
|
1638
|
+
column: {
|
|
1639
|
+
extraParams: {
|
|
1640
|
+
dropdownPosition: actions === null || actions === void 0 ? void 0 : actions.dropdownPosition,
|
|
1641
|
+
dropdownDirection: actions === null || actions === void 0 ? void 0 : actions.dropdownDirection,
|
|
1642
|
+
menuAppendTo: actions === null || actions === void 0 ? void 0 : actions.menuAppendTo,
|
|
1643
|
+
actionsToggle: actions === null || actions === void 0 ? void 0 : actions.actionsToggle
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
})
|
|
1647
|
+
: null;
|
|
1648
|
+
const expandableParams = expand !== null
|
|
1649
|
+
? collapsible(null, {
|
|
1650
|
+
rowIndex: expand.rowIndex,
|
|
1651
|
+
columnIndex: expand === null || expand === void 0 ? void 0 : expand.columnIndex,
|
|
1652
|
+
rowData: {
|
|
1653
|
+
isOpen: expand.isExpanded
|
|
1654
|
+
},
|
|
1655
|
+
column: {
|
|
1656
|
+
extraParams: {
|
|
1657
|
+
onCollapse: expand === null || expand === void 0 ? void 0 : expand.onToggle,
|
|
1658
|
+
expandId: expand === null || expand === void 0 ? void 0 : expand.expandId
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
: null;
|
|
1663
|
+
const compoundParams = compoundExpandProp !== null
|
|
1664
|
+
? compoundExpand({
|
|
1665
|
+
title: children,
|
|
1666
|
+
props: {
|
|
1667
|
+
isOpen: compoundExpandProp.isExpanded
|
|
1668
|
+
}
|
|
1669
|
+
}, {
|
|
1670
|
+
rowIndex: compoundExpandProp === null || compoundExpandProp === void 0 ? void 0 : compoundExpandProp.rowIndex,
|
|
1671
|
+
columnIndex: compoundExpandProp === null || compoundExpandProp === void 0 ? void 0 : compoundExpandProp.columnIndex,
|
|
1672
|
+
column: {
|
|
1673
|
+
extraParams: {
|
|
1674
|
+
onExpand: compoundExpandProp === null || compoundExpandProp === void 0 ? void 0 : compoundExpandProp.onToggle,
|
|
1675
|
+
expandId: compoundExpandProp === null || compoundExpandProp === void 0 ? void 0 : compoundExpandProp.expandId
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
})
|
|
1679
|
+
: null;
|
|
1680
|
+
const widthParams = width ? cellWidth(width)() : null;
|
|
1681
|
+
const visibilityParams = visibility
|
|
1682
|
+
? classNames(...visibility.map((vis) => Visibility[vis]))()
|
|
1683
|
+
: null;
|
|
1684
|
+
const treeRowParams = treeRowProp !== null
|
|
1685
|
+
? treeRow(treeRowProp.onCollapse, treeRowProp.onCheckChange, treeRowProp.onToggleRowDetails)({
|
|
1686
|
+
title: children
|
|
1687
|
+
}, {
|
|
1688
|
+
rowIndex: treeRowProp.rowIndex,
|
|
1689
|
+
rowData: {
|
|
1690
|
+
props: treeRowProp.props
|
|
1691
|
+
}
|
|
1692
|
+
})
|
|
1693
|
+
: null;
|
|
1694
|
+
const merged = mergeProps(selectParams, actionParams, expandableParams, compoundParams, widthParams, visibilityParams, favoriteParams, treeRowParams, draggableParams);
|
|
1695
|
+
const {
|
|
1696
|
+
// selectable adds this but we don't want it
|
|
1697
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1698
|
+
isVisible = null, children: mergedChildren = null, className: mergedClassName = '', component: MergedComponent = component } = merged, mergedProps = __rest(merged, ["isVisible", "children", "className", "component"]);
|
|
1699
|
+
const treeTableTitleCell = (className && className.includes(treeViewStyles.tableTreeViewTitleCell)) ||
|
|
1700
|
+
(mergedClassName && mergedClassName.includes(treeViewStyles.tableTreeViewTitleCell));
|
|
1701
|
+
React.useEffect(() => {
|
|
1702
|
+
setTruncated(cellRef.current.offsetWidth <
|
|
1703
|
+
cellRef.current.scrollWidth);
|
|
1704
|
+
}, [cellRef]);
|
|
1705
|
+
const cell = (React.createElement(MergedComponent, Object.assign({ tabIndex: (select || !truncated) && modifier !== 'truncate' ? -1 : 0 }, (!treeTableTitleCell && { 'data-label': dataLabel }), { onFocus: tooltip !== null ? onMouseEnter : onMouseEnterProp, onBlur: () => setShowTooltip(false), onMouseEnter: tooltip !== null ? onMouseEnter : onMouseEnterProp, className: css(styles$1.tableTd, className, isActionCell && styles$1.tableAction, textCenter && styles$1.modifiers.center, noPadding && styles$1.modifiers.noPadding, isStickyColumn && styles.tableStickyCell, hasRightBorder && styles.modifiers.borderRight, hasLeftBorder && styles.modifiers.borderLeft, styles$1.modifiers[modifier], draggableParams && styles$1.tableDraggable, mergedClassName), ref: cellRef }, mergedProps, props, (isStickyColumn && {
|
|
1706
|
+
style: Object.assign({ [c_table__sticky_cell_MinWidth.name]: stickyMinWidth ? stickyMinWidth : undefined, [c_table__sticky_cell_InsetInlineStart.name]: stickyLeftOffset ? stickyLeftOffset : 0, [c_table__sticky_cell_InsetInlineEnd.name]: stickyRightOffset ? stickyRightOffset : 0 }, props.style)
|
|
1707
|
+
})), mergedChildren || children));
|
|
1708
|
+
const canMakeDefaultTooltip = tooltip === '' ? typeof children === 'string' : true;
|
|
1709
|
+
return tooltip !== null && canMakeDefaultTooltip && showTooltip ? (React.createElement(React.Fragment, null,
|
|
1710
|
+
cell,
|
|
1711
|
+
React.createElement(Tooltip, { triggerRef: cellRef, content: tooltip || (tooltip === '' && children), isVisible: true }))) : (cell);
|
|
1712
|
+
};
|
|
1713
|
+
const Td = React.forwardRef((props, ref) => (React.createElement(TdBase, Object.assign({}, props, { innerRef: ref }))));
|
|
1714
|
+
Td.displayName = 'Td';
|
|
1715
|
+
|
|
1716
|
+
const textStyles = {
|
|
1717
|
+
"textColorRequired": "pf-v6-u-text-color-required",
|
|
1718
|
+
"textColorSubtle": "pf-v6-u-text-color-subtle"};
|
|
1719
|
+
|
|
1720
|
+
const PropsTable = ({
|
|
1721
|
+
componentName,
|
|
1722
|
+
headingLevel = "h3",
|
|
1723
|
+
componentDescription,
|
|
1724
|
+
componentProps
|
|
1725
|
+
}) => {
|
|
1726
|
+
const SectionHeading = headingLevel;
|
|
1727
|
+
const publicProps = componentProps?.filter((prop) => !prop.isHidden);
|
|
1728
|
+
const hasPropsToRender = !!publicProps?.length;
|
|
1729
|
+
const renderTagLabel = (componentProp) => {
|
|
1730
|
+
const { name, isBeta, isDeprecated } = componentProp;
|
|
1731
|
+
if (!isBeta && !isDeprecated) {
|
|
1732
|
+
return null;
|
|
1733
|
+
}
|
|
1734
|
+
if (isBeta && isDeprecated) {
|
|
1735
|
+
console.error(
|
|
1736
|
+
`The ${name} prop for ${componentName} has both the isBeta and isDeprecated tag.`
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
return /* @__PURE__ */ jsx(Label, { color: `${isBeta ? "blue" : "grey"}`, isCompact: true, children: isBeta ? "Beta" : "Deprecated" });
|
|
1740
|
+
};
|
|
1741
|
+
const renderRequiredDescription = (isRequired) => {
|
|
1742
|
+
if (!isRequired) {
|
|
1743
|
+
return null;
|
|
1744
|
+
}
|
|
1745
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1746
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: css(textStyles.textColorRequired), children: "*" }),
|
|
1747
|
+
/* @__PURE__ */ jsx("span", { className: css(accessibleStyles.screenReader), children: "required" })
|
|
1748
|
+
] });
|
|
1749
|
+
};
|
|
1750
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1751
|
+
/* @__PURE__ */ jsx(SectionHeading, { children: componentName }),
|
|
1752
|
+
/* @__PURE__ */ jsxs(Stack, { hasGutter: true, children: [
|
|
1753
|
+
componentDescription && /* @__PURE__ */ jsx(
|
|
1754
|
+
"div",
|
|
1755
|
+
{
|
|
1756
|
+
"data-testid": "component-description",
|
|
1757
|
+
className: css(textStyles.textColorSubtle),
|
|
1758
|
+
children: componentDescription
|
|
1759
|
+
}
|
|
1760
|
+
),
|
|
1761
|
+
hasPropsToRender && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1762
|
+
/* @__PURE__ */ jsxs("div", { id: `${componentName}-required-description`, children: [
|
|
1763
|
+
/* @__PURE__ */ jsx("span", { className: css(textStyles.textColorRequired), children: "*" }),
|
|
1764
|
+
" ",
|
|
1765
|
+
/* @__PURE__ */ jsx("span", { className: css(textStyles.textColorSubtle), children: "indicates a required prop" })
|
|
1766
|
+
] }),
|
|
1767
|
+
/* @__PURE__ */ jsxs(
|
|
1768
|
+
Table,
|
|
1769
|
+
{
|
|
1770
|
+
variant: "compact",
|
|
1771
|
+
"aria-label": `Props for ${componentName}`,
|
|
1772
|
+
"aria-describedby": `${componentName}-required-description`,
|
|
1773
|
+
gridBreakPoint: "grid-lg",
|
|
1774
|
+
children: [
|
|
1775
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
1776
|
+
/* @__PURE__ */ jsx(Th, { width: 20, children: "Name" }),
|
|
1777
|
+
/* @__PURE__ */ jsx(Th, { width: 20, children: "Type" }),
|
|
1778
|
+
/* @__PURE__ */ jsx(Th, { width: 10, children: "Default" }),
|
|
1779
|
+
/* @__PURE__ */ jsx(Th, { children: "Description" })
|
|
1780
|
+
] }) }),
|
|
1781
|
+
/* @__PURE__ */ jsx(Tbody, { children: publicProps.map((prop) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
1782
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(TableText, { wrapModifier: "breakWord", children: [
|
|
1783
|
+
prop.name,
|
|
1784
|
+
renderRequiredDescription(prop.isRequired),
|
|
1785
|
+
" ",
|
|
1786
|
+
renderTagLabel(prop)
|
|
1787
|
+
] }) }),
|
|
1788
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(TableText, { wrapModifier: "breakWord", children: prop.type || "No type info available" }) }),
|
|
1789
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(TableText, { wrapModifier: "breakWord", children: prop.defaultValue || "-" }) }),
|
|
1790
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(TableText, { wrapModifier: "breakWord", children: prop.description || "No description available." }) })
|
|
1791
|
+
] }, prop.name)) })
|
|
1792
|
+
]
|
|
1793
|
+
}
|
|
1794
|
+
)
|
|
1795
|
+
] })
|
|
1796
|
+
] })
|
|
1797
|
+
] });
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
const $$Astro = createAstro();
|
|
1801
|
+
const $$PropsTables = createComponent(async ($$result, $$props, $$slots) => {
|
|
1802
|
+
const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
|
|
1803
|
+
Astro2.self = $$PropsTables;
|
|
1804
|
+
async function getPropsData(propComponents2) {
|
|
1805
|
+
if (!propComponents2 || propComponents2.length === 0) {
|
|
1806
|
+
return [];
|
|
1807
|
+
}
|
|
1808
|
+
const url = new URL(`/props?components=${propComponents2}`, Astro2.url);
|
|
1809
|
+
try {
|
|
1810
|
+
const response = await fetch(url);
|
|
1811
|
+
const propsData2 = await response.json();
|
|
1812
|
+
return propsData2;
|
|
1813
|
+
} catch (e) {
|
|
1814
|
+
console.error(e);
|
|
1815
|
+
return [];
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
const { propComponents } = Astro2.props;
|
|
1819
|
+
const propsData = await getPropsData(propComponents);
|
|
1820
|
+
return renderTemplate`${propsData.filter((comp) => !!comp).map((component) => renderTemplate`${renderComponent($$result, "PropsTable", PropsTable, { "key": component.name, "componentName": component.name, "componentDescription": component.description, "componentProps": component.props })}`)}`;
|
|
1821
|
+
}, "/home/runner/work/patternfly-doc-core/patternfly-doc-core/src/components/PropsTables.astro", void 0);
|
|
1822
|
+
|
|
1823
|
+
const $$file = "/home/runner/work/patternfly-doc-core/patternfly-doc-core/src/components/PropsTables.astro";
|
|
1824
|
+
const $$url = undefined;
|
|
1825
|
+
|
|
1826
|
+
export { $$PropsTables as default, $$file as file, $$url as url };
|