@justeattakeaway/pie-switch 0.29.11 → 0.30.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.
@@ -35,7 +35,7 @@
35
35
  "type": {
36
36
  "text": "DefaultProps"
37
37
  },
38
- "default": "{\n checked: false,\n required: false,\n disabled: false,\n value: 'on',\n labelPlacement: 'leading',\n}"
38
+ "default": "{\r\n checked: false,\r\n disabled: false,\r\n labelPlacement: 'leading',\r\n required: false,\r\n value: 'on',\r\n}"
39
39
  }
40
40
  ],
41
41
  "exports": [
@@ -74,19 +74,11 @@
74
74
  "description": "",
75
75
  "name": "PieSwitch",
76
76
  "members": [
77
- {
78
- "kind": "field",
79
- "name": "input",
80
- "type": {
81
- "text": "HTMLInputElement | undefined"
82
- },
83
- "privacy": "private"
84
- },
85
77
  {
86
78
  "kind": "field",
87
79
  "name": "label",
88
80
  "type": {
89
- "text": "string | undefined"
81
+ "text": "SwitchProps['label']"
90
82
  },
91
83
  "privacy": "public",
92
84
  "attribute": "label"
@@ -94,9 +86,6 @@
94
86
  {
95
87
  "kind": "field",
96
88
  "name": "labelPlacement",
97
- "type": {
98
- "text": "SwitchProps['labelPlacement']"
99
- },
100
89
  "privacy": "public",
101
90
  "attribute": "labelPlacement"
102
91
  },
@@ -104,7 +93,7 @@
104
93
  "kind": "field",
105
94
  "name": "aria",
106
95
  "type": {
107
- "text": "AriaProps"
96
+ "text": "SwitchProps['aria']"
108
97
  },
109
98
  "privacy": "public",
110
99
  "attribute": "aria"
@@ -133,7 +122,7 @@
133
122
  "kind": "field",
134
123
  "name": "name",
135
124
  "type": {
136
- "text": "string | undefined"
125
+ "text": "SwitchProps['name']"
137
126
  },
138
127
  "privacy": "public",
139
128
  "attribute": "name"
@@ -145,6 +134,14 @@
145
134
  "attribute": "disabled",
146
135
  "reflects": true
147
136
  },
137
+ {
138
+ "kind": "field",
139
+ "name": "input",
140
+ "type": {
141
+ "text": "HTMLInputElement | undefined"
142
+ },
143
+ "privacy": "private"
144
+ },
148
145
  {
149
146
  "kind": "field",
150
147
  "name": "focusTarget",
@@ -188,7 +185,7 @@
188
185
  "text": ""
189
186
  }
190
187
  },
191
- "description": "Returns a boolean value which indicates validity of the value of the component. If the value is invalid, this method also fires the invalid event on the component.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity"
188
+ "description": "Returns a boolean value which indicates validity of the value of the component. If the value is invalid, this method also fires the invalid event on the component.\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity"
192
189
  },
193
190
  {
194
191
  "kind": "method",
@@ -199,7 +196,7 @@
199
196
  "text": ""
200
197
  }
201
198
  },
202
- "description": "If the value is invalid, this method also fires the invalid event on the element, and (if the event isn't canceled) reports the problem to the user.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity"
199
+ "description": "If the value is invalid, this method also fires the invalid event on the element, and (if the event isn't canceled) reports the problem to the user.\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity"
203
200
  },
204
201
  {
205
202
  "kind": "method",
@@ -218,7 +215,7 @@
218
215
  }
219
216
  }
220
217
  ],
221
- "description": "Allows a consumer to set a custom validation message on the switch. An empty string counts as valid.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity"
218
+ "description": "Allows a consumer to set a custom validation message on the switch. An empty string counts as valid.\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity"
222
219
  },
223
220
  {
224
221
  "kind": "field",
@@ -227,7 +224,7 @@
227
224
  "text": "ValidityState"
228
225
  },
229
226
  "privacy": "public",
230
- "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",
227
+ "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",
231
228
  "readonly": true
232
229
  },
233
230
  {
@@ -237,19 +234,27 @@
237
234
  "text": "string"
238
235
  },
239
236
  "privacy": "public",
240
- "description": "(Read-only) Returns a string representing a localized message that describes the validation constraints that the control does not satisfy (if any).\nThis string is empty if the component is valid.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage",
237
+ "description": "(Read-only) Returns a string representing a localized message that describes the validation constraints that the control does not satisfy (if any).\r\nThis string is empty if the component is valid.\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage",
241
238
  "readonly": true
242
239
  },
