@primer/behaviors 0.0.0-20251215124648 → 0.0.0-20251215125247

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.
@@ -65,19 +65,12 @@ const KEY_TO_DIRECTION = {
65
65
  PageDown: 'end',
66
66
  Backspace: 'previous',
67
67
  };
68
- let cachedIsMac;
69
- function getIsMac() {
70
- if (cachedIsMac === undefined) {
71
- cachedIsMac = userAgent.isMacOS();
72
- }
73
- return cachedIsMac;
74
- }
75
68
  function getDirection(keyboardEvent) {
76
69
  const direction = KEY_TO_DIRECTION[keyboardEvent.key];
77
70
  if (keyboardEvent.key === 'Tab' && keyboardEvent.shiftKey) {
78
71
  return 'previous';
79
72
  }
80
- const isMac = getIsMac();
73
+ const isMac = userAgent.isMacOS();
81
74
  if ((isMac && keyboardEvent.metaKey) || (!isMac && keyboardEvent.ctrlKey)) {
82
75
  if (keyboardEvent.key === 'ArrowLeft' || keyboardEvent.key === 'ArrowUp') {
83
76
  return 'start';
@@ -97,7 +90,7 @@ function shouldIgnoreFocusHandling(keyboardEvent, activeElement) {
97
90
  return true;
98
91
  }
99
92
  if (isSelect) {
100
- const isMac = getIsMac();
93
+ const isMac = userAgent.isMacOS();
101
94
  if (key === 'ArrowDown' && isMac && !keyboardEvent.metaKey) {
102
95
  return true;
103
96
  }
@@ -63,19 +63,12 @@ const KEY_TO_DIRECTION = {
63
63
  PageDown: 'end',
64
64
  Backspace: 'previous',
65
65
  };
66
- let cachedIsMac;
67
- function getIsMac() {
68
- if (cachedIsMac === undefined) {
69
- cachedIsMac = isMacOS();
70
- }
71
- return cachedIsMac;
72
- }
73
66
  function getDirection(keyboardEvent) {
74
67
  const direction = KEY_TO_DIRECTION[keyboardEvent.key];
75
68
  if (keyboardEvent.key === 'Tab' && keyboardEvent.shiftKey) {
76
69
  return 'previous';
77
70
  }
78
- const isMac = getIsMac();
71
+ const isMac = isMacOS();
79
72
  if ((isMac && keyboardEvent.metaKey) || (!isMac && keyboardEvent.ctrlKey)) {
80
73
  if (keyboardEvent.key === 'ArrowLeft' || keyboardEvent.key === 'ArrowUp') {
81
74
  return 'start';
@@ -95,7 +88,7 @@ function shouldIgnoreFocusHandling(keyboardEvent, activeElement) {
95
88
  return true;
96
89
  }
97
90
  if (isSelect) {
98
- const isMac = getIsMac();
91
+ const isMac = isMacOS();
99
92
  if (key === 'ArrowDown' && isMac && !keyboardEvent.metaKey) {
100
93
  return true;
101
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-20251215124648",
3
+ "version": "0.0.0-20251215125247",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cjs/index.js",