@justeattakeaway/pie-textarea 0.22.0 → 0.23.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/README.md CHANGED
@@ -39,6 +39,7 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
39
39
  ### Properties
40
40
  | Prop | Options | Description | Default |
41
41
  |----------------|--------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
42
+ | `aria` | `{ label?: string }` | ARIA attributes for the textarea. Offers `label` — use it when no visible label is associated with the textarea. | `undefined` |
42
43
  | `assistiveText`| `string` | Allows assistive text to be displayed below the textarea. Must be provided if using a non-default status. | `undefined` |
43
44
  | `autocomplete` | `string` | Allows enabling or disabling autocomplete. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for values. | `undefined` |
44
45
  | `autoFocus` | `true`, `false` | If true, focuses the textarea on first render. Only one element should have `autofocus`. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus). | `false` |
@@ -203,6 +203,15 @@
203
203
  "privacy": "public",
204
204
  "attribute": "rows"
205
205
  },
206
+ {
207
+ "kind": "field",
208
+ "name": "aria",
209
+ "type": {
210
+ "text": "TextareaProps['aria']"
211
+ },
212
+ "privacy": "public",
213
+ "attribute": "aria"
214
+ },
206
215
  {
207
216
  "kind": "field",
208
217
  "name": "_textarea",
@@ -451,6 +460,13 @@
451
460
  "text": "TextareaProps['rows']"
452
461
  },
453
462
  "fieldName": "rows"
463
+ },
464
+ {
465
+ "name": "aria",
466
+ "type": {
467
+ "text": "TextareaProps['aria']"
468
+ },
469
+ "fieldName": "aria"
454
470
  }
455
471
  ],
