@nectary/components 5.11.1 → 5.13.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/bundle.js CHANGED
@@ -5346,6 +5346,7 @@ class Input extends NectaryElement {
5346
5346
  this.#$iconSlot.addEventListener("slotchange", this.#onIconSlotChange, options);
5347
5347
  this.#$leftSlot.addEventListener("slotchange", this.#onLeftSlotChange, options);
5348
5348
  this.#$rightSlot.addEventListener("slotchange", this.#onRightSlotChange, options);
5349
+ this.addEventListener("-key-down", this.#onKeyDownReactHandler, options);
5349
5350
  this.addEventListener("-change", this.#onChangeReactHandler, options);
5350
5351
  this.addEventListener("-focus", this.#onFocusReactHandler, options);
5351
5352
  this.addEventListener("-blur", this.#onBlurReactHandler, options);
@@ -5437,6 +5438,7 @@ class Input extends NectaryElement {
5437
5438
  }
5438
5439
  }
5439
5440
  }
5441
+ this.dispatchEvent(new CustomEvent("-key-down", e));
5440
5442
  };
5441
5443
  static get observedAttributes() {
5442
5444
  return [
@@ -5998,6 +6000,10 @@ class Input extends NectaryElement {
5998
6000
  const size = this.getAttribute("data-size") ?? DEFAULT_SIZE;
5999
6001
  this.#sizeContext.dispatch(size);
6000
6002
  }
6003
+ #onKeyDownReactHandler = (e) => {
6004
+ getReactEventHandler(this, "on-key-down")?.(e);
6005
+ getReactEventHandler(this, "onKeyDown")?.(e);
6006
+ };
6001
6007
  #onChangeReactHandler = (e) => {
6002
6008
  getReactEventHandler(this, "on-change")?.(e);
6003
6009
  getReactEventHandler(this, "onChange")?.(e);
@@ -12389,6 +12395,7 @@ class Textarea extends NectaryElement {
12389
12395
  this.#sizeContext.listen(this.#controller.signal);
12390
12396
  this.#onBottomSlotChange();
12391
12397
  this.#updateMinRows();
12398
+ this.#updateMaxRows();
12392
12399
  this.#onSizeUpdate();
12393
12400
  }
12394
12401
  disconnectedCallback() {
@@ -12484,6 +12491,10 @@ class Textarea extends NectaryElement {
12484
12491
  updateAttribute(this.#$input, "rows", newVal);
12485
12492
  break;
12486
12493
  }
12494
+ case "maxrows": {
12495
+ this.#updateMaxRows();
12496
+ break;
12497
+ }
12487
12498
  case "minrows": {
12488
12499
  this.#updateMinRows();
12489
12500
  break;
@@ -12549,6 +12560,12 @@ class Textarea extends NectaryElement {
12549
12560
  get minRows() {
12550
12561
  return getIntegerAttribute(this, "minrows", 0);
12551
12562
  }
12563
+ get maxRows() {
12564
+ return getIntegerAttribute(this, "maxrows", 0);
12565
+ }
12566
+ set maxRows(value) {
12567
+ updateAttribute(this, "maxRows", value);
12568
+ }
12552
12569
  get selectionStart() {
12553
12570
  return this.#$input.selectionStart;
12554
12571
  }
@@ -12576,6 +12593,15 @@ class Textarea extends NectaryElement {
12576
12593
  blur() {
12577
12594
  this.#$input.blur();
12578
12595
  }
12596
+ #updateMaxRows() {
12597
+ if (this.maxRows === 0) {
12598
+ this.#$input.style.removeProperty("max-height");
12599
+ return;
12600
+ }
12601
+ if (this.isDomConnected) {
12602
+ this.#calcMaxRows();
12603
+ }
12604
+ }
12579
12605
  #updateMinRows() {
12580
12606
  const minRows = this.minRows;
12581
12607
  if (minRows <= 0) {
@@ -12599,6 +12625,14 @@ class Textarea extends NectaryElement {
12599
12625
  this.#calcMinRows();
12600
12626
  }
12601
12627
  };
12628
+ #calcMaxRows() {
12629
+ if (this.maxRows === 0) {
12630
+ return;
12631
+ }
12632
+ this.#$input.rows = this.maxRows;
12633
+ this.#$input.style.setProperty("max-height", `${getRect(this.#$input).height}px`);
12634
+ this.#$input.rows = this.rows;
12635
+ }
12602
12636
  #calcMinRows() {
12603
12637
  this.#$input.rows = this.minRows;
12604
12638
  this.#$input.style.setProperty("min-height", `${getRect(this.#$input).height}px`);
package/input/index.js CHANGED
@@ -69,6 +69,7 @@ class Input extends NectaryElement {
69
69
  this.#$iconSlot.addEventListener("slotchange", this.#onIconSlotChange, options);
70
70
  this.#$leftSlot.addEventListener("slotchange", this.#onLeftSlotChange, options);
71
71
  this.#$rightSlot.addEventListener("slotchange", this.#onRightSlotChange, options);
72
+ this.addEventListener("-key-down", this.#onKeyDownReactHandler, options);
72
73
  this.addEventListener("-change", this.#onChangeReactHandler, options);
73
74
  this.addEventListener("-focus", this.#onFocusReactHandler, options);
74
75
  this.addEventListener("-blur", this.#onBlurReactHandler, options);
@@ -160,6 +161,7 @@ class Input extends NectaryElement {
160
161
  }
161
162
  }
162
163
  }
164
+ this.dispatchEvent(new CustomEvent("-key-down", e));
163
165
  };
164
166
  static get observedAttributes() {
165
167
  return [
@@ -721,6 +723,10 @@ class Input extends NectaryElement {
721
723
  const size = this.getAttribute("data-size") ?? DEFAULT_SIZE;
722
724
  this.#sizeContext.dispatch(size);
723
725
  }
726
+ #onKeyDownReactHandler = (e) => {
727
+ getReactEventHandler(this, "on-key-down")?.(e);
728
+ getReactEventHandler(this, "onKeyDown")?.(e);
729
+ };
724
730
  #onChangeReactHandler = (e) => {
725
731
  getReactEventHandler(this, "on-change")?.(e);
726
732
  getReactEventHandler(this, "onChange")?.(e);
package/input/types.d.ts CHANGED
@@ -50,6 +50,8 @@ export type TSinchInputMethods = {
50
50
  setSelectionRange(selectionStart: number, selectionEnd: number): void;
51
51
  };
52
52
  export type TSinchInputEvents = {
53
+ /** key-down handler*/
54
+ '-key-down'?: (e: KeyboardEvent) => void;
53
55
  /** Change value handler */
54
56
  '-change'?: (e: CustomEvent<string>) => void;
55
57
  /** Focus handler */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.11.1",
3
+ "version": "5.13.0",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -27,6 +27,8 @@ export declare class Textarea extends NectaryElement {
27
27
  get rows(): HTMLTextAreaElement['rows'];
28
28
  set minRows(value: number);
29
29
  get minRows(): number;
30
+ get maxRows(): number;
31
+ set maxRows(value: number);
30
32
  get selectionStart(): HTMLTextAreaElement['selectionStart'];
31
33
  set selectionStart(value: HTMLTextAreaElement['selectionStart']);
32
34
  get selectionEnd(): HTMLTextAreaElement['selectionEnd'];
package/textarea/index.js CHANGED
@@ -57,6 +57,7 @@ class Textarea extends NectaryElement {
57
57
  this.#sizeContext.listen(this.#controller.signal);
58
58
  this.#onBottomSlotChange();
59
59
  this.#updateMinRows();
60
+ this.#updateMaxRows();
60
61
  this.#onSizeUpdate();
61
62
  }
62
63
  disconnectedCallback() {
@@ -152,6 +153,10 @@ class Textarea extends NectaryElement {
152
153
  updateAttribute(this.#$input, "rows", newVal);
153
154
  break;
154
155
  }
156
+ case "maxrows": {
157
+ this.#updateMaxRows();
158
+ break;
159
+ }
155
160
  case "minrows": {
156
161
  this.#updateMinRows();
157
162
  break;
@@ -217,6 +222,12 @@ class Textarea extends NectaryElement {
217
222
  get minRows() {
218
223
  return getIntegerAttribute(this, "minrows", 0);
219
224
  }
225
+ get maxRows() {
226
+ return getIntegerAttribute(this, "maxrows", 0);
227
+ }
228
+ set maxRows(value) {
229
+ updateAttribute(this, "maxRows", value);
230
+ }
220
231
  get selectionStart() {
221
232
  return this.#$input.selectionStart;
222
233
  }
@@ -244,6 +255,15 @@ class Textarea extends NectaryElement {
244
255
  blur() {
245
256
  this.#$input.blur();
246
257
  }
258
+ #updateMaxRows() {
259
+ if (this.maxRows === 0) {
260
+ this.#$input.style.removeProperty("max-height");
261
+ return;
262
+ }
263
+ if (this.isDomConnected) {
264
+ this.#calcMaxRows();
265
+ }
266
+ }
247
267
  #updateMinRows() {
248
268
  const minRows = this.minRows;
249
269
  if (minRows <= 0) {
@@ -267,6 +287,14 @@ class Textarea extends NectaryElement {
267
287
  this.#calcMinRows();
268
288
  }
269
289
  };
290
+ #calcMaxRows() {
291
+ if (this.maxRows === 0) {
292
+ return;
293
+ }
294
+ this.#$input.rows = this.maxRows;
295
+ this.#$input.style.setProperty("max-height", `${getRect(this.#$input).height}px`);
296
+ this.#$input.rows = this.rows;
297
+ }
270
298
  #calcMinRows() {
271
299
  this.#$input.rows = this.minRows;
272
300
  this.#$input.style.setProperty("min-height", `${getRect(this.#$input).height}px`);
@@ -14,6 +14,7 @@ export type TSinchTextareaProps = {
14
14
  /** Number of rows */
15
15
  rows?: number;
16
16
  minRows?: number;
17
+ maxRows?: number;
17
18
  /** Whether the text field is resizable */
18
19
  resizable?: boolean;
19
20
  selectionStart?: number;