@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.
Files changed (29) hide show
  1. package/components/Checkbox/checkbox-group.js +1 -1
  2. package/components/Checkbox/checkbox.js +1 -1
  3. package/components/Checkbox/index.umd.js +195 -31
  4. package/components/Checkbox/index.umd.js.map +1 -1
  5. package/components/Checkbox/sgds-checkbox-group.d.ts +49 -10
  6. package/components/Checkbox/sgds-checkbox-group.js +161 -25
  7. package/components/Checkbox/sgds-checkbox-group.js.map +1 -1
  8. package/components/Checkbox/sgds-checkbox.d.ts +5 -1
  9. package/components/Checkbox/sgds-checkbox.js +39 -6
  10. package/components/Checkbox/sgds-checkbox.js.map +1 -1
  11. package/components/ComboBox/index.umd.js +39 -6
  12. package/components/ComboBox/index.umd.js.map +1 -1
  13. package/components/index.umd.js +195 -31
  14. package/components/index.umd.js.map +1 -1
  15. package/index.umd.js +195 -31
  16. package/index.umd.js.map +1 -1
  17. package/package.json +1 -1
  18. package/react/components/Checkbox/checkbox-group.cjs.js +1 -1
  19. package/react/components/Checkbox/checkbox-group.js +1 -1
  20. package/react/components/Checkbox/checkbox.cjs.js +1 -1
  21. package/react/components/Checkbox/checkbox.js +1 -1
  22. package/react/components/Checkbox/sgds-checkbox-group.cjs.js +160 -24
  23. package/react/components/Checkbox/sgds-checkbox-group.cjs.js.map +1 -1
  24. package/react/components/Checkbox/sgds-checkbox-group.js +161 -25
  25. package/react/components/Checkbox/sgds-checkbox-group.js.map +1 -1
  26. package/react/components/Checkbox/sgds-checkbox.cjs.js +38 -5
  27. package/react/components/Checkbox/sgds-checkbox.cjs.js.map +1 -1
  28. package/react/components/Checkbox/sgds-checkbox.js +39 -6
  29. package/react/components/Checkbox/sgds-checkbox.js.map +1 -1
@@ -9224,7 +9224,7 @@
9224
9224
  property({ type: Boolean, reflect: true })
9225
9225
  ], FormControlElement.prototype, "invalid", void 0);
9226
9226
 
9227
- var css_248z$2 = 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%}`;
9227
+ var css_248z$2 = 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%}`;
9228
9228
 
9229
9229
  /**
9230
9230
  * @summary Checkbox component is used when you require users to select multiple items from a list.
@@ -9241,14 +9241,14 @@
9241
9241
  super(...arguments);
9242
9242
  /** Draws the checkbox in a checked state. */
9243
9243
  this.checked = false;
9244
- /** Allows invalidFeedback, invalid and valid styles to be visible with the input */
9245
- this.hasFeedback = false;
9246
9244
  /** 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. */
9247
9245
  this.defaultChecked = false;
9248
9246
  /** Marks the checkbox input as indeterminate , with indeterminate logo */
9249
9247
  this.indeterminate = false;
9250
9248
  /** Makes the checkbox a required field. */
9251
9249
  this.required = false;
9250
+ /**Feedback text for error state when validated */
9251
+ this.invalidFeedback = "";
9252
9252
  this._isTouched = false;
9253
9253
  }
9254
9254
  _handleInvalidChange() {
@@ -9273,7 +9273,6 @@
9273
9273
  this.indeterminate = !this.indeterminate;
9274
9274
  }
9275
9275
  this.checked = !this.checked;
9276
- this.value = this.input.value;
9277
9276
  super._mixinHandleChange(e);
9278
9277
  this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
9279
9278
  }
@@ -9304,6 +9303,11 @@
9304
9303
  this.invalid = !this.input.checkValidity();
9305
9304
  }
9306
9305
  }
