@fluentui-react-native/focus-zone 0.17.1 → 0.18.0

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.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@fluentui-react-native/focus-zone",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 15 Apr 2024 21:29:45 GMT",
5
+ "date": "Tue, 23 Jul 2024 16:55:40 GMT",
6
+ "version": "0.18.0",
7
+ "tag": "@fluentui-react-native/focus-zone_v0.18.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "nakambo@microsoft.com",
12
+ "package": "@fluentui-react-native/focus-zone",
13
+ "commit": "ddf90fafdfaccd6318bb66f1d114f632bc5eb485",
14
+ "comment": "Implement Focus Zone circular navigation and tab key behaviors for macOS"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 15 Apr 2024 21:31:44 GMT",
6
21
  "version": "0.17.1",
7
22
  "tag": "@fluentui-react-native/focus-zone_v0.17.1",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @fluentui-react-native/focus-zone
2
2
 
3
- This log was last generated on Mon, 15 Apr 2024 21:29:45 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 23 Jul 2024 16:55:40 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.18.0
8
+
9
+ Tue, 23 Jul 2024 16:55:40 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Implement Focus Zone circular navigation and tab key behaviors for macOS (nakambo@microsoft.com)
14
+
7
15
  ## 0.17.1
8
16
 
9
- Mon, 15 Apr 2024 21:29:45 GMT
17
+ Mon, 15 Apr 2024 21:31:44 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -29,7 +29,6 @@ export type FocusZoneProps = React.PropsWithChildren<{
29
29
  */
30
30
  use2DNavigation?: boolean;
31
31
  /**
32
- * @platform win32
33
32
  * By default, pressing Tab within a FocusZone moves focus out of the FocusZone.
34
33
  * This prop allows you to change that behavior.
35
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.types.d.ts","sourceRoot":"","sources":["../src/FocusZone.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC,MAAM,WAAW,cAAc;CAAG;AAElC,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACnD;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3C;;OAEG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE1D;;OAEG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAE5B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAC/E,aAAa,CAAC,EAAE,aAAa,CAAC;IA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@ -29,7 +29,6 @@ export type FocusZoneProps = React.PropsWithChildren<{
29
29
  */
30
30
  use2DNavigation?: boolean;
31
31
  /**
32
- * @platform win32
33
32
  * By default, pressing Tab within a FocusZone moves focus out of the FocusZone.
34
33
  * This prop allows you to change that behavior.
35
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.types.d.ts","sourceRoot":"","sources":["../src/FocusZone.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC,MAAM,WAAW,cAAc;CAAG;AAElC,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACnD;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3C;;OAEG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE1D;;OAEG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAE5B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,WAAW,WAAY,SA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Ae,CAAC;IACxB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,KAAK,EAAE,cAAc,CAAC;CACvB"}
@@ -15,6 +15,7 @@ typedef NS_ENUM(NSInteger, FocusZoneDirection) {
15
15
  @property(nonatomic) BOOL disabled;
16
16
  @property(nonatomic) FocusZoneDirection focusZoneDirection;
17
17
  @property(nonatomic) NSString *navigateAtEnd;
18
+ @property(nonatomic) NSString *tabKeyNavigation;
18
19
  @property(nonatomic) NSView *defaultResponder;
19
20
 
20
21
  @end
@@ -308,6 +308,73 @@ static BOOL ShouldSkipFocusZone(NSView *view)
308
308
  return [self nextViewToFocusForCondition:block];
309
309
  }
310
310
 
311
+ - (NSView *)nextViewToFocusForCircularAction:(FocusZoneAction)action
312
+ {
313
+ BOOL isAdvance = IsAdvanceWithinZoneAction(action);
314
+ BOOL isHorizontal = IsHorizontalNavigationWithinZoneAction(action);
315
+
316
+ NSView *firstResponder = GetFirstResponder([self window]);
317
+ NSRect firstResponderRect = [firstResponder convertRect:[firstResponder bounds] toView:self];
318
+ NSPoint anchorPoint = isHorizontal
319
+ ? NSMakePoint(isAdvance ? 0 : [self bounds].size.width, NSMidY(firstResponderRect))
320
+ : NSMakePoint(NSMidX(firstResponderRect), isAdvance ? 0 : [self bounds].size.height);
321
+
322
+ __block CGFloat closestDistance = CGFLOAT_MAX;
323
+
324
+ IsViewLeadingCandidateForNextFocus block = ^BOOL(NSView *candidateView)
325
+ {
326
+ BOOL isLeadingCandidate = NO;
327
+ BOOL skip = NO;
328
+ NSRect candidateRect = [candidateView convertRect:[candidateView bounds] toView:self];
329
+ BOOL subviewRelationExists = [candidateView isDescendantOf:firstResponder] || [firstResponder isDescendantOf:candidateView];
330
+
331
+ if (isHorizontal)
332
+ {
333
+ if (subviewRelationExists)
334
+ {
335
+ skip = (isAdvance && NSMinX(candidateRect) > NSMinX(firstResponderRect))
336
+ || (!isAdvance && NSMaxX(candidateRect) < NSMaxX(firstResponderRect));
337
+ }
338
+ else
339
+ {
340
+ skip = (isAdvance && NSMidX(candidateRect) > NSMidX(firstResponderRect))
341
+ || (!isAdvance && NSMidX(candidateRect) < NSMidX(firstResponderRect));
342
+ }
343
+ }
344
+ else
345
+ {
346
+ if (subviewRelationExists)
347
+ {
348
+ skip = (isAdvance && NSMinY(candidateRect) > NSMinY(firstResponderRect))
349
+ || (!isAdvance && NSMaxY(candidateRect) < NSMaxY(firstResponderRect));
350
+ }
351
+ else
352
+ {
353
+ skip = (isAdvance && NSMidY(candidateRect) > NSMidY(firstResponderRect))
354
+ || (!isAdvance && NSMidY(candidateRect) < NSMidY(firstResponderRect));
355
+ }
356
+ }
357
+
358
+ if (!skip)
359
+ {
360
+ NSPoint candidatePoint = isHorizontal
361
+ ? NSMakePoint(isAdvance ? NSMinX(candidateRect) : NSMaxX(candidateRect), NSMidY(candidateRect))
362
+ : NSMakePoint(NSMidX(candidateRect), isAdvance ? NSMinY(candidateRect) : NSMaxY(candidateRect));
363
+
364
+ CGFloat distance = GetDistanceBetweenPoints(anchorPoint, candidatePoint);
365
+ if (closestDistance > distance)
366
+ {
367
+ closestDistance = distance;
368
+ isLeadingCandidate = YES;
369
+ }
370
+ }
371
+
372
+ return isLeadingCandidate;
373
+ };
374
+
375
+ return [self nextViewToFocusForCondition:block];
376
+ }
377
+
311
378
  - (NSView *)nextViewToFocusForHorizontalNavigation:(FocusZoneAction)action
312
379
  {
313
380
  BOOL isAdvance = IsAdvanceWithinZoneAction(action);
@@ -347,9 +414,8 @@ static BOOL ShouldSkipFocusZone(NSView *view)
347
414
  return [self nextViewToFocusForCondition:block];
348
415
  }
349
416
 
350
- - (NSView *)nextViewToFocusWithFallback:(FocusZoneAction)action
417
+ - (NSView *)nextViewToFocusWithFallback:(FocusZoneAction)action considerCircular:(BOOL)shouldTryCircular
351
418
  {
352
-
353
419
  // Special case if we're currently focused on self
354
420
  NSView *firstResponder = GetFirstResponder([self window]);
355
421
  if (self == firstResponder)
@@ -364,18 +430,37 @@ static BOOL ShouldSkipFocusZone(NSView *view)
364
430
  }
365
431
  }
366
432
 
433
+ BOOL isHorizontal = IsHorizontalNavigationWithinZoneAction(action);
434
+ BOOL isAdvance = IsAdvanceWithinZoneAction(action);
367
435
  NSView *nextViewToFocus = [self nextViewToFocusForAction:action];
368
436
 
369
437
  if (nextViewToFocus == nil)
370
438
  {
371
- if (IsHorizontalNavigationWithinZoneAction(action))
439
+ if (isHorizontal)
372
440
  {
373
441
  nextViewToFocus = [self nextViewToFocusForHorizontalNavigation:action];
374
442
  }
375
443
  else
376
444
  {
377
- FocusZoneAction horizontalAction = IsAdvanceWithinZoneAction(action) ? FocusZoneActionRightArrow : FocusZoneActionLeftArrow;
378
- nextViewToFocus = [self nextViewToFocusWithFallback:horizontalAction];
445
+ FocusZoneAction horizontalAction = isAdvance ? FocusZoneActionRightArrow : FocusZoneActionLeftArrow;
446
+ nextViewToFocus = [self nextViewToFocusWithFallback:horizontalAction considerCircular:NO];
447
+ }
448
+ }
449
+
450
+ if (nextViewToFocus == nil && shouldTryCircular)
451
+ {
452
+ nextViewToFocus = [self nextViewToFocusForCircularAction:action];
453
+
454
+ if (nextViewToFocus == firstResponder)
455
+ {
456
+ nextViewToFocus = isHorizontal ?
457
+ [self nextViewToFocusForCircularAction:isAdvance ? FocusZoneActionDownArrow : FocusZoneActionUpArrow] :
458
+ [self nextViewToFocusForCircularAction:isAdvance ? FocusZoneActionRightArrow : FocusZoneActionLeftArrow];
459
+ }
460
+
461
+ if (nextViewToFocus == firstResponder)
462
+ {
463
+ nextViewToFocus = nil;
379
464
  }
380
465
  }
381
466
 
@@ -440,29 +525,42 @@ static BOOL ShouldSkipFocusZone(NSView *view)
440
525
  {
441
526
  FocusZoneAction action = GetActionForEvent(event);
442
527
  FocusZoneDirection focusZoneDirection = [self focusZoneDirection];
528
+ NSString *navigateAtEnd = [self navigateAtEnd];
529
+ NSString *tabKeyNavigation = [self tabKeyNavigation];
530
+
531
+ BOOL tabAllowed = [@"NavigateWrap" isEqual:tabKeyNavigation]
532
+ || [@"NavigateStopAtEnds" isEqual:tabKeyNavigation]
533
+ || [@"Normal" isEqual:tabKeyNavigation];
443
534
 
444
535
  BOOL passthrough = NO;
445
536
  NSView *viewToFocus = nil;
446
-
447
- if ([self disabled] || action == FocusZoneActionNone)
537
+ if ([self disabled] || action == FocusZoneActionNone
538
+ || (focusZoneDirection == FocusZoneDirectionVertical
539
+ && (action == FocusZoneActionRightArrow || action == FocusZoneActionLeftArrow))
540
+ || (focusZoneDirection == FocusZoneDirectionHorizontal
541
+ && (action == FocusZoneActionUpArrow || action == FocusZoneActionDownArrow)))
448
542
  {
449
543
  passthrough = YES;
450
544
  }
451
- else if (action == FocusZoneActionTab || action == FocusZoneActionShiftTab)
545
+ else if (!tabAllowed && (action == FocusZoneActionTab || action == FocusZoneActionShiftTab))
452
546
  {
453
547
  viewToFocus = [self nextViewToFocusOutsideZone:action];
454
548
  }
455
- else if ((focusZoneDirection == FocusZoneDirectionVertical
456
- && (action == FocusZoneActionRightArrow || action == FocusZoneActionLeftArrow))
457
- || (focusZoneDirection == FocusZoneDirectionHorizontal
458
- && (action == FocusZoneActionUpArrow || action == FocusZoneActionDownArrow))
459
- || (focusZoneDirection == FocusZoneDirectionNone))
460
- {
461
- passthrough = YES;
462
- }
463
549
  else
464
550
  {
465
- viewToFocus = [self nextViewToFocusWithFallback:action];
551
+ FocusZoneAction directionalAction = action == FocusZoneActionTab ? FocusZoneActionDownArrow
552
+ : (action == FocusZoneActionShiftTab ? FocusZoneActionUpArrow : action);
553
+
554
+ BOOL allowCircular = [@"NavigateWrap" isEqual:action == FocusZoneActionTab || action == FocusZoneActionShiftTab
555
+ ? tabKeyNavigation : navigateAtEnd];
556
+
557
+ viewToFocus = [self nextViewToFocusWithFallback:directionalAction considerCircular:allowCircular];
558
+
559
+ if (viewToFocus == nil && action != directionalAction && [@"Normal" isEqual:tabKeyNavigation]) // tab, shift+tab
560
+ {
561
+ // didn't find a view IN the zone -- look outside
562
+ viewToFocus = [self nextViewToFocusOutsideZone:action];
563
+ }
466
564
  }
467
565
 
468
566
  if (viewToFocus != nil)
@@ -478,14 +576,4 @@ static BOOL ShouldSkipFocusZone(NSView *view)
478
576
  }
479
577
  }
480
578
 
481
- - (void)setNavigateAtEnd:(NSString *)value
482
- {
483
- // do nothing
484
- }
485
-
486
- - (NSString *)navigateAtEnd
487
- {
488
- return @"NavigateStopAtEnds";
489
- }
490
-
491
579
  @end
@@ -34,6 +34,7 @@ RCT_CUSTOM_VIEW_PROPERTY(focusZoneDirection, NSString, RCTFocusZone)
34
34
  }
35
35
 
36
36
  RCT_EXPORT_VIEW_PROPERTY(navigateAtEnd, NSString)
37
+ RCT_EXPORT_VIEW_PROPERTY(tabKeyNavigation, NSString)
37
38
 
38
39
  RCT_CUSTOM_VIEW_PROPERTY(defaultTabbableElement, NSNumber, RCTFocusZone)
39
40
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/focus-zone",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "A cross-platform FocusZone component using the Fluent Design System",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -39,7 +39,6 @@ export type FocusZoneProps = React.PropsWithChildren<{
39
39
  use2DNavigation?: boolean;
40
40
 
41
41
  /**
42
- * @platform win32
43
42
  * By default, pressing Tab within a FocusZone moves focus out of the FocusZone.
44
43
  * This prop allows you to change that behavior.
45
44
  *