@primer/react 0.0.0-20260312192106 → 0.0.0-20260312204752
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 +32 -4
- package/dist/ActionList/Item.d.ts.map +1 -1
- package/dist/ActionList/Item.js +628 -192
- 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/List.d.ts.map +1 -1
- package/dist/ActionList/List.js +6 -5
- package/dist/ActionList/index.d.ts +25 -1
- package/dist/ActionList/index.d.ts.map +1 -1
- package/dist/Autocomplete/AutocompleteInput.js +3 -3
- package/dist/Autocomplete/AutocompleteOverlay.js +3 -3
- package/dist/Banner/Banner-41040ab7.css +2 -0
- package/dist/Banner/Banner-41040ab7.css.map +1 -0
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +1 -0
- package/dist/Banner/Banner.module.css.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 +19 -62
- package/dist/Button/{ButtonBase-781fba8b.css → ButtonBase-6659abcf.css} +2 -2
- package/dist/Button/{ButtonBase-781fba8b.css.map → ButtonBase-6659abcf.css.map} +1 -1
- package/dist/Button/ButtonBase.d.ts.map +1 -1
- package/dist/Button/ButtonBase.js +4 -3
- package/dist/Button/ButtonBase.module.css.js +1 -1
- package/dist/Dialog/{Dialog-2d417a89.css → Dialog-2de477b3.css} +2 -2
- package/dist/Dialog/{Dialog-2d417a89.css.map → Dialog-2de477b3.css.map} +1 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +6 -4
- package/dist/Dialog/Dialog.module.css.js +2 -2
- package/dist/Heading/Heading.js +3 -3
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +4 -3
- package/dist/Overlay/{Overlay-15519c09.css → Overlay-dbaa6b8c.css} +2 -2
- package/dist/Overlay/Overlay-dbaa6b8c.css.map +1 -0
- package/dist/Overlay/Overlay.js +21 -22
- package/dist/Overlay/Overlay.module.css.js +1 -1
- package/dist/PageLayout/PageLayout.d.ts +4 -20
- package/dist/PageLayout/PageLayout.d.ts.map +1 -1
- package/dist/PageLayout/PageLayout.js +17 -5
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +30 -29
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +31 -5
- package/dist/TextInputWithTokens/TextInputWithTokens.js +95 -96
- package/dist/TreeView/TreeView.d.ts.map +1 -1
- package/dist/TreeView/TreeView.js +101 -59
- package/dist/TreeView/useRovingTabIndex.d.ts +14 -0
- package/dist/TreeView/useRovingTabIndex.d.ts.map +1 -1
- package/dist/TreeView/useRovingTabIndex.js +94 -16
- package/dist/deprecated/DialogV1/Dialog.js +11 -12
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- 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/utils/character-counter.d.ts.map +1 -1
- package/dist/utils/character-counter.js +1 -0
- package/generated/components.json +1 -1
- package/generated/hooks.json +0 -22
- package/package.json +1 -1
- package/dist/Banner/Banner-f672cdf9.css +0 -2
- package/dist/Banner/Banner-f672cdf9.css.map +0 -1
- package/dist/Overlay/Overlay-15519c09.css.map +0 -1
- package/dist/hooks/useCombinedRefs.d.ts +0 -51
- package/dist/hooks/useCombinedRefs.d.ts.map +0 -1
- package/dist/hooks/useCombinedRefs.js +0 -86
package/dist/Overlay/Overlay.js
CHANGED
|
@@ -2,7 +2,7 @@ import { c } from 'react-compiler-runtime';
|
|
|
2
2
|
import React, { useRef, useEffect } from 'react';
|
|
3
3
|
import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
|
|
4
4
|
import { Portal } from '../Portal/Portal.js';
|
|
5
|
-
import {
|
|
5
|
+
import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
|
|
6
6
|
import classes from './Overlay.module.css.js';
|
|
7
7
|
import { clsx } from 'clsx';
|
|
8
8
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -115,7 +115,7 @@ const BaseOverlay = /*#__PURE__*/React.forwardRef(({
|
|
|
115
115
|
|
|
116
116
|
*/
|
|
117
117
|
const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
118
|
-
const $ = c(
|
|
118
|
+
const $ = c(45);
|
|
119
119
|
let anchorSide;
|
|
120
120
|
let ignoreClickRefs;
|
|
121
121
|
let initialFocusRef;
|
|
@@ -196,7 +196,7 @@ const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
196
196
|
const visibility = t4 === undefined ? "visible" : t4;
|
|
197
197
|
const width = t5 === undefined ? "auto" : t5;
|
|
198
198
|
const overlayRef = useRef(null);
|
|
199
|
-
|
|
199
|
+
useRefObjectAsForwardedRef(forwardedRef, overlayRef);
|
|
200
200
|
let t6;
|
|
201
201
|
if ($[18] !== ignoreClickRefs || $[19] !== initialFocusRef || $[20] !== onClickOutside || $[21] !== onEscape || $[22] !== preventFocusOnOpen || $[23] !== returnFocusRef) {
|
|
202
202
|
t6 = {
|
|
@@ -269,12 +269,12 @@ const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
269
269
|
const leftPosition = left === undefined && right === undefined ? 0 : left;
|
|
270
270
|
const t11 = !preventOverflow ? true : undefined;
|
|
271
271
|
let t12;
|
|
272
|
-
if ($[32] !==
|
|
272
|
+
if ($[32] !== height || $[33] !== leftPosition || $[34] !== props || $[35] !== responsiveVariant || $[36] !== right || $[37] !== role || $[38] !== t11 || $[39] !== visibility || $[40] !== width) {
|
|
273
273
|
t12 = /*#__PURE__*/jsx(BaseOverlay, {
|
|
274
274
|
role: role,
|
|
275
275
|
width: width,
|
|
276
276
|
"data-reflow-container": t11,
|
|
277
|
-
ref:
|
|
277
|
+
ref: overlayRef,
|
|
278
278
|
left: leftPosition,
|
|
279
279
|
right: right,
|
|
280
280
|
height: height,
|
|
@@ -282,31 +282,30 @@ const Overlay = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
282
282
|
"data-responsive": responsiveVariant,
|
|
283
283
|
...props
|
|
284
284
|
});
|
|
285
|
-
$[32] =
|
|
286
|
-
$[33] =
|
|
287
|
-
$[34] =
|
|
288
|
-
$[35] =
|
|
289
|
-
$[36] =
|
|
290
|
-
$[37] =
|
|
291
|
-
$[38] =
|
|
292
|
-
$[39] =
|
|
293
|
-
$[40] =
|
|
294
|
-
$[41] =
|
|
295
|
-
$[42] = t12;
|
|
285
|
+
$[32] = height;
|
|
286
|
+
$[33] = leftPosition;
|
|
287
|
+
$[34] = props;
|
|
288
|
+
$[35] = responsiveVariant;
|
|
289
|
+
$[36] = right;
|
|
290
|
+
$[37] = role;
|
|
291
|
+
$[38] = t11;
|
|
292
|
+
$[39] = visibility;
|
|
293
|
+
$[40] = width;
|
|
294
|
+
$[41] = t12;
|
|
296
295
|
} else {
|
|
297
|
-
t12 = $[
|
|
296
|
+
t12 = $[41];
|
|
298
297
|
}
|
|
299
298
|
let t13;
|
|
300
|
-
if ($[
|
|
299
|
+
if ($[42] !== portalContainerName || $[43] !== t12) {
|
|
301
300
|
t13 = /*#__PURE__*/jsx(Portal, {
|
|
302
301
|
containerName: portalContainerName,
|
|
303
302
|
children: t12
|
|
304
303
|
});
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
307
|
-
$[
|
|
304
|
+
$[42] = portalContainerName;
|
|
305
|
+
$[43] = t12;
|
|
306
|
+
$[44] = t13;
|
|
308
307
|
} else {
|
|
309
|
-
t13 = $[
|
|
308
|
+
t13 = $[44];
|
|
310
309
|
}
|
|
311
310
|
return t13;
|
|
312
311
|
});
|
|
@@ -9,7 +9,7 @@ declare const SPACING_MAP: {
|
|
|
9
9
|
};
|
|
10
10
|
export type PageLayoutProps = {
|
|
11
11
|
/** The maximum width of the page container */
|
|
12
|
-
containerWidth?:
|
|
12
|
+
containerWidth?: 'full' | 'medium' | 'large' | 'xlarge';
|
|
13
13
|
/** The spacing between the outer edges of the page container and the viewport */
|
|
14
14
|
padding?: keyof typeof SPACING_MAP;
|
|
15
15
|
rowGap?: keyof typeof SPACING_MAP;
|
|
@@ -19,12 +19,6 @@ export type PageLayoutProps = {
|
|
|
19
19
|
className?: string;
|
|
20
20
|
style?: React.CSSProperties;
|
|
21
21
|
};
|
|
22
|
-
declare const containerWidths: {
|
|
23
|
-
full: string;
|
|
24
|
-
medium: string;
|
|
25
|
-
large: string;
|
|
26
|
-
xlarge: string;
|
|
27
|
-
};
|
|
28
22
|
export type PageLayoutHeaderProps = {
|
|
29
23
|
/**
|
|
30
24
|
* A unique label for the rendered banner landmark
|
|
@@ -69,20 +63,14 @@ export type PageLayoutContentProps = {
|
|
|
69
63
|
* An id to an element which uniquely labels the rendered main landmark
|
|
70
64
|
*/
|
|
71
65
|
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
|
|
72
|
-
width?:
|
|
66
|
+
width?: 'full' | 'medium' | 'large' | 'xlarge';
|
|
73
67
|
padding?: keyof typeof SPACING_MAP;
|
|
74
68
|
hidden?: boolean | ResponsiveValue<boolean>;
|
|
75
69
|
className?: string;
|
|
76
70
|
style?: React.CSSProperties;
|
|
77
71
|
};
|
|
78
|
-
declare const contentWidths: {
|
|
79
|
-
full: string;
|
|
80
|
-
medium: string;
|
|
81
|
-
large: string;
|
|
82
|
-
xlarge: string;
|
|
83
|
-
};
|
|
84
72
|
export type PageLayoutPaneBaseProps = {
|
|
85
|
-
position?:
|
|
73
|
+
position?: 'start' | 'end' | ResponsiveValue<'start' | 'end'>;
|
|
86
74
|
/**
|
|
87
75
|
* @deprecated Use the `position` prop with a responsive value instead.
|
|
88
76
|
*
|
|
@@ -97,7 +85,7 @@ export type PageLayoutPaneBaseProps = {
|
|
|
97
85
|
* position={{regular: 'start', narrow: 'end'}}
|
|
98
86
|
* ```
|
|
99
87
|
*/
|
|
100
|
-
positionWhenNarrow?: 'inherit' |
|
|
88
|
+
positionWhenNarrow?: 'inherit' | 'start' | 'end';
|
|
101
89
|
'aria-labelledby'?: string;
|
|
102
90
|
'aria-label'?: string;
|
|
103
91
|
/**
|
|
@@ -171,10 +159,6 @@ export type PageLayoutPaneProps = PageLayoutPaneBaseProps & ({
|
|
|
171
159
|
onResizeEnd?: never;
|
|
172
160
|
currentWidth?: never;
|
|
173
161
|
});
|
|
174
|
-
declare const panePositions: {
|
|
175
|
-
start: number;
|
|
176
|
-
end: number;
|
|
177
|
-
};
|
|
178
162
|
declare const Pane: React.ForwardRefExoticComponent<React.PropsWithChildren<PageLayoutPaneProps> & React.RefAttributes<HTMLDivElement>>;
|
|
179
163
|
export type PageLayoutSidebarProps = {
|
|
180
164
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageLayout.d.ts","sourceRoot":"","sources":["../../src/PageLayout/PageLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAIzC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAQhE,OAAO,KAAK,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"PageLayout.d.ts","sourceRoot":"","sources":["../../src/PageLayout/PageLayout.tsx"],"names":[],"mappings":"AAAA,OAAO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AAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAA;AA6DD,eAAO,MAAM,UAAU;;;;UAIP,cAAc,CAAC,OAAO,IAAI,CAAC;aACrB,cAAc,CAAC,OAAO,OAAO,CAAC;;CAElD,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useRef, memo } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { useId } from '../hooks/useId.js';
|
|
4
|
-
import {
|
|
4
|
+
import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
|
|
5
5
|
import { isResponsiveValue } from '../hooks/useResponsiveValue.js';
|
|
6
6
|
import { useSlots } from '../hooks/useSlots.js';
|
|
7
7
|
import { useOverflow } from '../hooks/useOverflow.js';
|
|
@@ -32,6 +32,9 @@ const PageLayoutContext = /*#__PURE__*/React.createContext({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
// ----------------------------------------------------------------------------
|
|
36
|
+
// PageLayout
|
|
37
|
+
|
|
35
38
|
// TODO: refs
|
|
36
39
|
const Root = ({
|
|
37
40
|
containerWidth = 'xlarge',
|
|
@@ -458,6 +461,11 @@ const Header = ({
|
|
|
458
461
|
};
|
|
459
462
|
Header.displayName = "Header";
|
|
460
463
|
Header.displayName = 'PageLayout.Header';
|
|
464
|
+
|
|
465
|
+
// ----------------------------------------------------------------------------
|
|
466
|
+
// PageLayout.Content
|
|
467
|
+
|
|
468
|
+
// TODO: Account for pane width when centering content
|
|
461
469
|
const Content = ({
|
|
462
470
|
as = 'main',
|
|
463
471
|
'aria-label': label,
|
|
@@ -492,6 +500,10 @@ const Content = ({
|
|
|
492
500
|
};
|
|
493
501
|
Content.displayName = "Content";
|
|
494
502
|
Content.displayName = 'PageLayout.Content';
|
|
503
|
+
|
|
504
|
+
// ----------------------------------------------------------------------------
|
|
505
|
+
// PageLayout.Pane
|
|
506
|
+
|
|
495
507
|
const overflowProps = {
|
|
496
508
|
tabIndex: 0,
|
|
497
509
|
role: 'region'
|
|
@@ -569,7 +581,7 @@ const Pane = /*#__PURE__*/React.forwardRef(({
|
|
|
569
581
|
onResizeEnd,
|
|
570
582
|
currentWidth: controlledWidth
|
|
571
583
|
});
|
|
572
|
-
|
|
584
|
+
useRefObjectAsForwardedRef(forwardRef, paneRef);
|
|
573
585
|
const hasOverflow = useOverflow(paneRef);
|
|
574
586
|
const paneId = useId(id);
|
|
575
587
|
const labelProp = {};
|
|
@@ -603,7 +615,7 @@ const Pane = /*#__PURE__*/React.forwardRef(({
|
|
|
603
615
|
},
|
|
604
616
|
position: positionProp
|
|
605
617
|
}), /*#__PURE__*/jsx("div", {
|
|
606
|
-
ref:
|
|
618
|
+
ref: paneRef
|
|
607
619
|
// Suppress hydration mismatch for --pane-width when localStorage
|
|
608
620
|
// provides a width that differs from the server-rendered default.
|
|
609
621
|
// Not needed when onResizeEnd is provided (localStorage isn't read).
|
|
@@ -773,7 +785,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
773
785
|
contentWrapperRef: sidebarContentWrapperRef,
|
|
774
786
|
constrainToViewport: true
|
|
775
787
|
});
|
|
776
|
-
|
|
788
|
+
useRefObjectAsForwardedRef(forwardRef, sidebarRef);
|
|
777
789
|
const hasOverflow = useOverflow(sidebarRef);
|
|
778
790
|
const sidebarId = useId(id);
|
|
779
791
|
const labelProp = {};
|
|
@@ -812,7 +824,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
812
824
|
getDefaultWidth: getDefaultWidth,
|
|
813
825
|
saveWidth: saveWidth
|
|
814
826
|
}), /*#__PURE__*/jsx("div", {
|
|
815
|
-
ref:
|
|
827
|
+
ref: sidebarRef
|
|
816
828
|
// Suppress hydration mismatch for --pane-width when localStorage
|
|
817
829
|
// provides a width that differs from the server-rendered default.
|
|
818
830
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../src/SelectPanel/SelectPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC1F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../src/SelectPanel/SelectPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC1F,OAAO,KAAK,EAAE,EAAoD,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AACxF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAC,iCAAiC,EAAC,MAAM,oCAAoC,CAAA;AACzF,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAA;AAGlE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAY,SAAS,EAAC,MAAM,IAAI,CAAA;AAiB5C,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAkCjE,UAAU,0BAA0B;IAClC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAA;IAC/B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAA;CAC5D;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,IAAI,CAAA;CAClD;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,CAAA;AACvD,MAAM,MAAM,0BAA0B,GAClC,KAAK,CAAC,YAAY,CAAC,OAAO,eAAe,CAAC,GAC1C,KAAK,CAAC,YAAY,CAAC,OAAO,aAAa,CAAC,CAAA;AAE5C,UAAU,oBAAoB;IAG5B,KAAK,CAAC,EAAE,MAA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AA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA"}
|
|
@@ -56,6 +56,9 @@ const focusZoneSettings = {
|
|
|
56
56
|
// Let FilteredActionList handle focus zone
|
|
57
57
|
disabled: true
|
|
58
58
|
};
|
|
59
|
+
const closeButtonProps = {
|
|
60
|
+
'aria-label': 'Cancel and close'
|
|
61
|
+
};
|
|
59
62
|
const areItemsEqual = (itemA, itemB) => {
|
|
60
63
|
// prefer checking equivality by item.id
|
|
61
64
|
if (typeof itemA.id !== 'undefined') return itemA.id === itemB.id;else return itemA === itemB;
|
|
@@ -537,9 +540,9 @@ function Panel({
|
|
|
537
540
|
prevOpenRef.current = open;
|
|
538
541
|
}
|
|
539
542
|
}, [open, resetSort]);
|
|
540
|
-
const focusTrapSettings = {
|
|
543
|
+
const focusTrapSettings = useMemo(() => ({
|
|
541
544
|
initialFocusRef: inputRef || undefined
|
|
542
|
-
};
|
|
545
|
+
}), [inputRef]);
|
|
543
546
|
const extendedTextInputProps = useMemo(() => {
|
|
544
547
|
return {
|
|
545
548
|
className: classes.TextInput,
|
|
@@ -615,9 +618,11 @@ function Panel({
|
|
|
615
618
|
regular: 'anchored',
|
|
616
619
|
narrow: 'fullscreen'
|
|
617
620
|
} : undefined, 'anchored');
|
|
618
|
-
const preventBubbling =
|
|
621
|
+
const preventBubbling = useCallback(event => {
|
|
622
|
+
var _overlayProps$onKeyDo;
|
|
623
|
+
overlayProps === null || overlayProps === void 0 ? void 0 : (_overlayProps$onKeyDo = overlayProps.onKeyDown) === null || _overlayProps$onKeyDo === void 0 ? void 0 : _overlayProps$onKeyDo.call(overlayProps, event);
|
|
624
|
+
|
|
619
625
|
// skip if a TextInput has focus
|
|
620
|
-
customOnKeyDown === null || customOnKeyDown === void 0 ? void 0 : customOnKeyDown(event);
|
|
621
626
|
const activeElement = document.activeElement;
|
|
622
627
|
if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') return;
|
|
623
628
|
|
|
@@ -632,7 +637,25 @@ function Panel({
|
|
|
632
637
|
|
|
633
638
|
// if this is a typeahead event, don't propagate outside of menu
|
|
634
639
|
event.stopPropagation();
|
|
635
|
-
};
|
|
640
|
+
}, [overlayProps]);
|
|
641
|
+
const mergedOverlayProps = useMemo(() => ({
|
|
642
|
+
role: 'dialog',
|
|
643
|
+
'aria-labelledby': titleId,
|
|
644
|
+
'aria-describedby': subtitle ? subtitleId : undefined,
|
|
645
|
+
...overlayProps,
|
|
646
|
+
...(variant === 'modal' ? {
|
|
647
|
+
top: '50vh',
|
|
648
|
+
left: '50vw',
|
|
649
|
+
anchorSide: undefined
|
|
650
|
+
} : {}),
|
|
651
|
+
style: {
|
|
652
|
+
transform: variant === 'modal' ? 'translate(-50%, -50%)' : undefined,
|
|
653
|
+
...(isKeyboardVisible ? {
|
|
654
|
+
maxHeight: availablePanelHeight !== undefined ? `${availablePanelHeight}px` : 'auto'
|
|
655
|
+
} : {})
|
|
656
|
+
},
|
|
657
|
+
onKeyDown: preventBubbling
|
|
658
|
+
}), [titleId, subtitle, subtitleId, overlayProps, variant, isKeyboardVisible, availablePanelHeight, preventBubbling]);
|
|
636
659
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
637
660
|
children: [/*#__PURE__*/jsx(AnchoredOverlay, {
|
|
638
661
|
renderAnchor: renderMenuAnchor,
|
|
@@ -641,27 +664,7 @@ function Panel({
|
|
|
641
664
|
open: open,
|
|
642
665
|
onOpen: onOpen,
|
|
643
666
|
onClose: onClose,
|
|
644
|
-
overlayProps:
|
|
645
|
-
role: 'dialog',
|
|
646
|
-
'aria-labelledby': titleId,
|
|
647
|
-
'aria-describedby': subtitle ? subtitleId : undefined,
|
|
648
|
-
...overlayProps,
|
|
649
|
-
...(variant === 'modal' ? {
|
|
650
|
-
/* override AnchoredOverlay position */
|
|
651
|
-
top: '50vh',
|
|
652
|
-
left: '50vw',
|
|
653
|
-
anchorSide: undefined
|
|
654
|
-
} : {}),
|
|
655
|
-
style: {
|
|
656
|
-
/* override AnchoredOverlay position */
|
|
657
|
-
transform: variant === 'modal' ? 'translate(-50%, -50%)' : undefined,
|
|
658
|
-
// set maxHeight based on calculated availablePanelHeight when keyboard is visible
|
|
659
|
-
...(isKeyboardVisible ? {
|
|
660
|
-
maxHeight: availablePanelHeight !== undefined ? `${availablePanelHeight}px` : 'auto'
|
|
661
|
-
} : {})
|
|
662
|
-
},
|
|
663
|
-
onKeyDown: preventBubbling(overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.onKeyDown)
|
|
664
|
-
},
|
|
667
|
+
overlayProps: mergedOverlayProps,
|
|
665
668
|
focusTrapSettings: focusTrapSettings,
|
|
666
669
|
focusZoneSettings: focusZoneSettings,
|
|
667
670
|
height: height,
|
|
@@ -674,9 +677,7 @@ function Panel({
|
|
|
674
677
|
pinPosition: !height,
|
|
675
678
|
className: classes.Overlay,
|
|
676
679
|
displayCloseButton: showXCloseIcon,
|
|
677
|
-
closeButtonProps:
|
|
678
|
-
'aria-label': 'Cancel and close'
|
|
679
|
-
},
|
|
680
|
+
closeButtonProps: closeButtonProps,
|
|
680
681
|
children: /*#__PURE__*/jsxs("div", {
|
|
681
682
|
className: classes.Wrapper,
|
|
682
683
|
"data-variant": variant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwD,MAAM,OAAO,CAAA;AAE5E,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAO/F,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAA;AAQ/E,MAAM,MAAM,4BAA4B,GAAG;IACzC,uEAAuE;IACvE,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,2DAA2D;IAC3D,OAAO,C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A;IACjB;;;;;QAKI;IACJ,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;IAChD,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;IACnD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;IACpD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACvE;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,OAAO,CACT,IAAI,CACF,kBAAkB,EAChB,OAAO,GACP,UAAU,GACV,UAAU,GACV,WAAW,GACX,OAAO,GACP,UAAU,GACV,UAAU,GACV,SAAS,GACT,MAAM,GACN,kBAAkB,CACrB,CACF,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,4BAA4B,CAAC,CAAA;;;;;;;;;;;AA+PzG,wBAGE"}
|
|
@@ -51,6 +51,10 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
51
51
|
const [isOverLimit, setIsOverLimit] = useState(false);
|
|
52
52
|
const [screenReaderMessage, setScreenReaderMessage] = useState('');
|
|
53
53
|
const characterCounterRef = useRef(null);
|
|
54
|
+
const lastCountedLengthRef = useRef(null);
|
|
55
|
+
const lastCharacterCountRef = useRef('');
|
|
56
|
+
const lastIsOverLimitRef = useRef(false);
|
|
57
|
+
const lastScreenReaderMessageRef = useRef('');
|
|
54
58
|
|
|
55
59
|
// this class is necessary to style FilterSearch, plz no touchy!
|
|
56
60
|
const wrapperClasses = clsx(className, 'TextInput-wrapper');
|
|
@@ -84,17 +88,31 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
84
88
|
if (characterLimit) {
|
|
85
89
|
characterCounterRef.current = new CharacterCounter({
|
|
86
90
|
onCountUpdate: (count, overLimit, message) => {
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
if (message !== lastCharacterCountRef.current) {
|
|
92
|
+
lastCharacterCountRef.current = message;
|
|
93
|
+
setCharacterCount(message);
|
|
94
|
+
}
|
|
95
|
+
if (overLimit !== lastIsOverLimitRef.current) {
|
|
96
|
+
lastIsOverLimitRef.current = overLimit;
|
|
97
|
+
setIsOverLimit(overLimit);
|
|
98
|
+
}
|
|
89
99
|
},
|
|
90
100
|
onScreenReaderAnnounce: message_0 => {
|
|
91
|
-
|
|
101
|
+
if (message_0 !== lastScreenReaderMessageRef.current) {
|
|
102
|
+
lastScreenReaderMessageRef.current = message_0;
|
|
103
|
+
setScreenReaderMessage(message_0);
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
106
|
});
|
|
107
|
+
lastCountedLengthRef.current = null;
|
|
94
108
|
return () => {
|
|
95
109
|
var _characterCounterRef$;
|
|
96
110
|
(_characterCounterRef$ = characterCounterRef.current) === null || _characterCounterRef$ === void 0 ? void 0 : _characterCounterRef$.cleanup();
|
|
97
111
|
characterCounterRef.current = null;
|
|
112
|
+
lastCountedLengthRef.current = null;
|
|
113
|
+
lastCharacterCountRef.current = '';
|
|
114
|
+
lastIsOverLimitRef.current = false;
|
|
115
|
+
lastScreenReaderMessageRef.current = '';
|
|
98
116
|
};
|
|
99
117
|
}
|
|
100
118
|
}, [characterLimit]);
|
|
@@ -103,14 +121,22 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
103
121
|
useEffect(() => {
|
|
104
122
|
if (characterLimit && characterCounterRef.current) {
|
|
105
123
|
const currentValue = value !== undefined ? String(value) : defaultValue !== undefined ? String(defaultValue) : '';
|
|
106
|
-
|
|
124
|
+
const currentLength = currentValue.length;
|
|
125
|
+
if (currentLength !== lastCountedLengthRef.current) {
|
|
126
|
+
lastCountedLengthRef.current = currentLength;
|
|
127
|
+
characterCounterRef.current.updateCharacterCount(currentLength, characterLimit);
|
|
128
|
+
}
|
|
107
129
|
}
|
|
108
130
|
}, [value, defaultValue, characterLimit]);
|
|
109
131
|
|
|
110
132
|
// Handle input change with character counter
|
|
111
133
|
const handleInputChange = useCallback(e_2 => {
|
|
112
134
|
if (characterLimit && characterCounterRef.current) {
|
|
113
|
-
|
|
135
|
+
const currentLength_0 = e_2.target.value.length;
|
|
136
|
+
if (currentLength_0 !== lastCountedLengthRef.current) {
|
|
137
|
+
lastCountedLengthRef.current = currentLength_0;
|
|
138
|
+
characterCounterRef.current.updateCharacterCount(currentLength_0, characterLimit);
|
|
139
|
+
}
|
|
114
140
|
}
|
|
115
141
|
onChange === null || onChange === void 0 ? void 0 : onChange(e_2);
|
|
116
142
|
}, [onChange, characterLimit]);
|