9306
+ _handleChecked() {
9307
+ this.checked
9308
+ ? this.emit("sgds-check", { detail: { value: this.value } })
9309
+ : this.emit("sgds-uncheck", { detail: { value: this.value } });
9310
+ }
9307
9311
  _mixinResetFormControl() {
9308
9312
  this._isTouched = false;
9309
9313
  this.checked = this.input.checked = this.defaultChecked;
@@ -9335,14 +9339,20 @@
9335
9339
  get validationMessage() {
9336
9340
  return this._mixinGetValidationMessage();
9337
9341
  }
9342
+ firstUpdated(_changedProperties) {
9343
+ super.firstUpdated(_changedProperties);
9344
+ this.checked && this.emit("sgds-check", { detail: { value: this.value } });
9345
+ }
9338
9346
  render() {
9347
+ const wantFeedbackStyle = this.hasFeedback === "both" || this.hasFeedback === "style";
9348
+ const wantFeedbackText = this.hasFeedback === "both" || this.hasFeedback === "text";
9339
9349
  return html$1 `
9340
9350
  <div class="form-check">
9341
9351
  <div class="form-check-input-container">
9342
9352
  <input
9343
9353
  class=${classMap({
9344
9354
  "form-check-input": true,
9345
- "is-invalid": this.hasFeedback && this.invalid
9355
+ "is-invalid": wantFeedbackStyle && this.invalid
9346
9356
  })}
9347
9357
  type="checkbox"
9348
9358
  id=${this._controlId}
@@ -9364,6 +9374,23 @@
9364
9374
  </div>
9365
9375
  <label for="${this._controlId}" class="form-check-label" id="${this._labelId}"><slot></slot></label>
9366
9376
  </div>
9377
+ ${wantFeedbackText && this.invalid
9378
+ ? html$1 `
9379
+ <div class="invalid-feedback-container">
9380
+ <slot name="invalidIcon">
9381
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
9382
+ <path
9383
+ 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"
9384
+ fill="currentColor"
9385
+ />
9386
+ </svg>
9387
+ </slot>
9388
+ <div id="checkbox-feedback" tabindex="0" class="invalid-feedback">
9389
+ ${this.invalidFeedback ? this.invalidFeedback : this.input.validationMessage}
9390
+ </div>
9391
+ </div>
9392
+ `
9393
+ : nothing}
9367
9394
  `;
9368
9395
  }
9369
9396
  }
@@ -9375,7 +9402,7 @@
9375
9402
  property({ type: Boolean, reflect: true })
9376
9403
  ], SgdsCheckbox.prototype, "checked", void 0);
9377
9404
  __decorate([
9378
- property({ type: Boolean, reflect: true })
9405
+ property({ type: String, reflect: true })
9379
9406
  ], SgdsCheckbox.prototype, "hasFeedback", void 0);
9380
9407
  __decorate([
9381
9408
  defaultValue("checked")
@@ -9386,6 +9413,9 @@
9386
9413
  __decorate([
9387
9414
  property({ type: Boolean, reflect: true })
9388
9415
  ], SgdsCheckbox.prototype, "required", void 0);
9416
+ __decorate([
9417
+ property({ type: String, reflect: true })
9418
+ ], SgdsCheckbox.prototype, "invalidFeedback", void 0);
9389
9419
  __decorate([
9390
9420
  state()
9391
9421
  ], SgdsCheckbox.prototype, "_isTouched", void 0);
@@ -9398,6 +9428,9 @@
9398
9428
  __decorate([
9399
9429
  watch("_isTouched", { waitUntilFirstUpdate: true })
9400
9430
  ], SgdsCheckbox.prototype, "_handleIsTouched", null);
9431
+ __decorate([
9432
+ watch("checked", { waitUntilFirstUpdate: true })
9433
+ ], SgdsCheckbox.prototype, "_handleChecked", null);
9401
9434
 
9402
9435
  var css_248z$1 = 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}`;
9403
9436