@justeattakeaway/pie-textarea 0.11.1 → 0.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.
@@ -139,15 +139,6 @@
139
139
  "privacy": "public",
140
140
  "attribute": "label"
141
141
  },
142
- {
143
- "kind": "field",
144
- "name": "maxLength",
145
- "type": {
146
- "text": "TextareaProps['maxLength']"
147
- },
148
- "privacy": "public",
149
- "attribute": "maxLength"
150
- },
151
142
  {
152
143
  "kind": "field",
153
144
  "name": "readonly",
@@ -275,11 +266,6 @@
275
266
  "name": "handleResize",
276
267
  "privacy": "private"
277
268
  },
278
- {
279
- "kind": "method",
280
- "name": "restrictInputLength",
281
- "privacy": "private"
282
- },
283
269
  {
284
270
  "kind": "field",
285
271
  "name": "handleInput",
@@ -327,13 +313,6 @@
327
313
  "type": {
328
314
  "text": "string"
329
315
  }
330
- },
331
- {
332
- "name": "maxLength",
333
- "optional": true,
334
- "type": {
335
- "text": "number"
336
- }
337
316
  }
338
317
  ]
339
318
  },
@@ -386,13 +365,6 @@
386
365
  "name": "label",
387
366
  "fieldName": "label"
388
367
  },
