@govtechsg/sgds-web-component 1.1.0-rc.0 → 1.1.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/base/dropdown-element.cjs.js +0 -1
- package/base/dropdown-element.cjs.js.map +1 -1
- package/base/dropdown-element.d.ts +1 -2
- package/base/dropdown-element.js +0 -1
- package/base/dropdown-element.js.map +1 -1
- package/components/ActionCard/index.umd.js +3 -1
- package/components/ActionCard/index.umd.js.map +1 -1
- package/components/Button/index.umd.js +3 -1
- package/components/Button/index.umd.js.map +1 -1
- package/components/Checkbox/index.umd.js +3 -1
- package/components/Checkbox/index.umd.js.map +1 -1
- package/components/ComboBox/index.umd.js +43 -26
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/Datepicker/datepicker-calendar.cjs.js +29 -14
- package/components/Datepicker/datepicker-calendar.cjs.js.map +1 -1
- package/components/Datepicker/datepicker-calendar.js +29 -14
- package/components/Datepicker/datepicker-calendar.js.map +1 -1
- package/components/Datepicker/datepicker-header.cjs.js +35 -17
- package/components/Datepicker/datepicker-header.cjs.js.map +1 -1
- package/components/Datepicker/datepicker-header.d.ts +2 -0
- package/components/Datepicker/datepicker-header.js +35 -18
- package/components/Datepicker/datepicker-header.js.map +1 -1
- package/components/Datepicker/datepicker-input.cjs.js +150 -0
- package/components/Datepicker/datepicker-input.cjs.js.map +1 -0
- package/components/Datepicker/datepicker-input.d.ts +24 -0
- package/components/Datepicker/datepicker-input.js +141 -0
- package/components/Datepicker/datepicker-input.js.map +1 -0
- package/components/Datepicker/index.js.map +1 -1
- package/components/Datepicker/index.umd.js +16655 -7545
- package/components/Datepicker/index.umd.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.cjs.js +207 -150
- package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.cjs2.js +1 -1
- package/components/Datepicker/sgds-datepicker.d.ts +38 -13
- package/components/Datepicker/sgds-datepicker.js +209 -152
- package/components/Datepicker/sgds-datepicker.js.map +1 -1
- package/components/Datepicker/sgds-datepicker2.js +1 -1
- package/components/Dropdown/index.umd.js +8 -3
- package/components/Dropdown/index.umd.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.cjs.js +5 -1
- package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.d.ts +4 -3
- package/components/Dropdown/sgds-dropdown.js +5 -1
- package/components/Dropdown/sgds-dropdown.js.map +1 -1
- package/components/FileUpload/index.umd.js +3 -1
- package/components/FileUpload/index.umd.js.map +1 -1
- package/components/Input/index.umd.js +43 -25
- package/components/Input/index.umd.js.map +1 -1
- package/components/Input/sgds-input.cjs.js +40 -24
- package/components/Input/sgds-input.cjs.js.map +1 -1
- package/components/Input/sgds-input.d.ts +15 -9
- package/components/Input/sgds-input.js +40 -24
- package/components/Input/sgds-input.js.map +1 -1
- package/components/Mainnav/index.umd.js +0 -1
- package/components/Mainnav/index.umd.js.map +1 -1
- package/components/QuantityToggle/index.umd.js +3 -1
- package/components/QuantityToggle/index.umd.js.map +1 -1
- package/components/Radio/index.umd.js +3 -1
- package/components/Radio/index.umd.js.map +1 -1
- package/components/Textarea/index.umd.js +3 -1
- package/components/Textarea/index.umd.js.map +1 -1
- package/components/index.umd.js +9905 -791
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +9905 -791
- package/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/react/datepicker/index.cjs.js +1 -2
- package/react/datepicker/index.cjs.js.map +1 -1
- package/react/datepicker/index.js +1 -2
- package/react/datepicker/index.js.map +1 -1
- package/utils/form.cjs.js +3 -1
- package/utils/form.cjs.js.map +1 -1
- package/utils/form.js +3 -1
- package/utils/form.js.map +1 -1
- package/utils/time.cjs.js +18 -4
- package/utils/time.cjs.js.map +1 -1
- package/utils/time.d.ts +17 -0
- package/utils/time.js +18 -4
- package/utils/time.js.map +1 -1
|
@@ -3467,7 +3467,9 @@
|
|
|
3467
3467
|
class FormSubmitController {
|
|
3468
3468
|
constructor(host, options) {
|
|
3469
3469
|
(this.host = host).addController(this);
|
|
3470
|
-
this.options = Object.assign({ form: (input) =>
|
|
3470
|
+
this.options = Object.assign({ form: (input) => {
|
|
3471
|
+
return input.closest("form");
|
|
3472
|
+
}, name: (input) => input.name, value: (input) => input.value, defaultValue: (input) => input.defaultValue, disabled: (input) => input.disabled, reportValidity: (input) => {
|
|
3471
3473
|
return typeof input.reportValidity === "function" ? input.reportValidity() : true;
|
|
3472
3474
|
}, setValue: (input, value) => {
|
|
3473
3475
|
input.value = value;
|
|
@@ -3689,20 +3691,23 @@
|
|
|
3689
3691
|
reportValidity() {
|
|
3690
3692
|
return this.input.reportValidity();
|
|
3691
3693
|
}
|
|
3692
|
-
|
|
3693
|
-
this.
|
|
3694
|
+
setCustomValidity(err) {
|
|
3695
|
+
return this.input.setCustomValidity(err);
|
|
3694
3696
|
}
|
|
3695
|
-
|
|
3697
|
+
setInvalid(bool) {
|
|
3698
|
+
this.invalid = bool;
|
|
3699
|
+
}
|
|
3700
|
+
_handleChange(event) {
|
|
3696
3701
|
this.value = this.input.value;
|
|
3697
3702
|
this.emit(event);
|
|
3698
3703
|
}
|
|
3699
|
-
|
|
3704
|
+
_handleFocus() {
|
|
3700
3705
|
this.emit("sgds-focus");
|
|
3701
3706
|
}
|
|
3702
|
-
|
|
3707
|
+
_handleBlur() {
|
|
3703
3708
|
this.emit("sgds-blur");
|
|
3704
3709
|
}
|
|
3705
|
-
|
|
3710
|
+
_handleKeyDown(event) {
|
|
3706
3711
|
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
3707
3712
|
// Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before
|
|
3708
3713
|
// submitting to allow users to cancel the keydown event if they need to
|
|
@@ -3715,12 +3720,12 @@
|
|
|
3715
3720
|
});
|
|
3716
3721
|
}
|
|
3717
3722
|
}
|
|
3718
|
-
|
|
3723
|
+
_handleDisabledChange() {
|
|
3719
3724
|
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
3720
3725
|
this.input.disabled = this.disabled;
|
|
3721
3726
|
this.invalid = !this.input.checkValidity();
|
|
3722
3727
|
}
|
|
3723
|
-
|
|
3728
|
+
_handleValueChange() {
|
|
3724
3729
|
this.invalid = !this.input.checkValidity();
|
|
3725
3730
|
this.valid = this.input.checkValidity();
|
|
3726
3731
|
// remove validation for input that is not required, is already dirty and has empty value
|
|
@@ -3728,9 +3733,8 @@
|
|
|
3728
3733
|
this.valid = false;
|
|
3729
3734
|
}
|
|
3730
3735
|
}
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
<input
|
|
3736
|
+
_renderInput() {
|
|
3737
|
+
return html `<input
|
|
3734
3738
|
class=${classMap({
|
|
3735
3739
|
"form-control": true,
|
|
3736
3740
|
"is-invalid": this.hasFeedback && this.invalid,
|
|
@@ -3750,17 +3754,34 @@
|
|
|
3750
3754
|
.value=${live(this.value)}
|
|
3751
3755
|
minlength=${ifDefined(this.minlength)}
|
|
3752
3756
|
maxlength=${ifDefined(this.maxlength)}
|
|
3753
|
-
@input=${() => this.
|
|
3754
|
-
@change=${() => this.
|
|
3755
|
-
@keydown=${this.
|
|
3756
|
-
@invalid=${this.
|
|
3757
|
-
@focus=${this.
|
|
3758
|
-
@blur=${this.
|
|
3757
|
+
@input=${() => this._handleChange("sgds-input")}
|
|
3758
|
+
@change=${() => this._handleChange("sgds-change")}
|
|
3759
|
+
@keydown=${this._handleKeyDown}
|
|
3760
|
+
@invalid=${() => this.setInvalid(true)}
|
|
3761
|
+
@focus=${this._handleFocus}
|
|
3762
|
+
@blur=${this._handleBlur}
|
|
3759
3763
|
/>
|
|
3760
3764
|
${this.hasFeedback
|
|
3761
3765
|
? html `<div id="${this.inputId}-invalid" class="invalid-feedback">${this.invalidFeedback}</div>`
|
|
3762
|
-
: ""}
|
|
3766
|
+
: ""} `;
|
|
3767
|
+
}
|
|
3768
|
+
_renderFeedback() {
|
|
3769
|
+
return this.hasFeedback
|
|
3770
|
+
? html `<div id="${this.inputId}-invalid" class="invalid-feedback">${this.invalidFeedback}</div>`
|
|
3771
|
+
: "";
|
|
3772
|
+
}
|
|
3773
|
+
_renderLabel() {
|
|
3774
|
+
const labelTemplate = html ` <label for=${this.inputId} class="form-label">${this.label}</label> `;
|
|
3775
|
+
return this.label && labelTemplate;
|
|
3776
|
+
}
|
|
3777
|
+
_renderHintText() {
|
|
3778
|
+
const hintTextTemplate = html `
|
|
3779
|
+
<small id="${this.inputId}Help" class="text-muted form-text">${this.hintText}</small>
|
|
3763
3780
|
`;
|
|
3781
|
+
return this.hintText && hintTextTemplate;
|
|
3782
|
+
}
|
|
3783
|
+
render() {
|
|
3784
|
+
const input = html `${this._renderInput()}`;
|
|
3764
3785
|
// if iconName is defined
|
|
3765
3786
|
const inputWithIcon = html `
|
|
3766
3787
|
<div class="sgds form-control-group ${this.inputClasses}">
|
|
@@ -3769,12 +3790,9 @@
|
|
|
3769
3790
|
</div>
|
|
3770
3791
|
`;
|
|
3771
3792
|
// if hintText is defined
|
|
3772
|
-
const withHintText = html ` <small id="${this.inputId}Help" class="text-muted form-text">${this.hintText}</small> `;
|
|
3773
|
-
// if label is defined
|
|
3774
|
-
const withLabel = html ` <label for=${this.inputId} class="form-label">${this.label}</label> `;
|
|
3775
3793
|
return html `
|
|
3776
3794
|
<div class="d-flex flex-column w-100">
|
|
3777
|
-
${html `${this.
|
|
3795
|
+
${html `${this._renderLabel()} ${this._renderHintText()} ${this.icon ? inputWithIcon : input} `}
|
|
3778
3796
|
</div>
|
|
3779
3797
|
`;
|
|
3780
3798
|
}
|
|
@@ -3845,10 +3863,10 @@
|
|
|
3845
3863
|
], SgdsInput.prototype, "valid", void 0);
|
|
3846
3864
|
__decorate([
|
|
3847
3865
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
3848
|
-
], SgdsInput.prototype, "
|
|
3866
|
+
], SgdsInput.prototype, "_handleDisabledChange", null);
|
|
3849
3867
|
__decorate([
|
|
3850
3868
|
watch("value", { waitUntilFirstUpdate: true })
|
|
3851
|
-
], SgdsInput.prototype, "
|
|
3869
|
+
], SgdsInput.prototype, "_handleValueChange", null);
|
|
3852
3870
|
|
|
3853
3871
|
customElements.define("sgds-input", SgdsInput);
|
|
3854
3872
|
|