@patternfly/patternfly-doc-core 1.9.1 → 1.11.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.
Files changed (118) hide show
  1. package/astro.config.mjs +3 -4
  2. package/cli/cli.ts +60 -19
  3. package/cli/convertToMDX.ts +77 -22
  4. package/dist/.assetsignore +2 -0
  5. package/dist/_astro/ClientRouter.astro_astro_type_script_index_0_lang.CtSceO8m.js +1 -0
  6. package/dist/{client/_astro/LiveExample.DZkxbJA_.js → _astro/LiveExample.DjPiO80i.js} +1 -1
  7. package/dist/_astro/client.DN8ES6L5.js +1 -0
  8. package/dist/_routes.json +20 -0
  9. package/dist/_worker.js/_@astrojs-ssr-adapter.mjs +2 -0
  10. package/dist/_worker.js/_astro-internal_middleware.mjs +21 -0
  11. package/dist/_worker.js/_noop-actions.mjs +4 -0
  12. package/dist/{server/chunks/AutoLinkHeader_C2GD0g-K.mjs → _worker.js/chunks/AutoLinkHeader_xh_mBOfs.mjs} +13 -14
  13. package/dist/{server/chunks/Button_BKhHR-ak.mjs → _worker.js/chunks/Button_ByndGYyw.mjs} +83 -13
  14. package/dist/{server/chunks/CSSTable_B8tlH3gz.mjs → _worker.js/chunks/CSSTable_DAbso55e.mjs} +3 -3
  15. package/dist/_worker.js/chunks/PropsTables_BZngJp47.mjs +6628 -0
  16. package/dist/_worker.js/chunks/_@astrojs-ssr-adapter_C9Nk07-M.mjs +1082 -0
  17. package/dist/_worker.js/chunks/angle-down-icon_yt3z9cvI.mjs +3686 -0
  18. package/dist/_worker.js/chunks/astro/server_BpfPtTmt.mjs +7278 -0
  19. package/dist/_worker.js/chunks/astro-designed-error-pages_4xWqsa9_.mjs +928 -0
  20. package/dist/_worker.js/chunks/cloudflare-kv-binding_DMly_2Gl.mjs +107 -0
  21. package/dist/_worker.js/chunks/index_Dc2aKkl4.mjs +57 -0
  22. package/dist/{server/chunks/_@astrojs-ssr-adapter_CbICuCdt.mjs → _worker.js/chunks/index_DlGha6WC.mjs} +1295 -1817
  23. package/dist/_worker.js/chunks/noop-middleware_Ct44Kk5Y.mjs +10 -0
  24. package/dist/_worker.js/chunks/parse_EttCPxrw.mjs +271 -0
  25. package/dist/{server/chunks/path_Cvt6sEOY.mjs → _worker.js/chunks/path_C-ZOwaTP.mjs} +2 -1
  26. package/dist/{server/entry.mjs → _worker.js/index.js} +12 -19
  27. package/dist/_worker.js/manifest_DcBPbZXQ.mjs +100 -0
  28. package/dist/_worker.js/pages/_image.astro.mjs +24 -0
  29. package/dist/_worker.js/pages/_section_/_page_/_---tab_.astro.mjs +1 -0
  30. package/dist/_worker.js/pages/index.astro.mjs +1 -0
  31. package/dist/{server → _worker.js}/pages/props.astro.mjs +3 -2
  32. package/dist/_worker.js/renderers.mjs +484 -0
  33. package/dist/cli/cli.js +46 -12
  34. package/dist/cli/convertToMDX.js +53 -16
  35. package/dist/components/accordion/index.html +60 -0
  36. package/dist/components/accordion/react/index.html +60 -0
  37. package/dist/components/all-components/index.html +47 -0
  38. package/dist/design-foundations/typography/index.html +198 -0
  39. package/dist/{client/design-foundations → design-foundations}/usage-and-behavior/index.html +4 -54
  40. package/dist/get-started/contribute/index.html +94 -0
  41. package/dist/index.html +43 -0
  42. package/package.json +12 -8
  43. package/public/.assetsignore +2 -0
  44. package/src/components/LiveExample.astro +2 -2
  45. package/src/components/LiveExample.tsx +38 -9
  46. package/src/pages/props.ts +2 -2
  47. package/wrangler.jsonc +14 -0
  48. package/dist/client/_astro/ClientRouter.astro_astro_type_script_index_0_lang.Cainpjm5.js +0 -1
  49. package/dist/client/_astro/client.zs76E0tG.js +0 -1
  50. package/dist/client/components/accordion/index.html +0 -110
  51. package/dist/client/components/accordion/react/index.html +0 -110
  52. package/dist/client/components/all-components/index.html +0 -97
  53. package/dist/client/design-foundations/typography/index.html +0 -248
  54. package/dist/client/get-started/contribute/index.html +0 -144
  55. package/dist/client/index.html +0 -43
  56. package/dist/server/_@astrojs-ssr-adapter.mjs +0 -1
  57. package/dist/server/_noop-middleware.mjs +0 -3
  58. package/dist/server/chunks/PropsTables_PVzRHJNB.mjs +0 -1750
  59. package/dist/server/chunks/_astro_assets_DaYumpRZ.mjs +0 -1507
  60. package/dist/server/chunks/angle-down-icon_BO1Ed-9Z.mjs +0 -3288
  61. package/dist/server/chunks/astro/server_Cl9jPh4p.mjs +0 -2859
  62. package/dist/server/chunks/astro-designed-error-pages_BFveJFnQ.mjs +0 -282
  63. package/dist/server/chunks/consts_BmVDRGlB.mjs +0 -32
  64. package/dist/server/chunks/sharp_CbOL3WDk.mjs +0 -88
  65. package/dist/server/manifest_DxJLmW-j.mjs +0 -102
  66. package/dist/server/pages/_image.astro.mjs +0 -132
  67. package/dist/server/renderers.mjs +0 -308
  68. /package/dist/{client/PF-HorizontalLogo-Color.svg → PF-HorizontalLogo-Color.svg} +0 -0
  69. /package/dist/{client/PF-HorizontalLogo-Reverse.svg → PF-HorizontalLogo-Reverse.svg} +0 -0
  70. /package/dist/{client/_astro → _astro}/Button.BQCwQ5pE.js +0 -0
  71. /package/dist/{client/_astro → _astro}/CSSTable.DC79W1Ct.js +0 -0
  72. /package/dist/{client/_astro → _astro}/Content.B4M2qzJY.js +0 -0
  73. /package/dist/{client/_astro → _astro}/DropdownList.cxp03sS4.js +0 -0
  74. /package/dist/{client/_astro → _astro}/LiveExample.CxJsMvEq.css +0 -0
  75. /package/dist/{client/_astro → _astro}/Navigation.kbLxctIo.js +0 -0
  76. /package/dist/{client/_astro → _astro}/PageContext.miTsIqVo.js +0 -0
  77. /package/dist/{client/_astro → _astro}/PageSidebarBody.B0AJe8Hg.js +0 -0
  78. /package/dist/{client/_astro → _astro}/PageToggle.CMZ3C1v1.js +0 -0
  79. /package/dist/{client/_astro → _astro}/RedHatDisplayVF-Italic.CRpusWc8.woff2 +0 -0
  80. /package/dist/{client/_astro → _astro}/RedHatDisplayVF.CYDHf1NI.woff2 +0 -0
  81. /package/dist/{client/_astro → _astro}/RedHatMonoVF-Italic.DGQo2ogW.woff2 +0 -0
  82. /package/dist/{client/_astro → _astro}/RedHatMonoVF.C4fMH6Vz.woff2 +0 -0
  83. /package/dist/{client/_astro → _astro}/RedHatTextVF-Italic.Dkj_WqbA.woff2 +0 -0
  84. /package/dist/{client/_astro → _astro}/RedHatTextVF.wYvZ7prR.woff2 +0 -0
  85. /package/dist/{client/_astro → _astro}/SearchInput.DhHo7yPx.js +0 -0
  86. /package/dist/{client/_astro → _astro}/SectionGallery.3ABpQwE4.js +0 -0
  87. /package/dist/{client/_astro → _astro}/Toolbar.CroDQcyv.js +0 -0
  88. /package/dist/{client/_astro → _astro}/ToolbarContent.UH3ZRlHp.js +0 -0
  89. /package/dist/{client/_astro → _astro}/_page_.Chv_bGyU.css +0 -0
  90. /package/dist/{client/_astro → _astro}/_page_.CtheD08_.css +0 -0
  91. /package/dist/{client/_astro → _astro}/_page_.D1z73Byz.css +0 -0
  92. /package/dist/{client/_astro → _astro}/_page_.DxJDkZPc.css +0 -0
  93. /package/dist/{client/_astro → _astro}/angle-left-icon.teo8GC0v.js +0 -0
  94. /package/dist/{client/_astro → _astro}/bars-icon.Dk6ua1rr.js +0 -0
  95. /package/dist/{client/_astro → _astro}/divider.tlrBPkzg.js +0 -0
  96. /package/dist/{client/_astro → _astro}/fa-solid-900.DguXoeIz.woff2 +0 -0
  97. /package/dist/{client/_astro → _astro}/github-icon.ByC5XEPt.js +0 -0
  98. /package/dist/{client/_astro → _astro}/index.BQFV5hT1.js +0 -0
  99. /package/dist/{client/_astro → _astro}/index.CAChmxYj.js +0 -0
  100. /package/dist/{client/_astro → _astro}/index.DYVB4vTo.js +0 -0
  101. /package/dist/{client/_astro → _astro}/index.eCxJ45ll.js +0 -0
  102. /package/dist/{client/_astro → _astro}/link-icon.BNHnRn73.js +0 -0
  103. /package/dist/{client/_astro → _astro}/page.BTC3Kf3x.js +0 -0
  104. /package/dist/{client/_astro → _astro}/pf-v6-pficon.Dy6oiu9u.woff2 +0 -0
  105. /package/dist/{server/chunks/Accordion_BJka4Qvb.mjs → _worker.js/chunks/Accordion_BNafbla6.mjs} +0 -0
  106. /package/dist/{server/chunks/Accordion_BQIphkaZ.mjs → _worker.js/chunks/Accordion_CZsuyu9E.mjs} +0 -0
  107. /package/dist/{server/chunks/AllComponents_CRhgTsiT.mjs → _worker.js/chunks/AllComponents_BrL9IHSc.mjs} +0 -0
  108. /package/dist/{server/chunks/AllComponents_CjOtwUH6.mjs → _worker.js/chunks/AllComponents_CI7S6uwA.mjs} +0 -0
  109. /package/dist/{server/chunks/_astro_data-layer-content_D4Ib_RjR.mjs → _worker.js/chunks/_astro_assets_vBCb4v6U.mjs} +0 -0
  110. /package/dist/{server/chunks/content-assets_DleWbedO.mjs → _worker.js/chunks/_astro_data-layer-content_CgXoS6Mm.mjs} +0 -0
  111. /package/dist/{server/chunks/content-modules_fX1c2JRG.mjs → _worker.js/chunks/content-assets_XqCgPAV2.mjs} +0 -0
  112. /package/dist/{server/pages/_section_/_---page_.astro.mjs → _worker.js/chunks/content-modules_CKq2j9RQ.mjs} +0 -0
  113. /package/dist/{server/pages/_section_/_page_/_---tab_.astro.mjs → _worker.js/chunks/sharp_CNjr3bU4.mjs} +0 -0
  114. /package/dist/{server/pages/index.astro.mjs → _worker.js/pages/_section_/_---page_.astro.mjs} +0 -0
  115. /package/dist/{client/avatarImg.svg → avatarImg.svg} +0 -0
  116. /package/dist/{client/avatarImgDark.svg → avatarImgDark.svg} +0 -0
  117. /package/dist/{client/content → content}/typography/line-height.png +0 -0
  118. /package/dist/{client/favicon.svg → favicon.svg} +0 -0
