@primer/react 0.0.0-20260225200721 → 0.0.0-20260225210238
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/ActionBar/ActionBar.d.ts.map +1 -1
- package/dist/ActionBar/ActionBar.js +131 -134
- package/dist/utils/descendant-registry.d.ts +1 -3
- package/dist/utils/descendant-registry.d.ts.map +1 -1
- package/dist/utils/descendant-registry.js +9 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../src/ActionBar/ActionBar.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../src/ActionBar/ActionBar.tsx"],"names":[],"mappings":"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"}
|
|
@@ -398,33 +398,28 @@ const ActionBar = props => {
|
|
|
398
398
|
};
|
|
399
399
|
function useWidth(ref) {
|
|
400
400
|
const $ = c(3);
|
|
401
|
-
const
|
|
401
|
+
const [width, setWidth] = useState(-1);
|
|
402
402
|
let t0;
|
|
403
|
+
let t1;
|
|
403
404
|
if ($[0] !== ref) {
|
|
404
405
|
t0 = () => {
|
|
405
|
-
var _ref$current;
|
|
406
|
-
|
|
407
|
-
if (width) {
|
|
408
|
-
widthRef.current = width;
|
|
409
|
-
}
|
|
406
|
+
var _ref$current$getBound, _ref$current;
|
|
407
|
+
return setWidth((_ref$current$getBound = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().width) !== null && _ref$current$getBound !== void 0 ? _ref$current$getBound : -1);
|
|
410
408
|
};
|
|
409
|
+
t1 = [ref];
|
|
411
410
|
$[0] = ref;
|
|
412
411
|
$[1] = t0;
|
|
413
|
-
} else {
|
|
414
|
-
t0 = $[1];
|
|
415
|
-
}
|
|
416
|
-
let t1;
|
|
417
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
418
|
-
t1 = [];
|
|
419
412
|
$[2] = t1;
|
|
420
413
|
} else {
|
|
414
|
+
t0 = $[1];
|
|
421
415
|
t1 = $[2];
|
|
422
416
|
}
|
|
423
417
|
useIsomorphicLayoutEffect(t0, t1);
|
|
424
|
-
return
|
|
418
|
+
return width;
|
|
425
419
|
}
|
|
426
420
|
const ActionBarIconButton = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
427
|
-
|
|
421
|
+
var _props$ariaLabel;
|
|
422
|
+
const $ = c(19);
|
|
428
423
|
let disabled;
|
|
429
424
|
let onClick;
|
|
430
425
|
let props;
|
|
@@ -452,54 +447,56 @@ const ActionBarIconButton = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
452
447
|
const {
|
|
453
448
|
groupId
|
|
454
449
|
} = React.useContext(ActionBarGroupContext);
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
450
|
+
const width = useWidth(ref);
|
|
451
|
+
const t1 = (_props$ariaLabel = props["aria-label"]) !== null && _props$ariaLabel !== void 0 ? _props$ariaLabel : "";
|
|
452
|
+
const t2 = !!disabled;
|
|
453
|
+
const t3 = onClick;
|
|
454
|
+
const t4 = groupId !== null && groupId !== void 0 ? groupId : undefined;
|
|
455
|
+
let t5;
|
|
456
|
+
if ($[4] !== props.icon || $[5] !== t1 || $[6] !== t2 || $[7] !== t3 || $[8] !== t4 || $[9] !== width) {
|
|
457
|
+
t5 = {
|
|
458
|
+
type: "action",
|
|
459
|
+
label: t1,
|
|
460
|
+
icon: props.icon,
|
|
461
|
+
disabled: t2,
|
|
462
|
+
onClick: t3,
|
|
463
|
+
width,
|
|
464
|
+
groupId: t4
|
|
469
465
|
};
|
|
470
|
-
$[4] =
|
|
471
|
-
$[5] =
|
|
472
|
-
$[6] =
|
|
473
|
-
$[7] =
|
|
474
|
-
$[8] =
|
|
475
|
-
$[9] =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
466
|
+
$[4] = props.icon;
|
|
467
|
+
$[5] = t1;
|
|
468
|
+
$[6] = t2;
|
|
469
|
+
$[7] = t3;
|
|
470
|
+
$[8] = t4;
|
|
471
|
+
$[9] = width;
|
|
472
|
+
$[10] = t5;
|
|
473
|
+
} else {
|
|
474
|
+
t5 = $[10];
|
|
475
|
+
}
|
|
476
|
+
const registryProps = t5;
|
|
477
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
478
|
+
let t6;
|
|
479
|
+
if ($[11] !== disabled || $[12] !== onClick) {
|
|
480
|
+
t6 = event => {
|
|
484
481
|
var _onClick;
|
|
485
482
|
if (disabled) {
|
|
486
483
|
return;
|
|
487
484
|
}
|
|
488
485
|
(_onClick = onClick) === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
489
486
|
};
|
|
490
|
-
$[
|
|
491
|
-
$[
|
|
492
|
-
$[
|
|
487
|
+
$[11] = disabled;
|
|
488
|
+
$[12] = onClick;
|
|
489
|
+
$[13] = t6;
|
|
493
490
|
} else {
|
|
494
|
-
|
|
491
|
+
t6 = $[13];
|
|
495
492
|
}
|
|
496
|
-
const clickHandler =
|
|
493
|
+
const clickHandler = t6;
|
|
497
494
|
if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) {
|
|
498
495
|
return null;
|
|
499
496
|
}
|
|
500
|
-
let
|
|
501
|
-
if ($[
|
|
502
|
-
|
|
497
|
+
let t7;
|
|
498
|
+
if ($[14] !== clickHandler || $[15] !== disabled || $[16] !== props || $[17] !== size) {
|
|
499
|
+
t7 = /*#__PURE__*/jsx(IconButton, {
|
|
503
500
|
"aria-disabled": disabled,
|
|
504
501
|
ref: ref,
|
|
505
502
|
size: size,
|
|
@@ -507,15 +504,15 @@ const ActionBarIconButton = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
507
504
|
...props,
|
|
508
505
|
variant: "invisible"
|
|
509
506
|
});
|
|
510
|
-
$[
|
|
511
|
-
$[
|
|
512
|
-
$[
|
|
513
|
-
$[
|
|
514
|
-
$[
|
|
507
|
+
$[14] = clickHandler;
|
|
508
|
+
$[15] = disabled;
|
|
509
|
+
$[16] = props;
|
|
510
|
+
$[17] = size;
|
|
511
|
+
$[18] = t7;
|
|
515
512
|
} else {
|
|
516
|
-
|
|
513
|
+
t7 = $[18];
|
|
517
514
|
}
|
|
518
|
-
return
|
|
515
|
+
return t7;
|
|
519
516
|
});
|
|
520
517
|
const ActionBarGroupContext = /*#__PURE__*/React.createContext({
|
|
521
518
|
groupId: null
|
|
@@ -527,20 +524,20 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
527
524
|
} = t0;
|
|
528
525
|
const backupRef = useRef(null);
|
|
529
526
|
const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
530
|
-
const
|
|
527
|
+
const width = useWidth(ref);
|
|
531
528
|
let t1;
|
|
532
|
-
if ($[0] !==
|
|
533
|
-
t1 =
|
|
529
|
+
if ($[0] !== width) {
|
|
530
|
+
t1 = {
|
|
534
531
|
type: "group",
|
|
535
|
-
width
|
|
536
|
-
}
|
|
537
|
-
$[0] =
|
|
532
|
+
width
|
|
533
|
+
};
|
|
534
|
+
$[0] = width;
|
|
538
535
|
$[1] = t1;
|
|
539
536
|
} else {
|
|
540
537
|
t1 = $[1];
|
|
541
538
|
}
|
|
542
539
|
const registryProps = t1;
|
|
543
|
-
const id = ActionBarItemsRegistry.
|
|
540
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
544
541
|
let t2;
|
|
545
542
|
if ($[2] !== id) {
|
|
546
543
|
t2 = {
|
|
@@ -579,7 +576,7 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
579
576
|
return t4;
|
|
580
577
|
});
|
|
581
578
|
const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
582
|
-
const $ = c(
|
|
579
|
+
const $ = c(31);
|
|
583
580
|
let ariaLabel;
|
|
584
581
|
let icon;
|
|
585
582
|
let items;
|
|
@@ -616,35 +613,35 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
616
613
|
isVisibleChild
|
|
617
614
|
} = React.useContext(ActionBarContext);
|
|
618
615
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
616
|
+
const width = useWidth(ref);
|
|
617
|
+
const t1 = overflowIcon ? overflowIcon : icon;
|
|
618
|
+
let t2;
|
|
619
|
+
if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
|
|
620
|
+
t2 = {
|
|
623
621
|
type: "menu",
|
|
624
|
-
width
|
|
622
|
+
width,
|
|
625
623
|
label: ariaLabel,
|
|
626
|
-
icon:
|
|
624
|
+
icon: t1,
|
|
627
625
|
returnFocusRef,
|
|
628
626
|
items
|
|
629
|
-
}
|
|
627
|
+
};
|
|
630
628
|
$[7] = ariaLabel;
|
|
631
|
-
$[8] =
|
|
632
|
-
$[9] =
|
|
633
|
-
$[10] =
|
|
634
|
-
$[11] =
|
|
635
|
-
$[12] =
|
|
636
|
-
$[13] = t1;
|
|
629
|
+
$[8] = items;
|
|
630
|
+
$[9] = returnFocusRef;
|
|
631
|
+
$[10] = t1;
|
|
632
|
+
$[11] = width;
|
|
633
|
+
$[12] = t2;
|
|
637
634
|
} else {
|
|
638
|
-
|
|
635
|
+
t2 = $[12];
|
|
639
636
|
}
|
|
640
|
-
const registryProps =
|
|
641
|
-
const id = ActionBarItemsRegistry.
|
|
637
|
+
const registryProps = t2;
|
|
638
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
642
639
|
if (!isVisibleChild(id)) {
|
|
643
640
|
return null;
|
|
644
641
|
}
|
|
645
|
-
let
|
|
646
|
-
if ($[
|
|
647
|
-
|
|
642
|
+
let t3;
|
|
643
|
+
if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
|
|
644
|
+
t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
|
|
648
645
|
children: /*#__PURE__*/jsx(IconButton, {
|
|
649
646
|
variant: "invisible",
|
|
650
647
|
"aria-label": ariaLabel,
|
|
@@ -652,70 +649,70 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
652
649
|
...props
|
|
653
650
|
})
|
|
654
651
|
});
|
|
655
|
-
$[
|
|
656
|
-
$[
|
|
657
|
-
$[
|
|
658
|
-
$[
|
|
652
|
+
$[13] = ariaLabel;
|
|
653
|
+
$[14] = icon;
|
|
654
|
+
$[15] = props;
|
|
655
|
+
$[16] = t3;
|
|
659
656
|
} else {
|
|
660
|
-
|
|
657
|
+
t3 = $[16];
|
|
661
658
|
}
|
|
662
|
-
let
|
|
663
|
-
if ($[
|
|
664
|
-
|
|
659
|
+
let t4;
|
|
660
|
+
if ($[17] !== returnFocusRef) {
|
|
661
|
+
t4 = returnFocusRef && {
|
|
665
662
|
returnFocusRef
|
|
666
663
|
};
|
|
667
|
-
$[
|
|
668
|
-
$[
|
|
669
|
-
} else {
|
|
670
|
-
t3 = $[19];
|
|
671
|
-
}
|
|
672
|
-
let t4;
|
|
673
|
-
if ($[20] !== items) {
|
|
674
|
-
t4 = items.map(_temp4);
|
|
675
|
-
$[20] = items;
|
|
676
|
-
$[21] = t4;
|
|
664
|
+
$[17] = returnFocusRef;
|
|
665
|
+
$[18] = t4;
|
|
677
666
|
} else {
|
|
678
|
-
t4 = $[
|
|
667
|
+
t4 = $[18];
|
|
679
668
|
}
|
|
680
669
|
let t5;
|
|
681
|
-
if ($[
|
|
682
|
-
t5 =
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
$[22] = t4;
|
|
686
|
-
$[23] = t5;
|
|
670
|
+
if ($[19] !== items) {
|
|
671
|
+
t5 = items.map(_temp4);
|
|
672
|
+
$[19] = items;
|
|
673
|
+
$[20] = t5;
|
|
687
674
|
} else {
|
|
688
|
-
t5 = $[
|
|
675
|
+
t5 = $[20];
|
|
689
676
|
}
|
|
690
677
|
let t6;
|
|
691
|
-
if ($[
|
|
692
|
-
t6 = /*#__PURE__*/jsx(
|
|
693
|
-
...t3,
|
|
678
|
+
if ($[21] !== t5) {
|
|
679
|
+
t6 = /*#__PURE__*/jsx(ActionList, {
|
|
694
680
|
children: t5
|
|
695
681
|
});
|
|
696
|
-
$[
|
|
697
|
-
$[
|
|
698
|
-
$[26] = t6;
|
|
682
|
+
$[21] = t5;
|
|
683
|
+
$[22] = t6;
|
|
699
684
|
} else {
|
|
700
|
-
t6 = $[
|
|
685
|
+
t6 = $[22];
|
|
701
686
|
}
|
|
702
687
|
let t7;
|
|
703
|
-
if ($[
|
|
704
|
-
t7 = /*#__PURE__*/
|
|
688
|
+
if ($[23] !== t4 || $[24] !== t6) {
|
|
689
|
+
t7 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
|
|
690
|
+
...t4,
|
|
691
|
+
children: t6
|
|
692
|
+
});
|
|
693
|
+
$[23] = t4;
|
|
694
|
+
$[24] = t6;
|
|
695
|
+
$[25] = t7;
|
|
696
|
+
} else {
|
|
697
|
+
t7 = $[25];
|
|
698
|
+
}
|
|
699
|
+
let t8;
|
|
700
|
+
if ($[26] !== menuOpen || $[27] !== ref || $[28] !== t3 || $[29] !== t7) {
|
|
701
|
+
t8 = /*#__PURE__*/jsxs(ActionMenu, {
|
|
705
702
|
anchorRef: ref,
|
|
706
703
|
open: menuOpen,
|
|
707
704
|
onOpenChange: setMenuOpen,
|
|
708
|
-
children: [
|
|
705
|
+
children: [t3, t7]
|
|
709
706
|
});
|
|
710
|
-
$[
|
|
711
|
-
$[
|
|
712
|
-
$[
|
|
713
|
-
$[
|
|
714
|
-
$[
|
|
707
|
+
$[26] = menuOpen;
|
|
708
|
+
$[27] = ref;
|
|
709
|
+
$[28] = t3;
|
|
710
|
+
$[29] = t7;
|
|
711
|
+
$[30] = t8;
|
|
715
712
|
} else {
|
|
716
|
-
|
|
713
|
+
t8 = $[30];
|
|
717
714
|
}
|
|
718
|
-
return
|
|
715
|
+
return t8;
|
|
719
716
|
});
|
|
720
717
|
const VerticalDivider = () => {
|
|
721
718
|
const $ = c(3);
|
|
@@ -723,20 +720,20 @@ const VerticalDivider = () => {
|
|
|
723
720
|
const {
|
|
724
721
|
isVisibleChild
|
|
725
722
|
} = React.useContext(ActionBarContext);
|
|
726
|
-
const
|
|
723
|
+
const width = useWidth(ref);
|
|
727
724
|
let t0;
|
|
728
|
-
if ($[0] !==
|
|
729
|
-
t0 =
|
|
725
|
+
if ($[0] !== width) {
|
|
726
|
+
t0 = {
|
|
730
727
|
type: "divider",
|
|
731
|
-
width
|
|
732
|
-
}
|
|
733
|
-
$[0] =
|
|
728
|
+
width
|
|
729
|
+
};
|
|
730
|
+
$[0] = width;
|
|
734
731
|
$[1] = t0;
|
|
735
732
|
} else {
|
|
736
733
|
t0 = $[1];
|
|
737
734
|
}
|
|
738
735
|
const registryProps = t0;
|
|
739
|
-
const id = ActionBarItemsRegistry.
|
|
736
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
740
737
|
if (!isVisibleChild(id)) {
|
|
741
738
|
return null;
|
|
742
739
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Dispatch, type ReactNode } from 'react';
|
|
2
|
-
interface ProviderProps<T> {
|
|
2
|
+
export interface ProviderProps<T> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
/** State setter from `useRegistryState`. */
|
|
5
5
|
setRegistry: Dispatch<React.SetStateAction<ReadonlyMap<string, T> | undefined>>;
|
|
@@ -28,7 +28,5 @@ export declare function createDescendantRegistry<T>(): {
|
|
|
28
28
|
Provider: ({ children, setRegistry }: ProviderProps<T>) => import("react").JSX.Element;
|
|
29
29
|
useRegistryState: () => [ReadonlyMap<string, T> | undefined, Dispatch<import("react").SetStateAction<ReadonlyMap<string, T> | undefined>>];
|
|
30
30
|
useRegisterDescendant: (value: T) => string;
|
|
31
|
-
useRegisterDescendantCallback: (valueCallback: () => T) => string;
|
|
32
31
|
};
|
|
33
|
-
export {};
|
|
34
32
|
//# sourceMappingURL=descendant-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descendant-registry.d.ts","sourceRoot":"","sources":["../../src/utils/descendant-registry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAGd,
|
|
1
|
+
{"version":3,"file":"descendant-registry.d.ts","sourceRoot":"","sources":["../../src/utils/descendant-registry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAGd,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,EAAE,SAAS,CAAA;IACnB,4CAA4C;IAC5C,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAA;CAChF;AAQD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,CAAC;0CAgCG,aAAa,CAAC,CAAC,CAAC;;mCAfrB,CAAC;EA8FxC"}
|
|
@@ -38,12 +38,8 @@ function createDescendantRegistry() {
|
|
|
38
38
|
return useState();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
* `useRegisterDescendant` when you need to access a ref value or do some calculation to get the data that you want
|
|
44
|
-
* to register. The callback will be called during the effect phase. Ensure the callback is stable (`useCallback`).
|
|
45
|
-
*/
|
|
46
|
-
function useRegisterDescendantCallback(valueCallback) {
|
|
41
|
+
/** Register a descendant component with the registry. */
|
|
42
|
+
function useRegisterDescendant(value) {
|
|
47
43
|
const $ = c(16);
|
|
48
44
|
const {
|
|
49
45
|
register,
|
|
@@ -72,22 +68,22 @@ function createDescendantRegistry() {
|
|
|
72
68
|
}
|
|
73
69
|
useEffect(t0, t1);
|
|
74
70
|
let t2;
|
|
75
|
-
if ($[7] !== id || $[8] !== updateValue || $[9] !==
|
|
76
|
-
t2 = () => updateValue(id,
|
|
71
|
+
if ($[7] !== id || $[8] !== updateValue || $[9] !== value) {
|
|
72
|
+
t2 = () => updateValue(id, value);
|
|
77
73
|
$[7] = id;
|
|
78
74
|
$[8] = updateValue;
|
|
79
|
-
$[9] =
|
|
75
|
+
$[9] = value;
|
|
80
76
|
$[10] = t2;
|
|
81
77
|
} else {
|
|
82
78
|
t2 = $[10];
|
|
83
79
|
}
|
|
84
80
|
let t3;
|
|
85
|
-
if ($[11] !== id || $[12] !== key || $[13] !== updateValue || $[14] !==
|
|
86
|
-
t3 = [updateValue, id,
|
|
81
|
+
if ($[11] !== id || $[12] !== key || $[13] !== updateValue || $[14] !== value) {
|
|
82
|
+
t3 = [updateValue, id, value, key];
|
|
87
83
|
$[11] = id;
|
|
88
84
|
$[12] = key;
|
|
89
85
|
$[13] = updateValue;
|
|
90
|
-
$[14] =
|
|
86
|
+
$[14] = value;
|
|
91
87
|
$[15] = t3;
|
|
92
88
|
} else {
|
|
93
89
|
t3 = $[15];
|
|
@@ -95,21 +91,6 @@ function createDescendantRegistry() {
|
|
|
95
91
|
useEffect(t2, t3);
|
|
96
92
|
return id;
|
|
97
93
|
}
|
|
98
|
-
|
|
99
|
-
/** Simplified version of `useRegisterDescendantCallback` that allows directly passing a memoized value. */
|
|
100
|
-
function useRegisterDescendant(value) {
|
|
101
|
-
const $ = c(2);
|
|
102
|
-
let t0;
|
|
103
|
-
if ($[0] !== value) {
|
|
104
|
-
t0 = () => value;
|
|
105
|
-
$[0] = value;
|
|
106
|
-
$[1] = t0;
|
|
107
|
-
} else {
|
|
108
|
-
t0 = $[1];
|
|
109
|
-
}
|
|
110
|
-
const valueCallback = t0;
|
|
111
|
-
return useRegisterDescendantCallback(valueCallback);
|
|
112
|
-
}
|
|
113
94
|
const unsetValue = Symbol('unset');
|
|
114
95
|
|
|
115
96
|
/** Provide context for registering descendant components. This only needs to wrap `children`. */
|
|
@@ -234,8 +215,7 @@ function createDescendantRegistry() {
|
|
|
234
215
|
return {
|
|
235
216
|
Provider,
|
|
236
217
|
useRegistryState,
|
|
237
|
-
useRegisterDescendant
|
|
238
|
-
useRegisterDescendantCallback
|
|
218
|
+
useRegisterDescendant
|
|
239
219
|
};
|
|
240
220
|
}
|
|
241
221
|
|
package/package.json
CHANGED