@primer/react 0.0.0-20260529232437 → 0.0.0-20260601091151
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 +13 -5
- package/dist/ActionList/ActionList-1940009e.css +2 -0
- package/dist/ActionList/ActionList-1940009e.css.map +1 -0
- package/dist/ActionList/ActionList.module.css.js +2 -2
- package/dist/ActionList/Item.d.ts.map +1 -1
- package/dist/ActionList/Item.js +125 -118
- package/dist/ActionList/TrailingAction.d.ts.map +1 -1
- package/dist/ActionList/TrailingAction.js +1 -0
- package/dist/ActionList/Visuals.js +6 -4
- package/dist/KeybindingHint/KeybindingHint.d.ts +1 -6
- package/dist/KeybindingHint/KeybindingHint.d.ts.map +1 -1
- package/dist/KeybindingHint/KeybindingHint.js +2 -6
- package/dist/KeybindingHint/components/Chord.d.ts +1 -2
- package/dist/KeybindingHint/components/Chord.d.ts.map +1 -1
- package/dist/KeybindingHint/components/Chord.js +1 -1
- package/dist/KeybindingHint/components/Key.js +10 -10
- package/dist/KeybindingHint/components/Sequence.d.ts +1 -2
- package/dist/KeybindingHint/components/Sequence.d.ts.map +1 -1
- package/dist/KeybindingHint/components/Sequence.js +2 -2
- package/dist/KeybindingHint/key-names.d.ts +3 -4
- package/dist/KeybindingHint/key-names.d.ts.map +1 -1
- package/dist/KeybindingHint/key-names.js +14 -15
- package/dist/Text/{Text-ca7603b7.css → Text-d649cda5.css} +2 -2
- package/dist/Text/Text-d649cda5.css.map +1 -0
- package/dist/Text/Text.d.ts +3 -0
- package/dist/Text/Text.d.ts.map +1 -1
- package/dist/Text/Text.js +20 -14
- package/dist/Text/Text.module.css.js +1 -1
- package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
- package/dist/TooltipV2/Tooltip.js +3 -3
- package/dist/TreeView/TreeView.js +4 -4
- package/dist/hooks/useAnchoredPosition.d.ts.map +1 -1
- package/dist/hooks/useAnchoredPosition.js +31 -7
- package/dist/hooks/useIsMacOS.js +32 -0
- package/generated/components.json +20 -4
- package/package.json +1 -1
- package/dist/ActionList/ActionList-2a35a40c.css +0 -2
- package/dist/ActionList/ActionList-2a35a40c.css.map +0 -1
- package/dist/KeybindingHint/platform.d.ts +0 -22
- package/dist/KeybindingHint/platform.d.ts.map +0 -1
- package/dist/KeybindingHint/platform.js +0 -61
- package/dist/Text/Text-ca7603b7.css.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { accessibleSequenceString, Sequence } from './components/Sequence.js';
|
|
4
4
|
import classes from './KeybindingHint.module.css.js';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -89,11 +89,7 @@ KeybindingHint.displayName = 'KeybindingHint';
|
|
|
89
89
|
*
|
|
90
90
|
* NOTE that this string should _only_ be used when building `aria-label` or `aria-description` props (never rendered
|
|
91
91
|
* visibly) and should nearly always also be paired with a visible hint for sighted users.
|
|
92
|
-
*
|
|
93
|
-
* The `platform` argument controls how platform-specific keys (such as `Meta`, `Alt`, and `Mod`) are named. For
|
|
94
|
-
* backwards compatibility, a `boolean` may be passed instead, where `true` is treated as `'mac'` and `false` as
|
|
95
|
-
* `'other'`.
|
|
96
92
|
*/
|
|
97
|
-
const getAccessibleKeybindingHintString =
|
|
93
|
+
const getAccessibleKeybindingHintString = accessibleSequenceString;
|
|
98
94
|
|
|
99
95
|
export { KeybindingHint, getAccessibleKeybindingHintString };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { KeybindingHintProps } from '../props';
|
|
2
|
-
import type { Platform } from '../platform';
|
|
3
2
|
export declare const Chord: ({ keys, format, variant, size }: KeybindingHintProps) => import("react").JSX.Element;
|
|
4
3
|
/** Plain string version of `Chord` for use in `aria` string attributes. */
|
|
5
|
-
export declare const accessibleChordString: (chord: string,
|
|
4
|
+
export declare const accessibleChordString: (chord: string, isMacOS: boolean) => string;
|
|
6
5
|
//# sourceMappingURL=Chord.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chord.d.ts","sourceRoot":"","sources":["../../../src/KeybindingHint/components/Chord.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"Chord.d.ts","sourceRoot":"","sources":["../../../src/KeybindingHint/components/Chord.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AA+BjD,eAAO,MAAM,KAAK,GAAI,iCAAmE,mBAAmB,gCAsB3G,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,EAAE,SAAS,OAAO,WAGvD,CAAA"}
|
|
@@ -96,6 +96,6 @@ const Chord = t0 => {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
/** Plain string version of `Chord` for use in `aria` string attributes. */
|
|
99
|
-
const accessibleChordString = (chord,
|
|
99
|
+
const accessibleChordString = (chord, isMacOS) => splitChord(chord).map(key => accessibleKeyName(key, isMacOS)).join(' ');
|
|
100
100
|
|
|
101
101
|
export { Chord, accessibleChordString };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
2
|
import VisuallyHidden from '../../_VisuallyHidden.js';
|
|
3
3
|
import { accessibleKeyName, condensedKeyName, fullKeyName } from '../key-names.js';
|
|
4
|
-
import {
|
|
4
|
+
import { useIsMacOS } from '../../hooks/useIsMacOS.js';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
/** Renders a single key with accessible alternative text. */
|
|
@@ -11,12 +11,12 @@ const Key = t0 => {
|
|
|
11
11
|
name,
|
|
12
12
|
format
|
|
13
13
|
} = t0;
|
|
14
|
-
const
|
|
14
|
+
const isMacOS = useIsMacOS();
|
|
15
15
|
let t1;
|
|
16
|
-
if ($[0] !==
|
|
17
|
-
t1 = accessibleKeyName(name,
|
|
18
|
-
$[0] =
|
|
19
|
-
$[1] =
|
|
16
|
+
if ($[0] !== isMacOS || $[1] !== name) {
|
|
17
|
+
t1 = accessibleKeyName(name, isMacOS);
|
|
18
|
+
$[0] = isMacOS;
|
|
19
|
+
$[1] = name;
|
|
20
20
|
$[2] = t1;
|
|
21
21
|
} else {
|
|
22
22
|
t1 = $[2];
|
|
@@ -32,11 +32,11 @@ const Key = t0 => {
|
|
|
32
32
|
t2 = $[4];
|
|
33
33
|
}
|
|
34
34
|
let t3;
|
|
35
|
-
if ($[5] !== format || $[6] !==
|
|
36
|
-
t3 = format === "condensed" ? condensedKeyName(name,
|
|
35
|
+
if ($[5] !== format || $[6] !== isMacOS || $[7] !== name) {
|
|
36
|
+
t3 = format === "condensed" ? condensedKeyName(name, isMacOS) : fullKeyName(name, isMacOS);
|
|
37
37
|
$[5] = format;
|
|
38
|
-
$[6] =
|
|
39
|
-
$[7] =
|
|
38
|
+
$[6] = isMacOS;
|
|
39
|
+
$[7] = name;
|
|
40
40
|
$[8] = t3;
|
|
41
41
|
} else {
|
|
42
42
|
t3 = $[8];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { KeybindingHintProps } from '../props';
|
|
2
|
-
import type { Platform } from '../platform';
|
|
3
2
|
export declare const Sequence: ({ keys, ...chordProps }: KeybindingHintProps) => import("react").JSX.Element[];
|
|
4
3
|
/** Plain string version of `Sequence` for use in `aria` string attributes. */
|
|
5
|
-
export declare const accessibleSequenceString: (sequence: string,
|
|
4
|
+
export declare const accessibleSequenceString: (sequence: string, isMacOS: boolean) => string;
|
|
6
5
|
//# sourceMappingURL=Sequence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequence.d.ts","sourceRoot":"","sources":["../../../src/KeybindingHint/components/Sequence.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"Sequence.d.ts","sourceRoot":"","sources":["../../../src/KeybindingHint/components/Sequence.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAMjD,eAAO,MAAM,QAAQ,GAAI,yBAAuB,mBAAmB,kCAa/D,CAAA;AAEJ,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,EAAE,SAAS,OAAO,WAGxD,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment } from 'react';
|
|
2
2
|
import VisuallyHidden from '../../_VisuallyHidden.js';
|
|
3
|
-
import {
|
|
3
|
+
import { accessibleChordString, Chord } from './Chord.js';
|
|
4
4
|
import { jsxs, Fragment as Fragment$1, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
const splitSequence = sequence => sequence.split(' ');
|
|
@@ -21,6 +21,6 @@ const Sequence = ({
|
|
|
21
21
|
}, i));
|
|
22
22
|
|
|
23
23
|
/** Plain string version of `Sequence` for use in `aria` string attributes. */
|
|
24
|
-
const accessibleSequenceString = (sequence,
|
|
24
|
+
const accessibleSequenceString = (sequence, isMacOS) => splitSequence(sequence).map(chord => accessibleChordString(chord, isMacOS)).join(' then ');
|
|
25
25
|
|
|
26
26
|
export { Sequence, accessibleSequenceString };
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import type { Platform } from './platform';
|
|
2
1
|
/**
|
|
3
2
|
* Short-form iconic versions of keys. These should be intuitive (not archaic) and match icons on keyboards.
|
|
4
3
|
*/
|
|
5
|
-
export declare const condensedKeyName: (key: string,
|
|
4
|
+
export declare const condensedKeyName: (key: string, isMacOS: boolean) => string;
|
|
6
5
|
/**
|
|
7
6
|
* Specific key displays for 'full' format. We still do show some icons (ie punctuation)
|
|
8
7
|
* because that's more intuitive, but for the rest of keys we show the standard key name.
|
|
9
8
|
*/
|
|
10
|
-
export declare const fullKeyName: (key: string,
|
|
9
|
+
export declare const fullKeyName: (key: string, isMacOS: boolean) => string;
|
|
11
10
|
/**
|
|
12
11
|
* Accessible key names intended to be read by a screen reader. This prevents screen
|
|
13
12
|
* readers from expressing punctuation in speech, ie, reading a long pause instead of the
|
|
14
13
|
* word "period".
|
|
15
14
|
*/
|
|
16
|
-
export declare const accessibleKeyName: (key: string,
|
|
15
|
+
export declare const accessibleKeyName: (key: string, isMacOS: boolean) => string;
|
|
17
16
|
//# sourceMappingURL=key-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-names.d.ts","sourceRoot":"","sources":["../../src/KeybindingHint/key-names.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key-names.d.ts","sourceRoot":"","sources":["../../src/KeybindingHint/key-names.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,SAAS,OAAO,WAwBlC,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,SAAS,OAAO,WAa7B,CAAA;AAE5B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,SAAS,OAAO,WAmDjC,CAAA"}
|
|
@@ -12,15 +12,15 @@ const capitalize = ([first, ...rest]) => {
|
|
|
12
12
|
/**
|
|
13
13
|
* Short-form iconic versions of keys. These should be intuitive (not archaic) and match icons on keyboards.
|
|
14
14
|
*/
|
|
15
|
-
const condensedKeyName = (key,
|
|
15
|
+
const condensedKeyName = (key, isMacOS) => {
|
|
16
16
|
var _alt$control$shift$me;
|
|
17
17
|
return (_alt$control$shift$me = {
|
|
18
|
-
alt:
|
|
18
|
+
alt: isMacOS ? '⌥' : 'Alt',
|
|
19
19
|
// the alt key _is_ the option key on MacOS - in the browser there is no "option" key
|
|
20
20
|
control: '⌃',
|
|
21
21
|
shift: '⇧',
|
|
22
|
-
meta:
|
|
23
|
-
mod:
|
|
22
|
+
meta: isMacOS ? '⌘' : 'Win',
|
|
23
|
+
mod: isMacOS ? '⌘' : '⌃',
|
|
24
24
|
pageup: 'PgUp',
|
|
25
25
|
pagedown: 'PgDn',
|
|
26
26
|
arrowup: '↑',
|
|
@@ -47,12 +47,11 @@ const condensedKeyName = (key, platform) => {
|
|
|
47
47
|
* Specific key displays for 'full' format. We still do show some icons (ie punctuation)
|
|
48
48
|
* because that's more intuitive, but for the rest of keys we show the standard key name.
|
|
49
49
|
*/
|
|
50
|
-
const fullKeyName = (key,
|
|
51
|
-
var _alt$
|
|
52
|
-
return (_alt$
|
|
53
|
-
alt:
|
|
54
|
-
|
|
55
|
-
mod: platform === 'mac' ? 'Command' : 'Control',
|
|
50
|
+
const fullKeyName = (key, isMacOS) => {
|
|
51
|
+
var _alt$mod$$pageup$pag;
|
|
52
|
+
return (_alt$mod$$pageup$pag = {
|
|
53
|
+
alt: isMacOS ? 'Option' : 'Alt',
|
|
54
|
+
mod: isMacOS ? 'Command' : 'Control',
|
|
56
55
|
'+': 'Plus',
|
|
57
56
|
pageup: 'Page Up',
|
|
58
57
|
pagedown: 'Page Down',
|
|
@@ -62,7 +61,7 @@ const fullKeyName = (key, platform) => {
|
|
|
62
61
|
arrowright: 'Right Arrow',
|
|
63
62
|
capslock: 'Caps Lock',
|
|
64
63
|
printscreen: 'Print Screen'
|
|
65
|
-
}[key]) !== null && _alt$
|
|
64
|
+
}[key]) !== null && _alt$mod$$pageup$pag !== void 0 ? _alt$mod$$pageup$pag : capitalize(key);
|
|
66
65
|
};
|
|
67
66
|
|
|
68
67
|
/**
|
|
@@ -70,12 +69,12 @@ const fullKeyName = (key, platform) => {
|
|
|
70
69
|
* readers from expressing punctuation in speech, ie, reading a long pause instead of the
|
|
71
70
|
* word "period".
|
|
72
71
|
*/
|
|
73
|
-
const accessibleKeyName = (key,
|
|
72
|
+
const accessibleKeyName = (key, isMacOS) => {
|
|
74
73
|
var _alt$meta$mod$pageup$;
|
|
75
74
|
return (_alt$meta$mod$pageup$ = {
|
|
76
|
-
alt:
|
|
77
|
-
meta:
|
|
78
|
-
mod:
|
|
75
|
+
alt: isMacOS ? 'option' : 'alt',
|
|
76
|
+
meta: isMacOS ? 'command' : 'Windows',
|
|
77
|
+
mod: isMacOS ? 'command' : 'control',
|
|
79
78
|
// Screen readers may not be able to pronounce concatenated words - this provides a better experience
|
|
80
79
|
pageup: 'page up',
|
|
81
80
|
pagedown: 'page down',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.prc-Text-Text-9mHv3:where([data-size=small]){font-size:var(--text-body-size-small,.75rem);line-height:var(--text-body-lineHeight-small,1.625)}.prc-Text-Text-9mHv3:where([data-size=medium]){font-size:var(--text-body-size-medium,.875rem);line-height:var(--text-body-lineHeight-medium,1.5)}.prc-Text-Text-9mHv3:where([data-size=large]){font-size:var(--text-body-size-large,1rem);line-height:var(--text-body-lineHeight-large,1.5)}.prc-Text-Text-9mHv3:where([data-weight=light]){font-weight:var(--base-text-weight-light,300)}.prc-Text-Text-9mHv3:where([data-weight=normal]){font-weight:var(--base-text-weight-normal,400)}.prc-Text-Text-9mHv3:where([data-weight=medium]){font-weight:var(--base-text-weight-medium,500)}.prc-Text-Text-9mHv3:where([data-weight=semibold]){font-weight:var(--base-text-weight-semibold,600)}
|
|
2
|
-
/*# sourceMappingURL=Text-
|
|
1
|
+
.prc-Text-Text-9mHv3:where([data-size=small]){font-size:var(--text-body-size-small,.75rem);line-height:var(--text-body-lineHeight-small,1.625)}.prc-Text-Text-9mHv3:where([data-size=medium]){font-size:var(--text-body-size-medium,.875rem);line-height:var(--text-body-lineHeight-medium,1.5)}.prc-Text-Text-9mHv3:where([data-size=large]){font-size:var(--text-body-size-large,1rem);line-height:var(--text-body-lineHeight-large,1.5)}.prc-Text-Text-9mHv3:where([data-weight=light]){font-weight:var(--base-text-weight-light,300)}.prc-Text-Text-9mHv3:where([data-weight=normal]){font-weight:var(--base-text-weight-normal,400)}.prc-Text-Text-9mHv3:where([data-weight=medium]){font-weight:var(--base-text-weight-medium,500)}.prc-Text-Text-9mHv3:where([data-weight=semibold]){font-weight:var(--base-text-weight-semibold,600)}.prc-Text-Text-9mHv3:where([data-white-space=pre]){white-space:pre}.prc-Text-Text-9mHv3:where([data-white-space=normal]){white-space:normal}.prc-Text-Text-9mHv3:where([data-white-space=nowrap]){white-space:nowrap}.prc-Text-Text-9mHv3:where([data-white-space=pre-wrap]){white-space:pre-wrap}.prc-Text-Text-9mHv3:where([data-white-space=pre-line]){white-space:pre-line}
|
|
2
|
+
/*# sourceMappingURL=Text-d649cda5.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Text/Text.module.css.js"],"names":[],"mappings":"AACE,8CACE,4CAAsC,CACtC,mDACF,CAEA,+CACE,8CAAuC,CACvC,kDACF,CAEA,8CACE,0CAAsC,CACtC,iDACF,CAEA,gDACE,6CACF,CAEA,iDACE,8CACF,CAEA,iDACE,8CACF,CAEA,mDACE,gDACF,CAEA,mDACE,eACF,CAEA,sDACE,kBACF,CAEA,sDACE,kBACF,CAEA,wDACE,oBACF,CAEA,wDACE,oBACF","file":"Text-d649cda5.css","sourcesContent":[".Text {\n &:where([data-size='small']) {\n font-size: var(--text-body-size-small);\n line-height: var(--text-body-lineHeight-small);\n }\n\n &:where([data-size='medium']) {\n font-size: var(--text-body-size-medium);\n line-height: var(--text-body-lineHeight-medium);\n }\n\n &:where([data-size='large']) {\n font-size: var(--text-body-size-large);\n line-height: var(--text-body-lineHeight-large);\n }\n\n &:where([data-weight='light']) {\n font-weight: var(--base-text-weight-light);\n }\n\n &:where([data-weight='normal']) {\n font-weight: var(--base-text-weight-normal);\n }\n\n &:where([data-weight='medium']) {\n font-weight: var(--base-text-weight-medium);\n }\n\n &:where([data-weight='semibold']) {\n font-weight: var(--base-text-weight-semibold);\n }\n\n &:where([data-white-space='pre']) {\n white-space: pre;\n }\n\n &:where([data-white-space='normal']) {\n white-space: normal;\n }\n\n &:where([data-white-space='nowrap']) {\n white-space: nowrap;\n }\n\n &:where([data-white-space='pre-wrap']) {\n white-space: pre-wrap;\n }\n\n &:where([data-white-space='pre-line']) {\n white-space: pre-line;\n }\n}\n"]}
|
package/dist/Text/Text.d.ts
CHANGED
|
@@ -3,15 +3,18 @@ import { type PolymorphicProps } from '../utils/modern-polymorphic';
|
|
|
3
3
|
export type TextProps<As extends React.ElementType = 'span'> = PolymorphicProps<As, 'span', {
|
|
4
4
|
size?: 'large' | 'medium' | 'small';
|
|
5
5
|
weight?: 'light' | 'normal' | 'medium' | 'semibold';
|
|
6
|
+
whiteSpace?: 'pre' | 'normal' | 'nowrap' | 'pre-wrap' | 'pre-line';
|
|
6
7
|
className?: string;
|
|
7
8
|
}>;
|
|
8
9
|
declare const _default: <As extends React.ElementType>(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "span" : As> & {
|
|
9
10
|
size?: "large" | "medium" | "small";
|
|
10
11
|
weight?: "light" | "normal" | "medium" | "semibold";
|
|
12
|
+
whiteSpace?: "pre" | "normal" | "nowrap" | "pre-wrap" | "pre-line";
|
|
11
13
|
className?: string;
|
|
12
14
|
} extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "span" : As> & {
|
|
13
15
|
size?: "large" | "medium" | "small";
|
|
14
16
|
weight?: "light" | "normal" | "medium" | "semibold";
|
|
17
|
+
whiteSpace?: "pre" | "normal" | "nowrap" | "pre-wrap" | "pre-line";
|
|
15
18
|
className?: string;
|
|
16
19
|
} ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
17
20
|
as?: As | undefined;
|
package/dist/Text/Text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAkB,KAAK,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CAC7E,EAAE,EACF,MAAM,EACN;IACE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAA;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CACF,CAAA;yBAGa,EAAE,SAAS,KAAK,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAkB,KAAK,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CAC7E,EAAE,EACF,MAAM,EACN;IACE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAA;IACnD,UAAU,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAA;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CACF,CAAA;yBAGa,EAAE,SAAS,KAAK,CAAC,WAAW;WAR/B,OAAO,GAAG,QAAQ,GAAG,OAAO;aAC1B,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU;iBACtC,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU;gBACtD,MAAM;;WAHX,OAAO,GAAG,QAAQ,GAAG,OAAO;aAC1B,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU;iBACtC,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU;gBACtD,MAAM;;;;AAsBtB,wBAAoC"}
|
package/dist/Text/Text.js
CHANGED
|
@@ -6,18 +6,20 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
function Text(props, ref) {
|
|
9
|
-
const $ = c(
|
|
9
|
+
const $ = c(17);
|
|
10
10
|
let className;
|
|
11
11
|
let rest;
|
|
12
12
|
let size;
|
|
13
13
|
let t0;
|
|
14
14
|
let weight;
|
|
15
|
+
let whiteSpace;
|
|
15
16
|
if ($[0] !== props) {
|
|
16
17
|
({
|
|
17
18
|
as: t0,
|
|
18
19
|
className,
|
|
19
20
|
size,
|
|
20
21
|
weight,
|
|
22
|
+
whiteSpace,
|
|
21
23
|
...rest
|
|
22
24
|
} = props);
|
|
23
25
|
$[0] = props;
|
|
@@ -26,40 +28,44 @@ function Text(props, ref) {
|
|
|
26
28
|
$[3] = size;
|
|
27
29
|
$[4] = t0;
|
|
28
30
|
$[5] = weight;
|
|
31
|
+
$[6] = whiteSpace;
|
|
29
32
|
} else {
|
|
30
33
|
className = $[1];
|
|
31
34
|
rest = $[2];
|
|
32
35
|
size = $[3];
|
|
33
36
|
t0 = $[4];
|
|
34
37
|
weight = $[5];
|
|
38
|
+
whiteSpace = $[6];
|
|
35
39
|
}
|
|
36
40
|
const Component = t0 === undefined ? "span" : t0;
|
|
37
41
|
let t1;
|
|
38
|
-
if ($[
|
|
42
|
+
if ($[7] !== className) {
|
|
39
43
|
t1 = clsx(className, classes.Text);
|
|
40
|
-
$[
|
|
41
|
-
$[
|
|
44
|
+
$[7] = className;
|
|
45
|
+
$[8] = t1;
|
|
42
46
|
} else {
|
|
43
|
-
t1 = $[
|
|
47
|
+
t1 = $[8];
|
|
44
48
|
}
|
|
45
49
|
let t2;
|
|
46
|
-
if ($[
|
|
50
|
+
if ($[9] !== Component || $[10] !== ref || $[11] !== rest || $[12] !== size || $[13] !== t1 || $[14] !== weight || $[15] !== whiteSpace) {
|
|
47
51
|
t2 = /*#__PURE__*/jsx(Component, {
|
|
48
52
|
className: t1,
|
|
49
53
|
"data-size": size,
|
|
50
54
|
"data-weight": weight,
|
|
55
|
+
"data-white-space": whiteSpace,
|
|
51
56
|
...rest,
|
|
52
57
|
ref: ref
|
|
53
58
|
});
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
59
|
+
$[9] = Component;
|
|
60
|
+
$[10] = ref;
|
|
61
|
+
$[11] = rest;
|
|
62
|
+
$[12] = size;
|
|
63
|
+
$[13] = t1;
|
|
64
|
+
$[14] = weight;
|
|
65
|
+
$[15] = whiteSpace;
|
|
66
|
+
$[16] = t2;
|
|
61
67
|
} else {
|
|
62
|
-
t2 = $[
|
|
68
|
+
t2 = $[16];
|
|
63
69
|
}
|
|
64
70
|
return t2;
|
|
65
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/TooltipV2/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiD,KAAK,yBAAyB,EAAC,MAAM,OAAO,CAAA;AAS3G,OAAO,EAAoD,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/TooltipV2/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiD,KAAK,yBAAyB,EAAC,MAAM,OAAO,CAAA;AAS3G,OAAO,EAAoD,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAA;AAG7G,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AAE9C,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAA;AAChF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACjD,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAAA;IAC9B,cAAc,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAA;IACjF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACnC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAC,GACA,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AAiEnC,eAAO,MAAM,cAAc;gBAAoC,MAAM;EAAM,CAAA;AAI3E,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAC7C,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CACvE,GACC,UAkSD,CAAA"}
|
|
@@ -5,13 +5,13 @@ import { getAnchoredPosition } from '@primer/behaviors';
|
|
|
5
5
|
import { isSupported, apply } from '@oddbird/popover-polyfill/fn';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import classes from './Tooltip.module.css.js';
|
|
8
|
-
import { usePlatform } from '../KeybindingHint/platform.js';
|
|
9
8
|
import VisuallyHidden from '../_VisuallyHidden.js';
|
|
10
9
|
import useSafeTimeout from '../hooks/useSafeTimeout.js';
|
|
11
10
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
11
|
import { useId } from '../hooks/useId.js';
|
|
13
12
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
14
13
|
import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
|
|
14
|
+
import { useIsMacOS } from '../hooks/useIsMacOS.js';
|
|
15
15
|
import { getAccessibleKeybindingHintString, KeybindingHint } from '../KeybindingHint/KeybindingHint.js';
|
|
16
16
|
|
|
17
17
|
// map tooltip direction to anchoredPosition props
|
|
@@ -195,7 +195,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
195
195
|
closeTooltip();
|
|
196
196
|
}
|
|
197
197
|
}, [isPopoverOpen]);
|
|
198
|
-
const
|
|
198
|
+
const isMacOS = useIsMacOS();
|
|
199
199
|
const hasAriaLabel = 'aria-label' in rest;
|
|
200
200
|
|
|
201
201
|
// Normalize keybindingHint to an array for uniform rendering
|
|
@@ -290,7 +290,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
290
290
|
children: [/*#__PURE__*/jsxs("span", {
|
|
291
291
|
id: hasAriaLabel ? undefined : tooltipId,
|
|
292
292
|
children: [text, /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
293
|
-
children: ["(", keybindingHints.map(hint => getAccessibleKeybindingHintString(hint,
|
|
293
|
+
children: ["(", keybindingHints.map(hint => getAccessibleKeybindingHintString(hint, isMacOS)).join(' or '), ")"]
|
|
294
294
|
})]
|
|
295
295
|
}), /*#__PURE__*/jsx("span", {
|
|
296
296
|
className: clsx(classes.KeybindingHintContainer, text && classes.HasTextBefore, keybindingHints.length > 1 && classes.HasMultipleHints),
|
|
@@ -15,9 +15,9 @@ import { useTypeahead } from './useTypeahead.js';
|
|
|
15
15
|
import { IconButton } from '../Button/IconButton.js';
|
|
16
16
|
import { ButtonComponent } from '../Button/Button.js';
|
|
17
17
|
import { ActionList } from '../ActionList/index.js';
|
|
18
|
-
import { usePlatform } from '../KeybindingHint/platform.js';
|
|
19
18
|
import { isSlot } from '../utils/is-slot.js';
|
|
20
19
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
20
|
+
import { useIsMacOS } from '../hooks/useIsMacOS.js';
|
|
21
21
|
import { AriaStatus } from '../live-region/AriaStatus.js';
|
|
22
22
|
import Spinner from '../Spinner/Spinner.js';
|
|
23
23
|
import { Tooltip } from '../TooltipV2/Tooltip.js';
|
|
@@ -311,7 +311,7 @@ const Item = /*#__PURE__*/React.forwardRef(({
|
|
|
311
311
|
const [isSubTreeEmpty, setIsSubTreeEmpty] = React.useState(!hasSubTree);
|
|
312
312
|
const [actionCommandPressed, setActionCommandPressed] = React.useState(false);
|
|
313
313
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
314
|
-
const
|
|
314
|
+
const isMacOS = useIsMacOS();
|
|
315
315
|
|
|
316
316
|
// Set the expanded state and cache it
|
|
317
317
|
const setIsExpandedWithCache = React.useCallback(
|
|
@@ -372,8 +372,8 @@ const Item = /*#__PURE__*/React.forwardRef(({
|
|
|
372
372
|
}
|
|
373
373
|
}, [onSelect, setIsExpandedWithCache, toggle, activateActionsDialog]);
|
|
374
374
|
const ariaDescribedByIds = [slots.leadingVisual ? leadingVisualId : null, slots.trailingVisual ? trailingVisualId : null].filter(Boolean);
|
|
375
|
-
const shortcut = `Shift+${
|
|
376
|
-
const trailingActionShortcutText = `Press (${getAccessibleKeybindingHintString(shortcut,
|
|
375
|
+
const shortcut = `Shift+${isMacOS ? 'Meta' : 'Control'}+U`;
|
|
376
|
+
const trailingActionShortcutText = `Press (${getAccessibleKeybindingHintString(shortcut, isMacOS)}) for more actions.`;
|
|
377
377
|
return /*#__PURE__*/jsx(ItemContext.Provider, {
|
|
378
378
|
value: {
|
|
379
379
|
itemId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnchoredPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnchoredPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AA0BvE,MAAM,WAAW,4BAA6B,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IAC7E,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACpD,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAA;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;
|
|
1
|
+
{"version":3,"file":"useAnchoredPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnchoredPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AA0BvE,MAAM,WAAW,4BAA6B,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IAC7E,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACpD,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAA;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAcD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,CAAC,EAAE,4BAA4B,EACvC,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC;IACD,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACnD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACjD,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;CACrC,CAiJA"}
|
|
@@ -24,6 +24,16 @@ function getScrollableAncestors(element) {
|
|
|
24
24
|
scrollables.push(window);
|
|
25
25
|
return scrollables;
|
|
26
26
|
}
|
|
27
|
+
function hasOverflowingDescendant(element) {
|
|
28
|
+
if (!element) return false;
|
|
29
|
+
for (const descendant of element.querySelectorAll('*')) {
|
|
30
|
+
if (descendant.scrollHeight > descendant.clientHeight || descendant.scrollWidth > descendant.clientWidth) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
/**
|
|
28
38
|
* Calculates the top and left values for an absolutely-positioned floating element
|
|
29
39
|
* to be anchored to some anchor element. Returns refs for the floating element
|
|
@@ -50,9 +60,23 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
50
60
|
const updateElementHeight = () => {
|
|
51
61
|
let heightUpdated = false;
|
|
52
62
|
setPrevHeight(prevHeight => {
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
var _floatingElement$clie, _floatingElement$scro;
|
|
64
|
+
const floatingElement = floatingElementRef.current;
|
|
65
|
+
const currentHeight = (_floatingElement$clie = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.clientHeight) !== null && _floatingElement$clie !== void 0 ? _floatingElement$clie : 0;
|
|
66
|
+
const desiredHeight = Math.max((_floatingElement$scro = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.scrollHeight) !== null && _floatingElement$scro !== void 0 ? _floatingElement$scro : 0, currentHeight);
|
|
67
|
+
const contentNeedsMoreHeight = prevHeight !== undefined && desiredHeight > prevHeight || hasOverflowingDescendant(floatingElement);
|
|
68
|
+
|
|
69
|
+
// if the element is trying to shrink in height, restore to old height to prevent it from jumping.
|
|
70
|
+
// When the content now needs to grow past the previous height, clear any stale inline height instead.
|
|
71
|
+
if (prevHeight && prevHeight > currentHeight) {
|
|
72
|
+
if (contentNeedsMoreHeight) {
|
|
73
|
+
requestAnimationFrame(() => {
|
|
74
|
+
if (floatingElementRef.current instanceof HTMLElement) {
|
|
75
|
+
floatingElementRef.current.style.height = '';
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return prevHeight;
|
|
79
|
+
}
|
|
56
80
|
requestAnimationFrame(() => {
|
|
57
81
|
floatingElementRef.current.style.height = `${prevHeight}px`;
|
|
58
82
|
});
|
|
@@ -63,15 +87,15 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
63
87
|
return heightUpdated;
|
|
64
88
|
};
|
|
65
89
|
const updatePosition = React.useCallback(() => {
|
|
66
|
-
var _floatingElementRef$
|
|
90
|
+
var _floatingElementRef$c3;
|
|
67
91
|
if (!enabled) return;
|
|
68
92
|
if (floatingElementRef.current instanceof Element && anchorElementRef.current instanceof Element) {
|
|
69
93
|
const newPosition = getAnchoredPosition(floatingElementRef.current, anchorElementRef.current, settings);
|
|
70
94
|
setPosition(prev => {
|
|
71
95
|
if (settings !== null && settings !== void 0 && settings.pinPosition && topPositionChanged(prev, newPosition)) {
|
|
72
|
-
var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$
|
|
96
|
+
var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$c, _floatingElementRef$c2;
|
|
73
97
|
const anchorTop = (_anchorElementRef$cur = (_anchorElementRef$cur2 = anchorElementRef.current) === null || _anchorElementRef$cur2 === void 0 ? void 0 : _anchorElementRef$cur2.getBoundingClientRect().top) !== null && _anchorElementRef$cur !== void 0 ? _anchorElementRef$cur : 0;
|
|
74
|
-
const elementStillFitsOnTop = anchorTop > ((_floatingElementRef$
|
|
98
|
+
const elementStillFitsOnTop = anchorTop > ((_floatingElementRef$c = (_floatingElementRef$c2 = floatingElementRef.current) === null || _floatingElementRef$c2 === void 0 ? void 0 : _floatingElementRef$c2.clientHeight) !== null && _floatingElementRef$c !== void 0 ? _floatingElementRef$c : 0);
|
|
75
99
|
if (elementStillFitsOnTop && updateElementHeight()) {
|
|
76
100
|
return prev;
|
|
77
101
|
}
|
|
@@ -88,7 +112,7 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
88
112
|
setPosition(undefined);
|
|
89
113
|
(_savedOnPositionChang2 = savedOnPositionChange.current) === null || _savedOnPositionChang2 === void 0 ? void 0 : _savedOnPositionChang2.call(savedOnPositionChange, undefined);
|
|
90
114
|
}
|
|
91
|
-
setPrevHeight((_floatingElementRef$
|
|
115
|
+
setPrevHeight((_floatingElementRef$c3 = floatingElementRef.current) === null || _floatingElementRef$c3 === void 0 ? void 0 : _floatingElementRef$c3.clientHeight);
|
|
92
116
|
},
|
|
93
117
|
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo
|
|
94
118
|
[floatingElementRef, anchorElementRef, enabled, ...dependencies]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isMacOS } from '@primer/behaviors/utils';
|
|
2
|
+
import { useSyncExternalStore } from 'react';
|
|
3
|
+
|
|
4
|
+
// No-op. The platform never changes at runtime, so there is nothing to
|
|
5
|
+
// subscribe to. Hoisted to avoid creating a new function on every call.
|
|
6
|
+
const subscribe = () => () => {};
|
|
7
|
+
|
|
8
|
+
// Safe default for SSR since we can't detect the platform on the server.
|
|
9
|
+
const getServerSnapshot = () => false;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SSR-safe hook for determining if the current platform is MacOS.
|
|
13
|
+
*
|
|
14
|
+
* Uses `useSyncExternalStore` to read the platform value:
|
|
15
|
+
*
|
|
16
|
+
* - On the **client**, `ssrUnsafeIsMacOS` reads `navigator.userAgent` and
|
|
17
|
+
* returns the real value immediately, with no extra render pass.
|
|
18
|
+
*
|
|
19
|
+
* - On the **server**, returns `false`. During hydration, if the snapshots
|
|
20
|
+
* differ, React handles the mismatch internally in a single synchronous
|
|
21
|
+
* pass, avoiding the layout shift that a deferred `useEffect` + `setState`
|
|
22
|
+
* would cause.
|
|
23
|
+
*
|
|
24
|
+
* Previous implementation used `useState` + `useEffect`, which caused an
|
|
25
|
+
* unconditional second render on every mount (even on the client where the
|
|
26
|
+
* initial value was already correct).
|
|
27
|
+
*/
|
|
28
|
+
function useIsMacOS() {
|
|
29
|
+
return useSyncExternalStore(subscribe, isMacOS, getServerSnapshot);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { useIsMacOS };
|
|
@@ -3831,10 +3831,6 @@
|
|
|
3831
3831
|
{
|
|
3832
3832
|
"id": "experimental-components-keybindinghint-features--on-primary",
|
|
3833
3833
|
"code": "(args) => (\n <div className={classes.PrimaryBackground}>\n <KeybindingHint {...args} />\n </div>\n)"
|
|
3834
|
-
},
|
|
3835
|
-
{
|
|
3836
|
-
"id": "experimental-components-keybindinghint-features--platforms",
|
|
3837
|
-
"code": "({ format = 'full', ...args }) => (\n <table className={classes.PlatformTable}>\n <thead>\n <tr>\n <th\n scope=\"col\"\n className={`${classes.PlatformCell} ${classes.PlatformHeader}`}\n >\n Platform\n </th>\n {modifierKeys.map((key) => (\n <th\n scope=\"col\"\n className={`${classes.PlatformCell} ${classes.PlatformHeader}`}\n key={key}\n >\n {key}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {platforms.map(({ platform, label }) => (\n <tr key={platform}>\n <th\n scope=\"row\"\n className={`${classes.PlatformCell} ${classes.PlatformHeader}`}\n >\n {label}\n </th>\n {modifierKeys.map((key) => (\n <td key={key} className={classes.PlatformCell}>\n <PlatformOverrideProvider value={platform}>\n <KeybindingHint {...args} format={format} keys={`${key}+K`} />\n </PlatformOverrideProvider>\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n)"
|
|
3838
3834
|
}
|
|
3839
3835
|
],
|
|
3840
3836
|
"importPath": "@primer/react",
|
|
@@ -7524,6 +7520,26 @@
|
|
|
7524
7520
|
{
|
|
7525
7521
|
"id": "components-text-features--semibold-weight",
|
|
7526
7522
|
"code": "() => (\n <Text as=\"span\" weight=\"semibold\">\n Stylized text\n </Text>\n)"
|
|
7523
|
+
},
|
|
7524
|
+
{
|
|
7525
|
+
"id": "components-text-features--pre-white-space",
|
|
7526
|
+
"code": "() => (\n <Text as=\"span\" whiteSpace=\"pre\">\n Stylized text\n </Text>\n)"
|
|
7527
|
+
},
|
|
7528
|
+
{
|
|
7529
|
+
"id": "components-text-features--normal-white-space",
|
|
7530
|
+
"code": "() => (\n <Text as=\"span\" whiteSpace=\"normal\">\n Stylized text\n </Text>\n)"
|
|
7531
|
+
},
|
|
7532
|
+
{
|
|
7533
|
+
"id": "components-text-features--nowrap-white-space",
|
|
7534
|
+
"code": "() => (\n <Text as=\"span\" whiteSpace=\"nowrap\">\n Stylized text\n </Text>\n)"
|
|
7535
|
+
},
|
|
7536
|
+
{
|
|
7537
|
+
"id": "components-text-features--pre-wrap-white-space",
|
|
7538
|
+
"code": "() => (\n <Text as=\"span\" whiteSpace=\"pre-wrap\">\n Stylized text\n </Text>\n)"
|
|
7539
|
+
},
|
|
7540
|
+
{
|
|
7541
|
+
"id": "components-text-features--pre-line-white-space",
|
|
7542
|
+
"code": "() => (\n <Text as=\"span\" whiteSpace=\"pre-line\">\n Stylized text\n </Text>\n)"
|
|
7527
7543
|
}
|
|
7528
7544
|
],
|
|
7529
7545
|
"importPath": "@primer/react",
|
package/package.json
CHANGED