@@ -1,3288 +0,0 @@
1
- import { r as getUniqueId, a as canUseDOM, w as getLanguageDirection, x as clearTimeouts, c as css, b as createIcon, K as KeyTypes, g as getDefaultOUIAId, e as getOUIAProps, B as Button, d as ExclamationCircleIcon, E as ExclamationTriangleIcon, C as CheckCircleIcon, l as formatBreakpointMods, u as useOUIAProps } from './Button_BKhHR-ak.mjs';
2
- import { __rest } from 'tslib';
3
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
- import { Component, useLayoutEffect, useEffect, useRef, useState, useMemo, useCallback, isValidElement, cloneElement, createRef, createContext, forwardRef, useContext } from 'react';
5
- /* empty css */
6
- import * as ReactDOM from 'react-dom';
7
-
8
- /** This Component can be used to wrap a functional component in order to generate a random ID
9
- * Example of how to use this component
10
- *
11
- * const Component = ({id}: {id: string}) => (
12
- * <GenerateId>{randomId => (
13
- * <div id={id || randomId}>
14
- * div with random ID
15
- * </div>
16
- * )}
17
- * </GenerateId>
18
- * );
19
- */
20
- let currentId = 0;
21
- // gives us a unique (enough) id to add to the generated id that it should prevent issues with duplicate ids
22
- function getRandomId() {
23
- if (typeof crypto !== 'undefined' && crypto.randomUUID) {
24
- return crypto.randomUUID();
25
- }
26
- else {
27
- return getUniqueId();
28
- }
29
- }
30
- class GenerateId extends Component {
31
- constructor() {
32
- super(...arguments);
33
- this.uniqueElement = this.props.isRandom ? getRandomId() : currentId++;
34
- this.id = `${this.props.prefix}${this.uniqueElement}`;
35
- }
36
- render() {
37
- return this.props.children(this.id);
38
- }
39
- }
40
- GenerateId.displayName = 'GenerateId';
41
- GenerateId.defaultProps = {
42
- prefix: 'pf-random-id-',
43
- isRandom: false
44
- };
45
-
46
- const ASTERISK = '*';
47
-
48
- /**
49
- * @param element
50
- */
51
- function getBoundingClientRect(element) {
52
- const rect = element.getBoundingClientRect();
53
- return {
54
- width: rect.width,
55
- height: rect.height,
56
- top: rect.top,
57
- right: rect.right,
58
- bottom: rect.bottom,
59
- left: rect.left,
60
- x: rect.left,
61
- y: rect.top
62
- };
63
- }
64
-
65
- // @ts-nocheck
66
- /* :: import type { Window } from '../types'; */
67
- /* :: declare function getWindow(node: Node | Window): Window; */
68
- /**
69
- * @param node
70
- */
71
- function getWindow(node) {
72
- if (node.toString() !== '[object Window]') {
73
- const ownerDocument = node.ownerDocument;
74
- return ownerDocument ? ownerDocument.defaultView : window;
75
- }
76
- return node;
77
- }
78
-
79
- // @ts-nocheck
80
- /**
81
- * @param node
82
- */
83
- function getWindowScroll(node) {
84
- const win = getWindow(node);
85
- const scrollLeft = win.pageXOffset;
86
- const scrollTop = win.pageYOffset;
87
- return {
88
- scrollLeft,
89
- scrollTop
90
- };
91
- }
92
-
93
- // @ts-nocheck
94
- /* :: declare function isElement(node: mixed): boolean %checks(node instanceof
95
- Element); */
96
- /**
97
- * @param node
98
- */
99
- function isElement(node) {
100
- const OwnElement = getWindow(node).Element;
101
- return node instanceof OwnElement || node instanceof Element;
102
- }
103
- /* :: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
104
- HTMLElement); */
105
- /**
106
- * @param node
107
- */
108
- function isHTMLElement(node) {
109
- const OwnElement = getWindow(node).HTMLElement;
110
- return node instanceof OwnElement || node instanceof HTMLElement;
111
- }
112
-
113
- // @ts-nocheck
114
- /**
115
- * @param element
116
- */
117
- function getHTMLElementScroll(element) {
118
- return {
119
- scrollLeft: element.scrollLeft,
120
- scrollTop: element.scrollTop
121
- };
122
- }
123
-
124
- // @ts-nocheck
125
- /**
126
- * @param node
127
- */
128
- function getNodeScroll(node) {
129
- if (node === getWindow(node) || !isHTMLElement(node)) {
130
- return getWindowScroll(node);
131
- }
132
- else {
133
- return getHTMLElementScroll(node);
134
- }
135
- }
136
-
137
- /**
138
- * @param element
139
- */
140
- function getNodeName(element) {
141
- return element ? (element.nodeName || '').toLowerCase() : null;
142
- }
143
-
144
- // @ts-nocheck
145
- /**
146
- * @param element
147
- */
148
- function getDocumentElement(element) {
149
- // $FlowFixMe: assume body is always available
150
- return (isElement(element) ? element.ownerDocument : element.document).documentElement;
151
- }
152
-
153
- // @ts-nocheck
154
- /**
155
- * @param element
156
- */
157
- function getWindowScrollBarX(element) {
158
- // If <html> has a CSS width greater than the viewport, then this will be
159
- // incorrect for RTL.
160
- // Popper 1 is broken in this case and never had a bug report so let's assume
161
- // it's not an issue. I don't think anyone ever specifies width on <html>
162
- // anyway.
163
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
164
- // this (e.g. Edge 2019, IE11, Safari)
165
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
166
- }
167
-
168
- // @ts-nocheck
169
- /**
170
- * @param element
171
- */
172
- function getComputedStyle$1(element) {
173
- return getWindow(element).getComputedStyle(element);
174
- }
175
-
176
- // @ts-nocheck
177
- /**
178
- * @param element
179
- */
180
- function isScrollParent(element) {
181
- // Firefox wants us to check `-x` and `-y` variations as well
182
- const { overflow, overflowX, overflowY } = getComputedStyle$1(element);
183
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
184
- }
185
-
186
- // Returns the composite rect of an element relative to its offsetParent.
187
- // Composite means it takes into account transforms as well as layout.
188
- /**
189
- * @param elementOrVirtualElement
190
- * @param offsetParent
191
- * @param isFixed
192
- */
193
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed = false) {
194
- const documentElement = getDocumentElement(offsetParent);
195
- const rect = getBoundingClientRect(elementOrVirtualElement);
196
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
197
- let scroll = { scrollLeft: 0, scrollTop: 0 };
198
- let offsets = { x: 0, y: 0 };
199
- if (isOffsetParentAnElement || (!isOffsetParentAnElement && !isFixed)) {
200
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
201
- isScrollParent(documentElement)) {
202
- scroll = getNodeScroll(offsetParent);
203
- }
204
- if (isHTMLElement(offsetParent)) {
205
- offsets = getBoundingClientRect(offsetParent);
206
- offsets.x += offsetParent.clientLeft;
207
- offsets.y += offsetParent.clientTop;
208
- }
209
- else if (documentElement) {
210
- offsets.x = getWindowScrollBarX(documentElement);
211
- }
212
- }
213
- return {
214
- x: rect.left + scroll.scrollLeft - offsets.x,
215
- y: rect.top + scroll.scrollTop - offsets.y,
216
- width: rect.width,
217
- height: rect.height
218
- };
219
- }
220
-
221
- // Returns the layout rect of an element relative to its offsetParent. Layout
222
- // means it doesn't take into account transforms.
223
- /**
224
- * @param element
225
- */
226
- function getLayoutRect(element) {
227
- return {
228
- x: element.offsetLeft,
229
- y: element.offsetTop,
230
- width: element.offsetWidth,
231
- height: element.offsetHeight
232
- };
233
- }
234
-
235
- // @ts-nocheck
236
- /**
237
- * @param element
238
- */
239
- function getParentNode(element) {
240
- if (getNodeName(element) === 'html') {
241
- return element;
242
- }
243
- return (
244
- // $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
245
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
246
- element.parentNode || // DOM Element detected
247
- // $FlowFixMe: need a better way to handle this...
248
- element.host || // ShadowRoot detected
249
- // $FlowFixMe: HTMLElement is a Node
250
- getDocumentElement(element) // fallback
251
- );
252
- }
253
-
254
- // @ts-nocheck
255
- /**
256
- * @param node
257
- */
258
- function getScrollParent(node) {
259
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
260
- // $FlowFixMe: assume body is always available
261
- return node.ownerDocument.body;
262
- }
263
- if (isHTMLElement(node) && isScrollParent(node)) {
264
- return node;
265
- }
266
- return getScrollParent(getParentNode(node));
267
- }
268
-
269
- // @ts-nocheck
270
- /*
271
- given a DOM element, return the list of all scroll parents, up the list of ancesors
272
- until we get to the top window object. This list is what we attach scroll listeners
273
- to, because if any of these parent elements scroll, we'll need to re-calculate the
274
- reference element's position.
275
- */
276
- /**
277
- * @param element
278
- * @param list
279
- */
280
- function listScrollParents(element, list = []) {
281
- const scrollParent = getScrollParent(element);
282
- const isBody = getNodeName(scrollParent) === 'body';
283
- const win = getWindow(scrollParent);
284
- const target = isBody
285
- ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : [])
286
- : scrollParent;
287
- const updatedList = list.concat(target);
288
- return isBody
289
- ? updatedList // $FlowFixMe: isBody tells us target will be an HTMLElement here
290
- : updatedList.concat(listScrollParents(getParentNode(target)));
291
- }
292
-
293
- // @ts-nocheck
294
- /**
295
- * @param element
296
- */
297
- function isTableElement(element) {
298
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
299
- }
300
-
301
- // @ts-nocheck
302
- /**
303
- * @param element
304
- */
305
- function getTrueOffsetParent(element) {
306
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
307
- getComputedStyle$1(element).position === 'fixed') {
308
- return null;
309
- }
310
- const offsetParent = element.offsetParent;
311
- if (offsetParent) {
312
- const html = getDocumentElement(offsetParent);
313
- if (getNodeName(offsetParent) === 'body' &&
314
- getComputedStyle$1(offsetParent).position === 'static' &&
315
- getComputedStyle$1(html).position !== 'static') {
316
- return html;
317
- }
318
- }
319
- return offsetParent;
320
- }
321
- // `.offsetParent` reports `null` for fixed elements, while absolute elements
322
- // return the containing block
323
- /**
324
- * @param element
325
- */
326
- function getContainingBlock(element) {
327
- let currentNode = getParentNode(element);
328
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
329
- const css = getComputedStyle$1(currentNode);
330
- // This is non-exhaustive but covers the most common CSS properties that
331
- // create a containing block.
332
- if (css.transform !== 'none' || css.perspective !== 'none' || (css.willChange && css.willChange !== 'auto')) {
333
- return currentNode;
334
- }
335
- else {
336
- currentNode = currentNode.parentNode;
337
- }
338
- }
339
- return null;
340
- }
341
- // Gets the closest ancestor positioned element. Handles some edge cases,
342
- // such as table ancestors and cross browser bugs.
343
- /**
344
- * @param element
345
- */
346
- function getOffsetParent(element) {
347
- const window = getWindow(element);
348
- let offsetParent = getTrueOffsetParent(element);
349
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
350
- offsetParent = getTrueOffsetParent(offsetParent);
351
- }
352
- if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static') {
353
- return window;
354
- }
355
- return offsetParent || getContainingBlock(element) || window;
356
- }
357
-
358
- // @ts-nocheck
359
- const top = 'top';
360
- const bottom = 'bottom';
361
- const right = 'right';
362
- const left = 'left';
363
- const auto = 'auto';
364
- const basePlacements = [top, bottom, right, left];
365
- const start = 'start';
366
- const end = 'end';
367
- const clippingParents = 'clippingParents';
368
- const viewport = 'viewport';
369
- const popper = 'popper';
370
- const reference = 'reference';
371
- const variationPlacements = basePlacements.reduce((acc, placement) => acc.concat([`${placement}-${start}`, `${placement}-${end}`]), []);
372
- const placements = [...basePlacements, auto].reduce((acc, placement) => acc.concat([placement, `${placement}-${start}`, `${placement}-${end}`]), []);
373
- // modifiers that need to read the DOM
374
- const beforeRead = 'beforeRead';
375
- const read = 'read';
376
- const afterRead = 'afterRead';
377
- // pure-logic modifiers
378
- const beforeMain = 'beforeMain';
379
- const main = 'main';
380
- const afterMain = 'afterMain';
381
- // modifier with the purpose to write to the DOM (or write into a framework state)
382
- const beforeWrite = 'beforeWrite';
383
- const write = 'write';
384
- const afterWrite = 'afterWrite';
385
- const modifierPhases = [
386
- beforeRead,
387
- read,
388
- afterRead,
389
- beforeMain,
390
- main,
391
- afterMain,
392
- beforeWrite,
393
- write,
394
- afterWrite
395
- ];
396
-
397
- // source: https://stackoverflow.com/questions/49875255
398
- /**
399
- * @param modifiers
400
- */
401
- function order(modifiers) {
402
- const map = new Map();
403
- const visited = new Set();
404
- const result = [];
405
- modifiers.forEach(modifier => {
406
- map.set(modifier.name, modifier);
407
- });
408
- // On visiting object, check for its dependencies and visit them recursively
409
- /**
410
- * @param modifier
411
- */
412
- function sort(modifier) {
413
- visited.add(modifier.name);
414
- const requires = [...(modifier.requires || []), ...(modifier.requiresIfExists || [])];
415
- requires.forEach(dep => {
416
- if (!visited.has(dep)) {
417
- const depModifier = map.get(dep);
418
- if (depModifier) {
419
- sort(depModifier);
420
- }
421
- }
422
- });
423
- result.push(modifier);
424
- }
425
- modifiers.forEach(modifier => {
426
- if (!visited.has(modifier.name)) {
427
- // check for visited object
428
- sort(modifier);
429
- }
430
- });
431
- return result;
432
- }
433
- /**
434
- * @param modifiers
435
- */
436
- function orderModifiers(modifiers) {
437
- // order based on dependencies
438
- const orderedModifiers = order(modifiers);
439
- // order based on phase
440
- return modifierPhases.reduce((acc, phase) => acc.concat(orderedModifiers.filter(modifier => modifier.phase === phase)), []);
441
- }
442
-
443
- // @ts-nocheck
444
- /**
445
- * @param fn
446
- */
447
- function debounce(fn) {
448
- let pending;
449
- return () => {
450
- if (!pending) {
451
- pending = new Promise(resolve => {
452
- Promise.resolve().then(() => {
453
- pending = undefined;
454
- resolve(fn());
455
- });
456
- });
457
- }
458
- return pending;
459
- };
460
- }
461
-
462
- /**
463
- * @param placement
464
- */
465
- function getBasePlacement(placement) {
466
- return placement.split('-')[0];
467
- }
468
-
469
- /**
470
- * @param modifiers
471
- */
472
- function mergeByName(modifiers) {
473
- const merged = modifiers.reduce((merged, current) => {
474
- const existing = merged[current.name];
475
- merged[current.name] = existing
476
- ? Object.assign(Object.assign(Object.assign({}, existing), current), { options: Object.assign(Object.assign({}, existing.options), current.options), data: Object.assign(Object.assign({}, existing.data), current.data) }) : current;
477
- return merged;
478
- }, {});
479
- // IE11 does not support Object.values
480
- return Object.keys(merged).map(key => merged[key]);
481
- }
482
-
483
- // @ts-nocheck
484
- /**
485
- * @param element
486
- */
487
- function getViewportRect(element) {
488
- const win = getWindow(element);
489
- const html = getDocumentElement(element);
490
- const visualViewport = win.visualViewport;
491
- let width = html.clientWidth;
492
- let height = html.clientHeight;
493
- let x = 0;
494
- let y = 0;
495
- // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
496
- // can be obscured underneath it.
497
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
498
- // if it isn't open, so if this isn't available, the popper will be detected
499
- // to overflow the bottom of the screen too early.
500
- if (visualViewport) {
501
- width = visualViewport.width;
502
- height = visualViewport.height;
503
- // Uses Layout Viewport (like Chrome; Safari does not currently)
504
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
505
- // errors due to floating point numbers, so we need to check precision.
506
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
507
- // Feature detection fails in mobile emulation mode in Chrome.
508
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
509
- // 0.001
510
- // Fallback here: "Not Safari" userAgent
511
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
512
- x = visualViewport.offsetLeft;
513
- y = visualViewport.offsetTop;
514
- }
515
- }
516
- return {
517
- width,
518
- height,
519
- x: x + getWindowScrollBarX(element),
520
- y
521
- };
522
- }
523
-
524
- // Gets the entire size of the scrollable document area, even extending outside
525
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
526
- /**
527
- * @param element
528
- */
529
- function getDocumentRect(element) {
530
- const html = getDocumentElement(element);
531
- const winScroll = getWindowScroll(element);
532
- const body = element.ownerDocument.body;
533
- const width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
534
- const height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
535
- let x = -winScroll.scrollLeft + getWindowScrollBarX(element);
536
- const y = -winScroll.scrollTop;
537
- if (getComputedStyle$1(body || html).direction === 'rtl') {
538
- x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
539
- }
540
- return { width, height, x, y };
541
- }
542
-
543
- // @ts-nocheck
544
- /**
545
- * @param parent
546
- * @param child
547
- */
548
- function contains(parent, child) {
549
- // $FlowFixMe: hasOwnProperty doesn't seem to work in tests
550
- const isShadow = Boolean(child.getRootNode && child.getRootNode().host);
551
- // First, attempt with faster native method
552
- if (parent.contains(child)) {
553
- return true;
554
- } // then fallback to custom implementation with Shadow DOM support
555
- else if (isShadow) {
556
- let next = child;
557
- do {
558
- if (next && parent.isSameNode(next)) {
559
- return true;
560
- }
561
- // $FlowFixMe: need a better way to handle this...
562
- next = next.parentNode || next.host;
563
- } while (next);
564
- }
565
- // Give up, the result is false
566
- return false;
567
- }
568
-
569
- /**
570
- * @param rect
571
- */
572
- function rectToClientRect(rect) {
573
- return Object.assign(Object.assign({}, rect), { left: rect.x, top: rect.y, right: rect.x + rect.width, bottom: rect.y + rect.height });
574
- }
575
-
576
- /**
577
- * @param element
578
- */
579
- function getInnerBoundingClientRect(element) {
580
- const rect = getBoundingClientRect(element);
581
- rect.top = rect.top + element.clientTop;
582
- rect.left = rect.left + element.clientLeft;
583
- rect.bottom = rect.top + element.clientHeight;
584
- rect.right = rect.left + element.clientWidth;
585
- rect.width = element.clientWidth;
586
- rect.height = element.clientHeight;
587
- rect.x = rect.left;
588
- rect.y = rect.top;
589
- return rect;
590
- }
591
- /**
592
- * @param element
593
- * @param clippingParent
594
- */
595
- function getClientRectFromMixedType(element, clippingParent) {
596
- return clippingParent === viewport
597
- ? rectToClientRect(getViewportRect(element))
598
- : isHTMLElement(clippingParent)
599
- ? getInnerBoundingClientRect(clippingParent)
600
- : rectToClientRect(getDocumentRect(getDocumentElement(element)));
601
- }
602
- // A "clipping parent" is an overflowable container with the characteristic of
603
- // clipping (or hiding) overflowing elements with a position different from
604
- // `initial`
605
- /**
606
- * @param element
607
- */
608
- function getClippingParents(element) {
609
- const clippingParents = listScrollParents(getParentNode(element));
610
- const canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
611
- const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
612
- if (!isElement(clipperElement)) {
613
- return [];
614
- }
615
- // $FlowFixMe: https://github.com/facebook/flow/issues/1414
616
- return clippingParents.filter(clippingParent => isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body');
617
- }
618
- // Gets the maximum area that the element is visible in due to any number of
619
- // clipping parents
620
- /**
621
- * @param element
622
- * @param boundary
623
- * @param rootBoundary
624
- */
625
- function getClippingRect(element, boundary, rootBoundary) {
626
- const mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
627
- const clippingParents = [...mainClippingParents, rootBoundary];
628
- const firstClippingParent = clippingParents[0];
629
- const clippingRect = clippingParents.reduce((accRect, clippingParent) => {
630
- const rect = getClientRectFromMixedType(element, clippingParent);
631
- accRect.top = Math.max(rect.top, accRect.top);
632
- accRect.right = Math.min(rect.right, accRect.right);
633
- accRect.bottom = Math.min(rect.bottom, accRect.bottom);
634
- accRect.left = Math.max(rect.left, accRect.left);
635
- return accRect;
636
- }, getClientRectFromMixedType(element, firstClippingParent));
637
- clippingRect.width = clippingRect.right - clippingRect.left;
638
- clippingRect.height = clippingRect.bottom - clippingRect.top;
639
- clippingRect.x = clippingRect.left;
640
- clippingRect.y = clippingRect.top;
641
- return clippingRect;
642
- }
643
-
644
- /**
645
- * @param placement
646
- */
647
- function getVariation(placement) {
648
- return placement.split('-')[1];
649
- }
650
-
651
- /**
652
- * @param placement
653
- */
654
- function getMainAxisFromPlacement(placement) {
655
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
656
- }
657
-
658
- // @ts-nocheck
659
- /**
660
- *
661
- */
662
- function computeOffsets({ reference, element, placement }) {
663
- const basePlacement = placement ? getBasePlacement(placement) : null;
664
- const variation = placement ? getVariation(placement) : null;
665
- const commonX = reference.x + reference.width / 2 - element.width / 2;
666
- const commonY = reference.y + reference.height / 2 - element.height / 2;
667
- let offsets;
668
- switch (basePlacement) {
669
- case top:
670
- offsets = {
671
- x: commonX,
672
- y: reference.y - element.height
673
- };
674
- break;
675
- case bottom:
676
- offsets = {
677
- x: commonX,
678
- y: reference.y + reference.height
679
- };
680
- break;
681
- case right:
682
- offsets = {
683
- x: reference.x + reference.width,
684
- y: commonY
685
- };
686
- break;
687
- case left:
688
- offsets = {
689
- x: reference.x - element.width,
690
- y: commonY
691
- };
692
- break;
693
- default:
694
- offsets = {
695
- x: reference.x,
696
- y: reference.y
697
- };
698
- }
699
- const mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
700
- if (mainAxis != null) {
701
- const len = mainAxis === 'y' ? 'height' : 'width';
702
- switch (variation) {
703
- case start:
704
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
705
- break;
706
- case end:
707
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
708
- break;
709
- }
710
- }
711
- return offsets;
712
- }
713
-
714
- /**
715
- *
716
- */
717
- function getFreshSideObject() {
718
- return {
719
- top: 0,
720
- right: 0,
721
- bottom: 0,
722
- left: 0
723
- };
724
- }
725
-
726
- /**
727
- * @param paddingObject
728
- */
729
- function mergePaddingObject(paddingObject) {
730
- return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
731
- }
732
-
733
- // @ts-nocheck
734
- /**
735
- * @param value
736
- * @param keys
737
- */
738
- function expandToHashMap(value, keys) {
739
- return keys.reduce((hashMap, key) => {
740
- hashMap[key] = value;
741
- return hashMap;
742
- }, {});
743
- }
744
-
745
- /**
746
- * @param state
747
- * @param options
748
- */
749
- function detectOverflow(state, options = {}) {
750
- const { placement = state.placement, boundary = clippingParents, rootBoundary = viewport, elementContext = popper, altBoundary = false, padding = 0 } = options;
751
- const paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
752
- const altContext = elementContext === popper ? reference : popper;
753
- const referenceElement = state.elements.reference;
754
- const popperRect = state.rects.popper;
755
- const element = state.elements[altBoundary ? altContext : elementContext];
756
- const clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
757
- const referenceClientRect = getBoundingClientRect(referenceElement);
758
- const popperOffsets = computeOffsets({
759
- reference: referenceClientRect,
760
- element: popperRect,
761
- placement
762
- });
763
- const popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
764
- const elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
765
- // positive = overflowing the clipping rect
766
- // 0 or negative = within the clipping rect
767
- const overflowOffsets = {
768
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
769
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
770
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
771
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
772
- };
773
- const offsetData = state.modifiersData.offset;
774
- // Offsets can be applied only to the popper element
775
- if (elementContext === popper && offsetData) {
776
- const offset = offsetData[placement];
777
- Object.keys(overflowOffsets).forEach(key => {
778
- const multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
779
- const axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
780
- overflowOffsets[key] += offset[axis] * multiply;
781
- });
782
- }
783
- return overflowOffsets;
784
- }
785
-
786
- const DEFAULT_OPTIONS = {
787
- placement: 'bottom',
788
- modifiers: [],
789
- strategy: 'absolute'
790
- };
791
- /**
792
- * @param args
793
- */
794
- function areValidElements(...args) {
795
- return !args.some(element => !(element && typeof element.getBoundingClientRect === 'function'));
796
- }
797
- /**
798
- * @param generatorOptions
799
- */
800
- function popperGenerator(generatorOptions = {}) {
801
- const { defaultModifiers = [], defaultOptions = DEFAULT_OPTIONS } = generatorOptions;
802
- return function createPopper(reference, popper, options = defaultOptions) {
803
- let state = {
804
- placement: 'bottom',
805
- orderedModifiers: [],
806
- options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),
807
- modifiersData: {},
808
- elements: {
809
- reference,
810
- popper
811
- },
812
- attributes: {},
813
- styles: {}
814
- };
815
- let effectCleanupFns = [];
816
- let isDestroyed = false;
817
- const instance = {
818
- state,
819
- setOptions(options) {
820
- cleanupModifierEffects();
821
- state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
822
- state.scrollParents = {
823
- reference: isElement(reference)
824
- ? listScrollParents(reference)
825
- : reference.contextElement
826
- ? listScrollParents(reference.contextElement)
827
- : [],
828
- popper: listScrollParents(popper)
829
- };
830
- // Orders the modifiers based on their dependencies and `phase`
831
- // properties
832
- const orderedModifiers = orderModifiers(mergeByName([...defaultModifiers, ...state.options.modifiers]));
833
- // Strip out disabled modifiers
834
- state.orderedModifiers = orderedModifiers.filter(m => m.enabled);
835
- runModifierEffects();
836
- return instance.update();
837
- },
838
- // Sync update – it will always be executed, even if not necessary. This
839
- // is useful for low frequency updates where sync behavior simplifies the
840
- // logic.
841
- // For high frequency updates (e.g. `resize` and `scroll` events), always
842
- // prefer the async Popper#update method
843
- forceUpdate() {
844
- if (isDestroyed) {
845
- return;
846
- }
847
- const { reference, popper } = state.elements;
848
- // Don't proceed if `reference` or `popper` are not valid elements
849
- // anymore
850
- if (!areValidElements(reference, popper)) {
851
- return;
852
- }
853
- // Store the reference and popper rects to be read by modifiers
854
- state.rects = {
855
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
856
- popper: getLayoutRect(popper)
857
- };
858
- // Modifiers have the ability to reset the current update cycle. The
859
- // most common use case for this is the `flip` modifier changing the
860
- // placement, which then needs to re-run all the modifiers, because the
861
- // logic was previously ran for the previous placement and is therefore
862
- // stale/incorrect
863
- state.reset = false;
864
- state.placement = state.options.placement;
865
- // On each update cycle, the `modifiersData` property for each modifier
866
- // is filled with the initial data specified by the modifier. This means
867
- // it doesn't persist and is fresh on each update.
868
- // To ensure persistent data, use `${name}#persistent`
869
- state.orderedModifiers.forEach(modifier => (state.modifiersData[modifier.name] = Object.assign({}, modifier.data)));
870
- for (let index = 0; index < state.orderedModifiers.length; index++) {
871
- if (state.reset === true) {
872
- state.reset = false;
873
- index = -1;
874
- continue;
875
- }
876
- const { fn, options = {}, name } = state.orderedModifiers[index];
877
- if (typeof fn === 'function') {
878
- state = fn({ state, options, name, instance }) || state;
879
- }
880
- }
881
- },
882
- // Async and optimistically optimized update – it will not be executed if
883
- // not necessary (debounced to run at most once-per-tick)
884
- update: debounce(() => new Promise(resolve => {
885
- instance.forceUpdate();
886
- resolve(state);
887
- })),
888
- destroy() {
889
- cleanupModifierEffects();
890
- isDestroyed = true;
891
- }
892
- };
893
- if (!areValidElements(reference, popper)) {
894
- return instance;
895
- }
896
- instance.setOptions(options).then(state => {
897
- if (!isDestroyed && options.onFirstUpdate) {
898
- options.onFirstUpdate(state);
899
- }
900
- });
901
- // Modifiers have the ability to execute arbitrary code before the first
902
- // update cycle runs. They will be executed in the same order as the update
903
- // cycle. This is useful when a modifier adds some persistent data that
904
- // other modifiers need to use, but the modifier is run after the dependent
905
- // one.
906
- /**
907
- *
908
- */
909
- function runModifierEffects() {
910
- state.orderedModifiers.forEach(({ name, options = {}, effect }) => {
911
- if (typeof effect === 'function') {
912
- const cleanupFn = effect({ state, name, instance, options });
913
- const noopFn = () => { };
914
- effectCleanupFns.push(cleanupFn || noopFn);
915
- }
916
- });
917
- }
918
- /**
919
- *
920
- */
921
- function cleanupModifierEffects() {
922
- effectCleanupFns.forEach(fn => fn());
923
- effectCleanupFns = [];
924
- }
925
- return instance;
926
- };
927
- }
928
- popperGenerator();
929
-
930
- const passive = { passive: true };
931
- /**
932
- *
933
- */
934
- function effect$2({ state, instance, options }) {
935
- const { scroll = true, resize = true } = options;
936
- const window = getWindow(state.elements.popper);
937
- const scrollParents = [...state.scrollParents.reference, ...state.scrollParents.popper];
938
- if (scroll) {
939
- scrollParents.forEach(scrollParent => {
940
- scrollParent.addEventListener('scroll', instance.update, passive);
941
- });
942
- }
943
- if (resize) {
944
- window.addEventListener('resize', instance.update, passive);
945
- }
946
- return () => {
947
- if (scroll) {
948
- scrollParents.forEach(scrollParent => {
949
- scrollParent.removeEventListener('scroll', instance.update, passive);
950
- });
951
- }
952
- if (resize) {
953
- window.removeEventListener('resize', instance.update, passive);
954
- }
955
- };
956
- }
957
- const eventListeners = {
958
- name: 'eventListeners',
959
- enabled: true,
960
- phase: 'write',
961
- fn: () => { },
962
- effect: effect$2,
963
- data: {}
964
- };
965
-
966
- /**
967
- *
968
- */
969
- function popperOffsets({ state, name }) {
970
- // Offsets are the actual position the popper needs to have to be
971
- // properly positioned near its reference element
972
- // This is the most basic placement, and will be adjusted by
973
- // the modifiers in the next step
974
- state.modifiersData[name] = computeOffsets({
975
- reference: state.rects.reference,
976
- element: state.rects.popper,
977
- placement: state.placement
978
- });
979
- }
980
- const popperOffsets$1 = {
981
- name: 'popperOffsets',
982
- enabled: true,
983
- phase: 'read',
984
- fn: popperOffsets,
985
- data: {}
986
- };
987
-
988
- const unsetSides = {
989
- top: 'auto',
990
- right: 'auto',
991
- bottom: 'auto',
992
- left: 'auto'
993
- };
994
- // Round the offsets to the nearest suitable subpixel based on the DPR.
995
- // Zooming can change the DPR, but it seems to report a value that will
996
- // cleanly divide the values into the appropriate subpixels.
997
- /**
998
- *
999
- */
1000
- function roundOffsets({ x, y }) {
1001
- const win = window;
1002
- const dpr = win.devicePixelRatio || 1;
1003
- return {
1004
- x: Math.round(x * dpr) / dpr || 0,
1005
- y: Math.round(y * dpr) / dpr || 0
1006
- };
1007
- }
1008
- /**
1009
- *
1010
- */
1011
- function mapToStyles({ popper, popperRect, placement, offsets, position, gpuAcceleration, adaptive }) {
1012
- let { x, y } = roundOffsets(offsets);
1013
- const hasX = offsets.hasOwnProperty('x');
1014
- const hasY = offsets.hasOwnProperty('y');
1015
- let sideX = left;
1016
- let sideY = top;
1017
- const win = window;
1018
- if (adaptive) {
1019
- let offsetParent = getOffsetParent(popper);
1020
- if (offsetParent === getWindow(popper)) {
1021
- offsetParent = getDocumentElement(popper);
1022
- }
1023
- // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1024
- /* :: offsetParent = (offsetParent: Element); */
1025
- if (placement === top) {
1026
- sideY = bottom;
1027
- y -= offsetParent.clientHeight - popperRect.height;
1028
- y *= gpuAcceleration ? 1 : -1;
1029
- }
1030
- if (placement === left) {
1031
- sideX = right;
1032
- x -= offsetParent.clientWidth - popperRect.width;
1033
- x *= gpuAcceleration ? 1 : -1;
1034
- }
1035
- }
1036
- const commonStyles = Object.assign({ position }, (adaptive && unsetSides));
1037
- if (gpuAcceleration) {
1038
- return Object.assign(Object.assign({}, commonStyles), { [sideY]: hasY ? '0' : '', [sideX]: hasX ? '0' : '',
1039
- // Layer acceleration can disable subpixel rendering which causes slightly
1040
- // blurry text on low PPI displays, so we want to use 2D transforms
1041
- // instead
1042
- transform: (win.devicePixelRatio || 1) < 2 ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)` });
1043
- }
1044
- return Object.assign(Object.assign({}, commonStyles), { [sideY]: hasY ? `${y}px` : '', [sideX]: hasX ? `${x}px` : '', transform: '' });
1045
- }
1046
- /**
1047
- *
1048
- */
1049
- function computeStyles({ state, options }) {
1050
- const { gpuAcceleration = true, adaptive = true } = options;
1051
- const commonStyles = {
1052
- placement: getBasePlacement(state.placement),
1053
- popper: state.elements.popper,
1054
- popperRect: state.rects.popper,
1055
- gpuAcceleration
1056
- };
1057
- if (state.modifiersData.popperOffsets != null) {
1058
- state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), { offsets: state.modifiersData.popperOffsets, position: state.options.strategy, adaptive })));
1059
- }
1060
- if (state.modifiersData.arrow != null) {
1061
- state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), { offsets: state.modifiersData.arrow, position: 'absolute', adaptive: false })));
1062
- }
1063
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), { 'data-popper-placement': state.placement });
1064
- }
1065
- const computeStyles$1 = {
1066
- name: 'computeStyles',
1067
- enabled: true,
1068
- phase: 'beforeWrite',
1069
- fn: computeStyles,
1070
- data: {}
1071
- };
1072
-
1073
- // This modifier takes the styles prepared by the `computeStyles` modifier
1074
- // and applies them to the HTMLElements such as popper and arrow
1075
- /**
1076
- *
1077
- */
1078
- function applyStyles({ state }) {
1079
- Object.keys(state.elements).forEach(name => {
1080
- const style = state.styles[name] || {};
1081
- const attributes = state.attributes[name] || {};
1082
- const element = state.elements[name];
1083
- // arrow is optional + virtual elements
1084
- if (!isHTMLElement(element) || !getNodeName(element)) {
1085
- return;
1086
- }
1087
- // Flow doesn't support to extend this property, but it's the most
1088
- // effective way to apply styles to an HTMLElement
1089
- // $FlowFixMe
1090
- Object.assign(element.style, style);
1091
- Object.keys(attributes).forEach(name => {
1092
- const value = attributes[name];
1093
- if (value === false) {
1094
- element.removeAttribute(name);
1095
- }
1096
- else {
1097
- element.setAttribute(name, value === true ? '' : value);
1098
- }
1099
- });
1100
- });
1101
- }
1102
- /**
1103
- *
1104
- */
1105
- function effect$1({ state }) {
1106
- const initialStyles = {
1107
- popper: {
1108
- position: state.options.strategy,
1109
- left: '0',
1110
- top: '0',
1111
- margin: '0'
1112
- },
1113
- arrow: {
1114
- position: 'absolute'
1115
- },
1116
- reference: {}
1117
- };
1118
- Object.assign(state.elements.popper.style, initialStyles.popper);
1119
- if (state.elements.arrow) {
1120
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
1121
- }
1122
- return () => {
1123
- Object.keys(state.elements).forEach(name => {
1124
- const element = state.elements[name];
1125
- const attributes = state.attributes[name] || {};
1126
- const styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
1127
- // Set all values to an empty string to unset them
1128
- const style = styleProperties.reduce((style, property) => {
1129
- style[property] = '';
1130
- return style;
1131
- }, {});
1132
- // arrow is optional + virtual elements
1133
- if (!isHTMLElement(element) || !getNodeName(element)) {
1134
- return;
1135
- }
1136
- // Flow doesn't support to extend this property, but it's the most
1137
- // effective way to apply styles to an HTMLElement
1138
- // $FlowFixMe
1139
- Object.assign(element.style, style);
1140
- Object.keys(attributes).forEach(attribute => {
1141
- element.removeAttribute(attribute);
1142
- });
1143
- });
1144
- };
1145
- }
1146
- const applyStyles$1 = {
1147
- name: 'applyStyles',
1148
- enabled: true,
1149
- phase: 'write',
1150
- fn: applyStyles,
1151
- effect: effect$1,
1152
- requires: ['computeStyles']
1153
- };
1154
-
1155
- /**
1156
- * @param placement
1157
- * @param rects
1158
- * @param offset
1159
- */
1160
- function distanceAndSkiddingToXY(placement, rects, offset) {
1161
- const basePlacement = getBasePlacement(placement);
1162
- const invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1163
- let [skidding, distance] = typeof offset === 'function'
1164
- ? offset(Object.assign(Object.assign({}, rects), { placement }))
1165
- : offset;
1166
- skidding = skidding || 0;
1167
- distance = (distance || 0) * invertDistance;
1168
- return [left, right].indexOf(basePlacement) >= 0 ? { x: distance, y: skidding } : { x: skidding, y: distance };
1169
- }
1170
- /**
1171
- *
1172
- */
1173
- function offset({ state, options, name }) {
1174
- const { offset = [0, 0] } = options;
1175
- const data = placements.reduce((acc, placement) => {
1176
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1177
- return acc;
1178
- }, {});
1179
- const { x, y } = data[state.placement];
1180
- if (state.modifiersData.popperOffsets != null) {
1181
- state.modifiersData.popperOffsets.x += x;
1182
- state.modifiersData.popperOffsets.y += y;
1183
- }
1184
- state.modifiersData[name] = data;
1185
- }
1186
- const offset$1 = {
1187
- name: 'offset',
1188
- enabled: true,
1189
- phase: 'main',
1190
- requires: ['popperOffsets'],
1191
- fn: offset
1192
- };
1193
-
1194
- const hash$2 = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
1195
- /**
1196
- * @param placement
1197
- */
1198
- function getOppositePlacement$1(placement) {
1199
- return placement.replace(/left|right|bottom|top/g, matched => hash$2[matched]);
1200
- }
1201
-
1202
- const hash$1 = { start: 'end', end: 'start' };
1203
- /**
1204
- * @param placement
1205
- */
1206
- function getOppositeVariationPlacement(placement) {
1207
- return placement.replace(/start|end/g, matched => hash$1[matched]);
1208
- }
1209
-
1210
- /* :: type OverflowsMap = { [ComputedPlacement]: number }; */
1211
- /* ;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
1212
- /**
1213
- * @param state
1214
- * @param options
1215
- */
1216
- function computeAutoPlacement(state, options = {}) {
1217
- const { placement, boundary, rootBoundary, padding, flipVariations, allowedAutoPlacements = placements } = options;
1218
- const variation = getVariation(placement);
1219
- const placements$1 = variation
1220
- ? flipVariations
1221
- ? variationPlacements
1222
- : variationPlacements.filter(placement => getVariation(placement) === variation)
1223
- : basePlacements;
1224
- // $FlowFixMe
1225
- let allowedPlacements = placements$1.filter(placement => allowedAutoPlacements.indexOf(placement) >= 0);
1226
- if (allowedPlacements.length === 0) {
1227
- allowedPlacements = placements$1;
1228
- }
1229
- // $FlowFixMe: Flow seems to have problems with two array unions...
1230
- const overflows = allowedPlacements.reduce((acc, placement) => {
1231
- acc[placement] = detectOverflow(state, {
1232
- placement,
1233
- boundary,
1234
- rootBoundary,
1235
- padding
1236
- })[getBasePlacement(placement)];
1237
- return acc;
1238
- }, {});
1239
- return Object.keys(overflows).sort((a, b) => overflows[a] - overflows[b]);
1240
- }
1241
-
1242
- /**
1243
- * @param placement
1244
- */
1245
- function getExpandedFallbackPlacements(placement) {
1246
- if (getBasePlacement(placement) === auto) {
1247
- return [];
1248
- }
1249
- const oppositePlacement = getOppositePlacement$1(placement);
1250
- return [
1251
- getOppositeVariationPlacement(placement),
1252
- oppositePlacement,
1253
- getOppositeVariationPlacement(oppositePlacement)
1254
- ];
1255
- }
1256
- /**
1257
- *
1258
- */
1259
- function flip({ state, options, name }) {
1260
- if (state.modifiersData[name]._skip) {
1261
- return;
1262
- }
1263
- const { mainAxis: checkMainAxis = true, altAxis: checkAltAxis = true, fallbackPlacements: specifiedFallbackPlacements, padding, boundary, rootBoundary, altBoundary, flipVariations = true, allowedAutoPlacements } = options;
1264
- const preferredPlacement = state.options.placement;
1265
- const basePlacement = getBasePlacement(preferredPlacement);
1266
- const isBasePlacement = basePlacement === preferredPlacement;
1267
- const fallbackPlacements = specifiedFallbackPlacements ||
1268
- (isBasePlacement || !flipVariations
1269
- ? [getOppositePlacement$1(preferredPlacement)]
1270
- : getExpandedFallbackPlacements(preferredPlacement));
1271
- const placements = [preferredPlacement, ...fallbackPlacements].reduce((acc, placement) => acc.concat(getBasePlacement(placement) === auto
1272
- ? computeAutoPlacement(state, {
1273
- placement,
1274
- boundary,
1275
- rootBoundary,
1276
- padding,
1277
- flipVariations,
1278
- allowedAutoPlacements
1279
- })
1280
- : placement), []);
1281
- const referenceRect = state.rects.reference;
1282
- const popperRect = state.rects.popper;
1283
- const checksMap = new Map();
1284
- let makeFallbackChecks = true;
1285
- let firstFittingPlacement = placements[0];
1286
- for (let i = 0; i < placements.length; i++) {
1287
- const placement = placements[i];
1288
- const basePlacement = getBasePlacement(placement);
1289
- const isStartVariation = getVariation(placement) === start;
1290
- const isVertical = [top, bottom].indexOf(basePlacement) >= 0;
1291
- const len = isVertical ? 'width' : 'height';
1292
- const overflow = detectOverflow(state, {
1293
- placement,
1294
- boundary,
1295
- rootBoundary,
1296
- altBoundary,
1297
- padding
1298
- });
1299
- let mainVariationSide = isVertical ? (isStartVariation ? right : left) : isStartVariation ? bottom : top;
1300
- if (referenceRect[len] > popperRect[len]) {
1301
- mainVariationSide = getOppositePlacement$1(mainVariationSide);
1302
- }
1303
- const altVariationSide = getOppositePlacement$1(mainVariationSide);
1304
- const checks = [];
1305
- if (checkMainAxis) {
1306
- checks.push(overflow[basePlacement] <= 0);
1307
- }
1308
- if (checkAltAxis) {
1309
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1310
- }
1311
- if (checks.every(check => check)) {
1312
- firstFittingPlacement = placement;
1313
- makeFallbackChecks = false;
1314
- break;
1315
- }
1316
- checksMap.set(placement, checks);
1317
- }
1318
- if (makeFallbackChecks) {
1319
- // `2` may be desired in some cases – research later
1320
- const numberOfChecks = flipVariations ? 3 : 1;
1321
- for (let i = numberOfChecks; i > 0; i--) {
1322
- const fittingPlacement = placements.find(placement => {
1323
- const checks = checksMap.get(placement);
1324
- if (checks) {
1325
- return checks.slice(0, i).every(check => check);
1326
- }
1327
- });
1328
- if (fittingPlacement) {
1329
- firstFittingPlacement = fittingPlacement;
1330
- break;
1331
- }
1332
- }
1333
- }
1334
- if (state.placement !== firstFittingPlacement) {
1335
- state.modifiersData[name]._skip = true;
1336
- state.placement = firstFittingPlacement;
1337
- state.reset = true;
1338
- }
1339
- }
1340
- const flip$1 = {
1341
- name: 'flip',
1342
- enabled: true,
1343
- phase: 'main',
1344
- fn: flip,
1345
- requiresIfExists: ['offset'],
1346
- data: { _skip: false }
1347
- };
1348
-
1349
- // @ts-nocheck
1350
- /**
1351
- * @param axis
1352
- */
1353
- function getAltAxis(axis) {
1354
- return axis === 'x' ? 'y' : 'x';
1355
- }
1356
-
1357
- // @ts-nocheck
1358
- /**
1359
- * @param min
1360
- * @param value
1361
- * @param max
1362
- */
1363
- function within(min, value, max) {
1364
- return Math.max(min, Math.min(value, max));
1365
- }
1366
-
1367
- // @ts-nocheck
1368
- /**
1369
- *
1370
- */
1371
- function preventOverflow({ state, options, name }) {
1372
- const { mainAxis: checkMainAxis = true, altAxis: checkAltAxis = false, boundary, rootBoundary, altBoundary, padding, tether = true, tetherOffset = 0 } = options;
1373
- const overflow = detectOverflow(state, {
1374
- boundary,
1375
- rootBoundary,
1376
- padding,
1377
- altBoundary
1378
- });
1379
- const basePlacement = getBasePlacement(state.placement);
1380
- const variation = getVariation(state.placement);
1381
- const isBasePlacement = !variation;
1382
- const mainAxis = getMainAxisFromPlacement(basePlacement);
1383
- const altAxis = getAltAxis(mainAxis);
1384
- const popperOffsets = state.modifiersData.popperOffsets;
1385
- const referenceRect = state.rects.reference;
1386
- const popperRect = state.rects.popper;
1387
- const tetherOffsetValue = typeof tetherOffset === 'function'
1388
- ? tetherOffset(Object.assign(Object.assign({}, state.rects), { placement: state.placement }))
1389
- : tetherOffset;
1390
- const data = { x: 0, y: 0 };
1391
- if (!popperOffsets) {
1392
- return;
1393
- }
1394
- if (checkMainAxis) {
1395
- const mainSide = mainAxis === 'y' ? top : left;
1396
- const altSide = mainAxis === 'y' ? bottom : right;
1397
- const len = mainAxis === 'y' ? 'height' : 'width';
1398
- const offset = popperOffsets[mainAxis];
1399
- const min = popperOffsets[mainAxis] + overflow[mainSide];
1400
- const max = popperOffsets[mainAxis] - overflow[altSide];
1401
- const additive = tether ? -popperRect[len] / 2 : 0;
1402
- const minLen = variation === start ? referenceRect[len] : popperRect[len];
1403
- const maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
1404
- // We need to include the arrow in the calculation so the arrow doesn't go
1405
- // outside the reference bounds
1406
- const arrowElement = state.elements.arrow;
1407
- const arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : { width: 0, height: 0 };
1408
- const arrowPaddingObject = state.modifiersData['arrow#persistent']
1409
- ? state.modifiersData['arrow#persistent'].padding
1410
- : getFreshSideObject();
1411
- const arrowPaddingMin = arrowPaddingObject[mainSide];
1412
- const arrowPaddingMax = arrowPaddingObject[altSide];
1413
- // If the reference length is smaller than the arrow length, we don't want
1414
- // to include its full size in the calculation. If the reference is small
1415
- // and near the edge of a boundary, the popper can overflow even if the
1416
- // reference is not overflowing as well (e.g. virtual elements with no
1417
- // width or height)
1418
- const arrowLen = within(0, referenceRect[len], arrowRect[len]);
1419
- const minOffset = isBasePlacement
1420
- ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue
1421
- : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1422
- const maxOffset = isBasePlacement
1423
- ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue
1424
- : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1425
- const arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1426
- const clientOffset = arrowOffsetParent
1427
- ? mainAxis === 'y'
1428
- ? arrowOffsetParent.clientTop || 0
1429
- : arrowOffsetParent.clientLeft || 0
1430
- : 0;
1431
- const offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1432
- const tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1433
- const tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1434
- const preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
1435
- popperOffsets[mainAxis] = preventedOffset;
1436
- data[mainAxis] = preventedOffset - offset;
1437
- }
1438
- if (checkAltAxis) {
1439
- const mainSide = mainAxis === 'x' ? top : left;
1440
- const altSide = mainAxis === 'x' ? bottom : right;
1441
- const offset = popperOffsets[altAxis];
1442
- const min = offset + overflow[mainSide];
1443
- const max = offset - overflow[altSide];
1444
- const preventedOffset = within(min, offset, max);
1445
- popperOffsets[altAxis] = preventedOffset;
1446
- data[altAxis] = preventedOffset - offset;
1447
- }
1448
- state.modifiersData[name] = data;
1449
- }
1450
- const preventOverflow$1 = {
1451
- name: 'preventOverflow',
1452
- enabled: true,
1453
- phase: 'main',
1454
- fn: preventOverflow,
1455
- requiresIfExists: ['offset']
1456
- };
1457
-
1458
- /**
1459
- *
1460
- */
1461
- function arrow({ state, name }) {
1462
- const arrowElement = state.elements.arrow;
1463
- const popperOffsets = state.modifiersData.popperOffsets;
1464
- const basePlacement = getBasePlacement(state.placement);
1465
- const axis = getMainAxisFromPlacement(basePlacement);
1466
- const isVertical = [left, right].indexOf(basePlacement) >= 0;
1467
- const len = isVertical ? 'height' : 'width';
1468
- if (!arrowElement || !popperOffsets) {
1469
- return;
1470
- }
1471
- const paddingObject = state.modifiersData[`${name}#persistent`].padding;
1472
- const arrowRect = getLayoutRect(arrowElement);
1473
- const minProp = axis === 'y' ? top : left;
1474
- const maxProp = axis === 'y' ? bottom : right;
1475
- const endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1476
- const startDiff = popperOffsets[axis] - state.rects.reference[axis];
1477
- const arrowOffsetParent = getOffsetParent(arrowElement);
1478
- const clientSize = arrowOffsetParent
1479
- ? axis === 'y'
1480
- ? arrowOffsetParent.clientHeight || 0
1481
- : arrowOffsetParent.clientWidth || 0
1482
- : 0;
1483
- const centerToReference = endDiff / 2 - startDiff / 2;
1484
- // Make sure the arrow doesn't overflow the popper if the center point is
1485
- // outside of the popper bounds
1486
- const min = paddingObject[minProp];
1487
- const max = clientSize - arrowRect[len] - paddingObject[maxProp];
1488
- const center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1489
- const offset = within(min, center, max);
1490
- // Prevents breaking syntax highlighting...
1491
- const axisProp = axis;
1492
- state.modifiersData[name] = {
1493
- [axisProp]: offset,
1494
- centerOffset: offset - center
1495
- };
1496
- }
1497
- /**
1498
- *
1499
- */
1500
- function effect({ state, options, name }) {
1501
- let { element: arrowElement = '[data-popper-arrow]', padding = 0 } = options;
1502
- if (arrowElement == null) {
1503
- return;
1504
- }
1505
- // CSS selector
1506
- if (typeof arrowElement === 'string') {
1507
- arrowElement = state.elements.popper.querySelector(arrowElement);
1508
- if (!arrowElement) {
1509
- return;
1510
- }
1511
- }
1512
- if (!contains(state.elements.popper, arrowElement)) {
1513
- return;
1514
- }
1515
- state.elements.arrow = arrowElement;
1516
- state.modifiersData[`${name}#persistent`] = {
1517
- padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
1518
- };
1519
- }
1520
- const arrow$1 = {
1521
- name: 'arrow',
1522
- enabled: true,
1523
- phase: 'main',
1524
- fn: arrow,
1525
- effect,
1526
- requires: ['popperOffsets'],
1527
- requiresIfExists: ['preventOverflow']
1528
- };
1529
-
1530
- /**
1531
- * @param overflow
1532
- * @param rect
1533
- * @param preventedOffsets
1534
- */
1535
- function getSideOffsets(overflow, rect, preventedOffsets = { x: 0, y: 0 }) {
1536
- return {
1537
- top: overflow.top - rect.height - preventedOffsets.y,
1538
- right: overflow.right - rect.width + preventedOffsets.x,
1539
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1540
- left: overflow.left - rect.width - preventedOffsets.x
1541
- };
1542
- }
1543
- /**
1544
- * @param overflow
1545
- */
1546
- function isAnySideFullyClipped(overflow) {
1547
- return [top, right, bottom, left].some(side => overflow[side] >= 0);
1548
- }
1549
- /**
1550
- *
1551
- */
1552
- function hide({ state, name }) {
1553
- const referenceRect = state.rects.reference;
1554
- const popperRect = state.rects.popper;
1555
- const preventedOffsets = state.modifiersData.preventOverflow;
1556
- const referenceOverflow = detectOverflow(state, {
1557
- elementContext: 'reference'
1558
- });
1559
- const popperAltOverflow = detectOverflow(state, {
1560
- altBoundary: true
1561
- });
1562
- const referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1563
- const popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1564
- const isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1565
- const hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1566
- state.modifiersData[name] = {
1567
- referenceClippingOffsets,
1568
- popperEscapeOffsets,
1569
- isReferenceHidden,
1570
- hasPopperEscaped
1571
- };
1572
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), { 'data-popper-reference-hidden': isReferenceHidden, 'data-popper-escaped': hasPopperEscaped });
1573
- }
1574
- const hide$1 = {
1575
- name: 'hide',
1576
- enabled: true,
1577
- phase: 'main',
1578
- requiresIfExists: ['preventOverflow'],
1579
- fn: hide
1580
- };
1581
-
1582
- // @ts-nocheck
1583
- const defaultModifiers = [
1584
- eventListeners,
1585
- popperOffsets$1,
1586
- computeStyles$1,
1587
- applyStyles$1,
1588
- offset$1,
1589
- flip$1,
1590
- preventOverflow$1,
1591
- arrow$1,
1592
- hide$1
1593
- ];
1594
- const createPopper = popperGenerator({ defaultModifiers });
1595
-
1596
- /**
1597
- * Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
1598
- */
1599
- const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
1600
-
1601
- /* eslint-disable @typescript-eslint/consistent-type-definitions */
1602
- const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
1603
- /**
1604
- * Simple ponyfill for Object.fromEntries
1605
- */
1606
- const fromEntries = (entries) => entries.reduce((acc, [key, value]) => {
1607
- acc[key] = value;
1608
- return acc;
1609
- }, {});
1610
- const EMPTY_MODIFIERS = [];
1611
- const usePopper = (referenceElement, popperElement, options = {}) => {
1612
- const prevOptions = useRef(null);
1613
- const optionsWithDefaults = {
1614
- onFirstUpdate: options.onFirstUpdate,
1615
- placement: options.placement || 'bottom',
1616
- strategy: options.strategy || 'absolute',
1617
- modifiers: options.modifiers || EMPTY_MODIFIERS
1618
- };
1619
- const [state, setState] = useState({
1620
- styles: {
1621
- popper: {
1622
- position: optionsWithDefaults.strategy,
1623
- left: '0',
1624
- top: '0'
1625
- }
1626
- },
1627
- attributes: {}
1628
- });
1629
- const updateStateModifier = useMemo(() => ({
1630
- name: 'updateState',
1631
- enabled: true,
1632
- phase: 'write',
1633
- // eslint-disable-next-line no-shadow
1634
- fn: ({ state }) => {
1635
- const elements = Object.keys(state.elements);
1636
- setState({
1637
- styles: fromEntries(elements.map(element => [element, state.styles[element] || {}])),
1638
- attributes: fromEntries(elements.map(element => [element, state.attributes[element]]))
1639
- });
1640
- },
1641
- requires: ['computeStyles']
1642
- }), []);
1643
- const popperOptions = useMemo(() => {
1644
- const newOptions = {
1645
- onFirstUpdate: optionsWithDefaults.onFirstUpdate,
1646
- placement: optionsWithDefaults.placement,
1647
- strategy: optionsWithDefaults.strategy,
1648
- modifiers: [...optionsWithDefaults.modifiers, updateStateModifier, { name: 'applyStyles', enabled: false }]
1649
- };
1650
- if (isEqual(prevOptions.current, newOptions)) {
1651
- return prevOptions.current || newOptions;
1652
- }
1653
- else {
1654
- prevOptions.current = newOptions;
1655
- return newOptions;
1656
- }
1657
- }, [
1658
- optionsWithDefaults.onFirstUpdate,
1659
- optionsWithDefaults.placement,
1660
- optionsWithDefaults.strategy,
1661
- optionsWithDefaults.modifiers,
1662
- updateStateModifier
1663
- ]);
1664
- const popperInstanceRef = useRef(undefined);
1665
- useIsomorphicLayoutEffect(() => {
1666
- if (popperInstanceRef && popperInstanceRef.current) {
1667
- popperInstanceRef.current.setOptions(popperOptions);
1668
- }
1669
- }, [popperOptions]);
1670
- useIsomorphicLayoutEffect(() => {
1671
- if (referenceElement == null || popperElement == null) {
1672
- return;
1673
- }
1674
- const createPopper$1 = options.createPopper || createPopper;
1675
- const popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
1676
- popperInstanceRef.current = popperInstance;
1677
- return () => {
1678
- popperInstance.destroy();
1679
- popperInstanceRef.current = null;
1680
- };
1681
- }, [referenceElement, popperElement, options.createPopper]);
1682
- return {
1683
- state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
1684
- styles: state.styles,
1685
- attributes: state.attributes,
1686
- update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
1687
- forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
1688
- };
1689
- };
1690
-
1691
- const hash = {
1692
- left: 'right',
1693
- right: 'left',
1694
- bottom: 'top',
1695
- top: 'bottom',
1696
- 'top-start': 'bottom-end',
1697
- 'top-end': 'bottom-start',
1698
- 'bottom-start': 'top-end',
1699
- 'bottom-end': 'top-start',
1700
- 'left-start': 'right-end',
1701
- 'left-end': 'right-start',
1702
- 'right-start': 'left-end',
1703
- 'right-end': 'left-start'
1704
- };
1705
- const getOppositePlacement = (placement) => placement.replace(/left|right|bottom|top|top-start|top-end|bottom-start|bottom-end|right-start|right-end|left-start|left-end/g, (matched) => hash[matched]);
1706
- const getOpacityTransition = (animationDuration) => `opacity ${animationDuration}ms cubic-bezier(.54, 1.5, .38, 1.11)`;
1707
- const Popper = ({ trigger, popper, direction = 'down', position = 'start', placement, width, minWidth = 'trigger', maxWidth, appendTo = () => document.body, zIndex = 9999, isVisible = true, positionModifiers, distance = 0, onMouseEnter, onMouseLeave, onFocus, onBlur, onDocumentClick, onTriggerClick, onTriggerEnter, onPopperClick, onPopperMouseEnter, onPopperMouseLeave, onDocumentKeyDown, enableFlip = true, flipBehavior = 'flip', triggerRef, popperRef, animationDuration = 0, entryDelay = 0, exitDelay = 0, onHidden = () => { }, onHide = () => { }, onMount = () => { }, onShow = () => { }, onShown = () => { }, preventOverflow = false }) => {
1708
- var _a;
1709
- const [triggerElement, setTriggerElement] = useState(null);
1710
- const [refElement, setRefElement] = useState(null);
1711
- const [popperElement, setPopperElement] = useState(null);
1712
- const [popperContent, setPopperContent] = useState(null);
1713
- const [ready, setReady] = useState(false);
1714
- const [opacity, setOpacity] = useState(0);
1715
- const [internalIsVisible, setInternalIsVisible] = useState(isVisible);
1716
- const transitionTimerRef = useRef(null);
1717
- const showTimerRef = useRef(null);
1718
- const hideTimerRef = useRef(null);
1719
- const prevExitDelayRef = useRef(undefined);
1720
- const refOrTrigger = refElement || triggerElement;
1721
- const showPopper = isVisible || internalIsVisible;
1722
- const triggerParent = (_a = ((triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || triggerElement)) === null || _a === void 0 ? void 0 : _a.parentElement;
1723
- const languageDirection = getLanguageDirection(triggerParent);
1724
- const internalPosition = useMemo(() => {
1725
- const fixedPositions = { left: 'left', right: 'right', center: 'center' };
1726
- const positionMap = {
1727
- ltr: Object.assign({ start: 'left', end: 'right' }, fixedPositions),
1728
- rtl: Object.assign({ start: 'right', end: 'left' }, fixedPositions)
1729
- };
1730
- return positionMap[languageDirection][position];
1731
- }, [position, languageDirection]);
1732
- const onDocumentClickCallback = useCallback((event) => onDocumentClick(event, refOrTrigger, popperElement), [showPopper, triggerElement, refElement, popperElement, onDocumentClick]);
1733
- useEffect(() => {
1734
- setReady(true);
1735
- onMount();
1736
- }, []);
1737
- // Cancel all timers on unmount
1738
- useEffect(() => () => {
1739
- clearTimeouts([transitionTimerRef, hideTimerRef, showTimerRef]);
1740
- }, []);
1741
- useEffect(() => {
1742
- if (triggerRef) {
1743
- if (triggerRef.current) {
1744
- setRefElement(triggerRef.current);
1745
- }
1746
- else if (typeof triggerRef === 'function') {
1747
- setRefElement(triggerRef());
1748
- }
1749
- }
1750
- }, [triggerRef, trigger]);
1751
- useEffect(() => {
1752
- // When the popperRef is defined or the popper visibility changes, ensure the popper element is up to date
1753
- if (popperRef) {
1754
- if (popperRef.current) {
1755
- setPopperElement(popperRef.current);
1756
- }
1757
- else if (typeof popperRef === 'function') {
1758
- setPopperElement(popperRef());
1759
- }
1760
- }
1761
- }, [showPopper, popperRef]);
1762
- useEffect(() => {
1763
- // Trigger a Popper update when content changes.
1764
- const observer = new MutationObserver(() => {
1765
- update && update();
1766
- });
1767
- popperElement && observer.observe(popperElement, { attributes: true, childList: true, subtree: true });
1768
- return () => {
1769
- observer.disconnect();
1770
- };
1771
- }, [popperElement]);
1772
- const addEventListener = (listener, element, event, capture = false) => {
1773
- if (listener && element) {
1774
- element.addEventListener(event, listener, { capture });
1775
- }
1776
- };
1777
- const removeEventListener = (listener, element, event, capture = false) => {
1778
- if (listener && element) {
1779
- element.removeEventListener(event, listener, { capture });
1780
- }
1781
- };
1782
- useEffect(() => {
1783
- addEventListener(onMouseEnter, refOrTrigger, 'mouseenter');
1784
- addEventListener(onMouseLeave, refOrTrigger, 'mouseleave');
1785
- addEventListener(onFocus, refOrTrigger, 'focus');
1786
- addEventListener(onBlur, refOrTrigger, 'blur');
1787
- addEventListener(onTriggerClick, refOrTrigger, 'click');
1788
- addEventListener(onTriggerEnter, refOrTrigger, 'keydown');
1789
- addEventListener(onPopperClick, popperElement, 'click');
1790
- addEventListener(onPopperMouseEnter, popperElement, 'mouseenter');
1791
- addEventListener(onPopperMouseLeave, popperElement, 'mouseleave');
1792
- onDocumentClick && addEventListener(onDocumentClickCallback, document, 'click', true);
1793
- addEventListener(onDocumentKeyDown, document, 'keydown', true);
1794
- return () => {
1795
- removeEventListener(onMouseEnter, refOrTrigger, 'mouseenter');
1796
- removeEventListener(onMouseLeave, refOrTrigger, 'mouseleave');
1797
- removeEventListener(onFocus, refOrTrigger, 'focus');
1798
- removeEventListener(onBlur, refOrTrigger, 'blur');
1799
- removeEventListener(onTriggerClick, refOrTrigger, 'click');
1800
- removeEventListener(onTriggerEnter, refOrTrigger, 'keydown');
1801
- removeEventListener(onPopperClick, popperElement, 'click');
1802
- removeEventListener(onPopperMouseEnter, popperElement, 'mouseenter');
1803
- removeEventListener(onPopperMouseLeave, popperElement, 'mouseleave');
1804
- onDocumentClick && removeEventListener(onDocumentClickCallback, document, 'click', true);
1805
- removeEventListener(onDocumentKeyDown, document, 'keydown', true);
1806
- };
1807
- }, [
1808
- triggerElement,
1809
- popperElement,
1810
- onMouseEnter,
1811
- onMouseLeave,
1812
- onFocus,
1813
- onBlur,
1814
- onTriggerClick,
1815
- onTriggerEnter,
1816
- onPopperClick,
1817
- onPopperMouseEnter,
1818
- onPopperMouseLeave,
1819
- onDocumentClick,
1820
- onDocumentKeyDown,
1821
- refElement
1822
- ]);
1823
- const getPlacement = () => {
1824
- if (placement) {
1825
- return placement;
1826
- }
1827
- let convertedPlacement = direction === 'up' ? 'top' : 'bottom';
1828
- if (internalPosition !== 'center') {
1829
- convertedPlacement = `${convertedPlacement}-${internalPosition === 'right' ? 'end' : 'start'}`;
1830
- }
1831
- return convertedPlacement;
1832
- };
1833
- const getPlacementMemo = useMemo(getPlacement, [direction, internalPosition, placement]);
1834
- const getOppositePlacementMemo = useMemo(() => getOppositePlacement(getPlacement()), [direction, internalPosition, placement]);
1835
- const widthMods = useMemo(() => ({
1836
- name: 'widthMods',
1837
- enabled: width !== undefined || minWidth !== undefined || maxWidth !== undefined,
1838
- phase: 'beforeWrite',
1839
- requires: ['computeStyles'],
1840
- fn: ({ state }) => {
1841
- const triggerWidth = state.rects.reference.width;
1842
- if (width) {
1843
- state.styles.popper.width = width === 'trigger' ? `${triggerWidth}px` : width;
1844
- }
1845
- if (minWidth) {
1846
- state.styles.popper.minWidth = minWidth === 'trigger' ? `${triggerWidth}px` : minWidth;
1847
- }
1848
- if (maxWidth) {
1849
- state.styles.popper.maxWidth = maxWidth === 'trigger' ? `${triggerWidth}px` : maxWidth;
1850
- }
1851
- },
1852
- effect: ({ state }) => {
1853
- const triggerWidth = state.elements.reference.offsetWidth;
1854
- if (width) {
1855
- state.elements.popper.style.width = width === 'trigger' ? `${triggerWidth}px` : width;
1856
- }
1857
- if (minWidth) {
1858
- state.elements.popper.style.minWidth = minWidth === 'trigger' ? `${triggerWidth}px` : minWidth;
1859
- }
1860
- if (maxWidth) {
1861
- state.elements.popper.style.maxWidth = maxWidth === 'trigger' ? `${triggerWidth}px` : maxWidth;
1862
- }
1863
- return () => { };
1864
- }
1865
- }), [width, minWidth, maxWidth]);
1866
- const { styles: popperStyles, attributes, update, forceUpdate } = usePopper(refOrTrigger, popperElement, {
1867
- placement: getPlacementMemo,
1868
- modifiers: [
1869
- {
1870
- name: 'offset',
1871
- options: {
1872
- offset: [0, distance]
1873
- }
1874
- },
1875
- {
1876
- name: 'preventOverflow',
1877
- enabled: preventOverflow
1878
- },
1879
- {
1880
- // adds attribute [data-popper-reference-hidden] to the popper element which can be used to hide it using CSS
1881
- name: 'hide',
1882
- enabled: true
1883
- },
1884
- {
1885
- name: 'flip',
1886
- enabled: getPlacementMemo.startsWith('auto') || enableFlip,
1887
- options: {
1888
- fallbackPlacements: flipBehavior === 'flip' ? [getOppositePlacementMemo] : flipBehavior
1889
- }
1890
- },
1891
- widthMods
1892
- ]
1893
- });
1894
- /** We want to forceUpdate only when a tooltip's content is dynamically updated.
1895
- * TODO: Investigate into 3rd party libraries for a less limited/specific solution
1896
- */
1897
- useEffect(() => {
1898
- var _a, _b, _c, _d, _e, _f, _g;
1899
- // currentPopperContent = {tooltip children} || {dropdown children}
1900
- const currentPopperContent = ((_d = (_c = (_b = (_a = popper === null || popper === void 0 ? void 0 : popper.props) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.children) || ((_g = (_f = (_e = popper === null || popper === void 0 ? void 0 : popper.props) === null || _e === void 0 ? void 0 : _e.children) === null || _f === void 0 ? void 0 : _f.props) === null || _g === void 0 ? void 0 : _g.children);
1901
- setPopperContent(currentPopperContent);
1902
- if (currentPopperContent && popperContent && currentPopperContent !== popperContent) {
1903
- forceUpdate && forceUpdate();
1904
- }
1905
- }, [popper]);
1906
- useEffect(() => {
1907
- if (prevExitDelayRef.current < exitDelay) {
1908
- clearTimeouts([transitionTimerRef, hideTimerRef]);
1909
- hideTimerRef.current = setTimeout(() => {
1910
- transitionTimerRef.current = setTimeout(() => {
1911
- setInternalIsVisible(false);
1912
- }, animationDuration);
1913
- }, exitDelay);
1914
- }
1915
- prevExitDelayRef.current = exitDelay;
1916
- }, [exitDelay]);
1917
- const show = () => {
1918
- onShow();
1919
- clearTimeouts([transitionTimerRef, hideTimerRef]);
1920
- showTimerRef.current = setTimeout(() => {
1921
- setInternalIsVisible(true);
1922
- setOpacity(1);
1923
- onShown();
1924
- }, entryDelay);
1925
- };
1926
- const hide = () => {
1927
- onHide();
1928
- clearTimeouts([showTimerRef]);
1929
- hideTimerRef.current = setTimeout(() => {
1930
- setOpacity(0);
1931
- transitionTimerRef.current = setTimeout(() => {
1932
- setInternalIsVisible(false);
1933
- onHidden();
1934
- }, animationDuration);
1935
- }, exitDelay);
1936
- };
1937
- useEffect(() => {
1938
- if (isVisible) {
1939
- show();
1940
- }
1941
- else {
1942
- hide();
1943
- }
1944
- }, [isVisible]);
1945
- // Returns the CSS modifier class in order to place the Popper's arrow properly
1946
- // Depends on the position of the Popper relative to the reference element
1947
- const modifierFromPopperPosition = () => {
1948
- if (attributes && attributes.popper && attributes.popper['data-popper-placement']) {
1949
- const popperPlacement = attributes.popper['data-popper-placement'];
1950
- return positionModifiers[popperPlacement];
1951
- }
1952
- return positionModifiers.top;
1953
- };
1954
- const options = Object.assign({ className: css(popper.props && popper.props.className, positionModifiers && modifierFromPopperPosition()), style: Object.assign(Object.assign(Object.assign({}, ((popper.props && popper.props.style) || {})), popperStyles.popper), { zIndex,
1955
- opacity, transition: getOpacityTransition(animationDuration) }) }, attributes.popper);
1956
- const getMenuWithPopper = () => {
1957
- const localPopper = cloneElement(popper, options);
1958
- return popperRef ? (localPopper) : (jsx("div", { style: { display: 'contents' }, ref: (node) => {
1959
- setPopperElement(node === null || node === void 0 ? void 0 : node.firstElementChild);
1960
- }, children: localPopper }));
1961
- };
1962
- const getPopper = () => {
1963
- if (appendTo === 'inline') {
1964
- return getMenuWithPopper();
1965
- }
1966
- else {
1967
- const target = typeof appendTo === 'function' ? appendTo() : appendTo;
1968
- return ReactDOM.createPortal(getMenuWithPopper(), target);
1969
- }
1970
- };
1971
- return (jsxs(Fragment, { children: [!triggerRef && trigger && isValidElement(trigger) && (jsx("div", { style: { display: 'contents' }, ref: (node) => {
1972
- setTriggerElement(node === null || node === void 0 ? void 0 : node.firstElementChild);
1973
- }, children: trigger })), triggerRef && trigger && isValidElement(trigger) && trigger, ready && showPopper && getPopper()] }));
1974
- };
1975
- Popper.displayName = 'Popper';
1976
-
1977
- /**
1978
- * This function is a helper for handling basic arrow keyboard interactions. If a component already has its own key handler and event start up/tear down, this function may be easier to integrate in over the full component.
1979
- *
1980
- * @param {event} event Event triggered by the keyboard
1981
- * @param {element[]} navigableElements Valid traversable elements of the container
1982
- * @param {function} isActiveElement Callback to determine if a given element from the navigable elements array is the active element of the page
1983
- * @param {function} getFocusableElement Callback returning the focusable element of a given element from the navigable elements array
1984
- * @param {string[]} validSiblingTags Valid sibling tags that horizontal arrow handling will focus
1985
- * @param {boolean} noVerticalArrowHandling Flag indicating that the included vertical arrow key handling should be ignored
1986
- * @param {boolean} noHorizontalArrowHandling Flag indicating that the included horizontal arrow key handling should be ignored
1987
- * @param {boolean} updateTabIndex Flag indicating that the tabIndex of the currently focused element and next focused element should be updated, in the case of using a roving tabIndex
1988
- * @param {boolean} onlyTraverseSiblings Flag indicating that next focusable element of a horizontal movement will be this element's sibling
1989
- */
1990
- const handleArrows = (event, navigableElements, isActiveElement = (element) => document.activeElement.contains(element), getFocusableElement = (element) => element, validSiblingTags = ['A', 'BUTTON', 'INPUT'], noVerticalArrowHandling = false, noHorizontalArrowHandling = false, updateTabIndex = true, onlyTraverseSiblings = true) => {
1991
- const activeElement = document.activeElement;
1992
- const key = event.key;
1993
- let moveTarget = null;
1994
- // Handle vertical arrow keys. If noVerticalArrowHandling is passed, skip this block
1995
- if (!noVerticalArrowHandling) {
1996
- if (['ArrowUp', 'ArrowDown'].includes(key)) {
1997
- event.preventDefault();
1998
- event.stopImmediatePropagation(); // For menus in menus
1999
- // Traverse navigableElements to find the element which is currently active
2000
- let currentIndex = -1;
2001
- // while (currentIndex === -1) {
2002
- navigableElements.forEach((element, index) => {
2003
- if (isActiveElement(element)) {
2004
- // Once found, move up or down the array by 1. Determined by the vertical arrow key direction
2005
- let increment = 0;
2006
- // keep increasing the increment until you've tried the whole navigableElement
2007
- while (!moveTarget && increment < navigableElements.length && increment * -1 < navigableElements.length) {
2008
- key === 'ArrowUp' ? increment-- : increment++;
2009
- currentIndex = index + increment;
2010
- if (currentIndex >= navigableElements.length) {
2011
- currentIndex = 0;
2012
- }
2013
- if (currentIndex < 0) {
2014
- currentIndex = navigableElements.length - 1;
2015
- }
2016
- // Set the next target element (undefined if none found)
2017
- moveTarget = getFocusableElement(navigableElements[currentIndex]);
2018
- }
2019
- }
2020
- });
2021
- // }
2022
- }
2023
- }
2024
- // Handle horizontal arrow keys. If noHorizontalArrowHandling is passed, skip this block
2025
- if (!noHorizontalArrowHandling) {
2026
- if (['ArrowLeft', 'ArrowRight'].includes(key)) {
2027
- event.preventDefault();
2028
- event.stopImmediatePropagation(); // For menus in menus
2029
- let currentIndex = -1;
2030
- navigableElements.forEach((element, index) => {
2031
- if (isActiveElement(element)) {
2032
- const activeRow = navigableElements[index].querySelectorAll(validSiblingTags.join(',')); // all focusable elements in my row
2033
- if (!activeRow.length || onlyTraverseSiblings) {
2034
- let nextSibling = activeElement;
2035
- while (nextSibling) {
2036
- const isDirectChildOfNavigableElement = nextSibling.parentElement === element;
2037
- const nextSiblingMainElement = isDirectChildOfNavigableElement ? nextSibling : nextSibling.parentElement;
2038
- nextSibling =
2039
- key === 'ArrowLeft'
2040
- ? nextSiblingMainElement.previousElementSibling
2041
- : nextSiblingMainElement.nextElementSibling;
2042
- if (nextSibling) {
2043
- if (validSiblingTags.includes(nextSibling.tagName)) {
2044
- moveTarget = nextSibling;
2045
- break;
2046
- }
2047
- // For cases where the validSiblingTag is inside a div wrapper
2048
- if (validSiblingTags.includes(nextSibling.children[0].tagName)) {
2049
- moveTarget = nextSibling.children[0];
2050
- break;
2051
- }
2052
- }
2053
- }
2054
- }
2055
- else {
2056
- activeRow.forEach((focusableElement, index) => {
2057
- if (event.target === focusableElement) {
2058
- const increment = key === 'ArrowLeft' ? -1 : 1;
2059
- currentIndex = index + increment;
2060
- if (currentIndex >= activeRow.length) {
2061
- currentIndex = 0;
2062
- }
2063
- if (currentIndex < 0) {
2064
- currentIndex = activeRow.length - 1;
2065
- }
2066
- moveTarget = activeRow[currentIndex];
2067
- }
2068
- });
2069
- }
2070
- }
2071
- });
2072
- }
2073
- }
2074
- if (moveTarget) {
2075
- // If updateTabIndex is true, set the previously focussed element's tabIndex to -1 and the next focussed element's tabIndex to 0
2076
- // This updates the tabIndex for a roving tabIndex
2077
- if (updateTabIndex) {
2078
- activeElement.tabIndex = -1;
2079
- moveTarget.tabIndex = 0;
2080
- }
2081
- // If a move target has been set by either arrow handler, focus that target
2082
- moveTarget.focus();
2083
- }
2084
- };
2085
- /**
2086
- * This function is a helper for setting the initial tabIndexes in a roving tabIndex
2087
- *
2088
- * @param {HTMLElement[]} options Array of elements which should have a tabIndex of -1, except for the first element which will have a tabIndex of 0
2089
- */
2090
- const setTabIndex = (options) => {
2091
- if (options && options.length > 0) {
2092
- // Iterate the options and set the tabIndex to -1 on every option
2093
- options.forEach((option) => {
2094
- option.tabIndex = -1;
2095
- });
2096
- // Manually set the tabIndex of the first option to 0
2097
- options[0].tabIndex = 0;
2098
- }
2099
- };
2100
- /**
2101
- * This function is used in Dropdown, Select and MenuContainer as a default toggle keydown behavior. When the toggle has focus and the menu is open, pressing the up/down arrow keys will focus a valid non-disabled menu item - the first item for the down arrow key and last item for the up arrow key.
2102
- *
2103
- * @param event Event triggered by the keyboard
2104
- * @param menuRef Menu reference
2105
- */
2106
- const onToggleArrowKeydownDefault = (event, menuRef) => {
2107
- var _a;
2108
- if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') {
2109
- return;
2110
- }
2111
- event.preventDefault();
2112
- const listItems = Array.from((_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('li'));
2113
- const focusableElements = listItems
2114
- .map((li) => li.querySelector('button:not(:disabled),input:not(:disabled),a:not([aria-disabled="true"])'))
2115
- .filter((el) => el !== null);
2116
- let focusableElement;
2117
- if (event.key === 'ArrowDown') {
2118
- focusableElement = focusableElements[0];
2119
- }
2120
- else {
2121
- focusableElement = focusableElements[focusableElements.length - 1];
2122
- }
2123
- focusableElement && focusableElement.focus();
2124
- };
2125
- class KeyboardHandler extends Component {
2126
- constructor() {
2127
- super(...arguments);
2128
- this.keyHandler = (event) => {
2129
- const { isEventFromContainer } = this.props;
2130
- // If the passed keyboard event is not from the container, ignore the event by returning
2131
- if (isEventFromContainer ? !isEventFromContainer(event) : !this._isEventFromContainer(event)) {
2132
- return;
2133
- }
2134
- const { isActiveElement, getFocusableElement, noVerticalArrowHandling, noHorizontalArrowHandling, noEnterHandling, noSpaceHandling, updateTabIndex, validSiblingTags, additionalKeyHandler, createNavigableElements, onlyTraverseSiblings } = this.props;
2135
- // Pass the event off to be handled by any custom handler
2136
- additionalKeyHandler && additionalKeyHandler(event);
2137
- // Initialize navigableElements from the createNavigableElements callback
2138
- const navigableElements = createNavigableElements();
2139
- if (!navigableElements) {
2140
- // eslint-disable-next-line no-console
2141
- console.warn('No navigable elements have been passed to the KeyboardHandler. Keyboard navigation provided by this component will be ignored.');
2142
- return;
2143
- }
2144
- const key = event.key;
2145
- // Handle enter key. If noEnterHandling is passed, skip this block
2146
- if (!noEnterHandling) {
2147
- if (key === 'Enter') {
2148
- event.preventDefault();
2149
- event.stopImmediatePropagation(); // For menus in menus
2150
- document.activeElement.click();
2151
- }
2152
- }
2153
- // Handle space key. If noSpaceHandling is passed, skip this block
2154
- if (!noSpaceHandling) {
2155
- if (key === ' ') {
2156
- event.preventDefault();
2157
- event.stopImmediatePropagation(); // For menus in menus
2158
- document.activeElement.click();
2159
- }
2160
- }
2161
- // Inject helper handler for arrow navigation
2162
- handleArrows(event, navigableElements, isActiveElement, getFocusableElement, validSiblingTags, noVerticalArrowHandling, noHorizontalArrowHandling, updateTabIndex, onlyTraverseSiblings);
2163
- };
2164
- this._isEventFromContainer = (event) => {
2165
- const { containerRef } = this.props;
2166
- return containerRef.current && containerRef.current.contains(event.target);
2167
- };
2168
- }
2169
- componentDidMount() {
2170
- if (canUseDOM) {
2171
- window.addEventListener('keydown', this.keyHandler);
2172
- }
2173
- }
2174
- componentWillUnmount() {
2175
- if (canUseDOM) {
2176
- window.removeEventListener('keydown', this.keyHandler);
2177
- }
2178
- }
2179
- render() {
2180
- return null;
2181
- }
2182
- }
2183
- KeyboardHandler.displayName = 'KeyboardHandler';
2184
- KeyboardHandler.defaultProps = {
2185
- containerRef: null,
2186
- createNavigableElements: () => null,
2187
- isActiveElement: (navigableElement) => document.activeElement === navigableElement,
2188
- getFocusableElement: (navigableElement) => navigableElement,
2189
- validSiblingTags: ['BUTTON', 'A'],
2190
- onlyTraverseSiblings: true,
2191
- updateTabIndex: true,
2192
- noHorizontalArrowHandling: false,
2193
- noVerticalArrowHandling: false,
2194
- noEnterHandling: false,
2195
- noSpaceHandling: false
2196
- };
2197
-
2198
- const TimesIconConfig = {
2199
- name: 'TimesIcon',
2200
- height: 512,
2201
- width: 352,
2202
- svgPath: 'M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z',
2203
- yOffset: 0,
2204
- xOffset: 0,
2205
- };
2206
-
2207
- const TimesIcon = createIcon(TimesIconConfig);
2208
-
2209
- const styles$1 = {
2210
- "modifiers": {
2211
- "top": "pf-m-top",
2212
- "topLeft": "pf-m-top-left",
2213
- "topRight": "pf-m-top-right",
2214
- "bottom": "pf-m-bottom",
2215
- "bottomLeft": "pf-m-bottom-left",
2216
- "bottomRight": "pf-m-bottom-right",
2217
- "left": "pf-m-left",
2218
- "leftTop": "pf-m-left-top",
2219
- "leftBottom": "pf-m-left-bottom",
2220
- "right": "pf-m-right",
2221
- "rightTop": "pf-m-right-top",
2222
- "rightBottom": "pf-m-right-bottom",
2223
- "textAlignLeft": "pf-m-text-align-left"
2224
- },
2225
- "tooltip": "pf-v6-c-tooltip",
2226
- "tooltipArrow": "pf-v6-c-tooltip__arrow",
2227
- "tooltipContent": "pf-v6-c-tooltip__content"
2228
- };
2229
-
2230
- const TooltipContent = (_a) => {
2231
- var { className, children, isLeftAligned } = _a, props = __rest(_a, ["className", "children", "isLeftAligned"]);
2232
- return (jsx("div", Object.assign({ className: css(styles$1.tooltipContent, isLeftAligned && styles$1.modifiers.textAlignLeft, className) }, props, { children: children })));
2233
- };
2234
- TooltipContent.displayName = 'TooltipContent';
2235
-
2236
- const TooltipArrow = (_a) => {
2237
- var { className } = _a, props = __rest(_a, ["className"]);
2238
- return jsx("div", Object.assign({ className: css(styles$1.tooltipArrow, className) }, props));
2239
- };
2240
- TooltipArrow.displayName = 'TooltipArrow';
2241
-
2242
- const c_tooltip_MaxWidth = {
2243
- "value": "18.75rem"};
2244
-
2245
- var TooltipPosition;
2246
- (function (TooltipPosition) {
2247
- TooltipPosition["auto"] = "auto";
2248
- TooltipPosition["top"] = "top";
2249
- TooltipPosition["bottom"] = "bottom";
2250
- TooltipPosition["left"] = "left";
2251
- TooltipPosition["right"] = "right";
2252
- TooltipPosition["topStart"] = "top-start";
2253
- TooltipPosition["topEnd"] = "top-end";
2254
- TooltipPosition["bottomStart"] = "bottom-start";
2255
- TooltipPosition["bottomEnd"] = "bottom-end";
2256
- TooltipPosition["leftStart"] = "left-start";
2257
- TooltipPosition["leftEnd"] = "left-end";
2258
- TooltipPosition["rightStart"] = "right-start";
2259
- TooltipPosition["rightEnd"] = "right-end";
2260
- })(TooltipPosition || (TooltipPosition = {}));
2261
- // id for associating trigger with the content aria-describedby or aria-labelledby
2262
- let pfTooltipIdCounter = 1;
2263
- const Tooltip = (_a) => {
2264
- var { content: bodyContent, position = 'top', trigger = 'mouseenter focus', isVisible = false, isContentLeftAligned = false, enableFlip = true, className = '', entryDelay = 300, exitDelay = 300, appendTo = () => document.body, zIndex = 9999, minWidth, maxWidth = c_tooltip_MaxWidth.value, distance = 15, aria = 'describedby',
2265
- // For every initial starting position, there are 3 escape positions
2266
- flipBehavior = ['top', 'right', 'bottom', 'left', 'top', 'right', 'bottom'], id = `pf-tooltip-${pfTooltipIdCounter++}`, children, animationDuration = 300, triggerRef, 'aria-live': ariaLive = triggerRef ? 'polite' : 'off', onTooltipHidden = () => { } } = _a, rest = __rest(_a, ["content", "position", "trigger", "isVisible", "isContentLeftAligned", "enableFlip", "className", "entryDelay", "exitDelay", "appendTo", "zIndex", "minWidth", "maxWidth", "distance", "aria", "flipBehavior", "id", "children", "animationDuration", "triggerRef", 'aria-live', "onTooltipHidden"]);
2267
- const triggerOnMouseenter = trigger.includes('mouseenter');
2268
- const triggerOnFocus = trigger.includes('focus');
2269
- const triggerOnClick = trigger.includes('click');
2270
- const triggerManually = trigger === 'manual';
2271
- const [visible, setVisible] = useState(false);
2272
- const popperRef = createRef();
2273
- const onDocumentKeyDown = (event) => {
2274
- if (!triggerManually) {
2275
- if (event.key === KeyTypes.Escape && visible) {
2276
- hide();
2277
- }
2278
- }
2279
- };
2280
- const onTriggerEnter = (event) => {
2281
- if (event.key === KeyTypes.Enter) {
2282
- if (!visible) {
2283
- show();
2284
- }
2285
- else {
2286
- hide();
2287
- }
2288
- }
2289
- };
2290
- useEffect(() => {
2291
- if (isVisible) {
2292
- show();
2293
- }
2294
- else {
2295
- hide();
2296
- }
2297
- }, [isVisible]);
2298
- const show = () => {
2299
- setVisible(true);
2300
- };
2301
- const hide = () => {
2302
- setVisible(false);
2303
- };
2304
- const positionModifiers = {
2305
- top: styles$1.modifiers.top,
2306
- bottom: styles$1.modifiers.bottom,
2307
- left: styles$1.modifiers.left,
2308
- right: styles$1.modifiers.right,
2309
- 'top-start': styles$1.modifiers.topLeft,
2310
- 'top-end': styles$1.modifiers.topRight,
2311
- 'bottom-start': styles$1.modifiers.bottomLeft,
2312
- 'bottom-end': styles$1.modifiers.bottomRight,
2313
- 'left-start': styles$1.modifiers.leftTop,
2314
- 'left-end': styles$1.modifiers.leftBottom,
2315
- 'right-start': styles$1.modifiers.rightTop,
2316
- 'right-end': styles$1.modifiers.rightBottom
2317
- };
2318
- const hasCustomMaxWidth = maxWidth !== c_tooltip_MaxWidth.value;
2319
- const content = (jsxs("div", Object.assign({ "aria-live": ariaLive, className: css(styles$1.tooltip, className), role: "tooltip", id: id, style: {
2320
- maxWidth: hasCustomMaxWidth ? maxWidth : null
2321
- }, ref: popperRef }, rest, { children: [jsx(TooltipArrow, {}), jsx(TooltipContent, { isLeftAligned: isContentLeftAligned, children: bodyContent })] })));
2322
- const onDocumentClick = (event, triggerElement) => {
2323
- // event.currentTarget = document
2324
- // event.target could be triggerElement or something else
2325
- {
2326
- // hide on inside the toggle as well as on outside clicks
2327
- if (visible) {
2328
- hide();
2329
- }
2330
- else if (event.target === triggerElement) {
2331
- show();
2332
- }
2333
- }
2334
- };
2335
- const addAriaToTrigger = () => {
2336
- if (aria === 'describedby' && children && children.props && !children.props['aria-describedby']) {
2337
- return cloneElement(children, { 'aria-describedby': id });
2338
- }
2339
- else if (aria === 'labelledby' && children.props && !children.props['aria-labelledby']) {
2340
- return cloneElement(children, { 'aria-labelledby': id });
2341
- }
2342
- return children;
2343
- };
2344
- return (jsx(Popper, { trigger: aria !== 'none' && visible ? addAriaToTrigger() : children, triggerRef: triggerRef, popper: content, popperRef: popperRef, minWidth: minWidth !== undefined ? minWidth : 'revert', appendTo: appendTo, isVisible: visible, positionModifiers: positionModifiers, distance: distance, placement: position, onMouseEnter: triggerOnMouseenter && show, onMouseLeave: triggerOnMouseenter && hide, onPopperMouseEnter: triggerOnMouseenter && show, onPopperMouseLeave: triggerOnMouseenter && hide, onFocus: triggerOnFocus && show, onBlur: triggerOnFocus && hide, onDocumentClick: triggerOnClick && onDocumentClick, onDocumentKeyDown: triggerManually ? null : onDocumentKeyDown, onTriggerEnter: triggerManually ? null : onTriggerEnter, enableFlip: enableFlip, zIndex: zIndex, flipBehavior: flipBehavior, animationDuration: animationDuration, entryDelay: entryDelay, exitDelay: exitDelay, onHidden: onTooltipHidden }));
2345
- };
2346
- Tooltip.displayName = 'Tooltip';
2347
-
2348
- const AngleRightIconConfig = {
2349
- name: 'AngleRightIcon',
2350
- height: 512,
2351
- width: 256,
2352
- svgPath: 'M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z',
2353
- yOffset: 0,
2354
- xOffset: 0,
2355
- };
2356
-
2357
- const AngleRightIcon = createIcon(AngleRightIconConfig);
2358
-
2359
- const breadcrumbStyles = {
2360
- "breadcrumbLink": "pf-v6-c-breadcrumb__link"};
2361
-
2362
- const menuStyles = {
2363
- "divider": "pf-v6-c-divider",
2364
- "menu": "pf-v6-c-menu",
2365
- "menuContent": "pf-v6-c-menu__content",
2366
- "menuGroup": "pf-v6-c-menu__group",
2367
- "menuGroupTitle": "pf-v6-c-menu__group-title",
2368
- "menuItem": "pf-v6-c-menu__item",
2369
- "menuItemAction": "pf-v6-c-menu__item-action",
2370
- "menuItemCheck": "pf-v6-c-menu__item-check",
2371
- "menuItemDescription": "pf-v6-c-menu__item-description",
2372
- "menuItemExternalIcon": "pf-v6-c-menu__item-external-icon",
2373
- "menuItemIcon": "pf-v6-c-menu__item-icon",
2374
- "menuItemMain": "pf-v6-c-menu__item-main",
2375
- "menuItemSelectIcon": "pf-v6-c-menu__item-select-icon",
2376
- "menuItemText": "pf-v6-c-menu__item-text",
2377
- "menuItemToggleIcon": "pf-v6-c-menu__item-toggle-icon",
2378
- "menuList": "pf-v6-c-menu__list",
2379
- "menuListItem": "pf-v6-c-menu__list-item",
2380
- "menuSearch": "pf-v6-c-menu__search",
2381
- "modifiers": {
2382
- "disabled": "pf-m-disabled",
2383
- "ariaDisabled": "pf-m-aria-disabled",
2384
- "flyout": "pf-m-flyout",
2385
- "left": "pf-m-left",
2386
- "drilldown": "pf-m-drilldown",
2387
- "drilledIn": "pf-m-drilled-in",
2388
- "currentPath": "pf-m-current-path",
2389
- "plain": "pf-m-plain",
2390
- "scrollable": "pf-m-scrollable",
2391
- "load": "pf-m-load",
2392
- "loading": "pf-m-loading",
2393
- "danger": "pf-m-danger",
2394
- "selected": "pf-m-selected",
2395
- "favorited": "pf-m-favorited"
2396
- }
2397
- };
2398
-
2399
- const MenuContext = createContext({
2400
- menuId: null,
2401
- parentMenu: null,
2402
- onActionClick: () => null,
2403
- onSelect: () => null,
2404
- activeItemId: null,
2405
- selected: null,
2406
- drilledInMenus: [],
2407
- drilldownItemPath: [],
2408
- onDrillIn: null,
2409
- onDrillOut: null,
2410
- onGetMenuHeight: () => null,
2411
- flyoutRef: null,
2412
- setFlyoutRef: () => null,
2413
- disableHover: false,
2414
- role: 'menu'
2415
- });
2416
- const MenuItemContext = createContext({
2417
- itemId: null,
2418
- isDisabled: false
2419
- });
2420
-
2421
- class MenuBase extends Component {
2422
- constructor(props) {
2423
- super(props);
2424
- this.menuRef = createRef();
2425
- this.activeMenu = null;
2426
- this.state = {
2427
- ouiaStateId: getDefaultOUIAId(Menu.displayName),
2428
- transitionMoveTarget: null,
2429
- flyoutRef: null,
2430
- disableHover: false,
2431
- currentDrilldownMenuId: this.props.id
2432
- };
2433
- this.handleDrilldownTransition = (event) => {
2434
- const current = this.menuRef.current;
2435
- if (!current ||
2436
- (current !== event.target.closest(`.${menuStyles.menu}`) &&
2437
- !Array.from(current.getElementsByClassName(menuStyles.menu)).includes(event.target.closest(`.${menuStyles.menu}`)))) {
2438
- return;
2439
- }
2440
- if (this.state.transitionMoveTarget) {
2441
- this.state.transitionMoveTarget.focus();
2442
- this.setState({ transitionMoveTarget: null });
2443
- }
2444
- else {
2445
- const nextMenu = current.querySelector('#' + this.props.activeMenu) || current || null;
2446
- const nextMenuLists = nextMenu.getElementsByTagName('UL');
2447
- if (nextMenuLists.length === 0) {
2448
- return;
2449
- }
2450
- const nextMenuChildren = Array.from(nextMenuLists[0].children);
2451
- if (!this.state.currentDrilldownMenuId || nextMenu.id !== this.state.currentDrilldownMenuId) {
2452
- this.setState({ currentDrilldownMenuId: nextMenu.id });
2453
- }
2454
- else {
2455
- // if the drilldown transition ends on the same menu, do not focus the first item
2456
- return;
2457
- }
2458
- const nextTarget = nextMenuChildren.filter((el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains(menuStyles.divider)))[0].firstChild;
2459
- nextTarget.focus();
2460
- nextTarget.tabIndex = 0;
2461
- }
2462
- };
2463
- this.handleExtraKeys = (event) => {
2464
- const isDrilldown = this.props.containsDrilldown;
2465
- const activeElement = document.activeElement;
2466
- if (event.target.closest(`.${menuStyles.menu}`) !== this.activeMenu &&
2467
- !event.target.classList.contains(breadcrumbStyles.breadcrumbLink)) {
2468
- this.activeMenu = event.target.closest(`.${menuStyles.menu}`);
2469
- this.setState({ disableHover: true });
2470
- }
2471
- if (event.target.tagName === 'INPUT') {
2472
- return;
2473
- }
2474
- const parentMenu = this.activeMenu;
2475
- const key = event.key;
2476
- const isFromBreadcrumb = activeElement.classList.contains(breadcrumbStyles.breadcrumbLink);
2477
- if (key === ' ' || key === 'Enter') {
2478
- event.preventDefault();
2479
- if (isDrilldown && !isFromBreadcrumb) {
2480
- const isDrillingOut = activeElement.closest('li').classList.contains('pf-m-current-path');
2481
- if (isDrillingOut && parentMenu.parentElement.tagName === 'LI') {
2482
- activeElement.tabIndex = -1;
2483
- parentMenu.parentElement.firstChild.tabIndex = 0;
2484
- this.setState({ transitionMoveTarget: parentMenu.parentElement.firstChild });
2485
- }
2486
- else {
2487
- if (activeElement.nextElementSibling && activeElement.nextElementSibling.classList.contains(menuStyles.menu)) {
2488
- const childItems = Array.from(activeElement.nextElementSibling.getElementsByTagName('UL')[0].children).filter((el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains(menuStyles.divider)));
2489
- activeElement.tabIndex = -1;
2490
- childItems[0].firstChild.tabIndex = 0;
2491
- this.setState({ transitionMoveTarget: childItems[0].firstChild });
2492
- }
2493
- }
2494
- }
2495
- document.activeElement.click();
2496
- }
2497
- };
2498
- this.createNavigableElements = () => {
2499
- const isDrilldown = this.props.containsDrilldown;
2500
- if (isDrilldown) {
2501
- return this.activeMenu
2502
- ? Array.from(this.activeMenu.getElementsByTagName('UL')[0].children).filter((el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains(menuStyles.divider)))
2503
- : [];
2504
- }
2505
- else {
2506
- return this.menuRef.current
2507
- ? Array.from(this.menuRef.current.getElementsByTagName('LI')).filter((el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains(menuStyles.divider)))
2508
- : [];
2509
- }
2510
- };
2511
- if (props.innerRef) {
2512
- this.menuRef = props.innerRef;
2513
- }
2514
- }
2515
- allowTabFirstItem() {
2516
- // Allow tabbing to first menu item
2517
- const current = this.menuRef.current;
2518
- if (current) {
2519
- const first = current.querySelector('ul button:not(:disabled), ul a:not(:disabled)');
2520
- if (first) {
2521
- first.tabIndex = 0;
2522
- }
2523
- }
2524
- }
2525
- componentDidMount() {
2526
- if (this.context) {
2527
- this.setState({ disableHover: this.context.disableHover });
2528
- }
2529
- if (canUseDOM && this.props.containsDrilldown) {
2530
- window.addEventListener('transitionend', this.props.isRootMenu ? this.handleDrilldownTransition : null);
2531
- }
2532
- this.allowTabFirstItem();
2533
- }
2534
- componentWillUnmount() {
2535
- if (canUseDOM && this.props.containsDrilldown) {
2536
- window.removeEventListener('transitionend', this.handleDrilldownTransition);
2537
- }
2538
- }
2539
- componentDidUpdate(prevProps) {
2540
- if (prevProps.children !== this.props.children) {
2541
- this.allowTabFirstItem();
2542
- }
2543
- }
2544
- render() {
2545
- const _a = this.props, { id, children, className, onSelect, selected = null, onActionClick, ouiaId, ouiaSafe, containsFlyout, containsDrilldown, isMenuDrilledIn, isPlain, isScrollable, drilldownItemPath, drilledInMenus, onDrillIn, onDrillOut, onGetMenuHeight, parentMenu = null, activeItemId = null,
2546
- /* eslint-disable @typescript-eslint/no-unused-vars */
2547
- innerRef, isRootMenu, activeMenu, role, isNavFlyout } = _a,
2548
- /* eslint-enable @typescript-eslint/no-unused-vars */
2549
- props = __rest(_a, ["id", "children", "className", "onSelect", "selected", "onActionClick", "ouiaId", "ouiaSafe", "containsFlyout", "containsDrilldown", "isMenuDrilledIn", "isPlain", "isScrollable", "drilldownItemPath", "drilledInMenus", "onDrillIn", "onDrillOut", "onGetMenuHeight", "parentMenu", "activeItemId", "innerRef", "isRootMenu", "activeMenu", "role", "isNavFlyout"]);
2550
- const _isMenuDrilledIn = isMenuDrilledIn || (drilledInMenus && drilledInMenus.includes(id)) || false;
2551
- return (jsxs(MenuContext.Provider, { value: {
2552
- menuId: id,
2553
- parentMenu: parentMenu || id,
2554
- onSelect,
2555
- onActionClick,
2556
- activeItemId,
2557
- selected,
2558
- drilledInMenus,
2559
- drilldownItemPath,
2560
- onDrillIn,
2561
- onDrillOut,
2562
- onGetMenuHeight,
2563
- flyoutRef: this.state.flyoutRef,
2564
- setFlyoutRef: (flyoutRef) => this.setState({ flyoutRef }),
2565
- disableHover: this.state.disableHover,
2566
- role
2567
- }, children: [isRootMenu && (jsx(KeyboardHandler, { containerRef: this.menuRef || null, additionalKeyHandler: this.handleExtraKeys, createNavigableElements: this.createNavigableElements, isActiveElement: (element) => document.activeElement.closest('li') === element || // if element is a basic MenuItem
2568
- document.activeElement.parentElement === element ||
2569
- document.activeElement.closest(`.${menuStyles.menuSearch}`) === element || // if element is a MenuSearch
2570
- (document.activeElement.closest('ol') && document.activeElement.closest('ol').firstChild === element), getFocusableElement: (navigableElement) => {
2571
- var _a, _b;
2572
- return ((navigableElement === null || navigableElement === void 0 ? void 0 : navigableElement.tagName) === 'DIV' && navigableElement.querySelector('input')) || // for MenuSearchInput
2573
- (((_a = navigableElement.firstChild) === null || _a === void 0 ? void 0 : _a.tagName) === 'LABEL' &&
2574
- navigableElement.querySelector('input')) || // for MenuItem checkboxes
2575
- (((_b = navigableElement.firstChild) === null || _b === void 0 ? void 0 : _b.tagName) === 'DIV' &&
2576
- navigableElement.querySelector('a, button, input')) || // For aria-disabled element that is rendered inside a div with "display: contents" styling
2577
- navigableElement.firstChild;
2578
- }, noHorizontalArrowHandling: document.activeElement &&
2579
- (document.activeElement.classList.contains(breadcrumbStyles.breadcrumbLink) ||
2580
- document.activeElement.tagName === 'INPUT'), noEnterHandling: true, noSpaceHandling: true })), jsx("div", Object.assign({ id: id, className: css(menuStyles.menu, isPlain && menuStyles.modifiers.plain, isScrollable && menuStyles.modifiers.scrollable, containsFlyout && menuStyles.modifiers.flyout, isNavFlyout && 'pf-m-nav', containsDrilldown && menuStyles.modifiers.drilldown, _isMenuDrilledIn && menuStyles.modifiers.drilledIn, className), ref: this.menuRef }, getOUIAProps(Menu.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props, { children: children }))] }));
2581
- }
2582
- }
2583
- MenuBase.displayName = 'Menu';
2584
- MenuBase.contextType = MenuContext;
2585
- MenuBase.defaultProps = {
2586
- ouiaSafe: true,
2587
- isRootMenu: true,
2588
- isPlain: false,
2589
- isScrollable: false,
2590
- role: 'menu'
2591
- };
2592
- const Menu = forwardRef((props, ref) => (jsx(MenuBase, Object.assign({}, props, { innerRef: ref }))));
2593
- Menu.displayName = 'Menu';
2594
-
2595
- const c_menu__content_Height = {
2596
- "name": "--pf-v6-c-menu__content--Height"};
2597
-
2598
- const c_menu__content_MaxHeight = {
2599
- "name": "--pf-v6-c-menu__content--MaxHeight"};
2600
-
2601
- const MenuContent = forwardRef((props, ref) => {
2602
- const { getHeight, children, menuHeight, maxMenuHeight } = props, rest = __rest(props, ["getHeight", "children", "menuHeight", "maxMenuHeight"]);
2603
- const menuContentRef = createRef();
2604
- const refCallback = (el, menuId, onGetMenuHeight) => {
2605
- if (el) {
2606
- let clientHeight = el.clientHeight;
2607
- // if this menu is a submenu, we need to account for the root menu list's padding and root menu content's border.
2608
- let rootMenuList = null;
2609
- let parentEl = el.closest(`.${menuStyles.menuList}`);
2610
- while (parentEl !== null && parentEl.nodeType === 1) {
2611
- if (parentEl.classList.contains(menuStyles.menuList)) {
2612
- rootMenuList = parentEl;
2613
- }
2614
- parentEl = parentEl.parentElement;
2615
- }
2616
- if (rootMenuList) {
2617
- const rootMenuListStyles = getComputedStyle(rootMenuList);
2618
- const rootMenuListPaddingOffset = parseFloat(rootMenuListStyles.getPropertyValue('padding-top').replace(/px/g, '')) +
2619
- parseFloat(rootMenuListStyles.getPropertyValue('padding-bottom').replace(/px/g, '')) +
2620
- parseFloat(getComputedStyle(rootMenuList.parentElement).getPropertyValue('border-bottom-width').replace(/px/g, ''));
2621
- clientHeight = clientHeight + rootMenuListPaddingOffset;
2622
- }
2623
- onGetMenuHeight && onGetMenuHeight(menuId, clientHeight);
2624
- getHeight && getHeight(clientHeight.toString());
2625
- }
2626
- return ref || menuContentRef;
2627
- };
2628
- return (jsx(MenuContext.Consumer, { children: ({ menuId, onGetMenuHeight }) => (jsx("div", Object.assign({}, rest, { className: css(menuStyles.menuContent, props.className), ref: (el) => {
2629
- refCallback(el, menuId, onGetMenuHeight);
2630
- }, style: Object.assign(Object.assign({}, (menuHeight && { [c_menu__content_Height.name]: menuHeight })), (maxMenuHeight && { [c_menu__content_MaxHeight.name]: maxMenuHeight })), children: children }))) }));
2631
- });
2632
- MenuContent.displayName = 'MenuContent';
2633
-
2634
- const c_menu_m_flyout__menu_top_offset = {
2635
- "name": "--pf-v6-c-menu--m-flyout__menu--top-offset"};
2636
-
2637
- const c_menu_m_flyout__menu_m_left_right_offset = {
2638
- "name": "--pf-v6-c-menu--m-flyout__menu--m-left--right-offset"};
2639
-
2640
- const c_menu_m_flyout__menu_left_offset = {
2641
- "name": "--pf-v6-c-menu--m-flyout__menu--left-offset"};
2642
-
2643
- const ExternalLinkAltIconConfig = {
2644
- name: 'ExternalLinkAltIcon',
2645
- height: 512,
2646
- width: 512,
2647
- svgPath: 'M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z',
2648
- yOffset: 0,
2649
- xOffset: 0,
2650
- };
2651
-
2652
- const ExternalLinkAltIcon = createIcon(ExternalLinkAltIconConfig);
2653
-
2654
- const AngleLeftIconConfig = {
2655
- name: 'AngleLeftIcon',
2656
- height: 512,
2657
- width: 256,
2658
- svgPath: 'M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z',
2659
- yOffset: 0,
2660
- xOffset: 0,
2661
- };
2662
-
2663
- const AngleLeftIcon = createIcon(AngleLeftIconConfig);
2664
-
2665
- const CheckIconConfig = {
2666
- name: 'CheckIcon',
2667
- height: 512,
2668
- width: 512,
2669
- svgPath: 'M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z',
2670
- yOffset: 0,
2671
- xOffset: 0,
2672
- };
2673
-
2674
- const CheckIcon = createIcon(CheckIconConfig);
2675
-
2676
- const checkStyles = {
2677
- "check": "pf-v6-c-check",
2678
- "checkBody": "pf-v6-c-check__body",
2679
- "checkDescription": "pf-v6-c-check__description",
2680
- "checkInput": "pf-v6-c-check__input",
2681
- "checkLabel": "pf-v6-c-check__label",
2682
- "checkLabelRequired": "pf-v6-c-check__label-required",
2683
- "modifiers": {
2684
- "standalone": "pf-m-standalone",
2685
- "disabled": "pf-m-disabled"
2686
- }
2687
- };
2688
-
2689
- // tslint:disable-next-line:no-empty
2690
- const defaultOnChange = () => { };
2691
- class Checkbox extends Component {
2692
- constructor(props) {
2693
- super(props);
2694
- this.handleChange = (event) => {
2695
- this.props.onChange(event, event.currentTarget.checked);
2696
- };
2697
- this.state = {
2698
- ouiaStateId: getDefaultOUIAId(Checkbox.displayName)
2699
- };
2700
- }
2701
- render() {
2702
- const _a = this.props, { 'aria-label': ariaLabel, className, inputClassName, onChange, isLabelWrapped, labelPosition = 'end', isValid, isDisabled, isRequired, isChecked, label, checked, defaultChecked, description, body, ouiaId, ouiaSafe, component } = _a, props = __rest(_a, ['aria-label', "className", "inputClassName", "onChange", "isLabelWrapped", "labelPosition", "isValid", "isDisabled", "isRequired", "isChecked", "label", "checked", "defaultChecked", "description", "body", "ouiaId", "ouiaSafe", "component"]);
2703
- if (!props.id) {
2704
- // eslint-disable-next-line no-console
2705
- console.error('Checkbox:', 'id is required to make input accessible');
2706
- }
2707
- const checkedProps = {};
2708
- if ([true, false].includes(checked) || isChecked === true) {
2709
- checkedProps.checked = checked || isChecked;
2710
- }
2711
- if (onChange !== defaultOnChange) {
2712
- checkedProps.checked = isChecked;
2713
- }
2714
- if ([false, true].includes(defaultChecked)) {
2715
- checkedProps.defaultChecked = defaultChecked;
2716
- }
2717
- const inputRendered = (jsx("input", Object.assign({}, props, { className: css(checkStyles.checkInput, inputClassName), type: "checkbox", onChange: this.handleChange, "aria-invalid": !isValid, "aria-label": ariaLabel, disabled: isDisabled, required: isRequired, ref: (elem) => {
2718
- elem && (elem.indeterminate = isChecked === null);
2719
- } }, checkedProps, getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe))));
2720
- const wrapWithLabel = (isLabelWrapped && !component) || component === 'label';
2721
- const Label = wrapWithLabel ? 'span' : 'label';
2722
- const labelRendered = label ? (jsxs(Label, { className: css(checkStyles.checkLabel, isDisabled && checkStyles.modifiers.disabled), htmlFor: !wrapWithLabel ? props.id : undefined, children: [label, isRequired && (jsx("span", { className: css(checkStyles.checkLabelRequired), "aria-hidden": "true", children: ASTERISK }))] })) : null;
2723
- const Component = component !== null && component !== void 0 ? component : (wrapWithLabel ? 'label' : 'div');
2724
- checkedProps.checked = checkedProps.checked === null ? false : checkedProps.checked;
2725
- return (jsxs(Component, { className: css(checkStyles.check, !label && checkStyles.modifiers.standalone, className), htmlFor: wrapWithLabel ? props.id : undefined, children: [labelPosition === 'start' ? (jsxs(Fragment, { children: [labelRendered, inputRendered] })) : (jsxs(Fragment, { children: [inputRendered, labelRendered] })), description && jsx("span", { className: css(checkStyles.checkDescription), children: description }), body && jsx("span", { className: css(checkStyles.checkBody), children: body })] }));
2726
- }
2727
- }
2728
- Checkbox.displayName = 'Checkbox';
2729
- Checkbox.defaultProps = {
2730
- className: '',
2731
- isLabelWrapped: false,
2732
- isValid: true,
2733
- isDisabled: false,
2734
- isRequired: false,
2735
- isChecked: false,
2736
- onChange: defaultOnChange,
2737
- ouiaSafe: true
2738
- };
2739
-
2740
- const StarIconConfig = {
2741
- name: 'StarIcon',
2742
- height: 512,
2743
- width: 576,
2744
- svgPath: 'M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z',
2745
- yOffset: 0,
2746
- xOffset: 0,
2747
- };
2748
-
2749
- const StarIcon = createIcon(StarIconConfig);
2750
-
2751
- const MenuItemActionBase = (_a) => {
2752
- var { className, icon, onClick, 'aria-label': ariaLabel, isFavorited = null, isDisabled, actionId, innerRef } = _a, props = __rest(_a, ["className", "icon", "onClick", 'aria-label', "isFavorited", "isDisabled", "actionId", "innerRef"]);
2753
- return (jsx(MenuContext.Consumer, { children: ({ onActionClick }) => (jsx(MenuItemContext.Consumer, { children: ({ itemId, isDisabled: isDisabledContext }) => {
2754
- const onClickButton = (event) => {
2755
- // event specified on the MenuItemAction
2756
- onClick && onClick(event);
2757
- // event specified on the Menu
2758
- onActionClick && onActionClick(event, itemId, actionId);
2759
- };
2760
- return (jsx("div", Object.assign({ className: css(menuStyles.menuItemAction, isFavorited !== null && 'pf-m-favorite', isFavorited && menuStyles.modifiers.favorited, className) }, props, { children: jsx(Button, { "aria-label": ariaLabel, onClick: onClickButton, ref: innerRef, role: "menuitem", variant: "plain", tabIndex: -1, isDisabled: isDisabled || isDisabledContext, icon: icon === 'favorites' || isFavorited !== null ? jsx(StarIcon, {}) : icon }) })));
2761
- } })) }));
2762
- };
2763
- const MenuItemAction = forwardRef((props, ref) => (jsx(MenuItemActionBase, Object.assign({}, props, { innerRef: ref }))));
2764
- MenuItemAction.displayName = 'MenuItemAction';
2765
-
2766
- const FlyoutContext = createContext({
2767
- direction: 'right'
2768
- });
2769
- const MenuItemBase = (_a) => {
2770
- var { children, className, itemId = null, to, hasCheckbox = false, isActive = null, isFavorited = null, isLoadButton = false, isLoading = false, flyoutMenu, direction, description = null, onClick = () => { }, component = 'button', isDisabled = false, isAriaDisabled = false, isExternalLink = false, isSelected = null, isFocused, isDanger = false, icon, actions, onShowFlyout, drilldownMenu, isOnPath, innerRef, id, 'aria-label': ariaLabel, tooltipProps, rel, target, download } = _a, props = __rest(_a, ["children", "className", "itemId", "to", "hasCheckbox", "isActive", "isFavorited", "isLoadButton", "isLoading", "flyoutMenu", "direction", "description", "onClick", "component", "isDisabled", "isAriaDisabled", "isExternalLink", "isSelected", "isFocused", "isDanger", "icon", "actions", "onShowFlyout", "drilldownMenu", "isOnPath", "innerRef", "id", 'aria-label', "tooltipProps", "rel", "target", "download"]);
2771
- const { menuId, parentMenu, onSelect, onActionClick, activeItemId, selected, drilldownItemPath, onDrillIn, onDrillOut, flyoutRef, setFlyoutRef, disableHover, role: menuRole } = useContext(MenuContext);
2772
- let Component = (to ? 'a' : component);
2773
- if (hasCheckbox && !to) {
2774
- Component = 'label';
2775
- }
2776
- const [flyoutTarget, setFlyoutTarget] = useState(null);
2777
- const flyoutContext = useContext(FlyoutContext);
2778
- const [flyoutXDirection, setFlyoutXDirection] = useState(flyoutContext.direction);
2779
- const ref = useRef(undefined);
2780
- const privateRef = useRef(undefined);
2781
- const innerComponentRef = innerRef || privateRef;
2782
- const flyoutVisible = ref === flyoutRef;
2783
- const hasFlyout = flyoutMenu !== undefined;
2784
- const showFlyout = (show) => {
2785
- if (!flyoutVisible && show) {
2786
- setFlyoutRef(ref);
2787
- }
2788
- else if (flyoutVisible && !show) {
2789
- setFlyoutRef(null);
2790
- }
2791
- onShowFlyout && show && onShowFlyout();
2792
- };
2793
- useIsomorphicLayoutEffect(() => {
2794
- if (hasFlyout && ref.current && canUseDOM) {
2795
- const flyoutMenu = ref.current.lastElementChild;
2796
- if (flyoutMenu && flyoutMenu.classList.contains(menuStyles.menu)) {
2797
- const origin = ref.current.getClientRects()[0];
2798
- const rect = flyoutMenu.getClientRects()[0];
2799
- if (origin && rect) {
2800
- const spaceLeftLeft = origin.x - rect.width;
2801
- const spaceLeftRight = window.innerWidth - origin.x - origin.width - rect.width;
2802
- let xDir = flyoutXDirection;
2803
- if (spaceLeftRight < 0 && xDir !== 'left') {
2804
- setFlyoutXDirection('left');
2805
- xDir = 'left';
2806
- }
2807
- else if (spaceLeftLeft < 0 && xDir !== 'right') {
2808
- setFlyoutXDirection('right');
2809
- xDir = 'right';
2810
- }
2811
- let xOffset = 0;
2812
- if (spaceLeftLeft < 0 && spaceLeftRight < 0) {
2813
- xOffset = xDir === 'right' ? -spaceLeftRight : -spaceLeftLeft;
2814
- }
2815
- if (xDir === 'left') {
2816
- flyoutMenu.classList.add(menuStyles.modifiers.left);
2817
- flyoutMenu.style.setProperty(c_menu_m_flyout__menu_m_left_right_offset.name, `-${xOffset}px`);
2818
- }
2819
- else {
2820
- flyoutMenu.style.setProperty(c_menu_m_flyout__menu_left_offset.name, `-${xOffset}px`);
2821
- }
2822
- const spaceLeftBot = window.innerHeight - origin.y - rect.height;
2823
- const spaceLeftTop = window.innerHeight - rect.height;
2824
- if (spaceLeftTop < 0 && spaceLeftBot < 0) ;
2825
- else if (spaceLeftBot < 0) {
2826
- flyoutMenu.style.setProperty(c_menu_m_flyout__menu_top_offset.name, `${spaceLeftBot}px`);
2827
- }
2828
- }
2829
- }
2830
- }
2831
- }, [flyoutVisible, flyoutMenu]);
2832
- useEffect(() => {
2833
- setFlyoutXDirection(flyoutContext.direction);
2834
- }, [flyoutContext]);
2835
- useEffect(() => {
2836
- if (flyoutTarget) {
2837
- if (flyoutVisible) {
2838
- const flyoutMenu = flyoutTarget.nextElementSibling;
2839
- const flyoutItems = Array.from(flyoutMenu.getElementsByTagName('UL')[0].children).filter((el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains(menuStyles.divider)));
2840
- flyoutItems[0].firstChild.focus();
2841
- }
2842
- else {
2843
- flyoutTarget.focus();
2844
- }
2845
- }
2846
- }, [flyoutVisible, flyoutTarget]);
2847
- const handleFlyout = (event) => {
2848
- const key = event.key;
2849
- const target = event.target;
2850
- const type = event.type;
2851
- if (key === ' ' || key === 'Enter' || key === 'ArrowRight' || type === 'click') {
2852
- event.stopPropagation();
2853
- event.preventDefault();
2854
- if (!flyoutVisible) {
2855
- showFlyout(true);
2856
- setFlyoutTarget(target);
2857
- }
2858
- }
2859
- if (key === 'Escape' || key === 'ArrowLeft') {
2860
- if (flyoutVisible) {
2861
- event.stopPropagation();
2862
- showFlyout(false);
2863
- }
2864
- }
2865
- };
2866
- const onItemSelect = (event, onSelect) => {
2867
- if (!isAriaDisabled) {
2868
- // Trigger callback for Menu onSelect
2869
- onSelect && onSelect(event, itemId);
2870
- // Trigger callback for item onClick
2871
- onClick && onClick(event);
2872
- }
2873
- };
2874
- const _isOnPath = (isOnPath && isOnPath) || (drilldownItemPath && drilldownItemPath.includes(itemId)) || false;
2875
- let drill;
2876
- if (direction) {
2877
- if (direction === 'down') {
2878
- drill = (event) => onDrillIn &&
2879
- onDrillIn(event, menuId, typeof drilldownMenu === 'function'
2880
- ? drilldownMenu().props.id
2881
- : drilldownMenu.props.id, itemId);
2882
- }
2883
- else {
2884
- drill = (event) => onDrillOut && onDrillOut(event, parentMenu, itemId);
2885
- }
2886
- }
2887
- let additionalProps = {};
2888
- if (Component === 'a') {
2889
- additionalProps = {
2890
- href: to,
2891
- 'aria-disabled': isDisabled || isAriaDisabled ? true : null,
2892
- // prevent invalid 'disabled' attribute on <a> tags
2893
- disabled: null,
2894
- target: isExternalLink ? '_blank' : target,
2895
- rel,
2896
- download
2897
- };
2898
- }
2899
- else if (Component === 'button') {
2900
- additionalProps = {
2901
- type: 'button',
2902
- 'aria-disabled': isAriaDisabled ? true : null
2903
- };
2904
- }
2905
- if (isOnPath) {
2906
- additionalProps['aria-expanded'] = true;
2907
- }
2908
- else if (hasFlyout) {
2909
- additionalProps['aria-haspopup'] = 'menu';
2910
- additionalProps['aria-expanded'] = flyoutVisible;
2911
- }
2912
- const getAriaCurrent = () => {
2913
- if (isActive !== null) {
2914
- if (isActive) {
2915
- return 'page';
2916
- }
2917
- else {
2918
- return null;
2919
- }
2920
- }
2921
- else if (itemId !== null && activeItemId !== null) {
2922
- return itemId === activeItemId;
2923
- }
2924
- return null;
2925
- };
2926
- const getIsSelected = () => {
2927
- if (isSelected !== null) {
2928
- return isSelected;
2929
- }
2930
- else if (selected !== null && itemId !== null) {
2931
- return (Array.isArray(selected) && selected.includes(itemId)) || itemId === selected;
2932
- }
2933
- return false;
2934
- };
2935
- const onMouseOver = () => {
2936
- if (disableHover) {
2937
- return;
2938
- }
2939
- if (hasFlyout) {
2940
- showFlyout(true);
2941
- }
2942
- else {
2943
- setFlyoutRef(null);
2944
- }
2945
- };
2946
- useEffect(() => {
2947
- if (isFocused && ref.current) {
2948
- const itemEl = ref.current;
2949
- const parentListEl = itemEl.parentElement;
2950
- if (parentListEl) {
2951
- const isAboveTop = itemEl.offsetTop - parentListEl.offsetTop < parentListEl.scrollTop;
2952
- const isBelowBottom = itemEl.offsetTop - parentListEl.offsetTop + itemEl.clientHeight;
2953
- if (isAboveTop || isBelowBottom) {
2954
- itemEl.scrollIntoView({ behavior: 'auto', block: 'nearest' });
2955
- }
2956
- }
2957
- }
2958
- }, [isFocused]);
2959
- const isSelectMenu = menuRole === 'listbox';
2960
- const renderItem = (jsxs(Fragment, { children: [jsx(GenerateId, { children: (randomId) => (jsxs(Component, Object.assign({ id: id, tabIndex: -1, className: css(menuStyles.menuItem, getIsSelected() && !hasCheckbox && menuStyles.modifiers.selected, className), "aria-current": getAriaCurrent() }, (!hasCheckbox && { disabled: isDisabled, 'aria-label': ariaLabel }), (!hasCheckbox && !flyoutMenu && { role: isSelectMenu ? 'option' : 'menuitem' }), (!hasCheckbox && !flyoutMenu && isSelectMenu && { 'aria-selected': getIsSelected() }), { ref: innerComponentRef }, (!hasCheckbox && {
2961
- onClick: (event) => {
2962
- if (!isAriaDisabled) {
2963
- onItemSelect(event, onSelect);
2964
- drill && drill(event);
2965
- flyoutMenu && handleFlyout(event);
2966
- }
2967
- else {
2968
- event.preventDefault();
2969
- }
2970
- }
2971
- }), (hasCheckbox && { htmlFor: randomId }), additionalProps, { children: [jsxs("span", { className: css(menuStyles.menuItemMain), children: [direction === 'up' && (jsx("span", { className: css(menuStyles.menuItemToggleIcon), children: jsx(AngleLeftIcon, {}) })), icon && jsx("span", { className: css(menuStyles.menuItemIcon), children: icon }), hasCheckbox && (jsx("span", { className: css(menuStyles.menuItemCheck), children: jsx(Checkbox, { id: randomId, component: "span", isChecked: isSelected || false, onChange: (event) => onItemSelect(event, onSelect), isDisabled: isDisabled, "aria-disabled": isAriaDisabled }) })), jsx("span", { className: css(menuStyles.menuItemText), children: children }), isExternalLink && (jsx("span", { className: css(menuStyles.menuItemExternalIcon), children: jsx(ExternalLinkAltIcon, {}) })), (flyoutMenu || direction === 'down') && (jsx("span", { className: css(menuStyles.menuItemToggleIcon), children: jsx(AngleRightIcon, {}) })), getIsSelected() && (jsx("span", { className: css(menuStyles.menuItemSelectIcon), children: jsx(CheckIcon, {}) }))] }), description && direction !== 'up' && (jsx("span", { className: css(menuStyles.menuItemDescription), children: jsx("span", { children: description }) }))] }))) }), flyoutVisible && (jsx(MenuContext.Provider, { value: { disableHover }, children: jsx(FlyoutContext.Provider, { value: { direction: flyoutXDirection }, children: flyoutMenu }) })), typeof drilldownMenu === 'function' ? drilldownMenu() : drilldownMenu, jsxs(MenuItemContext.Provider, { value: { itemId, isDisabled }, children: [actions, isFavorited !== null && (jsx(MenuItemAction, { icon: "favorites", isFavorited: isFavorited, "aria-label": isFavorited ? 'starred' : 'not starred', onClick: (event) => onActionClick(event, itemId), tabIndex: -1, actionId: "fav" }))] })] }));
2972
- return (jsxs(Fragment, { children: [jsx("li", Object.assign({ className: css(menuStyles.menuListItem, isDisabled && menuStyles.modifiers.disabled, isAriaDisabled && menuStyles.modifiers.ariaDisabled, _isOnPath && menuStyles.modifiers.currentPath, isLoadButton && menuStyles.modifiers.load, isLoading && menuStyles.modifiers.loading, isFocused && 'pf-m-focus', isDanger && menuStyles.modifiers.danger, className), onMouseOver: () => {
2973
- if (!isAriaDisabled) {
2974
- onMouseOver();
2975
- }
2976
- } }, (flyoutMenu && !isAriaDisabled && { onKeyDown: handleFlyout }), { ref: ref, role: !hasCheckbox ? 'none' : 'menuitem' }, (hasCheckbox && { 'aria-label': ariaLabel }), props, { children: renderItem })), tooltipProps && jsx(Tooltip, Object.assign({}, tooltipProps, { triggerRef: innerComponentRef }))] }));
2977
- };
2978
- const MenuItem = forwardRef((props, ref) => (jsx(MenuItemBase, Object.assign({}, props, { innerRef: ref }))));
2979
- MenuItem.displayName = 'MenuItem';
2980
-
2981
- const MenuList = (_a) => {
2982
- var { children = null, className, isAriaMultiselectable = false, 'aria-label': ariaLabel } = _a, props = __rest(_a, ["children", "className", "isAriaMultiselectable", 'aria-label']);
2983
- const { role } = useContext(MenuContext);
2984
- return (jsx("ul", Object.assign({ role: role }, (role === 'listbox' && { 'aria-multiselectable': isAriaMultiselectable }), { className: css(menuStyles.menuList, className), "aria-label": ariaLabel }, props, { children: children })));
2985
- };
2986
- MenuList.displayName = 'MenuList';
2987
-
2988
- const styles = {
2989
- "menuToggle": "pf-v6-c-menu-toggle",
2990
- "menuToggleButton": "pf-v6-c-menu-toggle__button",
2991
- "menuToggleControls": "pf-v6-c-menu-toggle__controls",
2992
- "menuToggleCount": "pf-v6-c-menu-toggle__count",
2993
- "menuToggleIcon": "pf-v6-c-menu-toggle__icon",
2994
- "menuToggleStatusIcon": "pf-v6-c-menu-toggle__status-icon",
2995
- "menuToggleText": "pf-v6-c-menu-toggle__text",
2996
- "menuToggleToggleIcon": "pf-v6-c-menu-toggle__toggle-icon",
2997
- "modifiers": {
2998
- "primary": "pf-m-primary",
2999
- "secondary": "pf-m-secondary",
3000
- "fullHeight": "pf-m-full-height",
3001
- "fullWidth": "pf-m-full-width",
3002
- "plain": "pf-m-plain",
3003
- "expanded": "pf-m-expanded",
3004
- "disabled": "pf-m-disabled",
3005
- "small": "pf-m-small",
3006
- "success": "pf-m-success",
3007
- "warning": "pf-m-warning",
3008
- "danger": "pf-m-danger",
3009
- "placeholder": "pf-m-placeholder",
3010
- "splitButton": "pf-m-split-button",
3011
- "standalone": "pf-m-standalone",
3012
- "typeahead": "pf-m-typeahead",
3013
- "text": "pf-m-text",
3014
- "avatar": "pf-m-avatar"
3015
- }};
3016
-
3017
- const CaretDownIconConfig = {
3018
- name: 'CaretDownIcon',
3019
- height: 512,
3020
- width: 320,
3021
- svgPath: 'M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z',
3022
- yOffset: 0,
3023
- xOffset: 0,
3024
- };
3025
-
3026
- const CaretDownIcon = createIcon(CaretDownIconConfig);
3027
-
3028
- var MenuToggleStatus;
3029
- (function (MenuToggleStatus) {
3030
- MenuToggleStatus["success"] = "success";
3031
- MenuToggleStatus["danger"] = "danger";
3032
- MenuToggleStatus["warning"] = "warning";
3033
- })(MenuToggleStatus || (MenuToggleStatus = {}));
3034
- var MenuToggleSize;
3035
- (function (MenuToggleSize) {
3036
- MenuToggleSize["default"] = "default";
3037
- MenuToggleSize["sm"] = "sm";
3038
- })(MenuToggleSize || (MenuToggleSize = {}));
3039
- class MenuToggleBase extends Component {
3040
- constructor() {
3041
- super(...arguments);
3042
- this.displayName = 'MenuToggleBase';
3043
- this.state = {
3044
- ouiaStateId: getDefaultOUIAId(MenuToggle.displayName, this.props.variant)
3045
- };
3046
- }
3047
- render() {
3048
- const _a = this.props, { children, className, icon, badge, isExpanded, isDisabled, isFullHeight, isFullWidth, isPlaceholder, splitButtonItems, variant, status, statusIcon, innerRef, onClick, 'aria-label': ariaLabel, ouiaId, ouiaSafe, size } = _a, otherProps = __rest(_a, ["children", "className", "icon", "badge", "isExpanded", "isDisabled", "isFullHeight", "isFullWidth", "isPlaceholder", "splitButtonItems", "variant", "status", "statusIcon", "innerRef", "onClick", 'aria-label', "ouiaId", "ouiaSafe", "size"]);
3049
- const isPlain = variant === 'plain';
3050
- const isPlainText = variant === 'plainText';
3051
- const isTypeahead = variant === 'typeahead';
3052
- const ouiaProps = getOUIAProps(MenuToggle.displayName, ouiaId !== null && ouiaId !== void 0 ? ouiaId : this.state.ouiaStateId, ouiaSafe);
3053
- let _statusIcon = statusIcon;
3054
- if (!statusIcon) {
3055
- switch (status) {
3056
- case MenuToggleStatus.success:
3057
- _statusIcon = jsx(CheckCircleIcon, {});
3058
- break;
3059
- case MenuToggleStatus.warning:
3060
- _statusIcon = jsx(ExclamationTriangleIcon, {});
3061
- break;
3062
- case MenuToggleStatus.danger:
3063
- _statusIcon = jsx(ExclamationCircleIcon, {});
3064
- break;
3065
- }
3066
- }
3067
- const toggleControls = (jsxs("span", { className: css(styles.menuToggleControls), children: [status !== undefined && jsx("span", { className: css(styles.menuToggleStatusIcon), children: _statusIcon }), jsx("span", { className: css(styles.menuToggleToggleIcon), children: jsx(CaretDownIcon, {}) })] }));
3068
- const content = (jsxs(Fragment, { children: [icon && jsx("span", { className: css(styles.menuToggleIcon), children: icon }), isTypeahead ? children : children && jsx("span", { className: css(styles.menuToggleText), children: children }), isValidElement(badge) && jsx("span", { className: css(styles.menuToggleCount), children: badge }), isTypeahead ? (jsx("button", Object.assign({ type: "button", className: css(styles.menuToggleButton), "aria-expanded": isExpanded, onClick: onClick, "aria-label": ariaLabel || 'Menu toggle', tabIndex: -1 }, ouiaProps, { children: toggleControls }))) : (!isPlain && toggleControls)] }));
3069
- const commonStyles = css(styles.menuToggle, isExpanded && styles.modifiers.expanded, variant === 'primary' && styles.modifiers.primary, variant === 'secondary' && styles.modifiers.secondary, status && styles.modifiers[status], (isPlain || isPlainText) && styles.modifiers.plain, isPlainText && 'pf-m-text', isFullHeight && styles.modifiers.fullHeight, isFullWidth && styles.modifiers.fullWidth, isDisabled && styles.modifiers.disabled, isPlaceholder && styles.modifiers.placeholder, size === MenuToggleSize.sm && styles.modifiers.small, className);
3070
- const componentProps = Object.assign(Object.assign({ children: content }, (isDisabled && { disabled: true })), otherProps);
3071
- if (isTypeahead) {
3072
- return (jsx("div", Object.assign({ ref: innerRef, className: css(commonStyles, styles.modifiers.typeahead) }, componentProps)));
3073
- }
3074
- if (splitButtonItems) {
3075
- return (jsxs("div", { ref: innerRef, className: css(commonStyles, styles.modifiers.splitButton), children: [splitButtonItems, jsxs("button", Object.assign({ className: css(styles.menuToggleButton, children && styles.modifiers.text), type: "button", "aria-expanded": isExpanded, "aria-label": ariaLabel, disabled: isDisabled, onClick: onClick }, otherProps, ouiaProps, { children: [children && jsx("span", { className: css(styles.menuToggleText), children: children }), toggleControls] }))] }));
3076
- }
3077
- return (jsx("button", Object.assign({ className: css(commonStyles), type: "button", "aria-label": ariaLabel, "aria-expanded": isExpanded, ref: innerRef, disabled: isDisabled, onClick: onClick }, componentProps, ouiaProps)));
3078
- }
3079
- }
3080
- MenuToggleBase.defaultProps = {
3081
- className: '',
3082
- isExpanded: false,
3083
- isDisabled: false,
3084
- isFullWidth: false,
3085
- isFullHeight: false,
3086
- isPlaceholder: false,
3087
- size: 'default',
3088
- ouiaSafe: true
3089
- };
3090
- const MenuToggle = forwardRef((props, ref) => (jsx(MenuToggleBase, Object.assign({ innerRef: ref }, props))));
3091
- MenuToggle.displayName = 'MenuToggle';
3092
-
3093
- const dividerStyles = {
3094
- "divider": "pf-v6-c-divider",
3095
- "modifiers": {
3096
- "hidden": "pf-m-hidden",
3097
- "hiddenOnSm": "pf-m-hidden-on-sm",
3098
- "visibleOnSm": "pf-m-visible-on-sm",
3099
- "hiddenOnMd": "pf-m-hidden-on-md",
3100
- "visibleOnMd": "pf-m-visible-on-md",
3101
- "hiddenOnLg": "pf-m-hidden-on-lg",
3102
- "visibleOnLg": "pf-m-visible-on-lg",
3103
- "hiddenOnXl": "pf-m-hidden-on-xl",
3104
- "visibleOnXl": "pf-m-visible-on-xl",
3105
- "hiddenOn_2xl": "pf-m-hidden-on-2xl",
3106
- "visibleOn_2xl": "pf-m-visible-on-2xl",
3107
- "horizontal": "pf-m-horizontal",
3108
- "vertical": "pf-m-vertical",
3109
- "insetNone": "pf-m-inset-none",
3110
- "insetXs": "pf-m-inset-xs",
3111
- "insetSm": "pf-m-inset-sm",
3112
- "insetMd": "pf-m-inset-md",
3113
- "insetLg": "pf-m-inset-lg",
3114
- "insetXl": "pf-m-inset-xl",
3115
- "inset_2xl": "pf-m-inset-2xl",
3116
- "inset_3xl": "pf-m-inset-3xl",
3117
- "horizontalOnSm": "pf-m-horizontal-on-sm",
3118
- "verticalOnSm": "pf-m-vertical-on-sm",
3119
- "insetNoneOnSm": "pf-m-inset-none-on-sm",
3120
- "insetXsOnSm": "pf-m-inset-xs-on-sm",
3121
- "insetSmOnSm": "pf-m-inset-sm-on-sm",
3122
- "insetMdOnSm": "pf-m-inset-md-on-sm",
3123
- "insetLgOnSm": "pf-m-inset-lg-on-sm",
3124
- "insetXlOnSm": "pf-m-inset-xl-on-sm",
3125
- "inset_2xlOnSm": "pf-m-inset-2xl-on-sm",
3126
- "inset_3xlOnSm": "pf-m-inset-3xl-on-sm",
3127
- "horizontalOnMd": "pf-m-horizontal-on-md",
3128
- "verticalOnMd": "pf-m-vertical-on-md",
3129
- "insetNoneOnMd": "pf-m-inset-none-on-md",
3130
- "insetXsOnMd": "pf-m-inset-xs-on-md",
3131
- "insetSmOnMd": "pf-m-inset-sm-on-md",
3132
- "insetMdOnMd": "pf-m-inset-md-on-md",
3133
- "insetLgOnMd": "pf-m-inset-lg-on-md",
3134
- "insetXlOnMd": "pf-m-inset-xl-on-md",
3135
- "inset_2xlOnMd": "pf-m-inset-2xl-on-md",
3136
- "inset_3xlOnMd": "pf-m-inset-3xl-on-md",
3137
- "horizontalOnLg": "pf-m-horizontal-on-lg",
3138
- "verticalOnLg": "pf-m-vertical-on-lg",
3139
- "insetNoneOnLg": "pf-m-inset-none-on-lg",
3140
- "insetXsOnLg": "pf-m-inset-xs-on-lg",
3141
- "insetSmOnLg": "pf-m-inset-sm-on-lg",
3142
- "insetMdOnLg": "pf-m-inset-md-on-lg",
3143
- "insetLgOnLg": "pf-m-inset-lg-on-lg",
3144
- "insetXlOnLg": "pf-m-inset-xl-on-lg",
3145
- "inset_2xlOnLg": "pf-m-inset-2xl-on-lg",
3146
- "inset_3xlOnLg": "pf-m-inset-3xl-on-lg",
3147
- "horizontalOnXl": "pf-m-horizontal-on-xl",
3148
- "verticalOnXl": "pf-m-vertical-on-xl",
3149
- "insetNoneOnXl": "pf-m-inset-none-on-xl",
3150
- "insetXsOnXl": "pf-m-inset-xs-on-xl",
3151
- "insetSmOnXl": "pf-m-inset-sm-on-xl",
3152
- "insetMdOnXl": "pf-m-inset-md-on-xl",
3153
- "insetLgOnXl": "pf-m-inset-lg-on-xl",
3154
- "insetXlOnXl": "pf-m-inset-xl-on-xl",
3155
- "inset_2xlOnXl": "pf-m-inset-2xl-on-xl",
3156
- "inset_3xlOnXl": "pf-m-inset-3xl-on-xl",
3157
- "horizontalOn_2xl": "pf-m-horizontal-on-2xl",
3158
- "verticalOn_2xl": "pf-m-vertical-on-2xl",
3159
- "insetNoneOn_2xl": "pf-m-inset-none-on-2xl",
3160
- "insetXsOn_2xl": "pf-m-inset-xs-on-2xl",
3161
- "insetSmOn_2xl": "pf-m-inset-sm-on-2xl",
3162
- "insetMdOn_2xl": "pf-m-inset-md-on-2xl",
3163
- "insetLgOn_2xl": "pf-m-inset-lg-on-2xl",
3164
- "insetXlOn_2xl": "pf-m-inset-xl-on-2xl",
3165
- "inset_2xlOn_2xl": "pf-m-inset-2xl-on-2xl",
3166
- "inset_3xlOn_2xl": "pf-m-inset-3xl-on-2xl"
3167
- }
3168
- };
3169
-
3170
- var DividerVariant;
3171
- (function (DividerVariant) {
3172
- DividerVariant["hr"] = "hr";
3173
- DividerVariant["li"] = "li";
3174
- DividerVariant["div"] = "div";
3175
- })(DividerVariant || (DividerVariant = {}));
3176
- const Divider = (_a) => {
3177
- var { className, component = DividerVariant.hr, inset, orientation } = _a, props = __rest(_a, ["className", "component", "inset", "orientation"]);
3178
- const Component = component;
3179
- return (jsx(Component, Object.assign({ className: css(dividerStyles.divider, formatBreakpointMods(inset, dividerStyles), formatBreakpointMods(orientation, dividerStyles), className) }, (component !== 'hr' && { role: 'separator' }), props)));
3180
- };
3181
- Divider.displayName = 'Divider';
3182
-
3183
- const DropdownBase = (_a) => {
3184
- var { children, className, onSelect, isOpen, toggle, shouldFocusToggleOnSelect = false, onOpenChange, onToggleKeydown, isPlain, isScrollable, innerRef, ouiaId, ouiaSafe = true, zIndex = 9999, popperProps, onOpenChangeKeys = ['Escape', 'Tab'], menuHeight, maxMenuHeight, shouldFocusFirstItemOnOpen = false, shouldPreventScrollOnItemFocus = true, focusTimeoutDelay = 0 } = _a, props = __rest(_a, ["children", "className", "onSelect", "isOpen", "toggle", "shouldFocusToggleOnSelect", "onOpenChange", "onToggleKeydown", "isPlain", "isScrollable", "innerRef", "ouiaId", "ouiaSafe", "zIndex", "popperProps", "onOpenChangeKeys", "menuHeight", "maxMenuHeight", "shouldFocusFirstItemOnOpen", "shouldPreventScrollOnItemFocus", "focusTimeoutDelay"]);
3185
- const localMenuRef = useRef(undefined);
3186
- const localToggleRef = useRef(undefined);
3187
- const ouiaProps = useOUIAProps(Dropdown.displayName, ouiaId, ouiaSafe);
3188
- const menuRef = innerRef || localMenuRef;
3189
- const toggleRef = typeof toggle === 'function' || (typeof toggle !== 'function' && !toggle.toggleRef)
3190
- ? localToggleRef
3191
- : toggle === null || toggle === void 0 ? void 0 : toggle.toggleRef;
3192
- const prevIsOpen = useRef(isOpen);
3193
- useEffect(() => {
3194
- // menu was opened, focus on first menu item
3195
- if (prevIsOpen.current === false && isOpen === true && shouldFocusFirstItemOnOpen) {
3196
- setTimeout(() => {
3197
- var _a;
3198
- const firstElement = (_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('li button:not(:disabled),li input:not(:disabled),li a:not([aria-disabled="true"])');
3199
- firstElement && firstElement.focus({ preventScroll: shouldPreventScrollOnItemFocus });
3200
- }, focusTimeoutDelay);
3201
- }
3202
- prevIsOpen.current = isOpen;
3203
- // eslint-disable-next-line react-hooks/exhaustive-deps
3204
- }, [isOpen]);
3205
- useEffect(() => {
3206
- const handleMenuKeys = (event) => {
3207
- var _a, _b, _c, _d;
3208
- // Close the menu on tab or escape if onOpenChange is provided
3209
- if (isOpen &&
3210
- onOpenChange &&
3211
- (((_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) || ((_b = toggleRef.current) === null || _b === void 0 ? void 0 : _b.contains(event.target)))) {
3212
- if (onOpenChangeKeys.includes(event.key)) {
3213
- onOpenChange(false);
3214
- (_c = toggleRef.current) === null || _c === void 0 ? void 0 : _c.focus();
3215
- }
3216
- }
3217
- if ((_d = toggleRef.current) === null || _d === void 0 ? void 0 : _d.contains(event.target)) {
3218
- if (onToggleKeydown) {
3219
- onToggleKeydown(event);
3220
- }
3221
- else if (isOpen) {
3222
- onToggleArrowKeydownDefault(event, menuRef);
3223
- }
3224
- }
3225
- };
3226
- const handleClick = (event) => {
3227
- var _a, _b;
3228
- // If the event is not on the toggle and onOpenChange callback is provided, close the menu
3229
- if (isOpen && onOpenChange && !((_a = toggleRef === null || toggleRef === void 0 ? void 0 : toggleRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
3230
- if (isOpen && !((_b = menuRef.current) === null || _b === void 0 ? void 0 : _b.contains(event.target))) {
3231
- onOpenChange(false);
3232
- }
3233
- }
3234
- };
3235
- window.addEventListener('keydown', handleMenuKeys);
3236
- window.addEventListener('click', handleClick);
3237
- return () => {
3238
- window.removeEventListener('keydown', handleMenuKeys);
3239
- window.removeEventListener('click', handleClick);
3240
- };
3241
- }, [
3242
- isOpen,
3243
- menuRef,
3244
- toggleRef,
3245
- onOpenChange,
3246
- onOpenChangeKeys,
3247
- onToggleKeydown,
3248
- shouldPreventScrollOnItemFocus,
3249
- shouldFocusFirstItemOnOpen,
3250
- focusTimeoutDelay
3251
- ]);
3252
- const scrollable = maxMenuHeight !== undefined || menuHeight !== undefined || isScrollable;
3253
- const menu = (jsx(Menu, Object.assign({ className: css(className), ref: menuRef, onSelect: (event, value) => {
3254
- var _a;
3255
- onSelect && onSelect(event, value);
3256
- shouldFocusToggleOnSelect && ((_a = toggleRef.current) === null || _a === void 0 ? void 0 : _a.focus());
3257
- }, isPlain: isPlain, isScrollable: scrollable }, props, ouiaProps, { children: jsx(MenuContent, { menuHeight: menuHeight, maxMenuHeight: maxMenuHeight, children: children }) })));
3258
- return (jsx(Popper, Object.assign({ trigger: typeof toggle === 'function' ? toggle(toggleRef) : toggle.toggleNode, triggerRef: toggleRef, popper: menu, popperRef: menuRef, isVisible: isOpen, zIndex: zIndex }, popperProps)));
3259
- };
3260
- const Dropdown = forwardRef((props, ref) => (jsx(DropdownBase, Object.assign({ innerRef: ref }, props))));
3261
- Dropdown.displayName = 'Dropdown';
3262
-
3263
- const DropdownItemBase = (_a) => {
3264
- var { children, className, description, isDisabled, isAriaDisabled, value, onClick, ouiaId, ouiaSafe, innerRef, tooltipProps } = _a, props = __rest(_a, ["children", "className", "description", "isDisabled", "isAriaDisabled", "value", "onClick", "ouiaId", "ouiaSafe", "innerRef", "tooltipProps"]);
3265
- const ouiaProps = useOUIAProps(DropdownItem.displayName, ouiaId, ouiaSafe);
3266
- return (jsx(MenuItem, Object.assign({ className: css(className), description: description, isDisabled: isDisabled, isAriaDisabled: isAriaDisabled, itemId: value, onClick: onClick, tooltipProps: tooltipProps, ref: innerRef }, ouiaProps, props, { children: children })));
3267
- };
3268
- const DropdownItem = forwardRef((props, ref) => (jsx(DropdownItemBase, Object.assign({}, props, { innerRef: ref }))));
3269
- DropdownItem.displayName = 'DropdownItem';
3270
-
3271
- const DropdownList = (_a) => {
3272
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
3273
- return (jsx(MenuList, Object.assign({ className: css(className) }, props, { children: children })));
3274
- };
3275
- DropdownList.displayName = 'DropdownList';
3276
-
3277
- const AngleDownIconConfig = {
3278
- name: 'AngleDownIcon',
3279
- height: 512,
3280
- width: 320,
3281
- svgPath: 'M143 352.3L7 216.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.2 9.4-24.4 9.4-33.8 0z',
3282
- yOffset: 0,
3283
- xOffset: 0,
3284
- };
3285
-
3286
- const AngleDownIcon = createIcon(AngleDownIconConfig);
3287
-
3288
- export { ASTERISK as A, CaretDownIcon as C, Divider as D, GenerateId as G, MenuToggle as M, Popper as P, StarIcon as S, TimesIcon as T, AngleDownIcon as a, Dropdown as b, DropdownList as c, DropdownItem as d, Tooltip as e, checkStyles as f, Checkbox as g, handleArrows as h, menuStyles as m, setTabIndex as s, useIsomorphicLayoutEffect as u };