@primer/react 0.0.0-20260608154601 → 0.0.0-20260608202019

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +51 -3
  2. package/dist/ActionList/ActionList-1940009e.css +2 -0
  3. package/dist/ActionList/ActionList-1940009e.css.map +1 -0
  4. package/dist/ActionList/ActionList.module.css.js +2 -2
  5. package/dist/ActionList/Item.d.ts.map +1 -1
  6. package/dist/ActionList/Item.js +125 -118
  7. package/dist/ActionList/TrailingAction.d.ts.map +1 -1
  8. package/dist/ActionList/TrailingAction.js +1 -0
  9. package/dist/ActionList/Visuals.js +6 -4
  10. package/dist/Autocomplete/AutocompleteInput.d.ts.map +1 -1
  11. package/dist/Autocomplete/AutocompleteInput.js +14 -2
  12. package/dist/Dialog/Dialog.d.ts +1 -0
  13. package/dist/Dialog/Dialog.d.ts.map +1 -1
  14. package/dist/Dialog/Dialog.js +16 -2
  15. package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
  16. package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
  17. package/dist/InlineMessage/InlineMessage-cd1e4c93.css +2 -0
  18. package/dist/InlineMessage/InlineMessage-cd1e4c93.css.map +1 -0
  19. package/dist/InlineMessage/InlineMessage.d.ts +1 -1
  20. package/dist/InlineMessage/InlineMessage.d.ts.map +1 -1
  21. package/dist/InlineMessage/InlineMessage.js +34 -19
  22. package/dist/InlineMessage/InlineMessage.module.css.js +1 -1
  23. package/dist/KeybindingHint/KeybindingHint.d.ts +6 -1
  24. package/dist/KeybindingHint/KeybindingHint.d.ts.map +1 -1
  25. package/dist/KeybindingHint/KeybindingHint.js +6 -2
  26. package/dist/KeybindingHint/components/Chord.d.ts +2 -1
  27. package/dist/KeybindingHint/components/Chord.d.ts.map +1 -1
  28. package/dist/KeybindingHint/components/Chord.js +1 -1
  29. package/dist/KeybindingHint/components/Key.js +10 -10
  30. package/dist/KeybindingHint/components/Sequence.d.ts +2 -1
  31. package/dist/KeybindingHint/components/Sequence.d.ts.map +1 -1
  32. package/dist/KeybindingHint/components/Sequence.js +2 -2
  33. package/dist/KeybindingHint/key-names.d.ts +4 -3
  34. package/dist/KeybindingHint/key-names.d.ts.map +1 -1
  35. package/dist/KeybindingHint/key-names.js +15 -14
  36. package/dist/KeybindingHint/platform.d.ts +22 -0
  37. package/dist/KeybindingHint/platform.d.ts.map +1 -0
  38. package/dist/KeybindingHint/platform.js +61 -0
  39. package/dist/PageLayout/PageLayout.d.ts +24 -6
  40. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  41. package/dist/PageLayout/PageLayout.js +7 -2
  42. package/dist/Text/{Text-ca7603b7.css → Text-d649cda5.css} +2 -2
  43. package/dist/Text/Text-d649cda5.css.map +1 -0
  44. package/dist/Text/Text.d.ts +3 -0
  45. package/dist/Text/Text.d.ts.map +1 -1
  46. package/dist/Text/Text.js +20 -14
  47. package/dist/Text/Text.module.css.js +1 -1
  48. package/dist/Timeline/Timeline-ff81db92.css +2 -0
  49. package/dist/Timeline/Timeline-ff81db92.css.map +1 -0
  50. package/dist/Timeline/Timeline.d.ts +9 -8
  51. package/dist/Timeline/Timeline.d.ts.map +1 -1
  52. package/dist/Timeline/Timeline.js +156 -61
  53. package/dist/Timeline/Timeline.module.css.js +1 -1
  54. package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
  55. package/dist/TooltipV2/Tooltip.js +3 -3
  56. package/dist/TreeView/TreeView-1bf45a33.css +2 -0
  57. package/dist/TreeView/TreeView-1bf45a33.css.map +1 -0
  58. package/dist/TreeView/TreeView.d.ts.map +1 -1
  59. package/dist/TreeView/TreeView.js +25 -12
  60. package/dist/TreeView/TreeView.module.css.js +2 -2
  61. package/generated/components.json +57 -10
  62. package/package.json +1 -1
  63. package/dist/ActionList/ActionList-2a35a40c.css +0 -2
  64. package/dist/ActionList/ActionList-2a35a40c.css.map +0 -1
  65. package/dist/InlineMessage/InlineMessage-80d97643.css +0 -2
  66. package/dist/InlineMessage/InlineMessage-80d97643.css.map +0 -1
  67. package/dist/Text/Text-ca7603b7.css.map +0 -1
  68. package/dist/Timeline/Timeline-0c88f21b.css +0 -2
  69. package/dist/Timeline/Timeline-0c88f21b.css.map +0 -1
  70. package/dist/TreeView/TreeView-0fe09f34.css +0 -2
  71. package/dist/TreeView/TreeView-0fe09f34.css.map +0 -1
  72. package/dist/hooks/useIsMacOS.js +0 -32
