@govtechsg/sgds-web-component 3.0.6 → 3.1.0-rc.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/components/Checkbox/checkbox-group.js +1 -1
- package/components/Checkbox/checkbox.js +1 -1
- package/components/Checkbox/index.umd.js +195 -31
- package/components/Checkbox/index.umd.js.map +1 -1
- package/components/Checkbox/sgds-checkbox-group.d.ts +49 -10
- package/components/Checkbox/sgds-checkbox-group.js +161 -25
- package/components/Checkbox/sgds-checkbox-group.js.map +1 -1
- package/components/Checkbox/sgds-checkbox.d.ts +5 -1
- package/components/Checkbox/sgds-checkbox.js +39 -6
- package/components/Checkbox/sgds-checkbox.js.map +1 -1
- package/components/ComboBox/index.umd.js +39 -6
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/index.umd.js +195 -31
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +195 -31
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Checkbox/checkbox-group.cjs.js +1 -1
- package/react/components/Checkbox/checkbox-group.js +1 -1
- package/react/components/Checkbox/checkbox.cjs.js +1 -1
- package/react/components/Checkbox/checkbox.js +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js +160 -24
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.js +161 -25
- package/react/components/Checkbox/sgds-checkbox-group.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox.cjs.js +38 -5
- package/react/components/Checkbox/sgds-checkbox.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox.js +39 -6
- package/react/components/Checkbox/sgds-checkbox.js.map +1 -1
package/components/index.umd.js
CHANGED
|
@@ -10589,7 +10589,7 @@
|
|
|
10589
10589
|
return ToBeValidatedElement;
|
|
10590
10590
|
};
|
|
10591
10591
|
|
|
10592
|
-
var css_248z$H = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input,.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-surface-default);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-default);border-radius:var(--sgds-form-border-radius-md)}:host(:not([disabled]):not([invalid]):not([checked]):not([indeterminate])) .form-check-input:hover{border:var(--sgds-form-border-width-thick) solid var(--sgds-border-color-emphasis)}.form-check-input:focus,.form-check-input:focus-visible{border:var(--sgds-form-border-width-thick) solid var(--sgds-border-color-emphasis);box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path d="M14.347 3.979a.522.522 0 0 1 0 .739L7.043 12.02a.521.521 0 0 1-.738 0L2.653 8.369a.522.522 0 1 1 .739-.738l3.282 3.283 6.934-6.935a.52.52 0 0 1 .739 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-input:checked:focus,.form-check-input:checked:hover,.form-check-input[checked]:focus-visible,.form-check-input[checked]:hover{background-color:var(--sgds-form-primary-surface-emphasis)}.form-check-input:indeterminate,.form-check-input[indeterminate]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-input:indeterminate:focus,.form-check-input:indeterminate:hover,.form-check-input[indeterminate]:focus-visible,.form-check-input[indeterminate]:hover{background-color:var(--sgds-form-primary-surface-emphasis)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input.is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color-default)}.form-check-input:checked.is-invalid,.form-check-input:indeterminate.is-invalid,.form-check-input[checked].is-invalid,.form-check-input[indeterminate].is-invalid{background-color:var(--sgds-form-danger-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-label{width:100%}`;
|
|
10592
|
+
var css_248z$H = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);margin-bottom:var(--sgds-margin-3-xs);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input,.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-surface-default);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-default);border-radius:var(--sgds-form-border-radius-md)}:host(:not([disabled]):not([invalid]):not([checked]):not([indeterminate])) .form-check-input:hover{border:var(--sgds-form-border-width-thick) solid var(--sgds-border-color-emphasis)}.form-check-input:focus,.form-check-input:focus-visible{border:var(--sgds-form-border-width-thick) solid var(--sgds-border-color-emphasis);box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path d="M14.347 3.979a.522.522 0 0 1 0 .739L7.043 12.02a.521.521 0 0 1-.738 0L2.653 8.369a.522.522 0 1 1 .739-.738l3.282 3.283 6.934-6.935a.52.52 0 0 1 .739 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-input:checked:focus,.form-check-input:checked:hover,.form-check-input[checked]:focus-visible,.form-check-input[checked]:hover{background-color:var(--sgds-form-primary-surface-emphasis)}.form-check-input:indeterminate,.form-check-input[indeterminate]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-input:indeterminate:focus,.form-check-input:indeterminate:hover,.form-check-input[indeterminate]:focus-visible,.form-check-input[indeterminate]:hover{background-color:var(--sgds-form-primary-surface-emphasis)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input.is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color-default)}.form-check-input:checked.is-invalid,.form-check-input:indeterminate.is-invalid,.form-check-input[checked].is-invalid,.form-check-input[indeterminate].is-invalid{background-color:var(--sgds-form-danger-surface-default);border:var(--sgds-form-border-width-default) solid var(--sgds-border-color-transparent)}.form-check-label{width:100%}`;
|
|
10593
10593
|
|
|
10594
10594
|
/**
|
|
10595
10595
|
* @summary Checkbox component is used when you require users to select multiple items from a list.
|
|
@@ -10606,14 +10606,14 @@
|
|
|
10606
10606
|
super(...arguments);
|
|
10607
10607
|
/** Draws the checkbox in a checked state. */
|
|
10608
10608
|
this.checked = false;
|
|
10609
|
-
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
10610
|
-
this.hasFeedback = false;
|
|
10611
10609
|
/** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
|
|
10612
10610
|
this.defaultChecked = false;
|
|
10613
10611
|
/** Marks the checkbox input as indeterminate , with indeterminate logo */
|
|
10614
10612
|
this.indeterminate = false;
|
|
10615
10613
|
/** Makes the checkbox a required field. */
|
|
10616
10614
|
this.required = false;
|
|
10615
|
+
/**Feedback text for error state when validated */
|
|
10616
|
+
this.invalidFeedback = "";
|
|
10617
10617
|
this._isTouched = false;
|
|
10618
10618
|
}
|
|
10619
10619
|
_handleInvalidChange() {
|
|
@@ -10638,7 +10638,6 @@
|
|
|
10638
10638
|
this.indeterminate = !this.indeterminate;
|
|
10639
10639
|
}
|
|
10640
10640
|
this.checked = !this.checked;
|
|
10641
|
-
this.value = this.input.value;
|
|
10642
10641
|
super._mixinHandleChange(e);
|
|
10643
10642
|
this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
|
|
10644
10643
|
}
|
|
@@ -10669,6 +10668,11 @@
|
|
|
10669
10668
|
this.invalid = !this.input.checkValidity();
|
|
10670
10669
|
}
|
|
10671
10670
|
}
|
|
10671
|
+
_handleChecked() {
|
|
10672
|
+
this.checked
|
|
10673
|
+
? this.emit("sgds-check", { detail: { value: this.value } })
|
|
10674
|
+
: this.emit("sgds-uncheck", { detail: { value: this.value } });
|
|
10675
|
+
}
|
|
10672
10676
|
_mixinResetFormControl() {
|
|
10673
10677
|
this._isTouched = false;
|
|
10674
10678
|
this.checked = this.input.checked = this.defaultChecked;
|
|
@@ -10700,14 +10704,20 @@
|
|
|
10700
10704
|
get validationMessage() {
|
|
10701
10705
|
return this._mixinGetValidationMessage();
|
|
10702
10706
|
}
|
|
10707
|
+
firstUpdated(_changedProperties) {
|
|
10708
|
+
super.firstUpdated(_changedProperties);
|
|
10709
|
+
this.checked && this.emit("sgds-check", { detail: { value: this.value } });
|
|
10710
|
+
}
|
|
10703
10711
|
render() {
|
|
10712
|
+
const wantFeedbackStyle = this.hasFeedback === "both" || this.hasFeedback === "style";
|
|
10713
|
+
const wantFeedbackText = this.hasFeedback === "both" || this.hasFeedback === "text";
|
|
10704
10714
|
return html$1 `
|
|
10705
10715
|
<div class="form-check">
|
|
10706
10716
|
<div class="form-check-input-container">
|
|
10707
10717
|
<input
|
|
10708
10718
|
class=${classMap({
|
|
10709
10719
|
"form-check-input": true,
|
|
10710
|
-
"is-invalid":
|
|
10720
|
+
"is-invalid": wantFeedbackStyle && this.invalid
|
|
10711
10721
|
})}
|
|
10712
10722
|
type="checkbox"
|
|
10713
10723
|
id=${this._controlId}
|
|
@@ -10729,6 +10739,23 @@
|
|
|
10729
10739
|
</div>
|
|
10730
10740
|
<label for="${this._controlId}" class="form-check-label" id="${this._labelId}"><slot></slot></label>
|
|
10731
10741
|
</div>
|
|
10742
|
+
${wantFeedbackText && this.invalid
|
|
10743
|
+
? html$1 `
|
|
10744
|
+
<div class="invalid-feedback-container">
|
|
10745
|
+
<slot name="invalidIcon">
|
|
10746
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
10747
|
+
<path
|
|
10748
|
+
d="M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10ZM10 6.25C9.49805 6.25 9.10584 6.68339 9.15578 7.18285L9.48461 10.4711C9.51109 10.7359 9.7339 10.9375 10 10.9375C10.2661 10.9375 10.4889 10.7359 10.5154 10.4711L10.8442 7.18285C10.8942 6.68339 10.5019 6.25 10 6.25ZM10.0014 11.875C9.48368 11.875 9.06394 12.2947 9.06394 12.8125C9.06394 13.3303 9.48368 13.75 10.0014 13.75C10.5192 13.75 10.9389 13.3303 10.9389 12.8125C10.9389 12.2947 10.5192 11.875 10.0014 11.875Z"
|
|
10749
|
+
fill="currentColor"
|
|
10750
|
+
/>
|
|
10751
|
+
</svg>
|
|
10752
|
+
</slot>
|
|
10753
|
+
<div id="checkbox-feedback" tabindex="0" class="invalid-feedback">
|
|
10754
|
+
${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}
|
|
10755
|
+
</div>
|
|
10756
|
+
</div>
|
|
10757
|
+
`
|
|
10758
|
+
: nothing}
|
|
10732
10759
|
`;
|
|
10733
10760
|
}
|
|
10734
10761
|
}
|
|
@@ -10740,7 +10767,7 @@
|
|
|
10740
10767
|
property({ type: Boolean, reflect: true })
|
|
10741
10768
|
], SgdsCheckbox.prototype, "checked", void 0);
|
|
10742
10769
|
__decorate([
|
|
10743
|
-
property({ type:
|
|
10770
|
+
property({ type: String, reflect: true })
|
|
10744
10771
|
], SgdsCheckbox.prototype, "hasFeedback", void 0);
|
|
10745
10772
|
__decorate([
|
|
10746
10773
|
defaultValue("checked")
|
|
@@ -10751,6 +10778,9 @@
|
|
|
10751
10778
|
__decorate([
|
|
10752
10779
|
property({ type: Boolean, reflect: true })
|
|
10753
10780
|
], SgdsCheckbox.prototype, "required", void 0);
|
|
10781
|
+
__decorate([
|
|
10782
|
+
property({ type: String, reflect: true })
|
|
10783
|
+
], SgdsCheckbox.prototype, "invalidFeedback", void 0);
|
|
10754
10784
|
__decorate([
|
|
10755
10785
|
state()
|
|
10756
10786
|
], SgdsCheckbox.prototype, "_isTouched", void 0);
|
|
@@ -10763,8 +10793,11 @@
|
|
|
10763
10793
|
__decorate([
|
|
10764
10794
|
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
10765
10795
|
], SgdsCheckbox.prototype, "_handleIsTouched", null);
|
|
10796
|
+
__decorate([
|
|
10797
|
+
watch("checked", { waitUntilFirstUpdate: true })
|
|
10798
|
+
], SgdsCheckbox.prototype, "_handleChecked", null);
|
|
10766
10799
|
|
|
10767
|
-
var css_248z$G = css`:host{--sgds-checkbox-group-gap:var(--sgds-spacer-2)}fieldset{border:0;gap:var(--sgds-form-gap-md);margin:0;min-width:0;padding:0}.label-hint-container,fieldset{display:flex;flex-direction:column}.label-hint-container{gap:var(--sgds-form-gap-sm)}.label-hint-container .form-label{color:var(--sgds-form-color-default);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular)}.checkbox-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}`;
|
|
10800
|
+
var css_248z$G = css`:host{--sgds-checkbox-group-gap:var(--sgds-spacer-2)}fieldset{border:0;gap:var(--sgds-form-gap-md);margin:0;min-width:0;padding:0}.label-hint-container,fieldset{display:flex;flex-direction:column}.label-hint-container{gap:var(--sgds-form-gap-sm)}.label-hint-container .form-label{color:var(--sgds-form-color-default);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular)}.checkbox-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}.checkbox-group-validation-input{display:none}`;
|
|
10768
10801
|
|
|
10769
10802
|
/**
|
|
10770
10803
|
* @summary CheckboxGroup is the container that group multiple checkboxes under a single question field.
|
|
@@ -10774,10 +10807,9 @@
|
|
|
10774
10807
|
* @slot invalidIcon - The slot for invalid icon
|
|
10775
10808
|
*
|
|
10776
10809
|
*/
|
|
10777
|
-
class SgdsCheckboxGroup extends
|
|
10810
|
+
class SgdsCheckboxGroup extends SgdsFormValidatorMixin(FormControlElement) {
|
|
10778
10811
|
constructor() {
|
|
10779
|
-
super();
|
|
10780
|
-
this.hasInvalidCheckbox = false;
|
|
10812
|
+
super(...arguments);
|
|
10781
10813
|
/** The checkbox group's label */
|
|
10782
10814
|
this.label = "";
|
|
10783
10815
|
/**Feedback text for error state when validated */
|
|
@@ -10786,27 +10818,126 @@
|
|
|
10786
10818
|
this.hasFeedback = false;
|
|
10787
10819
|
/** The checkbox group's hint text */
|
|
10788
10820
|
this.hintText = "";
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
this.
|
|
10821
|
+
/** Makes the checkbox group a required field. Only available for when multiselect is true */
|
|
10822
|
+
this.required = false;
|
|
10823
|
+
/** Consolidates the values of its child checked checkboxes into a single string with semi-colon delimiter. Only available when required is true */
|
|
10824
|
+
this.value = "";
|
|
10825
|
+
this._isTouched = false;
|
|
10826
|
+
/**@internal */
|
|
10827
|
+
this.defaultValue = "";
|
|
10796
10828
|
}
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10829
|
+
connectedCallback() {
|
|
10830
|
+
super.connectedCallback();
|
|
10831
|
+
this.defaultValue = this.value;
|
|
10832
|
+
this.addEventListener("sgds-check", (e) => {
|
|
10833
|
+
const { value } = e.detail;
|
|
10834
|
+
!this.value.includes(value) && this._addValue(value);
|
|
10835
|
+
});
|
|
10836
|
+
this.addEventListener("sgds-uncheck", (e) => {
|
|
10837
|
+
const { value } = e.detail;
|
|
10838
|
+
this._removeValue(value);
|
|
10839
|
+
});
|
|
10840
|
+
this.addEventListener("sgds-blur", () => {
|
|
10841
|
+
this._isTouched = true;
|
|
10842
|
+
});
|
|
10800
10843
|
}
|
|
10801
10844
|
_renderHintText() {
|
|
10802
10845
|
const hintTextTemplate = html$1 ` <div class="form-text">${this.hintText}</div> `;
|
|
10803
10846
|
return this.hintText && hintTextTemplate;
|
|
10804
10847
|
}
|
|
10805
|
-
|
|
10806
|
-
this.
|
|
10848
|
+
_addValue(newValue) {
|
|
10849
|
+
const valueArray = this.value ? this.value.split(";") : [];
|
|
10850
|
+
valueArray.push(newValue);
|
|
10851
|
+
this.value = valueArray.join(";");
|
|
10852
|
+
}
|
|
10853
|
+
_removeValue(oldValue) {
|
|
10854
|
+
const valueArray = this.value ? this.value.split(";") : [];
|
|
10855
|
+
const newValueArray = valueArray.filter(v => v !== oldValue);
|
|
10856
|
+
this.value = newValueArray.join(";");
|
|
10857
|
+
}
|
|
10858
|
+
_sanitizeSlot() {
|
|
10859
|
+
const checkboxes = this._checkboxes;
|
|
10860
|
+
checkboxes.forEach(checkbox => {
|
|
10861
|
+
checkbox.checked = this.value.includes(checkbox.value);
|
|
10862
|
+
checkbox.hasFeedback = this.hasFeedback ? "style" : null;
|
|
10863
|
+
if (checkbox.required) {
|
|
10864
|
+
console.error("Checkboxes in a group cannot have required or hasFeedback prop set to true");
|
|
10865
|
+
checkbox.remove();
|
|
10866
|
+
}
|
|
10867
|
+
});
|
|
10868
|
+
this._disabledChildCheckboxes();
|
|
10807
10869
|
}
|
|
10808
|
-
|
|
10809
|
-
this.
|
|
10870
|
+
_disabledChildCheckboxes() {
|
|
10871
|
+
if (this.disabled) {
|
|
10872
|
+
const checkboxes = this._checkboxes;
|
|
10873
|
+
checkboxes.forEach(checkbox => (checkbox.disabled = this.disabled));
|
|
10874
|
+
}
|
|
10875
|
+
}
|
|
10876
|
+
_handleValueChange() {
|
|
10877
|
+
const checkboxes = this._checkboxes;
|
|
10878
|
+
checkboxes.forEach(checkbox => {
|
|
10879
|
+
checkbox.checked = this.value.includes(checkbox.value);
|
|
10880
|
+
});
|
|
10881
|
+
this._updateInputValue();
|
|
10882
|
+
this._updateInvalid();
|
|
10883
|
+
}
|
|
10884
|
+
_handleIsTouched() {
|
|
10885
|
+
if (this._isTouched) {
|
|
10886
|
+
this.invalid = !this.input.checkValidity();
|
|
10887
|
+
this._updateInvalid();
|
|
10888
|
+
}
|
|
10889
|
+
}
|
|
10890
|
+
_updateInvalid() {
|
|
10891
|
+
const checkboxes = this._checkboxes;
|
|
10892
|
+
checkboxes.forEach(ch => (ch.invalid = this.invalid));
|
|
10893
|
+
}
|
|
10894
|
+
/**
|
|
10895
|
+
* Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
|
|
10896
|
+
* Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput
|
|
10897
|
+
*/
|
|
10898
|
+
reportValidity() {
|
|
10899
|
+
return this._mixinReportValidity();
|
|
10900
|
+
}
|
|
10901
|
+
/**
|
|
10902
|
+
* Checks for validity without any native error popup message
|
|
10903
|
+
*/
|
|
10904
|
+
checkValidity() {
|
|
10905
|
+
return this._mixinCheckValidity();
|
|
10906
|
+
}
|
|
10907
|
+
/**
|
|
10908
|
+
* Returns the ValidityState object
|
|
10909
|
+
*/
|
|
10910
|
+
get validity() {
|
|
10911
|
+
return this._mixinGetValidity();
|
|
10912
|
+
}
|
|
10913
|
+
/**
|
|
10914
|
+
* Returns the validation message based on the ValidityState
|
|
10915
|
+
*/
|
|
10916
|
+
get validationMessage() {
|
|
10917
|
+
return this._mixinGetValidationMessage();
|
|
10918
|
+
}
|
|
10919
|
+
/**
|
|
10920
|
+
* radio requries a custom _mixinResetFormControl as the update of input value
|
|
10921
|
+
* requires to fire a reset event manually
|
|
10922
|
+
* */
|
|
10923
|
+
_mixinResetFormControl() {
|
|
10924
|
+
this.value = this.input.value = this.defaultValue;
|
|
10925
|
+
this._updateInputValue("reset");
|
|
10926
|
+
this._mixinResetValidity(this.input);
|
|
10927
|
+
}
|
|
10928
|
+
/**
|
|
10929
|
+
* when input value is set programatically, need to manually dispatch a change event
|
|
10930
|
+
* In order to prevent race conditions and ensure sequence of events, set input's value here instead of binding to value prop of input
|
|
10931
|
+
*/
|
|
10932
|
+
_updateInputValue(eventName = "change") {
|
|
10933
|
+
this.input.value = this.value;
|
|
10934
|
+
this.input.dispatchEvent(new InputEvent(eventName));
|
|
10935
|
+
}
|
|
10936
|
+
firstUpdated(changedProperties) {
|
|
10937
|
+
super.firstUpdated(changedProperties);
|
|
10938
|
+
if (this.value) {
|
|
10939
|
+
this._updateInputValue();
|
|
10940
|
+
}
|
|
10810
10941
|
}
|
|
10811
10942
|
render() {
|
|
10812
10943
|
return html$1 `
|
|
@@ -10816,9 +10947,21 @@
|
|
|
10816
10947
|
${this._renderHintText()}
|
|
10817
10948
|
</div>
|
|
10818
10949
|
<div class="checkbox-container">
|
|
10819
|
-
<slot></slot>
|
|
10950
|
+
<slot @slotchange=${this._sanitizeSlot}></slot>
|
|
10820
10951
|
</div>
|
|
10821
|
-
|
|
10952
|
+
<input
|
|
10953
|
+
type="text"
|
|
10954
|
+
class="checkbox-group-validation-input ${classMap({
|
|
10955
|
+
"is-invalid": this.hasFeedback && this.invalid
|
|
10956
|
+
})}"
|
|
10957
|
+
?required=${this.required}
|
|
10958
|
+
tabindex="-1"
|
|
10959
|
+
@change=${(e) => {
|
|
10960
|
+
super._mixinHandleChange(e);
|
|
10961
|
+
}}
|
|
10962
|
+
.value=${live(this.value)}
|
|
10963
|
+
/>
|
|
10964
|
+
${this.invalid && this.hasFeedback
|
|
10822
10965
|
? html$1 `
|
|
10823
10966
|
<div class="invalid-feedback-container">
|
|
10824
10967
|
<slot name="invalidIcon">
|
|
@@ -10844,11 +10987,8 @@
|
|
|
10844
10987
|
queryAssignedElements({ flatten: true })
|
|
10845
10988
|
], SgdsCheckboxGroup.prototype, "checkboxes", void 0);
|
|
10846
10989
|
__decorate([
|
|
10847
|
-
|
|
10848
|
-
], SgdsCheckboxGroup.prototype, "
|
|
10849
|
-
__decorate([
|
|
10850
|
-
state()
|
|
10851
|
-
], SgdsCheckboxGroup.prototype, "validationMessage", void 0);
|
|
10990
|
+
queryAsync("slot")
|
|
10991
|
+
], SgdsCheckboxGroup.prototype, "checkboxesAsync", void 0);
|
|
10852
10992
|
__decorate([
|
|
10853
10993
|
property({ reflect: true })
|
|
10854
10994
|
], SgdsCheckboxGroup.prototype, "label", void 0);
|
|
@@ -10861,6 +11001,30 @@
|
|
|
10861
11001
|
__decorate([
|
|
10862
11002
|
property({ reflect: true })
|
|
10863
11003
|
], SgdsCheckboxGroup.prototype, "hintText", void 0);
|
|
11004
|
+
__decorate([
|
|
11005
|
+
property({ type: Boolean, reflect: true })
|
|
11006
|
+
], SgdsCheckboxGroup.prototype, "required", void 0);
|
|
11007
|
+
__decorate([
|
|
11008
|
+
property({ type: String, reflect: true })
|
|
11009
|
+
], SgdsCheckboxGroup.prototype, "value", void 0);
|
|
11010
|
+
__decorate([
|
|
11011
|
+
state()
|
|
11012
|
+
], SgdsCheckboxGroup.prototype, "_isTouched", void 0);
|
|
11013
|
+
__decorate([
|
|
11014
|
+
state()
|
|
11015
|
+
], SgdsCheckboxGroup.prototype, "defaultValue", void 0);
|
|
11016
|
+
__decorate([
|
|
11017
|
+
queryAssignedElements()
|
|
11018
|
+
], SgdsCheckboxGroup.prototype, "_checkboxes", void 0);
|
|
11019
|
+
__decorate([
|
|
11020
|
+
watch("value", { waitUntilFirstUpdate: true })
|
|
11021
|
+
], SgdsCheckboxGroup.prototype, "_handleValueChange", null);
|
|
11022
|
+
__decorate([
|
|
11023
|
+
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
11024
|
+
], SgdsCheckboxGroup.prototype, "_handleIsTouched", null);
|
|
11025
|
+
__decorate([
|
|
11026
|
+
watch("invalid", { waitUntilFirstUpdate: true })
|
|
11027
|
+
], SgdsCheckboxGroup.prototype, "_updateInvalid", null);
|
|
10864
11028
|
|
|
10865
11029
|
var css_248z$F = css`:host([active]) .dropdown-item{background-color:var(--sgds-primary-surface-translucent)}.dropdown-item{background-color:var(--sgds-bg-transparent);clear:both;color:var(--sgds-color-default);cursor:pointer;height:100%;padding:var(--sgds-padding-sm) var(--sgds-padding-lg);text-align:inherit;white-space:nowrap}.dropdown-item .normal-item-content{align-items:center;display:flex;justify-content:space-between}:host([active]) .dropdown-item .normal-item-content{color:var(--sgds-primary-bg-default)}:host([active]) .dropdown-item .normal-item-content sgds-icon{fill:var(--sgds-primary-bg-default);color:var(--sgds-primary-bg-default)}.dropdown-item:hover{background:var(--sgds-bg-translucent-subtle)}.dropdown-item:focus,.dropdown-item:focus-visible{background:var(--sgds-bg-translucent-subtle);box-shadow:inset var(--sgds-form-box-shadow-focus);outline:0}`;
|
|
10866
11030
|
|