@konce-pt/angular 0.11.1 → 0.11.2

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.
@@ -1,6 +1,6 @@
1
1
  import { NgTemplateOutlet, isPlatformBrowser } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { signal, Injectable, input, inject, ElementRef, effect, isDevMode, ViewEncapsulation, ChangeDetectionStrategy, Component, booleanAttribute, computed, model, output, linkedSignal, InjectionToken, Injector, viewChild, afterNextRender, provideAppInitializer, PLATFORM_ID, DestroyRef, makeEnvironmentProviders, contentChild, forwardRef, untracked, numberAttribute, afterRenderEffect, Directive, TemplateRef, viewChildren, contentChildren } from '@angular/core';
3
+ import { signal, Injectable, input, inject, ElementRef, effect, isDevMode, ViewEncapsulation, ChangeDetectionStrategy, Component, booleanAttribute, computed, afterRenderEffect, Directive, model, output, linkedSignal, InjectionToken, Injector, viewChild, afterNextRender, provideAppInitializer, PLATFORM_ID, DestroyRef, makeEnvironmentProviders, contentChild, forwardRef, untracked, numberAttribute, TemplateRef, viewChildren, contentChildren } from '@angular/core';
4
4
  import { KPT_ICONS, toKptIconRecord, sanitizeSvgFragment, renderKptIconSvg } from '@konce-pt/icons';
5
5
  export { renderKptIconSvg } from '@konce-pt/icons';
6
6
  import { CdkOverlayOrigin, CdkConnectedOverlay, OverlayContainer } from '@angular/cdk/overlay';
@@ -344,6 +344,245 @@ class KptIconButton {
344
344
  }], null, { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], shape: [{ type: i0.Input, args: [{ isSignal: true, alias: "shape", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: true }] }], ariaPressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaPressed", required: false }] }], ariaExpanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaExpanded", required: false }] }] }); })();
345
345
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptIconButton, { className: "KptIconButton", filePath: "lib/icon-button/icon-button.component.ts", lineNumber: 38 }); })();
346
346
 
