@kouji-ui/core 0.6.0 → 0.6.1
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.
|
@@ -3613,6 +3613,18 @@ class KjRovingTabindexItemDirective {
|
|
|
3613
3613
|
/** @internal */
|
|
3614
3614
|
active = signal(false, /* @ts-ignore */
|
|
3615
3615
|
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
3616
|
+
constructor() {
|
|
3617
|
+
// Registration is by DI, NOT by a content query on the container: a styled
|
|
3618
|
+
// wrapper (`<kj-tab>`) renders its item inside its OWN view, and a content
|
|
3619
|
+
// query cannot cross that boundary. Querying left every item at
|
|
3620
|
+
// tabindex="-1" whenever the wrappers were used — i.e. in every app — so
|
|
3621
|
+
// the tab strip could not be reached by keyboard at all.
|
|
3622
|
+
const parent = inject(KJ_ROVING_TABINDEX, { optional: true });
|
|
3623
|
+
if (!parent)
|
|
3624
|
+
return;
|
|
3625
|
+
parent.register(this);
|
|
3626
|
+
inject(DestroyRef).onDestroy(() => parent.unregister(this));
|
|
3627
|
+
}
|
|
3616
3628
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: KjRovingTabindexItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3617
3629
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.5", type: KjRovingTabindexItemDirective, isStandalone: true, selector: "[kjRovingTabindexItem]", host: { properties: { "attr.tabindex": "active() ? \"0\" : \"-1\"" } }, ngImport: i0 });
|
|
3618
3630
|
}
|
|
@@ -3625,7 +3637,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
3625
3637
|
'[attr.tabindex]': 'active() ? "0" : "-1"',
|
|
3626
3638
|
},
|
|
3627
3639
|
}]
|
|
3628
|
-
}] });
|
|
3640
|
+
}], ctorParameters: () => [] });
|
|
3629
3641
|
/**
|
|
3630
3642
|
* Implements the roving tabindex pattern for composite widgets such as toolbars and tab lists.
|
|
3631
3643
|
* Only one item has `tabindex="0"` at a time; arrow keys move focus between items.
|
|
@@ -3643,9 +3655,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
3643
3655
|
*/
|
|
3644
3656
|
class KjRovingTabindex {
|
|
3645
3657
|
host = inject((ElementRef));
|
|
3646
|
-
|
|
3658
|
+
registered = signal([], /* @ts-ignore */
|
|
3659
|
+
...(ngDevMode ? [{ debugName: "registered" }] : /* istanbul ignore next */ []));
|
|
3660
|
+
/** Items in DOM order — registration order follows creation, which a
|
|
3661
|
+
* re-order (`@for` with a changing track) does not preserve. */
|
|
3662
|
+
items = computed(() => [...this.registered()].sort((a, b) => a.el.nativeElement.compareDocumentPosition(b.el.nativeElement) &
|
|
3663
|
+
Node.DOCUMENT_POSITION_FOLLOWING
|
|
3664
|
+
? -1
|
|
3665
|
+
: 1), /* @ts-ignore */
|
|
3666
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
3647
3667
|
activeIndex = signal(0, /* @ts-ignore */
|
|
3648
3668
|
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
3669
|
+
/** @internal */
|
|
3670
|
+
register(item) {
|
|
3671
|
+
this.registered.update((all) => [...all, item]);
|
|
3672
|
+
}
|
|
3673
|
+
/** @internal */
|
|
3674
|
+
unregister(item) {
|
|
3675
|
+
this.registered.update((all) => all.filter((i) => i !== item));
|
|
3676
|
+
}
|
|
3649
3677
|
/**
|
|
3650
3678
|
* Restricts arrow-key navigation to a single axis.
|
|
3651
3679
|
* - `'horizontal'`: only ArrowLeft / ArrowRight move focus.
|
|
@@ -3726,7 +3754,7 @@ class KjRovingTabindex {
|
|
|
3726
3754
|
all[next].el.nativeElement.focus();
|
|
3727
3755
|
}
|
|
3728
3756
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: KjRovingTabindex, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3729
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.
|
|
3757
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", type: KjRovingTabindex, isStandalone: true, selector: "[kjRovingTabindex]", inputs: { kjRovingOrientation: { classPropertyName: "kjRovingOrientation", publicName: "kjRovingOrientation", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keydown": "onKeydown($event)", "focusin": "onFocusIn($event)" } }, providers: [{ provide: KJ_ROVING_TABINDEX, useExisting: forwardRef(() => KjRovingTabindex) }], ngImport: i0 });
|
|
3730
3758
|
}
|
|
3731
3759
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: KjRovingTabindex, decorators: [{
|
|
3732
3760
|
type: Directive,
|
|
@@ -3739,9 +3767,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
3739
3767
|
'(focusin)': 'onFocusIn($event)',
|
|
3740
3768
|
},
|
|
3741
3769
|
}]
|
|
3742
|
-
}], ctorParameters: () => [], propDecorators: {
|
|
3743
|
-
descendants: true,
|
|
3744
|
-
}, isSignal: true }] }], kjRovingOrientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjRovingOrientation", required: false }] }] } });
|
|
3770
|
+
}], ctorParameters: () => [], propDecorators: { kjRovingOrientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjRovingOrientation", required: false }] }] } });
|
|
3745
3771
|
|
|
3746
3772
|
/**
|
|
3747
3773
|
* Visually hides an element while keeping it accessible to screen readers.
|