@primer/react 38.32.0-rc.3ce9543fd → 38.32.0-rc.4bb4bba69

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.
@@ -22,10 +22,9 @@ import { getFirstChildElement, useRovingTabIndex } from "./useRovingTabIndex.js"
22
22
  import { useTypeahead } from "./useTypeahead.js";
23
23
  import { SkeletonAvatar } from "../SkeletonAvatar/SkeletonAvatar.js";
24
24
  import { SkeletonText } from "../SkeletonText/SkeletonText.js";
25
- import { c } from "react-compiler-runtime";
26
25
  import { clsx } from "clsx";
27
26
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
- import React, { useEffect } from "react";
27
+ import React, { useCallback, useEffect } from "react";
29
28
  import { ChevronDownIcon, ChevronRightIcon, FileDirectoryFillIcon, FileDirectoryOpenFillIcon } from "@primer/octicons-react";
30
29
  //#region src/TreeView/TreeView.tsx
31
30
  const RootContext = /*#__PURE__*/ React.createContext({
@@ -46,168 +45,79 @@ const ItemContext = /*#__PURE__*/ React.createContext({
46
45
  });
47
46
  const LoadingPlaceholderContext = /*#__PURE__*/ React.createContext(false);
48
47
  const TOGGLE_ICON_SIZE = 12;
49
- const Root = (t0) => {
50
- const $ = c(26);
51
- const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, children, flat, truncate: t1, className, style } = t0;
52
- const truncate = t1 === void 0 ? true : t1;
48
+ const Root = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, children, flat, truncate = true, className, style }) => {
53
49
  const containerRef = React.useRef(null);
54
50
  const mouseDownRef = React.useRef(false);
55
51
  const [ariaLiveMessage, setAriaLiveMessage] = React.useState("");
56
- let t2;
57
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
58
- t2 = (message) => {
59
- setAriaLiveMessage(message);
60
- };
61
- $[0] = t2;
62
- } else t2 = $[0];
63
- const announceUpdate = t2;
64
- let t3;
65
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
66
- t3 = () => {
67
- mouseDownRef.current = true;
68
- };
69
- $[1] = t3;
70
- } else t3 = $[1];
71
- const onMouseDown = t3;
72
- let t4;
73
- let t5;
74
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
75
- t4 = () => {
76
- const onMouseUp = function onMouseUp() {
77
- mouseDownRef.current = false;
78
- };
79
- document.addEventListener("mouseup", onMouseUp);
80
- return () => {
81
- document.removeEventListener("mouseup", onMouseUp);
82
- };
83
- };
84
- t5 = [];
85
- $[2] = t4;
86
- $[3] = t5;
87
- } else {
88
- t4 = $[2];
89
- t5 = $[3];
90
- }
91
- useEffect(t4, t5);
92
- let t6;
93
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
94
- t6 = {
95
- containerRef,
96
- mouseDownRef
97
- };
98
- $[4] = t6;
99
- } else t6 = $[4];
100
- useRovingTabIndex(t6);
101
- let t7;
102
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
103
- t7 = {
104
- containerRef,
105
- onFocusChange: _temp
52
+ const announceUpdate = React.useCallback((message) => {
53
+ setAriaLiveMessage(message);
54
+ }, []);
55
+ const onMouseDown = useCallback(() => {
56
+ mouseDownRef.current = true;
57
+ }, []);
58
+ useEffect(() => {
59
+ function onMouseUp() {
60
+ mouseDownRef.current = false;
61
+ }
62
+ document.addEventListener("mouseup", onMouseUp);
63
+ return () => {
64
+ document.removeEventListener("mouseup", onMouseUp);
106
65
  };
107
- $[5] = t7;
108
- } else t7 = $[5];
109
- useTypeahead(t7);
66
+ }, []);
67
+ useRovingTabIndex({
68
+ containerRef,
69
+ mouseDownRef
70
+ });
71
+ useTypeahead({
72
+ containerRef,
73
+ onFocusChange: (element) => {
74
+ if (element instanceof HTMLElement) element.focus();
75
+ }
76
+ });
110
77
  const pendingScrollRef = React.useRef(null);
