@primer/react 38.47.0-rc.207872287 → 38.47.0-rc.2f87f01e5
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 +4 -0
- package/dist/ActionList/List.js +43 -50
- package/dist/AnchoredOverlay/AnchoredOverlay.js +1 -10
- package/dist/ButtonGroup/ButtonGroup.js +20 -27
- package/dist/Checkbox/Checkbox.js +47 -61
- package/dist/Dialog/Dialog.js +4 -10
- package/dist/FeatureFlags/DefaultFeatureFlags.js +0 -1
- package/dist/FilteredActionList/FilteredActionList.js +17 -36
- package/dist/PageHeader/PageHeader.js +31 -41
- package/dist/TextInput/TextInput.js +107 -114
- package/dist/TooltipV2/Tooltip.js +76 -87
- package/dist/experimental/Tabs/useTabList.js +14 -21
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +40 -52
- package/package.json +3 -4
|
@@ -7,12 +7,10 @@ import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
|
7
7
|
import { FilteredActionListBodyLoader } from "./FilteredActionListLoaders.js";
|
|
8
8
|
import FilteredActionList_module_css_default from "./FilteredActionList.module.css.js";
|
|
9
9
|
import Checkbox from "../Checkbox/Checkbox.js";
|
|
10
|
+
import { FilteredActionListLoadingTypes } from "./constants.js";
|
|
10
11
|
import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
|
|
11
12
|
import { useAnnouncements } from "./useAnnouncements.js";
|
|
12
|
-
import { FilteredActionListLoadingTypes } from "./constants.js";
|
|
13
13
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
14
|
-
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
15
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
16
14
|
import { FilteredActionListInput } from "./FilteredActionListInput.js";
|
|
17
15
|
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
18
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -26,7 +24,7 @@ const menuScrollMargins = {
|
|
|
26
24
|
endMargin: 8
|
|
27
25
|
};
|
|
28
26
|
function FilteredActionList({ loading = false, placeholderText, filterValue: externalFilterValue, loadingType = FilteredActionListLoadingTypes.bodySpinner, onFilterChange, onListContainerRefChanged, onInputRefChanged, items, textInputProps, inputRef: providedInputRef, scrollContainerRef: providedScrollContainerRef, groupMetadata, showItemDividers, message, messageText, className, selectionVariant, announcementsEnabled = true, fullScreenOnNarrow, onSelectAllChange, actionListProps, focusOutBehavior = "wrap", _PrivateFocusManagement = "active-descendant", onActiveDescendantChanged, disableSelectOnHover = false, setInitialFocus = false, focusPrependedElements, scrollBehavior, virtualized = false, ...listProps }) {
|
|
29
|
-
var
|
|
27
|
+
var _scrollContainerRef$c;
|
|
30
28
|
if (virtualized && groupMetadata !== null && groupMetadata !== void 0 && groupMetadata.length) console.warn("FilteredActionList: `virtualized` has no effect when `groupMetadata` is provided. Grouped lists are rendered without virtualization.");
|
|
31
29
|
const isVirtualized = virtualized && !(groupMetadata !== null && groupMetadata !== void 0 && groupMetadata.length);
|
|
32
30
|
const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate(externalFilterValue, void 0, "");
|
|
@@ -37,17 +35,10 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
37
35
|
}, [onFilterChange, setInternalFilterValue]);
|
|
38
36
|
const inputAndListContainerRef = useRef(null);
|
|
39
37
|
const listRef = useRef(null);
|
|
40
|
-
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
41
38
|
const scrollContainerRef = useRef(null);
|
|
42
39
|
const mergedScrollContainerRef = useMergedRefs(scrollContainerRef, providedScrollContainerRef);
|
|
43
|
-
const providedOrCreatedScrollContainerRef = useProvidedRefOrCreate(providedScrollContainerRef);
|
|
44
|
-
const readScrollContainerRef = mergedRefEnabled ? scrollContainerRef : providedOrCreatedScrollContainerRef;
|
|
45
|
-
const appliedScrollContainerRef = mergedRefEnabled ? mergedScrollContainerRef : providedOrCreatedScrollContainerRef;
|
|
46
40
|
const inputRef = useRef(null);
|
|
47
41
|
const mergedInputRef = useMergedRefs(inputRef, providedInputRef);
|
|
48
|
-
const providedOrCreatedInputRef = useProvidedRefOrCreate(providedInputRef);
|
|
49
|
-
const readInputRef = mergedRefEnabled ? inputRef : providedOrCreatedInputRef;
|
|
50
|
-
const appliedInputRef = mergedRefEnabled ? mergedInputRef : providedOrCreatedInputRef;
|
|
51
42
|
const usingRovingTabindex = _PrivateFocusManagement === "roving-tabindex";
|
|
52
43
|
const [listContainerElement, setListContainerElement] = useState(null);
|
|
53
44
|
const activeDescendantRef = useRef();
|
|
@@ -102,12 +93,12 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
102
93
|
onListContainerRefChanged === null || onListContainerRefChanged === void 0 || onListContainerRefChanged(node);
|
|
103
94
|
}, [onListContainerRefChanged]);
|
|
104
95
|
useEffect(() => {
|
|
105
|
-
onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(
|
|
106
|
-
}, [
|
|
96
|
+
onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(inputRef);
|
|
97
|
+
}, [onInputRefChanged]);
|
|
107
98
|
const DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
|
|
108
99
|
const virtualizer = useVirtualizer({
|
|
109
100
|
count: items.length,
|
|
110
|
-
getScrollElement: () =>
|
|
101
|
+
getScrollElement: () => scrollContainerRef.current,
|
|
111
102
|
estimateSize: () => DEFAULT_VIRTUAL_ITEM_HEIGHT,
|
|
112
103
|
overscan: 10,
|
|
113
104
|
enabled: isVirtualized,
|
|
@@ -141,7 +132,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
141
132
|
focusableElementFilter: (element) => {
|
|
142
133
|
return !(element instanceof HTMLInputElement);
|
|
143
134
|
},
|
|
144
|
-
activeDescendantFocus:
|
|
135
|
+
activeDescendantFocus: inputRef,
|
|
145
136
|
onActiveDescendantChanged: (current, previous, directlyActivated) => {
|
|
146
137
|
activeDescendantRef.current = current;
|
|
147
138
|
if (isVirtualized && current) {
|
|
@@ -149,7 +140,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
149
140
|
const range = virtualizer.range;
|
|
150
141
|
if (index !== null && range && (Number(index) < range.startIndex || Number(index) >= range.endIndex)) virtualizer.scrollToIndex(Number(index), { align: "auto" });
|
|
151
142
|
}
|
|
152
|
-
if (current &&
|
|
143
|
+
if (current && scrollContainerRef.current && (directlyActivated || focusPrependedElements)) scrollIntoView(current, scrollContainerRef.current, {
|
|
153
144
|
...menuScrollMargins,
|
|
154
145
|
behavior: scrollBehavior
|
|
155
146
|
});
|
|
@@ -166,16 +157,11 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
166
157
|
isVirtualized
|
|
167
158
|
]);
|
|
168
159
|
useEffect(() => {
|
|
169
|
-
if (activeDescendantRef.current &&
|
|
160
|
+
if (activeDescendantRef.current && scrollContainerRef.current) scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, {
|
|
170
161
|
...menuScrollMargins,
|
|
171
162
|
behavior: scrollBehavior
|
|
172
163
|
});
|
|
173
|
-
}, [
|
|
174
|
-
items,
|
|
175
|
-
readInputRef,
|
|
176
|
-
readScrollContainerRef,
|
|
177
|
-
scrollBehavior
|
|
178
|
-
]);
|
|
164
|
+
}, [items, scrollBehavior]);
|
|
179
165
|
useEffect(() => {
|
|
180
166
|
if (usingRovingTabindex) {
|
|
181
167
|
const inputAndListContainerElement = inputAndListContainerRef.current;
|
|
@@ -183,7 +169,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
183
169
|
const list = listRef.current;
|
|
184
170
|
if (!list) return;
|
|
185
171
|
const handleFocusIn = (event) => {
|
|
186
|
-
if (event.target ===
|
|
172
|
+
if (event.target === inputRef.current || list.contains(event.target)) setIsInputFocused(inputRef.current && inputRef.current === document.activeElement ? true : false);
|
|
187
173
|
};
|
|
188
174
|
inputAndListContainerElement.addEventListener("focusin", handleFocusIn);
|
|
189
175
|
return () => {
|
|
@@ -192,23 +178,18 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
192
178
|
}
|
|
193
179
|
}, [
|
|
194
180
|
items,
|
|
195
|
-
readInputRef,
|
|
196
181
|
listContainerElement,
|
|
197
182
|
usingRovingTabindex
|
|
198
183
|
]);
|
|
199
184
|
useEffect(() => {
|
|
200
|
-
if (usingRovingTabindex && !loading) setIsInputFocused(
|
|
201
|
-
}, [
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
usingRovingTabindex
|
|
205
|
-
]);
|
|
206
|
-
const onInputFocus = useAnnouncements(items, listRef, readInputRef, announcementsEnabled, loading, messageText, _PrivateFocusManagement, filterValue);
|
|
207
|
-
useScrollFlash(readScrollContainerRef);
|
|
185
|
+
if (usingRovingTabindex && !loading) setIsInputFocused(inputRef.current && inputRef.current === document.activeElement ? true : false);
|
|
186
|
+
}, [loading, usingRovingTabindex]);
|
|
187
|
+
const onInputFocus = useAnnouncements(items, listRef, inputRef, announcementsEnabled, loading, messageText, _PrivateFocusManagement, filterValue);
|
|
188
|
+
useScrollFlash(scrollContainerRef);
|
|
208
189
|
const handleSelectAllChange = useCallback((e) => {
|
|
209
190
|
if (onSelectAllChange) onSelectAllChange(e.target.checked);
|
|
210
191
|
}, [onSelectAllChange]);
|
|
211
|
-
const bodyLoaderHeight = loading && loadingType.appearsInBody ? (
|
|
192
|
+
const bodyLoaderHeight = loading && loadingType.appearsInBody ? (_scrollContainerRef$c = scrollContainerRef.current) === null || _scrollContainerRef$c === void 0 ? void 0 : _scrollContainerRef$c.clientHeight : void 0;
|
|
212
193
|
const showBodyLoader = bodyLoaderHeight !== void 0;
|
|
213
194
|
const isListRendered = !showBodyLoader && !message;
|
|
214
195
|
function getBodyContent() {
|
|
@@ -306,7 +287,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
306
287
|
"data-component": "FilteredActionList",
|
|
307
288
|
children: [
|
|
308
289
|
/* @__PURE__ */ jsx(FilteredActionListInput, {
|
|
309
|
-
inputRef:
|
|
290
|
+
inputRef: mergedInputRef,
|
|
310
291
|
onInputFocus,
|
|
311
292
|
value: filterValue,
|
|
312
293
|
onInputChange,
|
|
@@ -341,7 +322,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
341
322
|
})]
|
|
342
323
|
}),
|
|
343
324
|
/* @__PURE__ */ jsx("div", {
|
|
344
|
-
ref:
|
|
325
|
+
ref: mergedScrollContainerRef,
|
|
345
326
|
className: FilteredActionList_module_css_default.Container,
|
|
346
327
|
children: getBodyContent()
|
|
347
328
|
})
|
|
@@ -6,8 +6,6 @@ import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttribut
|
|
|
6
6
|
import { areAllValuesTheSame, haveRegularAndWideSameValue } from "../utils/getBreakpointDeclarations.js";
|
|
7
7
|
import { warning } from "../utils/warning.js";
|
|
8
8
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
9
|
-
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
10
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
11
9
|
import PageHeader_module_css_default from "./PageHeader.module.css.js";
|
|
12
10
|
import { isSlot } from "../utils/is-slot.js";
|
|
13
11
|
import React, { useEffect, useRef } from "react";
|
|
@@ -26,15 +24,11 @@ const hiddenOnNarrow = {
|
|
|
26
24
|
wide: false
|
|
27
25
|
};
|
|
28
26
|
const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
29
|
-
const $ = c(
|
|
27
|
+
const $ = c(16);
|
|
30
28
|
const { children, className, as: t1, "aria-label": ariaLabel, role, hasBorder } = t0;
|
|
31
29
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
32
|
-
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
33
30
|
const rootRef = useRef(null);
|
|
34
31
|
const mergedRef = useMergedRefs(rootRef, forwardedRef);
|
|
35
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
36
|
-
const readRef = mergedRefEnabled ? rootRef : providedOrCreatedRef;
|
|
37
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
38
32
|
const hoistChildState = (nodes) => {
|
|
39
33
|
const result = { hasNavigation: false };
|
|
40
34
|
for (const child of React.Children.toArray(nodes)) {
|
|
@@ -61,12 +55,12 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
61
55
|
const isInteractive = _temp;
|
|
62
56
|
let t2;
|
|
63
57
|
let t3;
|
|
64
|
-
if ($[0] !== children
|
|
58
|
+
if ($[0] !== children) {
|
|
65
59
|
t2 = function validateInteractiveElementsInTitle() {
|
|
66
60
|
let hasContextArea = false;
|
|
67
61
|
let hasLeadingAction = false;
|
|
68
|
-
if (!
|
|
69
|
-
const titleArea = Array.from(
|
|
62
|
+
if (!rootRef.current || rootRef.current.children.length <= 0) return;
|
|
63
|
+
const titleArea = Array.from(rootRef.current.children).find(_temp2);
|
|
70
64
|
if (!titleArea) return;
|
|
71
65
|
for (const child_1 of React.Children.toArray(children)) {
|
|
72
66
|
if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === ContextArea || isSlot(child_1, ContextArea))) hasContextArea = true;
|
|
@@ -75,31 +69,30 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
75
69
|
const hasInteractiveContent = Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3)));
|
|
76
70
|
warning(hasInteractiveContent && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
|
|
77
71
|
};
|
|
78
|
-
t3 = [children
|
|
72
|
+
t3 = [children];
|
|
79
73
|
$[0] = children;
|
|
80
|
-
$[1] =
|
|
81
|
-
$[2] =
|
|
82
|
-
$[3] = t3;
|
|
74
|
+
$[1] = t2;
|
|
75
|
+
$[2] = t3;
|
|
83
76
|
} else {
|
|
84
|
-
t2 = $[
|
|
85
|
-
t3 = $[
|
|
77
|
+
t2 = $[1];
|
|
78
|
+
t3 = $[2];
|
|
86
79
|
}
|
|
87
80
|
useEffect(t2, t3);
|
|
88
81
|
let t4;
|
|
89
|
-
if ($[
|
|
82
|
+
if ($[3] !== className) {
|
|
90
83
|
t4 = clsx(PageHeader_module_css_default.PageHeader, className);
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
} else t4 = $[
|
|
84
|
+
$[3] = className;
|
|
85
|
+
$[4] = t4;
|
|
86
|
+
} else t4 = $[4];
|
|
94
87
|
const t5 = "PageHeader";
|
|
95
88
|
const t6 = hasBorder ? "true" : void 0;
|
|
96
89
|
const t7 = hasNavigation ? "" : void 0;
|
|
97
90
|
const t8 = getResponsiveAttributes("title-size-variant", titleVariant);
|
|
98
91
|
const t9 = getNavHiddenDataAttributes(navigationHidden);
|
|
99
92
|
let t10;
|
|
100
|
-
if ($[
|
|
93
|
+
if ($[5] !== BaseComponent || $[6] !== ariaLabel || $[7] !== children || $[8] !== mergedRef || $[9] !== role || $[10] !== t4 || $[11] !== t6 || $[12] !== t7 || $[13] !== t8 || $[14] !== t9) {
|
|
101
94
|
t10 = /* @__PURE__ */ jsx(BaseComponent, {
|
|
102
|
-
ref:
|
|
95
|
+
ref: mergedRef,
|
|
103
96
|
className: t4,
|
|
104
97
|
"data-component": t5,
|
|
105
98
|
"data-has-border": t6,
|
|
@@ -110,18 +103,18 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
110
103
|
role,
|
|
111
104
|
children
|
|
112
105
|
});
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
} else t10 = $[
|
|
106
|
+
$[5] = BaseComponent;
|
|
107
|
+
$[6] = ariaLabel;
|
|
108
|
+
$[7] = children;
|
|
109
|
+
$[8] = mergedRef;
|
|
110
|
+
$[9] = role;
|
|
111
|
+
$[10] = t4;
|
|
112
|
+
$[11] = t6;
|
|
113
|
+
$[12] = t7;
|
|
114
|
+
$[13] = t8;
|
|
115
|
+
$[14] = t9;
|
|
116
|
+
$[15] = t10;
|
|
117
|
+
} else t10 = $[15];
|
|
125
118
|
return t10;
|
|
126
119
|
});
|
|
127
120
|
const ContextArea = (t0) => {
|
|
@@ -303,9 +296,6 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
303
296
|
const { children, className, hidden: t1, variant: t2 } = t0;
|
|
304
297
|
const hidden = t1 === void 0 ? false : t1;
|
|
305
298
|
const variant = t2 === void 0 ? "medium" : t2;
|
|
306
|
-
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
307
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
308
|
-
const appliedRef = mergedRefEnabled ? forwardedRef : providedOrCreatedRef;
|
|
309
299
|
let t3;
|
|
310
300
|
if ($[0] !== className) {
|
|
311
301
|
t3 = clsx(PageHeader_module_css_default.TitleArea, className);
|
|
@@ -325,17 +315,17 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
325
315
|
$[5] = t5;
|
|
326
316
|
} else t5 = $[5];
|
|
327
317
|
let t6;
|
|
328
|
-
if ($[6] !==
|
|
318
|
+
if ($[6] !== children || $[7] !== forwardedRef || $[8] !== t3 || $[9] !== t4 || $[10] !== t5) {
|
|
329
319
|
t6 = /* @__PURE__ */ jsx("div", {
|
|
330
320
|
className: t3,
|
|
331
|
-
ref:
|
|
321
|
+
ref: forwardedRef,
|
|
332
322
|
"data-component": "TitleArea",
|
|
333
323
|
...t4,
|
|
334
324
|
...t5,
|
|
335
325
|
children
|
|
336
326
|
});
|
|
337
|
-
$[6] =
|
|
338
|
-
$[7] =
|
|
327
|
+
$[6] = children;
|
|
328
|
+
$[7] = forwardedRef;
|
|
339
329
|
$[8] = t3;
|
|
340
330
|
$[9] = t4;
|
|
341
331
|
$[10] = t5;
|
|
@@ -10,8 +10,6 @@ import { getCharacterCountState } from "../utils/character-counter.js";
|
|
|
10
10
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
11
11
|
import Text_default from "../Text/Text.js";
|
|
12
12
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
13
|
-
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
14
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
15
13
|
import React, { useId, useRef, useState } from "react";
|
|
16
14
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
15
|
import { clsx } from "clsx";
|
|
@@ -20,18 +18,14 @@ import { AlertFillIcon } from "@primer/octicons-react";
|
|
|
20
18
|
// src/TextInput/TextInput.tsx
|
|
21
19
|
const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
22
20
|
var _counter$isOverLimit;
|
|
23
|
-
const $ = c(
|
|
21
|
+
const $ = c(79);
|
|
24
22
|
const { icon: IconComponent, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, trailingAction, block, className, contrast, disabled, loading, loaderPosition: t1, loaderText: t2, monospace, validationStatus, size: sizeProp, onFocus, onBlur, variant: variantProp, width: widthProp, minWidth: minWidthProp, maxWidth: maxWidthProp, type: t3, required, characterLimit, onChange, value, defaultValue, "data-component": dataComponent, ...inputProps } = t0;
|
|
25
23
|
const loaderPosition = t1 === void 0 ? "auto" : t1;
|
|
26
24
|
const loaderText = t2 === void 0 ? "Loading" : t2;
|
|
27
25
|
const type = t3 === void 0 ? "text" : t3;
|
|
28
26
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
29
|
-
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
30
27
|
const inputRef = useRef(null);
|
|
31
28
|
const mergedRef = useMergedRefs(inputRef, ref);
|
|
32
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
33
|
-
const readRef = mergedRefEnabled ? inputRef : providedOrCreatedRef;
|
|
34
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
35
29
|
const isControlled = value !== void 0;
|
|
36
30
|
let t4;
|
|
37
31
|
if ($[0] !== defaultValue) {
|
|
@@ -54,53 +48,52 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
54
48
|
const showTrailingLoadingIndicator = loading && (loaderPosition === "trailing" || Boolean(loaderPosition === "auto" && !LeadingVisual));
|
|
55
49
|
const isSegmentedInputType = type === "date" || type === "time" || type === "datetime-local";
|
|
56
50
|
let t6;
|
|
57
|
-
if ($[4] !== isSegmentedInputType
|
|
51
|
+
if ($[4] !== isSegmentedInputType) {
|
|
58
52
|
t6 = (e) => {
|
|
59
|
-
if (e.target !==
|
|
60
|
-
var
|
|
61
|
-
(
|
|
53
|
+
if (e.target !== inputRef.current || !isSegmentedInputType) {
|
|
54
|
+
var _inputRef$current;
|
|
55
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
62
56
|
}
|
|
63
57
|
};
|
|
64
58
|
$[4] = isSegmentedInputType;
|
|
65
|
-
$[5] =
|
|
66
|
-
|
|
67
|
-
} else t6 = $[6];
|
|
59
|
+
$[5] = t6;
|
|
60
|
+
} else t6 = $[5];
|
|
68
61
|
const focusInput = t6;
|
|
69
62
|
const leadingVisualId = useId();
|
|
70
63
|
const trailingVisualId = useId();
|
|
71
64
|
const loadingId = useId();
|
|
72
65
|
const inputDescribedBy = clsx(inputProps["aria-describedby"], LeadingVisual && leadingVisualId, TrailingVisual && trailingVisualId, loading && loadingId) || void 0;
|
|
73
66
|
let t7;
|
|
74
|
-
if ($[
|
|
67
|
+
if ($[6] !== onFocus) {
|
|
75
68
|
t7 = (e_0) => {
|
|
76
69
|
setIsInputFocused(true);
|
|
77
70
|
onFocus && onFocus(e_0);
|
|
78
71
|
};
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
} else t7 = $[
|
|
72
|
+
$[6] = onFocus;
|
|
73
|
+
$[7] = t7;
|
|
74
|
+
} else t7 = $[7];
|
|
82
75
|
const handleInputFocus = t7;
|
|
83
76
|
let t8;
|
|
84
|
-
if ($[
|
|
77
|
+
if ($[8] !== onBlur) {
|
|
85
78
|
t8 = (e_1) => {
|
|
86
79
|
setIsInputFocused(false);
|
|
87
80
|
onBlur && onBlur(e_1);
|
|
88
81
|
};
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
} else t8 = $[
|
|
82
|
+
$[8] = onBlur;
|
|
83
|
+
$[9] = t8;
|
|
84
|
+
} else t8 = $[9];
|
|
92
85
|
const handleInputBlur = t8;
|
|
93
86
|
let t9;
|
|
94
|
-
if ($[
|
|
87
|
+
if ($[10] !== characterLimit || $[11] !== isControlled || $[12] !== onChange) {
|
|
95
88
|
t9 = (e_2) => {
|
|
96
89
|
if (characterLimit && !isControlled) setUncontrolledLength(e_2.target.value.length);
|
|
97
90
|
onChange === null || onChange === void 0 || onChange(e_2);
|
|
98
91
|
};
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
} else t9 = $[
|
|
92
|
+
$[10] = characterLimit;
|
|
93
|
+
$[11] = isControlled;
|
|
94
|
+
$[12] = onChange;
|
|
95
|
+
$[13] = t9;
|
|
96
|
+
} else t9 = $[13];
|
|
104
97
|
const handleInputChange = t9;
|
|
105
98
|
const characterCountId = useId();
|
|
106
99
|
const characterCountStaticMessageId = useId();
|
|
@@ -110,23 +103,23 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
110
103
|
const t12 = Boolean(trailingAction);
|
|
111
104
|
const t13 = Boolean(loading);
|
|
112
105
|
let t14;
|
|
113
|
-
if ($[
|
|
106
|
+
if ($[14] !== IconComponent) {
|
|
114
107
|
t14 = IconComponent && /* @__PURE__ */ jsx(IconComponent, {
|
|
115
108
|
className: "TextInput-icon",
|
|
116
109
|
"data-component": "TextInput.Icon"
|
|
117
110
|
});
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
} else t14 = $[
|
|
111
|
+
$[14] = IconComponent;
|
|
112
|
+
$[15] = t14;
|
|
113
|
+
} else t14 = $[15];
|
|
121
114
|
const t15 = typeof loading === "boolean";
|
|
122
115
|
let t16;
|
|
123
|
-
if ($[
|
|
116
|
+
if ($[16] !== LeadingVisual) {
|
|
124
117
|
t16 = typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /* @__PURE__ */ jsx(LeadingVisual, {}) : LeadingVisual;
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
} else t16 = $[
|
|
118
|
+
$[16] = LeadingVisual;
|
|
119
|
+
$[17] = t16;
|
|
120
|
+
} else t16 = $[17];
|
|
128
121
|
let t17;
|
|
129
|
-
if ($[
|
|
122
|
+
if ($[18] !== leadingVisualId || $[19] !== showLeadingLoadingIndicator || $[20] !== t15 || $[21] !== t16) {
|
|
130
123
|
t17 = /* @__PURE__ */ jsx(TextInputInnerVisualSlot, {
|
|
131
124
|
visualPosition: "leading",
|
|
132
125
|
showLoadingIndicator: showLeadingLoadingIndicator,
|
|
@@ -134,26 +127,26 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
134
127
|
id: leadingVisualId,
|
|
135
128
|
children: t16
|
|
136
129
|
});
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
} else t17 = $[
|
|
130
|
+
$[18] = leadingVisualId;
|
|
131
|
+
$[19] = showLeadingLoadingIndicator;
|
|
132
|
+
$[20] = t15;
|
|
133
|
+
$[21] = t16;
|
|
134
|
+
$[22] = t17;
|
|
135
|
+
} else t17 = $[22];
|
|
143
136
|
const t18 = isValid === "error" ? "true" : void 0;
|
|
144
137
|
let t19;
|
|
145
|
-
if ($[
|
|
138
|
+
if ($[23] !== characterCountStaticMessageId || $[24] !== characterLimit || $[25] !== inputDescribedBy) {
|
|
146
139
|
t19 = characterLimit ? [characterCountStaticMessageId, inputDescribedBy].filter(Boolean).join(" ") || void 0 : inputDescribedBy;
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
} else t19 = $[
|
|
140
|
+
$[23] = characterCountStaticMessageId;
|
|
141
|
+
$[24] = characterLimit;
|
|
142
|
+
$[25] = inputDescribedBy;
|
|
143
|
+
$[26] = t19;
|
|
144
|
+
} else t19 = $[26];
|
|
152
145
|
const t20 = dataComponent !== null && dataComponent !== void 0 ? dataComponent : "input";
|
|
153
146
|
let t21;
|
|
154
|
-
if ($[
|
|
147
|
+
if ($[27] !== defaultValue || $[28] !== disabled || $[29] !== handleInputBlur || $[30] !== handleInputChange || $[31] !== handleInputFocus || $[32] !== inputProps || $[33] !== mergedRef || $[34] !== required || $[35] !== t18 || $[36] !== t19 || $[37] !== t20 || $[38] !== type || $[39] !== value) {
|
|
155
148
|
t21 = /* @__PURE__ */ jsx(UnstyledTextInput, {
|
|
156
|
-
ref:
|
|
149
|
+
ref: mergedRef,
|
|
157
150
|
disabled,
|
|
158
151
|
onFocus: handleInputFocus,
|
|
159
152
|
onBlur: handleInputBlur,
|
|
@@ -167,41 +160,41 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
167
160
|
"aria-describedby": t19,
|
|
168
161
|
"data-component": t20
|
|
169
162
|
});
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
} else t21 = $[
|
|
163
|
+
$[27] = defaultValue;
|
|
164
|
+
$[28] = disabled;
|
|
165
|
+
$[29] = handleInputBlur;
|
|
166
|
+
$[30] = handleInputChange;
|
|
167
|
+
$[31] = handleInputFocus;
|
|
168
|
+
$[32] = inputProps;
|
|
169
|
+
$[33] = mergedRef;
|
|
170
|
+
$[34] = required;
|
|
171
|
+
$[35] = t18;
|
|
172
|
+
$[36] = t19;
|
|
173
|
+
$[37] = t20;
|
|
174
|
+
$[38] = type;
|
|
175
|
+
$[39] = value;
|
|
176
|
+
$[40] = t21;
|
|
177
|
+
} else t21 = $[40];
|
|
185
178
|
let t22;
|
|
186
|
-
if ($[
|
|
179
|
+
if ($[41] !== loaderText || $[42] !== loading || $[43] !== loadingId) {
|
|
187
180
|
t22 = loading && /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
188
181
|
id: loadingId,
|
|
189
182
|
children: loaderText
|
|
190
183
|
});
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
} else t22 = $[
|
|
184
|
+
$[41] = loaderText;
|
|
185
|
+
$[42] = loading;
|
|
186
|
+
$[43] = loadingId;
|
|
187
|
+
$[44] = t22;
|
|
188
|
+
} else t22 = $[44];
|
|
196
189
|
const t23 = typeof loading === "boolean";
|
|
197
190
|
let t24;
|
|
198
|
-
if ($[
|
|
191
|
+
if ($[45] !== TrailingVisual) {
|
|
199
192
|
t24 = typeof TrailingVisual !== "string" && isValidElementType(TrailingVisual) ? /* @__PURE__ */ jsx(TrailingVisual, {}) : TrailingVisual;
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
} else t24 = $[
|
|
193
|
+
$[45] = TrailingVisual;
|
|
194
|
+
$[46] = t24;
|
|
195
|
+
} else t24 = $[46];
|
|
203
196
|
let t25;
|
|
204
|
-
if ($[
|
|
197
|
+
if ($[47] !== showTrailingLoadingIndicator || $[48] !== t23 || $[49] !== t24 || $[50] !== trailingVisualId) {
|
|
205
198
|
t25 = /* @__PURE__ */ jsx(TextInputInnerVisualSlot, {
|
|
206
199
|
visualPosition: "trailing",
|
|
207
200
|
showLoadingIndicator: showTrailingLoadingIndicator,
|
|
@@ -210,14 +203,14 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
210
203
|
"data-testid": "text-input-trailing-visual",
|
|
211
204
|
children: t24
|
|
212
205
|
});
|
|
213
|
-
$[
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
} else t25 = $[
|
|
206
|
+
$[47] = showTrailingLoadingIndicator;
|
|
207
|
+
$[48] = t23;
|
|
208
|
+
$[49] = t24;
|
|
209
|
+
$[50] = trailingVisualId;
|
|
210
|
+
$[51] = t25;
|
|
211
|
+
} else t25 = $[51];
|
|
219
212
|
let t26;
|
|
220
|
-
if ($[
|
|
213
|
+
if ($[52] !== block || $[53] !== contrast || $[54] !== disabled || $[55] !== focusInput || $[56] !== isInputFocused || $[57] !== isValid || $[58] !== maxWidthProp || $[59] !== minWidthProp || $[60] !== monospace || $[61] !== sizeProp || $[62] !== t10 || $[63] !== t11 || $[64] !== t12 || $[65] !== t13 || $[66] !== t14 || $[67] !== t17 || $[68] !== t21 || $[69] !== t22 || $[70] !== t25 || $[71] !== trailingAction || $[72] !== variantProp || $[73] !== widthProp || $[74] !== wrapperClasses) {
|
|
221
214
|
t26 = /* @__PURE__ */ jsxs(TextInputWrapper, {
|
|
222
215
|
block,
|
|
223
216
|
className: wrapperClasses,
|
|
@@ -245,31 +238,31 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
245
238
|
trailingAction
|
|
246
239
|
]
|
|
247
240
|
});
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
$[
|
|
266
|
-
$[
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
269
|
-
$[
|
|
270
|
-
$[
|
|
271
|
-
$[
|
|
272
|
-
} else t26 = $[
|
|
241
|
+
$[52] = block;
|
|
242
|
+
$[53] = contrast;
|
|
243
|
+
$[54] = disabled;
|
|
244
|
+
$[55] = focusInput;
|
|
245
|
+
$[56] = isInputFocused;
|
|
246
|
+
$[57] = isValid;
|
|
247
|
+
$[58] = maxWidthProp;
|
|
248
|
+
$[59] = minWidthProp;
|
|
249
|
+
$[60] = monospace;
|
|
250
|
+
$[61] = sizeProp;
|
|
251
|
+
$[62] = t10;
|
|
252
|
+
$[63] = t11;
|
|
253
|
+
$[64] = t12;
|
|
254
|
+
$[65] = t13;
|
|
255
|
+
$[66] = t14;
|
|
256
|
+
$[67] = t17;
|
|
257
|
+
$[68] = t21;
|
|
258
|
+
$[69] = t22;
|
|
259
|
+
$[70] = t25;
|
|
260
|
+
$[71] = trailingAction;
|
|
261
|
+
$[72] = variantProp;
|
|
262
|
+
$[73] = widthProp;
|
|
263
|
+
$[74] = wrapperClasses;
|
|
264
|
+
$[75] = t26;
|
|
265
|
+
} else t26 = $[75];
|
|
273
266
|
const t27 = characterLimit && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
274
267
|
/* @__PURE__ */ jsx(AriaStatus, {
|
|
275
268
|
announceOnShow: false,
|
|
@@ -296,12 +289,12 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
296
289
|
})
|
|
297
290
|
] });
|
|
298
291
|
let t28;
|
|
299
|
-
if ($[
|
|
292
|
+
if ($[76] !== t26 || $[77] !== t27) {
|
|
300
293
|
t28 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t26, t27] });
|
|
301
|
-
$[
|
|
302
|
-
$[
|
|
303
|
-
$[
|
|
304
|
-
} else t28 = $[
|
|
294
|
+
$[76] = t26;
|
|
295
|
+
$[77] = t27;
|
|
296
|
+
$[78] = t28;
|
|
297
|
+
} else t28 = $[78];
|
|
305
298
|
return t28;
|
|
306
299
|
});
|
|
307
300
|
TextInput.displayName = "TextInput";
|