@justeattakeaway/pie-textarea 0.16.8 → 0.16.10

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
@@ -22,6 +22,8 @@
22
22
  - [Example](#example)
23
23
  - [Displaying error messages](#displaying-error-messages)
24
24
  - [Usage Examples](#usage-examples)
25
+ - [Pitfalls](#pitfalls)
26
+ - [Controlled input values](#controlled-input-values)
25
27
  - [Questions and Support](#questions-and-support)
26
28
  - [Contributing](#contributing)
27
29
 
@@ -173,6 +175,28 @@ import { PieTextarea } from '@justeattakeaway/pie-webc/react/textarea.js';
173
175
  </PieTextarea>
174
176
  ```
175
177
 
178
+ ## Pitfalls
179
+
180
+ ### Controlled input values
181
+
182
+ If we want to add a constraint to what the user can input, then on input/change we perform the condition check and if it succeeds, update the input value. If it fails, then manually assign event.target.value to the last known valid input to prevent it from updating.
183
+
184
+ > This will need to be done regardless of application framework used.
185
+
186
+ Example:
187
+
188
+ ```js
189
+ const onInput = (event) => {
190
+ // For example, users can type only uppercase letters
191
+ const value = event.target.value
192
+ if (value === value.toUpperCase()) {
193
+ inputValue.value = value
194
+ } else {
195
+ event.target.value = inputValue.value
196
+ }
197
+ }
198
+ ```
199
+
176
200
  ## Questions and Support
177
201
 
178
202
  If you work at Just Eat Takeaway.com, please contact us on **#help-designsystem**. Otherwise, please raise an issue on [Github](https://github.com/justeattakeaway/pie/issues).
@@ -42,7 +42,7 @@
42
42
  "type": {
43
43
  "text": "DefaultProps"
44
44
  },
45
- "default": "{\r\n disabled: false,\r\n size: 'medium',\r\n resize: 'auto',\r\n value: '',\r\n placeholder: '',\r\n status: 'default',\r\n autoFocus: false,\r\n readonly: false,\r\n required: false,\r\n}",
45
+ "default": "{\n disabled: false,\n size: 'medium',\n resize: 'auto',\n value: '',\n placeholder: '',\n status: 'default',\n autoFocus: false,\n readonly: false,\n required: false,\n}",
46
46
  "description": "Default values for optional properties that have default fallback values in the component."
47
47
  }
48
48
  ],
@@ -102,8 +102,7 @@
102
102
  {
103
103
  "kind": "field",
104
104
  "name": "value",
105
- "privacy": "public",
106
- "attribute": "value"
105
+ "privacy": "public"
107
106
  },
108
107
  {
109
108
  "kind": "field",
@@ -111,51 +110,42 @@
111
110
  "type": {
112
111
  "text": "TextareaProps['defaultValue']"
113
112
  },
114
- "privacy": "public",
115
- "attribute": "defaultValue"
113
+ "privacy": "public"
116
114
  },
117
115
  {
118
116
  "kind": "field",
119
117
  "name": "disabled",
120
- "privacy": "public",
121
- "attribute": "disabled",
122
- "reflects": true
118
+ "privacy": "public"
123
119
  },
124
120
  {
125
121
  "kind": "field",
126
122
  "name": "size",
127
- "privacy": "public",
128
- "attribute": "size"
123
+ "privacy": "public"
129
124
  },
130
125
  {
131
126
  "kind": "field",
132
127
  "name": "resize",
133
- "privacy": "public",
134
- "attribute": "resize"
128
+ "privacy": "public"
135
129
  },
136
130
  {
137
131
  "kind": "field",
138
132
  "name": "readonly",
139
- "privacy": "public",
140
- "attribute": "readonly"
133
+ "privacy": "public"
141
134
  },
142
135
  {
143
136
  "kind": "field",
144
137
  "name": "autoFocus",
145
- "privacy": "public",
146
- "attribute": "autoFocus"
138
+ "privacy": "public"
147
139
  },
148
140
  {
149
141
  "kind": "field",
150
142
  "name": "required",
151
- "privacy": "public",
152
- "attribute": "required"
143
+ "privacy": "public"
153
144
  },
154
145
  {
155
146
  "kind": "field",
156
147
  "name": "status",
157
- "privacy": "public",
158
- "attribute": "status"
148
+ "privacy": "public"
159
149
  },
160
150
  {
161
151
  "kind": "field",
@@ -163,8 +153,7 @@
163
153
  "type": {
164
154
  "text": "TextareaProps['assistiveText']"
165
155
  },
166
- "privacy": "public",
167
- "attribute": "assistiveText"
156
+ "privacy": "public"
168
157
  },
169
158
  {
170
159
  "kind": "field",
@@ -172,9 +161,7 @@
172
161
  "type": {
173
162
  "text": "TextareaProps['name']"
174
163
  },
175
- "privacy": "public",
176
- "attribute": "name",
177
- "reflects": true
164
+ "privacy": "public"
178
165
  },
179
166
  {
180
167
  "kind": "field",
@@ -182,8 +169,7 @@
182
169
  "type": {
183
170
  "text": "TextareaProps['autocomplete']"
184
171
  },
185
- "privacy": "public",
186
- "attribute": "autocomplete"
172
+ "privacy": "public"
187
173
  },
188
174
  {
189
175
  "kind": "field",
@@ -191,8 +177,7 @@
191
177
  "type": {
192
178
  "text": "TextareaProps['placeholder']"
193
179
  },
194
- "privacy": "public",
195
- "attribute": "placeholder"
180
+ "privacy": "public"
196
181
  },
197
182
  {
198
183
  "kind": "field",
@@ -230,7 +215,7 @@
230
215
  "text": "ValidityState"
231
216
  },
232
217
  "privacy": "public",
233
- "description": "(Read-only) returns a ValidityState with the validity states that this element is in.\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity",
218
+ "description": "(Read-only) returns a ValidityState with the validity states that this element is in.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity",
234
219
  "readonly": true
235
220
  },
236
221
  {
@@ -251,7 +236,7 @@
251
236
  "description": "The latest disabled state of the input."
252
237
  }
253
238
  ],
254
- "description": "Called after the disabled state of the element changes,\r\neither because the disabled attribute of this element was added or removed;\r\nor because the disabled state changed on a <fieldset> that's an ancestor of this element."
239
+ "description": "Called after the disabled state of the element changes,\neither because the disabled attribute of this element was added or removed;\nor because the disabled state changed on a <fieldset> that's an ancestor of this element."
255
240
  },
256
241
  {
257
242
  "kind": "method",
@@ -262,7 +247,7 @@
262
247
  "text": "void"
263
248
  }
264
249
  },
265
- "description": "Called when the form that owns this component is reset.\r\nResets the value to the default value."
250
+ "description": "Called when the form that owns this component is reset.\nResets the value to the default value."
266
251
  },
267
252
  {
268
253
  "kind": "method",
@@ -329,75 +314,6 @@
329
314
  "name": "change"
330
315
  }
331
316
  ],
332
- "attributes": [
333
- {
334
- "name": "value",
335
- "fieldName": "value"
336
- },
337
- {
338
- "name": "defaultValue",
339
- "type": {
340
- "text": "TextareaProps['defaultValue']"
341
- },
342
- "fieldName": "defaultValue"
343
- },
344
- {
345
- "name": "disabled",
346
- "fieldName": "disabled"
347
- },
348
- {
349
- "name": "size",
350
- "fieldName": "size"
351
- },
352
- {
353
- "name": "resize",
354
- "fieldName": "resize"
355
- },
356
- {
357
- "name": "readonly",
358
- "fieldName": "readonly"
359
- },
360
- {
361
- "name": "autoFocus",
362
- "fieldName": "autoFocus"
363
- },
364
- {
365
- "name": "required",
366
- "fieldName": "required"
367
- },
368
- {
369
- "name": "status",
370
- "fieldName": "status"
371
- },
372
- {
373
- "name": "assistiveText",
374
- "type": {
375
- "text": "TextareaProps['assistiveText']"
376
- },
377
- "fieldName": "assistiveText"
378
- },
379
- {
380
- "name": "name",
381
- "type": {
382
- "text": "TextareaProps['name']"
383
- },
384
- "fieldName": "name"
385
- },
386
- {
387
- "name": "autocomplete",
388
- "type": {
389
- "text": "TextareaProps['autocomplete']"
390
- },
391
- "fieldName": "autocomplete"
392
- },
393
- {
394
- "name": "placeholder",
395
- "type": {
396
- "text": "TextareaProps['placeholder']"
397
- },
398
- "fieldName": "placeholder"
399
- }
400
- ],
401
317
  "mixins": [
402
318
  {
403
319
  "name": "FormControlMixin",
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
- import type { CSSResult } from 'lit';
3
- import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
- import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
2
+ import { CSSResult } from 'lit';
3
+ import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
+ import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
5
5
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
6
- import type { PIEInputElement } from '@justeattakeaway/pie-webc-core';
7
- import type { PropertyValues } from 'lit';
8
- import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
9
- import type { TemplateResult } from 'lit-html';
6
+ import { PIEInputElement } from '@justeattakeaway/pie-webc-core';
7
+ import { PropertyValues } from 'lit';
8
+ import { RTLInterface } from '@justeattakeaway/pie-webc-core';
9
+ import { TemplateResult } from 'lit-html';
10
10
 
11
11
  /**
12
12
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
@@ -27,7 +27,8 @@ export declare class PieTextarea extends PieTextarea_base implements TextareaPro
27
27
  static shadowRootOptions: {
28
28
  delegatesFocus: boolean;
29
29
  mode: ShadowRootMode;
30
- slotAssignment?: SlotAssignmentMode | undefined;
30
+ serializable?: boolean;
31
+ slotAssignment?: SlotAssignmentMode;
31
32
  };
32
33
  value: string;
33
34
  defaultValue: TextareaProps['defaultValue'];
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ const _ = class _ extends D {
10
10
  this.getAttribute("v") || this.setAttribute("v", _.v);
11
11
  }
12
12
  };
13
- _.v = "0.16.8";
13
+ _.v = "0.16.10";
14
14
  let w = _;
15
15
  var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
16
16
  function Z(e) {
package/dist/react.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
- import type { CSSResult } from 'lit';
3
- import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
- import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
2
+ import { CSSResult } from 'lit';
3
+ import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
+ import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
5
5
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
6
- import type { PIEInputElement } from '@justeattakeaway/pie-webc-core';
7
- import type { PropertyValues } from 'lit';
6
+ import { PIEInputElement } from '@justeattakeaway/pie-webc-core';
7
+ import { PropertyValues } from 'lit';
8
8
  import * as React_2 from 'react';
9
- import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
10
- import type { TemplateResult } from 'lit-html';
9
+ import { RTLInterface } from '@justeattakeaway/pie-webc-core';
10
+ import { TemplateResult } from 'lit-html';
11
11
 
12
12
  /**
13
13
  * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
@@ -19,7 +19,7 @@ declare type DefaultProps = ComponentDefaultProps<TextareaProps, keyof Omit<Text
19
19
  */
20
20
  export declare const defaultProps: DefaultProps;
21
21
 
22
- export declare const PieTextarea: React_2.ForwardRefExoticComponent<TextareaProps & React_2.RefAttributes<PieTextarea_2> & PieTextareaEvents & ReactBaseType>;
22
+ export declare const PieTextarea: React_2.ForwardRefExoticComponent<React_2.PropsWithoutRef<TextareaProps> & React_2.RefAttributes<PieTextarea_2> & PieTextareaEvents & ReactBaseType>;
23
23
 
24
24
  /**
25
25
  * @tagname pie-textarea
@@ -30,7 +30,8 @@ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps, P
30
30
  static shadowRootOptions: {
31
31
  delegatesFocus: boolean;
32
32
  mode: ShadowRootMode;
33
- slotAssignment?: SlotAssignmentMode | undefined;
33
+ serializable?: boolean;
34
+ slotAssignment?: SlotAssignmentMode;
34
35
  };
35
36
  value: string;
36
37
  defaultValue: TextareaProps['defaultValue'];
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.16.8",
4
+ "version": "0.16.10",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -39,14 +39,14 @@
39
39
  "license": "Apache-2.0",
40
40
  "devDependencies": {
41
41
  "@custom-elements-manifest/analyzer": "0.9.0",
42
- "@justeattakeaway/pie-components-config": "0.20.1",
43
- "@justeattakeaway/pie-css": "0.17.0",
44
- "@justeattakeaway/pie-monorepo-utils": "0.5.1",
42
+ "@justeattakeaway/pie-components-config": "0.21.0",
43
+ "@justeattakeaway/pie-css": "0.18.0",
44
+ "@justeattakeaway/pie-monorepo-utils": "0.6.0",
45
45
  "@types/lodash.throttle": "4.1.9",
46
46
  "cem-plugin-module-file-extensions": "0.0.5"
47
47
  },
48
48
  "dependencies": {
49
- "@justeattakeaway/pie-assistive-text": "0.10.8",
49
+ "@justeattakeaway/pie-assistive-text": "0.10.9",
50
50
  "@justeattakeaway/pie-webc-core": "1.0.0",
51
51
  "lodash.throttle": "4.1.1"
52
52
  },