@primer/react 0.0.0-20260218182540 → 0.0.0-20260218205658
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 -24
- package/dist/ActionList/Description.js +35 -113
- package/dist/ActionList/Divider.js +11 -30
- package/dist/ActionList/Group.js +117 -294
- package/dist/ActionList/Heading.js +22 -77
- package/dist/ActionList/Item.js +37 -98
- package/dist/ActionList/LinkItem.js +24 -80
- package/dist/ActionList/List.js +33 -143
- package/dist/ActionList/Selection.js +30 -78
- package/dist/ActionList/TrailingAction.js +23 -83
- package/dist/ActionList/Visuals.js +64 -162
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +62 -72
- package/dist/Button/Button.js +11 -34
- package/dist/Button/ButtonBase.d.ts.map +1 -1
- package/dist/Button/ButtonBase.js +14 -9
- package/dist/Button/IconButton.js +51 -140
- package/dist/Button/LinkButton.js +11 -39
- package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css +2 -0
- package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css.map +1 -0
- package/dist/FilteredActionList/FilteredActionList.module.css.js +2 -2
- package/dist/PageLayout/PageLayout-06f4c069.css +2 -0
- package/dist/PageLayout/PageLayout-06f4c069.css.map +1 -0
- package/dist/PageLayout/PageLayout.d.ts +71 -2
- package/dist/PageLayout/PageLayout.d.ts.map +1 -1
- package/dist/PageLayout/PageLayout.js +498 -44
- package/dist/PageLayout/PageLayout.module.css.js +2 -2
- package/dist/PageLayout/usePaneWidth.d.ts +16 -4
- package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
- package/dist/PageLayout/usePaneWidth.js +123 -109
- package/dist/SplitPageLayout/SplitPageLayout.d.ts +4 -1
- package/dist/SplitPageLayout/SplitPageLayout.d.ts.map +1 -1
- package/dist/SplitPageLayout/SplitPageLayout.js +54 -2
- package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNav.js +4 -11
- package/dist/experimental/SelectPanel2/SelectPanel-1f8c23b5.css +2 -0
- package/dist/experimental/SelectPanel2/{SelectPanel-f0c4b9ca.css.map → SelectPanel-1f8c23b5.css.map} +1 -1
- package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +1 -1
- package/dist/hooks/useIsMacOS.d.ts +3 -15
- package/dist/hooks/useIsMacOS.d.ts.map +1 -1
- package/dist/hooks/useIsMacOS.js +26 -24
- package/dist/hooks/useSlots.d.ts +6 -50
- package/dist/hooks/useSlots.d.ts.map +1 -1
- package/dist/hooks/useSlots.js +36 -114
- package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css +2 -0
- package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css.map +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
- package/dist/live-region/Announce.d.ts.map +1 -1
- package/dist/live-region/Announce.js +4 -7
- package/dist/utils/environment.js +9 -0
- package/generated/components.json +200 -2
- package/package.json +2 -2
- package/dist/FilteredActionList/FilteredActionList-02db90c6.css +0 -2
- package/dist/FilteredActionList/FilteredActionList-02db90c6.css.map +0 -1
- package/dist/PageLayout/PageLayout-cb491b47.css +0 -2
- package/dist/PageLayout/PageLayout-cb491b47.css.map +0 -1
- package/dist/experimental/SelectPanel2/SelectPanel-f0c4b9ca.css +0 -2
- package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +0 -2
- package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './SelectPanel-
|
|
1
|
+
import './SelectPanel-1f8c23b5.css';
|
|
2
2
|
|
|
3
3
|
var classes = {"Overlay":"prc-SelectPanel2-Overlay--Q-FI","Form":"prc-SelectPanel2-Form-bZ9HS","Container":"prc-SelectPanel2-Container-e5e6-","HeaderContent":"prc-SelectPanel2-HeaderContent-MsaAS","TitleWrapper":"prc-SelectPanel2-TitleWrapper-HzPu3","TextInput":"prc-SelectPanel2-TextInput-lHH1n","Checkbox":"prc-SelectPanel2-Checkbox-AYR38","FlexBox":"prc-SelectPanel2-FlexBox-gWPRg","Title":"prc-SelectPanel2-Title-T-h3f","Description":"prc-SelectPanel2-Description-qTXfi","ClearAction":"prc-SelectPanel2-ClearAction-tQj-f","Footer":"prc-SelectPanel2-Footer-TibV0","FooterContent":"prc-SelectPanel2-FooterContent-UjAOM","FooterActions":"prc-SelectPanel2-FooterActions-T6yQR","SecondaryCheckbox":"prc-SelectPanel2-SecondaryCheckbox-omkf-","SmallText":"prc-SelectPanel2-SmallText-c42ay","SelectPanelLoading":"prc-SelectPanel2-SelectPanelLoading-mtyhD","LoadingText":"prc-SelectPanel2-LoadingText-DB0wN","MessageFull":"prc-SelectPanel2-MessageFull-nY-qF","Octicon":"prc-SelectPanel2-Octicon-zt-zU","Error":"prc-SelectPanel2-Error-ZrZQQ","Warning":"prc-SelectPanel2-Warning-PDsVF","MessageTitle":"prc-SelectPanel2-MessageTitle-T7v9d","MessageContent":"prc-SelectPanel2-MessageContent-UZ9vY","MessageInline":"prc-SelectPanel2-MessageInline-sErQf","Header":"prc-SelectPanel2-Header-LKyEJ"};
|
|
4
4
|
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SSR-safe hook for determining if the current platform is MacOS.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - On the **client**, `ssrUnsafeIsMacOS` reads `navigator.userAgent` and
|
|
7
|
-
* returns the real value immediately, with no extra render pass.
|
|
8
|
-
*
|
|
9
|
-
* - On the **server**, returns `false`. During hydration, if the snapshots
|
|
10
|
-
* differ, React handles the mismatch internally in a single synchronous
|
|
11
|
-
* pass, avoiding the layout shift that a deferred `useEffect` + `setState`
|
|
12
|
-
* would cause.
|
|
13
|
-
*
|
|
14
|
-
* Previous implementation used `useState` + `useEffect`, which caused an
|
|
15
|
-
* unconditional second render on every mount (even on the client where the
|
|
16
|
-
* initial value was already correct).
|
|
2
|
+
* SSR-safe hook for determining if the current platform is MacOS. When rendering
|
|
3
|
+
* server-side, will default to non-MacOS and then re-render in an effect if the
|
|
4
|
+
* client turns out to be a MacOS device.
|
|
17
5
|
*/
|
|
18
6
|
export declare function useIsMacOS(): boolean;
|
|
19
7
|
//# sourceMappingURL=useIsMacOS.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMacOS.d.ts","sourceRoot":"","sources":["../../src/hooks/useIsMacOS.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsMacOS.d.ts","sourceRoot":"","sources":["../../src/hooks/useIsMacOS.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,UAAU,YASzB"}
|
package/dist/hooks/useIsMacOS.js
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import { isMacOS } from '@primer/behaviors/utils';
|
|
2
|
-
import {
|
|
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;
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { canUseDOM } from '../utils/environment.js';
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
|
-
* SSR-safe hook for determining if the current platform is MacOS.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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).
|
|
7
|
+
* SSR-safe hook for determining if the current platform is MacOS. When rendering
|
|
8
|
+
* server-side, will default to non-MacOS and then re-render in an effect if the
|
|
9
|
+
* client turns out to be a MacOS device.
|
|
27
10
|
*/
|
|
28
11
|
function useIsMacOS() {
|
|
29
|
-
|
|
12
|
+
const $ = c(2);
|
|
13
|
+
const [isMacOS$1, setIsMacOS] = useState(_temp);
|
|
14
|
+
let t0;
|
|
15
|
+
let t1;
|
|
16
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
17
|
+
t0 = () => {
|
|
18
|
+
setIsMacOS(isMacOS());
|
|
19
|
+
};
|
|
20
|
+
t1 = [];
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = t1;
|
|
23
|
+
} else {
|
|
24
|
+
t0 = $[0];
|
|
25
|
+
t1 = $[1];
|
|
26
|
+
}
|
|
27
|
+
useEffect(t0, t1);
|
|
28
|
+
return isMacOS$1;
|
|
29
|
+
}
|
|
30
|
+
function _temp() {
|
|
31
|
+
return canUseDOM ? isMacOS() : false;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export { useIsMacOS };
|
package/dist/hooks/useSlots.d.ts
CHANGED
|
@@ -1,56 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* useSlots - Extract slot components from children for SSR-compatible slot APIs.
|
|
4
|
-
*
|
|
5
|
-
* Given a list of children and a config mapping slot names to component types,
|
|
6
|
-
* separates children into two groups: matched slots and the rest.
|
|
7
|
-
*
|
|
8
|
-
* Config: { leadingVisual: LeadingVisual, description: Description }
|
|
9
|
-
*
|
|
10
|
-
* Children: Matching: Output:
|
|
11
|
-
* +----------------+ slots = {
|
|
12
|
-
* | LeadingVisual | -> matches slot 0 --> leadingVisual: <LeadingVisual />
|
|
13
|
-
* | "Project name" | -> no match --> description: <Description />
|
|
14
|
-
* | Description | -> matches slot 1 --> }
|
|
15
|
-
* | TrailingVisual | -> no match --> rest = ["Project name", <TrailingVisual />]
|
|
16
|
-
* +----------------+
|
|
17
|
-
*
|
|
18
|
-
* Performance-sensitive: called per item in lists (e.g. 100-item ActionList
|
|
19
|
-
* calls this 101 times per render).
|
|
20
|
-
*
|
|
21
|
-
* Once all slots are filled, remaining children skip matching entirely in
|
|
22
|
-
* production (single integer comparison). In dev, we still scan for duplicates
|
|
23
|
-
* to emit a warning.
|
|
24
|
-
*
|
|
25
|
-
* Flow per child:
|
|
26
|
-
*
|
|
27
|
-
* child ──> isValidElement? ──no──> rest[]
|
|
28
|
-
* |
|
|
29
|
-
* yes
|
|
30
|
-
* |
|
|
31
|
-
* v
|
|
32
|
-
* all slots filled? ──yes──> rest[] (prod)
|
|
33
|
-
* | |
|
|
34
|
-
* no [dev: check for
|
|
35
|
-
* | duplicate warning]
|
|
36
|
-
* v
|
|
37
|
-
* match against unfilled slots
|
|
38
|
-
* |
|
|
39
|
-
* found match? ──no──> rest[]
|
|
40
|
-
* |
|
|
41
|
-
* yes
|
|
42
|
-
* |
|
|
43
|
-
* v
|
|
44
|
-
* slots[key] = child, slotsFound++
|
|
45
|
-
*
|
|
46
|
-
* Slot config supports two matcher styles:
|
|
47
|
-
* 1. Component reference: { visual: LeadingVisual }
|
|
48
|
-
* 2. Component + test fn: { block: [Description, props => props.variant === 'block'] }
|
|
49
|
-
*/
|
|
50
|
-
type Props = any;
|
|
51
2
|
type ComponentMatcher = React.ElementType<Props>;
|
|
52
3
|
type ComponentAndPropsMatcher = [ComponentMatcher, (props: Props) => boolean];
|
|
53
4
|
export type SlotConfig = Record<string, ComponentMatcher | ComponentAndPropsMatcher>;
|
|
5
|
+
type Props = any;
|
|
54
6
|
type SlotElements<Config extends SlotConfig> = {
|
|
55
7
|
[Property in keyof Config]: SlotValue<Config, Property>;
|
|
56
8
|
};
|
|
@@ -58,7 +10,11 @@ type SlotValue<Config, Property extends keyof Config> = Config[Property] extends
|
|
|
58
10
|
infer ElementType extends React.ElementType,
|
|
59
11
|
infer _testFn
|
|
60
12
|
] ? React.ReactElement<React.ComponentPropsWithoutRef<ElementType>, ElementType> : never;
|
|
61
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Extract components from `children` so we can render them in different places,
|
|
15
|
+
* allowing us to implement components with SSR-compatible slot APIs.
|
|
16
|
+
* Note: We can only extract direct children, not nested ones.
|
|
17
|
+
*/
|
|
62
18
|
export declare function useSlots<Config extends SlotConfig>(children: React.ReactNode, config: Config): [Partial<SlotElements<Config>>, React.ReactNode[]];
|
|
63
19
|
export {};
|
|
64
20
|
//# sourceMappingURL=useSlots.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSlots.d.ts","sourceRoot":"","sources":["../../src/hooks/useSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"useSlots.d.ts","sourceRoot":"","sources":["../../src/hooks/useSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,KAAK,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;AAEhD,KAAK,wBAAwB,GAAG,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,CAAA;AAE7E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,wBAAwB,CAAC,CAAA;AAIpF,KAAK,KAAK,GAAG,GAAG,CAAA;AAEhB,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI;KAC5C,QAAQ,IAAI,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;CACxD,CAAA;AAED,KAAK,SAAS,CAAC,MAAM,EAAE,QAAQ,SAAS,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,CAAC,WAAW,GAC9F,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,GACtF,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAS;IAC9B,MAAM,WAAW,SAAS,KAAK,CAAC,WAAW;IAE3C,MAAM,OAAO;CACd,GACD,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,wBAAwB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,GAC5E,KAAK,CAAA;AAEX;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAS,UAAU,EAChD,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,MAAM,EAAE,MAAM,GACb,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CA8CpD"}
|
package/dist/hooks/useSlots.js
CHANGED
|
@@ -2,85 +2,29 @@ import React from 'react';
|
|
|
2
2
|
import { warning } from '../utils/warning.js';
|
|
3
3
|
import { isSlot } from '../utils/is-slot.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Given a list of children and a config mapping slot names to component types,
|
|
9
|
-
* separates children into two groups: matched slots and the rest.
|
|
10
|
-
*
|
|
11
|
-
* Config: { leadingVisual: LeadingVisual, description: Description }
|
|
12
|
-
*
|
|
13
|
-
* Children: Matching: Output:
|
|
14
|
-
* +----------------+ slots = {
|
|
15
|
-
* | LeadingVisual | -> matches slot 0 --> leadingVisual: <LeadingVisual />
|
|
16
|
-
* | "Project name" | -> no match --> description: <Description />
|
|
17
|
-
* | Description | -> matches slot 1 --> }
|
|
18
|
-
* | TrailingVisual | -> no match --> rest = ["Project name", <TrailingVisual />]
|
|
19
|
-
* +----------------+
|
|
20
|
-
*
|
|
21
|
-
* Performance-sensitive: called per item in lists (e.g. 100-item ActionList
|
|
22
|
-
* calls this 101 times per render).
|
|
23
|
-
*
|
|
24
|
-
* Once all slots are filled, remaining children skip matching entirely in
|
|
25
|
-
* production (single integer comparison). In dev, we still scan for duplicates
|
|
26
|
-
* to emit a warning.
|
|
27
|
-
*
|
|
28
|
-
* Flow per child:
|
|
29
|
-
*
|
|
30
|
-
* child ──> isValidElement? ──no──> rest[]
|
|
31
|
-
* |
|
|
32
|
-
* yes
|
|
33
|
-
* |
|
|
34
|
-
* v
|
|
35
|
-
* all slots filled? ──yes──> rest[] (prod)
|
|
36
|
-
* | |
|
|
37
|
-
* no [dev: check for
|
|
38
|
-
* | duplicate warning]
|
|
39
|
-
* v
|
|
40
|
-
* match against unfilled slots
|
|
41
|
-
* |
|
|
42
|
-
* found match? ──no──> rest[]
|
|
43
|
-
* |
|
|
44
|
-
* yes
|
|
45
|
-
* |
|
|
46
|
-
* v
|
|
47
|
-
* slots[key] = child, slotsFound++
|
|
48
|
-
*
|
|
49
|
-
* Slot config supports two matcher styles:
|
|
50
|
-
* 1. Component reference: { visual: LeadingVisual }
|
|
51
|
-
* 2. Component + test fn: { block: [Description, props => props.variant === 'block'] }
|
|
52
|
-
*/
|
|
5
|
+
// slot config allows 2 options:
|
|
6
|
+
// 1. Component to match, example: { leadingVisual: LeadingVisual }
|
|
53
7
|
|
|
54
|
-
//
|
|
8
|
+
// 2. Component to match + a test function, example: { blockDescription: [Description, props => props.variant === 'block'] }
|
|
55
9
|
|
|
10
|
+
// We don't know what the props are yet, we set them later based on slot config
|
|
56
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
12
|
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
/** Check if a child element matches a slot config entry, either by direct type comparison or slot symbol. */
|
|
61
|
-
function childMatchesSlot(child, slotValue) {
|
|
62
|
-
if (Array.isArray(slotValue)) {
|
|
63
|
-
const [component, testFn] = slotValue;
|
|
64
|
-
return (child.type === component || isSlot(child, component)) && testFn(child.props);
|
|
65
|
-
}
|
|
66
|
-
return child.type === slotValue || isSlot(child, slotValue);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// --- Hook ---
|
|
13
|
+
// useful for narrowing types, third option is not possible
|
|
70
14
|
|
|
71
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Extract components from `children` so we can render them in different places,
|
|
17
|
+
* allowing us to implement components with SSR-compatible slot APIs.
|
|
18
|
+
* Note: We can only extract direct children, not nested ones.
|
|
19
|
+
*/
|
|
72
20
|
function useSlots(children, config) {
|
|
21
|
+
// Object mapping slot names to their elements
|
|
22
|
+
const slots = mapValues(config, () => undefined);
|
|
23
|
+
|
|
24
|
+
// Array of elements that are not slots
|
|
73
25
|
const rest = [];
|
|
74
26
|
const keys = Object.keys(config);
|
|
75
27
|
const values = Object.values(config);
|
|
76
|
-
const totalSlots = keys.length;
|
|
77
|
-
|
|
78
|
-
// Initialize all slot keys to undefined so callers can check `slots.x === undefined`
|
|
79
|
-
const slots = {};
|
|
80
|
-
for (let i = 0; i < totalSlots; i++) {
|
|
81
|
-
slots[keys[i]] = undefined;
|
|
82
|
-
}
|
|
83
|
-
let slotsFound = 0;
|
|
84
28
|
|
|
85
29
|
// eslint-disable-next-line github/array-foreach
|
|
86
30
|
React.Children.forEach(children, child => {
|
|
@@ -88,63 +32,41 @@ function useSlots(children, config) {
|
|
|
88
32
|
rest.push(child);
|
|
89
33
|
return;
|
|
90
34
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
35
|
+
const index = values.findIndex(value => {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
const [component, testFn] = value;
|
|
38
|
+
return (child.type === component || isSlot(child, component)) && testFn(child.props);
|
|
39
|
+
} else {
|
|
40
|
+
return child.type === value || isSlot(child, value);
|
|
96
41
|
}
|
|
97
|
-
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
42
|
+
});
|
|
100
43
|
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
if (matchedIndex === -1) {
|
|
44
|
+
// If the child is not a slot, add it to the `rest` array
|
|
45
|
+
if (index === -1) {
|
|
104
46
|
rest.push(child);
|
|
105
47
|
return;
|
|
106
48
|
}
|
|
107
|
-
const slotKey = keys[
|
|
49
|
+
const slotKey = keys[index];
|
|
108
50
|
|
|
109
|
-
//
|
|
110
|
-
if (slots[slotKey]
|
|
111
|
-
|
|
112
|
-
process.env.NODE_ENV !== "production" ? warning(true, `Found duplicate "${String(slotKey)}" slot. Only the first will be rendered.`) : void 0;
|
|
113
|
-
}
|
|
51
|
+
// If slot is already filled, ignore duplicates
|
|
52
|
+
if (slots[slotKey]) {
|
|
53
|
+
process.env.NODE_ENV !== "production" ? warning(true, `Found duplicate "${String(slotKey)}" slot. Only the first will be rendered.`) : void 0;
|
|
114
54
|
return;
|
|
115
55
|
}
|
|
56
|
+
|
|
57
|
+
// If the child is a slot, add it to the `slots` object
|
|
58
|
+
|
|
116
59
|
slots[slotKey] = child;
|
|
117
|
-
slotsFound++;
|
|
118
60
|
});
|
|
119
61
|
return [slots, rest];
|
|
120
62
|
}
|
|
121
63
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
function findMatchingSlot(child, values, totalSlots) {
|
|
129
|
-
for (let i = 0; i < totalSlots; i++) {
|
|
130
|
-
if (childMatchesSlot(child, values[i])) return i;
|
|
131
|
-
}
|
|
132
|
-
return -1;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Dev-only: check if a child duplicates an already-filled slot.
|
|
137
|
-
* Returns true (and warns) if a duplicate is found, false otherwise.
|
|
138
|
-
* Used in the short-circuit path where all slots are already filled.
|
|
139
|
-
*/
|
|
140
|
-
function warnIfDuplicate(child, keys, values, totalSlots) {
|
|
141
|
-
for (let i = 0; i < totalSlots; i++) {
|
|
142
|
-
if (childMatchesSlot(child, values[i])) {
|
|
143
|
-
process.env.NODE_ENV !== "production" ? warning(true, `Found duplicate "${String(keys[i])}" slot. Only the first will be rendered.`) : void 0;
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return false;
|
|
64
|
+
/** Map the values of an object */
|
|
65
|
+
function mapValues(obj, fn) {
|
|
66
|
+
return Object.keys(obj).reduce((result, key) => {
|
|
67
|
+
result[key] = fn(obj[key]);
|
|
68
|
+
return result;
|
|
69
|
+
}, {});
|
|
148
70
|
}
|
|
149
71
|
|
|
150
72
|
export { useSlots };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.prc-components-UnderlineWrapper-eT-Yj{align-items:center;box-shadow:inset 0 -1px var(--borderColor-muted,var(--color-border-muted));display:flex;justify-content:flex-start;min-height:var(--control-xlarge-size,48px);padding-inline:var(--stack-padding-normal,1rem)}.prc-components-UnderlineWrapper-eT-Yj[data-variant=flush]{padding-inline:unset}.prc-components-UnderlineItemList-xKlKC{display:flex;gap:8px;list-style:none;margin:0;padding:0;white-space:nowrap}.prc-components-UnderlineItem-7fP-n,.prc-components-UnderlineItemList-xKlKC{align-items:center;position:relative}.prc-components-UnderlineItem-7fP-n{appearance:none;background-color:transparent;border:0;border-radius:var(--borderRadius-medium,var(--borderRadius-small,.1875rem));color:var(--fgColor-default,var(--color-fg-default));cursor:pointer;display:inline-flex;font:inherit;font-size:var(--text-body-size-medium,.875rem);line-height:var(--text-body-lineHeight-medium,1.4285);padding-block:var(--base-size-6,.375rem);padding-inline:var(--base-size-8,.5rem);text-align:center;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.prc-components-UnderlineItem-7fP-n:hover{background-color:var(--bgColor-neutral-muted,var(--color-neutral-subtle));-webkit-text-decoration:none;text-decoration:none;transition:background-color .12s ease-out}}.prc-components-UnderlineItem-7fP-n:focus{box-shadow:inset 0 0 0 2px var(--fgColor-accent,var(--color-accent-fg));outline:2px solid transparent}.prc-components-UnderlineItem-7fP-n:focus:not(:focus-visible){box-shadow:none}.prc-components-UnderlineItem-7fP-n:focus-visible{box-shadow:inset 0 0 0 2px var(--fgColor-accent,var(--color-accent-fg));outline:2px solid transparent}.prc-components-UnderlineItem-7fP-n [data-content]:before{content:attr(data-content);display:block;font-weight:var(--base-text-weight-semibold,600);height:0;visibility:hidden;white-space:nowrap}.prc-components-UnderlineItem-7fP-n [data-component=icon]{align-items:center;color:var(--fgColor-muted,var(--color-fg-muted));display:inline-flex;margin-inline-end:var(--base-size-8,.5rem)}.prc-components-UnderlineItem-7fP-n [data-component=counter]{align-items:center;display:flex;margin-inline-start:var(--base-size-8,.5rem)}.prc-components-UnderlineItem-7fP-n:after{background-color:transparent;border-radius:0;bottom:calc(50% - var(--control-xlarge-size, var(--base-size-48,3rem))/2 - 1px);content:"";height:2px;pointer-events:none;position:absolute;right:50%;transform:translate(50%,-50%);width:100%}.prc-components-UnderlineItem-7fP-n[aria-current]:not([aria-current=false]) [data-component=text],.prc-components-UnderlineItem-7fP-n[aria-selected=true] [data-component=text]{font-weight:var(--base-text-weight-semibold,600)}.prc-components-UnderlineItem-7fP-n[aria-current]:not([aria-current=false]):after,.prc-components-UnderlineItem-7fP-n[aria-selected=true]:after{background-color:var(--underlineNav-borderColor-active,var(--color-primer-border-active,#fd8c73))}@media (forced-colors:active){.prc-components-UnderlineItem-7fP-n[aria-current]:not([aria-current=false]):after,.prc-components-UnderlineItem-7fP-n[aria-selected=true]:after{background-color:LinkText}}.prc-components-LoadingCounter-dBuLy{animation:prc-components-loadingCounterKeyFrames-8tMlf 1.2s ease-in-out infinite alternate;background-color:var(--bgColor-neutral-muted,var(--color-neutral-subtle));border-color:var(--borderColor-default,var(--color-border-default));border-radius:20px;display:inline-block;height:1rem;width:1.5rem}@keyframes prc-components-loadingCounterKeyFrames-8tMlf{0%{opacity:1}to{opacity:.2}}
|
|
2
|
+
/*# sourceMappingURL=UnderlineTabbedInterface-20c3ba3d.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/internal/components/UnderlineTabbedInterface.module.css.js"],"names":[],"mappings":"AAAA,uCAKE,kBAAmB,CAOnB,0EAAiD,CAXjD,YAAa,CAGb,0BAA2B,CAI3B,0CAA4C,CAL5C,+CAeF,CAJE,2DAEE,oBACF,CAGF,wCAEE,YAAa,CAMb,OAAQ,CAFR,eAAgB,CAFhB,QAAS,CADT,SAAU,CAEV,kBAIF,CAEA,4EAJE,kBAAmB,CANnB,iBAsCF,CA5BA,oCAgBE,eAAgB,CALhB,4BAA6B,CAC7B,QAAS,CACT,2EAAoE,CANpE,oDAA6B,CAG7B,cAAe,CAPf,mBAAoB,CACpB,YAAa,CACb,8CAAuC,CACvC,qDAAuD,CAYvD,wCAAiC,CADjC,uCAAkC,CATlC,iBAAkB,CAClB,4BAAqB,CAArB,oBAmBF,CAPE,qBACE,0CAEE,yEAA8C,CAD9C,4BAAqB,CAArB,oBAAqB,CAErB,yCACF,CACF,CAGF,0CAGE,uEAAiD,CAFjD,6BAQF,CAHE,8DACE,eACF,CAGF,kDAGE,uEAAiD,CAFjD,6BAGF,CAGA,0DAME,0BAA2B,CAL3B,aAAc,CAEd,gDAA6C,CAD7C,QAAS,CAGT,iBAAkB,CADlB,kBAGF,CAEA,0DAGE,kBAAmB,CADnB,gDAA2B,CAD3B,mBAAoB,CAGpB,0CACF,CAEA,6DAGE,kBAAmB,CADnB,YAAa,CADb,4CAGF,CAEA,0CAaE,4BAA6B,CAC7B,eAAgB,CANhB,+EAAmF,CAInF,UAAW,CAFX,UAAW,CACX,mBAAoB,CAVpB,iBAAkB,CAClB,SAAU,CAaV,6BAA+B,CAN/B,UAOF,CAEA,gLAEE,gDACF,CAEA,gJAGE,iGAMF,CAJE,8BALF,gJAOI,yBAEJ,CADE,CAGF,qCASE,0FAAsE,CAJtE,yEAA8C,CAC9C,mEAAwC,CAExC,kBAAmB,CAPnB,oBAAqB,CAErB,WAAY,CADZ,YAQF,CAEA,wDACE,GACE,SACF,CAEA,GACE,UACF,CACF","file":"UnderlineTabbedInterface-20c3ba3d.css","sourcesContent":[".UnderlineWrapper {\n display: flex;\n /* stylelint-disable-next-line primer/spacing */\n padding-inline: var(--stack-padding-normal);\n justify-content: flex-start;\n align-items: center;\n\n /* make space for the underline */\n min-height: var(--control-xlarge-size, 48px);\n\n /* using a box-shadow instead of a border to accommodate 'overflow-y: hidden' on UnderlinePanels */\n /* stylelint-disable-next-line primer/box-shadow */\n box-shadow: inset 0 -1px var(--borderColor-muted);\n\n &[data-variant='flush'] {\n /* stylelint-disable-next-line primer/spacing */\n padding-inline: unset;\n }\n}\n\n.UnderlineItemList {\n position: relative;\n display: flex;\n padding: 0;\n margin: 0;\n white-space: nowrap;\n list-style: none;\n align-items: center;\n gap: 8px;\n}\n\n.UnderlineItem {\n /* underline tab specific styles */\n position: relative;\n display: inline-flex;\n font: inherit;\n font-size: var(--text-body-size-medium);\n line-height: var(--text-body-lineHeight-medium, 1.4285);\n color: var(--fgColor-default);\n text-align: center;\n text-decoration: none;\n cursor: pointer;\n background-color: transparent;\n border: 0;\n border-radius: var(--borderRadius-medium, var(--borderRadius-small));\n\n /* button resets */\n appearance: none;\n padding-inline: var(--base-size-8);\n padding-block: var(--base-size-6);\n align-items: center;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: none;\n background-color: var(--bgColor-neutral-muted);\n transition: background-color 0.12s ease-out;\n }\n }\n}\n\n.UnderlineItem:focus {\n outline: 2px solid transparent;\n /* stylelint-disable-next-line primer/box-shadow */\n box-shadow: inset 0 0 0 2px var(--fgColor-accent);\n\n /* where focus-visible is supported, remove the focus box-shadow */\n &:not(:focus-visible) {\n box-shadow: none;\n }\n}\n\n.UnderlineItem:focus-visible {\n outline: 2px solid transparent;\n /* stylelint-disable-next-line primer/box-shadow */\n box-shadow: inset 0 0 0 2px var(--fgColor-accent);\n}\n\n/* renders a visibly hidden \"copy\" of the label in bold, reserving box space for when label becomes bold on selected */\n.UnderlineItem [data-content]::before {\n display: block;\n height: 0;\n font-weight: var(--base-text-weight-semibold);\n white-space: nowrap;\n visibility: hidden;\n content: attr(data-content);\n}\n\n.UnderlineItem [data-component='icon'] {\n display: inline-flex;\n color: var(--fgColor-muted);\n align-items: center;\n margin-inline-end: var(--base-size-8);\n}\n\n.UnderlineItem [data-component='counter'] {\n margin-inline-start: var(--base-size-8);\n display: flex;\n align-items: center;\n}\n\n.UnderlineItem::after {\n position: absolute;\n right: 50%;\n\n /* TODO: see if we can simplify this positioning */\n\n /* 48px total height / 2 (24px) + 1px */\n /* stylelint-disable-next-line primer/spacing */\n bottom: calc(50% - calc(var(--control-xlarge-size, var(--base-size-48)) / 2 + 1px));\n width: 100%;\n height: 2px;\n pointer-events: none;\n content: '';\n background-color: transparent;\n border-radius: 0;\n transform: translate(50%, -50%);\n}\n\n.UnderlineItem[aria-current]:not([aria-current='false']) [data-component='text'],\n.UnderlineItem[aria-selected='true'] [data-component='text'] {\n font-weight: var(--base-text-weight-semibold);\n}\n\n.UnderlineItem[aria-current]:not([aria-current='false'])::after,\n.UnderlineItem[aria-selected='true']::after {\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--underlineNav-borderColor-active, var(--color-primer-border-active, #fd8c73));\n\n @media (forced-colors: active) {\n /* Support for Window Force Color Mode https://learn.microsoft.com/en-us/fluent-ui/web-components/design-system/high-contrast */\n background-color: LinkText;\n }\n}\n\n.LoadingCounter {\n display: inline-block;\n width: 1.5rem;\n height: 1rem;\n /* 16px */\n background-color: var(--bgColor-neutral-muted);\n border-color: var(--borderColor-default);\n /* stylelint-disable-next-line primer/borders */\n border-radius: 20px;\n animation: loadingCounterKeyFrames 1.2s ease-in-out infinite alternate;\n}\n\n@keyframes loadingCounterKeyFrames {\n from {\n opacity: 1;\n }\n\n to {\n opacity: 0.2;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './UnderlineTabbedInterface-
|
|
1
|
+
import './UnderlineTabbedInterface-20c3ba3d.css';
|
|
2
2
|
|
|
3
3
|
var classes = {"UnderlineWrapper":"prc-components-UnderlineWrapper-eT-Yj","UnderlineItemList":"prc-components-UnderlineItemList-xKlKC","UnderlineItem":"prc-components-UnderlineItem-7fP-n","LoadingCounter":"prc-components-LoadingCounter-dBuLy","loadingCounterKeyFrames":"prc-components-loadingCounterKeyFrames-8tMlf"};
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Announce.d.ts","sourceRoot":"","sources":["../../src/live-region/Announce.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAEjE,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,IAAI,gBAAgB,CACxE,EAAE,EACF,KAAK,EACL;IACE;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAA;CACpC,CACF,CAAA;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Announce.d.ts","sourceRoot":"","sources":["../../src/live-region/Announce.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAEjE,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,IAAI,gBAAgB,CACxE,EAAE,EACF,KAAK,EACL;IACE;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAA;CACpC,CACF,CAAA;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,qBAgGtF"}
|
|
@@ -66,13 +66,6 @@ function Announce(props) {
|
|
|
66
66
|
if (hidden) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
const textContent = getTextContent(element);
|
|
70
|
-
if (!textContent) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (textContent === previousAnnouncementText) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
69
|
const style = window.getComputedStyle(element);
|
|
77
70
|
if (style.display === "none") {
|
|
78
71
|
return;
|
|
@@ -80,6 +73,10 @@ function Announce(props) {
|
|
|
80
73
|
if (style.visibility === "hidden") {
|
|
81
74
|
return;
|
|
82
75
|
}
|
|
76
|
+
const textContent = getTextContent(element);
|
|
77
|
+
if (textContent === previousAnnouncementText) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
83
80
|
(_savedAnnouncement$cu = savedAnnouncement.current) === null || _savedAnnouncement$cu === void 0 ? void 0 : _savedAnnouncement$cu.cancel();
|
|
84
81
|
savedAnnouncement.current = announceFromElement(element, politeness === "assertive" ? {
|
|
85
82
|
politeness
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indicate whether current execution environment can access the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
7
|
+
const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
8
|
+
|
|
9
|
+
export { canUseDOM };
|