243
240
  {
244
241
  "kind": "method",
245
242
  "name": "renderSwitchLabel",
246
243
  "privacy": "private",
247
- "return": {
248
- "type": {
249
- "text": "TemplateResult"
244
+ "parameters": [
245
+ {
246
+ "name": "placement",
247
+ "type": {
248
+ "text": "SwitchProps['labelPlacement']"
249
+ }
250
250
  }
251
- },
252
- "description": "Renders the label for a switch if provided.\nif invalid value is passed, nothing gets rendered"
251
+ ],
252
+ "description": "If a label is provided, renders it if `labelPlacement` matches the given position.\r\nIf no label is provided, or `labelPlacement` does not match the given position, nothing is rendered."
253
+ },
254
+ {
255
+ "kind": "method",
256
+ "name": "renderAriaDescription",
257
+ "privacy": "private"
253
258
  }
254
259
  ],
255
260
  "events": [
@@ -271,21 +276,18 @@
271
276
  {
272
277
  "name": "label",
273
278
  "type": {
274
- "text": "string | undefined"
279
+ "text": "SwitchProps['label']"
275
280
  },
276
281
  "fieldName": "label"
277
282
  },
278
283
  {
279
284
  "name": "labelPlacement",
280
- "type": {
281
- "text": "SwitchProps['labelPlacement']"
282
- },
283
285
  "fieldName": "labelPlacement"
284
286
  },
285
287
  {
286
288
  "name": "aria",
287
289
  "type": {
288
- "text": "AriaProps"
290
+ "text": "SwitchProps['aria']"
289
291
  },
290
292
  "fieldName": "aria"
291
293
  },
@@ -304,7 +306,7 @@
304
306
  {
305
307
  "name": "name",
306
308
  "type": {
307
- "text": "string | undefined"
309
+ "text": "SwitchProps['name']"
308
310
  },
309
311
  "fieldName": "name"
310
312
  },
package/dist/index.d.ts CHANGED
@@ -4,11 +4,10 @@ import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
4
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
5
5
  import type { LitElement } from 'lit';
6
6
  import type { PIEInputElement } from '@justeattakeaway/pie-webc-core';
7
- import type { PropertyValues } from 'lit';
8
7
  import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
9
- import type { TemplateResult } from 'lit';
8
+ import type { TemplateResult } from 'lit-html';
10
9
 
11
- export declare type AriaProps = {
10
+ declare type AriaProps = {
12
11
  label?: string;
13
12
  describedBy?: string;
14
13
  };
@@ -17,8 +16,6 @@ export declare type DefaultProps = ComponentDefaultProps<SwitchProps, keyof Omit
17
16
 
18
17
  export declare const defaultProps: DefaultProps;
19
18
 
20
- export declare type LabelPlacement = typeof labelPlacements[number];
21
-
22
19
  export declare const labelPlacements: readonly ["leading", "trailing"];
23
20
 
24
21
  /**
@@ -33,18 +30,18 @@ export declare const ON_SWITCH_CHANGED_EVENT = "change";
33
30
  * @event {CustomEvent} change - when the switch checked state is changed.
34
31
  */
35
32
  export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PIEInputElement {
36
- private input?;
37
- protected firstUpdated(_changedProperties: PropertyValues<this>): void;
38
- protected updated(_changedProperties: PropertyValues<this>): void;
39
- label?: string;
40
- labelPlacement: SwitchProps['labelPlacement'];
41
- aria: AriaProps;
33
+ label: SwitchProps['label'];
34
+ labelPlacement: "leading" | "trailing";
35
+ aria: SwitchProps['aria'];
42
36
  checked: boolean;
43
37
  required: boolean;
44
38
  value: string;
45
- name?: string;
39
+ name: SwitchProps['name'];
46
40
  disabled: boolean;
41
+ private input?;
47
42
  focusTarget: HTMLElement;
43
+ protected firstUpdated(): void;
44
+ protected updated(): void;
48
45
  static styles: CSSResult;
49
46
  /**
50
47
  * Ensures that the form value and validation state are in sync with the component.
@@ -84,12 +81,13 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
84
81
  */
85
82
  get validationMessage(): string;
86
83
  /**
87
- * Renders the label for a switch if provided.
88
- * if invalid value is passed, nothing gets rendered
84
+ * If a label is provided, renders it if `labelPlacement` matches the given position.
85
+ * If no label is provided, or `labelPlacement` does not match the given position, nothing is rendered.
89
86
  *
90
87
  * @private
91
88
  */
92
89
  private renderSwitchLabel;
90
+ private renderAriaDescription;
93
91
  render(): TemplateResult<1>;
94
92
  }
95
93
 
@@ -119,7 +117,7 @@ export declare interface SwitchProps {
119
117
  /**
120
118
  * The placement of the label such as leading or trailing
121
119
  */
122
- labelPlacement?: LabelPlacement;
120
+ labelPlacement?: typeof labelPlacements[number];
123
121
  /**
124
122
  * Same as the HTML name attribute - indicates the name of the switch (for use with forms)
125
123
  */