111
- let t8;
112
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
113
- t8 = (element_0) => {
114
- if (!element_0) return;
115
- if (pendingScrollRef.current !== null) cancelAnimationFrame(pendingScrollRef.current);
116
- pendingScrollRef.current = requestAnimationFrame(() => {
117
- pendingScrollRef.current = null;
118
- if (!element_0.isConnected) return;
119
- element_0.scrollIntoView({
120
- block: "nearest",
121
- inline: "nearest"
122
- });
78
+ const scrollElementIntoView = useCallback((element) => {
79
+ if (!element) return;
80
+ if (pendingScrollRef.current !== null) cancelAnimationFrame(pendingScrollRef.current);
81
+ pendingScrollRef.current = requestAnimationFrame(() => {
82
+ pendingScrollRef.current = null;
83
+ if (!element.isConnected) return;
84
+ element.scrollIntoView({
85
+ block: "nearest",
86
+ inline: "nearest"
123
87
  });
124
- };
125
- $[6] = t8;
126
- } else t8 = $[6];
127
- const scrollElementIntoView = t8;
128
- let t10;
129
- let t9;
130
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
131
- t9 = () => () => {
88
+ });
89
+ }, []);
90
+ useEffect(() => {
91
+ return () => {
132
92
  if (pendingScrollRef.current !== null) cancelAnimationFrame(pendingScrollRef.current);
133
93
  };
134
- t10 = [];
135
- $[7] = t10;
136
- $[8] = t9;
137
- } else {
138
- t10 = $[7];
139
- t9 = $[8];
140
- }
141
- useEffect(t9, t10);
94
+ }, []);
142
95
  const expandedStateCache = React.useRef(null);
143
- if (expandedStateCache.current === null) {
144
- let t11;
145
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
146
- t11 = /* @__PURE__ */ new Map();
147
- $[9] = t11;
148
- } else t11 = $[9];
149
- expandedStateCache.current = t11;
150
- }
151
- let t11;
152
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
153
- t11 = {
96
+ if (expandedStateCache.current === null) expandedStateCache.current = /* @__PURE__ */ new Map();
97
+ return /*#__PURE__*/ jsx(RootContext.Provider, {
98
+ value: {
154
99
  announceUpdate,
155
100
  expandedStateCache,
156
101
  scrollElementIntoView
157
- };
158
- $[10] = t11;
159
- } else t11 = $[10];
160
- let t12;
161
- if ($[11] !== ariaLiveMessage) {
162
- t12 = /*#__PURE__*/ jsx(VisuallyHidden, { children: /*#__PURE__*/ jsx(AriaStatus, {
102
+ },
103
+ children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx(VisuallyHidden, { children: /*#__PURE__*/ jsx(AriaStatus, {
163
104
  announceOnShow: true,
164
105
  children: ariaLiveMessage
165
- }) });
166
- $[11] = ariaLiveMessage;
167
- $[12] = t12;
168
- } else t12 = $[12];
169
- const t13 = truncate || false;
170
- let t14;
171
- if ($[13] !== className) {
172
- t14 = clsx(className, TreeView_module_css_default.TreeViewRootUlStyles);
173
- $[13] = className;
174
- $[14] = t14;
175
- } else t14 = $[14];
176
- let t15;
177
- if ($[15] !== ariaLabel || $[16] !== ariaLabelledby || $[17] !== children || $[18] !== flat || $[19] !== style || $[20] !== t13 || $[21] !== t14) {
178
- t15 = /*#__PURE__*/ jsx("ul", {
106
+ }) }), /*#__PURE__*/ jsx("ul", {
179
107
  ref: containerRef,
180
108
  role: "tree",
181
109
  "aria-label": ariaLabel,
182
110
  "aria-labelledby": ariaLabelledby,
183
111
  "data-omit-spacer": flat,
184
- "data-truncate-text": t13,
112
+ "data-truncate-text": truncate || false,
185
113
  onMouseDown,
186
- className: t14,
114
+ className: clsx(className, TreeView_module_css_default.TreeViewRootUlStyles),
187
115
  style,
188
116
  children
189
- });
190
- $[15] = ariaLabel;
191
- $[16] = ariaLabelledby;
192
- $[17] = children;
193
- $[18] = flat;
194
- $[19] = style;
195
- $[20] = t13;
196
- $[21] = t14;
197
- $[22] = t15;
198
- } else t15 = $[22];
199
- let t16;
200
- if ($[23] !== t12 || $[24] !== t15) {
201
- t16 = /*#__PURE__*/ jsx(RootContext.Provider, {
202
- value: t11,
203
- children: /*#__PURE__*/ jsxs(Fragment, { children: [t12, t15] })
204
- });
205
- $[23] = t12;
206
- $[24] = t15;
207
- $[25] = t16;
208
- } else t16 = $[25];
209
- return t16;
117
+ })] })
118
+ });
210
119
  };
120
+ Root.displayName = "Root";
211
121
  Root.displayName = "TreeView";
