@nectary/components 5.11.0 → 5.12.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
@@ -295,8 +295,8 @@ class Text extends NectaryElement {
295
295
  get inline() {
296
296
  return getBooleanAttribute(this, "inline");
297
297
  }
298
- set ellipsis(isEllipsis) {
299
- updateBooleanAttribute(this, "ellipsis", isEllipsis);
298
+ set ellipsis(isEllipsis2) {
299
+ updateBooleanAttribute(this, "ellipsis", isEllipsis2);
300
300
  }
301
301
  get ellipsis() {
302
302
  return getBooleanAttribute(this, "ellipsis");
@@ -364,8 +364,8 @@ class Title extends NectaryElement {
364
364
  get type() {
365
365
  return getLiteralAttribute(this, typeValues$6, "type");
366
366
  }
367
- set ellipsis(isEllipsis) {
368
- updateBooleanAttribute(this, "ellipsis", isEllipsis);
367
+ set ellipsis(isEllipsis2) {
368
+ updateBooleanAttribute(this, "ellipsis", isEllipsis2);
369
369
  }
370
370
  get ellipsis() {
371
371
  return getBooleanAttribute(this, "ellipsis");
@@ -3358,8 +3358,8 @@ class CardV2Title extends NectaryElement {
3358
3358
  set orientation(value) {
3359
3359
  updateAttribute(this, "orientation", value);
3360
3360
  }
3361
- set ellipsis(isEllipsis) {
3362
- updateBooleanAttribute(this, "ellipsis", isEllipsis);
3361
+ set ellipsis(isEllipsis2) {
3362
+ updateBooleanAttribute(this, "ellipsis", isEllipsis2);
3363
3363
  }
3364
3364
  get ellipsis() {
3365
3365
  return getBooleanAttribute(this, "ellipsis");
@@ -7696,6 +7696,9 @@ const FIRST_BTN_INDEX = 0;
7696
7696
  const LAST_BTN_INDEX = NUM_BUTTONS - 1;
7697
7697
  const DOTS_LEFT_INDEX = 1;
7698
7698
  const DOTS_RIGHT_INDEX = LAST_BTN_INDEX - 1;
7699
+ const isEllipsis = (btnIndex, value, max) => {
7700
+ return btnIndex === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || btnIndex === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX;
7701
+ };
7699
7702
  const template$t = document.createElement("template");
7700
7703
  template$t.innerHTML = templateHTML$t;
7701
7704
  class Pagination extends NectaryElement {
@@ -7763,19 +7766,12 @@ class Pagination extends NectaryElement {
7763
7766
  isActive = i === MIDDLE_BTN_INDEX;
7764
7767
  }
7765
7768
  setClass($b, "active", isActive);
7766
- if (isActive) {
7767
- $b.setAttribute("aria-current", "page");
7768
- } else {
7769
- $b.removeAttribute("aria-current");
7770
- }
7769
+ updateAttribute($b, "aria-current", isActive ? "page" : null);
7771
7770
  if (max > NUM_BUTTONS) {
7772
- const isEllipsis = i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX;
7773
- setClass($b, "dots", isEllipsis);
7774
- if (isEllipsis) {
7775
- $b.setAttribute("aria-hidden", "true");
7776
- } else {
7777
- $b.removeAttribute("aria-hidden");
7778
- }
7771
+ const ellipsis = isEllipsis(i, value, max);
7772
+ setClass($b, "dots", ellipsis);
7773
+ updateAttribute($b, "aria-hidden", ellipsis);
7774
+ $b.disabled = ellipsis;
7779
7775
  }
7780
7776
  setClass($b, "hidden", i >= max);
7781
7777
  const btnText = $b.firstElementChild;
@@ -7791,7 +7787,7 @@ class Pagination extends NectaryElement {
7791
7787
  }
7792
7788
  #onButtonClick = (e) => {
7793
7789
  e.stopPropagation();
7794
- const value = Math.max(getIntegerAttribute(this, "value", 0) - 1);
7790
+ const value = getIntegerAttribute(this, "value", 0) - 1;
7795
7791
  const max = Math.max(0, getIntegerAttribute(this, "max", 0));
7796
7792
  if (isTargetEqual(e, this.#$left)) {
7797
7793
  return this.#dispatchChangeEvent(Math.max(value - 1, 0));
@@ -12393,6 +12389,7 @@ class Textarea extends NectaryElement {
12393
12389
  this.#sizeContext.listen(this.#controller.signal);
12394
12390
  this.#onBottomSlotChange();
12395
12391
  this.#updateMinRows();
12392
+ this.#updateMaxRows();
12396
12393
  this.#onSizeUpdate();
12397
12394
  }
12398
12395
  disconnectedCallback() {
@@ -12488,6 +12485,10 @@ class Textarea extends NectaryElement {
12488
12485
  updateAttribute(this.#$input, "rows", newVal);
12489
12486
  break;
12490
12487
  }
12488
+ case "maxrows": {
12489
+ this.#updateMaxRows();
12490
+ break;
12491
+ }
12491
12492
  case "minrows": {
12492
12493
  this.#updateMinRows();
12493
12494
  break;
@@ -12553,6 +12554,12 @@ class Textarea extends NectaryElement {
12553
12554
  get minRows() {
12554
12555
  return getIntegerAttribute(this, "minrows", 0);
12555
12556
  }
12557
+ get maxRows() {
12558
+ return getIntegerAttribute(this, "maxrows", 0);
12559
+ }
12560
+ set maxRows(value) {
12561
+ updateAttribute(this, "maxRows", value);
12562
+ }
12556
12563
  get selectionStart() {
12557
12564
  return this.#$input.selectionStart;
12558
12565
  }
@@ -12580,6 +12587,15 @@ class Textarea extends NectaryElement {
12580
12587
  blur() {
12581
12588
  this.#$input.blur();
12582
12589
  }
12590
+ #updateMaxRows() {
12591
+ if (this.maxRows === 0) {
12592
+ this.#$input.style.removeProperty("max-height");
12593
+ return;
12594
+ }
12595
+ if (this.isDomConnected) {
12596
+ this.#calcMaxRows();
12597
+ }
12598
+ }
12583
12599
  #updateMinRows() {
12584
12600
  const minRows = this.minRows;
12585
12601
  if (minRows <= 0) {
@@ -12603,6 +12619,14 @@ class Textarea extends NectaryElement {
12603
12619
  this.#calcMinRows();
12604
12620
  }
12605
12621
  };
12622
+ #calcMaxRows() {
12623
+ if (this.maxRows === 0) {
12624
+ return;
12625
+ }
12626
+ this.#$input.rows = this.maxRows;
12627
+ this.#$input.style.setProperty("max-height", `${getRect(this.#$input).height}px`);
12628
+ this.#$input.rows = this.rows;
12629
+ }
12606
12630
  #calcMinRows() {
12607
12631
  this.#$input.rows = this.minRows;
12608
12632
  this.#$input.style.setProperty("min-height", `${getRect(this.#$input).height}px`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.11.0",
3
+ "version": "5.12.0",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -11,6 +11,9 @@ const FIRST_BTN_INDEX = 0;
11
11
  const LAST_BTN_INDEX = NUM_BUTTONS - 1;
12
12
  const DOTS_LEFT_INDEX = 1;
13
13
  const DOTS_RIGHT_INDEX = LAST_BTN_INDEX - 1;
14
+ const isEllipsis = (btnIndex, value, max) => {
15
+ return btnIndex === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || btnIndex === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX;
16
+ };
14
17
  const template = document.createElement("template");
15
18
  template.innerHTML = templateHTML;
16
19
  class Pagination extends NectaryElement {
@@ -78,19 +81,12 @@ class Pagination extends NectaryElement {
78
81
  isActive = i === MIDDLE_BTN_INDEX;
79
82
  }
80
83
  setClass($b, "active", isActive);
81
- if (isActive) {
82
- $b.setAttribute("aria-current", "page");
83
- } else {
84
- $b.removeAttribute("aria-current");
85
- }
84
+ updateAttribute($b, "aria-current", isActive ? "page" : null);
86
85
  if (max > NUM_BUTTONS) {
87
- const isEllipsis = i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX;
88
- setClass($b, "dots", isEllipsis);
89
- if (isEllipsis) {
90
- $b.setAttribute("aria-hidden", "true");
91
- } else {
92
- $b.removeAttribute("aria-hidden");
93
- }
86
+ const ellipsis = isEllipsis(i, value, max);
87
+ setClass($b, "dots", ellipsis);
88
+ updateAttribute($b, "aria-hidden", ellipsis);
89
+ $b.disabled = ellipsis;
94
90
  }
95
91
  setClass($b, "hidden", i >= max);
96
92
  const btnText = $b.firstElementChild;
@@ -106,7 +102,7 @@ class Pagination extends NectaryElement {
106
102
  }
107
103
  #onButtonClick = (e) => {
108
104
  e.stopPropagation();
109
- const value = Math.max(getIntegerAttribute(this, "value", 0) - 1);
105
+ const value = getIntegerAttribute(this, "value", 0) - 1;
110
106
  const max = Math.max(0, getIntegerAttribute(this, "max", 0));
111
107
  if (isTargetEqual(e, this.#$left)) {
112
108
  return this.#dispatchChangeEvent(Math.max(value - 1, 0));
@@ -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;