@govtechsg/sgds-web-component 3.0.6 → 3.1.0-rc.1
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 +196 -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 +162 -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 +196 -31
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +196 -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 +161 -24
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.js +162 -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/index.umd.js
CHANGED
|
@@ -10608,7 +10608,7 @@
|
|
|
10608
10608
|
property({ type: Boolean, reflect: true })
|
|
10609
10609
|
], FormControlElement.prototype, "invalid", void 0);
|
|
10610
10610
|
|
|
10611
|
-
var css_248z$I = 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%}`;
|
|
10611
|
+
var css_248z$I = 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%}`;
|
|
10612
10612
|
|
|
10613
10613
|
/**
|
|
10614
10614
|
* @summary Checkbox component is used when you require users to select multiple items from a list.
|
|
@@ -10625,14 +10625,14 @@
|
|
|
10625
10625
|
super(...arguments);
|
|
10626
10626
|
/** Draws the checkbox in a checked state. */
|
|
10627
10627
|
this.checked = false;
|
|
10628
|
-
/** Allows invalidFeedback, invalid and valid styles to be visible with the input */
|
|
10629
|
-
this.hasFeedback = false;
|
|
10630
10628
|
/** 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. */
|
|
10631
10629
|
this.defaultChecked = false;
|
|
10632
10630
|
/** Marks the checkbox input as indeterminate , with indeterminate logo */
|
|
10633
10631
|
this.indeterminate = false;
|
|
10634
10632
|
/** Makes the checkbox a required field. */
|
|
10635
10633
|
this.required = false;
|
|
10634
|
+
/**Feedback text for error state when validated */
|
|
10635
|
+
this.invalidFeedback = "";
|
|
10636
10636
|
this._isTouched = false;
|
|
10637
10637
|
}
|
|
10638
10638
|
_handleInvalidChange() {
|
|
@@ -10657,7 +10657,6 @@
|
|
|
10657
10657
|
this.indeterminate = !this.indeterminate;
|
|
10658
10658
|
}
|
|
10659
10659
|
this.checked = !this.checked;
|
|
10660
|
-
this.value = this.input.value;
|
|
10661
10660
|
super._mixinHandleChange(e);
|
|
10662
10661
|
this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
|
|
10663
10662
|
}
|
|
@@ -10688,6 +10687,11 @@
|
|
|
10688
10687
|
this.invalid = !this.input.checkValidity();
|
|
10689
10688
|
}
|
|
10690
10689
|
}
|
|
10690
|
+
_handleChecked() {
|
|
10691
|
+
this.checked
|
|
10692
|
+
? this.emit("sgds-check", { detail: { value: this.value } })
|
|
10693
|
+
: this.emit("sgds-uncheck", { detail: { value: this.value } });
|
|
10694
|
+
}
|
|
10691
10695
|
_mixinResetFormControl() {
|
|
10692
10696
|
this._isTouched = false;
|
|
10693
10697
|
this.checked = this.input.checked = this.defaultChecked;
|
|
@@ -10719,14 +10723,20 @@
|
|
|
10719
10723
|
get validationMessage() {
|
|
10720
10724
|
return this._mixinGetValidationMessage();
|
|
10721
10725
|
}
|
|
10726
|
+
firstUpdated(_changedProperties) {
|
|
10727
|
+
super.firstUpdated(_changedProperties);
|
|
10728
|
+
this.checked && this.emit("sgds-check", { detail: { value: this.value } });
|
|
10729
|
+
}
|
|
10722
10730
|
render() {
|
|
10731
|
+
const wantFeedbackStyle = this.hasFeedback === "both" || this.hasFeedback === "style";
|
|
10732
|
+
const wantFeedbackText = this.hasFeedback === "both" || this.hasFeedback === "text";
|
|
10723
10733
|
return html$1 `
|
|
10724
10734
|
<div class="form-check">
|
|
10725
10735
|
<div class="form-check-input-container">
|
|
10726
10736
|
<input
|
|
10727
10737
|
class=${classMap({
|
|
10728
10738
|
"form-check-input": true,
|
|
10729
|
-
"is-invalid":
|
|
10739
|
+
"is-invalid": wantFeedbackStyle && this.invalid
|
|
10730
10740
|
})}
|
|
10731
10741
|
type="checkbox"
|
|
10732
10742
|
id=${this._controlId}
|
|
@@ -10748,6 +10758,23 @@
|
|
|
10748
10758
|
</div>
|
|
10749
10759
|
<label for="${this._controlId}" class="form-check-label" id="${this._labelId}"><slot></slot></label>
|
|
10750
10760
|
</div>
|
|
10761
|
+
${wantFeedbackText && this.invalid
|
|
10762
|
+
? html$1 `
|
|
10763
|
+
<div class="invalid-feedback-container">
|
|
10764
|
+
<slot name="invalidIcon">
|
|
10765
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
10766
|
+
<path
|
|
10767
|
+
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"
|
|
10768
|
+
fill="currentColor"
|
|
10769
|
+
/>
|
|
10770
|
+
</svg>
|
|
10771
|
+
</slot>
|
|
10772
|
+
<div id="checkbox-feedback" tabindex="0" class="invalid-feedback">
|
|
10773
|
+
${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}
|
|
10774
|
+
</div>
|
|
10775
|
+
</div>
|
|
10776
|
+
`
|
|
10777
|
+
: nothing}
|
|
10751
10778
|
`;
|
|
10752
10779
|
}
|
|
10753
10780
|
}
|
|
@@ -10759,7 +10786,7 @@
|
|
|
10759
10786
|
property({ type: Boolean, reflect: true })
|
|
10760
10787
|
], SgdsCheckbox.prototype, "checked", void 0);
|
|
10761
10788
|
__decorate([
|
|
10762
|
-
property({ type:
|
|
10789
|
+
property({ type: String, reflect: true })
|
|
10763
10790
|
], SgdsCheckbox.prototype, "hasFeedback", void 0);
|
|
10764
10791
|
__decorate([
|
|
10765
10792
|
defaultValue("checked")
|
|
@@ -10770,6 +10797,9 @@
|
|
|
10770
10797
|
__decorate([
|
|
10771
10798
|
property({ type: Boolean, reflect: true })
|
|
10772
10799
|
], SgdsCheckbox.prototype, "required", void 0);
|
|
10800
|
+
__decorate([
|
|
10801
|
+
property({ type: String, reflect: true })
|
|
10802
|
+
], SgdsCheckbox.prototype, "invalidFeedback", void 0);
|
|
10773
10803
|
__decorate([
|
|
10774
10804
|
state()
|
|
10775
10805
|
], SgdsCheckbox.prototype, "_isTouched", void 0);
|
|
@@ -10782,6 +10812,9 @@
|
|
|
10782
10812
|
__decorate([
|
|
10783
10813
|
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
10784
10814
|
], SgdsCheckbox.prototype, "_handleIsTouched", null);
|
|
10815
|
+
__decorate([
|
|
10816
|
+
watch("checked", { waitUntilFirstUpdate: true })
|
|
10817
|
+
], SgdsCheckbox.prototype, "_handleChecked", null);
|
|
10785
10818
|
|
|
10786
10819
|
var css_248z$H = 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}`;
|
|
10787
10820
|
|
|
@@ -11344,7 +11377,7 @@
|
|
|
11344
11377
|
|
|
11345
11378
|
register("sgds-combo-box", SgdsComboBox);
|
|
11346
11379
|
|
|
11347
|
-
var css_248z$F = 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)}`;
|
|
11380
|
+
var css_248z$F = 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}`;
|
|
11348
11381
|
|
|
11349
11382
|
/**
|
|
11350
11383
|
* @summary CheckboxGroup is the container that group multiple checkboxes under a single question field.
|
|
@@ -11354,10 +11387,9 @@
|
|
|
11354
11387
|
* @slot invalidIcon - The slot for invalid icon
|
|
11355
11388
|
*
|
|
11356
11389
|
*/
|
|
11357
|
-
class SgdsCheckboxGroup extends
|
|
11390
|
+
class SgdsCheckboxGroup extends SgdsFormValidatorMixin(FormControlElement) {
|
|
11358
11391
|
constructor() {
|
|
11359
|
-
super();
|
|
11360
|
-
this.hasInvalidCheckbox = false;
|
|
11392
|
+
super(...arguments);
|
|
11361
11393
|
/** The checkbox group's label */
|
|
11362
11394
|
this.label = "";
|
|
11363
11395
|
/**Feedback text for error state when validated */
|
|
@@ -11366,27 +11398,127 @@
|
|
|
11366
11398
|
this.hasFeedback = false;
|
|
11367
11399
|
/** The checkbox group's hint text */
|
|
11368
11400
|
this.hintText = "";
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
this.
|
|
11401
|
+
/** Makes the checkbox group a required field. Only available for when multiselect is true */
|
|
11402
|
+
this.required = false;
|
|
11403
|
+
/** Consolidates the values of its child checked checkboxes into a single string with semi-colon delimiter. Only available when required is true */
|
|
11404
|
+
this.value = "";
|
|
11405
|
+
this._isTouched = false;
|
|
11406
|
+
/**@internal */
|
|
11407
|
+
this.defaultValue = "";
|
|
11376
11408
|
}
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11409
|
+
connectedCallback() {
|
|
11410
|
+
super.connectedCallback();
|
|
11411
|
+
this.defaultValue = this.value;
|
|
11412
|
+
this.addEventListener("sgds-check", (e) => {
|
|
11413
|
+
const { value } = e.detail;
|
|
11414
|
+
!this.value.includes(value) && this._addValue(value);
|
|
11415
|
+
});
|
|
11416
|
+
this.addEventListener("sgds-uncheck", (e) => {
|
|
11417
|
+
const { value } = e.detail;
|
|
11418
|
+
this._removeValue(value);
|
|
11419
|
+
});
|
|
11420
|
+
this.addEventListener("sgds-blur", () => {
|
|
11421
|
+
this._isTouched = true;
|
|
11422
|
+
});
|
|
11380
11423
|
}
|
|
11381
11424
|
_renderHintText() {
|
|
11382
11425
|
const hintTextTemplate = html$1 ` <div class="form-text">${this.hintText}</div> `;
|
|
11383
11426
|
return this.hintText && hintTextTemplate;
|
|
11384
11427
|
}
|
|
11385
|
-
|
|
11386
|
-
this.
|
|
11428
|
+
_addValue(newValue) {
|
|
11429
|
+
const valueArray = this.value ? this.value.split(";") : [];
|
|
11430
|
+
valueArray.push(newValue);
|
|
11431
|
+
this.value = valueArray.join(";");
|
|
11432
|
+
}
|
|
11433
|
+
_removeValue(oldValue) {
|
|
11434
|
+
const valueArray = this.value ? this.value.split(";") : [];
|
|
11435
|
+
const newValueArray = valueArray.filter(v => v !== oldValue);
|
|
11436
|
+
this.value = newValueArray.join(";");
|
|
11437
|
+
}
|
|
11438
|
+
_sanitizeSlot() {
|
|
11439
|
+
const checkboxes = this._checkboxes;
|
|
11440
|
+
checkboxes.forEach(checkbox => {
|
|
11441
|
+
checkbox.checked = this.value.includes(checkbox.value);
|
|
11442
|
+
checkbox.hasFeedback = this.hasFeedback ? "style" : null;
|
|
11443
|
+
if (checkbox.required) {
|
|
11444
|
+
console.error("Checkboxes in a group cannot have required or hasFeedback prop set to true");
|
|
11445
|
+
checkbox.remove();
|
|
11446
|
+
}
|
|
11447
|
+
});
|
|
11448
|
+
this._disabledChildCheckboxes();
|
|
11387
11449
|
}
|
|
11388
|
-
|
|
11389
|
-
this.
|
|
11450
|
+
_disabledChildCheckboxes() {
|
|
11451
|
+
if (this.disabled) {
|
|
11452
|
+
const checkboxes = this._checkboxes;
|
|
11453
|
+
checkboxes.forEach(checkbox => (checkbox.disabled = this.disabled));
|
|
11454
|
+
}
|
|
11455
|
+
}
|
|
11456
|
+
_handleValueChange() {
|
|
11457
|
+
this.emit("sgds-change");
|
|
11458
|
+
const checkboxes = this._checkboxes;
|
|
11459
|
+
checkboxes.forEach(checkbox => {
|
|
11460
|
+
checkbox.checked = this.value.includes(checkbox.value);
|
|
11461
|
+
});
|
|
11462
|
+
this._updateInputValue();
|
|
11463
|
+
this._updateInvalid();
|
|
11464
|
+
}
|
|
11465
|
+
_handleIsTouched() {
|
|
11466
|
+
if (this._isTouched) {
|
|
11467
|
+
this.invalid = !this.input.checkValidity();
|
|
11468
|
+
this._updateInvalid();
|
|
11469
|
+
}
|
|
11470
|
+
}
|
|
11471
|
+
_updateInvalid() {
|
|
11472
|
+
const checkboxes = this._checkboxes;
|
|
11473
|
+
checkboxes.forEach(ch => (ch.invalid = this.invalid));
|
|
11474
|
+
}
|
|
11475
|
+
/**
|
|
11476
|
+
* Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
|
|
11477
|
+
* 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
|
|
11478
|
+
*/
|
|
11479
|
+
reportValidity() {
|
|
11480
|
+
return this._mixinReportValidity();
|
|
11481
|
+
}
|
|
11482
|
+
/**
|
|
11483
|
+
* Checks for validity without any native error popup message
|
|
11484
|
+
*/
|
|
11485
|
+
checkValidity() {
|
|
11486
|
+
return this._mixinCheckValidity();
|
|
11487
|
+
}
|
|
11488
|
+
/**
|
|
11489
|
+
* Returns the ValidityState object
|
|
11490
|
+
*/
|
|
11491
|
+
get validity() {
|
|
11492
|
+
return this._mixinGetValidity();
|
|
11493
|
+
}
|
|
11494
|
+
/**
|
|
11495
|
+
* Returns the validation message based on the ValidityState
|
|
11496
|
+
*/
|
|
11497
|
+
get validationMessage() {
|
|
11498
|
+
return this._mixinGetValidationMessage();
|
|
11499
|
+
}
|
|
11500
|
+
/**
|
|
11501
|
+
* radio requries a custom _mixinResetFormControl as the update of input value
|
|
11502
|
+
* requires to fire a reset event manually
|
|
11503
|
+
* */
|
|
11504
|
+
_mixinResetFormControl() {
|
|
11505
|
+
this.value = this.input.value = this.defaultValue;
|
|
11506
|
+
this._updateInputValue("reset");
|
|
11507
|
+
this._mixinResetValidity(this.input);
|
|
11508
|
+
}
|
|
11509
|
+
/**
|
|
11510
|
+
* when input value is set programatically, need to manually dispatch a change event
|
|
11511
|
+
* In order to prevent race conditions and ensure sequence of events, set input's value here instead of binding to value prop of input
|
|
11512
|
+
*/
|
|
11513
|
+
_updateInputValue(eventName = "change") {
|
|
11514
|
+
this.input.value = this.value;
|
|
11515
|
+
this.input.dispatchEvent(new InputEvent(eventName));
|
|
11516
|
+
}
|
|
11517
|
+
firstUpdated(changedProperties) {
|
|
11518
|
+
super.firstUpdated(changedProperties);
|
|
11519
|
+
if (this.value) {
|
|
11520
|
+
this._updateInputValue();
|
|
11521
|
+
}
|
|
11390
11522
|
}
|
|
11391
11523
|
render() {
|
|
11392
11524
|
return html$1 `
|
|
@@ -11396,9 +11528,21 @@
|
|
|
11396
11528
|
${this._renderHintText()}
|
|
11397
11529
|
</div>
|
|
11398
11530
|
<div class="checkbox-container">
|
|
11399
|
-
<slot></slot>
|
|
11531
|
+
<slot @slotchange=${this._sanitizeSlot}></slot>
|
|
11400
11532
|
</div>
|
|
11401
|
-
|
|
11533
|
+
<input
|
|
11534
|
+
type="text"
|
|
11535
|
+
class="checkbox-group-validation-input ${classMap({
|
|
11536
|
+
"is-invalid": this.hasFeedback && this.invalid
|
|
11537
|
+
})}"
|
|
11538
|
+
?required=${this.required}
|
|
11539
|
+
tabindex="-1"
|
|
11540
|
+
@change=${(e) => {
|
|
11541
|
+
super._mixinHandleChange(e);
|
|
11542
|
+
}}
|
|
11543
|
+
.value=${live(this.value)}
|
|
11544
|
+
/>
|
|
11545
|
+
${this.invalid && this.hasFeedback
|
|
11402
11546
|
? html$1 `
|
|
11403
11547
|
<div class="invalid-feedback-container">
|
|
11404
11548
|
<slot name="invalidIcon">
|
|
@@ -11424,11 +11568,8 @@
|
|
|
11424
11568
|
queryAssignedElements({ flatten: true })
|
|
11425
11569
|
], SgdsCheckboxGroup.prototype, "checkboxes", void 0);
|
|
11426
11570
|
__decorate([
|
|
11427
|
-
|
|
11428
|
-
], SgdsCheckboxGroup.prototype, "
|
|
11429
|
-
__decorate([
|
|
11430
|
-
state()
|
|
11431
|
-
], SgdsCheckboxGroup.prototype, "validationMessage", void 0);
|
|
11571
|
+
queryAsync("slot")
|
|
11572
|
+
], SgdsCheckboxGroup.prototype, "checkboxesAsync", void 0);
|
|
11432
11573
|
__decorate([
|
|
11433
11574
|
property({ reflect: true })
|
|
11434
11575
|
], SgdsCheckboxGroup.prototype, "label", void 0);
|
|
@@ -11441,6 +11582,30 @@
|
|
|
11441
11582
|
__decorate([
|
|
11442
11583
|
property({ reflect: true })
|
|
11443
11584
|
], SgdsCheckboxGroup.prototype, "hintText", void 0);
|
|
11585
|
+
__decorate([
|
|
11586
|
+
property({ type: Boolean, reflect: true })
|
|
11587
|
+
], SgdsCheckboxGroup.prototype, "required", void 0);
|
|
11588
|
+
__decorate([
|
|
11589
|
+
property({ type: String, reflect: true })
|
|
11590
|
+
], SgdsCheckboxGroup.prototype, "value", void 0);
|
|
11591
|
+
__decorate([
|
|
11592
|
+
state()
|
|
11593
|
+
], SgdsCheckboxGroup.prototype, "_isTouched", void 0);
|
|
11594
|
+
__decorate([
|
|
11595
|
+
state()
|
|
11596
|
+
], SgdsCheckboxGroup.prototype, "defaultValue", void 0);
|
|
11597
|
+
__decorate([
|
|
11598
|
+
queryAssignedElements()
|
|
11599
|
+
], SgdsCheckboxGroup.prototype, "_checkboxes", void 0);
|
|
11600
|
+
__decorate([
|
|
11601
|
+
watch("value", { waitUntilFirstUpdate: true })
|
|
11602
|
+
], SgdsCheckboxGroup.prototype, "_handleValueChange", null);
|
|
11603
|
+
__decorate([
|
|
11604
|
+
watch("_isTouched", { waitUntilFirstUpdate: true })
|
|
11605
|
+
], SgdsCheckboxGroup.prototype, "_handleIsTouched", null);
|
|
11606
|
+
__decorate([
|
|
11607
|
+
watch("invalid", { waitUntilFirstUpdate: true })
|
|
11608
|
+
], SgdsCheckboxGroup.prototype, "_updateInvalid", null);
|
|
11444
11609
|
|
|
11445
11610
|
register("sgds-checkbox", SgdsCheckbox);
|
|
11446
11611
|
register("sgds-checkbox-group", SgdsCheckboxGroup);
|