212
122
  const ItemImpl = fixedForwardRef(({ id: itemId, containIntrinsicSize, current: isCurrentItem = false, defaultExpanded, expanded, onExpandedChange, onSelect, children, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, secondaryActions, as: Component, ...restProps }, ref) => {
213
123
  const ItemElement = Component !== null && Component !== void 0 ? Component : "li";
@@ -390,31 +300,17 @@ const ItemImpl = fixedForwardRef(({ id: itemId, containIntrinsicSize, current: i
390
300
  });
391
301
  const Item = Object.assign(ItemImpl, { displayName: "TreeView.Item" });
392
302
  /** Lines to indicate the depth of an item in a TreeView */
393
- const LevelIndicatorLines = (t0) => {
394
- const $ = c(3);
395
- const { level } = t0;
396
- let t1;
397
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
398
- t1 = {
303
+ const LevelIndicatorLines = ({ level }) => {
304
+ return /*#__PURE__*/ jsx("div", {
305
+ style: {
399
306
  width: "100%",
400
307
  display: "flex"
401
- };
402
- $[0] = t1;
403
- } else t1 = $[0];
404
- let t2;
405
- if ($[1] !== level) {
406
- t2 = /*#__PURE__*/ jsx("div", {
407
- style: t1,
408
- children: Array.from({ length: level - 1 }).map(_temp2)
409
- });
410
- $[1] = level;
411
- $[2] = t2;
412
- } else t2 = $[2];
413
- return t2;
308
+ },
309
+ children: Array.from({ length: level - 1 }).map((_, index) => /*#__PURE__*/ jsx("div", { className: clsx("PRIVATE_TreeView-item-level-line", TreeView_module_css_default.TreeViewItemLevelLine) }, index))
310
+ });
414
311
  };
415
- const SubTree = (t0) => {
416
- const $ = c(29);
417
- const { count, state, children, "aria-label": ariaLabel } = t0;
312
+ LevelIndicatorLines.displayName = "LevelIndicatorLines";
313
+ const SubTree = ({ count, state, children, "aria-label": ariaLabel }) => {
418
314
  const { announceUpdate } = React.useContext(RootContext);
419
315
  const { itemId, isExpanded, isSubTreeEmpty, setIsSubTreeEmpty } = React.useContext(ItemContext);
420
316
  const loadingItemRef = React.useRef(null);
@@ -423,151 +319,80 @@ const SubTree = (t0) => {
423
319
  const [subTreeLabel, setSubTreeLabel] = React.useState("");
424
320
  const previousState = usePreviousValue(state);
425
321
  const { safeSetTimeout } = useSafeTimeout();
426
- let t1;
427
- let t2;
428
- if ($[0] !== children || $[1] !== isSubTreeEmpty || $[2] !== setIsSubTreeEmpty || $[3] !== state) {
429
- t1 = () => {
430
- if (state === void 0 || state === "done") {
431
- if (!isSubTreeEmpty && !children) setIsSubTreeEmpty(true);
432
- else if (isSubTreeEmpty && children) setIsSubTreeEmpty(false);
433
- }
434
- };
435
- t2 = [
436
- state,
437
- isSubTreeEmpty,
438
- setIsSubTreeEmpty,
439
- children
440
- ];
441
- $[0] = children;
442
- $[1] = isSubTreeEmpty;
443
- $[2] = setIsSubTreeEmpty;
444
- $[3] = state;
445
- $[4] = t1;
446
- $[5] = t2;
447
- } else {
448
- t1 = $[4];
449
- t2 = $[5];
450
- }
451
- React.useEffect(t1, t2);
452
- let t3;
453
- let t4;
454
- if ($[6] !== announceUpdate || $[7] !== itemId || $[8] !== loadingFocused || $[9] !== previousState || $[10] !== safeSetTimeout || $[11] !== state) {
455
- t3 = () => {
456
- const parentElement = document.getElementById(itemId);
457
- if (!parentElement) return;
458
- setSubTreeLabel(getAccessibleName(parentElement));
459
- if (previousState === "loading" && state === "done") {
460
- var _ref$current;
461
- const parentName = getAccessibleName(parentElement);
462
- if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.childElementCount) announceUpdate(`${parentName} content loaded`);
463
- else announceUpdate(`${parentName} is empty`);
464
- if (loadingFocused) {
465
- const firstChild = getFirstChildElement(parentElement);
466
- if (firstChild) safeSetTimeout(() => {
467
- firstChild.focus();
468
- });
469
- else safeSetTimeout(() => {
470
- parentElement.focus();
471
- });
472
- setLoadingFocused(false);
473
- }
474
- } else if (state === "loading") announceUpdate(`${getAccessibleName(parentElement)} content loading`);
475
- };
476
- t4 = [
477
- loadingFocused,
478
- previousState,
479
- state,
480
- itemId,
481
- announceUpdate,
482
- ref,
483
- safeSetTimeout
484
- ];
485
- $[6] = announceUpdate;
486
- $[7] = itemId;
487
- $[8] = loadingFocused;
488
- $[9] = previousState;
489
- $[10] = safeSetTimeout;
490
- $[11] = state;
491
- $[12] = t3;
492
- $[13] = t4;
493
- } else {
494
- t3 = $[12];
495
- t4 = $[13];
496
- }
497
- React.useEffect(t3, t4);
498
- let t5;
499
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
500
- t5 = () => {
501
- const handleFocus = function handleFocus() {
502
- setLoadingFocused(true);
503
- };
504
- const handleBlur = function handleBlur(event) {
505
- if (!event.relatedTarget) return;
322
+ React.useEffect(() => {
323
+ if (state === void 0 || state === "done") {
324
+ if (!isSubTreeEmpty && !children) setIsSubTreeEmpty(true);
325
+ else if (isSubTreeEmpty && children) setIsSubTreeEmpty(false);
326
+ }
327
+ }, [
328
+ state,
329
+ isSubTreeEmpty,
330
+ setIsSubTreeEmpty,
331
+ children
332
+ ]);
333
+ React.useEffect(() => {
334
+ const parentElement = document.getElementById(itemId);
335
+ if (!parentElement) return;
336
+ setSubTreeLabel(getAccessibleName(parentElement));
337
+ if (previousState === "loading" && state === "done") {
338
+ var _ref$current;
339
+ const parentName = getAccessibleName(parentElement);
340
+ if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.childElementCount) announceUpdate(`${parentName} content loaded`);
341
+ else announceUpdate(`${parentName} is empty`);
342
+ if (loadingFocused) {
343
+ const firstChild = getFirstChildElement(parentElement);
344
+ if (firstChild) safeSetTimeout(() => {
345
+ firstChild.focus();
346
+ });
347
+ else safeSetTimeout(() => {
348
+ parentElement.focus();
349
+ });
506
350
  setLoadingFocused(false);
507
- };
508
- const loadingElement = loadingItemRef.current;
509
- if (!loadingElement) return;
510
- loadingElement.addEventListener("focus", handleFocus);
511
- loadingElement.addEventListener("blur", handleBlur);
512
- return () => {
513
- loadingElement.removeEventListener("focus", handleFocus);
514
- loadingElement.removeEventListener("blur", handleBlur);
515
- };
351
+ }
352
+ } else if (state === "loading") announceUpdate(`${getAccessibleName(parentElement)} content loading`);
353
+ }, [
354
+ loadingFocused,
355
+ previousState,
356
+ state,
357
+ itemId,
358
+ announceUpdate,
359
+ ref,
360
+ safeSetTimeout
361
+ ]);
362
+ React.useEffect(() => {
363
+ function handleFocus() {
364
+ setLoadingFocused(true);
365
+ }
366
+ function handleBlur(event) {
367
+ if (!event.relatedTarget) return;
368
+ setLoadingFocused(false);
369
+ }
370
+ const loadingElement = loadingItemRef.current;
371
+ if (!loadingElement) return;
372
+ loadingElement.addEventListener("focus", handleFocus);
373
+ loadingElement.addEventListener("blur", handleBlur);
374
+ return () => {
375
+ loadingElement.removeEventListener("focus", handleFocus);
376
+ loadingElement.removeEventListener("blur", handleBlur);
516
377
  };
517
- $[14] = t5;
518
- } else t5 = $[14];
519
- let t6;
520
- if ($[15] !== state) {
521
- t6 = [loadingItemRef, state];
522
- $[15] = state;
523
- $[16] = t6;
524
- } else t6 = $[16];
525
- React.useEffect(t5, t6);
378
+ }, [loadingItemRef, state]);
526
379
  if (!isExpanded) return null;
527
- let t7;
528
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
529
- t7 = {
380
+ return /*#__PURE__*/ jsxs("ul", {
381
+ role: "group",
382
+ style: {
530
383
  listStyle: "none",
531
384
  padding: 0,
532
385
  margin: 0
533
- };
534
- $[17] = t7;
535
- } else t7 = $[17];
536
- const t8 = ariaLabel || subTreeLabel;
537
- let t9;
538
- if ($[18] !== children || $[19] !== count || $[20] !== state) {
539
- t9 = state === "loading" ? /*#__PURE__*/ jsx(LoadingItem, {
386
+ },
387
+ ref,
388
+ "aria-label": ariaLabel || subTreeLabel,
389
+ children: [state === "loading" ? /*#__PURE__*/ jsx(LoadingItem, {
540
390
  ref: loadingItemRef,
541
391
  count
542
- }) : children;
543
- $[18] = children;
544
- $[19] = count;
545
- $[20] = state;
546
- $[21] = t9;
547
- } else t9 = $[21];
548
- let t10;
549
- if ($[22] !== isSubTreeEmpty || $[23] !== state) {
550
- t10 = isSubTreeEmpty && state !== "loading" ? /*#__PURE__*/ jsx(EmptyItem, {}) : null;
551
- $[22] = isSubTreeEmpty;
552
- $[23] = state;
553
- $[24] = t10;
554
- } else t10 = $[24];
555
- let t11;
556
- if ($[25] !== t10 || $[26] !== t8 || $[27] !== t9) {
557
- t11 = /*#__PURE__*/ jsxs("ul", {
558
- role: "group",
559
- style: t7,
560
- ref,
561
- "aria-label": t8,
562
- children: [t9, t10]
563
- });
564
- $[25] = t10;
565
- $[26] = t8;
566
- $[27] = t9;
567
- $[28] = t11;
568
- } else t11 = $[28];
569
- return t11;
392
+ }) : children, isSubTreeEmpty && state !== "loading" ? /*#__PURE__*/ jsx(EmptyItem, {}) : null]
393
+ });
570
394
  };
395
+ SubTree.displayName = "SubTree";
571
396
  SubTree.displayName = "TreeView.SubTree";
572
397
  SubTree.__SLOT__ = Symbol("TreeView.SubTree");
573
398
  function usePreviousValue(value) {
@@ -578,516 +403,238 @@ function usePreviousValue(value) {
578
403
  return ref.current;
579
404
  }
580
405
  const SkeletonItem = () => {
581
- const $ = c(1);
582
- let t0;
583
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
584
- t0 = /*#__PURE__*/ jsxs("span", {
585
- className: clsx(TreeView_module_css_default.TreeViewSkeletonItemContainerStyle, TreeView_module_css_default.TreeViewItemSkeleton, "PRIVATE_TreeView-item-skeleton"),
586
- children: [/*#__PURE__*/ jsx(SkeletonAvatar, {
587
- size: 16,
588
- square: true
589
- }), /*#__PURE__*/ jsx(SkeletonText, { className: TreeView_module_css_default.TreeItemSkeletonTextStyles })]
590
- });
591
- $[0] = t0;
592
- } else t0 = $[0];
593
- return t0;
406
+ return /*#__PURE__*/ jsxs("span", {
407
+ className: clsx(TreeView_module_css_default.TreeViewSkeletonItemContainerStyle, TreeView_module_css_default.TreeViewItemSkeleton, "PRIVATE_TreeView-item-skeleton"),
408
+ children: [/*#__PURE__*/ jsx(SkeletonAvatar, {
409
+ size: 16,
410
+ square: true
411
+ }), /*#__PURE__*/ jsx(SkeletonText, { className: TreeView_module_css_default.TreeItemSkeletonTextStyles })]
412
+ });
594
413
  };
595
- const LoadingItem = /*#__PURE__*/ React.forwardRef((t0, ref) => {
596
- const $ = c(15);
597
- const { count } = t0;
414
+ SkeletonItem.displayName = "SkeletonItem";
415
+ const LoadingItem = /*#__PURE__*/ React.forwardRef(({ count }, ref) => {
598
416
  const itemId = useId$1();
599
- if (count) {
600
- const t1 = ref;
601
- let t2;
602
- if ($[0] !== count) {
603
- t2 = Array.from({ length: count }).map(_temp3);
604
- $[0] = count;
605
- $[1] = t2;
606
- } else t2 = $[1];
607
- let t3;
608
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
609
- t3 = clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden);
610
- $[2] = t3;
611
- } else t3 = $[2];
612
- let t4;
613
- if ($[3] !== count) {
614
- t4 = /*#__PURE__*/ jsxs("div", {
615
- className: t3,
417
+ if (count) return /*#__PURE__*/ jsx(LoadingPlaceholderContext.Provider, {
418
+ value: true,
419
+ children: /*#__PURE__*/ jsxs(Item, {
420
+ id: itemId,
421
+ ref,
422
+ children: [Array.from({ length: count }).map((_, i) => {
423
+ return /*#__PURE__*/ jsx(SkeletonItem, { "aria-hidden": true }, i);
424
+ }), /*#__PURE__*/ jsxs("div", {
425
+ className: clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden),
616
426
  children: [
617
427
  "Loading ",
618
428
  count,
619
429
  " items"
620
430
  ]
621
- });
622
- $[3] = count;
623
- $[4] = t4;
624
- } else t4 = $[4];
625
- let t5;
626
- if ($[5] !== itemId || $[6] !== t1 || $[7] !== t2 || $[8] !== t4) {
627
- t5 = /*#__PURE__*/ jsx(LoadingPlaceholderContext.Provider, {
628
- value: true,
629
- children: /*#__PURE__*/ jsxs(Item, {
630
- id: itemId,
631
- ref: t1,
632
- children: [t2, t4]
633
- })
634
- });
635
- $[5] = itemId;
636
- $[6] = t1;
637
- $[7] = t2;
638
- $[8] = t4;
639
- $[9] = t5;
640
- } else t5 = $[9];
641
- return t5;
642
- }
643
- const t1 = ref;
644
- let t2;
645
- let t3;
646
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
647
- t2 = /*#__PURE__*/ jsx(LeadingVisual, { children: /*#__PURE__*/ jsx(Spinner, { size: "small" }) });
648
- t3 = /*#__PURE__*/ jsx(Text_default, {
649
- className: "fgColor-muted",
650
- children: "Loading..."
651
- });
652
- $[10] = t2;
653
- $[11] = t3;
654
- } else {
655
- t2 = $[10];
656
- t3 = $[11];
657
- }
658
- let t4;
659
- if ($[12] !== itemId || $[13] !== t1) {
660
- t4 = /*#__PURE__*/ jsx(LoadingPlaceholderContext.Provider, {
661
- value: true,
662
- children: /*#__PURE__*/ jsxs(Item, {
663
- id: itemId,
664
- ref: t1,
665
- children: [t2, t3]
666
- })
667
- });
668
- $[12] = itemId;
669
- $[13] = t1;
670
- $[14] = t4;
671
- } else t4 = $[14];
672
- return t4;
431
+ })]
432
+ })
433
+ });
434
+ return /*#__PURE__*/ jsx(LoadingPlaceholderContext.Provider, {
435
+ value: true,
436
+ children: /*#__PURE__*/ jsxs(Item, {
437
+ id: itemId,
438
+ ref,
439
+ children: [/*#__PURE__*/ jsx(LeadingVisual, { children: /*#__PURE__*/ jsx(Spinner, { size: "small" }) }), /*#__PURE__*/ jsx(Text_default, {
440
+ className: "fgColor-muted",
441
+ children: "Loading..."
442
+ })]
443
+ })
444
+ });
673
445
  });