347
+ /** Elementy, które same przyjmują fokus — na nie trafia `aria-describedby`. */
348
+ const FOCUSABLE$3 = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])';
349
+ /** Ile czasu ma wskaźnik na przejście z hosta na dymek, zanim ten zniknie (WCAG 1.4.13). */
350
+ const HIDE_DELAY_MS = 120;
351
+ let nextId$l = 0;
352
+ /** Strona przeciwna i dwie boczne — kolejność prób, gdy zadana strona się nie nadaje. */
353
+ const FALLBACKS = {
354
+ top: ['top', 'bottom', 'right', 'left'],
355
+ bottom: ['bottom', 'top', 'right', 'left'],
356
+ left: ['left', 'right', 'top', 'bottom'],
357
+ right: ['right', 'left', 'top', 'bottom'],
358
+ };
359
+ /**
360
+ * Ustawia dymek przy hoście, na pierwszej stronie z `FALLBACKS`, która się nadaje: dymek mieści się
361
+ * w oknie, a krawędź hosta od tej strony nie jest niczym przykryta (przyklejony nagłówek, menu, panel
362
+ * — sprawdzane `elementFromPoint` tuż przy krawędzi). Bez tego dymek przycisku wsuniętego pod
363
+ * nagłówek wyskakiwał nad nagłówkiem, odcięty od tego, co opisuje. Gdy żadna strona się nie nadaje,
364
+ * zostaje zadana. Na koniec dymek jest dociśnięty do okna z marginesem 4 px.
365
+ * Bliźniak tej funkcji żyje w drugim porcie — zmiany w obu naraz.
366
+ */
367
+ function placeTooltip(host, tip, preferred) {
368
+ const r = host.getBoundingClientRect();
369
+ const t = tip.getBoundingClientRect();
370
+ const gap = 8;
371
+ const margin = 4;
372
+ const vw = document.documentElement.clientWidth;
373
+ const vh = document.documentElement.clientHeight;
374
+ const at = (side) => {
375
+ switch (side) {
376
+ case 'bottom':
377
+ return { top: r.bottom + gap, left: r.left + r.width / 2 - t.width / 2 };
378
+ case 'left':
379
+ return { top: r.top + r.height / 2 - t.height / 2, left: r.left - t.width - gap };
380
+ case 'right':
381
+ return { top: r.top + r.height / 2 - t.height / 2, left: r.right + gap };
382
+ default:
383
+ return { top: r.top - t.height - gap, left: r.left + r.width / 2 - t.width / 2 };
384
+ }
385
+ };
386
+ const fits = (side) => {
387
+ const { top, left } = at(side);
388
+ // Po osi poprzecznej dymek i tak zostanie dociśnięty do okna — liczy się tylko oś strony.
389
+ return side === 'top' || side === 'bottom'
390
+ ? top >= margin && top + t.height <= vh - margin
391
+ : left >= margin && left + t.width <= vw - margin;
392
+ };
393
+ // Punkt 2 px w głąb hosta przy krawędzi danej strony; widoczny, gdy na wierzchu jest host, jego
394
+ // potomek albo sam dymek (stoi jeszcze w poprzednim miejscu).
395
+ const exposed = (side) => {
396
+ const x = side === 'left' ? r.left + 2 : side === 'right' ? r.right - 2 : r.left + r.width / 2;
397
+ const y = side === 'top' ? r.top + 2 : side === 'bottom' ? r.bottom - 2 : r.top + r.height / 2;
398
+ if (x < 0 || y < 0 || x >= vw || y >= vh)
399
+ return false;
400
+ const hit = document.elementFromPoint(x, y);
401
+ return !hit || host.contains(hit) || tip.contains(hit);
402
+ };
403
+ const side = FALLBACKS[preferred].find((s) => fits(s) && exposed(s)) ?? preferred;
404
+ const { top, left } = at(side);
405
+ tip.dataset['side'] = side;
406
+ tip.style.top = `${Math.min(Math.max(margin, top), Math.max(margin, vh - t.height - margin))}px`;
407
+ tip.style.left = `${Math.min(Math.max(margin, left), Math.max(margin, vw - t.width - margin))}px`;
408
+ }
409
+ /**
410
+ * Dymek podpowiedzi (tooltip) pokazywany na hover/focus hosta. Lekki — element dodawany
411
+ * do `body` i pozycjonowany względem hosta (działa w trybie zoneless).
412
+ *
413
+ * Dostępność:
414
+ * - fokus łapiemy przez `focusin`/`focusout`, bo `focus`/`blur` nie bąbelkują — na
415
+ * `kpt-button` czy `kpt-icon-button` fokus dostaje wewnętrzny `<button>`, nie host;
416
+ * - tekst trafia do czytników przez trwały, ukryty opis powiązany `aria-describedby`
417
+ * z elementem, który faktycznie przyjmuje fokus (sam dymek powstaje dopiero przy pokazaniu,
418
+ * więc nie da się go wskazać wcześniej). Opisu nie dodajemy, gdy powtarzałby nazwę elementu
419
+ * albo przy `kptTooltipOnlyWhenTruncated` — tam dymek pokazuje tekst, który i tak jest w DOM-ie;
420
+ * - `Escape` zamyka dymek, a wskaźnik może na niego przejść bez zniknięcia (WCAG 1.4.13).
421
+ *
422
+ * @example
423
+ * <kpt-button kptTooltip="Zapisz zmiany" kptTooltipPosition="bottom">Zapisz</kpt-button>
424
+ *
425
+ * @example Dymek tylko wtedy, gdy tekst nie mieści się w elemencie:
426
+ * <span class="ellipsis" [kptTooltip]="name" kptTooltipOnlyWhenTruncated>{{ name }}</span>
427
+ */
428
+ class KptTooltip {
429
+ constructor() {
430
+ this.text = input.required({ ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'kptTooltip' });
431
+ this.position = input('top', { ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), alias: 'kptTooltipPosition' });
432
+ this.onlyWhenTruncated = input(false, { ...(ngDevMode ? { debugName: "onlyWhenTruncated" } : /* istanbul ignore next */ {}), alias: 'kptTooltipOnlyWhenTruncated',
433
+ transform: booleanAttribute });
434
+ this.host = inject(ElementRef);
435
+ this.descId = `kpt-tooltip-desc-${++nextId$l}`;
436
+ this.follow = () => this.reposition();
437
+ this.onKeydown = (event) => {
438
+ if (event.key === 'Escape')
439
+ this.hide();
440
+ };
441
+ // Po renderze, bo wewnętrzny `<button>` komponentu-hosta istnieje dopiero wtedy.
442
+ // Efekt czyta `text()` i `onlyWhenTruncated()`, więc zmiana treści aktualizuje opis.
443
+ afterRenderEffect(() => this.syncDescription(this.text(), this.onlyWhenTruncated()));
444
+ }
445
+ show() {
446
+ this.cancelHide();
447
+ if (this.tip || !this.text())
448
+ return;
449
+ // Sprawdzamy dopiero teraz, a nie przy renderze: dzięki temu wynik jest zawsze
450
+ // aktualny po zmianie szerokości czy powiększenia, bez żadnych obserwatorów.
451
+ if (this.onlyWhenTruncated() && !this.isTruncated())
452
+ return;
453
+ const tip = document.createElement('div');
454
+ tip.className = 'kpt-tooltip';
455
+ tip.setAttribute('role', 'tooltip');
456
+ // Treść czytnik dostaje z trwałego opisu — dymek by ją zdublował.
457
+ if (this.desc)
458
+ tip.setAttribute('aria-hidden', 'true');
459
+ tip.textContent = this.text();
460
+ tip.style.cssText =
461
+ 'position:fixed;z-index:1400;max-width:16rem;padding:0.35rem 0.6rem;' +
462
+ 'border-radius:var(--kpt-radius-sm,0.25rem);font-size:var(--kpt-font-size-xs,0.75rem);' +
463
+ 'line-height:1.4;background:var(--kpt-color-on-surface);color:var(--kpt-color-surface);' +
464
+ 'box-shadow:var(--kpt-elevation-2);opacity:0;transition:opacity 120ms;';
465
+ // Wskaźnik może przejść na dymek (np. żeby go powiększyć lupą) — wtedy dymek zostaje.
466
+ tip.addEventListener('mouseenter', () => this.cancelHide());
467
+ tip.addEventListener('mouseleave', () => this.scheduleHide());
468
+ document.body.appendChild(tip);
469
+ this.tip = tip;
470
+ this.reposition();
471
+ // Faza przechwytywania łapie także przewijanie zagnieżdżonych kontenerów
472
+ // (np. osi roadmapy), bo zdarzenie `scroll` elementu się nie propaguje.
473
+ window.addEventListener('scroll', this.follow, true);
474
+ window.addEventListener('resize', this.follow);
475
+ document.addEventListener('keydown', this.onKeydown);
476
+ requestAnimationFrame(() => {
477
+ if (this.tip)
478
+ this.tip.style.opacity = '1';
479
+ });
480
+ }
481
+ /** Fokus przeszedł do innego elementu w obrębie hosta — dymek zostaje. */
482
+ onFocusOut(event) {
483
+ const next = event.relatedTarget;
484
+ if (next && this.host.nativeElement.contains(next))
485
+ return;
486
+ this.hide();
487
+ }
488
+ scheduleHide() {
489
+ this.cancelHide();
490
+ this.hideTimer = setTimeout(() => this.hide(), HIDE_DELAY_MS);
491
+ }
492
+ cancelHide() {
493
+ if (this.hideTimer !== undefined)
494
+ clearTimeout(this.hideTimer);
495
+ this.hideTimer = undefined;
496
+ }
497
+ hide() {
498
+ this.cancelHide();
499
+ window.removeEventListener('scroll', this.follow, true);
500
+ window.removeEventListener('resize', this.follow);
501
+ document.removeEventListener('keydown', this.onKeydown);
502
+ this.tip?.remove();
503
+ this.tip = undefined;
504
+ }
505
+ /** Trwały opis dla czytników albo jego usunięcie, gdy nie jest potrzebny. */
506
+ syncDescription(text, onlyWhenTruncated) {
507
+ const target = this.focusTarget();
508
+ const name = (target.getAttribute('aria-label') ?? target.textContent ?? '').trim();
509
+ if (!text || onlyWhenTruncated || name === text.trim()) {
510
+ this.removeDescription();
511
+ return;
512
+ }
513
+ if (!this.desc) {
514
+ const desc = document.createElement('span');
515
+ desc.id = this.descId;
516
+ desc.hidden = true;
517
+ document.body.appendChild(desc);
518
+ this.desc = desc;
519
+ }
520
+ this.desc.textContent = text;
521
+ if (this.describedEl !== target) {
522
+ this.unlink();
523
+ const ids = (target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean);
524
+ if (!ids.includes(this.descId))
525
+ ids.push(this.descId);
526
+ target.setAttribute('aria-describedby', ids.join(' '));
527
+ this.describedEl = target;
528
+ }
529
+ }
530
+ removeDescription() {
531
+ this.unlink();
532
+ this.desc?.remove();
533
+ this.desc = undefined;
534
+ }
535
+ unlink() {
536
+ const el = this.describedEl;
537
+ if (!el)
538
+ return;
539
+ const ids = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((id) => id && id !== this.descId);
540
+ if (ids.length)
541
+ el.setAttribute('aria-describedby', ids.join(' '));
542
+ else
543
+ el.removeAttribute('aria-describedby');
544
+ this.describedEl = undefined;
545
+ }
546
+ /** Host, jeśli sam przyjmuje fokus, inaczej pierwsza kontrolka w środku, a w ostateczności host. */
547
+ focusTarget() {
548
+ const root = this.host.nativeElement;
549
+ if (root.matches(FOCUSABLE$3))
550
+ return root;
551
+ return root.querySelector(FOCUSABLE$3) ?? root;
552
+ }
553
+ isTruncated() {
554
+ const root = this.host.nativeElement;
555
+ const overflows = (el) =>
556
+ // Tolerancja 1 px pochłania zaokrąglenia subpikselowe przy skalowaniu.
557
+ el.scrollWidth > el.clientWidth + 1 || el.scrollHeight > el.clientHeight + 1;
558
+ return overflows(root) || Array.from(root.children).some(overflows);
559
+ }
560
+ reposition() {
561
+ if (this.tip)
562
+ placeTooltip(this.host.nativeElement, this.tip, this.position());
563
+ }
564
+ ngOnDestroy() {
565
+ this.hide();
566
+ this.removeDescription();
567
+ }
568
+ static { this.ɵfac = function KptTooltip_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || KptTooltip)(); }; }
569
+ static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: KptTooltip, selectors: [["", "kptTooltip", ""]], hostBindings: function KptTooltip_HostBindings(rf, ctx) { if (rf & 1) {
570
+ i0.ɵɵlistener("mouseenter", function KptTooltip_mouseenter_HostBindingHandler() { return ctx.show(); })("mouseleave", function KptTooltip_mouseleave_HostBindingHandler() { return ctx.scheduleHide(); })("focusin", function KptTooltip_focusin_HostBindingHandler() { return ctx.show(); })("focusout", function KptTooltip_focusout_HostBindingHandler($event) { return ctx.onFocusOut($event); });
571
+ } }, inputs: { text: [1, "kptTooltip", "text"], position: [1, "kptTooltipPosition", "position"], onlyWhenTruncated: [1, "kptTooltipOnlyWhenTruncated", "onlyWhenTruncated"] } }); }
572
+ }
573
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(KptTooltip, [{
574
+ type: Directive,
575
+ args: [{
576
+ selector: '[kptTooltip]',
577
+ host: {
578
+ '(mouseenter)': 'show()',
579
+ '(mouseleave)': 'scheduleHide()',
580
+ '(focusin)': 'show()',
581
+ '(focusout)': 'onFocusOut($event)',
582
+ },
583
+ }]
584
+ }], () => [], { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "kptTooltip", required: true }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "kptTooltipPosition", required: false }] }], onlyWhenTruncated: [{ type: i0.Input, args: [{ isSignal: true, alias: "kptTooltipOnlyWhenTruncated", required: false }] }] }); })();
585
+
347
586
  const _forTrack0$f = ($index, $item) => $item.value;