456
472
  "mixins": [
package/dist/index.d.ts CHANGED
@@ -8,10 +8,17 @@ import { PropertyValues } from 'lit';
8
8
  import { RTLInterface } from '@justeattakeaway/pie-webc-core';
9
9
  import { TemplateResult } from 'lit-html';
10
10
 
11
+ declare type AriaProps = {
12
+ /**
13
+ * Provides an accessible label for the textarea. Should be used when no visible label is associated with the textarea.
14
+ */
15
+ label?: string;
16
+ };
17
+
11
18
  /**
12
19
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
13
20
  */
14
- declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue' | 'maxlength' | 'rows'>>;
21
+ declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue' | 'maxlength' | 'rows' | 'aria'>>;
15
22
 
16
23
  /**
17
24
  * Default values for optional properties that have default fallback values in the component.
@@ -39,6 +46,7 @@ export declare class PieTextarea extends PieTextarea_base implements TextareaPro
39
46
  placeholder: TextareaProps['placeholder'];
40
47
  maxlength: TextareaProps['maxlength'];
41
48
  rows: TextareaProps['rows'];
49
+ aria: TextareaProps['aria'];
42
50
  private _textarea;
43
51
  focusTarget: HTMLElement;
44
52
  private _abortController;
@@ -95,6 +103,10 @@ export declare const sizes: readonly ["small", "medium", "large"];
95
103
  export declare const statusTypes: readonly ["default", "success", "error"];
96
104
 
97
105
  export declare interface TextareaProps {
106
+ /**
107
+ * ARIA attributes for the textarea.
108
+ */
109
+ aria?: AriaProps;
98
110
  /**
99
111
  * Same as the HTML disabled attribute - indicates whether the textarea is disabled.
100
112
  */
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { LitElement as de, html as Y, unsafeCSS as ce } from "lit";
2
- import { property as l, query as ee } from "lit/decorators.js";
2
+ import { property as s, query as ee } from "lit/decorators.js";
3
3
  import { classMap as ue } from "lit/directives/class-map.js";
4
- import { ifDefined as b } from "lit/directives/if-defined.js";
4
+ import { ifDefined as f } from "lit/directives/if-defined.js";
5
5
  import { live as pe } from "lit/directives/live.js";
6
6
  import "@justeattakeaway/pie-assistive-text";
7
7
  import { FormControlMixin as he, RtlMixin as xe, DelegatesFocusMixin as fe, wrapNativeEvent as ve, validPropertyValues as U, safeCustomElement as ge } from "@justeattakeaway/pie-webc-core";
8
- const O = class O extends de {
8
+ const I = class I extends de {
9
9
  willUpdate() {
10
- this.getAttribute("v") || this.setAttribute("v", O.v);
10
+ this.getAttribute("v") || this.setAttribute("v", I.v);
11
11
  }
12
12
  };
13
- O.v = "0.22.0";
14
- let P = O;
15
- var j = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
13
+ I.v = "0.23.0";
14
+ let P = I;
15
+ var E = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
16
16
  function be(e) {
17
17
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
18
18
  }
@@ -20,92 +20,92 @@ var V, Z;
20
20
  function me() {
21
21
  if (Z) return V;
22
22
  Z = 1;
23
- var e = "Expected a function", n = NaN, h = "[object Symbol]", f = /^\s+|\s+$/g, c = /^[-+]0x[0-9a-f]+$/i, m = /^0b[01]+$/i, v = /^0o[0-7]+$/i, E = parseInt, I = typeof j == "object" && j && j.Object === Object && j, F = typeof self == "object" && self && self.Object === Object && self, k = I || F || Function("return this")(), R = Object.prototype, L = R.toString, M = Math.max, q = Math.min, D = function() {
23
+ var e = "Expected a function", n = NaN, h = "[object Symbol]", v = /^\s+|\s+$/g, c = /^[-+]0x[0-9a-f]+$/i, m = /^0b[01]+$/i, g = /^0o[0-7]+$/i, F = parseInt, R = typeof E == "object" && E && E.Object === Object && E, L = typeof self == "object" && self && self.Object === Object && self, k = R || L || Function("return this")(), M = Object.prototype, q = M.toString, D = Math.max, $ = Math.min, _ = function() {
24
24
  return k.Date.now();
25
25
  };
26
- function te(t, i, s) {
27
- var p, x, w, z, u, y, $ = 0, K = !1, _ = !1, A = !0;
26
+ function te(t, o, l) {
27
+ var p, x, j, z, u, y, T = 0, K = !1, C = !1, A = !0;
28
28
  if (typeof t != "function")
29
29
  throw new TypeError(e);
30
- i = G(i) || 0, S(s) && (K = !!s.leading, _ = "maxWait" in s, w = _ ? M(G(s.maxWait) || 0, i) : w, A = "trailing" in s ? !!s.trailing : A);
31
- function B(a) {
32
- var g = p, T = x;
33
- return p = x = void 0, $ = a, z = t.apply(T, g), z;
30
+ o = G(o) || 0, W(l) && (K = !!l.leading, C = "maxWait" in l, j = C ? D(G(l.maxWait) || 0, o) : j, A = "trailing" in l ? !!l.trailing : A);
31
+ function B(r) {
32
+ var b = p, S = x;
33
+ return p = x = void 0, T = r, z = t.apply(S, b), z;
34
34
  }
35
- function oe(a) {
36
- return $ = a, u = setTimeout(W, i), K ? B(a) : z;
35
+ function oe(r) {
36
+ return T = r, u = setTimeout(O, o), K ? B(r) : z;
37
37
  }
38
- function ne(a) {
39
- var g = a - y, T = a - $, Q = i - g;
40
- return _ ? q(Q, w - T) : Q;
38
+ function ne(r) {
39
+ var b = r - y, S = r - T, Q = o - b;
40
+ return C ? $(Q, j - S) : Q;
41
41
  }
42
- function X(a) {
43
- var g = a - y, T = a - $;
44
- return y === void 0 || g >= i || g < 0 || _ && T >= w;
42
+ function X(r) {
43
+ var b = r - y, S = r - T;
44
+ return y === void 0 || b >= o || b < 0 || C && S >= j;
45
45
  }
46
- function W() {
47
- var a = D();
48
- if (X(a))
49
- return J(a);
50
- u = setTimeout(W, ne(a));
46
+ function O() {
47
+ var r = _();
48
+ if (X(r))
49
+ return J(r);
50
+ u = setTimeout(O, ne(r));
51
51
  }
52
- function J(a) {
53
- return u = void 0, A && p ? B(a) : (p = x = void 0, z);
52
+ function J(r) {
53
+ return u = void 0, A && p ? B(r) : (p = x = void 0, z);
54
54
  }
55
55
  function se() {
56
- u !== void 0 && clearTimeout(u), $ = 0, p = y = x = u = void 0;
56
+ u !== void 0 && clearTimeout(u), T = 0, p = y = x = u = void 0;
57
57
  }
58
58
  function le() {
59
- return u === void 0 ? z : J(D());
59
+ return u === void 0 ? z : J(_());
60
60
  }
61
61
  function N() {
62
- var a = D(), g = X(a);
63
- if (p = arguments, x = this, y = a, g) {
62
+ var r = _(), b = X(r);
63
+ if (p = arguments, x = this, y = r, b) {
64
64
  if (u === void 0)
65
65
  return oe(y);
66
- if (_)
67
- return u = setTimeout(W, i), B(y);
66
+ if (C)
67
+ return u = setTimeout(O, o), B(y);
68
68
  }
69
- return u === void 0 && (u = setTimeout(W, i)), z;
69
+ return u === void 0 && (u = setTimeout(O, o)), z;
70
70
  }
71
71
  return N.cancel = se, N.flush = le, N;
72
72
  }
73
- function re(t, i, s) {
73
+ function ae(t, o, l) {
74
74
  var p = !0, x = !0;
75
75
  if (typeof t != "function")
76
76
  throw new TypeError(e);
77
- return S(s) && (p = "leading" in s ? !!s.leading : p, x = "trailing" in s ? !!s.trailing : x), te(t, i, {
77
+ return W(l) && (p = "leading" in l ? !!l.leading : p, x = "trailing" in l ? !!l.trailing : x), te(t, o, {
78
78
  leading: p,
79
- maxWait: i,
79
+ maxWait: o,
80
80
  trailing: x
81
81
  });
82
82
  }
83
- function S(t) {
84
- var i = typeof t;
85
- return !!t && (i == "object" || i == "function");
83
+ function W(t) {
84
+ var o = typeof t;
85
+ return !!t && (o == "object" || o == "function");
86
86
  }
87
- function ae(t) {
87
+ function re(t) {
88
88
  return !!t && typeof t == "object";
89
89
  }
90
90
  function ie(t) {
91
- return typeof t == "symbol" || ae(t) && L.call(t) == h;
91
+ return typeof t == "symbol" || re(t) && q.call(t) == h;
92
92
  }
93
93
  function G(t) {
94
94
  if (typeof t == "number")
95
95
  return t;
96
96
  if (ie(t))
97
97
  return n;
98
- if (S(t)) {
99
- var i = typeof t.valueOf == "function" ? t.valueOf() : t;
100
- t = S(i) ? i + "" : i;
98
+ if (W(t)) {
99
+ var o = typeof t.valueOf == "function" ? t.valueOf() : t;
100
+ t = W(o) ? o + "" : o;
101
101
  }
102
102
  if (typeof t != "string")
103
103
  return t === 0 ? t : +t;
104
- t = t.replace(f, "");
105
- var s = m.test(t);
106
- return s || v.test(t) ? E(t.slice(2), s ? 2 : 8) : c.test(t) ? n : +t;
104
+ t = t.replace(v, "");
105
+ var l = m.test(t);
106
+ return l || g.test(t) ? F(t.slice(2), l ? 2 : 8) : c.test(t) ? n : +t;
107
107
  }
108
- return V = re, V;
108
+ return V = ae, V;
109
109
  }
110
110
  var ye = me();
111
111
  const ze = /* @__PURE__ */ be(ye), ke = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.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-border-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.is-readonly{--textarea-background-color: var(--dt-color-container-subtle);--textarea-border-color: var(--dt-color-border-form)}.c-textareaWrapper.is-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(.is-disabled,.is-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))))}@supports (background-color: color-mix(in srgb,black,white)){.c-textareaWrapper:hover:not(.is-disabled,.is-readonly){--textarea-background-color: color-mix(in srgb, var(--dt-color-hover-01-bg) var(--dt-color-hover-01), var(--dt-color-container-default))}}}.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-height: auto;--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--resize-none{--textarea-height: auto}.c-textareaWrapper.has-error{--textarea-border-color: var(--dt-color-support-error)}", $e = ["small", "medium", "large"], _e = ["auto", "manual", "none"], Te = ["default", "success", "error"], d = {
@@ -119,13 +119,13 @@ const ze = /* @__PURE__ */ be(ye), ke = "*,*:after,*:before{box-sizing:inherit}:
119
119
  readonly: !1,
120
120
  required: !1
121
121
  };
122
- var Ce = Object.defineProperty, Se = Object.getOwnPropertyDescriptor, o = (e, n, h, f) => {
123
- for (var c = f > 1 ? void 0 : f ? Se(n, h) : n, m = e.length - 1, v; m >= 0; m--)
124
- (v = e[m]) && (c = (f ? v(n, h, c) : v(c)) || c);
125
- return f && c && Ce(n, h, c), c;
122
+ var Ce = Object.defineProperty, Se = Object.getOwnPropertyDescriptor, i = (e, n, h, v) => {
123
+ for (var c = v > 1 ? void 0 : v ? Se(n, h) : n, m = e.length - 1, g; m >= 0; m--)
124
+ (g = e[m]) && (c = (v ? g(n, h, c) : g(c)) || c);
125
+ return v && c && Ce(n, h, c), c;
126
126
  };
127
- const C = "pie-textarea", H = "assistive-text";
128
- let r = class extends he(xe(fe(P))) {
127
+ const w = "pie-textarea", H = "assistive-text";
128
+ let a = class extends he(xe(fe(P))) {
129
129
  constructor() {
130
130
  super(...arguments), this.value = d.value, this.disabled = d.disabled, this.size = d.size, this.resize = d.resize, this.readonly = d.readonly, this.autoFocus = d.autoFocus, this.required = d.required, this.status = d.status, this._throttledResize = ze(() => {
131
131
  this.resize === "auto" && (this._textarea.style.height = "auto", this._textarea.style.height = `${this._textarea.scrollHeight}px`);
@@ -189,7 +189,7 @@ let r = class extends he(xe(fe(P))) {
189
189
  return Y`
190
190
  <pie-assistive-text
191
191
  id="${H}"
192
- variant=${b(this.status)}
192
+ variant=${f(this.status)}
193
193
  message=${this.assistiveText || ""}
194
194
  ?isVisuallyHidden=${!this.assistiveText}
195
195
  data-test-id="pie-textarea-assistive-text">
@@ -201,113 +201,118 @@ let r = class extends he(xe(fe(P))) {
201
201
  disabled: e,
202
202
  resize: n,
203
203
  size: h,
204
- autocomplete: f,
204
+ autocomplete: v,
205
205
  autoFocus: c,
206
206
  name: m,
207
- readonly: v,
208
- placeholder: E,
209
- value: I,
210
- required: F,
207
+ readonly: g,
208
+ placeholder: F,
209
+ value: R,
210
+ required: L,
211
211
  status: k,
212
- assistiveText: R,
213
- maxlength: L,
214
- rows: M
215
- } = this, q = {
212
+ assistiveText: M,
213
+ maxlength: q,
214
+ rows: D,
215
+ aria: $
216
+ } = this, _ = {
216
217
  "c-textareaWrapper": !0,
217
218
  "is-disabled": e,
218
- "is-readonly": v,
219
+ "is-readonly": g,
219
220
  "has-error": k === "error",
220
221
  [`c-textarea--resize-${n}`]: !0,
221
222
  [`c-textarea--${h}`]: !0
222
223
  };
223
224
  return Y`<div>
224
225
  <div
225
- class="${ue(q)}"
226
+ class="${ue(_)}"
226
227
  data-test-id="pie-textarea-wrapper">
227
228
  <textarea
228
- id="${C}"
229
- data-test-id="${C}"
230
- name=${b(m)}
231
- autocomplete=${b(f)}
232
- placeholder=${b(E)}
233
- .value=${pe(I)}
229
+ id="${w}"
230
+ data-test-id="${w}"
231
+ name=${f(m)}
232
+ autocomplete=${f(v)}
233
+ placeholder=${f(F)}
234
+ .value=${pe(R)}
234
235
  ?autofocus=${c}
235
- ?readonly=${v}
236
- ?required=${F}
236
+ ?readonly=${g}
237
+ ?required=${L}
237
238
  ?disabled=${e}
238
- aria-describedby=${b(R ? H : void 0)}
239
+ aria-label=${f($ == null ? void 0 : $.label)}
240
+ aria-describedby=${f(M ? H : void 0)}
239
241
  aria-invalid=${k === "error" ? "true" : "false"}
240
- aria-errormessage="${b(k === "error" ? H : void 0)}"
242
+ aria-errormessage="${f(k === "error" ? H : void 0)}"
241
243
  @input=${this.handleInput}
242
244
  @change=${this.handleChange}
243
- maxlength=${b(L)}
244
- rows=${b(M)}
245
+ maxlength=${f(q)}
246
+ rows=${f(D)}
245
247
  ></textarea>
246
248
  </div>
247
249
  ${this.renderAssistiveText()}
248
250
  </div>`;
249
251
  }
250
252
  };
251
- r.styles = ce(ke);
252
- o([
253
- l({ type: String })
254
- ], r.prototype, "value", 2);
255
- o([
256
- l({ type: String })
257
- ], r.prototype, "defaultValue", 2);
258
- o([
259
- l({ type: Boolean, reflect: !0 })
260
- ], r.prototype, "disabled", 2);
261
- o([
262
- l({ type: String }),
263
- U(C, $e, d.size)
264
- ], r.prototype, "size", 2);
265
- o([
266
- l({ type: String }),
267
- U(C, _e, d.resize)
268
- ], r.prototype, "resize", 2);
269
- o([
270
- l({ type: Boolean })
271
- ], r.prototype, "readonly", 2);
272
- o([
273
- l({ type: Boolean })
274
- ], r.prototype, "autoFocus", 2);
275
- o([
276
- l({ type: Boolean })
277
- ], r.prototype, "required", 2);
278
- o([
279
- l({ type: String }),
280
- U(C, Te, d.status)
281
- ], r.prototype, "status", 2);
282
- o([
283
- l({ type: String })
284
- ], r.prototype, "assistiveText", 2);
285
- o([
286
- l({ type: String, reflect: !0 })
287
- ], r.prototype, "name", 2);
288
- o([
289
- l({ type: String })
290
- ], r.prototype, "autocomplete", 2);
291
- o([
292
- l({ type: String })
293
- ], r.prototype, "placeholder", 2);
294
- o([
295
- l({ type: Number })
296
- ], r.prototype, "maxlength", 2);
297
- o([
298
- l({ type: Number })
299
- ], r.prototype, "rows", 2);
300
- o([
253
+ a.styles = ce(ke);
254
+ i([
255
+ s({ type: String })
256
+ ], a.prototype, "value", 2);
257
+ i([
258
+ s({ type: String })
259
+ ], a.prototype, "defaultValue", 2);
260
+ i([
261
+ s({ type: Boolean, reflect: !0 })
262
+ ], a.prototype, "disabled", 2);
263
+ i([
264
+ s({ type: String }),
265
+ U(w, $e, d.size)
266
+ ], a.prototype, "size", 2);
267
+ i([
268
+ s({ type: String }),
269
+ U(w, _e, d.resize)
270
+ ], a.prototype, "resize", 2);
271
+ i([
272
+ s({ type: Boolean })
273
+ ], a.prototype, "readonly", 2);
274
+ i([
275
+ s({ type: Boolean })
276
+ ], a.prototype, "autoFocus", 2);
277
+ i([
278
+ s({ type: Boolean })
279
+ ], a.prototype, "required", 2);
280
+ i([
281
+ s({ type: String }),
282
+ U(w, Te, d.status)
283
+ ], a.prototype, "status", 2);
284
+ i([
285
+ s({ type: String })
286
+ ], a.prototype, "assistiveText", 2);
287
+ i([
288
+ s({ type: String, reflect: !0 })
289
+ ], a.prototype, "name", 2);
290
+ i([
291
+ s({ type: String })
292
+ ], a.prototype, "autocomplete", 2);
293
+ i([
294
+ s({ type: String })
295
+ ], a.prototype, "placeholder", 2);
296
+ i([
297
+ s({ type: Number })
298
+ ], a.prototype, "maxlength", 2);
299
+ i([
300
+ s({ type: Number })
301
+ ], a.prototype, "rows", 2);
302
+ i([
303
+ s({ type: Object })
304
+ ], a.prototype, "aria", 2);
305
+ i([
301
306
  ee("textarea")
302
- ], r.prototype, "_textarea", 2);
303
- o([
307
+ ], a.prototype, "_textarea", 2);
308
+ i([
304
309
  ee("textarea")
305
- ], r.prototype, "focusTarget", 2);
306
- r = o([
310
+ ], a.prototype, "focusTarget", 2);
311
+ a = i([
307
312
  ge("pie-textarea")
308
- ], r);
313
+ ], a);
309
314
  export {
310
- r as PieTextarea,
315
+ a as PieTextarea,
311
316
  d as defaultProps,
312
317
  _e as resizeModes,
313
318
  $e as sizes,
package/dist/react.d.ts CHANGED
@@ -9,10 +9,17 @@ import * as React_2 from 'react';
9
9
  import { RTLInterface } from '@justeattakeaway/pie-webc-core';
10
10
  import { TemplateResult } from 'lit-html';
11
11
 
12
+ declare type AriaProps = {
13
+ /**
14
+ * Provides an accessible label for the textarea. Should be used when no visible label is associated with the textarea.
15
+ */
16
+ label?: string;
17
+ };
18
+
12
19
  /**
13
20
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
14
21
  */
15
- declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue' | 'maxlength' | 'rows'>>;
22
+ declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue' | 'maxlength' | 'rows' | 'aria'>>;
16
23
 
17
24
  /**
18
25
  * Default values for optional properties that have default fallback values in the component.
@@ -42,6 +49,7 @@ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps, P
42
49
  placeholder: TextareaProps['placeholder'];
43
50
  maxlength: TextareaProps['maxlength'];
44
51
  rows: TextareaProps['rows'];
52
+ aria: TextareaProps['aria'];
45
53
  private _textarea;
46
54
  focusTarget: HTMLElement;
47
55
  private _abortController;
@@ -105,6 +113,10 @@ export declare const sizes: readonly ["small", "medium", "large"];
105
113
  export declare const statusTypes: readonly ["default", "success", "error"];
106
114
 
107
115
  export declare interface TextareaProps {
116
+ /**
117
+ * ARIA attributes for the textarea.
118
+ */
119
+ aria?: AriaProps;
108
120
  /**
109
121
  * Same as the HTML disabled attribute - indicates whether the textarea is disabled.
110
122
  */
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.22.0",
4
+ "version": "0.23.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -44,12 +44,12 @@
44
44
  "license": "Apache-2.0",
45
45
  "devDependencies": {
46
46
  "@justeattakeaway/pie-components-config": "0.21.3",
47
- "@justeattakeaway/pie-css": "1.3.0",
47
+ "@justeattakeaway/pie-css": "1.3.1",
48
48
  "@justeattakeaway/pie-monorepo-utils": "0.9.7",
49
49
  "@types/lodash.throttle": "4.1.9"
50
50
  },
51
51
  "dependencies": {
52
- "@justeattakeaway/pie-assistive-text": "1.0.4",
52
+ "@justeattakeaway/pie-assistive-text": "1.0.5",
53
53
  "@justeattakeaway/pie-webc-core": "16.0.0",
54
54
  "lodash.throttle": "4.1.1"
55
55
  },
package/src/defs.ts CHANGED
@@ -4,7 +4,19 @@ export const sizes = ['small', 'medium', 'large'] as const;
4
4
  export const resizeModes = ['auto', 'manual', 'none'] as const;
5
5
  export const statusTypes = ['default', 'success', 'error'] as const;
6
6
 
7
+ type AriaProps = {
8
+ /**
9
+ * Provides an accessible label for the textarea. Should be used when no visible label is associated with the textarea.
10
+ */
11
+ label?: string;
12
+ }
13
+
7
14
  export interface TextareaProps {
15
+ /**
16
+ * ARIA attributes for the textarea.
17
+ */
18
+ aria?: AriaProps;
19
+
8
20
  /**
9
21
  * Same as the HTML disabled attribute - indicates whether the textarea is disabled.
10
22
  */
@@ -93,7 +105,7 @@ export interface TextareaProps {
93
105
  /**
94
106
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
95
107
  */
96
- type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue' | 'maxlength' | 'rows'>>;
108
+ type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<TextareaProps, 'name' | 'autocomplete' | 'assistiveText' | 'defaultValue' | 'maxlength' | 'rows' | 'aria'>>;
97
109
 
98
110
  /**
99
111
  * Default values for optional properties that have default fallback values in the component.
package/src/index.ts CHANGED
@@ -81,6 +81,9 @@ export class PieTextarea extends FormControlMixin(RtlMixin(DelegatesFocusMixin(P
81
81
  @property({ type: Number })
82
82
  public rows: TextareaProps['rows'];
83
83
 
84
+ @property({ type: Object })
85
+ public aria: TextareaProps['aria'];
86
+
84
87
  @query('textarea')
85
88
  private _textarea!: HTMLTextAreaElement;
86
89
 
@@ -236,6 +239,7 @@ export class PieTextarea extends FormControlMixin(RtlMixin(DelegatesFocusMixin(P
236
239
  assistiveText,
237
240
  maxlength,
238
241
  rows,
242
+ aria,
239
243
  } = this;
240
244
 
241
245
  const classes = {
@@ -262,6 +266,7 @@ export class PieTextarea extends FormControlMixin(RtlMixin(DelegatesFocusMixin(P
262
266
  ?readonly=${readonly}
263
267
  ?required=${required}
264
268
  ?disabled=${disabled}
269
+ aria-label=${ifDefined(aria?.label)}
265
270
  aria-describedby=${ifDefined(assistiveText ? assistiveTextIdValue : undefined)}
266
271
  aria-invalid=${status === 'error' ? 'true' : 'false'}
267
272
  aria-errormessage="${ifDefined(status === 'error' ? assistiveTextIdValue : undefined)}"