674
446
  const EmptyItem = /*#__PURE__*/ React.forwardRef((props, ref) => {
675
- const $ = c(4);
676
- const t0 = useId$1();
677
- const t1 = ref;
678
- let t2;
679
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
680
- t2 = /*#__PURE__*/ jsx(Text_default, {
447
+ return /*#__PURE__*/ jsx(Item, {
448
+ expanded: null,
449
+ id: useId$1(),
450
+ ref,
451
+ children: /*#__PURE__*/ jsx(Text_default, {
681
452
  className: "fgColor-muted",
682
453
  children: "No items found"
683
- });
684
- $[0] = t2;
685
- } else t2 = $[0];
686
- let t3;
687
- if ($[1] !== t0 || $[2] !== t1) {
688
- t3 = /*#__PURE__*/ jsx(Item, {
689
- expanded: null,
690
- id: t0,
691
- ref: t1,
692
- children: t2
693
- });
694
- $[1] = t0;
695
- $[2] = t1;
696
- $[3] = t3;
697
- } else t3 = $[3];
698
- return t3;
454
+ })
455
+ });
699
456
  });
700
457
  function useSubTree(children) {
701
- const $ = c(8);
702
- let t0;
703
- if ($[0] !== children) {
704
- t0 = React.Children.toArray(children).find(_temp4);
705
- $[0] = children;
706
- $[1] = t0;
707
- } else t0 = $[1];
708
- const subTree = t0;
709
- let t1;
710
- if ($[2] !== children) {
711
- t1 = React.Children.toArray(children).filter(_temp5);
712
- $[2] = children;
713
- $[3] = t1;
714
- } else t1 = $[3];
715
- const childrenWithoutSubTree = t1;
716
- const t2 = Boolean(subTree);
717
- let t3;
718
- if ($[4] !== childrenWithoutSubTree || $[5] !== subTree || $[6] !== t2) {
719
- t3 = {
458
+ return React.useMemo(() => {
459
+ const subTree = React.Children.toArray(children).find((child) => /*#__PURE__*/ React.isValidElement(child) && (child.type === SubTree || isSlot(child, SubTree)));
460
+ return {
720
461
  subTree,
721
- childrenWithoutSubTree,
722
- hasSubTree: t2
462
+ childrenWithoutSubTree: React.Children.toArray(children).filter((child) => !(/*#__PURE__*/ React.isValidElement(child) && (child.type === SubTree || isSlot(child, SubTree)))),
463
+ hasSubTree: Boolean(subTree)
723
464
  };
724
- $[4] = childrenWithoutSubTree;
725
- $[5] = subTree;
726
- $[6] = t2;
727
- $[7] = t3;
728
- } else t3 = $[7];
729
- return t3;
730
- }
731
- function _temp5(child_0) {
732
- return !(/*#__PURE__*/ React.isValidElement(child_0) && (child_0.type === SubTree || isSlot(child_0, SubTree)));
733
- }
734
- function _temp4(child) {
735
- return /*#__PURE__*/ React.isValidElement(child) && (child.type === SubTree || isSlot(child, SubTree));
465
+ }, [children]);
736
466
  }
737
467
  const LeadingVisual = (props) => {
738
- const $ = c(13);
739
468
  const { isExpanded, leadingVisualId } = React.useContext(ItemContext);
740
- let t0;
741
- if ($[0] !== isExpanded || $[1] !== props.children) {
742
- t0 = typeof props.children === "function" ? props.children({ isExpanded }) : props.children;
743
- $[0] = isExpanded;
744
- $[1] = props.children;
745
- $[2] = t0;
746
- } else t0 = $[2];
747
- const children = t0;
748
- let t1;
749
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
750
- t1 = clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden);
751
- $[3] = t1;
752
- } else t1 = $[3];
753
- let t2;
754
- if ($[4] !== leadingVisualId || $[5] !== props.label) {
755
- t2 = /*#__PURE__*/ jsx("div", {
756
- className: t1,
757
- "aria-hidden": true,
758
- id: leadingVisualId,
759
- children: props.label
760
- });
761
- $[4] = leadingVisualId;
762
- $[5] = props.label;
763
- $[6] = t2;
764
- } else t2 = $[6];
765
- let t3;
766
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
767
- t3 = clsx("PRIVATE_TreeView-item-visual", TreeView_module_css_default.TreeViewItemVisual);
768
- $[7] = t3;
769
- } else t3 = $[7];
770
- let t4;
771
- if ($[8] !== children) {
772
- t4 = /*#__PURE__*/ jsx("div", {
773
- className: t3,
774
- "aria-hidden": true,
775
- children
776
- });
777
- $[8] = children;
778
- $[9] = t4;
779
- } else t4 = $[9];
780
- let t5;
781
- if ($[10] !== t2 || $[11] !== t4) {
782
- t5 = /*#__PURE__*/ jsxs(Fragment, { children: [t2, t4] });
783
- $[10] = t2;
784
- $[11] = t4;
785
- $[12] = t5;
786
- } else t5 = $[12];
787
- return t5;
469
+ const children = typeof props.children === "function" ? props.children({ isExpanded }) : props.children;
470
+ return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("div", {
471
+ className: clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden),
472
+ "aria-hidden": true,
473
+ id: leadingVisualId,
474
+ children: props.label
475
+ }), /*#__PURE__*/ jsx("div", {
476
+ className: clsx("PRIVATE_TreeView-item-visual", TreeView_module_css_default.TreeViewItemVisual),
477
+ "aria-hidden": true,
478
+ children
479
+ })] });
788
480
  };