@@ -139,7 +139,7 @@ const TrailingVisual = t0 => {
139
139
  //
140
140
  // This preserves the left alignment of item text.
141
141
  const VisualOrIndicator = t0 => {
142
- const $ = c(5);
142
+ const $ = c(6);
143
143
  const {
144
144
  children,
145
145
  labelId,
@@ -157,9 +157,10 @@ const VisualOrIndicator = t0 => {
157
157
  return children;
158
158
  }
159
159
  let t1;
160
- if ($[0] !== VisualComponent || $[1] !== className || $[2] !== inactiveText || $[3] !== labelId) {
160
+ if ($[0] !== VisualComponent || $[1] !== className || $[2] !== inactiveText || $[3] !== labelId || $[4] !== position) {
161
161
  t1 = inactiveText ? /*#__PURE__*/jsx("span", {
162
162
  className: classes.InactiveButtonWrap,
163
+ "data-position": position,
163
164
  children: /*#__PURE__*/jsx(Tooltip, {
164
165
  text: inactiveText,
165
166
  type: "description",
@@ -182,9 +183,10 @@ const VisualOrIndicator = t0 => {
182
183
  $[1] = className;
183
184
  $[2] = inactiveText;
184
185
  $[3] = labelId;
185
- $[4] = t1;
186
+ $[4] = position;
187
+ $[5] = t1;
186
188
  } else {
187
- t1 = $[4];
189
+ t1 = $[5];
188
190
  }
189
191
  return t1;
190
192
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqD,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAE/F,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAGlD,KAAK,8BAA8B,GAAG;IAEpC,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAEtD;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAID,QAAA,MAAM,iBAAiB,EAyJlB,8BAA8B,CAAC,OAAO,SAAS,EAAE,8BAA8B,CAAC,CAAA;AAIrF,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAC7E,eAAe,iBAAiB,CAAA"}
1
+ {"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqD,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAE/F,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAGlD,KAAK,8BAA8B,GAAG;IAEpC,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAEtD;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAID,QAAA,MAAM,iBAAiB,EA2KlB,8BAA8B,CAAC,OAAO,SAAS,EAAE,8BAA8B,CAAC,CAAA;AAIrF,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAC7E,eAAe,iBAAiB,CAAA"}
@@ -56,9 +56,17 @@ const AutocompleteInput = /*#__PURE__*/React.forwardRef(({
56
56
  safeSetTimeout(() => {
57
57
  if (document.activeElement !== inputRef.current) {
58
58
  setShowMenu(false);
59
+
60
+ // Reset the input's value to the text the user actually typed rather than leaving the
61
+ // inline autocomplete suggestion in place. This keeps the blur behavior consistent with
62
+ // pressing Escape, so deleting characters off a selection and then clicking away does not
63
+ // silently restore the full suggestion. See https://github.com/primer/react/issues/4275
64
+ if (inputRef.current && autocompleteSuggestion && inputRef.current.value !== inputValue) {
65
+ inputRef.current.value = inputValue;
66
+ }
59
67
  }
60
68
  }, 0);
61
- }, [onBlur, setShowMenu, inputRef, safeSetTimeout]);
69
+ }, [onBlur, setShowMenu, inputRef, safeSetTimeout, autocompleteSuggestion, inputValue]);
62
70
  const handleInputChange = event => {
63
71
  onChange && onChange(event);
64
72
  setInputValue(event.currentTarget.value);
@@ -110,7 +118,11 @@ const AutocompleteInput = /*#__PURE__*/React.forwardRef(({
110
118
  // TODO: fix bug where this function prevents `onChange` from being triggered if the highlighted item text
111
119
  // is the same as what I'm typing
112
120
  // e.g.: typing 'tw' highlights 'two', but when I 'two', the text input change does not get triggered
113
- if (highlightRemainingText && autocompleteSuggestion && (inputValue || isMenuDirectlyActivated)) {
121
+ // Only apply the inline autocomplete suggestion while the input is focused. Without this guard,
122
+ // the suggestion can be re-applied to the DOM after the input is blurred, which would restore
123
+ // the full suggestion the user was editing away from. See https://github.com/primer/react/issues/4275
124
+ const isInputFocused = document.activeElement === inputRef.current;
125
+ if (isInputFocused && highlightRemainingText && autocompleteSuggestion && (inputValue || isMenuDirectlyActivated)) {
114
126
  inputRef.current.value = autocompleteSuggestion;
115
127
  if (autocompleteSuggestion.toLowerCase().indexOf(inputValue.toLowerCase()) === 0) {
116
128
  inputRef.current.setSelectionRange(inputValue.length, autocompleteSuggestion.length);
@@ -170,6 +170,7 @@ export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & {
170
170
  }>>;
171
171
  CloseButton: React.FC<React.PropsWithChildren<{
172
172
  onClose: () => void;
173
+ onKeyDown?: React.KeyboardEventHandler;
173
174
  }>>;
174
175
  };
175
176
  export {};
@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B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAGD,QAAA,MAAM,SAAS;;;;CAIL,CAAA;AAEV,QAAA,MAAM,QAAQ;;;;;CAKJ,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAA;AAC5F,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,SAAS,CAAA;AAoEjD,eAAO,MAAM,aAAa,mCAAqD,CAAA;AAmS/E,eAAO,MAAM,MAAM;;;;;;;;;iBA9EuC,iBAAiB,EAAE;;;iBAoCf,MAAM,IAAI;oBAAc,KAAK,CAAC,oBAAoB;;CAkD9G,CAAA"}
@@ -36,6 +36,17 @@ const DefaultHeader = ({
36
36
  const onCloseClick = useCallback(() => {
37
37
  onClose('close-button');
38
38
  }, [onClose]);
39
+ const onCloseKeyDown = useCallback(event => {
40
+ if (event.key === 'Escape') {
41
+ // When the close button is focused its tooltip is open, and the
42
+ // tooltip's own Escape handler (registered on `document`) would
43
+ // otherwise swallow this keypress. Handle Escape here and stop it from
44
+ // reaching the document-level handler so the dialog closes on the first
45
+ // press while keeping the tooltip fully functional.
46
+ event.stopPropagation();
47
+ onClose('escape');
48
+ }
49
+ }, [onClose]);
39
50
  return /*#__PURE__*/jsx(Dialog.Header, {
40
51
  children: /*#__PURE__*/jsxs("div", {
41
52
  className: classes.HeaderInner,
@@ -49,7 +60,8 @@ const DefaultHeader = ({
49
60
  children: subtitle
50
61
  })]
51
62
  }), /*#__PURE__*/jsx(Dialog.CloseButton, {
52
- onClose: onCloseClick
63
+ onClose: onCloseClick,
64
+ onKeyDown: onCloseKeyDown
53
65
  })]
54
66
  })
55
67
  });
@@ -348,12 +360,14 @@ const Buttons = ({
348
360
  });
349
361
  };
350
362
  const CloseButton = ({
351
- onClose
363
+ onClose,
364
+ onKeyDown
352
365
  }) => {
353
366
  return /*#__PURE__*/jsx(IconButton, {
354
367
  icon: XIcon,
355
368
  "aria-label": "Close",
356
369
  onClick: onClose,
370
+ onKeyDown: onKeyDown,
357
371
  variant: "invisible",
358
372
  "data-component": "Dialog.CloseButton"
359
373
  });
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultFeatureFlags.d.ts","sourceRoot":"","sources":["../../src/FeatureFlags/DefaultFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAEnD,eAAO,MAAM,mBAAmB,kBAK9B,CAAA"}
1
+ {"version":3,"file":"DefaultFeatureFlags.d.ts","sourceRoot":"","sources":["../../src/FeatureFlags/DefaultFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAEnD,eAAO,MAAM,mBAAmB,kBAM9B,CAAA"}
@@ -4,7 +4,8 @@ const DefaultFeatureFlags = FeatureFlagScope.create({
4
4
  primer_react_select_panel_fullscreen_on_narrow: false,
5
5
  primer_react_select_panel_order_selected_at_top: false,
6
6
  primer_react_styled_react_use_primer_theme_providers: false,
7
- primer_react_action_list_group_heading_trailing_action: false
7
+ primer_react_action_list_group_heading_trailing_action: false,
8
+ primer_react_timeline_list_semantics: false
8
9
  });
9
10
 
10
11
  export { DefaultFeatureFlags };
@@ -0,0 +1,2 @@
1
+ .prc-InlineMessage-InlineMessage-8xfK-{align-items:start;color:var(--inline-message-fgColor);column-gap:.5rem;display:grid;font-size:var(--inline-message-fontSize);grid-template-columns:auto 1fr;line-height:var(--inline-message-lineHeight);--inline-message-fgColor:var(--fgColor-default,#1f2328)}.prc-InlineMessage-InlineMessage-8xfK-[data-size=small]{--inline-message-fontSize:var(--text-body-size-small,0.75rem);--inline-message-lineHeight:var(--text-body-lineHeight-small,1.6666)}.prc-InlineMessage-InlineMessage-8xfK-[data-size=medium]{--inline-message-fontSize:var(--text-body-size-medium,0.875rem);--inline-message-lineHeight:var(--text-body-lineHeight-medium,1.4285)}.prc-InlineMessage-InlineMessage-8xfK-[data-variant=warning]{--inline-message-fgColor:var(--fgColor-attention,#9a6700)}.prc-InlineMessage-InlineMessage-8xfK-[data-variant=critical]{--inline-message-fgColor:var(--fgColor-danger,#d1242f)}.prc-InlineMessage-InlineMessage-8xfK-[data-variant=success]{--inline-message-fgColor:var(--fgColor-success,#1a7f37)}.prc-InlineMessage-InlineMessage-8xfK-[data-variant=unavailable]{--inline-message-fgColor:var(--fgColor-muted,#59636e)}.prc-InlineMessage-InlineMessageIcon-rl8pZ{min-height:calc(var(--inline-message-lineHeight)*var(--inline-message-fontSize))}
2
+ /*# sourceMappingURL=InlineMessage-cd1e4c93.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/InlineMessage/InlineMessage.module.css.js"],"names":[],"mappings":"AAAA,uCAUE,iBAAkB,CAHlB,mCAAoC,CACpC,gBAAkB,CAPlB,YAAa,CAEb,wCAAyC,CAMzC,8BAA+B,CAJ/B,4CAA6C,CAO7C,uDA2BF,CAzBE,wDACE,6DAAsD,CACtD,oEACF,CAEA,yDACE,+DAAuD,CACvD,qEACF,CAEA,6DACE,yDACF,CAEA,8DACE,sDACF,CAEA,6DACE,uDACF,CAEA,iEACE,qDACF,CAGF,2CACE,gFACF","file":"InlineMessage-cd1e4c93.css","sourcesContent":[".InlineMessage {\n display: grid;\n /* stylelint-disable-next-line primer/typography */\n font-size: var(--inline-message-fontSize);\n /* stylelint-disable-next-line primer/typography */\n line-height: var(--inline-message-lineHeight);\n /* stylelint-disable-next-line primer/colors */\n color: var(--inline-message-fgColor);\n column-gap: 0.5rem;\n grid-template-columns: auto 1fr;\n align-items: start;\n\n --inline-message-fgColor: var(--fgColor-default);\n\n &[data-size='small'] {\n --inline-message-fontSize: var(--text-body-size-small);\n --inline-message-lineHeight: var(--text-body-lineHeight-small, 1.6666);\n }\n\n &[data-size='medium'] {\n --inline-message-fontSize: var(--text-body-size-medium);\n --inline-message-lineHeight: var(--text-body-lineHeight-medium, 1.4285);\n }\n\n &[data-variant='warning'] {\n --inline-message-fgColor: var(--fgColor-attention);\n }\n\n &[data-variant='critical'] {\n --inline-message-fgColor: var(--fgColor-danger);\n }\n\n &[data-variant='success'] {\n --inline-message-fgColor: var(--fgColor-success);\n }\n\n &[data-variant='unavailable'] {\n --inline-message-fgColor: var(--fgColor-muted);\n }\n}\n\n.InlineMessageIcon {\n min-height: calc(var(--inline-message-lineHeight) * var(--inline-message-fontSize));\n}\n"]}
@@ -8,7 +8,7 @@ export type InlineMessageProps = React.ComponentPropsWithoutRef<'div'> & {
8
8
  /**
9
9
  * Specify the type of the InlineMessage
10
10
  */
11
- variant: MessageVariant;
11
+ variant?: MessageVariant;
12
12
  /**
13
13
  * A custom leading visual (icon or other element) to display instead of the default variant icon.
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"InlineMessage.d.ts","sourceRoot":"","sources":["../../src/InlineMessage/InlineMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,KAAK,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAA;AAExE,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG;IACvE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAEzB;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IAEvB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;CACpD,CAAA;AAgBD,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,IAAe,EACf,OAAO,EACP,aAAa,EAAE,aAAa,EAC5B,GAAG,IAAI,EACR,EAAE,kBAAkB,qBA0BpB"}
1
+ {"version":3,"file":"InlineMessage.d.ts","sourceRoot":"","sources":["../../src/InlineMessage/InlineMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,KAAK,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAA;AAExE,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG;IACvE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;CACpD,CAAA;AAgBD,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,IAAe,EACf,OAAO,EACP,aAAa,EAAE,aAAa,EAC5B,GAAG,IAAI,EACR,EAAE,kBAAkB,qBA4BpB"}
@@ -1,5 +1,5 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import { AlertIcon, CheckCircleIcon, AlertFillIcon, CheckCircleFillIcon } from '@primer/octicons-react';
2
+ import { AlertIcon, CheckCircleIcon, AlertFillIcon, CheckCircleFillIcon, InfoIcon } from '@primer/octicons-react';
3
3
  import { clsx } from 'clsx';
4
4
  import { isValidElementType } from 'react-is';
5
5
  import classes from './InlineMessage.module.css.js';
@@ -38,7 +38,8 @@ const smallIcons = {
38
38
  })
39
39
  };
40
40
  function InlineMessage(t0) {
41
- const $ = c(18);
41
+ var _variant;
42
+ const $ = c(19);
42
43
  let LeadingVisual;
43
44
  let children;
44
45
  let className;
@@ -88,37 +89,51 @@ function InlineMessage(t0) {
88
89
  icon = LeadingVisual;
89
90
  }
90
91
  } else {
91
- icon = size === "small" ? smallIcons[variant] : icons[variant];
92
+ if (variant) {
93
+ icon = size === "small" ? smallIcons[variant] : icons[variant];
94
+ } else {
95
+ let t2;
96
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
97
+ t2 = /*#__PURE__*/jsx(InfoIcon, {
98
+ className: classes.InlineMessageIcon
99
+ });
100
+ $[9] = t2;
101
+ } else {
102
+ t2 = $[9];
103
+ }
104
+ icon = t2;
105
+ }
92
106
  }
93
107
  let t2;
94
- if ($[9] !== className) {
108
+ if ($[10] !== className) {
95
109
  t2 = clsx(className, classes.InlineMessage);
96
- $[9] = className;
97
- $[10] = t2;
110
+ $[10] = className;
111
+ $[11] = t2;
98
112
  } else {
99
- t2 = $[10];
113
+ t2 = $[11];
100
114
  }
101
- let t3;
102
- if ($[11] !== children || $[12] !== icon || $[13] !== rest || $[14] !== size || $[15] !== t2 || $[16] !== variant) {
103
- t3 = /*#__PURE__*/jsxs("div", {
115
+ const t3 = (_variant = variant) !== null && _variant !== void 0 ? _variant : undefined;
116
+ let t4;
117
+ if ($[12] !== children || $[13] !== icon || $[14] !== rest || $[15] !== size || $[16] !== t2 || $[17] !== t3) {
118
+ t4 = /*#__PURE__*/jsxs("div", {
104
119
  ...rest,
105
120
  className: t2,
106
121
  "data-size": size,
107
- "data-variant": variant,
122
+ "data-variant": t3,
108
123
  "data-component": "InlineMessage",
109
124
  children: [icon, children]
110
125
  });
111
- $[11] = children;
112
- $[12] = icon;
113
- $[13] = rest;
114
- $[14] = size;
115
- $[15] = t2;
116
- $[16] = variant;
126
+ $[12] = children;
127
+ $[13] = icon;
128
+ $[14] = rest;
129
+ $[15] = size;
130
+ $[16] = t2;
117
131
  $[17] = t3;
132
+ $[18] = t4;
118
133
  } else {
119
- t3 = $[17];
134
+ t4 = $[18];
120
135
  }
121
- return t3;
136
+ return t4;
122
137
  }
123
138
 
124
139
  export { InlineMessage };
@@ -1,4 +1,4 @@
1
- import './InlineMessage-80d97643.css';
1
+ import './InlineMessage-cd1e4c93.css';
2
2
 
3
3
  var classes = {"InlineMessage":"prc-InlineMessage-InlineMessage-8xfK-","InlineMessageIcon":"prc-InlineMessage-InlineMessageIcon-rl8pZ"};
4
4
 
@@ -1,4 +1,5 @@
1
1
  import type { KeybindingHintProps } from './props';
2
+ import type { Platform } from './platform';
2
3
  /** Indicates the presence of an available keybinding. */
3
4
  export declare const KeybindingHint: import("react").MemoExoticComponent<({ className, ...props }: KeybindingHintProps) => import("react").JSX.Element>;
4
5
  /**
@@ -8,6 +9,10 @@ export declare const KeybindingHint: import("react").MemoExoticComponent<({ clas
8
9
  *
9
10
  * NOTE that this string should _only_ be used when building `aria-label` or `aria-description` props (never rendered
10
11
  * visibly) and should nearly always also be paired with a visible hint for sighted users.
12
+ *
13
+ * The `platform` argument controls how platform-specific keys (such as `Meta`, `Alt`, and `Mod`) are named. For
14
+ * backwards compatibility, a `boolean` may be passed instead, where `true` is treated as `'apple'` and `false` as
15
+ * `'other'`.
11
16
  */
12
- export declare const getAccessibleKeybindingHintString: (sequence: string, isMacOS: boolean) => string;
17
+ export declare const getAccessibleKeybindingHintString: (sequence: string, platform: Platform | boolean) => string;
13
18
  //# sourceMappingURL=KeybindingHint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"KeybindingHint.d.ts","sourceRoot":"","sources":["../../src/KeybindingHint/KeybindingHint.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,SAAS,CAAA;AAoBhD,yDAAyD;AAEzD,eAAO,MAAM,cAAc,gEAAgC,mBAAmB,iCAI5E,CAAA;AAGF;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,gDAA2B,CAAA"}
1
+ {"version":3,"file":"KeybindingHint.d.ts","sourceRoot":"","sources":["../../src/KeybindingHint/KeybindingHint.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,SAAS,CAAA;AAEhD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAmBxC,yDAAyD;AAEzD,eAAO,MAAM,cAAc,gEAAgC,mBAAmB,iCAI5E,CAAA;AAGF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iCAAiC,GAAI,UAAU,MAAM,EAAE,UAAU,QAAQ,GAAG,OAAO,WACe,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { c } from 'react-compiler-runtime';
2
2
  import { memo } from 'react';
3
- import { accessibleSequenceString, Sequence } from './components/Sequence.js';
3
+ import { Sequence, accessibleSequenceString } 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,7 +89,11 @@ 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 `'apple'` and `false` as
95
+ * `'other'`.
92
96
  */
93
- const getAccessibleKeybindingHintString = accessibleSequenceString;
97
+ const getAccessibleKeybindingHintString = (sequence, platform) => accessibleSequenceString(sequence, typeof platform === 'boolean' ? platform ? 'apple' : 'other' : platform);
94
98
 
95
99
  export { KeybindingHint, getAccessibleKeybindingHintString };
@@ -1,5 +1,6 @@
1
1
  import type { KeybindingHintProps } from '../props';
2
+ import type { Platform } from '../platform';
2
3
  export declare const Chord: ({ keys, format, variant, size }: KeybindingHintProps) => import("react").JSX.Element;
3
4
  /** Plain string version of `Chord` for use in `aria` string attributes. */
4
- export declare const accessibleChordString: (chord: string, isMacOS: boolean) => string;
5
+ export declare const accessibleChordString: (chord: string, platform: Platform) => string;
5
6
  //# 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;AA+BjD,eAAO,MAAM,KAAK,GAAI,iCAAmE,mBAAmB,gCAsB3G,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,EAAE,SAAS,OAAO,WAGvD,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;AAGjD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AA6BzC,eAAO,MAAM,KAAK,GAAI,iCAAmE,mBAAmB,gCAsB3G,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,EAAE,UAAU,QAAQ,WAGzD,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, isMacOS) => splitChord(chord).map(key => accessibleKeyName(key, isMacOS)).join(' ');
99
+ const accessibleChordString = (chord, platform) => splitChord(chord).map(key => accessibleKeyName(key, platform)).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 { useIsMacOS } from '../../hooks/useIsMacOS.js';
4
+ import { usePlatform } from '../platform.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 isMacOS = useIsMacOS();
14
+ const platform = usePlatform();
15
15
  let t1;
16
- if ($[0] !== isMacOS || $[1] !== name) {
17
- t1 = accessibleKeyName(name, isMacOS);
18
- $[0] = isMacOS;
19
- $[1] = name;
16
+ if ($[0] !== name || $[1] !== platform) {
17
+ t1 = accessibleKeyName(name, platform);
18
+ $[0] = name;
19
+ $[1] = platform;
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] !== isMacOS || $[7] !== name) {
36
- t3 = format === "condensed" ? condensedKeyName(name, isMacOS) : fullKeyName(name, isMacOS);
35
+ if ($[5] !== format || $[6] !== name || $[7] !== platform) {
36
+ t3 = format === "condensed" ? condensedKeyName(name, platform) : fullKeyName(name, platform);
37
37
  $[5] = format;
38
- $[6] = isMacOS;
39
- $[7] = name;
38
+ $[6] = name;
39
+ $[7] = platform;
40
40
  $[8] = t3;
41
41
  } else {
42
42
  t3 = $[8];
@@ -1,5 +1,6 @@
1
1
  import type { KeybindingHintProps } from '../props';
2
+ import type { Platform } from '../platform';
2
3
  export declare const Sequence: ({ keys, ...chordProps }: KeybindingHintProps) => import("react").JSX.Element[];
3
4
  /** Plain string version of `Sequence` for use in `aria` string attributes. */
4
- export declare const accessibleSequenceString: (sequence: string, isMacOS: boolean) => string;
5
+ export declare const accessibleSequenceString: (sequence: string, platform: Platform) => string;
5
6
  //# 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;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
+ {"version":3,"file":"Sequence.d.ts","sourceRoot":"","sources":["../../../src/KeybindingHint/components/Sequence.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAGjD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAIzC,eAAO,MAAM,QAAQ,GAAI,yBAAuB,mBAAmB,kCAa/D,CAAA;AAEJ,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,EAAE,UAAU,QAAQ,WAG1D,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Fragment } from 'react';
2
2
  import VisuallyHidden from '../../_VisuallyHidden.js';
3
- import { accessibleChordString, Chord } from './Chord.js';
3
+ import { Chord, accessibleChordString } 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, isMacOS) => splitSequence(sequence).map(chord => accessibleChordString(chord, isMacOS)).join(' then ');
24
+ const accessibleSequenceString = (sequence, platform) => splitSequence(sequence).map(chord => accessibleChordString(chord, platform)).join(' then ');
25
25
 
26
26
  export { Sequence, accessibleSequenceString };
@@ -1,16 +1,17 @@
1
+ import type { Platform } from './platform';
1
2
  /**
2
3
  * Short-form iconic versions of keys. These should be intuitive (not archaic) and match icons on keyboards.
3
4
  */
4
- export declare const condensedKeyName: (key: string, isMacOS: boolean) => string;
5
+ export declare const condensedKeyName: (key: string, platform: Platform) => string;
5
6
  /**
6
7
  * Specific key displays for 'full' format. We still do show some icons (ie punctuation)
7
8
  * because that's more intuitive, but for the rest of keys we show the standard key name.
8
9
  */
9
- export declare const fullKeyName: (key: string, isMacOS: boolean) => string;
10
+ export declare const fullKeyName: (key: string, platform: Platform) => string;
10
11
  /**
11
12
  * Accessible key names intended to be read by a screen reader. This prevents screen
12
13
  * readers from expressing punctuation in speech, ie, reading a long pause instead of the
13
14
  * word "period".
14
15
  */
15
- export declare const accessibleKeyName: (key: string, isMacOS: boolean) => string;
16
+ export declare const accessibleKeyName: (key: string, platform: Platform) => string;
16
17
  //# 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":"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"}
1
+ {"version":3,"file":"key-names.d.ts","sourceRoot":"","sources":["../../src/KeybindingHint/key-names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAUxC;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,UAAU,QAAQ,WAwBpC,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,UAAU,QAAQ,WAc/B,CAAA;AAE5B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,UAAU,QAAQ,WAmDnC,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, isMacOS) => {
15
+ const condensedKeyName = (key, platform) => {
16
16
  var _alt$control$shift$me;
17
17
  return (_alt$control$shift$me = {
18
- alt: isMacOS ? '⌥' : 'Alt',
18
+ alt: platform === 'apple' ? '⌥' : '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: isMacOS ? '⌘' : 'Win',
23
- mod: isMacOS ? '⌘' : '⌃',
22
+ meta: platform === 'apple' ? '⌘' : platform === 'windows' ? 'Win' : 'Meta',
23
+ mod: platform === 'apple' ? '⌘' : '⌃',
24
24
  pageup: 'PgUp',
25
25
  pagedown: 'PgDn',
26
26
  arrowup: '↑',
@@ -47,11 +47,12 @@ const condensedKeyName = (key, isMacOS) => {
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, isMacOS) => {
51
- var _alt$mod$$pageup$pag;
52
- return (_alt$mod$$pageup$pag = {
53
- alt: isMacOS ? 'Option' : 'Alt',
54
- mod: isMacOS ? 'Command' : 'Control',
50
+ const fullKeyName = (key, platform) => {
51
+ var _alt$meta$mod$$pageu;
52
+ return (_alt$meta$mod$$pageu = {
53
+ alt: platform === 'apple' ? 'Option' : 'Alt',
54
+ meta: platform === 'apple' ? 'Command' : platform === 'windows' ? 'Windows' : 'Meta',
55
+ mod: platform === 'apple' ? 'Command' : 'Control',
55
56
  '+': 'Plus',
56
57
  pageup: 'Page Up',
57
58
  pagedown: 'Page Down',
@@ -61,7 +62,7 @@ const fullKeyName = (key, isMacOS) => {
61
62
  arrowright: 'Right Arrow',
62
63
  capslock: 'Caps Lock',
63
64
  printscreen: 'Print Screen'
64
- }[key]) !== null && _alt$mod$$pageup$pag !== void 0 ? _alt$mod$$pageup$pag : capitalize(key);
65
+ }[key]) !== null && _alt$meta$mod$$pageu !== void 0 ? _alt$meta$mod$$pageu : capitalize(key);
65
66
  };
66
67
 
67
68
  /**
@@ -69,12 +70,12 @@ const fullKeyName = (key, isMacOS) => {
69
70
  * readers from expressing punctuation in speech, ie, reading a long pause instead of the
70
71
  * word "period".
71
72
  */
72
- const accessibleKeyName = (key, isMacOS) => {
73
+ const accessibleKeyName = (key, platform) => {
73
74
  var _alt$meta$mod$pageup$;
74
75
  return (_alt$meta$mod$pageup$ = {
75
- alt: isMacOS ? 'option' : 'alt',
76
- meta: isMacOS ? 'command' : 'Windows',
77
- mod: isMacOS ? 'command' : 'control',
76
+ alt: platform === 'apple' ? 'option' : 'alt',
77
+ meta: platform === 'apple' ? 'command' : platform === 'windows' ? 'Windows' : 'meta',
78
+ mod: platform === 'apple' ? 'command' : 'control',
78
79
  // Screen readers may not be able to pronounce concatenated words - this provides a better experience
79
80
  pageup: 'page up',
80
81
  pagedown: 'page down',
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The platform categories that affect how keyboard shortcut keys are displayed.
3
+ *
4
+ * - `apple`: Apple platforms (macOS and iOS/iPadOS), which use the Command and Option keys.
5
+ * - `windows`: Windows, which uses the Windows (Meta) key.
6
+ * - `other`: Any other platform (e.g. Linux, Android), where the Meta key does not map to a
7
+ * consistent label.
8
+ */
9
+ export type Platform = 'apple' | 'windows' | 'other';
10
+ export declare const PlatformOverrideProvider: import("react").Provider<Platform | null>;
11
+ /**
12
+ * SSR-safe hook for determining the current platform category used when displaying
13
+ * keyboard shortcut keys.
14
+ *
15
+ * Mirrors the approach of `useIsMacOS`: on the client it reads the real value immediately,
16
+ * and on the server it returns a safe default (`'other'`).
17
+ *
18
+ * If a `PlatformOverrideProvider` is present with a non-null value, that value is used
19
+ * instead of the detected platform.
20
+ */
21
+ export declare function usePlatform(): Platform;
22
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/KeybindingHint/platform.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAA;AAkCpD,eAAO,MAAM,wBAAwB,2CAAmC,CAAA;AAExE;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAItC"}
@@ -0,0 +1,61 @@
1
+ import { isMacOS } from '@primer/behaviors/utils';
2
+ import { useContext, useSyncExternalStore, createContext } from 'react';
3
+
4
+ /**
5
+ * The platform categories that affect how keyboard shortcut keys are displayed.
6
+ *
7
+ * - `apple`: Apple platforms (macOS and iOS/iPadOS), which use the Command and Option keys.
8
+ * - `windows`: Windows, which uses the Windows (Meta) key.
9
+ * - `other`: Any other platform (e.g. Linux, Android), where the Meta key does not map to a
10
+ * consistent label.
11
+ */
12
+
13
+ // No-op. The platform never changes at runtime, so there is nothing to
14
+ // subscribe to. Hoisted to avoid creating a new function on every call.
15
+ const subscribe = () => () => {};
16
+
17
+ /** SSR-unsafe detection of iOS/iPadOS (in addition to macOS, which is detected separately). */
18
+ const ssrUnsafeIsIOS = () => {
19
+ if (typeof navigator === 'undefined') return false;
20
+ return /iphone|ipad|ipod/i.test(navigator.platform) || /iphone|ipad|ipod/i.test(navigator.userAgent);
21
+ };
22
+
23
+ /** SSR-unsafe detection of Windows. */
24
+ const ssrUnsafeIsWindows = () => {
25
+ if (typeof navigator === 'undefined') return false;
26
+ return /^win/i.test(navigator.platform);
27
+ };
28
+ const getSnapshot = () => {
29
+ if (isMacOS() || ssrUnsafeIsIOS()) return 'apple';
30
+ if (ssrUnsafeIsWindows()) return 'windows';
31
+ return 'other';
32
+ };
33
+
34
+ // Safe default for SSR since we can't detect the platform on the server.
35
+ const getServerSnapshot = () => 'other';
36
+
37
+ /**
38
+ * Allows overriding the detected platform. This is primarily intended for testing and
39
+ * Storybook, where we want to preview how keyboard hints render on platforms other than the
40
+ * one actually running. A `null` value (the default) means "use the detected platform".
41
+ */
42
+ const PlatformOverrideContext = /*#__PURE__*/createContext(null);
43
+ PlatformOverrideContext.Provider;
44
+
45
+ /**
46
+ * SSR-safe hook for determining the current platform category used when displaying
47
+ * keyboard shortcut keys.
48
+ *
49
+ * Mirrors the approach of `useIsMacOS`: on the client it reads the real value immediately,
50
+ * and on the server it returns a safe default (`'other'`).
51
+ *
52
+ * If a `PlatformOverrideProvider` is present with a non-null value, that value is used
53
+ * instead of the detected platform.
54
+ */
55
+ function usePlatform() {
56
+ const override = useContext(PlatformOverrideContext);
57
+ const detected = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
58
+ return override !== null && override !== void 0 ? override : detected;
59
+ }
60
+
61
+ export { usePlatform };