348
587
  function KptButtonGroup_For_2_Conditional_1_Template(rf, ctx) { if (rf & 1) {
349
588
  i0.ɵɵelement(0, "kpt-icon", 3);
@@ -371,8 +610,8 @@ function KptButtonGroup_For_2_Template(rf, ctx) { if (rf & 1) {
371
610
  const opt_r2 = ctx.$implicit;
372
611
  const ctx_r2 = i0.ɵɵnextContext();
373
612
  i0.ɵɵclassProp("is-active", opt_r2.value === ctx_r2.value());
374
- i0.ɵɵproperty("disabled", ctx_r2.disabled() || opt_r2.disabled);
375
- i0.ɵɵattribute("aria-pressed", opt_r2.value === ctx_r2.value())("aria-label", ctx_r2.iconOnly() ? opt_r2.label : null)("title", ctx_r2.iconOnly() ? opt_r2.label : null);
613
+ i0.ɵɵproperty("disabled", ctx_r2.disabled() || opt_r2.disabled)("kptTooltip", ctx_r2.iconOnly() ? opt_r2.label : "");
614
+ i0.ɵɵattribute("aria-pressed", opt_r2.value === ctx_r2.value())("aria-label", ctx_r2.iconOnly() ? opt_r2.label : null);
376
615
  i0.ɵɵadvance();
377
616
  i0.ɵɵconditional(opt_r2.icon ? 1 : -1);
378
617
  i0.ɵɵadvance();
@@ -382,7 +621,7 @@ function KptButtonGroup_For_2_Template(rf, ctx) { if (rf & 1) {
382
621
  * Segmentowana grupa przycisków (toggle) — pojedynczy wybór z opcji. Signal Forms.
383
622
  *
384
623
  * Pozycja może mieć ikonę (`KptOption.icon`); `iconOnly` chowa etykietę, ale zostawia ją
385
- * w nazwie dostępnej, więc czytnik ekranu dalej wie, co wybiera.
624
+ * w nazwie dostępnej, więc czytnik ekranu dalej wie, co wybiera, a myszka dostaje `kptTooltip`.
386
625
  *
387
626
  * @example
388
627
  * <kpt-button-group [(value)]="view" [options]="[{label:'Lista',value:'list'},{label:'Siatka',value:'grid'}]" />
@@ -400,7 +639,7 @@ class KptButtonGroup {
400
639
  this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
401
640
  this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
402
641
  this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
403
- /** Chowa etykiety — zostaje sama ikona, a `label` zasila `aria-label` i `title`. */
642
+ /** Chowa etykiety — zostaje sama ikona, a `label` zasila `aria-label` i dymek `kptTooltip`. */
404
643
  this.iconOnly = input(false, { ...(ngDevMode ? { debugName: "iconOnly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
405
644
  this.touch = output();
406
645
  }
@@ -411,7 +650,7 @@ class KptButtonGroup {
411
650
  this.touch.emit();
412
651
  }
413
652
  static { this.ɵfac = function KptButtonGroup_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || KptButtonGroup)(); }; }
414
- static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: KptButtonGroup, selectors: [["kpt-button-group"]], hostAttrs: [1, "kpt-button-group-host"], inputs: { options: [1, "options"], value: [1, "value"], size: [1, "size"], disabled: [1, "disabled"], invalid: [1, "invalid"], touched: [1, "touched"], iconOnly: [1, "iconOnly"] }, outputs: { value: "valueChange", touch: "touch" }, decls: 3, vars: 2, consts: [["role", "group", 1, "kpt-button-group"], ["type", "button", 1, "kpt-button-group__item", 3, "is-active", "disabled"], ["type", "button", 1, "kpt-button-group__item", 3, "click", "disabled"], [1, "kpt-button-group__icon", 3, "name"], [1, "kpt-button-group__label"]], template: function KptButtonGroup_Template(rf, ctx) { if (rf & 1) {
653
+ static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: KptButtonGroup, selectors: [["kpt-button-group"]], hostAttrs: [1, "kpt-button-group-host"], inputs: { options: [1, "options"], value: [1, "value"], size: [1, "size"], disabled: [1, "disabled"], invalid: [1, "invalid"], touched: [1, "touched"], iconOnly: [1, "iconOnly"] }, outputs: { value: "valueChange", touch: "touch" }, decls: 3, vars: 2, consts: [["role", "group", 1, "kpt-button-group"], ["type", "button", 1, "kpt-button-group__item", 3, "is-active", "disabled", "kptTooltip"], ["type", "button", 1, "kpt-button-group__item", 3, "click", "disabled", "kptTooltip"], [1, "kpt-button-group__icon", 3, "name"], [1, "kpt-button-group__label"]], template: function KptButtonGroup_Template(rf, ctx) { if (rf & 1) {
415
654
  i0.ɵɵelementStart(0, "div", 0);
416
655
  i0.ɵɵrepeaterCreate(1, KptButtonGroup_For_2_Template, 3, 8, "button", 1, _forTrack0$f);
417
656
  i0.ɵɵelementEnd();
@@ -419,35 +658,35 @@ class KptButtonGroup {
419
658
  i0.ɵɵattribute("data-size", ctx.size())("data-icon-only", ctx.iconOnly() ? "" : null);
420
659
  i0.ɵɵadvance();
421
660
  i0.ɵɵrepeater(ctx.options());
422
- } }, dependencies: [KptIcon], styles: ["@layer kpt.components{.kpt-button-group-host{display:inline-flex}.kpt-button-group{display:inline-flex;border:var(--%NS%kpt-border-width-thin, 1px) solid var(--%NS%kpt-color-border-strong);border-radius:var(--%NS%kpt-radius-md, .5rem);overflow:hidden;background:var(--%NS%kpt-color-surface)}.kpt-button-group__item{appearance:none;border:0;border-inline-start:var(--%NS%kpt-border-width-thin, 1px) solid var(--%NS%kpt-color-border);background:none;color:var(--%NS%kpt-color-on-surface);display:inline-flex;align-items:center;justify-content:center;gap:var(--%NS%kpt-button-gap, .5rem);padding:0 var(--%NS%_px, 1rem);height:var(--%NS%_h, 2.5rem);font:inherit;font-size:var(--%NS%_fs, .875rem);font-weight:var(--%NS%kpt-font-weight-medium, 500);cursor:pointer;transition:background-color var(--%NS%kpt-motion-duration-fast, .12s) var(--%NS%kpt-motion-easing-standard)}.kpt-button-group__item:first-child{border-inline-start:0}.kpt-button-group__item:hover:not(:disabled):not(.is-active){background:var(--%NS%kpt-color-muted)}.kpt-button-group__item.is-active{background:var(--%NS%kpt-color-primary);color:var(--%NS%kpt-color-on-primary)}.kpt-button-group__item:disabled{opacity:.5;cursor:not-allowed}.kpt-button-group__icon{font-size:var(--%NS%_icon, 1.125rem)}.kpt-button-group{--%NS%_h: 2.5rem;--%NS%_px: 1rem;--%NS%_fs: .875rem;--%NS%_icon: 1.125rem}.kpt-button-group[data-size=sm]{--%NS%_h: 2rem;--%NS%_px: .75rem;--%NS%_fs: .8125rem;--%NS%_icon: 1rem}.kpt-button-group[data-size=lg]{--%NS%_h: 3rem;--%NS%_px: 1.5rem;--%NS%_fs: 1rem;--%NS%_icon: 1.25rem}.kpt-button-group[data-icon-only] .kpt-button-group__item{--%NS%_px: 0;width:var(--%NS%_h)}}\n"], encapsulation: 2 }); }
661
+ } }, dependencies: [KptIcon, KptTooltip], styles: ["@layer kpt.components{.kpt-button-group-host{display:inline-flex}.kpt-button-group{display:inline-flex;border:var(--%NS%kpt-border-width-thin, 1px) solid var(--%NS%kpt-color-border-strong);border-radius:var(--%NS%kpt-radius-md, .5rem);overflow:hidden;background:var(--%NS%kpt-color-surface)}.kpt-button-group__item{appearance:none;border:0;border-inline-start:var(--%NS%kpt-border-width-thin, 1px) solid var(--%NS%kpt-color-border);background:none;color:var(--%NS%kpt-color-on-surface);display:inline-flex;align-items:center;justify-content:center;gap:var(--%NS%kpt-button-gap, .5rem);padding:0 var(--%NS%_px, 1rem);height:var(--%NS%_h, 2.5rem);font:inherit;font-size:var(--%NS%_fs, .875rem);font-weight:var(--%NS%kpt-font-weight-medium, 500);cursor:pointer;transition:background-color var(--%NS%kpt-motion-duration-fast, .12s) var(--%NS%kpt-motion-easing-standard)}.kpt-button-group__item:first-child{border-inline-start:0}.kpt-button-group__item:hover:not(:disabled):not(.is-active){background:var(--%NS%kpt-color-muted)}.kpt-button-group__item.is-active{background:var(--%NS%kpt-color-primary);color:var(--%NS%kpt-color-on-primary)}.kpt-button-group__item:disabled{opacity:.5;cursor:not-allowed}.kpt-button-group__icon{font-size:var(--%NS%_icon, 1.125rem)}.kpt-button-group{--%NS%_h: 2.5rem;--%NS%_px: 1rem;--%NS%_fs: .875rem;--%NS%_icon: 1.125rem}.kpt-button-group[data-size=sm]{--%NS%_h: 2rem;--%NS%_px: .75rem;--%NS%_fs: .8125rem;--%NS%_icon: 1rem}.kpt-button-group[data-size=lg]{--%NS%_h: 3rem;--%NS%_px: 1.5rem;--%NS%_fs: 1rem;--%NS%_icon: 1.25rem}.kpt-button-group[data-icon-only] .kpt-button-group__item{--%NS%_px: 0;width:var(--%NS%_h)}}\n"], encapsulation: 2 }); }
423
662
  }
424
663
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(KptButtonGroup, [{
425
664
  type: Component,
426
- args: [{ selector: 'kpt-button-group', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [KptIcon], template: `
427
- <div class="kpt-button-group" role="group" [attr.data-size]="size()" [attr.data-icon-only]="iconOnly() ? '' : null">
428
- @for (opt of options(); track opt.value) {
429
- <button
430
- type="button"
431
- class="kpt-button-group__item"
432
- [class.is-active]="opt.value === value()"
433
- [disabled]="disabled() || opt.disabled"
434
- [attr.aria-pressed]="opt.value === value()"
435
- [attr.aria-label]="iconOnly() ? opt.label : null"
436
- [attr.title]="iconOnly() ? opt.label : null"
437
- (click)="select(opt)"
438
- >
439
- @if (opt.icon) {
440
- <kpt-icon class="kpt-button-group__icon" [name]="opt.icon" />
441
- }
442
- @if (!iconOnly()) {
443
- <span class="kpt-button-group__label">{{ opt.label }}</span>
444
- }
445
- </button>
446
- }
447
- </div>
665
+ args: [{ selector: 'kpt-button-group', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [KptIcon, KptTooltip], template: `
666
+ <div class="kpt-button-group" role="group" [attr.data-size]="size()" [attr.data-icon-only]="iconOnly() ? '' : null">
667
+ @for (opt of options(); track opt.value) {
668
+ <button
669
+ type="button"
670
+ class="kpt-button-group__item"
671
+ [class.is-active]="opt.value === value()"
672
+ [disabled]="disabled() || opt.disabled"
673
+ [attr.aria-pressed]="opt.value === value()"
674
+ [attr.aria-label]="iconOnly() ? opt.label : null"
675
+ [kptTooltip]="iconOnly() ? opt.label : ''"
676
+ (click)="select(opt)"
677
+ >
678
+ @if (opt.icon) {
679
+ <kpt-icon class="kpt-button-group__icon" [name]="opt.icon" />
680
+ }
681
+ @if (!iconOnly()) {
682
+ <span class="kpt-button-group__label">{{ opt.label }}</span>
683
+ }
684
+ </button>
685
+ }
686
+ </div>
448
687
  `, host: { class: 'kpt-button-group-host' }, styles: ["@layer kpt.components{.kpt-button-group-host{display:inline-flex}.kpt-button-group{display:inline-flex;border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border-strong);border-radius:var(--kpt-radius-md, .5rem);overflow:hidden;background:var(--kpt-color-surface)}.kpt-button-group__item{appearance:none;border:0;border-inline-start:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);background:none;color:var(--kpt-color-on-surface);display:inline-flex;align-items:center;justify-content:center;gap:var(--kpt-button-gap, .5rem);padding:0 var(--_px, 1rem);height:var(--_h, 2.5rem);font:inherit;font-size:var(--_fs, .875rem);font-weight:var(--kpt-font-weight-medium, 500);cursor:pointer;transition:background-color var(--kpt-motion-duration-fast, .12s) var(--kpt-motion-easing-standard)}.kpt-button-group__item:first-child{border-inline-start:0}.kpt-button-group__item:hover:not(:disabled):not(.is-active){background:var(--kpt-color-muted)}.kpt-button-group__item.is-active{background:var(--kpt-color-primary);color:var(--kpt-color-on-primary)}.kpt-button-group__item:disabled{opacity:.5;cursor:not-allowed}.kpt-button-group__icon{font-size:var(--_icon, 1.125rem)}.kpt-button-group{--_h: 2.5rem;--_px: 1rem;--_fs: .875rem;--_icon: 1.125rem}.kpt-button-group[data-size=sm]{--_h: 2rem;--_px: .75rem;--_fs: .8125rem;--_icon: 1rem}.kpt-button-group[data-size=lg]{--_h: 3rem;--_px: 1.5rem;--_fs: 1rem;--_icon: 1.25rem}.kpt-button-group[data-icon-only] .kpt-button-group__item{--_px: 0;width:var(--_h)}}\n"] }]
449
688
  }], null, { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], iconOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconOnly", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }] }); })();
450
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptButtonGroup, { className: "KptButtonGroup", filePath: "lib/button-group/button-group.component.ts", lineNumber: 56 }); })();
689
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptButtonGroup, { className: "KptButtonGroup", filePath: "lib/button-group/button-group.component.ts", lineNumber: 57 }); })();
451
690
 
452
691
  const _c0$P = ["*"];
453
692
  /**
@@ -948,7 +1187,7 @@ function KptSplitButton_ng_template_7_Template(rf, ctx) { if (rf & 1) {
948
1187
  i0.ɵɵadvance(2);
949
1188
  i0.ɵɵrepeater(ctx_r1.items());
950
1189
  } }
951
- let nextId$l = 0;
1190
+ let nextId$k = 0;
952
1191
  /**
953
1192
  * Przycisk dzielony (split button) — akcja główna + rozwijane menu dodatkowych akcji.
954
1193
  * Wymaga `import '@angular/cdk/overlay-prebuilt.css';`
@@ -968,7 +1207,7 @@ class KptSplitButton {
968
1207
  this.i18n = inject(KptI18n);
969
1208
  this.open = signal(false, /* @ts-ignore */
970
1209
  ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
971
- this.panelId = `kpt-split-button-menu-${(nextId$l += 1)}`;
1210
+ this.panelId = `kpt-split-button-menu-${(nextId$k += 1)}`;
972
1211
  this.injector = inject(Injector);
973
1212
  this.toggleBtn = viewChild.required('toggleBtn', /* @ts-ignore */
974
1213
  ...(ngDevMode ? [{ debugName: "toggleBtn" }] : /* istanbul ignore next */ []));
@@ -1280,7 +1519,7 @@ function KptChip_Conditional_3_Template(rf, ctx) { if (rf & 1) {
1280
1519
  i0.ɵɵproperty("id", ctx_r1.removeId)("disabled", ctx_r1.disabled());
1281
1520
  i0.ɵɵattribute("aria-label", ctx_r1.i18n.t("common.remove"))("aria-labelledby", ctx_r1.removeId + " " + ctx_r1.labelId);
1282
1521
  } }
1283
- let nextId$k = 0;
1522
+ let nextId$j = 0;
1284
1523
  /**
1285
1524
  * Chip / tag — etykieta, opcjonalnie usuwalna.
1286
1525
  *
@@ -1304,7 +1543,7 @@ class KptChip {
1304
1543
  this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1305
1544
  this.removed = output();
1306
1545
  this.i18n = inject(KptI18n);
1307
- this.uid = (nextId$k += 1);
1546
+ this.uid = (nextId$j += 1);
1308
1547
  this.labelId = `kpt-chip-label-${this.uid}`;
1309
1548
  this.removeId = `kpt-chip-remove-${this.uid}`;
1310
1549
  }
@@ -1658,7 +1897,7 @@ const KPT_FORM_FIELD_CONTROL = new InjectionToken('KPT_FORM_FIELD_CONTROL');
1658
1897
 
1659
1898
  /** Token DI kontekstu pola — dostarcza go `kpt-form-field` swojej zawartości. */
1660
1899
  const KPT_FORM_FIELD = new InjectionToken('KPT_FORM_FIELD');
1661
- let nextId$j = 0;
1900
+ let nextId$i = 0;
1662
1901
  /**
1663
1902
  * Wiąże kontrolkę z otaczającym `kpt-form-field`. Wołać w kontekście wstrzykiwania (pole klasy
1664
1903
  * komponentu). Poza wrapperem zwraca samo `id` (własne albo wygenerowane) i puste powiązania.
@@ -1670,7 +1909,7 @@ let nextId$j = 0;
1670
1909
  */
1671
1910
  function kptFieldA11y(ownId, prefix) {
1672
1911
  const field = inject(KPT_FORM_FIELD, { optional: true });
1673
- const fallback = `${prefix}-${(nextId$j += 1)}`;
1912
+ const fallback = `${prefix}-${(nextId$i += 1)}`;
1674
1913
  const id = computed(() => ownId() || field?.explicitId() || fallback, /* @ts-ignore */
1675
1914
  ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
1676
1915
  if (field) {
@@ -1741,7 +1980,7 @@ function KptFormField_Conditional_6_Template(rf, ctx) { if (rf & 1) {
1741
1980
  i0.ɵɵadvance();
1742
1981
  i0.ɵɵtextInterpolate(ctx_r0.hint());
1743
1982
  } }
1744
- let nextId$i = 0;
1983
+ let nextId$h = 0;
1745
1984
  /**
1746
1985
  * Wrapper pola formularza: etykieta, podpowiedź i komunikat błędu wokół dowolnej
1747
1986
  * kontrolki (np. `kpt-input`). Prezentacyjny — stan błędu przekazuje się przez `error`
@@ -1798,7 +2037,7 @@ class KptFormField {
1798
2037
  this.labelType = input('fixed', /* @ts-ignore */
1799
2038
  ...(ngDevMode ? [{ debugName: "labelType" }] : /* istanbul ignore next */ []));
1800
2039
  this.host = inject(ElementRef);
1801
- this.uid = `kpt-form-field-${(nextId$i += 1)}`;
2040
+ this.uid = `kpt-form-field-${(nextId$h += 1)}`;
1802
2041
  this.labelElId = `${this.uid}-label`;
1803
2042
  this.messageId = `${this.uid}-message`;
1804
2043
  this.registry = createControlRegistry();
@@ -2618,7 +2857,7 @@ function KptSelect_ng_template_8_Template(rf, ctx) { if (rf & 1) {
2618
2857
  i0.ɵɵadvance();
2619
2858
  i0.ɵɵrepeater(ctx_r2.filteredOptions());
2620
2859
  } }
2621
- let nextId$h = 0;
2860
+ let nextId$g = 0;
2622
2861
  /**
2623
2862
  * Lista wyboru (select) na własnym panelu (CDK Overlay), zintegrowana z Signal Forms.
2624
2863
  * Warianty: pojedynczy, z wyszukiwarką (`filter`) i wielokrotny (`multiple`, chipy).
@@ -2673,7 +2912,7 @@ class KptSelect {
2673
2912
  ...(ngDevMode ? [{ debugName: "filterText" }] : /* istanbul ignore next */ []));
2674
2913
  this.activeIndex = signal(-1, /* @ts-ignore */
2675
2914
  ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
2676
- this.uid = (nextId$h += 1);
2915
+ this.uid = (nextId$g += 1);
2677
2916
  this.listId = `kpt-select-list-${this.uid}`;
2678
2917
  this.triggerEl = viewChild('triggerEl', /* @ts-ignore */
2679
2918
  ...(ngDevMode ? [{ debugName: "triggerEl" }] : /* istanbul ignore next */ []));
@@ -3140,10 +3379,10 @@ class KptClock {
3140
3379
  *
3141
3380
  * Bliźniak w porcie React: `internal/calendar-focus.ts` — zmiana zachowania w obu.
3142
3381
  */
3143
- const FOCUSABLE$3 = 'button:not(:disabled):not([tabindex="-1"]), input:not(:disabled), [tabindex="0"]';
3382
+ const FOCUSABLE$2 = 'button:not(:disabled):not([tabindex="-1"]), input:not(:disabled), [tabindex="0"]';
3144
3383
  /** Zawija `Tab` / `Shift+Tab` w obrębie `panel`. */
3145
3384
  function trapTab(panel, event) {
3146
- const items = [...panel.querySelectorAll(FOCUSABLE$3)].filter((el) => el.offsetParent !== null);
3385
+ const items = [...panel.querySelectorAll(FOCUSABLE$2)].filter((el) => el.offsetParent !== null);
3147
3386
  if (!items.length)
3148
3387
  return;
3149
3388
  const first = items[0];
@@ -3449,7 +3688,7 @@ function KptDatepicker_ng_template_8_Template(rf, ctx) { if (rf & 1) {
3449
3688
  i0.ɵɵadvance(2);
3450
3689
  i0.ɵɵconditional(ctx_r0.hasFooter() ? 3 : -1);
3451
3690
  } }
3452
- let nextId$g = 0;
3691
+ let nextId$f = 0;
3453
3692
  /**
3454
3693
  * Wybór daty/godziny z własnym kalendarzem (CDK Overlay), Signal Forms.
3455
3694
  * Granulacja przez `selectionMode`: data, miesiąc+rok, rok, miesiąc, data+godzina, sama godzina.
@@ -3546,7 +3785,7 @@ class KptDatepicker {
3546
3785
  ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
3547
3786
  this.today = new Date();
3548
3787
  this.todayIso = toIso(this.today);
3549
- this.uid = (nextId$g += 1);
3788
+ this.uid = (nextId$f += 1);
3550
3789
  this.panelId = `kpt-datepicker-panel-${this.uid}`;
3551
3790
  this.triggerEl = viewChild('triggerEl', /* @ts-ignore */
3552
3791
  ...(ngDevMode ? [{ debugName: "triggerEl" }] : /* istanbul ignore next */ []));
@@ -4148,213 +4387,6 @@ class KptTextarea {
4148
4387
  }], () => [], { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], autoResize: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoResize", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], maxLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxLength", required: false }] }], counter: [{ type: i0.Input, args: [{ isSignal: true, alias: "counter", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], ta: [{ type: i0.ViewChild, args: ['ta', { isSignal: true }] }] }); })();
4149
4388
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptTextarea, { className: "KptTextarea", filePath: "lib/textarea/textarea.component.ts", lineNumber: 56 }); })();
4150
4389
 
4151
- /** Elementy, które same przyjmują fokus — na nie trafia `aria-describedby`. */
4152
- const FOCUSABLE$2 = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])';
4153
- /** Ile czasu ma wskaźnik na przejście z hosta na dymek, zanim ten zniknie (WCAG 1.4.13). */
4154
- const HIDE_DELAY_MS = 120;
4155
- let nextId$f = 0;
4156
- /**
4157
- * Dymek podpowiedzi (tooltip) pokazywany na hover/focus hosta. Lekki — element dodawany
4158
- * do `body` i pozycjonowany względem hosta (działa w trybie zoneless).
4159
- *
4160
- * Dostępność:
4161
- * - fokus łapiemy przez `focusin`/`focusout`, bo `focus`/`blur` nie bąbelkują — na
4162
- * `kpt-button` czy `kpt-icon-button` fokus dostaje wewnętrzny `<button>`, nie host;
4163
- * - tekst trafia do czytników przez trwały, ukryty opis powiązany `aria-describedby`
4164
- * z elementem, który faktycznie przyjmuje fokus (sam dymek powstaje dopiero przy pokazaniu,
4165
- * więc nie da się go wskazać wcześniej). Opisu nie dodajemy, gdy powtarzałby nazwę elementu
4166
- * albo przy `kptTooltipOnlyWhenTruncated` — tam dymek pokazuje tekst, który i tak jest w DOM-ie;
4167
- * - `Escape` zamyka dymek, a wskaźnik może na niego przejść bez zniknięcia (WCAG 1.4.13).
4168
- *
4169
- * @example
4170
- * <kpt-button kptTooltip="Zapisz zmiany" kptTooltipPosition="bottom">Zapisz</kpt-button>
4171
- *
4172
- * @example Dymek tylko wtedy, gdy tekst nie mieści się w elemencie:
4173
- * <span class="ellipsis" [kptTooltip]="name" kptTooltipOnlyWhenTruncated>{{ name }}</span>
4174
- */
4175
- class KptTooltip {
4176
- constructor() {
4177
- this.text = input.required({ ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'kptTooltip' });
4178
- this.position = input('top', { ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), alias: 'kptTooltipPosition' });
4179
- this.onlyWhenTruncated = input(false, { ...(ngDevMode ? { debugName: "onlyWhenTruncated" } : /* istanbul ignore next */ {}), alias: 'kptTooltipOnlyWhenTruncated',
4180
- transform: booleanAttribute });
4181
- this.host = inject(ElementRef);
4182
- this.descId = `kpt-tooltip-desc-${++nextId$f}`;
4183
- this.follow = () => this.reposition();
4184
- this.onKeydown = (event) => {
4185
- if (event.key === 'Escape')
4186
- this.hide();
4187
- };
4188
- // Po renderze, bo wewnętrzny `<button>` komponentu-hosta istnieje dopiero wtedy.
4189
- // Efekt czyta `text()` i `onlyWhenTruncated()`, więc zmiana treści aktualizuje opis.
4190
- afterRenderEffect(() => this.syncDescription(this.text(), this.onlyWhenTruncated()));
4191
- }
4192
- show() {
4193
- this.cancelHide();
4194
- if (this.tip || !this.text())
4195
- return;
4196
- // Sprawdzamy dopiero teraz, a nie przy renderze: dzięki temu wynik jest zawsze
4197
- // aktualny po zmianie szerokości czy powiększenia, bez żadnych obserwatorów.
4198
- if (this.onlyWhenTruncated() && !this.isTruncated())
4199
- return;
4200
- const tip = document.createElement('div');
4201
- tip.className = 'kpt-tooltip';
4202
- tip.setAttribute('role', 'tooltip');
4203
- // Treść czytnik dostaje z trwałego opisu — dymek by ją zdublował.
4204
- if (this.desc)
4205
- tip.setAttribute('aria-hidden', 'true');
4206
- tip.textContent = this.text();
4207
- tip.style.cssText =
4208
- 'position:fixed;z-index:1400;max-width:16rem;padding:0.35rem 0.6rem;' +
4209
- 'border-radius:var(--kpt-radius-sm,0.25rem);font-size:var(--kpt-font-size-xs,0.75rem);' +
4210
- 'line-height:1.4;background:var(--kpt-color-on-surface);color:var(--kpt-color-surface);' +
4211
- 'box-shadow:var(--kpt-elevation-2);opacity:0;transition:opacity 120ms;';
4212
- // Wskaźnik może przejść na dymek (np. żeby go powiększyć lupą) — wtedy dymek zostaje.
4213
- tip.addEventListener('mouseenter', () => this.cancelHide());
4214
- tip.addEventListener('mouseleave', () => this.scheduleHide());
4215
- document.body.appendChild(tip);
4216
- this.tip = tip;
4217
- this.reposition();
4218
- // Faza przechwytywania łapie także przewijanie zagnieżdżonych kontenerów
4219
- // (np. osi roadmapy), bo zdarzenie `scroll` elementu się nie propaguje.
4220
- window.addEventListener('scroll', this.follow, true);
4221
- window.addEventListener('resize', this.follow);
4222
- document.addEventListener('keydown', this.onKeydown);
4223
- requestAnimationFrame(() => {
4224
- if (this.tip)
4225
- this.tip.style.opacity = '1';
4226
- });
4227
- }
4228
- /** Fokus przeszedł do innego elementu w obrębie hosta — dymek zostaje. */
4229
- onFocusOut(event) {
4230
- const next = event.relatedTarget;
4231
- if (next && this.host.nativeElement.contains(next))
4232
- return;
4233
- this.hide();
4234
- }
4235
- scheduleHide() {
4236
- this.cancelHide();
4237
- this.hideTimer = setTimeout(() => this.hide(), HIDE_DELAY_MS);
4238
- }
4239
- cancelHide() {
4240
- if (this.hideTimer !== undefined)
4241
- clearTimeout(this.hideTimer);
4242
- this.hideTimer = undefined;
4243
- }
4244
- hide() {
4245
- this.cancelHide();
4246
- window.removeEventListener('scroll', this.follow, true);
4247
- window.removeEventListener('resize', this.follow);
4248
- document.removeEventListener('keydown', this.onKeydown);
4249
- this.tip?.remove();
4250
- this.tip = undefined;
4251
- }
4252
- /** Trwały opis dla czytników albo jego usunięcie, gdy nie jest potrzebny. */
4253
- syncDescription(text, onlyWhenTruncated) {
4254
- const target = this.focusTarget();
4255
- const name = (target.getAttribute('aria-label') ?? target.textContent ?? '').trim();
4256
- if (!text || onlyWhenTruncated || name === text.trim()) {
4257
- this.removeDescription();
4258
- return;
4259
- }
4260
- if (!this.desc) {
4261
- const desc = document.createElement('span');
4262
- desc.id = this.descId;
4263
- desc.hidden = true;
4264
- document.body.appendChild(desc);
4265
- this.desc = desc;
4266
- }
4267
- this.desc.textContent = text;
4268
- if (this.describedEl !== target) {
4269
- this.unlink();
4270
- const ids = (target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean);
4271
- if (!ids.includes(this.descId))
4272
- ids.push(this.descId);
4273
- target.setAttribute('aria-describedby', ids.join(' '));
4274
- this.describedEl = target;
4275
- }
4276
- }
4277
- removeDescription() {
4278
- this.unlink();
4279
- this.desc?.remove();
4280
- this.desc = undefined;
4281
- }
4282
- unlink() {
4283
- const el = this.describedEl;
4284
- if (!el)
4285
- return;
4286
- const ids = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((id) => id && id !== this.descId);
4287
- if (ids.length)
4288
- el.setAttribute('aria-describedby', ids.join(' '));
4289
- else
4290
- el.removeAttribute('aria-describedby');
4291
- this.describedEl = undefined;
4292
- }
4293
- /** Host, jeśli sam przyjmuje fokus, inaczej pierwsza kontrolka w środku, a w ostateczności host. */
4294
- focusTarget() {
4295
- const root = this.host.nativeElement;
4296
- if (root.matches(FOCUSABLE$2))
4297
- return root;
4298
- return root.querySelector(FOCUSABLE$2) ?? root;
4299
- }
4300
- isTruncated() {
4301
- const root = this.host.nativeElement;
4302
- const overflows = (el) =>
4303
- // Tolerancja 1 px pochłania zaokrąglenia subpikselowe przy skalowaniu.
4304
- el.scrollWidth > el.clientWidth + 1 || el.scrollHeight > el.clientHeight + 1;
4305
- return overflows(root) || Array.from(root.children).some(overflows);
4306
- }
4307
- reposition() {
4308
- const tip = this.tip;
4309
- if (!tip)
4310
- return;
4311
- const r = this.host.nativeElement.getBoundingClientRect();
4312
- const t = tip.getBoundingClientRect();
4313
- const gap = 8;
4314
- let top;
4315
- let left;
4316
- switch (this.position()) {
4317
- case 'bottom':
4318
- top = r.bottom + gap;
4319
- left = r.left + r.width / 2 - t.width / 2;
4320
- break;
4321
- case 'left':
4322
- top = r.top + r.height / 2 - t.height / 2;
4323
- left = r.left - t.width - gap;
4324
- break;
4325
- case 'right':
4326
- top = r.top + r.height / 2 - t.height / 2;
4327
- left = r.right + gap;
4328
- break;
4329
- default:
4330
- top = r.top - t.height - gap;
4331
- left = r.left + r.width / 2 - t.width / 2;
4332
- }
4333
- tip.style.top = `${Math.max(4, top)}px`;
4334
- tip.style.left = `${Math.max(4, left)}px`;
4335
- }
4336
- ngOnDestroy() {
4337
- this.hide();
4338
- this.removeDescription();
4339
- }
4340
- static { this.ɵfac = function KptTooltip_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || KptTooltip)(); }; }
4341
- static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: KptTooltip, selectors: [["", "kptTooltip", ""]], hostBindings: function KptTooltip_HostBindings(rf, ctx) { if (rf & 1) {
4342
- i0.ɵɵlistener("mouseenter", function KptTooltip_mouseenter_HostBindingHandler() { return ctx.show(); })("mouseleave", function KptTooltip_mouseleave_HostBindingHandler() { return ctx.scheduleHide(); })("focusin", function KptTooltip_focusin_HostBindingHandler() { return ctx.show(); })("focusout", function KptTooltip_focusout_HostBindingHandler($event) { return ctx.onFocusOut($event); });
4343
- } }, inputs: { text: [1, "kptTooltip", "text"], position: [1, "kptTooltipPosition", "position"], onlyWhenTruncated: [1, "kptTooltipOnlyWhenTruncated", "onlyWhenTruncated"] } }); }
4344
- }
4345
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(KptTooltip, [{
4346
- type: Directive,
4347
- args: [{
4348
- selector: '[kptTooltip]',
4349
- host: {
4350
- '(mouseenter)': 'show()',
4351
- '(mouseleave)': 'scheduleHide()',
4352
- '(focusin)': 'show()',
4353
- '(focusout)': 'onFocusOut($event)',
4354
- },
4355
- }]
4356
- }], () => [], { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "kptTooltip", required: true }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "kptTooltipPosition", required: false }] }], onlyWhenTruncated: [{ type: i0.Input, args: [{ isSignal: true, alias: "kptTooltipOnlyWhenTruncated", required: false }] }] }); })();
4357
-
4358
4390
  /*
4359
4391
  * Nawigacja strzałkami po poziomym rzędzie z jednym przystankiem Tab („roving tabindex”) —
4360
4392
  * wspólna dla `kpt-tabs`, `kpt-menubar` i `kpt-megamenu`. Port React ma bliźniaczy plik