789
481
  LeadingVisual.displayName = "TreeView.LeadingVisual";
790
482
  const TrailingVisual = (props) => {
791
- const $ = c(13);
792
483
  const { isExpanded, trailingVisualId } = React.useContext(ItemContext);
793
- let t0;
794
- if ($[0] !== isExpanded || $[1] !== props.children) {
795
- t0 = typeof props.children === "function" ? props.children({ isExpanded }) : props.children;
796
- $[0] = isExpanded;
797
- $[1] = props.children;
798
- $[2] = t0;
799
- } else t0 = $[2];
800
- const children = t0;
801
- let t1;
802
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
803
- t1 = clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden);
804
- $[3] = t1;
805
- } else t1 = $[3];
806
- let t2;
807
- if ($[4] !== props.label || $[5] !== trailingVisualId) {
808
- t2 = /*#__PURE__*/ jsx("div", {
809
- className: t1,
810
- "aria-hidden": true,
811
- id: trailingVisualId,
812
- children: props.label
813
- });
814
- $[4] = props.label;
815
- $[5] = trailingVisualId;
816
- $[6] = t2;
817
- } else t2 = $[6];
818
- let t3;
819
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
820
- t3 = clsx("PRIVATE_TreeView-item-visual", TreeView_module_css_default.TreeViewItemVisual);
821
- $[7] = t3;
822
- } else t3 = $[7];
823
- let t4;
824
- if ($[8] !== children) {
825
- t4 = /*#__PURE__*/ jsx("div", {
826
- className: t3,
827
- "aria-hidden": true,
828
- children
829
- });
830
- $[8] = children;
831
- $[9] = t4;
832
- } else t4 = $[9];
833
- let t5;
834
- if ($[10] !== t2 || $[11] !== t4) {
835
- t5 = /*#__PURE__*/ jsxs(Fragment, { children: [t2, t4] });
836
- $[10] = t2;
837
- $[11] = t4;
838
- $[12] = t5;
839
- } else t5 = $[12];
840
- return t5;
484
+ const children = typeof props.children === "function" ? props.children({ isExpanded }) : props.children;
485
+ return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("div", {
486
+ className: clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden),
487
+ "aria-hidden": true,
488
+ id: trailingVisualId,
489
+ children: props.label
490
+ }), /*#__PURE__*/ jsx("div", {
491
+ className: clsx("PRIVATE_TreeView-item-visual", TreeView_module_css_default.TreeViewItemVisual),
492
+ "aria-hidden": true,
493
+ children
494
+ })] });
841
495
  };