389
- {
390
- "name": "maxLength",
391
- "type": {
392
- "text": "TextareaProps['maxLength']"
393
- },
394
- "fieldName": "maxLength"
395
- },
396
368
  {
397
369
  "name": "readonly",
398
370
  "fieldName": "readonly"
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import type { TemplateResult } from 'lit-html';
12
12
  /**
13
13
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
14
14
  */
15
- declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'maxLength' | 'assistiveText' | 'defaultValue'>>;
15
+ declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue'>>;
16
16
 
17
17
  /**
18
18
  * Default values for optional properties that have default fallback values in the component.
@@ -36,7 +36,6 @@ export declare class PieTextarea extends PieTextarea_base implements TextareaPro
36
36
  size: "small" | "medium" | "large";
37
37
  resize: "auto" | "manual";
38
38
  label: string;
39
- maxLength: TextareaProps['maxLength'];
40
39
  readonly: boolean;
41
40
  autoFocus: boolean;
42
41
  required: boolean;
@@ -67,7 +66,6 @@ export declare class PieTextarea extends PieTextarea_base implements TextareaPro
67
66
  formResetCallback(): void;
68
67
  protected firstUpdated(): void;
69
68
  private handleResize;
70
- private restrictInputLength;
71
69
  protected updated(changedProperties: PropertyValues<this>): void;
72
70
  /**
73
71
  * Handles input events and updates the component's value based on the input event or a provided new value.
@@ -82,7 +80,7 @@ export declare class PieTextarea extends PieTextarea_base implements TextareaPro
82
80
  private handleChange;
83
81
  private handleKeyDown;
84
82
  disconnectedCallback(): void;
85
- renderLabel(label: string, maxLength?: number): TemplateResult<1> | typeof nothing;
83
+ renderLabel(label: string): TemplateResult<1> | typeof nothing;
86
84
  renderAssistiveText(): TemplateResult<1> | typeof nothing;
87
85
  render(): TemplateResult<1>;
88
86
  static styles: CSSResult;
@@ -155,11 +153,6 @@ export declare interface TextareaProps {
155
153
  * The label text for the textarea field.
156
154
  */
157
155
  label?: string;
158
- /**
159
- * The maximum number of characters allowed in the textarea field.
160
- * If the `label` property is not set, this property will have no effect.
161
- */
162
- maxLength?: number;
163
156
  /**
164
157
  * The placeholder text to display when the textarea is empty.
165
158
  */
package/dist/index.js CHANGED
@@ -1,101 +1,101 @@
1
- import { LitElement as M, html as j, nothing as q, unsafeCSS as P } from "lit";
2
- import { property as l, query as V } from "lit/decorators.js";
1
+ import { LitElement as L, html as j, nothing as M, unsafeCSS as P } from "lit";
2
+ import { property as l, query as D } from "lit/decorators.js";
3
3
  import { classMap as G } from "lit/directives/class-map.js";
4
- import { ifDefined as b } from "lit/directives/if-defined.js";
4
+ import { ifDefined as m } from "lit/directives/if-defined.js";
5
5
  import { live as H } from "lit/directives/live.js";
6
6
  import "@justeattakeaway/pie-assistive-text";
7
7
  import "@justeattakeaway/pie-form-label";
8
8
  import { FormControlMixin as U, RtlMixin as X, wrapNativeEvent as J, validPropertyValues as C, defineCustomElement as Q } from "@justeattakeaway/pie-webc-core";
9
9
  var T = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
10
- function Y(t) {
11
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
10
+ function Y(e) {
11
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
12
12
  }
13
- var N = "Expected a function", B = NaN, Z = "[object Symbol]", ee = /^\s+|\s+$/g, te = /^[-+]0x[0-9a-f]+$/i, ae = /^0b[01]+$/i, re = /^0o[0-7]+$/i, ie = parseInt, oe = typeof T == "object" && T && T.Object === Object && T, ne = typeof self == "object" && self && self.Object === Object && self, se = oe || ne || Function("return this")(), le = Object.prototype, de = le.toString, ce = Math.max, ue = Math.min, w = function() {
13
+ var V = "Expected a function", q = NaN, Z = "[object Symbol]", ee = /^\s+|\s+$/g, te = /^[-+]0x[0-9a-f]+$/i, ae = /^0b[01]+$/i, re = /^0o[0-7]+$/i, ie = parseInt, oe = typeof T == "object" && T && T.Object === Object && T, ne = typeof self == "object" && self && self.Object === Object && self, se = oe || ne || Function("return this")(), le = Object.prototype, de = le.toString, ce = Math.max, ue = Math.min, w = function() {
14
14
  return se.Date.now();
15
15
  };
16
- function he(t, e, a) {
17
- var s, o, h, u, d, p, x = 0, k = !1, v = !1, y = !0;
18
- if (typeof t != "function")
19
- throw new TypeError(N);
20
- e = D(e) || 0, S(a) && (k = !!a.leading, v = "maxWait" in a, h = v ? ce(D(a.maxWait) || 0, e) : h, y = "trailing" in a ? !!a.trailing : y);
21
- function g(i) {
22
- var f = s, z = o;
23
- return s = o = void 0, x = i, u = t.apply(z, f), u;
16
+ function pe(e, t, a) {
17
+ var d, o, p, u, s, h, x = 0, k = !1, v = !1, g = !0;
18
+ if (typeof e != "function")
19
+ throw new TypeError(V);
20
+ t = B(t) || 0, S(a) && (k = !!a.leading, v = "maxWait" in a, p = v ? ce(B(a.maxWait) || 0, t) : p, g = "trailing" in a ? !!a.trailing : g);
21
+ function y(r) {
22
+ var f = d, z = o;
23
+ return d = o = void 0, x = r, u = e.apply(z, f), u;
24
24
  }
25
- function _(i) {
26
- return x = i, d = setTimeout($, e), k ? g(i) : u;
25
+ function E(r) {
26
+ return x = r, s = setTimeout($, t), k ? y(r) : u;
27
27
  }
28
- function E(i) {
29
- var f = i - p, z = i - x, R = e - f;
30
- return v ? ue(R, h - z) : R;
28
+ function A(r) {
29
+ var f = r - h, z = r - x, R = t - f;
30
+ return v ? ue(R, p - z) : R;
31
31
  }
32
- function O(i) {
33
- var f = i - p, z = i - x;
34
- return p === void 0 || f >= e || f < 0 || v && z >= h;
32
+ function I(r) {
33
+ var f = r - h, z = r - x;
34
+ return h === void 0 || f >= t || f < 0 || v && z >= p;
35
35
  }
36
36
  function $() {
37
- var i = w();
38
- if (O(i))
39
- return F(i);
40
- d = setTimeout($, E(i));
37
+ var r = w();
38
+ if (I(r))
39
+ return F(r);
40
+ s = setTimeout($, A(r));
41
41
  }
42
- function F(i) {
43
- return d = void 0, y && s ? g(i) : (s = o = void 0, u);
42
+ function F(r) {
43
+ return s = void 0, g && d ? y(r) : (d = o = void 0, u);
44
44
  }
45
- function A() {
46
- d !== void 0 && clearTimeout(d), x = 0, s = p = o = d = void 0;
45
+ function N() {
46
+ s !== void 0 && clearTimeout(s), x = 0, d = h = o = s = void 0;
47
47
  }
48
48
  function K() {
49
- return d === void 0 ? u : F(w());
49
+ return s === void 0 ? u : F(w());
50
50
  }
51
- function L() {
52
- var i = w(), f = O(i);
53
- if (s = arguments, o = this, p = i, f) {
54
- if (d === void 0)
55
- return _(p);
51
+ function _() {
52
+ var r = w(), f = I(r);
53
+ if (d = arguments, o = this, h = r, f) {
54
+ if (s === void 0)
55
+ return E(h);
56
56
  if (v)
57
- return d = setTimeout($, e), g(p);
57
+ return s = setTimeout($, t), y(h);
58
58
  }
59
- return d === void 0 && (d = setTimeout($, e)), u;
59
+ return s === void 0 && (s = setTimeout($, t)), u;
60
60
  }
61
- return L.cancel = A, L.flush = K, L;
61
+ return _.cancel = N, _.flush = K, _;
62
62
  }
63
- function pe(t, e, a) {
64
- var s = !0, o = !0;
65
- if (typeof t != "function")
66
- throw new TypeError(N);
67
- return S(a) && (s = "leading" in a ? !!a.leading : s, o = "trailing" in a ? !!a.trailing : o), he(t, e, {
68
- leading: s,
69
- maxWait: e,
63
+ function he(e, t, a) {
64
+ var d = !0, o = !0;
65
+ if (typeof e != "function")
66
+ throw new TypeError(V);
67
+ return S(a) && (d = "leading" in a ? !!a.leading : d, o = "trailing" in a ? !!a.trailing : o), pe(e, t, {
68
+ leading: d,
69
+ maxWait: t,
70
70
  trailing: o
71
71
  });
72
72
  }
73
- function S(t) {
74
- var e = typeof t;
75
- return !!t && (e == "object" || e == "function");
73
+ function S(e) {
74
+ var t = typeof e;
75
+ return !!e && (t == "object" || t == "function");
76
76
  }
77
- function fe(t) {
78
- return !!t && typeof t == "object";
77
+ function fe(e) {
78
+ return !!e && typeof e == "object";
79
79
  }
80
- function xe(t) {
81
- return typeof t == "symbol" || fe(t) && de.call(t) == Z;
80
+ function xe(e) {
81
+ return typeof e == "symbol" || fe(e) && de.call(e) == Z;
82
82
  }
83
- function D(t) {
84
- if (typeof t == "number")
85
- return t;
86
- if (xe(t))
87
- return B;
88
- if (S(t)) {
89
- var e = typeof t.valueOf == "function" ? t.valueOf() : t;
90
- t = S(e) ? e + "" : e;
83
+ function B(e) {
84
+ if (typeof e == "number")
85
+ return e;
86
+ if (xe(e))
87
+ return q;
88
+ if (S(e)) {
89
+ var t = typeof e.valueOf == "function" ? e.valueOf() : e;
90
+ e = S(t) ? t + "" : t;
91
91
  }
92
- if (typeof t != "string")
93
- return t === 0 ? t : +t;
94
- t = t.replace(ee, "");
95
- var a = ae.test(t);
96
- return a || re.test(t) ? ie(t.slice(2), a ? 2 : 8) : te.test(t) ? B : +t;
92
+ if (typeof e != "string")
93
+ return e === 0 ? e : +e;
94
+ e = e.replace(ee, "");
95
+ var a = ae.test(e);
96
+ return a || re.test(e) ? ie(e.slice(2), a ? 2 : 8) : te.test(e) ? q : +e;
97
97
  }
98
- var ve = pe;
98
+ var ve = he;
99
99
  const ge = /* @__PURE__ */ Y(ve), be = "*,*:after,*:before{box-sizing:inherit}.c-textareaWrapper{--textarea-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--textarea-border-thickness: 1px;--textarea-resize: none;--textarea-padding-inline: var(--dt-spacing-c);--textarea-padding-block: var(--dt-spacing-b);--textarea-background-color: var(--dt-color-container-default);--textarea-border-color: var(--dt-color-interactive-form);--textarea-content-color: var(--dt-color-content-default);--textarea-placeholder-color: var(--dt-color-content-placeholder);--textarea-height: calc((var(--textarea-line-height) * 2) + (var(--textarea-padding-block) * 2));line-height:0;padding:var(--dt-spacing-a);border:var(--textarea-border-thickness) solid var(--textarea-border-color);background-color:var(--textarea-background-color);border-radius:var(--dt-radius-rounded-c);inline-size:100%}.c-textareaWrapper textarea{font-size:calc(var(--dt-font-body-l-size) * 1px);line-height:var(--textarea-line-height);font-family:var(--dt-font-body-l-family);resize:var(--textarea-resize);border:none;background-color:var(--textarea-background-color);color:var(--textarea-content-color);block-size:var(--textarea-height);max-block-size:var(--textarea-max-height);min-block-size:var(--textarea-min-height);inline-size:100%;padding-block-start:var(--textarea-padding-block);padding-block-end:var(--textarea-padding-block);padding-inline-start:var(--textarea-padding-inline);padding-inline-end:var(--textarea-padding-inline)}.c-textareaWrapper textarea:focus{box-shadow:none;outline:none}.c-textareaWrapper textarea::placeholder{color:var(--textarea-placeholder-color);opacity:1}.c-textareaWrapper.c-textarea--readonly{--textarea-background-color: var(--dt-color-container-subtle);--textarea-border-color: var(--dt-color-interactive-form)}.c-textareaWrapper.c-textarea--disabled{--textarea-background-color: var(--dt-color-disabled-01);--textarea-border-color: var(--dt-color-disabled-01);--textarea-content-color: var(--dt-color-content-disabled);--textarea-placeholder-color: var(--dt-color-content-disabled)}@media (hover: hover){.c-textareaWrapper:hover:not(.c-textarea--disabled,.c-textarea--readonly){--textarea-background-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))))}}.c-textareaWrapper:focus-within{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-textareaWrapper.c-textarea--large{--textarea-padding-block: var(--dt-spacing-c)}.c-textareaWrapper.c-textarea--small{--textarea-padding-block: var(--dt-spacing-a)}.c-textareaWrapper.c-textarea--resize-manual{--textarea-resize: vertical;--textarea-min-height: calc((var(--textarea-line-height) * 1) + (var(--textarea-padding-block) * 2))}@media (pointer: coarse){.c-textareaWrapper.c-textarea--resize-manual{--textarea-height: calc((var(--textarea-line-height) * 6) + (var(--textarea-padding-block) * 2));--textarea-min-height: calc((var(--textarea-line-height) * 6) + (var(--textarea-padding-block) * 2));--textarea-max-height: calc((var(--textarea-line-height) * 6) + (var(--textarea-padding-block) * 2));--textarea-resize: none}}.c-textareaWrapper.c-textarea--resize-auto{--textarea-max-height: calc((var(--textarea-line-height) * 6) + (var(--textarea-padding-block) * 2));--textarea-min-height: var(--textarea-height)}.c-textareaWrapper.c-textarea--error{--textarea-border-color: var(--dt-color-support-error)}", me = ["small", "medium", "large"], ye = ["auto", "manual"], ze = ["default", "success", "error"], c = {
100
100
  disabled: !1,
101
101
  size: "medium",
@@ -108,22 +108,22 @@ const ge = /* @__PURE__ */ Y(ve), be = "*,*:after,*:before{box-sizing:inherit}.c
108
108
  readonly: !1,
109
109
  required: !1
110
110
  };
111
- var ke = Object.defineProperty, n = (t, e, a, s) => {
112
- for (var o = void 0, h = t.length - 1, u; h >= 0; h--)
113
- (u = t[h]) && (o = u(e, a, o) || o);
114
- return o && ke(e, a, o), o;
111
+ var ke = Object.defineProperty, n = (e, t, a, d) => {
112
+ for (var o = void 0, p = e.length - 1, u; p >= 0; p--)
113
+ (u = e[p]) && (o = u(t, a, o) || o);
114
+ return o && ke(t, a, o), o;
115
115
  };
116
- const m = "pie-textarea", I = "assistive-text", W = class W extends U(X(M)) {
116
+ const b = "pie-textarea", O = "assistive-text", W = class W extends U(X(L)) {
117
117
  constructor() {
118
118
  super(...arguments), this.value = c.value, this.disabled = c.disabled, this.size = c.size, this.resize = c.resize, this.label = c.label, this.readonly = c.readonly, this.autoFocus = c.autoFocus, this.required = c.required, this.status = c.status, this._throttledResize = ge(() => {
119
119
  this.resize === "auto" && (this._textarea.style.height = "auto", this._textarea.style.height = `${this._textarea.scrollHeight}px`);
120
- }, 100), this.handleInput = (e, a) => {
121
- e ? this.value = e.target.value : a && (this.value = a), this.restrictInputLength(), this._internals.setFormValue(this.value), this.handleResize();
122
- }, this.handleChange = (e) => {
123
- const a = J(e);
120
+ }, 100), this.handleInput = (t, a) => {
121
+ t ? this.value = t.target.value : a && (this.value = a), this._internals.setFormValue(this.value), this.handleResize();
122
+ }, this.handleChange = (t) => {
123
+ const a = J(t);
124
124
  this.dispatchEvent(a);
125
- }, this.handleKeyDown = (e) => {
126
- e.key === "Enter" && e.stopPropagation();
125
+ }, this.handleKeyDown = (t) => {
126
+ t.key === "Enter" && t.stopPropagation();
127
127
  };
128
128
  }
129
129
  /**
@@ -139,8 +139,8 @@ const m = "pie-textarea", I = "assistive-text", W = class W extends U(X(M)) {
139
139
  * or because the disabled state changed on a <fieldset> that's an ancestor of this element.
140
140
  * @param disabled - The latest disabled state of the input.
141
141
  */
142
- formDisabledCallback(e) {
143
- this.disabled = e;
142
+ formDisabledCallback(t) {
143
+ this.disabled = t;
144
144
  }
145
145
  /**
146
146
  * Called when the form that owns this component is reset.
@@ -150,80 +150,72 @@ const m = "pie-textarea", I = "assistive-text", W = class W extends U(X(M)) {
150
150
  this.value = this.defaultValue ?? c.value, this._internals.setFormValue(this.value);
151
151
  }
152
152
  firstUpdated() {
153
- this.restrictInputLength(), this._internals.setFormValue(this.value), window.addEventListener("resize", () => this.handleResize()), this._textarea.addEventListener("keydown", this.handleKeyDown);
153
+ this._internals.setFormValue(this.value), window.addEventListener("resize", () => this.handleResize()), this._textarea.addEventListener("keydown", this.handleKeyDown);
154
154
  }
155
155
  handleResize() {
156
156
  this._throttledResize();
157
157
  }
158
- restrictInputLength() {
159
- if (this.label.length && this.maxLength && this.value.length > this.maxLength) {
160
- const e = this.value.slice(0, this.maxLength);
161
- this._textarea.value = e, this.value = e;
162
- }
163
- }
164
- updated(e) {
165
- e.has("value") && this.handleInput(null, this.value), this.resize === "auto" && (e.has("resize") || e.has("size")) && this.handleResize();
158
+ updated(t) {
159
+ t.has("value") && this.handleInput(null, this.value), this.resize === "auto" && (t.has("resize") || t.has("size")) && this.handleResize();
166
160
  }
167
161
  disconnectedCallback() {
168
162
  this._textarea.removeEventListener("keydown", this.handleKeyDown), window.removeEventListener("resize", () => this.handleResize());
169
163
  }
170
- renderLabel(e, a) {
171
- const s = a ? `${this.value.length}/${a}` : void 0;
172
- return e != null && e.length ? j`<pie-form-label for="${m}" trailing=${b(s)}>${e}</pie-form-label>` : q;
164
+ renderLabel(t) {
165
+ return t != null && t.length ? j`<pie-form-label for="${b}">${t}</pie-form-label>` : M;
173
166
  }
174
167
  renderAssistiveText() {
175
168
  return this.assistiveText ? j`
176
169
  <pie-assistive-text
177
- id="${I}"
178
- variant=${b(this.status)}
170
+ id="${O}"
171
+ variant=${m(this.status)}
179
172
  data-test-id="pie-textarea-assistive-text">
180
173
  ${this.assistiveText}
181
174
  </pie-assistive-text>
182
- ` : q;
175
+ ` : M;
183
176
  }
184
177
  render() {
185
178
  const {
186
- disabled: e,
179
+ disabled: t,
187
180
  resize: a,
188
- size: s,
181
+ size: d,
189
182
  autocomplete: o,
190
- autoFocus: h,
183
+ autoFocus: p,
191
184
  name: u,
192
- readonly: d,
193
- placeholder: p,
185
+ readonly: s,
186
+ placeholder: h,
194
187
  value: x,
195
188
  required: k,
196
189
  label: v,
197
- maxLength: y,
198
190
  status: g,
199
- assistiveText: _
191
+ assistiveText: y
200
192
  } = this, E = {
201
193
  "c-textareaWrapper": !0,
202
- "c-textarea--disabled": e,
203
- "c-textarea--readonly": d,
194
+ "c-textarea--disabled": t,
195
+ "c-textarea--readonly": s,
204
196
  "c-textarea--error": g === "error",
205
197
  [`c-textarea--resize-${a}`]: !0,
206
- [`c-textarea--${s}`]: !0
198
+ [`c-textarea--${d}`]: !0
207
199
  };
208
200
  return j`<div>
209
- ${this.renderLabel(v, y)}
201
+ ${this.renderLabel(v)}
210
202
  <div
211
203
  class="${G(E)}"
212
204
  data-test-id="pie-textarea-wrapper">
213
205
  <textarea
214
- id="${m}"
215
- data-test-id="${m}"
216
- name=${b(u)}
217
- autocomplete=${b(o)}
218
- placeholder=${b(p)}
206
+ id="${b}"
207
+ data-test-id="${b}"
208
+ name=${m(u)}
209
+ autocomplete=${m(o)}
210
+ placeholder=${m(h)}
219
211
  .value=${H(x)}
220
- ?autofocus=${h}
221
- ?readonly=${d}
212
+ ?autofocus=${p}
213
+ ?readonly=${s}
222
214
  ?required=${k}
223
- ?disabled=${e}
224
- aria-describedby=${b(_ ? I : void 0)}
215
+ ?disabled=${t}
216
+ aria-describedby=${m(y ? O : void 0)}
225
217
  aria-invalid=${g === "error" ? "true" : "false"}
226
- aria-errormessage="${b(g === "error" ? I : void 0)}"
218
+ aria-errormessage="${m(g === "error" ? O : void 0)}"
227
219
  @input=${this.handleInput}
228
220
  @change=${this.handleChange}
229
221
  ></textarea>
@@ -232,65 +224,62 @@ const m = "pie-textarea", I = "assistive-text", W = class W extends U(X(M)) {
232
224
  </div>`;
233
225
  }
234
226
  };
235
- W.shadowRootOptions = { ...M.shadowRootOptions, delegatesFocus: !0 }, W.styles = P(be);
236
- let r = W;
227
+ W.shadowRootOptions = { ...L.shadowRootOptions, delegatesFocus: !0 }, W.styles = P(be);
228
+ let i = W;
237
229
  n([
238
230
  l({ type: String })
239
- ], r.prototype, "value");
231
+ ], i.prototype, "value");
240
232
  n([
241
233
  l({ type: String })
242
- ], r.prototype, "defaultValue");
234
+ ], i.prototype, "defaultValue");
243
235
  n([
244
236
  l({ type: Boolean, reflect: !0 })
245
- ], r.prototype, "disabled");
237
+ ], i.prototype, "disabled");
246
238
  n([
247
239
  l({ type: String }),
248
- C(m, me, c.size)
249
- ], r.prototype, "size");
240
+ C(b, me, c.size)
241
+ ], i.prototype, "size");
250
242
  n([
251
243
  l({ type: String }),
252
- C(m, ye, c.resize)
253
- ], r.prototype, "resize");
244
+ C(b, ye, c.resize)
245
+ ], i.prototype, "resize");
254
246
  n([
255
247
  l({ type: String })
256
- ], r.prototype, "label");
257
- n([
258
- l({ type: Number })
259
- ], r.prototype, "maxLength");
248
+ ], i.prototype, "label");
260
249
  n([
261
250
  l({ type: Boolean })
262
- ], r.prototype, "readonly");
251
+ ], i.prototype, "readonly");
263
252
  n([
264
253
  l({ type: Boolean })
265
- ], r.prototype, "autoFocus");
254
+ ], i.prototype, "autoFocus");
266
255
  n([
267
256
  l({ type: Boolean })
268
- ], r.prototype, "required");
257
+ ], i.prototype, "required");
269
258
  n([
270
259
  l({ type: String }),
271
- C(m, ze, c.status)
272
- ], r.prototype, "status");
260
+ C(b, ze, c.status)
261
+ ], i.prototype, "status");
273
262
  n([
274
263
  l({ type: String })
275
- ], r.prototype, "assistiveText");
264
+ ], i.prototype, "assistiveText");
276
265
  n([
277
266
  l({ type: String })
278
- ], r.prototype, "name");
267
+ ], i.prototype, "name");
279
268
  n([
280
269
  l({ type: String })
281
- ], r.prototype, "autocomplete");
270
+ ], i.prototype, "autocomplete");
282
271
  n([
283
272
  l({ type: String })
284
- ], r.prototype, "placeholder");
273
+ ], i.prototype, "placeholder");
285
274
  n([
286
- V("textarea")
287
- ], r.prototype, "_textarea");
275
+ D("textarea")
276
+ ], i.prototype, "_textarea");
288
277
  n([
289
- V("textarea")
290
- ], r.prototype, "focusTarget");
291
- Q(m, r);
278
+ D("textarea")
279
+ ], i.prototype, "focusTarget");
280
+ Q(b, i);
292
281
  export {
293
- r as PieTextarea,
282
+ i as PieTextarea,
294
283
  c as defaultProps,
295
284
  ye as resizeModes,
296
285
  me as sizes,
package/dist/react.d.ts CHANGED
@@ -13,7 +13,7 @@ import type { TemplateResult } from 'lit-html';
13
13
  /**
14
14
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
15
15
  */
16
- declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'maxLength' | 'assistiveText' | 'defaultValue'>>;
16
+ declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue'>>;
17
17
 
18
18
  /**
19
19
  * Default values for optional properties that have default fallback values in the component.
@@ -39,7 +39,6 @@ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps, P
39
39
  size: "small" | "medium" | "large";
40
40
  resize: "auto" | "manual";
41
41
  label: string;
42
- maxLength: TextareaProps['maxLength'];
43
42
  readonly: boolean;
44
43
  autoFocus: boolean;
45
44
  required: boolean;
@@ -70,7 +69,6 @@ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps, P
70
69
  formResetCallback(): void;
71
70
  protected firstUpdated(): void;
72
71
  private handleResize;
73
- private restrictInputLength;
74
72
  protected updated(changedProperties: PropertyValues<this>): void;
75
73
  /**
76
74
  * Handles input events and updates the component's value based on the input event or a provided new value.
@@ -85,7 +83,7 @@ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps, P
85
83
  private handleChange;
86
84
  private handleKeyDown;
87
85
  disconnectedCallback(): void;
88
- renderLabel(label: string, maxLength?: number): TemplateResult<1> | typeof nothing;
86
+ renderLabel(label: string): TemplateResult<1> | typeof nothing;
89
87
  renderAssistiveText(): TemplateResult<1> | typeof nothing;
90
88
  render(): TemplateResult<1>;
91
89
  static styles: CSSResult;
@@ -165,11 +163,6 @@ export declare interface TextareaProps {
165
163
  * The label text for the textarea field.
166
164
  */
167
165
  label?: string;
168
- /**
169
- * The maximum number of characters allowed in the textarea field.
170
- * If the `label` property is not set, this property will have no effect.
171
- */
172
- maxLength?: number;
173
166
  /**
174
167
  * The placeholder text to display when the textarea is empty.
175
168
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-textarea",
3
3
  "description": "PIE Design System Textarea built using Web Components",
4
- "version": "0.11.1",
4
+ "version": "0.12.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
package/src/defs.ts CHANGED
@@ -76,12 +76,6 @@ export interface TextareaProps {
76
76
  */
77
77
  label?: string;
78
78
 
79
- /**
80
- * The maximum number of characters allowed in the textarea field.
81
- * If the `label` property is not set, this property will have no effect.
82
- */
83
- maxLength?: number;
84
-
85
79
  /**
86
80
  * The placeholder text to display when the textarea is empty.
87
81
  */
@@ -91,7 +85,7 @@ export interface TextareaProps {
91
85
  /**
92
86
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
93
87
  */
94
- type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'maxLength' | 'assistiveText' | 'defaultValue'>>;
88
+ type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue'>>;
95
89
 
96
90
  /**
97
91
  * Default values for optional properties that have default fallback values in the component.
package/src/index.ts CHANGED
@@ -52,9 +52,6 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
52
52
  @property({ type: String })
53
53
  public label = defaultProps.label;
54
54
 
55
- @property({ type: Number })
56
- public maxLength: TextareaProps['maxLength'];
57
-
58
55
  @property({ type: Boolean })
59
56
  public readonly = defaultProps.readonly;
60
57
 
@@ -122,7 +119,6 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
122
119
  }
123
120
 
124
121
  protected firstUpdated (): void {
125
- this.restrictInputLength();
126
122
  this._internals.setFormValue(this.value);
127
123
 
128
124
  window.addEventListener('resize', () => this.handleResize());
@@ -133,16 +129,6 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
133
129
  this._throttledResize();
134
130
  }
135
131
 
136
- private restrictInputLength () {
137
- if (this.label.length && this.maxLength && this.value.length > this.maxLength) {
138
- const trimmedValue = this.value.slice(0, this.maxLength);
139
- // Ensures that the internal text area is correctly trimmed and synced with our value.
140
- // The live() directive does not solve this for us.
141
- this._textarea.value = trimmedValue;
142
- this.value = trimmedValue;
143
- }
144
- }
145
-
146
132
  protected updated (changedProperties: PropertyValues<this>) {
147
133
  if (changedProperties.has('value')) {
148
134
  this.handleInput(null, this.value);
@@ -169,7 +155,6 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
169
155
  this.value = newValue;
170
156
  }
171
157
 
172
- this.restrictInputLength();
173
158
  this._internals.setFormValue(this.value);
174
159
 
175
160
  this.handleResize();
@@ -196,11 +181,9 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
196
181
  window.removeEventListener('resize', () => this.handleResize());
197
182
  }
198
183
 
199
- renderLabel (label: string, maxLength?: number) {
200
- const characterCount = maxLength ? `${this.value.length}/${maxLength}` : undefined;
201
-
184
+ renderLabel (label: string) {
202
185
  return label?.length
203
- ? html`<pie-form-label for="${componentSelector}" trailing=${ifDefined(characterCount)}>${label}</pie-form-label>`
186
+ ? html`<pie-form-label for="${componentSelector}">${label}</pie-form-label>`
204
187
  : nothing;
205
188
  }
206
189
 
@@ -232,7 +215,6 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
232
215
  value,
233
216
  required,
234
217
  label,
235
- maxLength,
236
218
  status,
237
219
  assistiveText,
238
220
  } = this;
@@ -247,7 +229,7 @@ export class PieTextarea extends FormControlMixin(RtlMixin(LitElement)) implemen
247
229
  };
248
230
 
249
231
  return html`<div>
250
- ${this.renderLabel(label, maxLength)}
232
+ ${this.renderLabel(label)}
251
233
  <div
252
234
  class="${classMap(classes)}"
253
235
  data-test-id="pie-textarea-wrapper">