@ionic/core 8.4.4-dev.11741289071.1e8e1c3f → 8.4.4-dev.11741298262.12200f27
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-select.js +5 -47
- package/components/ion-toggle.js +37 -5
- package/dist/cjs/ion-select_3.cjs.entry.js +5 -45
- package/dist/cjs/ion-toggle.cjs.entry.js +35 -5
- package/dist/cjs/ionic.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/select/select.ios.css +0 -59
- package/dist/collection/components/select/select.js +3 -80
- package/dist/collection/components/select/select.md.css +0 -61
- package/dist/collection/components/toggle/toggle.ios.css +52 -15
- package/dist/collection/components/toggle/toggle.js +70 -3
- package/dist/collection/components/toggle/toggle.md.css +52 -15
- package/dist/docs.json +73 -73
- package/dist/esm/ion-select_3.entry.js +5 -45
- package/dist/esm/ion-toggle.entry.js +35 -5
- package/dist/esm/ionic.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm-es5/ion-select_3.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-0f5d878e.system.entry.js +4 -0
- package/dist/ionic/p-322c5fb4.system.js +1 -1
- package/dist/ionic/p-3990c92b.entry.js +4 -0
- package/dist/ionic/p-3e99e3e0.entry.js +4 -0
- package/dist/ionic/p-7ae680ba.system.entry.js +4 -0
- package/dist/types/components/select/select.d.ts +0 -23
- package/dist/types/components/toggle/toggle.d.ts +19 -0
- package/dist/types/components.d.ts +16 -16
- package/hydrate/index.js +45 -55
- package/hydrate/index.mjs +45 -55
- package/package.json +1 -1
- package/dist/ionic/p-0bfffa34.system.entry.js +0 -4
- package/dist/ionic/p-5c47ebbd.system.entry.js +0 -4
- package/dist/ionic/p-a18470c6.entry.js +0 -4
- package/dist/ionic/p-d0546368.entry.js +0 -4
|
@@ -299,63 +299,6 @@ button {
|
|
|
299
299
|
--highlight-color: var(--highlight-color-valid);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
.select-bottom {
|
|
303
|
-
/**
|
|
304
|
-
* The bottom content should take on the start and end
|
|
305
|
-
* padding so it is always aligned with either the label
|
|
306
|
-
* or the start of the text select.
|
|
307
|
-
*/
|
|
308
|
-
-webkit-padding-start: var(--padding-start);
|
|
309
|
-
padding-inline-start: var(--padding-start);
|
|
310
|
-
-webkit-padding-end: var(--padding-end);
|
|
311
|
-
padding-inline-end: var(--padding-end);
|
|
312
|
-
padding-top: 5px;
|
|
313
|
-
padding-bottom: 0;
|
|
314
|
-
display: flex;
|
|
315
|
-
justify-content: space-between;
|
|
316
|
-
border-top: var(--border-width) var(--border-style) var(--border-color);
|
|
317
|
-
font-size: 0.75rem;
|
|
318
|
-
white-space: normal;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* If the select has a validity state, the
|
|
323
|
-
* border and label should reflect that as a color.
|
|
324
|
-
* The invalid state should show if the select is
|
|
325
|
-
* invalid and has already been touched.
|
|
326
|
-
* The valid state should show if the select
|
|
327
|
-
* is valid, has already been touched, and
|
|
328
|
-
* is currently focused. Do not show the valid
|
|
329
|
-
* highlight when the select is blurred.
|
|
330
|
-
*/
|
|
331
|
-
:host(.has-focus.ion-valid),
|
|
332
|
-
:host(.ion-touched.ion-invalid) {
|
|
333
|
-
--border-color: var(--highlight-color);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Error text should only be shown when .ion-invalid is
|
|
338
|
-
* present on the select. Otherwise the helper text should
|
|
339
|
-
* be shown.
|
|
340
|
-
*/
|
|
341
|
-
.select-bottom .error-text {
|
|
342
|
-
display: none;
|
|
343
|
-
color: var(--highlight-color-invalid);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.select-bottom .helper-text {
|
|
347
|
-
display: block;
|
|
348
|
-
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
:host(.ion-touched.ion-invalid) .select-bottom .error-text {
|
|
352
|
-
display: block;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
:host(.ion-touched.ion-invalid) .select-bottom .helper-text {
|
|
356
|
-
display: none;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
302
|
.label-text-wrapper {
|
|
360
303
|
/**
|
|
361
304
|
* This causes the label to take up
|
|
@@ -743,8 +686,6 @@ button {
|
|
|
743
686
|
* }
|
|
744
687
|
*/
|
|
745
688
|
:host {
|
|
746
|
-
--border-width: 0.55px;
|
|
747
|
-
--border-color: var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-250, var(--ion-background-color-step-250, #c8c7cc))));
|
|
748
689
|
--highlight-height: 0px;
|
|
749
690
|
}
|
|
750
691
|
|
|
@@ -23,15 +23,10 @@ import { getIonMode } from "../../global/ionic-global";
|
|
|
23
23
|
* @part icon - The select icon container.
|
|
24
24
|
* @part container - The container for the selected text or placeholder.
|
|
25
25
|
* @part label - The label text describing the select.
|
|
26
|
-
* @part supporting-text - Supporting text displayed beneath the select.
|
|
27
|
-
* @part helper-text - Supporting text displayed beneath the select when the select is valid.
|
|
28
|
-
* @part error-text - Supporting text displayed beneath the select when the select is invalid and touched.
|
|
29
26
|
*/
|
|
30
27
|
export class Select {
|
|
31
28
|
constructor() {
|
|
32
29
|
this.inputId = `ion-sel-${selectIds++}`;
|
|
33
|
-
this.helperTextId = `${this.inputId}-helper-text`;
|
|
34
|
-
this.errorTextId = `${this.inputId}-error-text`;
|
|
35
30
|
this.inheritedAttributes = {};
|
|
36
31
|
this.onClick = (ev) => {
|
|
37
32
|
const target = ev.target;
|
|
@@ -82,8 +77,6 @@ export class Select {
|
|
|
82
77
|
this.compareWith = undefined;
|
|
83
78
|
this.disabled = false;
|
|
84
79
|
this.fill = undefined;
|
|
85
|
-
this.errorText = undefined;
|
|
86
|
-
this.helperText = undefined;
|
|
87
80
|
this.interface = 'alert';
|
|
88
81
|
this.interfaceOptions = {};
|
|
89
82
|
this.justify = undefined;
|
|
@@ -664,43 +657,7 @@ export class Select {
|
|
|
664
657
|
}
|
|
665
658
|
renderListbox() {
|
|
666
659
|
const { disabled, inputId, isExpanded, required } = this;
|
|
667
|
-
return (h("button", { disabled: disabled, id: inputId, "aria-label": this.ariaLabel, "aria-haspopup": "dialog", "aria-expanded": `${isExpanded}`, "aria-
|
|
668
|
-
}
|
|
669
|
-
getHintTextID() {
|
|
670
|
-
const { el, helperText, errorText, helperTextId, errorTextId } = this;
|
|
671
|
-
if (el.classList.contains('ion-touched') && el.classList.contains('ion-invalid') && errorText) {
|
|
672
|
-
return errorTextId;
|
|
673
|
-
}
|
|
674
|
-
if (helperText) {
|
|
675
|
-
return helperTextId;
|
|
676
|
-
}
|
|
677
|
-
return undefined;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Renders the helper text or error text values
|
|
681
|
-
*/
|
|
682
|
-
renderHintText() {
|
|
683
|
-
const { helperText, errorText, helperTextId, errorTextId } = this;
|
|
684
|
-
return [
|
|
685
|
-
h("div", { id: helperTextId, class: "helper-text", part: "supporting-text helper-text" }, helperText),
|
|
686
|
-
h("div", { id: errorTextId, class: "error-text", part: "supporting-text error-text" }, errorText),
|
|
687
|
-
];
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Responsible for rendering helper text, and error text. This element
|
|
691
|
-
* should only be rendered if hint text is set.
|
|
692
|
-
*/
|
|
693
|
-
renderBottomContent() {
|
|
694
|
-
const { helperText, errorText } = this;
|
|
695
|
-
/**
|
|
696
|
-
* undefined and empty string values should
|
|
697
|
-
* be treated as not having helper/error text.
|
|
698
|
-
*/
|
|
699
|
-
const hasHintText = !!helperText || !!errorText;
|
|
700
|
-
if (!hasHintText) {
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
return h("div", { class: "select-bottom" }, this.renderHintText());
|
|
660
|
+
return (h("button", { disabled: disabled, id: inputId, "aria-label": this.ariaLabel, "aria-haspopup": "dialog", "aria-expanded": `${isExpanded}`, "aria-required": `${required}`, onFocus: this.onFocus, onBlur: this.onBlur, ref: (focusEl) => (this.focusEl = focusEl) }));
|
|
704
661
|
}
|
|
705
662
|
render() {
|
|
706
663
|
const { disabled, el, isExpanded, expandedIcon, labelPlacement, justify, placeholder, fill, shape, name, value } = this;
|
|
@@ -731,7 +688,7 @@ export class Select {
|
|
|
731
688
|
* TODO(FW-5592): Remove hasStartEndSlots condition
|
|
732
689
|
*/
|
|
733
690
|
const labelShouldFloat = labelPlacement === 'stacked' || (labelPlacement === 'floating' && (hasValue || isExpanded || hasStartEndSlots));
|
|
734
|
-
return (h(Host, { key: '
|
|
691
|
+
return (h(Host, { key: 'f7cf03de773cd85da42978e274d65cc1eb6ed8a3', onClick: this.onClick, class: createColorClasses(this.color, {
|
|
735
692
|
[mode]: true,
|
|
736
693
|
'in-item': inItem,
|
|
737
694
|
'in-item-color': hostContext('ion-item.ion-color', el),
|
|
@@ -747,7 +704,7 @@ export class Select {
|
|
|
747
704
|
[`select-justify-${justify}`]: justifyEnabled,
|
|
748
705
|
[`select-shape-${shape}`]: shape !== undefined,
|
|
749
706
|
[`select-label-placement-${labelPlacement}`]: true,
|
|
750
|
-
}) }, h("label", { key: '
|
|
707
|
+
}) }, h("label", { key: '91674f8f5cce37c87a7096d09b3f1d351cba1527', class: "select-wrapper", id: "select-label" }, this.renderLabelContainer(), h("div", { key: '2229333833047db13ed2a01cb10bb6e6f774031d', class: "select-wrapper-inner" }, h("slot", { key: 'f2766bdf8bff261efa5711f72d9edef407e45189', name: "start" }), h("div", { key: '84fec020ecaaac41298a01dbffdbb2f3744170b4', class: "native-wrapper", ref: (el) => (this.nativeWrapperEl = el), part: "container" }, this.renderSelectText(), this.renderListbox()), h("slot", { key: '9b91237d7a1621bce1e15546abcb4f6b74cccc5f', name: "end" }), !hasFloatingOrStackedLabel && this.renderSelectIcon()), hasFloatingOrStackedLabel && this.renderSelectIcon(), shouldRenderHighlight && h("div", { key: 'e02aea3e8f344376013257f5261a29408e62b359', class: "select-highlight" }))));
|
|
751
708
|
}
|
|
752
709
|
static get is() { return "ion-select"; }
|
|
753
710
|
static get encapsulation() { return "shadow"; }
|
|
@@ -864,40 +821,6 @@ export class Select {
|
|
|
864
821
|
"attribute": "fill",
|
|
865
822
|
"reflect": false
|
|
866
823
|
},
|
|
867
|
-
"errorText": {
|
|
868
|
-
"type": "string",
|
|
869
|
-
"mutable": false,
|
|
870
|
-
"complexType": {
|
|
871
|
-
"original": "string",
|
|
872
|
-
"resolved": "string | undefined",
|
|
873
|
-
"references": {}
|
|
874
|
-
},
|
|
875
|
-
"required": false,
|
|
876
|
-
"optional": true,
|
|
877
|
-
"docs": {
|
|
878
|
-
"tags": [],
|
|
879
|
-
"text": "Text that is placed under the select and displayed when an error is detected."
|
|
880
|
-
},
|
|
881
|
-
"attribute": "error-text",
|
|
882
|
-
"reflect": false
|
|
883
|
-
},
|
|
884
|
-
"helperText": {
|
|
885
|
-
"type": "string",
|
|
886
|
-
"mutable": false,
|
|
887
|
-
"complexType": {
|
|
888
|
-
"original": "string",
|
|
889
|
-
"resolved": "string | undefined",
|
|
890
|
-
"references": {}
|
|
891
|
-
},
|
|
892
|
-
"required": false,
|
|
893
|
-
"optional": true,
|
|
894
|
-
"docs": {
|
|
895
|
-
"tags": [],
|
|
896
|
-
"text": "Text that is placed under the select and displayed when no error is detected."
|
|
897
|
-
},
|
|
898
|
-
"attribute": "helper-text",
|
|
899
|
-
"reflect": false
|
|
900
|
-
},
|
|
901
824
|
"interface": {
|
|
902
825
|
"type": "string",
|
|
903
826
|
"mutable": false,
|
|
@@ -299,63 +299,6 @@ button {
|
|
|
299
299
|
--highlight-color: var(--highlight-color-valid);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
.select-bottom {
|
|
303
|
-
/**
|
|
304
|
-
* The bottom content should take on the start and end
|
|
305
|
-
* padding so it is always aligned with either the label
|
|
306
|
-
* or the start of the text select.
|
|
307
|
-
*/
|
|
308
|
-
-webkit-padding-start: var(--padding-start);
|
|
309
|
-
padding-inline-start: var(--padding-start);
|
|
310
|
-
-webkit-padding-end: var(--padding-end);
|
|
311
|
-
padding-inline-end: var(--padding-end);
|
|
312
|
-
padding-top: 5px;
|
|
313
|
-
padding-bottom: 0;
|
|
314
|
-
display: flex;
|
|
315
|
-
justify-content: space-between;
|
|
316
|
-
border-top: var(--border-width) var(--border-style) var(--border-color);
|
|
317
|
-
font-size: 0.75rem;
|
|
318
|
-
white-space: normal;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* If the select has a validity state, the
|
|
323
|
-
* border and label should reflect that as a color.
|
|
324
|
-
* The invalid state should show if the select is
|
|
325
|
-
* invalid and has already been touched.
|
|
326
|
-
* The valid state should show if the select
|
|
327
|
-
* is valid, has already been touched, and
|
|
328
|
-
* is currently focused. Do not show the valid
|
|
329
|
-
* highlight when the select is blurred.
|
|
330
|
-
*/
|
|
331
|
-
:host(.has-focus.ion-valid),
|
|
332
|
-
:host(.ion-touched.ion-invalid) {
|
|
333
|
-
--border-color: var(--highlight-color);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Error text should only be shown when .ion-invalid is
|
|
338
|
-
* present on the select. Otherwise the helper text should
|
|
339
|
-
* be shown.
|
|
340
|
-
*/
|
|
341
|
-
.select-bottom .error-text {
|
|
342
|
-
display: none;
|
|
343
|
-
color: var(--highlight-color-invalid);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.select-bottom .helper-text {
|
|
347
|
-
display: block;
|
|
348
|
-
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
:host(.ion-touched.ion-invalid) .select-bottom .error-text {
|
|
352
|
-
display: block;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
:host(.ion-touched.ion-invalid) .select-bottom .helper-text {
|
|
356
|
-
display: none;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
302
|
.label-text-wrapper {
|
|
360
303
|
/**
|
|
361
304
|
* This causes the label to take up
|
|
@@ -825,10 +768,6 @@ button {
|
|
|
825
768
|
--border-color: var(--highlight-color);
|
|
826
769
|
}
|
|
827
770
|
|
|
828
|
-
/**
|
|
829
|
-
* The bottom content should never have
|
|
830
|
-
* a border with the solid style.
|
|
831
|
-
*/
|
|
832
771
|
:host(.select-fill-solid) .select-bottom {
|
|
833
772
|
border-top: none;
|
|
834
773
|
}
|
|
@@ -171,32 +171,39 @@ input {
|
|
|
171
171
|
align-items: center;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
.toggle-bottom {
|
|
175
|
+
padding-top: 4px;
|
|
176
|
+
display: flex;
|
|
175
177
|
justify-content: space-between;
|
|
178
|
+
font-size: 0.75rem;
|
|
179
|
+
white-space: normal;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
:host(.toggle-
|
|
179
|
-
|
|
182
|
+
:host(.toggle-label-placement-stacked) .toggle-bottom {
|
|
183
|
+
font-size: 1rem;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Error text should only be shown when .ion-invalid is
|
|
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);
|
|
184
194
|
}
|
|
185
195
|
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
.toggle-bottom .helper-text {
|
|
197
|
+
display: block;
|
|
198
|
+
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
:host(.
|
|
191
|
-
|
|
201
|
+
:host(.ion-touched.ion-invalid) .toggle-bottom .error-text {
|
|
202
|
+
display: block;
|
|
192
203
|
}
|
|
193
204
|
|
|
194
|
-
:host(.toggle-
|
|
195
|
-
:
|
|
196
|
-
:host(.toggle-justify-end),
|
|
197
|
-
:host(.toggle-alignment-start),
|
|
198
|
-
:host(.toggle-alignment-center) {
|
|
199
|
-
display: block;
|
|
205
|
+
:host(.ion-touched.ion-invalid) .toggle-bottom .helper-text {
|
|
206
|
+
display: none;
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
/**
|
|
@@ -225,6 +232,7 @@ input {
|
|
|
225
232
|
*/
|
|
226
233
|
:host(.toggle-label-placement-end) .toggle-wrapper {
|
|
227
234
|
flex-direction: row-reverse;
|
|
235
|
+
justify-content: start;
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
/**
|
|
@@ -267,6 +275,7 @@ input {
|
|
|
267
275
|
*/
|
|
268
276
|
:host(.toggle-label-placement-stacked) .toggle-wrapper {
|
|
269
277
|
flex-direction: column;
|
|
278
|
+
text-align: center;
|
|
270
279
|
}
|
|
271
280
|
|
|
272
281
|
:host(.toggle-label-placement-stacked) .label-text-wrapper {
|
|
@@ -312,6 +321,34 @@ input {
|
|
|
312
321
|
}
|
|
313
322
|
}
|
|
314
323
|
|
|
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
|
+
|
|
315
352
|
.toggle-icon-wrapper {
|
|
316
353
|
display: flex;
|
|
317
354
|
position: relative;
|
|
@@ -17,10 +17,15 @@ 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.
|
|
20
23
|
*/
|
|
21
24
|
export class Toggle {
|
|
22
25
|
constructor() {
|
|
23
26
|
this.inputId = `ion-tg-${toggleIds++}`;
|
|
27
|
+
this.helperTextId = `${this.inputId}-helper-text`;
|
|
28
|
+
this.errorTextId = `${this.inputId}-error-text`;
|
|
24
29
|
this.lastDrag = 0;
|
|
25
30
|
this.inheritedAttributes = {};
|
|
26
31
|
this.didLoad = false;
|
|
@@ -66,6 +71,8 @@ export class Toggle {
|
|
|
66
71
|
this.name = this.inputId;
|
|
67
72
|
this.checked = false;
|
|
68
73
|
this.disabled = false;
|
|
74
|
+
this.errorText = undefined;
|
|
75
|
+
this.helperText = undefined;
|
|
69
76
|
this.value = 'on';
|
|
70
77
|
this.enableOnOffLabels = config.get('toggleOnOffLabels');
|
|
71
78
|
this.labelPlacement = 'start';
|
|
@@ -152,13 +159,39 @@ export class Toggle {
|
|
|
152
159
|
get hasLabel() {
|
|
153
160
|
return this.el.textContent !== '';
|
|
154
161
|
}
|
|
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
|
+
}
|
|
155
188
|
render() {
|
|
156
189
|
const { activated, color, checked, disabled, el, justify, labelPlacement, inputId, name, alignment, required } = this;
|
|
157
190
|
const mode = getIonMode(this);
|
|
158
191
|
const value = this.getValue();
|
|
159
192
|
const rtl = isRTL(el) ? 'rtl' : 'ltr';
|
|
160
193
|
renderHiddenInput(true, el, name, checked ? value : '', disabled);
|
|
161
|
-
return (h(Host, { key: '
|
|
194
|
+
return (h(Host, { key: '6a03757dc962cda1c8f986e84d8545875de8e5fa', "aria-describedby": this.getHintTextID(), "aria-invalid": this.getHintTextID() === this.errorTextId, onClick: this.onClick, class: createColorClasses(color, {
|
|
162
195
|
[mode]: true,
|
|
163
196
|
'in-item': hostContext('ion-item', el),
|
|
164
197
|
'toggle-activated': activated,
|
|
@@ -168,10 +201,10 @@ export class Toggle {
|
|
|
168
201
|
[`toggle-alignment-${alignment}`]: alignment !== undefined,
|
|
169
202
|
[`toggle-label-placement-${labelPlacement}`]: true,
|
|
170
203
|
[`toggle-${rtl}`]: true,
|
|
171
|
-
}) }, h("label", { key: '
|
|
204
|
+
}) }, h("label", { key: '842e00a34befece9ea84a9e28dd62d49104de681', class: "toggle-wrapper" }, h("input", Object.assign({ key: 'eb889c180b3f6efab26f31669aa6adc23d866eb1', 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: 'fe57b4a97a0ddabf99995f1def5cd432b7ea591d', class: {
|
|
172
205
|
'label-text-wrapper': true,
|
|
173
206
|
'label-text-wrapper-hidden': !this.hasLabel,
|
|
174
|
-
}, part: "label" }, h("slot", { key: '
|
|
207
|
+
}, part: "label" }, h("slot", { key: '4ae52733af284130dfb2e2c3b476e0516e0be147' }), this.renderHintText()), h("div", { key: 'ffee5416e2ab4b8d286d2790490255bb45346ce0', class: "native-wrapper" }, this.renderToggleControl()))));
|
|
175
208
|
}
|
|
176
209
|
static get is() { return "ion-toggle"; }
|
|
177
210
|
static get encapsulation() { return "shadow"; }
|
|
@@ -266,6 +299,40 @@ export class Toggle {
|
|
|
266
299
|
"reflect": false,
|
|
267
300
|
"defaultValue": "false"
|
|
268
301
|
},
|
|
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
|
+
},
|
|
269
336
|
"value": {
|
|
270
337
|
"type": "string",
|
|
271
338
|
"mutable": false,
|
|
@@ -171,32 +171,39 @@ input {
|
|
|
171
171
|
align-items: center;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
.toggle-bottom {
|
|
175
|
+
padding-top: 4px;
|
|
176
|
+
display: flex;
|
|
175
177
|
justify-content: space-between;
|
|
178
|
+
font-size: 0.75rem;
|
|
179
|
+
white-space: normal;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
:host(.toggle-
|
|
179
|
-
|
|
182
|
+
:host(.toggle-label-placement-stacked) .toggle-bottom {
|
|
183
|
+
font-size: 1rem;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Error text should only be shown when .ion-invalid is
|
|
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);
|
|
184
194
|
}
|
|
185
195
|
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
.toggle-bottom .helper-text {
|
|
197
|
+
display: block;
|
|
198
|
+
color: var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
:host(.
|
|
191
|
-
|
|
201
|
+
:host(.ion-touched.ion-invalid) .toggle-bottom .error-text {
|
|
202
|
+
display: block;
|
|
192
203
|
}
|
|
193
204
|
|
|
194
|
-
:host(.toggle-
|
|
195
|
-
:
|
|
196
|
-
:host(.toggle-justify-end),
|
|
197
|
-
:host(.toggle-alignment-start),
|
|
198
|
-
:host(.toggle-alignment-center) {
|
|
199
|
-
display: block;
|
|
205
|
+
:host(.ion-touched.ion-invalid) .toggle-bottom .helper-text {
|
|
206
|
+
display: none;
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
/**
|
|
@@ -225,6 +232,7 @@ input {
|
|
|
225
232
|
*/
|
|
226
233
|
:host(.toggle-label-placement-end) .toggle-wrapper {
|
|
227
234
|
flex-direction: row-reverse;
|
|
235
|
+
justify-content: start;
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
/**
|
|
@@ -267,6 +275,7 @@ input {
|
|
|
267
275
|
*/
|
|
268
276
|
:host(.toggle-label-placement-stacked) .toggle-wrapper {
|
|
269
277
|
flex-direction: column;
|
|
278
|
+
text-align: center;
|
|
270
279
|
}
|
|
271
280
|
|
|
272
281
|
:host(.toggle-label-placement-stacked) .label-text-wrapper {
|
|
@@ -312,6 +321,34 @@ input {
|
|
|
312
321
|
}
|
|
313
322
|
}
|
|
314
323
|
|
|
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
|
+
|
|
315
352
|
.toggle-icon-wrapper {
|
|
316
353
|
display: flex;
|
|
317
354
|
position: relative;
|