842
496
  TrailingVisual.displayName = "TreeView.TrailingVisual";
843
497
  const LeadingAction = (props) => {
844
- const $ = c(12);
845
498
  const { isExpanded } = React.useContext(ItemContext);
846
- let t0;
847
- if ($[0] !== isExpanded || $[1] !== props.children) {
848
- t0 = typeof props.children === "function" ? props.children({ isExpanded }) : props.children;
849
- $[0] = isExpanded;
850
- $[1] = props.children;
851
- $[2] = t0;
852
- } else t0 = $[2];
853
- const children = t0;
854
- let t1;
855
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
856
- t1 = clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden);
857
- $[3] = t1;
858
- } else t1 = $[3];
859
- let t2;
860
- if ($[4] !== props.label) {
861
- t2 = /*#__PURE__*/ jsx("div", {
862
- className: t1,
863
- "aria-hidden": true,
864
- children: props.label
865
- });
866
- $[4] = props.label;
867
- $[5] = t2;
868
- } else t2 = $[5];
869
- let t3;
870
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
871
- t3 = clsx("PRIVATE_TreeView-item-leading-action", TreeView_module_css_default.TreeViewItemLeadingAction);
872
- $[6] = t3;
873
- } else t3 = $[6];
874
- let t4;
875
- if ($[7] !== children) {
876
- t4 = /*#__PURE__*/ jsx("div", {
877
- className: t3,
878
- "aria-hidden": true,
879
- children
880
- });
881
- $[7] = children;
882
- $[8] = t4;
883
- } else t4 = $[8];
884
- let t5;
885
- if ($[9] !== t2 || $[10] !== t4) {
886
- t5 = /*#__PURE__*/ jsxs(Fragment, { children: [t2, t4] });
887
- $[9] = t2;
888
- $[10] = t4;
889
- $[11] = t5;
890
- } else t5 = $[11];
891
- return t5;
499
+ const children = typeof props.children === "function" ? props.children({ isExpanded }) : props.children;
500
+ return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("div", {
501
+ className: clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden),
502
+ "aria-hidden": true,
503
+ children: props.label
504
+ }), /*#__PURE__*/ jsx("div", {
505
+ className: clsx("PRIVATE_TreeView-item-leading-action", TreeView_module_css_default.TreeViewItemLeadingAction),
506
+ "aria-hidden": true,
507
+ children
508
+ })] });
892
509
  };
893
510
  LeadingAction.displayName = "TreeView.LeadingAction";
894
511
  const TrailingAction = (props) => {
895
- const $ = c(14);
896
512
  const { trailingActionId, itemId } = React.useContext(ItemContext);
897
513
  const { items, shortcutText } = props;
898
- let t0;
899
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
900
- t0 = clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden);
901
- $[0] = t0;
902
- } else t0 = $[0];
903
- let t1;
904
- if ($[1] !== shortcutText || $[2] !== trailingActionId) {
905
- t1 = /*#__PURE__*/ jsxs("div", {
906
- id: trailingActionId,
907
- className: t0,
908
- children: ["- ", shortcutText]
909
- });
910
- $[1] = shortcutText;
911
- $[2] = trailingActionId;
912
- $[3] = t1;
913
- } else t1 = $[3];
914
- let t2;
915
- if ($[4] !== itemId || $[5] !== items) {
916
- let t3;
917
- if ($[7] !== itemId) {
918
- t3 = (t4, index) => {
919
- const { label, onClick, icon, count, className } = t4;
920
- if (count) return /*#__PURE__*/ jsx(Tooltip, {
921
- text: label,
922
- children: /*#__PURE__*/ jsx(ButtonComponent, {
923
- "aria-label": label,
924
- leadingVisual: icon,
925
- variant: "invisible",
926
- className: clsx(className, TreeView_module_css_default.TreeViewItemTrailingActionButton),
927
- onClick,
928
- onKeyDown: () => {
929
- const parentElement = document.getElementById(itemId);
930
- parentElement === null || parentElement === void 0 || parentElement.focus();
931
- },
932
- tabIndex: -1,
933
- "aria-hidden": true,
934
- count
935
- })
936
- }, index);
937
- return /*#__PURE__*/ jsx(IconButton, {
938
- icon,
939
- variant: "invisible",
514
+ return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsxs("div", {
515
+ id: trailingActionId,
516
+ className: clsx("PRIVATE_VisuallyHidden", TreeView_module_css_default.TreeViewVisuallyHidden),
517
+ children: ["- ", shortcutText]
518
+ }), /*#__PURE__*/ jsx("div", {
519
+ className: TreeView_module_css_default.TreeViewItemTrailingAction,
520
+ "aria-hidden": true,
521
+ onClick: (event) => event.stopPropagation(),
522
+ onKeyDown: (event) => event.stopPropagation(),
523
+ children: items.map(({ label, onClick, icon, count, className }, index) => {
524
+ if (count) return /*#__PURE__*/ jsx(Tooltip, {
525
+ text: label,
526
+ children: /*#__PURE__*/ jsx(ButtonComponent, {
940
527
  "aria-label": label,
528
+ leadingVisual: icon,
529
+ variant: "invisible",
941
530
  className: clsx(className, TreeView_module_css_default.TreeViewItemTrailingActionButton),
942
531
  onClick,
532
+ onKeyDown: () => {
533
+ const parentElement = document.getElementById(itemId);
534
+ parentElement === null || parentElement === void 0 || parentElement.focus();
535
+ },
943
536
  tabIndex: -1,
944
537
  "aria-hidden": true,
945
- onKeyDown: () => {
946
- const parentElement_0 = document.getElementById(itemId);
947
- parentElement_0 === null || parentElement_0 === void 0 || parentElement_0.focus();
948
- }
949
- }, index);
950
- };
951
- $[7] = itemId;
952
- $[8] = t3;
953
- } else t3 = $[8];
954
- t2 = items.map(t3);
955
- $[4] = itemId;
956
- $[5] = items;
957
- $[6] = t2;
958
- } else t2 = $[6];
959
- let t3;
960
- if ($[9] !== t2) {
961
- t3 = /*#__PURE__*/ jsx("div", {
962
- className: TreeView_module_css_default.TreeViewItemTrailingAction,
963
- "aria-hidden": true,
964
- onClick: _temp6,
965
- onKeyDown: _temp7,
966
- children: t2
967
- });
968
- $[9] = t2;
969
- $[10] = t3;
970
- } else t3 = $[10];
971
- let t4;
972
- if ($[11] !== t1 || $[12] !== t3) {
973
- t4 = /*#__PURE__*/ jsxs(Fragment, { children: [t1, t3] });
974
- $[11] = t1;
975
- $[12] = t3;
976
- $[13] = t4;
977
- } else t4 = $[13];
978
- return t4;
538
+ count
539
+ })
540
+ }, index);
541
+ return /*#__PURE__*/ jsx(IconButton, {
542
+ icon,
543
+ variant: "invisible",
544
+ "aria-label": label,
545
+ className: clsx(className, TreeView_module_css_default.TreeViewItemTrailingActionButton),
546
+ onClick,
547
+ tabIndex: -1,
548
+ "aria-hidden": true,
549
+ onKeyDown: () => {
550
+ const parentElement = document.getElementById(itemId);
551
+ parentElement === null || parentElement === void 0 || parentElement.focus();
552
+ }
553
+ }, index);
554
+ })
555
+ })] });
979
556
  };
