@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
|
@@ -6934,7 +6934,6 @@
|
|
|
6934
6934
|
* @event sgds-after-show - Emitted event when dropdown has been made visible to the user and CSS transitions have completed
|
|
6935
6935
|
* @event sgds-hide - Emitted event when hide instance is called
|
|
6936
6936
|
* @event sgds-after-hide - Emitted event when dropdown has hidden to the user and CSS transitions have completed
|
|
6937
|
-
* @event sgds-select - Emitted event when a slot item is selected
|
|
6938
6937
|
*/
|
|
6939
6938
|
class DropdownElement extends SgdsElement {
|
|
6940
6939
|
constructor() {
|
|
@@ -7446,7 +7445,9 @@
|
|
|
7446
7445
|
class FormSubmitController {
|
|
7447
7446
|
constructor(host, options) {
|
|
7448
7447
|
(this.host = host).addController(this);
|
|
7449
|
-
this.options = Object.assign({ form: (input) =>
|
|
7448
|
+
this.options = Object.assign({ form: (input) => {
|
|
7449
|
+
return input.closest("form");
|
|
7450
|
+
}, name: (input) => input.name, value: (input) => input.value, defaultValue: (input) => input.defaultValue, disabled: (input) => input.disabled, reportValidity: (input) => {
|
|
7450
7451
|
return typeof input.reportValidity === "function" ? input.reportValidity() : true;
|
|
7451
7452
|
}, setValue: (input, value) => {
|
|
7452
7453
|
input.value = value;
|
|
@@ -7664,20 +7665,23 @@
|
|
|
7664
7665
|
reportValidity() {
|
|
7665
7666
|
return this.input.reportValidity();
|
|
7666
7667
|
}
|
|
7667
|
-
|
|
7668
|
-
this.
|
|
7668
|
+
setCustomValidity(err) {
|
|
7669
|
+
return this.input.setCustomValidity(err);
|
|
7670
|
+
}
|
|
7671
|
+
setInvalid(bool) {
|
|
7672
|
+
this.invalid = bool;
|
|
7669
7673
|
}
|
|
7670
|
-
|
|
7674
|
+
_handleChange(event) {
|
|
7671
7675
|
this.value = this.input.value;
|
|
7672
7676
|
this.emit(event);
|
|
7673
7677
|
}
|
|
7674
|
-
|
|
7678
|
+
_handleFocus() {
|
|
7675
7679
|
this.emit("sgds-focus");
|
|
7676
7680
|
}
|
|
7677
|
-
|
|
7681
|
+
_handleBlur() {
|
|
7678
7682
|
this.emit("sgds-blur");
|
|
7679
7683
|
}
|
|
7680
|
-
|
|
7684
|
+
_handleKeyDown(event) {
|
|
7681
7685
|
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
7682
7686
|
// Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before
|
|
7683
7687
|
// submitting to allow users to cancel the keydown event if they need to
|
|
@@ -7690,12 +7694,12 @@
|
|
|
7690
7694
|
});
|
|
7691
7695
|
}
|
|
7692
7696
|
}
|
|
7693
|
-
|
|
7697
|
+
_handleDisabledChange() {
|
|
7694
7698
|
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
|
7695
7699
|
this.input.disabled = this.disabled;
|
|
7696
7700
|
this.invalid = !this.input.checkValidity();
|
|
7697
7701
|
}
|
|
7698
|
-
|
|
7702
|
+
_handleValueChange() {
|
|
7699
7703
|
this.invalid = !this.input.checkValidity();
|
|
7700
7704
|
this.valid = this.input.checkValidity();
|
|
7701
7705
|
// remove validation for input that is not required, is already dirty and has empty value
|
|
@@ -7703,9 +7707,8 @@
|
|
|
7703
7707
|
this.valid = false;
|
|
7704
7708
|
}
|
|
7705
7709
|
}
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
<input
|
|
7710
|
+
_renderInput() {
|
|
7711
|
+
return html `<input
|
|
7709
7712
|
class=${classMap({
|
|
7710
7713
|
"form-control": true,
|
|
7711
7714
|
"is-invalid": this.hasFeedback && this.invalid,
|
|
@@ -7725,17 +7728,34 @@
|
|
|
7725
7728
|
.value=${live(this.value)}
|
|
7726
7729
|
minlength=${ifDefined(this.minlength)}
|
|
7727
7730
|
maxlength=${ifDefined(this.maxlength)}
|
|
7728
|
-
@input=${() => this.
|
|
7729
|
-
@change=${() => this.
|
|
7730
|
-
@keydown=${this.
|
|
7731
|
-
@invalid=${this.
|
|
7732
|
-
@focus=${this.
|
|
7733
|
-
@blur=${this.
|
|
7731
|
+
@input=${() => this._handleChange("sgds-input")}
|
|
7732
|
+
@change=${() => this._handleChange("sgds-change")}
|
|
7733
|
+
@keydown=${this._handleKeyDown}
|
|
7734
|
+
@invalid=${() => this.setInvalid(true)}
|
|
7735
|
+
@focus=${this._handleFocus}
|
|
7736
|
+
@blur=${this._handleBlur}
|
|
7734
7737
|
/>
|
|
7735
7738
|
${this.hasFeedback
|
|
7736
7739
|
? html `<div id="${this.inputId}-invalid" class="invalid-feedback">${this.invalidFeedback}</div>`
|
|
7737
|
-
: ""}
|
|
7740
|
+
: ""} `;
|
|
7741
|
+
}
|
|
7742
|
+
_renderFeedback() {
|
|
7743
|
+
return this.hasFeedback
|
|
7744
|
+
? html `<div id="${this.inputId}-invalid" class="invalid-feedback">${this.invalidFeedback}</div>`
|
|
7745
|
+
: "";
|
|
7746
|
+
}
|
|
7747
|
+
_renderLabel() {
|
|
7748
|
+
const labelTemplate = html ` <label for=${this.inputId} class="form-label">${this.label}</label> `;
|
|
7749
|
+
return this.label && labelTemplate;
|
|
7750
|
+
}
|
|
7751
|
+
_renderHintText() {
|
|
7752
|
+
const hintTextTemplate = html `
|
|
7753
|
+
<small id="${this.inputId}Help" class="text-muted form-text">${this.hintText}</small>
|
|
7738
7754
|
`;
|
|
7755
|
+
return this.hintText && hintTextTemplate;
|
|
7756
|
+
}
|
|
7757
|
+
render() {
|
|
7758
|
+
const input = html `${this._renderInput()}`;
|
|
7739
7759
|
// if iconName is defined
|
|
7740
7760
|
const inputWithIcon = html `
|
|
7741
7761
|
<div class="sgds form-control-group ${this.inputClasses}">
|
|
@@ -7744,12 +7764,9 @@
|
|
|
7744
7764
|
</div>
|
|
7745
7765
|
`;
|
|
7746
7766
|
// if hintText is defined
|
|
7747
|
-
const withHintText = html ` <small id="${this.inputId}Help" class="text-muted form-text">${this.hintText}</small> `;
|
|
7748
|
-
// if label is defined
|
|
7749
|
-
const withLabel = html ` <label for=${this.inputId} class="form-label">${this.label}</label> `;
|
|
7750
7767
|
return html `
|
|
7751
7768
|
<div class="d-flex flex-column w-100">
|
|
7752
|
-
${html `${this.
|
|
7769
|
+
${html `${this._renderLabel()} ${this._renderHintText()} ${this.icon ? inputWithIcon : input} `}
|
|
7753
7770
|
</div>
|
|
7754
7771
|
`;
|
|
7755
7772
|
}
|
|
@@ -7820,10 +7837,10 @@
|
|
|
7820
7837
|
], SgdsInput.prototype, "valid", void 0);
|
|
7821
7838
|
__decorate([
|
|
7822
7839
|
watch("disabled", { waitUntilFirstUpdate: true })
|
|
7823
|
-
], SgdsInput.prototype, "
|
|
7840
|
+
], SgdsInput.prototype, "_handleDisabledChange", null);
|
|
7824
7841
|
__decorate([
|
|
7825
7842
|
watch("value", { waitUntilFirstUpdate: true })
|
|
7826
|
-
], SgdsInput.prototype, "
|
|
7843
|
+
], SgdsInput.prototype, "_handleValueChange", null);
|
|
7827
7844
|
|
|
7828
7845
|
var css_248z = css`.form-control-icon{bottom:0}`;
|
|
7829
7846
|
|