@primer/react 38.16.0 → 38.17.0-rc.0f1e4e0c9
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 +16 -0
- package/dist/ActionList/LinkItem.d.ts +6 -3
- package/dist/ActionList/LinkItem.d.ts.map +1 -1
- package/dist/ActionList/LinkItem.js +42 -87
- package/dist/ActionList/index.d.ts +25 -1
- package/dist/ActionList/index.d.ts.map +1 -1
- package/dist/ActionMenu/{ActionMenu-53493541.css → ActionMenu-58362ca7.css} +2 -2
- package/dist/ActionMenu/ActionMenu-58362ca7.css.map +1 -0
- package/dist/ActionMenu/ActionMenu.d.ts.map +1 -1
- package/dist/ActionMenu/ActionMenu.js +4 -0
- package/dist/ActionMenu/ActionMenu.module.css.js +1 -1
- package/dist/Banner/Banner.js +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +23 -8
- package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.js +27 -65
- package/dist/Details/Details.js +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
- package/dist/NavList/NavList.d.ts +20 -3
- package/dist/NavList/NavList.d.ts.map +1 -1
- package/dist/NavList/NavList.js +50 -124
- package/dist/Overlay/{Overlay-2e0ce8db.css → Overlay-f81a131d.css} +2 -2
- package/dist/Overlay/Overlay-f81a131d.css.map +1 -0
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +35 -22
- package/dist/Overlay/Overlay.module.css.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useMergedRefs.d.ts +51 -0
- package/dist/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/hooks/useMergedRefs.js +86 -0
- package/dist/hooks/useProvidedRefOrCreate.d.ts +12 -0
- package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.js +12 -0
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts +12 -0
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
- package/dist/hooks/useRefObjectAsForwardedRef.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.d.ts.map +1 -1
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +17 -8
- package/generated/hooks.json +22 -0
- package/package.json +1 -1
- package/dist/ActionMenu/ActionMenu-53493541.css.map +0 -1
- package/dist/Overlay/Overlay-2e0ce8db.css.map +0 -1
- package/dist/internal/hooks/useMergedRefs.d.ts +0 -2
- package/dist/internal/hooks/useMergedRefs.d.ts.map +0 -1
- package/dist/internal/hooks/useMergedRefs.js +0 -16
package/dist/NavList/NavList.js
CHANGED
|
@@ -11,6 +11,7 @@ import classes from '../ActionList/ActionList.module.css.js';
|
|
|
11
11
|
import navListClasses from './NavList.module.css.js';
|
|
12
12
|
import { flushSync } from 'react-dom';
|
|
13
13
|
import { isSlot } from '../utils/is-slot.js';
|
|
14
|
+
import { fixedForwardRef } from '../utils/modern-polymorphic.js';
|
|
14
15
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
15
16
|
|
|
16
17
|
const Root = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
@@ -72,128 +73,59 @@ Root.displayName = 'NavList';
|
|
|
72
73
|
// ----------------------------------------------------------------------------
|
|
73
74
|
// NavList.Item
|
|
74
75
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
({
|
|
83
|
-
"aria-current": ariaCurrent,
|
|
84
|
-
children,
|
|
85
|
-
defaultOpen,
|
|
86
|
-
...props
|
|
87
|
-
} = t0);
|
|
88
|
-
$[0] = t0;
|
|
89
|
-
$[1] = ariaCurrent;
|
|
90
|
-
$[2] = children;
|
|
91
|
-
$[3] = defaultOpen;
|
|
92
|
-
$[4] = props;
|
|
93
|
-
} else {
|
|
94
|
-
ariaCurrent = $[1];
|
|
95
|
-
children = $[2];
|
|
96
|
-
defaultOpen = $[3];
|
|
97
|
-
props = $[4];
|
|
98
|
-
}
|
|
76
|
+
const ItemComponent = fixedForwardRef(({
|
|
77
|
+
'aria-current': ariaCurrent,
|
|
78
|
+
children,
|
|
79
|
+
defaultOpen,
|
|
80
|
+
as: Component,
|
|
81
|
+
...props
|
|
82
|
+
}, ref) => {
|
|
99
83
|
const {
|
|
100
84
|
depth
|
|
101
85
|
} = React.useContext(SubNavContext);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
$[7] = childrenWithoutSubNavOrTrailingAction;
|
|
123
|
-
$[8] = subNav;
|
|
124
|
-
$[9] = t1;
|
|
125
|
-
} else {
|
|
126
|
-
childrenWithoutSubNavOrTrailingAction = $[7];
|
|
127
|
-
subNav = $[8];
|
|
128
|
-
t1 = $[9];
|
|
129
|
-
}
|
|
130
|
-
if (t1) {
|
|
131
|
-
let t2;
|
|
132
|
-
if ($[12] !== depth) {
|
|
133
|
-
t2 = {
|
|
134
|
-
"--subitem-depth": depth
|
|
135
|
-
};
|
|
136
|
-
$[12] = depth;
|
|
137
|
-
$[13] = t2;
|
|
138
|
-
} else {
|
|
139
|
-
t2 = $[13];
|
|
140
|
-
}
|
|
141
|
-
const t3 = t2;
|
|
142
|
-
let t4;
|
|
143
|
-
if ($[14] !== childrenWithoutSubNavOrTrailingAction || $[15] !== defaultOpen || $[16] !== depth || $[17] !== subNav || $[18] !== t3) {
|
|
144
|
-
t4 = /*#__PURE__*/jsx(ItemWithSubNav, {
|
|
145
|
-
subNav: subNav,
|
|
146
|
-
depth: depth,
|
|
147
|
-
defaultOpen: defaultOpen,
|
|
148
|
-
style: t3,
|
|
149
|
-
children: childrenWithoutSubNavOrTrailingAction
|
|
150
|
-
});
|
|
151
|
-
$[14] = childrenWithoutSubNavOrTrailingAction;
|
|
152
|
-
$[15] = defaultOpen;
|
|
153
|
-
$[16] = depth;
|
|
154
|
-
$[17] = subNav;
|
|
155
|
-
$[18] = t3;
|
|
156
|
-
$[19] = t4;
|
|
157
|
-
} else {
|
|
158
|
-
t4 = $[19];
|
|
159
|
-
}
|
|
160
|
-
return t4;
|
|
161
|
-
}
|
|
162
|
-
const t2 = Boolean(ariaCurrent) && ariaCurrent !== "false";
|
|
163
|
-
let t3;
|
|
164
|
-
if ($[20] !== depth) {
|
|
165
|
-
t3 = {
|
|
166
|
-
"--subitem-depth": depth
|
|
167
|
-
};
|
|
168
|
-
$[20] = depth;
|
|
169
|
-
$[21] = t3;
|
|
170
|
-
} else {
|
|
171
|
-
t3 = $[21];
|
|
172
|
-
}
|
|
173
|
-
const t4 = t3;
|
|
174
|
-
let t5;
|
|
175
|
-
if ($[22] !== ariaCurrent || $[23] !== children || $[24] !== props || $[25] !== ref || $[26] !== t2 || $[27] !== t4) {
|
|
176
|
-
t5 = /*#__PURE__*/jsx(ActionList.LinkItem, {
|
|
177
|
-
ref: ref,
|
|
178
|
-
"aria-current": ariaCurrent,
|
|
179
|
-
active: t2,
|
|
180
|
-
style: t4,
|
|
181
|
-
...props,
|
|
182
|
-
children: children
|
|
86
|
+
|
|
87
|
+
// Get SubNav from children
|
|
88
|
+
const subNav = React.Children.toArray(children).find(child => /*#__PURE__*/isValidElement(child) && (child.type === SubNav || isSlot(child, SubNav)));
|
|
89
|
+
|
|
90
|
+
// Get children without SubNav or TrailingAction
|
|
91
|
+
const childrenWithoutSubNavOrTrailingAction = React.Children.toArray(children).filter(child => /*#__PURE__*/isValidElement(child) ? child.type !== SubNav && child.type !== TrailingAction && !isSlot(child, SubNav) && !isSlot(child, TrailingAction) : true);
|
|
92
|
+
if (! /*#__PURE__*/isValidElement(subNav) && defaultOpen)
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.error('NavList.Item must have a NavList.SubNav to use defaultOpen.');
|
|
95
|
+
|
|
96
|
+
// Render ItemWithSubNav if SubNav is present
|
|
97
|
+
if (subNav && /*#__PURE__*/isValidElement(subNav)) {
|
|
98
|
+
return /*#__PURE__*/jsx(ItemWithSubNav, {
|
|
99
|
+
subNav: subNav,
|
|
100
|
+
depth: depth,
|
|
101
|
+
defaultOpen: defaultOpen,
|
|
102
|
+
style: {
|
|
103
|
+
'--subitem-depth': depth
|
|
104
|
+
},
|
|
105
|
+
children: childrenWithoutSubNavOrTrailingAction
|
|
183
106
|
});
|
|
184
|
-
$[22] = ariaCurrent;
|
|
185
|
-
$[23] = children;
|
|
186
|
-
$[24] = props;
|
|
187
|
-
$[25] = ref;
|
|
188
|
-
$[26] = t2;
|
|
189
|
-
$[27] = t4;
|
|
190
|
-
$[28] = t5;
|
|
191
|
-
} else {
|
|
192
|
-
t5 = $[28];
|
|
193
107
|
}
|
|
194
|
-
|
|
108
|
+
|
|
109
|
+
// Type safety for the polymorphic `as` prop is enforced at the
|
|
110
|
+
// Item boundary via fixedForwardRef. Internally we widen
|
|
111
|
+
// LinkItem's type so TypeScript doesn't re-check the generic
|
|
112
|
+
// constraint across two polymorphic layers.
|
|
113
|
+
const InternalLinkItem = ActionList.LinkItem;
|
|
114
|
+
return /*#__PURE__*/jsx(InternalLinkItem, {
|
|
115
|
+
ref: ref,
|
|
116
|
+
as: Component,
|
|
117
|
+
"aria-current": ariaCurrent,
|
|
118
|
+
active: Boolean(ariaCurrent) && ariaCurrent !== 'false',
|
|
119
|
+
style: {
|
|
120
|
+
'--subitem-depth': depth
|
|
121
|
+
},
|
|
122
|
+
...props,
|
|
123
|
+
children: children
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
const Item = Object.assign(ItemComponent, {
|
|
127
|
+
displayName: 'NavList.Item'
|
|
195
128
|
});
|
|
196
|
-
Item.displayName = 'NavList.Item';
|
|
197
129
|
|
|
198
130
|
// ----------------------------------------------------------------------------
|
|
199
131
|
// ItemWithSubNav (internal)
|
|
@@ -259,7 +191,7 @@ function ItemWithSubNav(t0) {
|
|
|
259
191
|
const t4 = !isOpen && containsCurrentItem;
|
|
260
192
|
let t5;
|
|
261
193
|
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
262
|
-
t5 = () => setIsOpen(
|
|
194
|
+
t5 = () => setIsOpen(_temp);
|
|
263
195
|
$[8] = t5;
|
|
264
196
|
} else {
|
|
265
197
|
t5 = $[8];
|
|
@@ -341,7 +273,7 @@ function ItemWithSubNav(t0) {
|
|
|
341
273
|
|
|
342
274
|
// ----------------------------------------------------------------------------
|
|
343
275
|
// NavList.SubNav
|
|
344
|
-
function
|
|
276
|
+
function _temp(open) {
|
|
345
277
|
return !open;
|
|
346
278
|
}
|
|
347
279
|
const SubNavContext = /*#__PURE__*/React.createContext({
|
|
@@ -696,11 +628,5 @@ const NavList = Object.assign(Root, {
|
|
|
696
628
|
GroupExpand,
|
|
697
629
|
GroupHeading
|
|
698
630
|
});
|
|
699
|
-
function _temp(child) {
|
|
700
|
-
return /*#__PURE__*/isValidElement(child) && (child.type === SubNav || isSlot(child, SubNav));
|
|
701
|
-
}
|
|
702
|
-
function _temp2(child_0) {
|
|
703
|
-
return /*#__PURE__*/isValidElement(child_0) ? child_0.type !== SubNav && child_0.type !== TrailingAction && !isSlot(child_0, SubNav) && !isSlot(child_0, TrailingAction) : true;
|
|
704
|
-
}
|
|
705
631
|
|
|
706
632
|
export { GroupExpand, NavList };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@keyframes prc-Overlay-overlay-appear-JpFey{0%{opacity:0}to{opacity:1}}.prc-Overlay-Overlay-jfs-T{background-color:var(--overlay-bgColor,var(--color-canvas-overlay));border-radius:var(--borderRadius-large,.75rem);box-shadow:var(--shadow-floating-small,var(--color-overlay-shadow));height:auto;max-height:100vh;max-width:calc(100vw - 2rem);min-width:192px;overflow:auto;position:absolute;width:auto}.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal]),.prc-Overlay-Overlay-jfs-T[data-anchor-position=false]{bottom:var(--bottom,auto);right:var(--right,auto)}@media screen and (max-width:calc(48rem - 0.02px)){[data-responsive=fullscreen]:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:0;top:0}}:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:var(--left,auto);top:var(--top,auto)}.prc-Overlay-Overlay-jfs-T:focus{outline:none}@media (forced-colors:active){.prc-Overlay-Overlay-jfs-T{outline:1px solid transparent}}.prc-Overlay-Overlay-jfs-T:where([data-reflow-container=true]){max-width:calc(100vw - 2rem)}.prc-Overlay-Overlay-jfs-T:where([data-overflow-auto]){overflow:auto}.prc-Overlay-Overlay-jfs-T:where([data-overflow-hidden]){overflow:hidden}.prc-Overlay-Overlay-jfs-T:where([data-overflow-scroll]){overflow:scroll}.prc-Overlay-Overlay-jfs-T:where([data-overflow-visible]){overflow:visible}.prc-Overlay-Overlay-jfs-T:where([data-height-xsmall]){height:192px}.prc-Overlay-Overlay-jfs-T:where([data-height-small]){height:256px}.prc-Overlay-Overlay-jfs-T:where([data-height-medium]){height:320px}.prc-Overlay-Overlay-jfs-T:where([data-height-large]){height:432px}.prc-Overlay-Overlay-jfs-T:where([data-height-xlarge]){height:600px}.prc-Overlay-Overlay-jfs-T:where([data-height-auto]),.prc-Overlay-Overlay-jfs-T:where([data-height-initial]){height:auto}.prc-Overlay-Overlay-jfs-T:where([data-height-fit-content]){height:-moz-fit-content;height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:192px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:432px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:600px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-fit-content]){max-height:-moz-fit-content;max-height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-width-small]){width:256px}.prc-Overlay-Overlay-jfs-T:where([data-width-medium]){width:320px}.prc-Overlay-Overlay-jfs-T:where([data-width-large]){width:480px}.prc-Overlay-Overlay-jfs-T:where([data-width-xlarge]){width:640px}.prc-Overlay-Overlay-jfs-T:where([data-width-xxlarge]){width:960px}.prc-Overlay-Overlay-jfs-T:where([data-width-auto]){width:auto}.prc-Overlay-Overlay-jfs-T:where([data-max-width-small]){max-width:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-medium]){max-width:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-large]){max-width:480px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xlarge]){max-width:640px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xxlarge]){max-width:960px}.prc-Overlay-Overlay-jfs-T:where([data-visibility-visible]){visibility:visible}.prc-Overlay-Overlay-jfs-T:where([data-visibility-hidden]){visibility:hidden}@media screen and (max-width:calc(48rem - 0.02px)){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]){border-radius:unset;height:100vh;left:0;margin:0;max-height:none;max-width:none;padding-bottom:env(safe-area-inset-bottom);position:fixed;top:0;width:100vw}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]){height:100dvh}}}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-variant=fullscreen]){height:100dvh}}@media (prefers-reduced-motion:no-preference){.prc-Overlay-Overlay-jfs-T{animation:prc-Overlay-overlay-appear-JpFey .2s cubic-bezier(.33,1,.68,1)}}
|
|
2
|
-
/*# sourceMappingURL=Overlay-
|
|
1
|
+
@keyframes prc-Overlay-overlay-appear-JpFey{0%{opacity:0}to{opacity:1}}.prc-Overlay-Overlay-jfs-T{background-color:var(--overlay-bgColor,var(--color-canvas-overlay));border-radius:var(--borderRadius-large,.75rem);box-shadow:var(--shadow-floating-small,var(--color-overlay-shadow));height:auto;max-height:100vh;max-width:calc(100vw - 2rem);min-width:192px;overflow:auto;position:absolute;width:auto}.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal]),.prc-Overlay-Overlay-jfs-T[data-anchor-position=false]{bottom:var(--bottom,auto);right:var(--right,auto)}@media screen and (max-width:calc(48rem - 0.02px)){[data-responsive=fullscreen]:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:0;top:0}}:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:var(--left,auto);top:var(--top,auto)}.prc-Overlay-Overlay-jfs-T:focus{outline:none}@media (forced-colors:active){.prc-Overlay-Overlay-jfs-T{outline:1px solid transparent}}.prc-Overlay-Overlay-jfs-T:where([data-reflow-container=true]){max-width:calc(100vw - 2rem)}.prc-Overlay-Overlay-jfs-T:where([data-overflow-auto]){overflow:auto}.prc-Overlay-Overlay-jfs-T:where([data-overflow-hidden]){overflow:hidden}.prc-Overlay-Overlay-jfs-T:where([data-overflow-scroll]){overflow:scroll}.prc-Overlay-Overlay-jfs-T:where([data-overflow-visible]){overflow:visible}.prc-Overlay-Overlay-jfs-T:where([data-height-xsmall]){height:192px}.prc-Overlay-Overlay-jfs-T:where([data-height-small]){height:256px}.prc-Overlay-Overlay-jfs-T:where([data-height-medium]){height:320px}.prc-Overlay-Overlay-jfs-T:where([data-height-large]){height:432px}.prc-Overlay-Overlay-jfs-T:where([data-height-xlarge]){height:600px}.prc-Overlay-Overlay-jfs-T:where([data-height-auto]),.prc-Overlay-Overlay-jfs-T:where([data-height-initial]){height:auto}.prc-Overlay-Overlay-jfs-T:where([data-height-fit-content]){height:-moz-fit-content;height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:192px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:432px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:600px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-clamp-to-viewport][data-max-height-xsmall]){max-height:min(192px,100dvh)}.prc-Overlay-Overlay-jfs-T:where([data-max-height-clamp-to-viewport][data-max-height-small]){max-height:min(256px,100dvh)}.prc-Overlay-Overlay-jfs-T:where([data-max-height-clamp-to-viewport][data-max-height-medium]){max-height:min(320px,100dvh)}.prc-Overlay-Overlay-jfs-T:where([data-max-height-clamp-to-viewport][data-max-height-large]){max-height:min(432px,100dvh)}.prc-Overlay-Overlay-jfs-T:where([data-max-height-clamp-to-viewport][data-max-height-xlarge]){max-height:min(600px,100dvh)}.prc-Overlay-Overlay-jfs-T:where([data-max-height-fit-content]){max-height:-moz-fit-content;max-height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-width-small]){width:256px}.prc-Overlay-Overlay-jfs-T:where([data-width-medium]){width:320px}.prc-Overlay-Overlay-jfs-T:where([data-width-large]){width:480px}.prc-Overlay-Overlay-jfs-T:where([data-width-xlarge]){width:640px}.prc-Overlay-Overlay-jfs-T:where([data-width-xxlarge]){width:960px}.prc-Overlay-Overlay-jfs-T:where([data-width-auto]){width:auto}.prc-Overlay-Overlay-jfs-T:where([data-max-width-small]){max-width:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-medium]){max-width:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-large]){max-width:480px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xlarge]){max-width:640px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xxlarge]){max-width:960px}.prc-Overlay-Overlay-jfs-T:where([data-visibility-visible]){visibility:visible}.prc-Overlay-Overlay-jfs-T:where([data-visibility-hidden]){visibility:hidden}@media screen and (max-width:calc(48rem - 0.02px)){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]){border-radius:unset;height:100vh;left:0;margin:0;max-height:none;max-width:none;padding-bottom:env(safe-area-inset-bottom);position:fixed;top:0;width:100vw}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]){height:100dvh}}}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-variant=fullscreen]){height:100dvh}}@media (prefers-reduced-motion:no-preference){.prc-Overlay-Overlay-jfs-T{animation:prc-Overlay-overlay-appear-JpFey .2s cubic-bezier(.33,1,.68,1)}}
|
|
2
|
+
/*# sourceMappingURL=Overlay-f81a131d.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Overlay/Overlay.module.css.js"],"names":[],"mappings":"AAAA,4CACE,GACE,SACF,CAEA,GACE,SACF,CACF,CAEA,2BAQE,mEAAwC,CACxC,8CAAwC,CACxC,mEAAwC,CALxC,WAAY,CACZ,gBAAiB,CAJjB,4BAA6B,CAE7B,eAAgB,CAGhB,aAAc,CANd,iBAAkB,CAElB,UAyNF,CAhNE,wIAKE,yBAA2B,CAF3B,uBAkBF,CAZI,mDADF,6LAGI,MAAO,CADP,KAGJ,CADE,CAGF,iKAIE,qBAAuB,CAFvB,mBAGF,CAGF,iCACE,YACF,CAEA,8BAvCF,2BAyCI,6BAmLJ,CAlLE,CAEA,+DACE,4BACF,CAEA,uDACE,aACF,CAEA,yDACE,eACF,CAEA,yDACE,eACF,CAEA,0DACE,gBACF,CAEA,uDACE,YACF,CAEA,sDACE,YACF,CAEA,uDACE,YACF,CAEA,sDACE,YACF,CAEA,uDACE,YACF,CAEA,6GAEE,WACF,CAEA,4DACE,uBAAmB,CAAnB,kBACF,CAEA,2DACE,gBACF,CAEA,0DACE,gBACF,CAEA,2DACE,gBACF,CAEA,0DACE,gBACF,CAEA,2DACE,gBACF,CAGA,8FACE,4BACF,CAEA,6FACE,4BACF,CAEA,8FACE,4BACF,CAEA,6FACE,4BACF,CAEA,8FACE,4BACF,CAEA,gEACE,2BAAuB,CAAvB,sBACF,CAEA,qDACE,WACF,CAEA,sDACE,WACF,CAEA,qDAEE,WACF,CAEA,sDAEE,WACF,CAEA,uDAEE,WACF,CAEA,oDACE,UACF,CAEA,yDACE,eACF,CAEA,0DACE,eACF,CAEA,yDACE,eACF,CAEA,0DACE,eACF,CAEA,2DACE,eACF,CAEA,4DACE,kBACF,CAEA,2DACE,iBACF,CAGE,mDADF,+DAUI,mBAAoB,CAHpB,YAAa,CAHb,MAAO,CAKP,QAAS,CADT,eAAgB,CAFhB,cAAe,CAMf,0CAA2C,CAV3C,cAAe,CACf,KAAM,CAEN,WAcJ,CALI,0BAdJ,+DAgBM,aAGN,CAFI,CACF,CAGF,0BAEE,4DACE,aACF,CACF,CAGF,8CACE,2BACE,wEACF,CACF","file":"Overlay-f81a131d.css","sourcesContent":["@keyframes overlay-appear {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.Overlay {\n position: absolute;\n max-width: calc(100vw - 2rem);\n width: auto;\n min-width: 192px;\n height: auto;\n max-height: 100vh;\n overflow: auto;\n background-color: var(--overlay-bgColor);\n border-radius: var(--borderRadius-large);\n box-shadow: var(--shadow-floating-small);\n\n &[data-anchor-position='false'],\n &:not([data-anchor-position]):not([data-variant='modal']) {\n /* stylelint-disable-next-line primer/spacing */\n right: var(--right, auto);\n /* stylelint-disable-next-line primer/spacing */\n bottom: var(--bottom, auto);\n\n /* stylelint-disable-next-line selector-max-specificity */\n &[data-responsive='fullscreen']:not([data-variant]) {\n @media screen and (--viewportRange-narrow) {\n top: 0;\n left: 0;\n }\n }\n\n &:not([data-variant]) {\n /* stylelint-disable-next-line primer/spacing */\n top: var(--top, auto);\n /* stylelint-disable-next-line primer/spacing */\n left: var(--left, auto);\n }\n }\n\n &:focus {\n outline: none;\n }\n\n @media (forced-colors: active) {\n /* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */\n outline: solid 1px transparent;\n }\n\n &:where([data-reflow-container='true']) {\n max-width: calc(100vw - 2rem);\n }\n\n &:where([data-overflow-auto]) {\n overflow: auto;\n }\n\n &:where([data-overflow-hidden]) {\n overflow: hidden;\n }\n\n &:where([data-overflow-scroll]) {\n overflow: scroll;\n }\n\n &:where([data-overflow-visible]) {\n overflow: visible;\n }\n\n &:where([data-height-xsmall]) {\n height: 192px;\n }\n\n &:where([data-height-small]) {\n height: 256px;\n }\n\n &:where([data-height-medium]) {\n height: 320px;\n }\n\n &:where([data-height-large]) {\n height: 432px;\n }\n\n &:where([data-height-xlarge]) {\n height: 600px;\n }\n\n &:where([data-height-auto]),\n &:where([data-height-initial]) {\n height: auto;\n }\n\n &:where([data-height-fit-content]) {\n height: fit-content;\n }\n\n &:where([data-max-height-xsmall]) {\n max-height: 192px;\n }\n\n &:where([data-max-height-small]) {\n max-height: 256px;\n }\n\n &:where([data-max-height-medium]) {\n max-height: 320px;\n }\n\n &:where([data-max-height-large]) {\n max-height: 432px;\n }\n\n &:where([data-max-height-xlarge]) {\n max-height: 600px;\n }\n\n /* Max-height size tokens clamped to viewport (enabled via feature flag) */\n &:where([data-max-height-clamp-to-viewport][data-max-height-xsmall]) {\n max-height: min(192px, 100dvh);\n }\n\n &:where([data-max-height-clamp-to-viewport][data-max-height-small]) {\n max-height: min(256px, 100dvh);\n }\n\n &:where([data-max-height-clamp-to-viewport][data-max-height-medium]) {\n max-height: min(320px, 100dvh);\n }\n\n &:where([data-max-height-clamp-to-viewport][data-max-height-large]) {\n max-height: min(432px, 100dvh);\n }\n\n &:where([data-max-height-clamp-to-viewport][data-max-height-xlarge]) {\n max-height: min(600px, 100dvh);\n }\n\n &:where([data-max-height-fit-content]) {\n max-height: fit-content;\n }\n\n &:where([data-width-small]) {\n width: 256px;\n }\n\n &:where([data-width-medium]) {\n width: 320px;\n }\n\n &:where([data-width-large]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 480px;\n }\n\n &:where([data-width-xlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 640px;\n }\n\n &:where([data-width-xxlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 960px;\n }\n\n &:where([data-width-auto]) {\n width: auto;\n }\n\n &:where([data-max-width-small]) {\n max-width: 256px;\n }\n\n &:where([data-max-width-medium]) {\n max-width: 320px;\n }\n\n &:where([data-max-width-large]) {\n max-width: 480px;\n }\n\n &:where([data-max-width-xlarge]) {\n max-width: 640px;\n }\n\n &:where([data-max-width-xxlarge]) {\n max-width: 960px;\n }\n\n &:where([data-visibility-visible]) {\n visibility: visible;\n }\n\n &:where([data-visibility-hidden]) {\n visibility: hidden;\n }\n\n &:where([data-responsive='fullscreen']) {\n @media screen and (--viewportRange-narrow) {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: none;\n height: 100vh;\n max-height: none;\n margin: 0;\n border-radius: unset;\n /* stylelint-disable-next-line primer/spacing */\n padding-bottom: env(safe-area-inset-bottom);\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n height: 100dvh;\n }\n }\n }\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n &:where([data-variant='fullscreen']) {\n height: 100dvh;\n }\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .Overlay {\n animation: overlay-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);\n }\n}\n"]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AAElE;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,OAAO,EAwFR,8BAA8B,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAA;AAEhE,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,OAAO,CAAC,CAAA;AAEhE,eAAe,OAAO,CAAA"}
|
package/dist/Overlay/Overlay.js
CHANGED
|
@@ -116,7 +116,7 @@ const BaseOverlay = /*#__PURE__*/React.forwardRef(({
|
|
|
116
116
|
|
|
117
117
|
*/
|
|
118
118
|
const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
119
|
-
const $ = c(
|
|
119
|
+
const $ = c(48);
|
|
120
120
|
let anchorSide;
|
|
121
121
|
let ignoreClickRefs;
|
|
122
122
|
let initialFocusRef;
|
|
@@ -197,6 +197,7 @@ const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
197
197
|
const visibility = t4 === undefined ? "visible" : t4;
|
|
198
198
|
const width = t5 === undefined ? "auto" : t5;
|
|
199
199
|
const cssAnchorPositioning = useFeatureFlag("primer_react_css_anchor_positioning");
|
|
200
|
+
const featureFlagMaxHeightClampToViewport = useFeatureFlag("primer_react_overlay_max_height_clamp_to_viewport");
|
|
200
201
|
const overlayRef = useRef(null);
|
|
201
202
|
useRefObjectAsForwardedRef(forwardedRef, overlayRef);
|
|
202
203
|
let t6;
|
|
@@ -271,8 +272,18 @@ const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
271
272
|
const leftPosition = left === undefined && right === undefined ? 0 : left;
|
|
272
273
|
const t11 = !preventOverflow ? true : undefined;
|
|
273
274
|
let t12;
|
|
274
|
-
if ($[32] !==
|
|
275
|
-
t12 =
|
|
275
|
+
if ($[32] !== featureFlagMaxHeightClampToViewport) {
|
|
276
|
+
t12 = featureFlagMaxHeightClampToViewport ? {
|
|
277
|
+
"data-max-height-clamp-to-viewport": ""
|
|
278
|
+
} : {};
|
|
279
|
+
$[32] = featureFlagMaxHeightClampToViewport;
|
|
280
|
+
$[33] = t12;
|
|
281
|
+
} else {
|
|
282
|
+
t12 = $[33];
|
|
283
|
+
}
|
|
284
|
+
let t13;
|
|
285
|
+
if ($[34] !== height || $[35] !== leftPosition || $[36] !== props || $[37] !== responsiveVariant || $[38] !== right || $[39] !== role || $[40] !== t11 || $[41] !== t12 || $[42] !== visibility || $[43] !== width) {
|
|
286
|
+
t13 = /*#__PURE__*/jsx(BaseOverlay, {
|
|
276
287
|
role: role,
|
|
277
288
|
width: width,
|
|
278
289
|
"data-reflow-container": t11,
|
|
@@ -282,38 +293,40 @@ const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
282
293
|
height: height,
|
|
283
294
|
visibility: visibility,
|
|
284
295
|
"data-responsive": responsiveVariant,
|
|
296
|
+
...t12,
|
|
285
297
|
...props
|
|
286
298
|
});
|
|
287
|
-
$[
|
|
288
|
-
$[
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
292
|
-
$[
|
|
293
|
-
$[
|
|
294
|
-
$[39] = visibility;
|
|
295
|
-
$[40] = width;
|
|
299
|
+
$[34] = height;
|
|
300
|
+
$[35] = leftPosition;
|
|
301
|
+
$[36] = props;
|
|
302
|
+
$[37] = responsiveVariant;
|
|
303
|
+
$[38] = right;
|
|
304
|
+
$[39] = role;
|
|
305
|
+
$[40] = t11;
|
|
296
306
|
$[41] = t12;
|
|
307
|
+
$[42] = visibility;
|
|
308
|
+
$[43] = width;
|
|
309
|
+
$[44] = t13;
|
|
297
310
|
} else {
|
|
298
|
-
|
|
311
|
+
t13 = $[44];
|
|
299
312
|
}
|
|
300
|
-
const overlayContent =
|
|
313
|
+
const overlayContent = t13;
|
|
301
314
|
if (cssAnchorPositioning) {
|
|
302
315
|
return overlayContent;
|
|
303
316
|
}
|
|
304
|
-
let
|
|
305
|
-
if ($[
|
|
306
|
-
|
|
317
|
+
let t14;
|
|
318
|
+
if ($[45] !== overlayContent || $[46] !== portalContainerName) {
|
|
319
|
+
t14 = /*#__PURE__*/jsx(Portal, {
|
|
307
320
|
containerName: portalContainerName,
|
|
308
321
|
children: overlayContent
|
|
309
322
|
});
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
312
|
-
$[
|
|
323
|
+
$[45] = overlayContent;
|
|
324
|
+
$[46] = portalContainerName;
|
|
325
|
+
$[47] = t14;
|
|
313
326
|
} else {
|
|
314
|
-
|
|
327
|
+
t14 = $[47];
|
|
315
328
|
}
|
|
316
|
-
return
|
|
329
|
+
return t14;
|
|
317
330
|
});
|
|
318
331
|
|
|
319
332
|
export { BaseOverlay, Overlay as default, heightMap };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -16,4 +16,5 @@ export { useMnemonics } from './useMnemonics';
|
|
|
16
16
|
export { useRefObjectAsForwardedRef } from './useRefObjectAsForwardedRef';
|
|
17
17
|
export { useId } from './useId';
|
|
18
18
|
export { useIsMacOS } from './useIsMacOS';
|
|
19
|
+
export { useMergedRefs } from './useMergedRefs';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,YAAY,EAAC,yBAAyB,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrF,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAC3D,YAAY,EAAC,4BAA4B,EAAC,MAAM,wBAAwB,CAAA;AACxE,YAAY,EAAC,4BAA4B,EAAC,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAA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E,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ForwardedRef, Ref as StandardRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Combine two refs of matching type (typically an external or forwarded ref and an internal `useRef` object or
|
|
4
|
+
* callback ref).
|
|
5
|
+
*
|
|
6
|
+
* If you need to combine more than two refs (what are you doing?) just nest the hook:
|
|
7
|
+
* `useMergedRefs(refA, useMergedRefs(refB, refC))`
|
|
8
|
+
*
|
|
9
|
+
* @param refA First ref to merge. The order is not important.
|
|
10
|
+
* @param refB Second ref to merge. The order is not important.
|
|
11
|
+
* @returns A new ref which must be passed to the relevant child component. **Important**: do not pass `refA` or
|
|
12
|
+
* `refB` to the component!
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // React 18
|
|
16
|
+
* const Example = forwardRef<HTMLButtonElement, {}>((props, forwardedRef) => {
|
|
17
|
+
* const ref = useRef<HTMLButtonElement>(null)
|
|
18
|
+
* const combinedRef = useMergedRefs(forwardedRef, ref)
|
|
19
|
+
*
|
|
20
|
+
* return <button ref={combinedRef} />
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // React 19
|
|
25
|
+
* const Example = ({ref: externalRef}: {ref?: Ref<HTMLButtonElement>}) => {
|
|
26
|
+
* const ref = useRef<HTMLButtonElement>(null)
|
|
27
|
+
* const combinedRef = useMergedRefs(externalRef, ref)
|
|
28
|
+
*
|
|
29
|
+
* return <button ref={combinedRef} />
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
export declare function useMergedRefs<T>(refA: Ref<T | null>, refB: Ref<T | null>): (value: T | null) => () => void;
|
|
33
|
+
type CleanupFunction = () => void;
|
|
34
|
+
/**
|
|
35
|
+
* React 19 supports callback refs that can return a cleanup function. If a cleanup function is returned, the
|
|
36
|
+
* cleanup is called on unmount **instead** of setting the ref to null.
|
|
37
|
+
*/
|
|
38
|
+
type React19RefCallback<T> = {
|
|
39
|
+
bivarianceHack(instance: T): void | CleanupFunction;
|
|
40
|
+
}['bivarianceHack'];
|
|
41
|
+
/**
|
|
42
|
+
* Supporting React 18 and 19 while alleviating the need for any hacks or casts in consumers:
|
|
43
|
+
* - `ForwardedRef` from the React 18 `forwardRef` HOC
|
|
44
|
+
* - `React19RefCallback` for callback refs that can return a cleanup function (this is included in `Ref` in React 19
|
|
45
|
+
* but not in 18)
|
|
46
|
+
* - `Ref` for standard refs from `useRef` or passed in as React 19 prop
|
|
47
|
+
* - `undefined` to allow for easy use of optional `ref` props in React 19
|
|
48
|
+
*/
|
|
49
|
+
type Ref<T> = ForwardedRef<T> | React19RefCallback<T> | StandardRef<T> | undefined;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=useMergedRefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMergedRefs.d.ts","sourceRoot":"","sources":["../../src/hooks/useMergedRefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,GAAG,IAAI,WAAW,EAAmB,MAAM,OAAO,CAAA;AAG7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,WAE7D,CAAC,GAAG,IAAI,gBAiBnB;AAED,KAAK,eAAe,GAAG,MAAM,IAAI,CAAA;AAEjC;;;GAGG;AAEH,KAAK,kBAAkB,CAAC,CAAC,IAAI;IAC3B,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,GAAG,eAAe,CAAA;CACpD,CAAC,gBAAgB,CAAC,CAAA;AAEnB;;;;;;;GAOG;AACH,KAAK,GAAG,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Combine two refs of matching type (typically an external or forwarded ref and an internal `useRef` object or
|
|
6
|
+
* callback ref).
|
|
7
|
+
*
|
|
8
|
+
* If you need to combine more than two refs (what are you doing?) just nest the hook:
|
|
9
|
+
* `useMergedRefs(refA, useMergedRefs(refB, refC))`
|
|
10
|
+
*
|
|
11
|
+
* @param refA First ref to merge. The order is not important.
|
|
12
|
+
* @param refB Second ref to merge. The order is not important.
|
|
13
|
+
* @returns A new ref which must be passed to the relevant child component. **Important**: do not pass `refA` or
|
|
14
|
+
* `refB` to the component!
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // React 18
|
|
18
|
+
* const Example = forwardRef<HTMLButtonElement, {}>((props, forwardedRef) => {
|
|
19
|
+
* const ref = useRef<HTMLButtonElement>(null)
|
|
20
|
+
* const combinedRef = useMergedRefs(forwardedRef, ref)
|
|
21
|
+
*
|
|
22
|
+
* return <button ref={combinedRef} />
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // React 19
|
|
27
|
+
* const Example = ({ref: externalRef}: {ref?: Ref<HTMLButtonElement>}) => {
|
|
28
|
+
* const ref = useRef<HTMLButtonElement>(null)
|
|
29
|
+
* const combinedRef = useMergedRefs(externalRef, ref)
|
|
30
|
+
*
|
|
31
|
+
* return <button ref={combinedRef} />
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
function useMergedRefs(refA, refB) {
|
|
35
|
+
const $ = c(3);
|
|
36
|
+
let t0;
|
|
37
|
+
if ($[0] !== refA || $[1] !== refB) {
|
|
38
|
+
t0 = value => {
|
|
39
|
+
const cleanupA = setRef(refA, value);
|
|
40
|
+
const cleanupB = setRef(refB, value);
|
|
41
|
+
return () => {
|
|
42
|
+
if (cleanupA) {
|
|
43
|
+
cleanupA();
|
|
44
|
+
} else {
|
|
45
|
+
setRef(refA, null);
|
|
46
|
+
}
|
|
47
|
+
if (cleanupB) {
|
|
48
|
+
cleanupB();
|
|
49
|
+
} else {
|
|
50
|
+
setRef(refB, null);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
$[0] = refA;
|
|
55
|
+
$[1] = refB;
|
|
56
|
+
$[2] = t0;
|
|
57
|
+
} else {
|
|
58
|
+
t0 = $[2];
|
|
59
|
+
}
|
|
60
|
+
return t0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* React 19 supports callback refs that can return a cleanup function. If a cleanup function is returned, the
|
|
65
|
+
* cleanup is called on unmount **instead** of setting the ref to null.
|
|
66
|
+
*/
|
|
67
|
+
// bivarianceHack copied from React types
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Supporting React 18 and 19 while alleviating the need for any hacks or casts in consumers:
|
|
71
|
+
* - `ForwardedRef` from the React 18 `forwardRef` HOC
|
|
72
|
+
* - `React19RefCallback` for callback refs that can return a cleanup function (this is included in `Ref` in React 19
|
|
73
|
+
* but not in 18)
|
|
74
|
+
* - `Ref` for standard refs from `useRef` or passed in as React 19 prop
|
|
75
|
+
* - `undefined` to allow for easy use of optional `ref` props in React 19
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
function setRef(ref, value) {
|
|
79
|
+
if (typeof ref === 'function') {
|
|
80
|
+
return ref(value);
|
|
81
|
+
} else if (ref) {
|
|
82
|
+
ref.current = value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { useMergedRefs };
|
|
@@ -6,6 +6,18 @@ import React from 'react';
|
|
|
6
6
|
* This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
|
|
7
7
|
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
|
|
8
8
|
* @type TRef The type of the RefObject which should be created.
|
|
9
|
+
*
|
|
10
|
+
* @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
|
|
11
|
+
* created ref instead.
|
|
12
|
+
*
|
|
13
|
+
* ```diff
|
|
14
|
+
* - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
|
|
15
|
+
* + const ref = useRef(null)
|
|
16
|
+
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
17
|
+
*
|
|
18
|
+
* - return <div ref={ref} />
|
|
19
|
+
* + return <div ref={mergedRef} />
|
|
20
|
+
* ```
|
|
9
21
|
*/
|
|
10
22
|
export declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
|
|
11
23
|
//# sourceMappingURL=useProvidedRefOrCreate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProvidedRefOrCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/useProvidedRefOrCreate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB
|
|
1
|
+
{"version":3,"file":"useProvidedRefOrCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/useProvidedRefOrCreate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAGrH"}
|
|
@@ -7,6 +7,18 @@ import React from 'react';
|
|
|
7
7
|
* This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
|
|
8
8
|
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
|
|
9
9
|
* @type TRef The type of the RefObject which should be created.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
|
|
12
|
+
* created ref instead.
|
|
13
|
+
*
|
|
14
|
+
* ```diff
|
|
15
|
+
* - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
|
|
16
|
+
* + const ref = useRef(null)
|
|
17
|
+
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
18
|
+
*
|
|
19
|
+
* - return <div ref={ref} />
|
|
20
|
+
* + return <div ref={mergedRef} />
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
function useProvidedRefOrCreate(providedRef) {
|
|
12
24
|
const createdRef = React.useRef(null);
|
|
@@ -5,6 +5,18 @@ import type { ForwardedRef, RefObject } from 'react';
|
|
|
5
5
|
* instance with `.current`.
|
|
6
6
|
*
|
|
7
7
|
* **NOTE**: The `refObject` should be passed to the underlying element, NOT the `forwardedRef`.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Migrate to `useMergedRefs`. It's safer, faster, and easier to use:
|
|
10
|
+
*
|
|
11
|
+
* ```diff
|
|
12
|
+
* const ref = useRef(null)
|
|
13
|
+
*
|
|
14
|
+
* - useRefObjectAsForwardedRef(forwardedRef, ref)
|
|
15
|
+
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
16
|
+
*
|
|
17
|
+
* - return <div ref={ref} />
|
|
18
|
+
* + return <div ref={mergedRef} />
|
|
19
|
+
* ```
|
|
8
20
|
*/
|
|
9
21
|
export declare function useRefObjectAsForwardedRef<T>(forwardedRef: ForwardedRef<T>, refObject: RefObject<T | null>): void;
|
|
10
22
|
//# sourceMappingURL=useRefObjectAsForwardedRef.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRefObjectAsForwardedRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useRefObjectAsForwardedRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAA;AAGlD
|
|
1
|
+
{"version":3,"file":"useRefObjectAsForwardedRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useRefObjectAsForwardedRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAA;AAGlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAEjH"}
|
|
@@ -7,6 +7,18 @@ import { useImperativeHandle } from 'react';
|
|
|
7
7
|
* instance with `.current`.
|
|
8
8
|
*
|
|
9
9
|
* **NOTE**: The `refObject` should be passed to the underlying element, NOT the `forwardedRef`.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Migrate to `useMergedRefs`. It's safer, faster, and easier to use:
|
|
12
|
+
*
|
|
13
|
+
* ```diff
|
|
14
|
+
* const ref = useRef(null)
|
|
15
|
+
*
|
|
16
|
+
* - useRefObjectAsForwardedRef(forwardedRef, ref)
|
|
17
|
+
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
18
|
+
*
|
|
19
|
+
* - return <div ref={ref} />
|
|
20
|
+
* + return <div ref={mergedRef} />
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
function useRefObjectAsForwardedRef(forwardedRef, refObject) {
|
|
12
24
|
const $ = c(2);
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type { FocusTrapHookSettings } from './hooks/useFocusTrap';
|
|
|
21
21
|
export { useFocusZone } from './hooks/useFocusZone';
|
|
22
22
|
export type { FocusZoneHookSettings } from './hooks/useFocusZone';
|
|
23
23
|
export { useRefObjectAsForwardedRef } from './hooks/useRefObjectAsForwardedRef';
|
|
24
|
+
export { useMergedRefs } from './hooks/useMergedRefs';
|
|
24
25
|
export { useResizeObserver } from './hooks/useResizeObserver';
|
|
25
26
|
export { useResponsiveValue, type ResponsiveValue } from './hooks/useResponsiveValue';
|
|
26
27
|
export { default as useIsomorphicLayoutEffect } from './utils/useIsomorphicLayoutEffect';
|