@primer/react 0.0.0-20260319212226 → 0.0.0-20260320092003
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 +2 -13
- package/dist/ActionBar/ActionBar.d.ts +1 -1
- package/dist/ActionBar/index.d.ts +1 -1
- package/dist/ActionMenu/{ActionMenu-58362ca7.css → ActionMenu-53493541.css} +2 -2
- package/dist/ActionMenu/ActionMenu-53493541.css.map +1 -0
- package/dist/ActionMenu/ActionMenu.d.ts.map +1 -1
- package/dist/ActionMenu/ActionMenu.js +0 -4
- package/dist/ActionMenu/ActionMenu.module.css.js +1 -1
- package/dist/Banner/Banner.js +1 -1
- package/dist/Button/{ButtonBase-42fcfaa3.css → ButtonBase-6659abcf.css} +2 -2
- package/dist/Button/ButtonBase-6659abcf.css.map +1 -0
- package/dist/Button/ButtonBase.module.css.js +1 -1
- package/dist/Button/types.d.ts +1 -1
- package/dist/Button/types.d.ts.map +1 -1
- package/dist/Details/Details.js +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
- package/dist/Link/{Link-ba423096.css → Link-968346ff.css} +2 -2
- package/dist/Link/Link-968346ff.css.map +1 -0
- package/dist/Link/Link.module.css.js +1 -1
- package/dist/Overlay/{Overlay-f81a131d.css → Overlay-2e0ce8db.css} +2 -2
- package/dist/Overlay/Overlay-2e0ce8db.css.map +1 -0
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +22 -35
- package/dist/Overlay/Overlay.module.css.js +1 -1
- package/dist/StateLabel/{StateLabel-056eec66.css → StateLabel-cd51ae39.css} +2 -2
- package/dist/StateLabel/StateLabel-cd51ae39.css.map +1 -0
- package/dist/StateLabel/StateLabel.d.ts +1 -0
- package/dist/StateLabel/StateLabel.d.ts.map +1 -1
- package/dist/StateLabel/StateLabel.js +4 -2
- package/dist/StateLabel/StateLabel.module.css.js +1 -1
- package/dist/TooltipV2/{Tooltip-dd983e5b.css → Tooltip-fcb90d9c.css} +2 -2
- package/dist/TooltipV2/Tooltip-fcb90d9c.css.map +1 -0
- package/dist/TooltipV2/Tooltip.d.ts +1 -1
- package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
- package/dist/TooltipV2/Tooltip.js +11 -17
- package/dist/TooltipV2/Tooltip.module.css.js +2 -2
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.d.ts +0 -12
- package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.js +0 -12
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts +0 -12
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
- package/dist/hooks/useRefObjectAsForwardedRef.js +0 -12
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.d.ts.map +1 -1
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +8 -17
- package/dist/internal/hooks/useMergedRefs.d.ts +2 -0
- package/dist/internal/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/internal/hooks/useMergedRefs.js +16 -0
- package/generated/components.json +9 -5
- package/generated/hooks.json +0 -22
- package/package.json +1 -1
- package/dist/ActionMenu/ActionMenu-58362ca7.css.map +0 -1
- package/dist/Button/ButtonBase-42fcfaa3.css.map +0 -1
- package/dist/Link/Link-ba423096.css.map +0 -1
- package/dist/Overlay/Overlay-f81a131d.css.map +0 -1
- package/dist/StateLabel/StateLabel-056eec66.css.map +0 -1
- package/dist/TooltipV2/Tooltip-dd983e5b.css.map +0 -1
- package/dist/hooks/useMergedRefs.d.ts +0 -51
- package/dist/hooks/useMergedRefs.d.ts.map +0 -1
- package/dist/hooks/useMergedRefs.js +0 -86
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TooltipV2/Tooltip.module.css.js"],"names":[],"mappings":"AACA,8CACE,GACE,SACF,CAEA,GACE,SACF,CACF,CAEA,6BAEE,YA8GF,CA5GE,sCAME,WAAY,CAHZ,eAAgB,CAMhB,gBAAiB,CAJjB,2FAA+E,CAJ/E,iBAAkB,CAClB,iBAAkB,CASlB,SAAU,CAMV,yCAAkC,CAClC,QAAS,CACT,gDAAyC,CANzC,iCAA6B,CAD7B,8KAAsC,CAGtC,wBAAyB,CADzB,iBAAkB,CAElB,kBAAmB,CAInB,2CAA4C,CAC5C,UAAW,CACX,iBACF,CAGA,mDACE,aACF,CAIA,sDACE,aACF,CAEA,8BAxCF,6BAyCI,6BAuEJ,CAtEE,CAGA,mCAME,UAAW,CAFX,aAAc,CACd,mCAA6B,CAF7B,MAAO,CAFP,iBAAkB,CAClB,OAKF,CAGA,iKAGE,QACF,CAEA,iKAGE,WACF,CAEA,qDAGE,SAKF,CAGA,0GATE,QAAS,CAKT,UAAW,CAHX,aAAc,CAEd,WAAY,CALZ,iBAAkB,CAIlB,SAgBF,CAVA,qDAQE,gBAAiB,CANjB,UAQF,CAGA,yDAEE,2FAME,kBAAmB,CAHnB,sBAAwB,CACxB,4BAA6B,CAF7B,iDAA8B,CAG9B,iCAEF,CAGA,iGAME,kBAAmB,CAHnB,sBAAwB,CACxB,4BAA6B,CAF7B,iDAA8B,CAG9B,iCAEF,CACF,CAGF,+EACE,sCACF,CAEA,oHACE,oCACF","file":"Tooltip-dd983e5b.css","sourcesContent":["/* Animation definition */\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n}\n\n.Tooltip {\n /* Overriding the default popover styles */\n display: none;\n\n &[popover] {\n position: absolute;\n width: max-content;\n max-width: 250px;\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--overlay-paddingBlock-condensed) var(--overlay-padding-condensed);\n margin: auto;\n\n /* for scrollbar */\n overflow: visible;\n /* stylelint-disable-next-line property-no-deprecated */\n clip: auto;\n font: var(--text-body-shorthand-small);\n color: var(--tooltip-fgColor);\n text-align: center;\n overflow-wrap: break-word;\n white-space: normal;\n background: var(--tooltip-bgColor);\n border: 0;\n border-radius: var(--borderRadius-medium);\n -webkit-font-smoothing: subpixel-antialiased;\n inset: auto;\n text-wrap: balance;\n }\n\n /* class name in chrome is :popover-open */\n &[popover]:popover-open {\n display: block;\n }\n\n /* class name in firefox and safari is \\:popover-open */\n /* stylelint-disable-next-line selector-class-pattern */\n &[popover]:global(.\\\\:popover-open) {\n display: block;\n }\n\n @media (forced-colors: active) {\n outline: 1px solid transparent;\n }\n\n /* This is needed to keep the tooltip open when the user leaves the trigger element to hover tooltip */\n &::after {\n position: absolute;\n right: 0;\n left: 0;\n display: block;\n height: var(--overlay-offset);\n content: '';\n }\n\n /* South, East, Southeast, Southwest after */\n &[data-direction='n']::after,\n &[data-direction='ne']::after,\n &[data-direction='nw']::after {\n top: 100%;\n }\n\n &[data-direction='s']::after,\n &[data-direction='se']::after,\n &[data-direction='sw']::after {\n bottom: 100%;\n }\n\n &[data-direction='w']::after {\n position: absolute;\n bottom: 0;\n left: 100%;\n display: block;\n width: 8px;\n height: 100%;\n content: '';\n }\n\n /* East before and after */\n &[data-direction='e']::after {\n position: absolute;\n right: 100%;\n bottom: 0;\n display: block;\n width: 8px;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -8px;\n content: '';\n }\n\n /* Only show animations if users don't have a preference for reduced motion */\n @media screen and (prefers-reduced-motion: no-preference) {\n /* Animation styles */\n &:popover-open,\n &:popover-open::before {\n animation-name: tooltip-appear;\n animation-duration: 0.1s;\n animation-fill-mode: forwards;\n animation-timing-function: ease-in;\n animation-delay: 0s;\n }\n\n /* Animation styles */\n &:global(.\\\\:popover-open) /* stylelint-disable-line selector-class-pattern */,\n &:global(.\\\\:popover-open)::before /* stylelint-disable-line selector-class-pattern */ {\n animation-name: tooltip-appear;\n animation-duration: 0.1s;\n animation-fill-mode: forwards;\n animation-timing-function: ease-in;\n animation-delay: 0s;\n }\n }\n}\n\n.KeybindingHintContainer.HasTextBefore {\n margin-left: var(--base-size-6);\n}\n\n.KeybindingHintContainer.HasTextBefore.HasMultipleHints {\n margin-left: var(--base-size-8);\n}\n"]}
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,86 +0,0 @@
|
|
|
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 };
|