@primer/react 0.0.0-20260223212355 → 0.0.0-20260223214708
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 +9 -3
- package/dist/ActionList/Description.d.ts.map +1 -1
- package/dist/ActionList/Description.js +40 -93
- package/dist/ActionList/Item.d.ts.map +1 -1
- package/dist/ActionList/Item.js +52 -98
- package/dist/ActionList/shared.d.ts +0 -1
- package/dist/ActionList/shared.d.ts.map +1 -1
- package/dist/Overlay/Overlay-15519c09.css +2 -0
- package/dist/Overlay/Overlay-15519c09.css.map +1 -0
- package/dist/Overlay/Overlay.module.css.js +1 -1
- package/dist/PageLayout/{PageLayout-06f4c069.css → PageLayout-3444a142.css} +1 -1
- package/dist/PageLayout/PageLayout-3444a142.css.map +1 -0
- package/dist/PageLayout/PageLayout.module.css.js +2 -2
- package/dist/PageLayout/usePaneWidth.d.ts +4 -5
- package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
- package/dist/PageLayout/usePaneWidth.js +13 -13
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +82 -32
- package/dist/TooltipV2/Tooltip.d.ts +0 -11
- package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
- package/dist/TooltipV2/Tooltip.js +103 -116
- package/dist/utils/environment.js +9 -0
- package/generated/components.json +3 -3
- package/package.json +2 -2
- package/dist/Overlay/Overlay-43cda449.css +0 -2
- package/dist/Overlay/Overlay-43cda449.css.map +0 -1
- package/dist/PageLayout/PageLayout-06f4c069.css.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaneWidth.d.ts","sourceRoot":"","sources":["../../src/PageLayout/usePaneWidth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"usePaneWidth.d.ts","sourceRoot":"","sources":["../../src/PageLayout/usePaneWidth.ts"],"names":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
2
2
|
import React, { startTransition } from 'react';
|
|
3
|
+
import { canUseDOM } from '../utils/environment.js';
|
|
3
4
|
import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
|
|
4
5
|
import classes from './PageLayout.module.css.js';
|
|
5
6
|
|
|
@@ -27,6 +28,9 @@ const DEFAULT_MAX_WIDTH_DIFF = Number(classes.paneMaxWidthDiffDefault);
|
|
|
27
28
|
*/
|
|
28
29
|
const DEFAULT_SIDEBAR_MAX_WIDTH_DIFF = Number(classes.sidebarMaxWidthDiffDefault);
|
|
29
30
|
|
|
31
|
+
// Value for --pane-max-width-diff at/above the wide breakpoint.
|
|
32
|
+
const WIDE_MAX_WIDTH_DIFF = Number(classes.paneMaxWidthDiffWide);
|
|
33
|
+
|
|
30
34
|
// --pane-max-width-diff changes at this breakpoint in PageLayout.module.css.
|
|
31
35
|
const DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT = Number(classes.paneMaxWidthDiffBreakpoint);
|
|
32
36
|
/**
|
|
@@ -67,17 +71,13 @@ const getDefaultPaneWidth = w => {
|
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* Note: This calls getComputedStyle which forces layout - cache the result when possible.
|
|
74
|
+
* Derives the --pane-max-width-diff value from viewport width alone.
|
|
75
|
+
* Avoids the expensive getComputedStyle call that forces a synchronous layout recalc.
|
|
76
|
+
* The CSS only defines two breakpoint-dependent values, so a simple width check is equivalent.
|
|
74
77
|
*/
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!paneElement) return defaultValue;
|
|
79
|
-
const value = parseInt(getComputedStyle(paneElement).getPropertyValue(cssVar), 10);
|
|
80
|
-
return value > 0 ? value : defaultValue;
|
|
78
|
+
function getMaxWidthDiffFromViewport() {
|
|
79
|
+
if (!canUseDOM) return DEFAULT_MAX_WIDTH_DIFF;
|
|
80
|
+
return window.innerWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT ? WIDE_MAX_WIDTH_DIFF : DEFAULT_MAX_WIDTH_DIFF;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// Helper to update ARIA slider attributes via direct DOM manipulation
|
|
@@ -321,7 +321,7 @@ function usePaneWidth(t0) {
|
|
|
321
321
|
const crossedBreakpoint = lastViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT || lastViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT;
|
|
322
322
|
lastViewportWidth = currentViewportWidth;
|
|
323
323
|
if (crossedBreakpoint) {
|
|
324
|
-
maxWidthDiffRef.current =
|
|
324
|
+
maxWidthDiffRef.current = getMaxWidthDiffFromViewport();
|
|
325
325
|
}
|
|
326
326
|
const actualMax = getMaxPaneWidthRef.current();
|
|
327
327
|
(_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 ? void 0 : _paneRef$current.style.setProperty("--pane-max-width", `${actualMax}px`);
|
|
@@ -342,7 +342,7 @@ function usePaneWidth(t0) {
|
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
};
|
|
345
|
-
maxWidthDiffRef.current =
|
|
345
|
+
maxWidthDiffRef.current = getMaxWidthDiffFromViewport();
|
|
346
346
|
const initialMax = getMaxPaneWidthRef.current();
|
|
347
347
|
setMaxPaneWidth(initialMax);
|
|
348
348
|
(_paneRef$current3 = paneRef.current) === null || _paneRef$current3 === void 0 ? void 0 : _paneRef$current3.style.setProperty("--pane-max-width", `${initialMax}px`);
|
|
@@ -453,4 +453,4 @@ function usePaneWidth(t0) {
|
|
|
453
453
|
return t14;
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
export { ARROW_KEY_STEP, DEFAULT_MAX_WIDTH_DIFF, DEFAULT_SIDEBAR_MAX_WIDTH_DIFF, SSR_DEFAULT_MAX_WIDTH, defaultPaneWidth, getDefaultPaneWidth,
|
|
456
|
+
export { ARROW_KEY_STEP, DEFAULT_MAX_WIDTH_DIFF, DEFAULT_SIDEBAR_MAX_WIDTH_DIFF, SSR_DEFAULT_MAX_WIDTH, defaultPaneWidth, getDefaultPaneWidth, getMaxWidthDiffFromViewport, isCustomWidthOptions, isPaneWidth, updateAriaValues, usePaneWidth };
|
|
@@ -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,EAA+E,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AACnH,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;AAiCjE,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,CAA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wide: false
|
|
134
134
|
}, false);
|
|
135
135
|
const [selectedOnSort, setSelectedOnSort] = useState([]);
|
|
136
|
-
const [prevItems, setPrevItems] = useState([]);
|
|
137
|
-
const [prevOpen, setPrevOpen] = useState(open);
|
|
138
136
|
const initialHeightRef = useRef(0);
|
|
139
137
|
const initialScaleRef = useRef(1);
|
|
140
138
|
const noticeRef = useRef(null);
|
|
@@ -206,6 +204,19 @@ function Panel({
|
|
|
206
204
|
resetSort();
|
|
207
205
|
}
|
|
208
206
|
}, [loadingManagedInternally, externalOnFilterChange, setInternalFilterValue, dataLoadedOnce, safeSetTimeout, safeClearTimeout, items.length, resetSort]);
|
|
207
|
+
|
|
208
|
+
// Pre-compute a Set of item IDs in the current filtered view for O(1) lookups
|
|
209
|
+
const itemsInViewSet = useMemo(() => {
|
|
210
|
+
const set = new Set();
|
|
211
|
+
for (const item of items) {
|
|
212
|
+
if (item.id !== undefined) {
|
|
213
|
+
set.add(item.id);
|
|
214
|
+
} else {
|
|
215
|
+
set.add(item);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return set;
|
|
219
|
+
}, [items]);
|
|
209
220
|
const handleSelectAllChange = useCallback(checked => {
|
|
210
221
|
// Exit early if not in multi-select mode
|
|
211
222
|
if (!isMultiSelectVariant(selected)) {
|
|
@@ -213,13 +224,20 @@ function Panel({
|
|
|
213
224
|
}
|
|
214
225
|
const multiSelectOnChange = onSelectedChange;
|
|
215
226
|
const selectedArray = selected;
|
|
216
|
-
|
|
227
|
+
|
|
228
|
+
// Use Set for O(1) lookup instead of O(n) items.some()
|
|
229
|
+
const selectedItemsNotInFilteredView = selectedArray.filter(selectedItem => {
|
|
230
|
+
if (selectedItem.id !== undefined) {
|
|
231
|
+
return !itemsInViewSet.has(selectedItem.id);
|
|
232
|
+
}
|
|
233
|
+
return !itemsInViewSet.has(selectedItem);
|
|
234
|
+
});
|
|
217
235
|
if (checked) {
|
|
218
236
|
multiSelectOnChange([...selectedItemsNotInFilteredView, ...items]);
|
|
219
237
|
} else {
|
|
220
238
|
multiSelectOnChange(selectedItemsNotInFilteredView);
|
|
221
239
|
}
|
|
222
|
-
}, [items, onSelectedChange, selected]);
|
|
240
|
+
}, [items, itemsInViewSet, onSelectedChange, selected]);
|
|
223
241
|
|
|
224
242
|
// disable body scroll when the panel is open on narrow screens
|
|
225
243
|
useEffect(() => {
|
|
@@ -385,10 +403,29 @@ function Panel({
|
|
|
385
403
|
});
|
|
386
404
|
};
|
|
387
405
|
}, [placeholder, renderAnchor, selected]);
|
|
406
|
+
|
|
407
|
+
// Pre-compute a Set of selected item IDs/references for O(1) lookups
|
|
408
|
+
// This optimizes isItemCurrentlySelected from O(m) to O(1) per call
|
|
409
|
+
const selectedItemsSet = useMemo(() => {
|
|
410
|
+
const set = new Set();
|
|
411
|
+
if (isMultiSelectVariant(selected)) {
|
|
412
|
+
for (const item of selected) {
|
|
413
|
+
if (item.id !== undefined) {
|
|
414
|
+
set.add(item.id);
|
|
415
|
+
} else {
|
|
416
|
+
set.add(item);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return set;
|
|
421
|
+
}, [selected]);
|
|
388
422
|
const isItemCurrentlySelected = useCallback(item => {
|
|
389
|
-
// For multi-select,
|
|
423
|
+
// For multi-select, use the pre-computed Set for O(1) lookup
|
|
390
424
|
if (isMultiSelectVariant(selected)) {
|
|
391
|
-
|
|
425
|
+
if (item.id !== undefined) {
|
|
426
|
+
return selectedItemsSet.has(item.id);
|
|
427
|
+
}
|
|
428
|
+
return selectedItemsSet.has(item);
|
|
392
429
|
}
|
|
393
430
|
|
|
394
431
|
// For single-select modal, there is an intermediate state when the user has selected
|
|
@@ -399,8 +436,24 @@ function Panel({
|
|
|
399
436
|
|
|
400
437
|
// For single-select anchored, we just need to check if the item is the selected item
|
|
401
438
|
return (selected === null || selected === void 0 ? void 0 : selected.id) !== undefined ? selected.id === item.id : selected === item;
|
|
402
|
-
}, [selected, intermediateSelected, isSingleSelectModal]);
|
|
439
|
+
}, [selected, selectedItemsSet, intermediateSelected, isSingleSelectModal]);
|
|
403
440
|
const itemsToRender = useMemo(() => {
|
|
441
|
+
// Pre-compute a Set of selected item IDs/references for O(1) lookups during sorting
|
|
442
|
+
// This avoids O(m * k) work per comparison in the sort function
|
|
443
|
+
const selectedOnSortSet = new Set();
|
|
444
|
+
for (const item of selectedOnSort) {
|
|
445
|
+
if (item.id !== undefined) {
|
|
446
|
+
selectedOnSortSet.add(item.id);
|
|
447
|
+
} else {
|
|
448
|
+
selectedOnSortSet.add(item);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const isSelectedForSort = item => {
|
|
452
|
+
if (item.id !== undefined) {
|
|
453
|
+
return selectedOnSortSet.has(item.id);
|
|
454
|
+
}
|
|
455
|
+
return selectedOnSortSet.has(item);
|
|
456
|
+
};
|
|
404
457
|
return items.map(item => {
|
|
405
458
|
return {
|
|
406
459
|
...item,
|
|
@@ -437,42 +490,39 @@ function Panel({
|
|
|
437
490
|
};
|
|
438
491
|
}).sort((itemA, itemB) => {
|
|
439
492
|
if (shouldOrderSelectedFirst) {
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
if (key === 'selected') {
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
return itemA[key] === value;
|
|
446
|
-
}));
|
|
447
|
-
|
|
448
|
-
// itemB is selected (for sorting purposes) if an object in selectedOnSort matches every property of itemA, except for the selected property
|
|
449
|
-
const itemBSelected = selectedOnSort.some(item => Object.entries(item).every(([key, value]) => {
|
|
450
|
-
if (key === 'selected') {
|
|
451
|
-
return true;
|
|
452
|
-
}
|
|
453
|
-
return itemB[key] === value;
|
|
454
|
-
}));
|
|
493
|
+
const itemASelected = isSelectedForSort(itemA);
|
|
494
|
+
const itemBSelected = isSelectedForSort(itemB);
|
|
455
495
|
|
|
456
496
|
// order selected items first
|
|
457
|
-
if (itemASelected
|
|
497
|
+
if (itemASelected && !itemBSelected) {
|
|
458
498
|
return -1;
|
|
459
|
-
} else if (itemASelected
|
|
499
|
+
} else if (!itemASelected && itemBSelected) {
|
|
460
500
|
return 1;
|
|
461
501
|
}
|
|
462
502
|
}
|
|
463
503
|
return 0;
|
|
464
504
|
});
|
|
465
505
|
}, [onClose, onSelectedChange, items, selected, isItemCurrentlySelected, isSingleSelectModal, intermediateSelected, shouldOrderSelectedFirst, selectedOnSort]);
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
506
|
+
|
|
507
|
+
// Track previous items and reset sort when items first load
|
|
508
|
+
const prevItemsRef = useRef(items);
|
|
509
|
+
useEffect(() => {
|
|
510
|
+
if (prevItemsRef.current !== items) {
|
|
511
|
+
if (prevItemsRef.current.length === 0 && items.length > 0) {
|
|
512
|
+
resetSort();
|
|
513
|
+
}
|
|
514
|
+
prevItemsRef.current = items;
|
|
515
|
+
}
|
|
516
|
+
}, [items, resetSort]);
|
|
517
|
+
|
|
518
|
+
// Reset sort when panel opens
|
|
519
|
+
const prevOpenRef = useRef(open);
|
|
520
|
+
useEffect(() => {
|
|
521
|
+
if (prevOpenRef.current !== open) {
|
|
469
522
|
resetSort();
|
|
523
|
+
prevOpenRef.current = open;
|
|
470
524
|
}
|
|
471
|
-
}
|
|
472
|
-
if (open !== prevOpen) {
|
|
473
|
-
setPrevOpen(open);
|
|
474
|
-
resetSort();
|
|
475
|
-
}
|
|
525
|
+
}, [open, resetSort]);
|
|
476
526
|
const focusTrapSettings = {
|
|
477
527
|
initialFocusRef: inputRef || undefined
|
|
478
528
|
};
|
|
@@ -24,17 +24,6 @@ export type TooltipProps = React.PropsWithChildren<{
|
|
|
24
24
|
* @default false
|
|
25
25
|
*/
|
|
26
26
|
_privateDisableTooltip?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Private API for use internally only. Renders the tooltip popover element before
|
|
29
|
-
* the trigger in the DOM instead of after it.
|
|
30
|
-
*
|
|
31
|
-
* This is used by ActionList items to ensure the tooltip's popover `<span>` does not
|
|
32
|
-
* sit between the ActionListContent and its adjacent SubGroup sibling, which would
|
|
33
|
-
* break CSS adjacent sibling (`+`) selectors used for expand/collapse.
|
|
34
|
-
*
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
_privateRenderBeforeTrigger?: boolean;
|
|
38
27
|
}> & React.HTMLAttributes<HTMLElement>;
|
|
39
28
|
export declare const TooltipContext: React.Context<{
|
|
40
29
|
tooltipId?: string;
|
|
@@ -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;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,CAAA;IAC5C;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACnC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,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,CAAA;IAC5C;;;;;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;AAE3E,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAC7C,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CACvE,GACC,UAgRD,CAAA"}
|
|
@@ -86,7 +86,6 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
86
86
|
keybindingHint,
|
|
87
87
|
delay = 'short',
|
|
88
88
|
_privateDisableTooltip = false,
|
|
89
|
-
_privateRenderBeforeTrigger = false,
|
|
90
89
|
...rest
|
|
91
90
|
}, forwardedRef) => {
|
|
92
91
|
const tooltipId = useId(id);
|
|
@@ -197,124 +196,112 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
197
196
|
}, [isPopoverOpen]);
|
|
198
197
|
const isMacOS = useIsMacOS();
|
|
199
198
|
const hasAriaLabel = 'aria-label' in rest;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
,
|
|
216
|
-
id: hasAriaLabel || !keybindingHint ? tooltipId : undefined,
|
|
217
|
-
children: keybindingHint ? /*#__PURE__*/jsxs(Fragment, {
|
|
218
|
-
children: [/*#__PURE__*/jsxs("span", {
|
|
219
|
-
id: hasAriaLabel ? undefined : tooltipId,
|
|
220
|
-
children: [text, /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
221
|
-
children: ["(", getAccessibleKeybindingHintString(keybindingHint, isMacOS), ")"]
|
|
222
|
-
})]
|
|
223
|
-
}), /*#__PURE__*/jsx("span", {
|
|
224
|
-
className: clsx(classes.KeybindingHintContainer, text && classes.HasTextBefore),
|
|
225
|
-
"aria-hidden": true,
|
|
226
|
-
children: /*#__PURE__*/jsx(KeybindingHint, {
|
|
227
|
-
keys: keybindingHint,
|
|
228
|
-
format: "condensed",
|
|
229
|
-
variant: "onEmphasis",
|
|
230
|
-
size: "small"
|
|
231
|
-
})
|
|
232
|
-
})]
|
|
233
|
-
}) : text
|
|
234
|
-
});
|
|
235
|
-
const triggerElement = /*#__PURE__*/React.isValidElement(child) &&
|
|
236
|
-
/*#__PURE__*/
|
|
237
|
-
// eslint-disable-next-line react-hooks/refs
|
|
238
|
-
React.cloneElement(child, {
|
|
239
|
-
// @ts-expect-error it needs a non nullable ref
|
|
240
|
-
ref: triggerRef,
|
|
241
|
-
// If it is a type description, we use tooltip to describe the trigger
|
|
242
|
-
'aria-describedby': (() => {
|
|
243
|
-
// If tooltip is not a description type, keep the original aria-describedby
|
|
244
|
-
if (type !== 'description') {
|
|
245
|
-
return child.props['aria-describedby'];
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// When the tooltip is disabled, don't add its ID to aria-describedby
|
|
249
|
-
// to avoid an empty string polluting the accessible description
|
|
250
|
-
if (_privateDisableTooltip) {
|
|
251
|
-
return child.props['aria-describedby'];
|
|
252
|
-
}
|
|
199
|
+
return /*#__PURE__*/jsx(TooltipContext.Provider, {
|
|
200
|
+
value: value,
|
|
201
|
+
children: /*#__PURE__*/jsxs(Fragment, {
|
|
202
|
+
children: [/*#__PURE__*/React.isValidElement(child) &&
|
|
203
|
+
/*#__PURE__*/
|
|
204
|
+
// eslint-disable-next-line react-hooks/refs
|
|
205
|
+
React.cloneElement(child, {
|
|
206
|
+
// @ts-expect-error it needs a non nullable ref
|
|
207
|
+
ref: triggerRef,
|
|
208
|
+
// If it is a type description, we use tooltip to describe the trigger
|
|
209
|
+
'aria-describedby': (() => {
|
|
210
|
+
// If tooltip is not a description type, keep the original aria-describedby
|
|
211
|
+
if (type !== 'description') {
|
|
212
|
+
return child.props['aria-describedby'];
|
|
213
|
+
}
|
|
253
214
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
215
|
+
// If tooltip is a description type, append our tooltipId
|
|
216
|
+
const existingDescribedBy = child.props['aria-describedby'];
|
|
217
|
+
if (existingDescribedBy) {
|
|
218
|
+
return `${existingDescribedBy} ${tooltipId}`;
|
|
219
|
+
}
|
|
259
220
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
221
|
+
// If no existing aria-describedby, use our tooltipId
|
|
222
|
+
return tooltipId;
|
|
223
|
+
})(),
|
|
224
|
+
// If it is a label type, we use tooltip to label the trigger
|
|
225
|
+
'aria-labelledby': type === 'label' ? tooltipId : child.props['aria-labelledby'],
|
|
226
|
+
onBlur: event => {
|
|
227
|
+
var _child$props$onBlur, _child$props;
|
|
228
|
+
closeTooltip();
|
|
229
|
+
(_child$props$onBlur = (_child$props = child.props).onBlur) === null || _child$props$onBlur === void 0 ? void 0 : _child$props$onBlur.call(_child$props, event);
|
|
230
|
+
},
|
|
231
|
+
onTouchEnd: event => {
|
|
232
|
+
var _child$props$onTouchE, _child$props2;
|
|
233
|
+
(_child$props$onTouchE = (_child$props2 = child.props).onTouchEnd) === null || _child$props$onTouchE === void 0 ? void 0 : _child$props$onTouchE.call(_child$props2, event);
|
|
273
234
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
235
|
+
// Hide tooltips on tap to essentially disable them on touch devices;
|
|
236
|
+
// this still allows viewing the tooltip on tap-and-hold
|
|
237
|
+
safeSetTimeout(() => closeTooltip(), 10);
|
|
238
|
+
},
|
|
239
|
+
onFocus: event => {
|
|
240
|
+
var _child$props$onFocus, _child$props3;
|
|
241
|
+
// only show tooltip on :focus-visible, not on :focus
|
|
242
|
+
try {
|
|
243
|
+
if (!event.target.matches(':focus-visible')) return;
|
|
244
|
+
} catch (_error) {
|
|
245
|
+
// jsdom (jest) does not support `:focus-visible` yet and would throw an error
|
|
246
|
+
// https://github.com/jsdom/jsdom/issues/3426
|
|
247
|
+
}
|
|
248
|
+
openTooltip();
|
|
249
|
+
(_child$props$onFocus = (_child$props3 = child.props).onFocus) === null || _child$props$onFocus === void 0 ? void 0 : _child$props$onFocus.call(_child$props3, event);
|
|
250
|
+
},
|
|
251
|
+
onMouseOverCapture: event => {
|
|
252
|
+
const delayTime = delayTimeMap[delay] || 50;
|
|
253
|
+
// We use a `capture` event to ensure this is called first before
|
|
254
|
+
// events that might cancel the opening timeout (like `onTouchEnd`)
|
|
255
|
+
// show tooltip after mouse has been hovering for the specified delay time
|
|
256
|
+
// (prevent showing tooltip when mouse is just passing through)
|
|
257
|
+
openTimeoutRef.current = safeSetTimeout(() => {
|
|
258
|
+
var _child$props$onMouseE, _child$props4;
|
|
259
|
+
// if the mouse is already moved out, do not show the tooltip
|
|
260
|
+
if (!openTimeoutRef.current) return;
|
|
261
|
+
openTooltip();
|
|
262
|
+
(_child$props$onMouseE = (_child$props4 = child.props).onMouseEnter) === null || _child$props$onMouseE === void 0 ? void 0 : _child$props$onMouseE.call(_child$props4, event);
|
|
263
|
+
}, delayTime);
|
|
264
|
+
},
|
|
265
|
+
onMouseLeave: event => {
|
|
266
|
+
var _child$props$onMouseL, _child$props5;
|
|
267
|
+
closeTooltip();
|
|
268
|
+
(_child$props$onMouseL = (_child$props5 = child.props).onMouseLeave) === null || _child$props$onMouseL === void 0 ? void 0 : _child$props$onMouseL.call(_child$props5, event);
|
|
269
|
+
}
|
|
270
|
+
}), /*#__PURE__*/jsx("span", {
|
|
271
|
+
className: clsx(className, classes.Tooltip),
|
|
272
|
+
ref: tooltipElRef,
|
|
273
|
+
"data-direction": calculatedDirection,
|
|
274
|
+
...rest,
|
|
275
|
+
// Only need tooltip role if the tooltip is a description for supplementary information
|
|
276
|
+
role: type === 'description' ? 'tooltip' : undefined
|
|
277
|
+
// stop AT from announcing the tooltip twice: when it is a label type it will be announced with "aria-labelledby",when it is a description type it will be announced with "aria-describedby"
|
|
278
|
+
,
|
|
279
|
+
"aria-hidden": true
|
|
280
|
+
// mouse leave and enter on the tooltip itself is needed to keep the tooltip open when the mouse is over the tooltip
|
|
281
|
+
,
|
|
282
|
+
onMouseEnter: openTooltip,
|
|
283
|
+
onMouseLeave: closeTooltip
|
|
284
|
+
// If there is an aria-label prop, always assign the ID to the parent so the accessible label can be overridden
|
|
285
|
+
,
|
|
286
|
+
id: hasAriaLabel || !keybindingHint ? tooltipId : undefined,
|
|
287
|
+
children: keybindingHint ? /*#__PURE__*/jsxs(Fragment, {
|
|
288
|
+
children: [/*#__PURE__*/jsxs("span", {
|
|
289
|
+
id: hasAriaLabel ? undefined : tooltipId,
|
|
290
|
+
children: [text, /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
291
|
+
children: ["(", getAccessibleKeybindingHintString(keybindingHint, isMacOS), ")"]
|
|
292
|
+
})]
|
|
293
|
+
}), /*#__PURE__*/jsx("span", {
|
|
294
|
+
className: clsx(classes.KeybindingHintContainer, text && classes.HasTextBefore),
|
|
295
|
+
"aria-hidden": true,
|
|
296
|
+
children: /*#__PURE__*/jsx(KeybindingHint, {
|
|
297
|
+
keys: keybindingHint,
|
|
298
|
+
format: "condensed",
|
|
299
|
+
variant: "onEmphasis",
|
|
300
|
+
size: "small"
|
|
301
|
+
})
|
|
302
|
+
})]
|
|
303
|
+
}) : text
|
|
304
|
+
})]
|
|
318
305
|
})
|
|
319
306
|
});
|
|
320
307
|
});
|
|
@@ -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 };
|
|
@@ -1759,7 +1759,7 @@
|
|
|
1759
1759
|
},
|
|
1760
1760
|
{
|
|
1761
1761
|
"id": "components-button-features--inactive",
|
|
1762
|
-
"code": "() => (\n <div\n style={{\n display: 'flex',\n flexDirection: 'row',\n gap: '1rem',\n }}\n >\n <Button inactive
|
|
1762
|
+
"code": "() => (\n <div\n style={{\n display: 'flex',\n flexDirection: 'row',\n gap: '1rem',\n }}\n >\n <VisuallyHidden id=\"inactive-state\">Inactive</VisuallyHidden>\n <Button inactive aria-describedby=\"inactive-state\">\n Default\n </Button>\n <Button variant=\"primary\" inactive aria-describedby=\"inactive-state\">\n Primary\n </Button>\n <Button variant=\"danger\" inactive aria-describedby=\"inactive-state\">\n Danger\n </Button>\n <Button variant=\"invisible\" inactive aria-describedby=\"inactive-state\">\n Invisible\n </Button>\n </div>\n)"
|
|
1763
1763
|
},
|
|
1764
1764
|
{
|
|
1765
1765
|
"id": "components-button-features--small",
|
|
@@ -3244,8 +3244,8 @@
|
|
|
3244
3244
|
"code": "() => {\n const [tokens, setTokens] = useState([...mockTokens])\n const onTokenRemove = (tokenId: string | number) => {\n setTokens(\n tokens.filter((token: { id: string | number }) => token.id !== tokenId),\n )\n }\n return (\n <div className={classes.GridContainer}>\n <FormControl>\n <FormControl.Label id=\"form-label\">\n TextInputWithTokens\n </FormControl.Label>\n <TextInputWithTokens onTokenRemove={onTokenRemove} tokens={tokens} />\n </FormControl>\n <FormControl>\n <FormControl.Label id=\"autocomplete-label\">\n Autocomplete\n </FormControl.Label>\n <Autocomplete>\n <Autocomplete.Input block />\n <Autocomplete.Overlay>\n <Autocomplete.Menu\n aria-labelledby=\"autocomplete-label\"\n items={[\n {\n text: 'css',\n id: '0',\n },\n {\n text: 'css-in-js',\n id: '1',\n },\n {\n text: 'styled-system',\n id: '2',\n },\n {\n text: 'javascript',\n id: '3',\n },\n {\n text: 'typescript',\n id: '4',\n },\n {\n text: 'react',\n id: '5',\n },\n {\n text: 'design-systems',\n id: '6',\n },\n ]}\n selectedItemIds={[]}\n />\n </Autocomplete.Overlay>\n </Autocomplete>\n </FormControl>\n <FormControl>\n <FormControl.Label>Select</FormControl.Label>\n <Select>\n <Select.Option value=\"figma\">Figma</Select.Option>\n <Select.Option value=\"css\">Primer CSS</Select.Option>\n <Select.Option value=\"prc\">Primer React components</Select.Option>\n <Select.Option value=\"pvc\">Primer ViewComponents</Select.Option>\n </Select>\n </FormControl>\n <FormControl>\n <FormControl.Label>Textarea</FormControl.Label>\n <Textarea />\n </FormControl>\n </div>\n )\n}"
|
|
3245
3245
|
},
|
|
3246
3246
|
{
|
|
3247
|
-
"id": "components-formcontrol-features--
|
|
3248
|
-
"code": "() => {\n const [value, setValue] = React.useState('mona lisa')\n const [validationResult, setValidationResult] = React.useState('')\n const doesValueContainSpaces = (inputValue: string) => /\\s/g.test(inputValue)\n const handleInputChange = (e: {\n currentTarget: {\n value: React.SetStateAction<string>\n }\n }) => {\n setValue(e.currentTarget.value)\n }\n React.useEffect(() => {\n if (doesValueContainSpaces(value)) {\n setValidationResult('noSpaces')\n } else if (value) {\n setValidationResult('validName')\n }\n }, [value])\n return (\n <div className={classes.GridContainer}>\n <FormControl>\n <FormControl.Label htmlFor=\"custom-input\">\n GitHub handle\n </FormControl.Label>\n <CustomTextInput\n id=\"custom-input\"\n aria-describedby=\"custom-input-
|
|
3247
|
+
"id": "components-formcontrol-features--with-custom-input",
|
|
3248
|
+
"code": "() => {\n const [value, setValue] = React.useState('mona lisa')\n const [validationResult, setValidationResult] = React.useState('')\n const doesValueContainSpaces = (inputValue: string) => /\\s/g.test(inputValue)\n const handleInputChange = (e: {\n currentTarget: {\n value: React.SetStateAction<string>\n }\n }) => {\n setValue(e.currentTarget.value)\n }\n React.useEffect(() => {\n if (doesValueContainSpaces(value)) {\n setValidationResult('noSpaces')\n } else if (value) {\n setValidationResult('validName')\n }\n }, [value])\n return (\n <div className={classes.GridContainer}>\n <FormControl>\n <FormControl.Label htmlFor=\"custom-input\">\n GitHub handle\n </FormControl.Label>\n <CustomTextInput\n id=\"custom-input\"\n aria-describedby=\"custom-input-validation custom-input-caption\"\n aria-invalid={validationResult === 'noSpaces'}\n onChange={handleInputChange}\n />\n {validationResult === 'noSpaces' && (\n <FormControl.Validation id=\"custom-input-validation\" variant=\"error\">\n GitHub handles cannot contain spaces\n </FormControl.Validation>\n )}\n {validationResult === 'validName' && (\n <FormControl.Validation\n id=\"custom-input-validation\"\n variant=\"success\"\n >\n Valid name\n </FormControl.Validation>\n )}\n <FormControl.Caption id=\"custom-input-caption\">\n With or without "@". For example "monalisa" or\n "@monalisa"\n </FormControl.Caption>\n </FormControl>\n\n <CheckboxGroup>\n <CheckboxGroup.Label>Checkboxes</CheckboxGroup.Label>\n <FormControl layout=\"horizontal\">\n <CustomCheckboxInput\n id=\"custom-checkbox-one\"\n aria-describedby=\"custom-checkbox-one-caption\"\n value=\"checkOne\"\n />\n <FormControl.Label htmlFor=\"custom-checkbox-one\">\n Checkbox one\n </FormControl.Label>\n <FormControl.Caption id=\"custom-checkbox-one-caption\">\n Hint text for checkbox one\n </FormControl.Caption>\n </FormControl>\n <FormControl layout=\"horizontal\">\n <CustomCheckboxInput\n id=\"custom-checkbox-two\"\n aria-describedby=\"custom-checkbox-two-caption\"\n value=\"checkTwo\"\n />\n <FormControl.Label htmlFor=\"custom-checkbox-two\">\n Checkbox two\n </FormControl.Label>\n <FormControl.Caption id=\"custom-checkbox-two-caption\">\n Hint text for checkbox two\n </FormControl.Caption>\n </FormControl>\n </CheckboxGroup>\n </div>\n )\n}"
|
|
3249
3249
|
},
|
|
3250
3250
|
{
|
|
3251
3251
|
"id": "components-formcontrol-features--with-checkbox-and-radio-inputs",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-20260223214708",
|
|
5
5
|
"description": "An implementation of GitHub's Primer Design System using React",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"react-is": "18.3.1",
|
|
171
171
|
"recast": "0.23.7",
|
|
172
172
|
"rimraf": "5.0.5",
|
|
173
|
-
"rollup": "4.
|
|
173
|
+
"rollup": "4.59.0",
|
|
174
174
|
"rollup-plugin-import-css": "^0.0.0",
|
|
175
175
|
"storybook": "^10.1.11",
|
|
176
176
|
"terser": "5.36.0",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
@keyframes prc-Overlay-overlay-appear-JpFey{0%{opacity:0}to{opacity:1}}.prc-Overlay-Overlay-jfs-T{background-color:var(--overlay-bgColor,var(--color-canvas-overlay));border-radius:var(--borderRadius-large,.75rem);bottom:var(--bottom,auto);box-shadow:var(--shadow-floating-small,var(--color-overlay-shadow));height:auto;left:var(--left,auto);max-height:100vh;max-width:calc(100vw - 2rem);min-width:192px;overflow:hidden;position:absolute;right:var(--right,auto);top:var(--top,auto);width:auto}.prc-Overlay-Overlay-jfs-T:focus{outline:none}@media (forced-colors:active){.prc-Overlay-Overlay-jfs-T{outline:1px solid transparent}}.prc-Overlay-Overlay-jfs-T:where([data-reflow-container=true]){max-width:calc(100vw - 2rem)}.prc-Overlay-Overlay-jfs-T:where([data-overflow-auto]){overflow:auto}.prc-Overlay-Overlay-jfs-T:where([data-overflow-hidden]){overflow:hidden}.prc-Overlay-Overlay-jfs-T:where([data-overflow-scroll]){overflow:scroll}.prc-Overlay-Overlay-jfs-T:where([data-overflow-visible]){overflow:visible}.prc-Overlay-Overlay-jfs-T:where([data-height-xsmall]){height:192px}.prc-Overlay-Overlay-jfs-T:where([data-height-small]){height:256px}.prc-Overlay-Overlay-jfs-T:where([data-height-medium]){height:320px}.prc-Overlay-Overlay-jfs-T:where([data-height-large]){height:432px}.prc-Overlay-Overlay-jfs-T:where([data-height-xlarge]){height:600px}.prc-Overlay-Overlay-jfs-T:where([data-height-auto]),.prc-Overlay-Overlay-jfs-T:where([data-height-initial]){height:auto}.prc-Overlay-Overlay-jfs-T:where([data-height-fit-content]){height:-moz-fit-content;height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:192px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:432px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:600px}.prc-Overlay-Overlay-jfs-T:where([data-max-height-fit-content]){max-height:-moz-fit-content;max-height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-width-small]){width:256px}.prc-Overlay-Overlay-jfs-T:where([data-width-medium]){width:320px}.prc-Overlay-Overlay-jfs-T:where([data-width-large]){width:480px}.prc-Overlay-Overlay-jfs-T:where([data-width-xlarge]){width:640px}.prc-Overlay-Overlay-jfs-T:where([data-width-xxlarge]){width:960px}.prc-Overlay-Overlay-jfs-T:where([data-width-auto]){width:auto}.prc-Overlay-Overlay-jfs-T:where([data-max-width-small]){max-width:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-medium]){max-width:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-large]){max-width:480px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xlarge]){max-width:640px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xxlarge]){max-width:960px}.prc-Overlay-Overlay-jfs-T:where([data-visibility-visible]){visibility:visible}.prc-Overlay-Overlay-jfs-T:where([data-visibility-hidden]){visibility:hidden}@media screen and (max-width:calc(48rem - 0.02px)){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]){border-radius:unset;height:100vh;left:0;margin:0;max-height:none;max-width:none;position:fixed;top:0;width:100vw}}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-variant=fullscreen]){height:100dvh}}@media (prefers-reduced-motion:no-preference){.prc-Overlay-Overlay-jfs-T{animation:prc-Overlay-overlay-appear-JpFey .2s cubic-bezier(.33,1,.68,1)}}
|
|
2
|
-
/*# sourceMappingURL=Overlay-43cda449.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Overlay/Overlay.module.css.js"],"names":[],"mappings":"AAAA,4CACE,GACE,SACF,CAEA,GACE,SACF,CACF,CAEA,2BAQE,mEAAwC,CACxC,8CAAwC,CASxC,yBAA2B,CAR3B,mEAAwC,CALxC,WAAY,CASZ,qBAAuB,CARvB,gBAAiB,CAJjB,4BAA6B,CAE7B,eAAgB,CAGhB,eAAgB,CANhB,iBAAkB,CAelB,uBAAyB,CAJzB,mBAAqB,CATrB,UA8KF,CA7JE,iCACE,YACF,CAEA,8BAxBF,2BA0BI,6BAuJJ,CAtJE,CAEA,+DACE,4BACF,CAEA,uDACE,aACF,CAEA,yDACE,eACF,CAEA,yDACE,eACF,CAEA,0DACE,gBACF,CAEA,uDACE,YACF,CAEA,sDACE,YACF,CAEA,uDACE,YACF,CAEA,sDACE,YACF,CAEA,uDACE,YACF,CAEA,6GAEE,WACF,CAEA,4DACE,uBAAmB,CAAnB,kBACF,CAEA,2DACE,gBACF,CAEA,0DACE,gBACF,CAEA,2DACE,gBACF,CAEA,0DACE,gBACF,CAEA,2DACE,gBACF,CAEA,gEACE,2BAAuB,CAAvB,sBACF,CAEA,qDACE,WACF,CAEA,sDACE,WACF,CAEA,qDAEE,WACF,CAEA,sDAEE,WACF,CAEA,uDAEE,WACF,CAEA,oDACE,UACF,CAEA,yDACE,eACF,CAEA,0DACE,eACF,CAEA,yDACE,eACF,CAEA,0DACE,eACF,CAEA,2DACE,eACF,CAEA,4DACE,kBACF,CAEA,2DACE,iBACF,CAGE,mDADF,+DAUI,mBAAoB,CAHpB,YAAa,CAHb,MAAO,CAKP,QAAS,CADT,eAAgB,CAFhB,cAAe,CAJf,cAAe,CACf,KAAM,CAEN,WAOJ,CADE,CAGF,0BAEE,4DACE,aACF,CACF,CAGF,8CACE,2BACE,wEACF,CACF","file":"Overlay-43cda449.css","sourcesContent":["@keyframes overlay-appear {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.Overlay {\n position: absolute;\n max-width: calc(100vw - 2rem);\n width: auto;\n min-width: 192px;\n height: auto;\n max-height: 100vh;\n overflow: hidden;\n background-color: var(--overlay-bgColor);\n border-radius: var(--borderRadius-large);\n box-shadow: var(--shadow-floating-small);\n /* stylelint-disable-next-line primer/spacing */\n top: var(--top, auto);\n /* stylelint-disable-next-line primer/spacing */\n left: var(--left, auto);\n /* stylelint-disable-next-line primer/spacing */\n right: var(--right, auto);\n /* stylelint-disable-next-line primer/spacing */\n bottom: var(--bottom, auto);\n\n &:focus {\n outline: none;\n }\n\n @media (forced-colors: active) {\n /* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */\n outline: solid 1px transparent;\n }\n\n &:where([data-reflow-container='true']) {\n max-width: calc(100vw - 2rem);\n }\n\n &:where([data-overflow-auto]) {\n overflow: auto;\n }\n\n &:where([data-overflow-hidden]) {\n overflow: hidden;\n }\n\n &:where([data-overflow-scroll]) {\n overflow: scroll;\n }\n\n &:where([data-overflow-visible]) {\n overflow: visible;\n }\n\n &:where([data-height-xsmall]) {\n height: 192px;\n }\n\n &:where([data-height-small]) {\n height: 256px;\n }\n\n &:where([data-height-medium]) {\n height: 320px;\n }\n\n &:where([data-height-large]) {\n height: 432px;\n }\n\n &:where([data-height-xlarge]) {\n height: 600px;\n }\n\n &:where([data-height-auto]),\n &:where([data-height-initial]) {\n height: auto;\n }\n\n &:where([data-height-fit-content]) {\n height: fit-content;\n }\n\n &:where([data-max-height-xsmall]) {\n max-height: 192px;\n }\n\n &:where([data-max-height-small]) {\n max-height: 256px;\n }\n\n &:where([data-max-height-medium]) {\n max-height: 320px;\n }\n\n &:where([data-max-height-large]) {\n max-height: 432px;\n }\n\n &:where([data-max-height-xlarge]) {\n max-height: 600px;\n }\n\n &:where([data-max-height-fit-content]) {\n max-height: fit-content;\n }\n\n &:where([data-width-small]) {\n width: 256px;\n }\n\n &:where([data-width-medium]) {\n width: 320px;\n }\n\n &:where([data-width-large]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 480px;\n }\n\n &:where([data-width-xlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 640px;\n }\n\n &:where([data-width-xxlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 960px;\n }\n\n &:where([data-width-auto]) {\n width: auto;\n }\n\n &:where([data-max-width-small]) {\n max-width: 256px;\n }\n\n &:where([data-max-width-medium]) {\n max-width: 320px;\n }\n\n &:where([data-max-width-large]) {\n max-width: 480px;\n }\n\n &:where([data-max-width-xlarge]) {\n max-width: 640px;\n }\n\n &:where([data-max-width-xxlarge]) {\n max-width: 960px;\n }\n\n &:where([data-visibility-visible]) {\n visibility: visible;\n }\n\n &:where([data-visibility-hidden]) {\n visibility: hidden;\n }\n\n &:where([data-responsive='fullscreen']) {\n @media screen and (--viewportRange-narrow) {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: none;\n height: 100vh;\n max-height: none;\n margin: 0;\n border-radius: unset;\n }\n }\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n &:where([data-variant='fullscreen']) {\n height: 100dvh;\n }\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .Overlay {\n animation: overlay-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);\n }\n}\n"]}
|