980
557
  TrailingAction.displayName = "TreeView.TrailingAction";
981
- const ActionDialog = (t0) => {
982
- const $ = c(10);
983
- const { items, onClose } = t0;
558
+ const ActionDialog = ({ items, onClose }) => {
984
559
  const { itemId } = React.useContext(ItemContext);
985
- let t1;
986
- if ($[0] !== itemId || $[1] !== onClose) {
987
- t1 = () => {
988
- if (onClose) onClose();
989
- setTimeout(() => {
990
- const parentElement = document.getElementById(itemId);
991
- parentElement === null || parentElement === void 0 || parentElement.focus();
992
- });
993
- };
994
- $[0] = itemId;
995
- $[1] = onClose;
996
- $[2] = t1;
997
- } else t1 = $[2];
998
- let t2;
999
- if ($[3] !== items) {
1000
- t2 = items.map(_temp0);
1001
- $[3] = items;
1002
- $[4] = t2;
1003
- } else t2 = $[4];
1004
- let t3;
1005
- if ($[5] !== t2) {
1006
- t3 = /*#__PURE__*/ jsx(ActionList, { children: t2 });
1007
- $[5] = t2;
1008
- $[6] = t3;
1009
- } else t3 = $[6];
1010
- let t4;
1011
- if ($[7] !== t1 || $[8] !== t3) {
1012
- t4 = /*#__PURE__*/ jsx("div", {
1013
- onClick: _temp8,
1014
- onKeyDown: _temp9,
1015
- children: /*#__PURE__*/ jsx(Dialog, {
1016
- title: "Supplemental actions",
1017
- onClose: t1,
1018
- children: t3
1019
- })
1020
- });
1021
- $[7] = t1;
1022
- $[8] = t3;
1023
- $[9] = t4;
1024
- } else t4 = $[9];
1025
- return t4;
560
+ return /*#__PURE__*/ jsx("div", {
561
+ onClick: (event) => {
562
+ event.stopPropagation();
563
+ },
564
+ onKeyDown: (event) => {
565
+ if ([
566
+ "Backspace",
567
+ "ArrowLeft",
568
+ "ArrowRight",
569
+ "ArrowUp",
570
+ "ArrowDown",
571
+ "Enter"
572
+ ].includes(event.key)) event.stopPropagation();
573
+ },
574
+ children: /*#__PURE__*/ jsx(Dialog, {
575
+ title: "Supplemental actions",
576
+ onClose: () => {
577
+ if (onClose) onClose();
578
+ setTimeout(() => {
579
+ const parentElement = document.getElementById(itemId);
580
+ parentElement === null || parentElement === void 0 || parentElement.focus();
581
+ });
582
+ },
583
+ children: /*#__PURE__*/ jsx(ActionList, { children: items.map(({ label, onClick, icon: Icon, count }, index) => /*#__PURE__*/ jsxs(ActionList.Item, {
584
+ onSelect: onClick,
585
+ children: [
586
+ /*#__PURE__*/ jsx(ActionList.LeadingVisual, { children: /*#__PURE__*/ jsx(Icon, {}) }),
587
+ label,
588
+ count ? /*#__PURE__*/ jsxs(ActionList.TrailingVisual, { children: [count, /*#__PURE__*/ jsx(VisuallyHidden, { children: "items" })] }) : null
589
+ ]
590
+ }, index)) })
591
+ })
592
+ });
1026
593
  };
594
+ ActionDialog.displayName = "ActionDialog";
1027
595
  ActionDialog.displayName = "TreeView.ActionDialog";
1028
596
  const DirectoryIcon = () => {
1029
- const $ = c(3);
1030
597
  const { isExpanded } = React.useContext(ItemContext);
1031
598
  const Icon = isExpanded ? FileDirectoryOpenFillIcon : FileDirectoryFillIcon;
1032
- let t0;
1033
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1034
- t0 = clsx("PRIVATE_TreeView-directory-icon", TreeView_module_css_default.TreeViewDirectoryIcon);
1035
- $[0] = t0;
1036
- } else t0 = $[0];
1037
- let t1;
1038
- if ($[1] !== Icon) {
1039
- t1 = /*#__PURE__*/ jsx("div", {
1040
- className: t0,
1041
- children: /*#__PURE__*/ jsx(Icon, {})
1042
- });
1043
- $[1] = Icon;
1044
- $[2] = t1;
1045
- } else t1 = $[2];
1046
- return t1;
599
+ return /*#__PURE__*/ jsx("div", {
600
+ className: clsx("PRIVATE_TreeView-directory-icon", TreeView_module_css_default.TreeViewDirectoryIcon),
601
+ children: /*#__PURE__*/ jsx(Icon, {})
602
+ });
1047
603
  };
