@justeattakeaway/pie-textarea 0.11.0 → 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.
- package/custom-elements.json +0 -28
- package/dist/index.d.ts +2 -9
- package/dist/index.js +133 -144
- package/dist/react.d.ts +2 -9
- package/package.json +2 -2
- package/src/defs.ts +1 -7
- package/src/index.ts +3 -21
package/custom-elements.json
CHANGED
|
@@ -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' | '
|
|
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
|
|
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
|
|
2
|
-
import { property as l, query as
|
|
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
|
|
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(
|
|
11
|
-
return
|
|
10
|
+
function Y(e) {
|
|
11
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
12
12
|
}
|
|
13
|
-
var
|
|
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
|
|
17
|
-
var
|
|
18
|
-
if (typeof
|
|
19
|
-
throw new TypeError(
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
var f =
|
|
23
|
-
return
|
|
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
|
|
26
|
-
return x =
|
|
25
|
+
function E(r) {
|
|
26
|
+
return x = r, s = setTimeout($, t), k ? y(r) : u;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
var f =
|
|
30
|
-
return v ? ue(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
|
|
33
|
-
var f =
|
|
34
|
-
return
|
|
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
|
|
38
|
-
if (
|
|
39
|
-
return F(
|
|
40
|
-
|
|
37
|
+
var r = w();
|
|
38
|
+
if (I(r))
|
|
39
|
+
return F(r);
|
|
40
|
+
s = setTimeout($, A(r));
|
|
41
41
|
}
|
|
42
|
-
function F(
|
|
43
|
-
return
|
|
42
|
+
function F(r) {
|
|
43
|
+
return s = void 0, g && d ? y(r) : (d = o = void 0, u);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
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
|
|
49
|
+
return s === void 0 ? u : F(w());
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
var
|
|
53
|
-
if (
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
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
|
|
57
|
+
return s = setTimeout($, t), y(h);
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return s === void 0 && (s = setTimeout($, t)), u;
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return _.cancel = N, _.flush = K, _;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
var
|
|
65
|
-
if (typeof
|
|
66
|
-
throw new TypeError(
|
|
67
|
-
return S(a) && (
|
|
68
|
-
leading:
|
|
69
|
-
maxWait:
|
|
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(
|
|
74
|
-
var
|
|
75
|
-
return !!
|
|
73
|
+
function S(e) {
|
|
74
|
+
var t = typeof e;
|
|
75
|
+
return !!e && (t == "object" || t == "function");
|
|
76
76
|
}
|
|
77
|
-
function fe(
|
|
78
|
-
return !!
|
|
77
|
+
function fe(e) {
|
|
78
|
+
return !!e && typeof e == "object";
|
|
79
79
|
}
|
|
80
|
-
function xe(
|
|
81
|
-
return typeof
|
|
80
|
+
function xe(e) {
|
|
81
|
+
return typeof e == "symbol" || fe(e) && de.call(e) == Z;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
if (typeof
|
|
85
|
-
return
|
|
86
|
-
if (xe(
|
|
87
|
-
return
|
|
88
|
-
if (S(
|
|
89
|
-
var
|
|
90
|
-
|
|
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
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
var a = ae.test(
|
|
96
|
-
return a || re.test(
|
|
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 =
|
|
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 = (
|
|
112
|
-
for (var o = void 0,
|
|
113
|
-
(u =
|
|
114
|
-
return o && ke(
|
|
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
|
|
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 = (
|
|
121
|
-
|
|
122
|
-
}, this.handleChange = (
|
|
123
|
-
const a = J(
|
|
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 = (
|
|
126
|
-
|
|
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(
|
|
143
|
-
this.disabled =
|
|
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.
|
|
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
|
-
|
|
159
|
-
|
|
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(
|
|
171
|
-
|
|
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="${
|
|
178
|
-
variant=${
|
|
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
|
-
` :
|
|
175
|
+
` : M;
|
|
183
176
|
}
|
|
184
177
|
render() {
|
|
185
178
|
const {
|
|
186
|
-
disabled:
|
|
179
|
+
disabled: t,
|
|
187
180
|
resize: a,
|
|
188
|
-
size:
|
|
181
|
+
size: d,
|
|
189
182
|
autocomplete: o,
|
|
190
|
-
autoFocus:
|
|
183
|
+
autoFocus: p,
|
|
191
184
|
name: u,
|
|
192
|
-
readonly:
|
|
193
|
-
placeholder:
|
|
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":
|
|
203
|
-
"c-textarea--readonly":
|
|
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--${
|
|
198
|
+
[`c-textarea--${d}`]: !0
|
|
207
199
|
};
|
|
208
200
|
return j`<div>
|
|
209
|
-
${this.renderLabel(v
|
|
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="${
|
|
215
|
-
data-test-id="${
|
|
216
|
-
name=${
|
|
217
|
-
autocomplete=${
|
|
218
|
-
placeholder=${
|
|
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=${
|
|
221
|
-
?readonly=${
|
|
212
|
+
?autofocus=${p}
|
|
213
|
+
?readonly=${s}
|
|
222
214
|
?required=${k}
|
|
223
|
-
?disabled=${
|
|
224
|
-
aria-describedby=${
|
|
215
|
+
?disabled=${t}
|
|
216
|
+
aria-describedby=${m(y ? O : void 0)}
|
|
225
217
|
aria-invalid=${g === "error" ? "true" : "false"}
|
|
226
|
-
aria-errormessage="${
|
|
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 = { ...
|
|
236
|
-
let
|
|
227
|
+
W.shadowRootOptions = { ...L.shadowRootOptions, delegatesFocus: !0 }, W.styles = P(be);
|
|
228
|
+
let i = W;
|
|
237
229
|
n([
|
|
238
230
|
l({ type: String })
|
|
239
|
-
],
|
|
231
|
+
], i.prototype, "value");
|
|
240
232
|
n([
|
|
241
233
|
l({ type: String })
|
|
242
|
-
],
|
|
234
|
+
], i.prototype, "defaultValue");
|
|
243
235
|
n([
|
|
244
236
|
l({ type: Boolean, reflect: !0 })
|
|
245
|
-
],
|
|
237
|
+
], i.prototype, "disabled");
|
|
246
238
|
n([
|
|
247
239
|
l({ type: String }),
|
|
248
|
-
C(
|
|
249
|
-
],
|
|
240
|
+
C(b, me, c.size)
|
|
241
|
+
], i.prototype, "size");
|
|
250
242
|
n([
|
|
251
243
|
l({ type: String }),
|
|
252
|
-
C(
|
|
253
|
-
],
|
|
244
|
+
C(b, ye, c.resize)
|
|
245
|
+
], i.prototype, "resize");
|
|
254
246
|
n([
|
|
255
247
|
l({ type: String })
|
|
256
|
-
],
|
|
257
|
-
n([
|
|
258
|
-
l({ type: Number })
|
|
259
|
-
], r.prototype, "maxLength");
|
|
248
|
+
], i.prototype, "label");
|
|
260
249
|
n([
|
|
261
250
|
l({ type: Boolean })
|
|
262
|
-
],
|
|
251
|
+
], i.prototype, "readonly");
|
|
263
252
|
n([
|
|
264
253
|
l({ type: Boolean })
|
|
265
|
-
],
|
|
254
|
+
], i.prototype, "autoFocus");
|
|
266
255
|
n([
|
|
267
256
|
l({ type: Boolean })
|
|
268
|
-
],
|
|
257
|
+
], i.prototype, "required");
|
|
269
258
|
n([
|
|
270
259
|
l({ type: String }),
|
|
271
|
-
C(
|
|
272
|
-
],
|
|
260
|
+
C(b, ze, c.status)
|
|
261
|
+
], i.prototype, "status");
|
|
273
262
|
n([
|
|
274
263
|
l({ type: String })
|
|
275
|
-
],
|
|
264
|
+
], i.prototype, "assistiveText");
|
|
276
265
|
n([
|
|
277
266
|
l({ type: String })
|
|
278
|
-
],
|
|
267
|
+
], i.prototype, "name");
|
|
279
268
|
n([
|
|
280
269
|
l({ type: String })
|
|
281
|
-
],
|
|
270
|
+
], i.prototype, "autocomplete");
|
|
282
271
|
n([
|
|
283
272
|
l({ type: String })
|
|
284
|
-
],
|
|
273
|
+
], i.prototype, "placeholder");
|
|
285
274
|
n([
|
|
286
|
-
|
|
287
|
-
],
|
|
275
|
+
D("textarea")
|
|
276
|
+
], i.prototype, "_textarea");
|
|
288
277
|
n([
|
|
289
|
-
|
|
290
|
-
],
|
|
291
|
-
Q(
|
|
278
|
+
D("textarea")
|
|
279
|
+
], i.prototype, "focusTarget");
|
|
280
|
+
Q(b, i);
|
|
292
281
|
export {
|
|
293
|
-
|
|
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' | '
|
|
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
|
|
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.
|
|
4
|
+
"version": "0.12.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@justeattakeaway/pie-form-label": "0.14.
|
|
45
|
+
"@justeattakeaway/pie-form-label": "0.14.4",
|
|
46
46
|
"@justeattakeaway/pie-webc-core": "0.24.2",
|
|
47
47
|
"lodash.throttle": "4.1.1"
|
|
48
48
|
},
|
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' | '
|
|
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
|
|
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}"
|
|
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
|
|
232
|
+
${this.renderLabel(label)}
|
|
251
233
|
<div
|
|
252
234
|
class="${classMap(classes)}"
|
|
253
235
|
data-test-id="pie-textarea-wrapper">
|