@ionic/core 8.4.4-dev.11741298262.12200f27 → 8.4.4-dev.11741357957.1558bd4c
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/components/ion-toggle.js +5 -37
- package/components/radio.js +37 -5
- package/dist/cjs/ion-radio_2.cjs.entry.js +35 -5
- package/dist/cjs/ion-toggle.cjs.entry.js +5 -35
- package/dist/cjs/ionic.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/radio/radio.ios.css +52 -15
- package/dist/collection/components/radio/radio.js +70 -3
- package/dist/collection/components/radio/radio.md.css +52 -15
- package/dist/collection/components/toggle/toggle.ios.css +15 -52
- package/dist/collection/components/toggle/toggle.js +3 -70
- package/dist/collection/components/toggle/toggle.md.css +15 -52
- package/dist/docs.json +73 -73
- package/dist/esm/ion-radio_2.entry.js +35 -5
- package/dist/esm/ion-toggle.entry.js +5 -35
- package/dist/esm/ionic.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm-es5/ion-radio_2.entry.js +1 -1
- package/dist/esm-es5/ion-toggle.entry.js +1 -1
- package/dist/esm-es5/ionic.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/html.html-data.json +8 -8
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-0bfffa34.system.entry.js +4 -0
- package/dist/ionic/p-322c5fb4.system.js +1 -1
- package/dist/ionic/p-5375091b.system.entry.js +4 -0
- package/dist/ionic/p-8f51281f.entry.js +4 -0
- package/dist/ionic/p-a18470c6.entry.js +4 -0
- package/dist/types/components/radio/radio.d.ts +19 -0
- package/dist/types/components/toggle/toggle.d.ts +0 -19
- package/dist/types/components.d.ts +16 -16
- package/hydrate/index.js +45 -45
- package/hydrate/index.mjs +45 -45
- package/package.json +1 -1
- package/dist/ionic/p-0f5d878e.system.entry.js +0 -4
- package/dist/ionic/p-3990c92b.entry.js +0 -4
- package/dist/ionic/p-6190d0d6.entry.js +0 -4
- package/dist/ionic/p-70ccc275.system.entry.js +0 -4
|
@@ -175,32 +175,39 @@ input {
|
|
|
175
175
|
align-items: center;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
.radio-bottom {
|
|
179
|
+
padding-top: 4px;
|
|
180
|
+
display: flex;
|
|
179
181
|
justify-content: space-between;
|
|
182
|
+
font-size: 0.75rem;
|
|
183
|
+
white-space: normal;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
:host(.radio-
|
|
183
|
-
|
|
186
|
+
:host(.radio-label-placement-stacked) .radio-bottom {
|
|
187
|
+
font-size: 1rem;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Error text should only be shown when .ion-invalid is
|
|
192
|
+
* present on the radio. Otherwise the helper text should
|
|
193
|
+
* be shown.
|
|
194
|
+
*/
|
|
195
|
+
.radio-bottom .error-text {
|
|
196
|
+
display: none;
|
|
197
|
+
color: var(--ion-color-danger, #c5000f);
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
|
|
191
|
-
|
|
200
|
+
.radio-bottom .helper-text {
|
|
201
|
+
display: block;
|
|
202
|
+
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
192
203
|
}
|
|
193
204
|
|
|
194
|
-
:host(.
|
|
195
|
-
|
|
205
|
+
:host(.ion-touched.ion-invalid) .radio-bottom .error-text {
|
|
206
|
+
display: block;
|
|
196
207
|
}
|
|
197
208
|
|
|
198
|
-
:host(.radio-
|
|
199
|
-
:
|
|
200
|
-
:host(.radio-justify-end),
|
|
201
|
-
:host(.radio-alignment-start),
|
|
202
|
-
:host(.radio-alignment-center) {
|
|
203
|
-
display: block;
|
|
209
|
+
:host(.ion-touched.ion-invalid) .radio-bottom .helper-text {
|
|
210
|
+
display: none;
|
|
204
211
|
}
|
|
205
212
|
|
|
206
213
|
/**
|
|
@@ -229,6 +236,7 @@ input {
|
|
|
229
236
|
*/
|
|
230
237
|
:host(.radio-label-placement-end) .radio-wrapper {
|
|
231
238
|
flex-direction: row-reverse;
|
|
239
|
+
justify-content: start;
|
|
232
240
|
}
|
|
233
241
|
|
|
234
242
|
/**
|
|
@@ -270,6 +278,7 @@ input {
|
|
|
270
278
|
*/
|
|
271
279
|
:host(.radio-label-placement-stacked) .radio-wrapper {
|
|
272
280
|
flex-direction: column;
|
|
281
|
+
text-align: center;
|
|
273
282
|
}
|
|
274
283
|
|
|
275
284
|
:host(.radio-label-placement-stacked) .label-text-wrapper {
|
|
@@ -315,6 +324,34 @@ input {
|
|
|
315
324
|
}
|
|
316
325
|
}
|
|
317
326
|
|
|
327
|
+
:host(.radio-justify-space-between) .radio-wrapper {
|
|
328
|
+
justify-content: space-between;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
:host(.radio-justify-start) .radio-wrapper {
|
|
332
|
+
justify-content: start;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
:host(.radio-justify-end) .radio-wrapper {
|
|
336
|
+
justify-content: end;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
:host(.radio-alignment-start) .radio-wrapper {
|
|
340
|
+
align-items: start;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
:host(.radio-alignment-center) .radio-wrapper {
|
|
344
|
+
align-items: center;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
:host(.radio-justify-space-between),
|
|
348
|
+
:host(.radio-justify-start),
|
|
349
|
+
:host(.radio-justify-end),
|
|
350
|
+
:host(.radio-alignment-start),
|
|
351
|
+
:host(.radio-alignment-center) {
|
|
352
|
+
display: block;
|
|
353
|
+
}
|
|
354
|
+
|
|
318
355
|
/**
|
|
319
356
|
* Convert a font size to a dynamic font size.
|
|
320
357
|
* Fonts that participate in Dynamic Type should use
|
|
@@ -14,10 +14,15 @@ import { getIonMode } from "../../global/ionic-global";
|
|
|
14
14
|
* @part container - The container for the radio mark.
|
|
15
15
|
* @part label - The label text describing the radio.
|
|
16
16
|
* @part mark - The checkmark or dot used to indicate the checked state.
|
|
17
|
+
* @part supporting-text - Supporting text displayed beneath the radio label.
|
|
18
|
+
* @part helper-text - Supporting text displayed beneath the radio label when the radio is valid.
|
|
19
|
+
* @part error-text - Supporting text displayed beneath the radio label when the radio is invalid and touched.
|
|
17
20
|
*/
|
|
18
21
|
export class Radio {
|
|
19
22
|
constructor() {
|
|
20
23
|
this.inputId = `ion-rb-${radioButtonIds++}`;
|
|
24
|
+
this.helperTextId = `${this.inputId}-helper-text`;
|
|
25
|
+
this.errorTextId = `${this.inputId}-error-text`;
|
|
21
26
|
this.radioGroup = null;
|
|
22
27
|
this.updateState = () => {
|
|
23
28
|
if (this.radioGroup) {
|
|
@@ -57,6 +62,8 @@ export class Radio {
|
|
|
57
62
|
this.color = undefined;
|
|
58
63
|
this.name = this.inputId;
|
|
59
64
|
this.disabled = false;
|
|
65
|
+
this.errorText = undefined;
|
|
66
|
+
this.helperText = undefined;
|
|
60
67
|
this.value = undefined;
|
|
61
68
|
this.labelPlacement = 'start';
|
|
62
69
|
this.justify = undefined;
|
|
@@ -116,11 +123,37 @@ export class Radio {
|
|
|
116
123
|
renderRadioControl() {
|
|
117
124
|
return (h("div", { class: "radio-icon", part: "container" }, h("div", { class: "radio-inner", part: "mark" }), h("div", { class: "radio-ripple" })));
|
|
118
125
|
}
|
|
126
|
+
getHintTextID() {
|
|
127
|
+
const { el, helperText, errorText, helperTextId, errorTextId } = this;
|
|
128
|
+
if (el.classList.contains('ion-touched') && el.classList.contains('ion-invalid') && errorText) {
|
|
129
|
+
return errorTextId;
|
|
130
|
+
}
|
|
131
|
+
if (helperText) {
|
|
132
|
+
return helperTextId;
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Responsible for rendering helper text and error text.
|
|
138
|
+
* This element should only be rendered if hint text is set.
|
|
139
|
+
*/
|
|
140
|
+
renderHintText() {
|
|
141
|
+
const { helperText, errorText, helperTextId, errorTextId } = this;
|
|
142
|
+
/**
|
|
143
|
+
* undefined and empty string values should
|
|
144
|
+
* be treated as not having helper/error text.
|
|
145
|
+
*/
|
|
146
|
+
const hasHintText = !!helperText || !!errorText;
|
|
147
|
+
if (!hasHintText) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
return (h("div", { class: "radio-bottom" }, h("div", { id: helperTextId, class: "helper-text", part: "supporting-text helper-text" }, helperText), h("div", { id: errorTextId, class: "error-text", part: "supporting-text error-text" }, errorText)));
|
|
151
|
+
}
|
|
119
152
|
render() {
|
|
120
153
|
const { checked, disabled, color, el, justify, labelPlacement, hasLabel, buttonTabindex, alignment } = this;
|
|
121
154
|
const mode = getIonMode(this);
|
|
122
155
|
const inItem = hostContext('ion-item', el);
|
|
123
|
-
return (h(Host, { key: '
|
|
156
|
+
return (h(Host, { key: '4f01024a74c1846438372c40519df1044f5b12b9', onFocus: this.onFocus, onBlur: this.onBlur, onClick: this.onClick, class: createColorClasses(color, {
|
|
124
157
|
[mode]: true,
|
|
125
158
|
'in-item': inItem,
|
|
126
159
|
'radio-checked': checked,
|
|
@@ -131,10 +164,10 @@ export class Radio {
|
|
|
131
164
|
// Focus and active styling should not apply when the radio is in an item
|
|
132
165
|
'ion-activatable': !inItem,
|
|
133
166
|
'ion-focusable': !inItem,
|
|
134
|
-
}), role: "radio", "aria-checked": checked ? 'true' : 'false', "aria-disabled": disabled ? 'true' : null, tabindex: buttonTabindex }, h("label", { key: '
|
|
167
|
+
}), role: "radio", "aria-checked": checked ? 'true' : 'false', "aria-disabled": disabled ? 'true' : null, "aria-describedby": this.getHintTextID(), "aria-invalid": this.getHintTextID() === this.errorTextId, tabindex: buttonTabindex }, h("label", { key: '59dc0343534e626692f3b71b32204c1b2b25d40a', class: "radio-wrapper" }, h("div", { key: '26d7d3faf1b02bb138fb2c46f83e824962b6b92e', class: {
|
|
135
168
|
'label-text-wrapper': true,
|
|
136
169
|
'label-text-wrapper-hidden': !hasLabel,
|
|
137
|
-
}, part: "label" }, h("slot", { key: '
|
|
170
|
+
}, part: "label" }, h("slot", { key: '9c3d8bb0c5cd3ce94d1e661d89587cf67c522bc0' }), this.renderHintText()), h("div", { key: '3183f79e2977ee001e69c23f73073555744281d8', class: "native-wrapper" }, this.renderRadioControl()))));
|
|
138
171
|
}
|
|
139
172
|
static get is() { return "ion-radio"; }
|
|
140
173
|
static get encapsulation() { return "shadow"; }
|
|
@@ -211,6 +244,40 @@ export class Radio {
|
|
|
211
244
|
"reflect": false,
|
|
212
245
|
"defaultValue": "false"
|
|
213
246
|
},
|
|
247
|
+
"errorText": {
|
|
248
|
+
"type": "string",
|
|
249
|
+
"mutable": false,
|
|
250
|
+
"complexType": {
|
|
251
|
+
"original": "string",
|
|
252
|
+
"resolved": "string | undefined",
|
|
253
|
+
"references": {}
|
|
254
|
+
},
|
|
255
|
+
"required": false,
|
|
256
|
+
"optional": true,
|
|
257
|
+
"docs": {
|
|
258
|
+
"tags": [],
|
|
259
|
+
"text": "Text that is placed under the radio label and displayed when an error is detected."
|
|
260
|
+
},
|
|
261
|
+
"attribute": "error-text",
|
|
262
|
+
"reflect": false
|
|
263
|
+
},
|
|
264
|
+
"helperText": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"mutable": false,
|
|
267
|
+
"complexType": {
|
|
268
|
+
"original": "string",
|
|
269
|
+
"resolved": "string | undefined",
|
|
270
|
+
"references": {}
|
|
271
|
+
},
|
|
272
|
+
"required": false,
|
|
273
|
+
"optional": true,
|
|
274
|
+
"docs": {
|
|
275
|
+
"tags": [],
|
|
276
|
+
"text": "Text that is placed under the radio label and displayed when no error is detected."
|
|
277
|
+
},
|
|
278
|
+
"attribute": "helper-text",
|
|
279
|
+
"reflect": false
|
|
280
|
+
},
|
|
214
281
|
"value": {
|
|
215
282
|
"type": "any",
|
|
216
283
|
"mutable": false,
|
|
@@ -175,32 +175,39 @@ input {
|
|
|
175
175
|
align-items: center;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
.radio-bottom {
|
|
179
|
+
padding-top: 4px;
|
|
180
|
+
display: flex;
|
|
179
181
|
justify-content: space-between;
|
|
182
|
+
font-size: 0.75rem;
|
|
183
|
+
white-space: normal;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
:host(.radio-
|
|
183
|
-
|
|
186
|
+
:host(.radio-label-placement-stacked) .radio-bottom {
|
|
187
|
+
font-size: 1rem;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Error text should only be shown when .ion-invalid is
|
|
192
|
+
* present on the radio. Otherwise the helper text should
|
|
193
|
+
* be shown.
|
|
194
|
+
*/
|
|
195
|
+
.radio-bottom .error-text {
|
|
196
|
+
display: none;
|
|
197
|
+
color: var(--ion-color-danger, #c5000f);
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
|
|
191
|
-
|
|
200
|
+
.radio-bottom .helper-text {
|
|
201
|
+
display: block;
|
|
202
|
+
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
192
203
|
}
|
|
193
204
|
|
|
194
|
-
:host(.
|
|
195
|
-
|
|
205
|
+
:host(.ion-touched.ion-invalid) .radio-bottom .error-text {
|
|
206
|
+
display: block;
|
|
196
207
|
}
|
|
197
208
|
|
|
198
|
-
:host(.radio-
|
|
199
|
-
:
|
|
200
|
-
:host(.radio-justify-end),
|
|
201
|
-
:host(.radio-alignment-start),
|
|
202
|
-
:host(.radio-alignment-center) {
|
|
203
|
-
display: block;
|
|
209
|
+
:host(.ion-touched.ion-invalid) .radio-bottom .helper-text {
|
|
210
|
+
display: none;
|
|
204
211
|
}
|
|
205
212
|
|
|
206
213
|
/**
|
|
@@ -229,6 +236,7 @@ input {
|
|
|
229
236
|
*/
|
|
230
237
|
:host(.radio-label-placement-end) .radio-wrapper {
|
|
231
238
|
flex-direction: row-reverse;
|
|
239
|
+
justify-content: start;
|
|
232
240
|
}
|
|
233
241
|
|
|
234
242
|
/**
|
|
@@ -270,6 +278,7 @@ input {
|
|
|
270
278
|
*/
|
|
271
279
|
:host(.radio-label-placement-stacked) .radio-wrapper {
|
|
272
280
|
flex-direction: column;
|
|
281
|
+
text-align: center;
|
|
273
282
|
}
|
|
274
283
|
|
|
275
284
|
:host(.radio-label-placement-stacked) .label-text-wrapper {
|
|
@@ -315,6 +324,34 @@ input {
|
|
|
315
324
|
}
|
|
316
325
|
}
|
|
317
326
|
|
|
327
|
+
:host(.radio-justify-space-between) .radio-wrapper {
|
|
328
|
+
justify-content: space-between;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
:host(.radio-justify-start) .radio-wrapper {
|
|
332
|
+
justify-content: start;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
:host(.radio-justify-end) .radio-wrapper {
|
|
336
|
+
justify-content: end;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
:host(.radio-alignment-start) .radio-wrapper {
|
|
340
|
+
align-items: start;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
:host(.radio-alignment-center) .radio-wrapper {
|
|
344
|
+
align-items: center;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
:host(.radio-justify-space-between),
|
|
348
|
+
:host(.radio-justify-start),
|
|
349
|
+
:host(.radio-justify-end),
|
|
350
|
+
:host(.radio-alignment-start),
|
|
351
|
+
:host(.radio-alignment-center) {
|
|
352
|
+
display: block;
|
|
353
|
+
}
|
|
354
|
+
|
|
318
355
|
/**
|
|
319
356
|
* Convert a font size to a dynamic font size.
|
|
320
357
|
* Fonts that participate in Dynamic Type should use
|
|
@@ -171,39 +171,32 @@ input {
|
|
|
171
171
|
align-items: center;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
.toggle-
|
|
175
|
-
padding-top: 4px;
|
|
176
|
-
display: flex;
|
|
174
|
+
:host(.toggle-justify-space-between) .toggle-wrapper {
|
|
177
175
|
justify-content: space-between;
|
|
178
|
-
font-size: 0.75rem;
|
|
179
|
-
white-space: normal;
|
|
180
176
|
}
|
|
181
177
|
|
|
182
|
-
:host(.toggle-
|
|
183
|
-
|
|
178
|
+
:host(.toggle-justify-start) .toggle-wrapper {
|
|
179
|
+
justify-content: start;
|
|
184
180
|
}
|
|
185
181
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
* present on the checkbox. Otherwise the helper text should
|
|
189
|
-
* be shown.
|
|
190
|
-
*/
|
|
191
|
-
.toggle-bottom .error-text {
|
|
192
|
-
display: none;
|
|
193
|
-
color: var(--ion-color-danger, #c5000f);
|
|
182
|
+
:host(.toggle-justify-end) .toggle-wrapper {
|
|
183
|
+
justify-content: end;
|
|
194
184
|
}
|
|
195
185
|
|
|
196
|
-
.toggle-
|
|
197
|
-
|
|
198
|
-
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
186
|
+
:host(.toggle-alignment-start) .toggle-wrapper {
|
|
187
|
+
align-items: start;
|
|
199
188
|
}
|
|
200
189
|
|
|
201
|
-
:host(.
|
|
202
|
-
|
|
190
|
+
:host(.toggle-alignment-center) .toggle-wrapper {
|
|
191
|
+
align-items: center;
|
|
203
192
|
}
|
|
204
193
|
|
|
205
|
-
:host(.
|
|
206
|
-
|
|
194
|
+
:host(.toggle-justify-space-between),
|
|
195
|
+
:host(.toggle-justify-start),
|
|
196
|
+
:host(.toggle-justify-end),
|
|
197
|
+
:host(.toggle-alignment-start),
|
|
198
|
+
:host(.toggle-alignment-center) {
|
|
199
|
+
display: block;
|
|
207
200
|
}
|
|
208
201
|
|
|
209
202
|
/**
|
|
@@ -232,7 +225,6 @@ input {
|
|
|
232
225
|
*/
|
|
233
226
|
:host(.toggle-label-placement-end) .toggle-wrapper {
|
|
234
227
|
flex-direction: row-reverse;
|
|
235
|
-
justify-content: start;
|
|
236
228
|
}
|
|
237
229
|
|
|
238
230
|
/**
|
|
@@ -275,7 +267,6 @@ input {
|
|
|
275
267
|
*/
|
|
276
268
|
:host(.toggle-label-placement-stacked) .toggle-wrapper {
|
|
277
269
|
flex-direction: column;
|
|
278
|
-
text-align: center;
|
|
279
270
|
}
|
|
280
271
|
|
|
281
272
|
:host(.toggle-label-placement-stacked) .label-text-wrapper {
|
|
@@ -321,34 +312,6 @@ input {
|
|
|
321
312
|
}
|
|
322
313
|
}
|
|
323
314
|
|
|
324
|
-
:host(.toggle-justify-space-between) .toggle-wrapper {
|
|
325
|
-
justify-content: space-between;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
:host(.toggle-justify-start) .toggle-wrapper {
|
|
329
|
-
justify-content: start;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
:host(.toggle-justify-end) .toggle-wrapper {
|
|
333
|
-
justify-content: end;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
:host(.toggle-alignment-start) .toggle-wrapper {
|
|
337
|
-
align-items: start;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
:host(.toggle-alignment-center) .toggle-wrapper {
|
|
341
|
-
align-items: center;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
:host(.toggle-justify-space-between),
|
|
345
|
-
:host(.toggle-justify-start),
|
|
346
|
-
:host(.toggle-justify-end),
|
|
347
|
-
:host(.toggle-alignment-start),
|
|
348
|
-
:host(.toggle-alignment-center) {
|
|
349
|
-
display: block;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
315
|
.toggle-icon-wrapper {
|
|
353
316
|
display: flex;
|
|
354
317
|
position: relative;
|
|
@@ -17,15 +17,10 @@ import { getIonMode } from "../../global/ionic-global";
|
|
|
17
17
|
* @part track - The background track of the toggle.
|
|
18
18
|
* @part handle - The toggle handle, or knob, used to change the checked state.
|
|
19
19
|
* @part label - The label text describing the toggle.
|
|
20
|
-
* @part supporting-text - Supporting text displayed beneath the toggle label.
|
|
21
|
-
* @part helper-text - Supporting text displayed beneath the toggle label when the toggle is valid.
|
|
22
|
-
* @part error-text - Supporting text displayed beneath the toggle label when the toggle is invalid and touched.
|
|
23
20
|
*/
|
|
24
21
|
export class Toggle {
|
|
25
22
|
constructor() {
|
|
26
23
|
this.inputId = `ion-tg-${toggleIds++}`;
|
|
27
|
-
this.helperTextId = `${this.inputId}-helper-text`;
|
|
28
|
-
this.errorTextId = `${this.inputId}-error-text`;
|
|
29
24
|
this.lastDrag = 0;
|
|
30
25
|
this.inheritedAttributes = {};
|
|
31
26
|
this.didLoad = false;
|
|
@@ -71,8 +66,6 @@ export class Toggle {
|
|
|
71
66
|
this.name = this.inputId;
|
|
72
67
|
this.checked = false;
|
|
73
68
|
this.disabled = false;
|
|
74
|
-
this.errorText = undefined;
|
|
75
|
-
this.helperText = undefined;
|
|
76
69
|
this.value = 'on';
|
|
77
70
|
this.enableOnOffLabels = config.get('toggleOnOffLabels');
|
|
78
71
|
this.labelPlacement = 'start';
|
|
@@ -159,39 +152,13 @@ export class Toggle {
|
|
|
159
152
|
get hasLabel() {
|
|
160
153
|
return this.el.textContent !== '';
|
|
161
154
|
}
|
|
162
|
-
getHintTextID() {
|
|
163
|
-
const { el, helperText, errorText, helperTextId, errorTextId } = this;
|
|
164
|
-
if (el.classList.contains('ion-touched') && el.classList.contains('ion-invalid') && errorText) {
|
|
165
|
-
return errorTextId;
|
|
166
|
-
}
|
|
167
|
-
if (helperText) {
|
|
168
|
-
return helperTextId;
|
|
169
|
-
}
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Responsible for rendering helper text and error text.
|
|
174
|
-
* This element should only be rendered if hint text is set.
|
|
175
|
-
*/
|
|
176
|
-
renderHintText() {
|
|
177
|
-
const { helperText, errorText, helperTextId, errorTextId } = this;
|
|
178
|
-
/**
|
|
179
|
-
* undefined and empty string values should
|
|
180
|
-
* be treated as not having helper/error text.
|
|
181
|
-
*/
|
|
182
|
-
const hasHintText = !!helperText || !!errorText;
|
|
183
|
-
if (!hasHintText) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
return (h("div", { class: "toggle-bottom" }, h("div", { id: helperTextId, class: "helper-text", part: "supporting-text helper-text" }, helperText), h("div", { id: errorTextId, class: "error-text", part: "supporting-text error-text" }, errorText)));
|
|
187
|
-
}
|
|
188
155
|
render() {
|
|
189
156
|
const { activated, color, checked, disabled, el, justify, labelPlacement, inputId, name, alignment, required } = this;
|
|
190
157
|
const mode = getIonMode(this);
|
|
191
158
|
const value = this.getValue();
|
|
192
159
|
const rtl = isRTL(el) ? 'rtl' : 'ltr';
|
|
193
160
|
renderHiddenInput(true, el, name, checked ? value : '', disabled);
|
|
194
|
-
return (h(Host, { key: '
|
|
161
|
+
return (h(Host, { key: 'ed75573caa6e37011f1453dd7f723fb9bd8a3656', onClick: this.onClick, class: createColorClasses(color, {
|
|
195
162
|
[mode]: true,
|
|
196
163
|
'in-item': hostContext('ion-item', el),
|
|
197
164
|
'toggle-activated': activated,
|
|
@@ -201,10 +168,10 @@ export class Toggle {
|
|
|
201
168
|
[`toggle-alignment-${alignment}`]: alignment !== undefined,
|
|
202
169
|
[`toggle-label-placement-${labelPlacement}`]: true,
|
|
203
170
|
[`toggle-${rtl}`]: true,
|
|
204
|
-
}) }, h("label", { key: '
|
|
171
|
+
}) }, h("label", { key: '484860e2a33f4d123904edb96159f0e1972d3add', class: "toggle-wrapper" }, h("input", Object.assign({ key: '360b53080aacfd99a9ff60ffb5219816bd4163ee', type: "checkbox", role: "switch", "aria-checked": `${checked}`, checked: checked, disabled: disabled, id: inputId, onFocus: () => this.onFocus(), onBlur: () => this.onBlur(), ref: (focusEl) => (this.focusEl = focusEl), required: required }, this.inheritedAttributes)), h("div", { key: 'f7239fa668fe11257239ea30cf0198e4f3274f6b', class: {
|
|
205
172
|
'label-text-wrapper': true,
|
|
206
173
|
'label-text-wrapper-hidden': !this.hasLabel,
|
|
207
|
-
}, part: "label" }, h("slot", { key: '
|
|
174
|
+
}, part: "label" }, h("slot", { key: '9495a4a39889822ee68e0d89dc5a2f863d1feb3c' })), h("div", { key: '55f1eb08c4b705e94fbcf02220bbe1d292f06155', class: "native-wrapper" }, this.renderToggleControl()))));
|
|
208
175
|
}
|
|
209
176
|
static get is() { return "ion-toggle"; }
|
|
210
177
|
static get encapsulation() { return "shadow"; }
|
|
@@ -299,40 +266,6 @@ export class Toggle {
|
|
|
299
266
|
"reflect": false,
|
|
300
267
|
"defaultValue": "false"
|
|
301
268
|
},
|
|
302
|
-
"errorText": {
|
|
303
|
-
"type": "string",
|
|
304
|
-
"mutable": false,
|
|
305
|
-
"complexType": {
|
|
306
|
-
"original": "string",
|
|
307
|
-
"resolved": "string | undefined",
|
|
308
|
-
"references": {}
|
|
309
|
-
},
|
|
310
|
-
"required": false,
|
|
311
|
-
"optional": true,
|
|
312
|
-
"docs": {
|
|
313
|
-
"tags": [],
|
|
314
|
-
"text": "Text that is placed under the toggle label and displayed when an error is detected."
|
|
315
|
-
},
|
|
316
|
-
"attribute": "error-text",
|
|
317
|
-
"reflect": false
|
|
318
|
-
},
|
|
319
|
-
"helperText": {
|
|
320
|
-
"type": "string",
|
|
321
|
-
"mutable": false,
|
|
322
|
-
"complexType": {
|
|
323
|
-
"original": "string",
|
|
324
|
-
"resolved": "string | undefined",
|
|
325
|
-
"references": {}
|
|
326
|
-
},
|
|
327
|
-
"required": false,
|
|
328
|
-
"optional": true,
|
|
329
|
-
"docs": {
|
|
330
|
-
"tags": [],
|
|
331
|
-
"text": "Text that is placed under the toggle label and displayed when no error is detected."
|
|
332
|
-
},
|
|
333
|
-
"attribute": "helper-text",
|
|
334
|
-
"reflect": false
|
|
335
|
-
},
|
|
336
269
|
"value": {
|
|
337
270
|
"type": "string",
|
|
338
271
|
"mutable": false,
|
|
@@ -171,39 +171,32 @@ input {
|
|
|
171
171
|
align-items: center;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
.toggle-
|
|
175
|
-
padding-top: 4px;
|
|
176
|
-
display: flex;
|
|
174
|
+
:host(.toggle-justify-space-between) .toggle-wrapper {
|
|
177
175
|
justify-content: space-between;
|
|
178
|
-
font-size: 0.75rem;
|
|
179
|
-
white-space: normal;
|
|
180
176
|
}
|
|
181
177
|
|
|
182
|
-
:host(.toggle-
|
|
183
|
-
|
|
178
|
+
:host(.toggle-justify-start) .toggle-wrapper {
|
|
179
|
+
justify-content: start;
|
|
184
180
|
}
|
|
185
181
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
* present on the checkbox. Otherwise the helper text should
|
|
189
|
-
* be shown.
|
|
190
|
-
*/
|
|
191
|
-
.toggle-bottom .error-text {
|
|
192
|
-
display: none;
|
|
193
|
-
color: var(--ion-color-danger, #c5000f);
|
|
182
|
+
:host(.toggle-justify-end) .toggle-wrapper {
|
|
183
|
+
justify-content: end;
|
|
194
184
|
}
|
|
195
185
|
|
|
196
|
-
.toggle-
|
|
197
|
-
|
|
198
|
-
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
186
|
+
:host(.toggle-alignment-start) .toggle-wrapper {
|
|
187
|
+
align-items: start;
|
|
199
188
|
}
|
|
200
189
|
|
|
201
|
-
:host(.
|
|
202
|
-
|
|
190
|
+
:host(.toggle-alignment-center) .toggle-wrapper {
|
|
191
|
+
align-items: center;
|
|
203
192
|
}
|
|
204
193
|
|
|
205
|
-
:host(.
|
|
206
|
-
|
|
194
|
+
:host(.toggle-justify-space-between),
|
|
195
|
+
:host(.toggle-justify-start),
|
|
196
|
+
:host(.toggle-justify-end),
|
|
197
|
+
:host(.toggle-alignment-start),
|
|
198
|
+
:host(.toggle-alignment-center) {
|
|
199
|
+
display: block;
|
|
207
200
|
}
|
|
208
201
|
|
|
209
202
|
/**
|
|
@@ -232,7 +225,6 @@ input {
|
|
|
232
225
|
*/
|
|
233
226
|
:host(.toggle-label-placement-end) .toggle-wrapper {
|
|
234
227
|
flex-direction: row-reverse;
|
|
235
|
-
justify-content: start;
|
|
236
228
|
}
|
|
237
229
|
|
|
238
230
|
/**
|
|
@@ -275,7 +267,6 @@ input {
|
|
|
275
267
|
*/
|
|
276
268
|
:host(.toggle-label-placement-stacked) .toggle-wrapper {
|
|
277
269
|
flex-direction: column;
|
|
278
|
-
text-align: center;
|
|
279
270
|
}
|
|
280
271
|
|
|
281
272
|
:host(.toggle-label-placement-stacked) .label-text-wrapper {
|
|
@@ -321,34 +312,6 @@ input {
|
|
|
321
312
|
}
|
|
322
313
|
}
|
|
323
314
|
|
|
324
|
-
:host(.toggle-justify-space-between) .toggle-wrapper {
|
|
325
|
-
justify-content: space-between;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
:host(.toggle-justify-start) .toggle-wrapper {
|
|
329
|
-
justify-content: start;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
:host(.toggle-justify-end) .toggle-wrapper {
|
|
333
|
-
justify-content: end;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
:host(.toggle-alignment-start) .toggle-wrapper {
|
|
337
|
-
align-items: start;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
:host(.toggle-alignment-center) .toggle-wrapper {
|
|
341
|
-
align-items: center;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
:host(.toggle-justify-space-between),
|
|
345
|
-
:host(.toggle-justify-start),
|
|
346
|
-
:host(.toggle-justify-end),
|
|
347
|
-
:host(.toggle-alignment-start),
|
|
348
|
-
:host(.toggle-alignment-center) {
|
|
349
|
-
display: block;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
315
|
.toggle-icon-wrapper {
|
|
353
316
|
display: flex;
|
|
354
317
|
position: relative;
|