@konce-pt/angular 0.11.0 → 0.11.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @konce-pt/angular
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2653c2f: `kpt-textarea` z `autoResize` dopasowuje wysokość także do wartości ustawionej z formularza
8
+ (edycja istniejącego wpisu), a nie tylko do wpisywanej z klawiatury. Pole ukryte przy pierwszym
9
+ renderze — w zamkniętym dialogu albo zwiniętej sekcji — nie zwija się już do zera: zostaje
10
+ wysokość z `rows`, a pomiar wraca, gdy pole staje się widoczne. Port React działał tak od początku.
11
+ - @konce-pt/backdrop@0.11.1
12
+ - @konce-pt/chart@0.11.1
13
+ - @konce-pt/chat@0.11.1
14
+ - @konce-pt/datetime@0.11.1
15
+ - @konce-pt/i18n@0.11.1
16
+ - @konce-pt/icons@0.11.1
17
+ - @konce-pt/map@0.11.1
18
+ - @konce-pt/mention@0.11.1
19
+ - @konce-pt/roadmap@0.11.1
20
+ - @konce-pt/table@0.11.1
21
+
3
22
  ## 0.11.0
4
23
 
5
24
  ### Patch Changes
@@ -4061,10 +4061,29 @@ class KptTextarea {
4061
4061
  ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
4062
4062
  this.ta = viewChild('ta', /* @ts-ignore */
4063
4063
  ...(ngDevMode ? [{ debugName: "ta" }] : /* istanbul ignore next */ []));
4064
- afterNextRender(() => {
4064
+ // Wysokość idzie za wartością — także ustawioną z formularza (edycja istniejącego wpisu),
4065
+ // nie tylko wpisaną z klawiatury.
4066
+ afterRenderEffect(() => {
4067
+ this.value();
4065
4068
  if (this.autoResize())
4066
4069
  this.resize();
4067
4070
  });
4071
+ // Pole ukryte przy pierwszym renderze (zamknięty dialog, zwinięta sekcja) nie ma `scrollHeight`.
4072
+ // Pomiar wraca, gdy pole dostaje układ — `ResizeObserver` zgłasza zmianę szerokości z zera.
4073
+ let width = 0;
4074
+ const observer = new ResizeObserver(([entry]) => {
4075
+ const next = entry?.contentRect.width ?? 0;
4076
+ if (next !== width && this.autoResize()) {
4077
+ width = next;
4078
+ this.resize();
4079
+ }
4080
+ });
4081
+ afterRenderEffect(() => {
4082
+ const el = this.ta()?.nativeElement;
4083
+ if (el)
4084
+ observer.observe(el);
4085
+ });
4086
+ inject(DestroyRef).onDestroy(() => observer.disconnect());
4068
4087
  }
4069
4088
  onInput(event) {
4070
4089
  this.value.set(event.target.value);
@@ -4075,6 +4094,11 @@ class KptTextarea {
4075
4094
  const el = this.ta()?.nativeElement;
4076
4095
  if (!el)
4077
4096
  return;
4097
+ // Bez układu `scrollHeight` to 0 — zostawiamy wysokość z `rows` zamiast zwijać pole do zera.
4098
+ if (!el.getClientRects().length) {
4099
+ el.style.height = '';
4100
+ return;
4101
+ }
4078
4102
  el.style.height = 'auto';
4079
4103
  el.style.height = `${el.scrollHeight}px`;
4080
4104
  }
@@ -4099,30 +4123,30 @@ class KptTextarea {
4099
4123
  }
4100
4124
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(KptTextarea, [{
4101
4125
  type: Component,
4102
- args: [{ selector: 'kpt-textarea', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
4103
- <textarea
4104
- #ta
4105
- class="kpt-textarea__field"
4106
- [id]="field.id()"
4107
- [value]="value()"
4108
- [placeholder]="placeholder()"
4109
- [disabled]="disabled()"
4110
- [readOnly]="readonly()"
4111
- [rows]="rows()"
4112
- [attr.aria-invalid]="showInvalid() ? 'true' : null"
4113
- [attr.aria-required]="required() ? 'true' : null"
4114
- [attr.aria-label]="ariaLabel()"
4115
- [attr.maxlength]="maxLength() ?? null"
4116
- [attr.aria-describedby]="describedBy()"
4117
- (input)="onInput($event)"
4118
- (blur)="touch.emit()"
4119
- ></textarea>
4120
- @if (counter() && maxLength()) {
4121
- <span class="kpt-textarea__counter" [id]="counterId()">{{ value().length }} / {{ maxLength() }}</span>
4122
- }
4126
+ args: [{ selector: 'kpt-textarea', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
4127
+ <textarea
4128
+ #ta
4129
+ class="kpt-textarea__field"
4130
+ [id]="field.id()"
4131
+ [value]="value()"
4132
+ [placeholder]="placeholder()"
4133
+ [disabled]="disabled()"
4134
+ [readOnly]="readonly()"
4135
+ [rows]="rows()"
4136
+ [attr.aria-invalid]="showInvalid() ? 'true' : null"
4137
+ [attr.aria-required]="required() ? 'true' : null"
4138
+ [attr.aria-label]="ariaLabel()"
4139
+ [attr.maxlength]="maxLength() ?? null"
4140
+ [attr.aria-describedby]="describedBy()"
4141
+ (input)="onInput($event)"
4142
+ (blur)="touch.emit()"
4143
+ ></textarea>
4144
+ @if (counter() && maxLength()) {
4145
+ <span class="kpt-textarea__counter" [id]="counterId()">{{ value().length }} / {{ maxLength() }}</span>
4146
+ }
4123
4147
  `, host: { class: 'kpt-textarea-host', '[attr.id]': 'null' }, styles: ["@layer kpt.components{.kpt-textarea-host{display:block}.kpt-textarea__field{display:block;width:100%;box-sizing:border-box;min-height:3rem;padding:var(--kpt-space-2, .5rem) var(--kpt-space-3, .75rem);border:var(--kpt-border-width-thin, 1px) solid var(--kpt-form-field-border);border-radius:var(--kpt-form-field-radius, .5rem);font-family:inherit;font-size:var(--kpt-font-size-sm, .875rem);line-height:var(--kpt-font-line-height-normal, 1.5);color:var(--kpt-form-field-text);background:var(--kpt-form-field-bg);resize:vertical}.kpt-textarea__field::placeholder{color:var(--kpt-form-field-placeholder)}.kpt-textarea__field:hover:not(:disabled){border-color:var(--kpt-form-field-border-hover)}.kpt-textarea__field:focus-visible{outline:none;border-color:var(--kpt-form-field-border-focus);box-shadow:0 0 0 2px color-mix(in oklch,var(--kpt-form-field-border-focus) 30%,transparent)}.kpt-textarea__field[aria-invalid=true]{border-color:var(--kpt-form-field-border-error)}.kpt-textarea__field:disabled{cursor:not-allowed;opacity:.6;background:var(--kpt-color-surface-variant)}.kpt-textarea__counter{display:block;margin-top:var(--kpt-space-1, .25rem);text-align:end;font-size:var(--kpt-font-size-xs, .75rem);font-variant-numeric:tabular-nums;color:var(--kpt-color-on-surface-muted)}}\n"] }]
4124
4148
  }], () => [], { 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 }] }] }); })();
4125
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptTextarea, { className: "KptTextarea", filePath: "lib/textarea/textarea.component.ts", lineNumber: 54 }); })();
4149
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptTextarea, { className: "KptTextarea", filePath: "lib/textarea/textarea.component.ts", lineNumber: 56 }); })();
4126
4150
 
4127
4151
  /** Elementy, które same przyjmują fokus — na nie trafia `aria-describedby`. */
4128
4152
  const FOCUSABLE$2 = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])';