@primer/react 0.0.0-20260220144011 → 0.0.0-20260220144739
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 +6 -2
- package/dist/Autocomplete/Autocomplete.js +76 -159
- package/dist/Autocomplete/AutocompleteMenu.js +128 -333
- package/dist/Autocomplete/AutocompleteOverlay.js +49 -130
- package/dist/Banner/Banner.js +64 -238
- package/dist/Button/Button.js +11 -34
- package/dist/Button/IconButton.js +51 -140
- package/dist/Button/LinkButton.js +11 -39
- package/dist/Checkbox/Checkbox.js +55 -163
- package/dist/Dialog/Dialog.js +105 -347
- package/dist/PageLayout/PageLayout.js +622 -1560
- package/dist/UnderlineNav/UnderlineNavItem.js +56 -149
- package/dist/experimental/SelectPanel2/SelectPanel.js +209 -593
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
- package/dist/hooks/useRefObjectAsForwardedRef.js +10 -2
- package/dist/hooks/useScrollFlash.js +17 -27
- package/dist/hooks/useSlots.d.ts +50 -6
- package/dist/hooks/useSlots.d.ts.map +1 -1
- package/dist/hooks/useSlots.js +114 -36
- package/package.json +1 -1
|
@@ -1,58 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef, useRef, useContext } from 'react';
|
|
1
|
+
import React, { forwardRef, useRef, useContext } from 'react';
|
|
3
2
|
import { UnderlineNavContext } from './UnderlineNavContext.js';
|
|
4
3
|
import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
|
|
5
4
|
import { UnderlineItem } from '../internal/components/UnderlineTabbedInterface.js';
|
|
6
5
|
import classes from './UnderlineNavItem.module.css.js';
|
|
7
6
|
import { jsx } from 'react/jsx-runtime';
|
|
8
7
|
|
|
9
|
-
const UnderlineNavItem = /*#__PURE__*/forwardRef((
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let t2;
|
|
21
|
-
if ($[0] !== t0) {
|
|
22
|
-
({
|
|
23
|
-
as: t1,
|
|
24
|
-
href: t2,
|
|
25
|
-
children,
|
|
26
|
-
counter,
|
|
27
|
-
onSelect,
|
|
28
|
-
"aria-current": ariaCurrent,
|
|
29
|
-
icon: Icon,
|
|
30
|
-
leadingVisual,
|
|
31
|
-
...props
|
|
32
|
-
} = t0);
|
|
33
|
-
$[0] = t0;
|
|
34
|
-
$[1] = Icon;
|
|
35
|
-
$[2] = ariaCurrent;
|
|
36
|
-
$[3] = children;
|
|
37
|
-
$[4] = counter;
|
|
38
|
-
$[5] = leadingVisual;
|
|
39
|
-
$[6] = onSelect;
|
|
40
|
-
$[7] = props;
|
|
41
|
-
$[8] = t1;
|
|
42
|
-
$[9] = t2;
|
|
43
|
-
} else {
|
|
44
|
-
Icon = $[1];
|
|
45
|
-
ariaCurrent = $[2];
|
|
46
|
-
children = $[3];
|
|
47
|
-
counter = $[4];
|
|
48
|
-
leadingVisual = $[5];
|
|
49
|
-
onSelect = $[6];
|
|
50
|
-
props = $[7];
|
|
51
|
-
t1 = $[8];
|
|
52
|
-
t2 = $[9];
|
|
53
|
-
}
|
|
54
|
-
const Component = t1 === undefined ? "a" : t1;
|
|
55
|
-
const href = t2 === undefined ? "#" : t2;
|
|
8
|
+
const UnderlineNavItem = /*#__PURE__*/forwardRef(({
|
|
9
|
+
as: Component = 'a',
|
|
10
|
+
href = '#',
|
|
11
|
+
children,
|
|
12
|
+
counter,
|
|
13
|
+
onSelect,
|
|
14
|
+
'aria-current': ariaCurrent,
|
|
15
|
+
icon: Icon,
|
|
16
|
+
leadingVisual,
|
|
17
|
+
...props
|
|
18
|
+
}, forwardedRef) => {
|
|
56
19
|
const backupRef = useRef(null);
|
|
57
20
|
const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
58
21
|
const {
|
|
@@ -61,107 +24,51 @@ const UnderlineNavItem = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
61
24
|
loadingCounters,
|
|
62
25
|
iconsVisible
|
|
63
26
|
} = useContext(UnderlineNavContext);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
let t6;
|
|
109
|
-
if ($[17] !== onSelect) {
|
|
110
|
-
t6 = event_0 => {
|
|
111
|
-
if (!event_0.defaultPrevented && typeof onSelect === "function") {
|
|
112
|
-
onSelect(event_0);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
$[17] = onSelect;
|
|
116
|
-
$[18] = t6;
|
|
117
|
-
} else {
|
|
118
|
-
t6 = $[18];
|
|
119
|
-
}
|
|
120
|
-
const clickHandler = t6;
|
|
121
|
-
const t7 = (_leadingVisual = leadingVisual) !== null && _leadingVisual !== void 0 ? _leadingVisual : Icon;
|
|
122
|
-
let t8;
|
|
123
|
-
if ($[19] !== Component || $[20] !== ariaCurrent || $[21] !== children || $[22] !== clickHandler || $[23] !== counter || $[24] !== href || $[25] !== iconsVisible || $[26] !== keyDownHandler || $[27] !== loadingCounters || $[28] !== props || $[29] !== ref || $[30] !== t7) {
|
|
124
|
-
t8 = /*#__PURE__*/jsx("li", {
|
|
125
|
-
className: classes.UnderlineNavItem,
|
|
126
|
-
children: /*#__PURE__*/jsx(UnderlineItem, {
|
|
127
|
-
ref: ref,
|
|
128
|
-
as: Component,
|
|
129
|
-
href: href,
|
|
130
|
-
"aria-current": ariaCurrent,
|
|
131
|
-
onKeyDown: keyDownHandler,
|
|
132
|
-
onClick: clickHandler,
|
|
133
|
-
counter: counter,
|
|
134
|
-
icon: t7,
|
|
135
|
-
loadingCounters: loadingCounters,
|
|
136
|
-
iconsVisible: iconsVisible,
|
|
137
|
-
...props,
|
|
138
|
-
children: children
|
|
139
|
-
})
|
|
140
|
-
});
|
|
141
|
-
$[19] = Component;
|
|
142
|
-
$[20] = ariaCurrent;
|
|
143
|
-
$[21] = children;
|
|
144
|
-
$[22] = clickHandler;
|
|
145
|
-
$[23] = counter;
|
|
146
|
-
$[24] = href;
|
|
147
|
-
$[25] = iconsVisible;
|
|
148
|
-
$[26] = keyDownHandler;
|
|
149
|
-
$[27] = loadingCounters;
|
|
150
|
-
$[28] = props;
|
|
151
|
-
$[29] = ref;
|
|
152
|
-
$[30] = t7;
|
|
153
|
-
$[31] = t8;
|
|
154
|
-
} else {
|
|
155
|
-
t8 = $[31];
|
|
156
|
-
}
|
|
157
|
-
return t8;
|
|
27
|
+
useIsomorphicLayoutEffect(() => {
|
|
28
|
+
if (ref.current) {
|
|
29
|
+
const domRect = ref.current.getBoundingClientRect();
|
|
30
|
+
const icon = Array.from(ref.current.children).find(child => child.getAttribute('data-component') === 'icon');
|
|
31
|
+
const content = Array.from(ref.current.children).find(child => child.getAttribute('data-component') === 'text');
|
|
32
|
+
const text = content.textContent;
|
|
33
|
+
const iconWidthWithMargin = icon ? icon.getBoundingClientRect().width + Number(getComputedStyle(icon).marginRight.slice(0, -2)) + Number(getComputedStyle(icon).marginLeft.slice(0, -2)) : 0;
|
|
34
|
+
setChildrenWidth({
|
|
35
|
+
text,
|
|
36
|
+
width: domRect.width
|
|
37
|
+
});
|
|
38
|
+
setNoIconChildrenWidth({
|
|
39
|
+
text,
|
|
40
|
+
width: domRect.width - iconWidthWithMargin
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, [ref, setChildrenWidth, setNoIconChildrenWidth]);
|
|
44
|
+
const keyDownHandler = React.useCallback(event => {
|
|
45
|
+
if ((event.key === ' ' || event.key === 'Enter') && !event.defaultPrevented && typeof onSelect === 'function') {
|
|
46
|
+
onSelect(event);
|
|
47
|
+
}
|
|
48
|
+
}, [onSelect]);
|
|
49
|
+
const clickHandler = React.useCallback(event => {
|
|
50
|
+
if (!event.defaultPrevented && typeof onSelect === 'function') {
|
|
51
|
+
onSelect(event);
|
|
52
|
+
}
|
|
53
|
+
}, [onSelect]);
|
|
54
|
+
return /*#__PURE__*/jsx("li", {
|
|
55
|
+
className: classes.UnderlineNavItem,
|
|
56
|
+
children: /*#__PURE__*/jsx(UnderlineItem, {
|
|
57
|
+
ref: ref,
|
|
58
|
+
as: Component,
|
|
59
|
+
href: href,
|
|
60
|
+
"aria-current": ariaCurrent,
|
|
61
|
+
onKeyDown: keyDownHandler,
|
|
62
|
+
onClick: clickHandler,
|
|
63
|
+
counter: counter,
|
|
64
|
+
icon: leadingVisual !== null && leadingVisual !== void 0 ? leadingVisual : Icon,
|
|
65
|
+
loadingCounters: loadingCounters,
|
|
66
|
+
iconsVisible: iconsVisible,
|
|
67
|
+
...props,
|
|
68
|
+
children: children
|
|
69
|
+
})
|
|
70
|
+
});
|
|
158
71
|
});
|
|
159
72
|
UnderlineNavItem.displayName = 'UnderlineNavItem';
|
|
160
|
-
function _temp(child) {
|
|
161
|
-
return child.getAttribute("data-component") === "icon";
|
|
162
|
-
}
|
|
163
|
-
function _temp2(child_0) {
|
|
164
|
-
return child_0.getAttribute("data-component") === "text";
|
|
165
|
-
}
|
|
166
73
|
|
|
167
74
|
export { UnderlineNavItem };
|