1048
- const ErrorDialog = (t0) => {
1049
- const $ = c(9);
1050
- const { title: t1, children, onRetry, onDismiss } = t0;
1051
- const title = t1 === void 0 ? "Error" : t1;
604
+ DirectoryIcon.displayName = "DirectoryIcon";
605
+ const ErrorDialog = ({ title = "Error", children, onRetry, onDismiss }) => {
1052
606
  const { itemId, setIsExpanded } = React.useContext(ItemContext);
1053
- let t2;
1054
- if ($[0] !== itemId || $[1] !== onDismiss || $[2] !== onRetry || $[3] !== setIsExpanded) {
1055
- t2 = (gesture) => {
1056
- setTimeout(() => {
1057
- const parentElement = document.getElementById(itemId);
1058
- parentElement === null || parentElement === void 0 || parentElement.focus();
1059
- });
1060
- if (gesture === "confirm") onRetry === null || onRetry === void 0 || onRetry();
1061
- else {
1062
- setIsExpanded(false);
1063
- onDismiss === null || onDismiss === void 0 || onDismiss();
1064
- }
1065
- };
1066
- $[0] = itemId;
1067
- $[1] = onDismiss;
1068
- $[2] = onRetry;
1069
- $[3] = setIsExpanded;
1070
- $[4] = t2;
1071
- } else t2 = $[4];
1072
- let t3;
1073
- if ($[5] !== children || $[6] !== t2 || $[7] !== title) {
1074
- t3 = /*#__PURE__*/ jsx("div", {
1075
- onKeyDown: _temp1,
1076
- children: /*#__PURE__*/ jsx(ConfirmationDialog, {
1077
- title,
1078
- onClose: t2,
1079
- confirmButtonContent: "Retry",
1080
- cancelButtonContent: "Dismiss",
1081
- children
1082
- })
1083
- });
1084
- $[5] = children;
1085
- $[6] = t2;
1086
- $[7] = title;
1087
- $[8] = t3;
1088
- } else t3 = $[8];
1089
- return t3;
607
+ return /*#__PURE__*/ jsx("div", {
608
+ onKeyDown: (event) => {
609
+ if ([
610
+ "Backspace",
611
+ "ArrowLeft",
612
+ "ArrowRight",
613
+ "ArrowUp",
614
+ "ArrowDown",
615
+ "Enter"
616
+ ].includes(event.key)) event.stopPropagation();
617
+ },
618
+ children: /*#__PURE__*/ jsx(ConfirmationDialog, {
619
+ title,
620
+ onClose: (gesture) => {
621
+ setTimeout(() => {
622
+ const parentElement = document.getElementById(itemId);
623
+ parentElement === null || parentElement === void 0 || parentElement.focus();
624
+ });
625
+ if (gesture === "confirm") onRetry === null || onRetry === void 0 || onRetry();
626
+ else {
627
+ setIsExpanded(false);
628
+ onDismiss === null || onDismiss === void 0 || onDismiss();
629
+ }
630
+ },
631
+ confirmButtonContent: "Retry",
632
+ cancelButtonContent: "Dismiss",
633
+ children
634
+ })
635
+ });
1090
636
  };
637
+ ErrorDialog.displayName = "ErrorDialog";
1091
638
  ErrorDialog.displayName = "TreeView.ErrorDialog";
1092
639
  const TreeView = Object.assign(Root, {
1093
640
  Item,
@@ -1098,57 +645,5 @@ const TreeView = Object.assign(Root, {
1098
645
  DirectoryIcon,
1099
646
  ErrorDialog
1100
647
  });
1101
- function _temp(element) {
1102
- if (element instanceof HTMLElement) element.focus();
1103
- }
1104
- function _temp2(_, index) {
1105
- return /*#__PURE__*/ jsx("div", { className: clsx("PRIVATE_TreeView-item-level-line", TreeView_module_css_default.TreeViewItemLevelLine) }, index);
1106
- }
1107
- _temp2.displayName = "_temp2";
1108
- function _temp3(_, i) {
1109
- return /*#__PURE__*/ jsx(SkeletonItem, { "aria-hidden": true }, i);
1110
- }
1111
- _temp3.displayName = "_temp3";
1112
- function _temp6(event) {
1113
- return event.stopPropagation();
1114
- }
1115
- function _temp7(event_0) {
1116
- return event_0.stopPropagation();
1117
- }
1118
- function _temp8(event) {
1119
- event.stopPropagation();
1120
- }
1121
- function _temp9(event_0) {
1122
- if ([
1123
- "Backspace",
1124
- "ArrowLeft",
1125
- "ArrowRight",
1126
- "ArrowUp",
1127
- "ArrowDown",
1128
- "Enter"
1129
- ].includes(event_0.key)) event_0.stopPropagation();
1130
- }
1131
- function _temp0(t0, index) {
1132
- const { label, onClick, icon: Icon, count } = t0;
1133
- return /*#__PURE__*/ jsxs(ActionList.Item, {
1134
- onSelect: onClick,
1135
- children: [
1136
- /*#__PURE__*/ jsx(ActionList.LeadingVisual, { children: /*#__PURE__*/ jsx(Icon, {}) }),
1137
- label,
1138
- count ? /*#__PURE__*/ jsxs(ActionList.TrailingVisual, { children: [count, /*#__PURE__*/ jsx(VisuallyHidden, { children: "items" })] }) : null
1139
- ]
1140
- }, index);
1141
- }
1142
- _temp0.displayName = "_temp0";
1143
- function _temp1(event) {
1144
- if ([
1145
- "Backspace",
1146
- "ArrowLeft",
1147
- "ArrowRight",
1148
- "ArrowUp",
1149
- "ArrowDown",
1150
- "Enter"
1151
- ].includes(event.key)) event.stopPropagation();
1152
- }
1153
648
  //#endregion
1154
649
  export { TreeView };