@sebgroup/green-core 2.6.4 → 2.6.5

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.
@@ -4,7 +4,7 @@ import {
4
4
  __privateGet,
5
5
  __privateMethod
6
6
  } from "../../../chunks/chunk.QU3DSPNU.js";
7
- var _handleInvalidChange, _CheckboxGroup_instances, renderCheckboxGroupContents_fn, renderFieldControlHeader_fn, renderCheckboxes_fn, handleCheckboxChange_fn, computeValue_fn, dispatchInputEvent_fn, renderFieldControlFooter_fn;
7
+ var _syncCheckboxes, _CheckboxGroup_instances, renderCheckboxGroupContents_fn, renderFieldControlHeader_fn, renderCheckboxes_fn, handleCheckboxChange_fn, computeValue_fn, dispatchInputEvent_fn, renderFieldControlFooter_fn;
8
8
  import { localized } from "@lit/localize";
9
9
  import { property, query } from "lit/decorators.js";
10
10
  import { classMap } from "lit/directives/class-map.js";
@@ -28,9 +28,10 @@ let CheckboxGroup = class extends GdsFormControlElement {
28
28
  this.direction = "column";
29
29
  this.supportingText = "";
30
30
  this.showExtendedSupportingText = false;
31
- __privateAdd(this, _handleInvalidChange, () => {
31
+ __privateAdd(this, _syncCheckboxes, () => {
32
32
  this.checkboxes.forEach((checkbox) => {
33
33
  checkbox.invalid = this.invalid;
34
+ checkbox.errorMessage = this.errorMessage;
34
35
  });
35
36
  });
36
37
  }
@@ -59,14 +60,14 @@ let CheckboxGroup = class extends GdsFormControlElement {
59
60
  });
60
61
  }
61
62
  _handleGroupInvalidChange() {
62
- __privateGet(this, _handleInvalidChange).call(this);
63
+ __privateGet(this, _syncCheckboxes).call(this);
63
64
  }
64
65
  focus() {
65
66
  this.checkboxes[0]?.focus();
66
67
  }
67
68
  connectedCallback() {
68
69
  super.connectedCallback();
69
- this.addEventListener("gds-validity-state", __privateGet(this, _handleInvalidChange));
70
+ this.addEventListener("gds-validity-state", __privateGet(this, _syncCheckboxes));
70
71
  }
71
72
  render() {
72
73
  const classes = {
@@ -86,10 +87,11 @@ let CheckboxGroup = class extends GdsFormControlElement {
86
87
  </div>`;
87
88
  }
88
89
  _syncOnDOMChange() {
90
+ __privateGet(this, _syncCheckboxes).call(this);
89
91
  __privateMethod(this, _CheckboxGroup_instances, computeValue_fn).call(this);
90
92
  }
91
93
  };
92
- _handleInvalidChange = new WeakMap();
94
+ _syncCheckboxes = new WeakMap();
93
95
  _CheckboxGroup_instances = new WeakSet();
94
96
  renderCheckboxGroupContents_fn = function() {
95
97
  const elements = [
@@ -173,7 +175,8 @@ __decorateClass([
173
175
  watch("value", { waitUntilFirstUpdate: true })
174
176
  ], CheckboxGroup.prototype, "_handleValueChange", 1);
175
177
  __decorateClass([
176
- watch("invalid")
178
+ watch("invalid"),
179
+ watch("errorMessage")
177
180
  ], CheckboxGroup.prototype, "_handleGroupInvalidChange", 1);
178
181
  __decorateClass([
179
182
  observeLightDOM({
@@ -35,6 +35,7 @@ export declare class GdsCheckbox extends GdsFormControlElement {
35
35
  set value(value: string);
36
36
  private _elCheckbox;
37
37
  private _handleIndeterminateChange;
38
+ focus(options?: FocusOptions): void;
38
39
  render(): any;
39
40
  protected _getValidityAnchor(): HTMLElement;
40
41
  protected formResetCallback(): void;
@@ -5,7 +5,7 @@ import {
5
5
  } from "../../chunks/chunk.QU3DSPNU.js";
6
6
  var _GdsCheckbox_instances, toggleChecked_fn, dispatchChangeEvents_fn;
7
7
  import { property, query } from "lit/decorators.js";
8
- import { ifDefined } from "lit/directives/if-defined.js";
8
+ import { when } from "lit/directives/when.js";
9
9
  import { GdsToggleControlBase } from "../../primitives/toggle-controls-base/toggle-control-base.component.js";
10
10
  import { gdsCustomElement, html } from "../../scoping.js";
11
11
  import rbcbToggleStyles from "../../shared-styles/rbcb-toggle.style.js";
@@ -37,6 +37,9 @@ let GdsCheckbox = class extends GdsFormControlElement {
37
37
  this.checked = false;
38
38
  }
39
39
  }
40
+ focus(options) {
41
+ this._elCheckbox.focus(options);
42
+ }
40
43
  render() {
41
44
  return html`
42
45
  <input
@@ -45,15 +48,17 @@ let GdsCheckbox = class extends GdsFormControlElement {
45
48
  ?disabled=${this.disabled}
46
49
  ?indeterminate=${this.indeterminate}
47
50
  aria-invalid=${this.invalid}
48
- aria-describedby=${ifDefined(
49
- this.supportingText ? "supporting-text" : ""
50
- )}
51
+ aria-describedby="message supporting-text"
51
52
  id="checkbox-input"
52
53
  @change=${() => {
53
54
  this.checked = this._elCheckbox.checked;
54
55
  __privateMethod(this, _GdsCheckbox_instances, dispatchChangeEvents_fn).call(this);
55
56
  }}
56
57
  />
58
+ ${when(
59
+ this.errorMessage,
60
+ () => html`<span id="message">${this.errorMessage}</span>`
61
+ )}
57
62
  <gds-toggle-control-base type="checkbox" @click=${__privateMethod(this, _GdsCheckbox_instances, toggleChecked_fn)}>
58
63
  <label for="checkbox-input" slot="label"> ${this.label} </label>
59
64
  <span
@@ -25,6 +25,10 @@ const style = css`
25
25
  height: 0;
26
26
  pointer-events: none;
27
27
  }
28
+
29
+ #message {
30
+ display: none;
31
+ }
28
32
  `;
29
33
  var checkbox_styles_default = style;
30
34
  export {
@@ -7,6 +7,7 @@ import {
7
7
  } from "../../chunks/chunk.QU3DSPNU.js";
8
8
  var _optionElements, _GdsDropdown_instances, shouldShowFooter_fn, _renderCombobox, _renderTriggerButton, _calcMaxHeight, _dispatchUISateEvent, _handlePopoverStateChange, _handleClearButton, _handleSearchFieldInput, _handleSearchFieldKeyDown, _handleListboxKeyDown, _handleOptionFocusChange, handleSelectionChange_fn, _dispatchInputEvent, _dispatchChangeEvent, registerAutoCloseListener_fn, unregisterAutoCloseListener_fn, _blurCloseListener, _tabCloseListener;
9
9
  import { localized, msg, str } from "@lit/localize";
10
+ import { nothing } from "lit";
10
11
  import { property, query, queryAsync } from "lit/decorators.js";
11
12
  import { ifDefined } from "lit/directives/if-defined.js";
12
13
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
@@ -99,7 +100,7 @@ let GdsDropdown = class extends GdsFormControlElement {
99
100
  aria-haspopup="listbox"
100
101
  aria-controls="listbox"
101
102
  name="trigger"
102
- aria-label="${this.label} ${this.displayValue}"
103
+ aria-label="${this.label}"
103
104
  aria-describedby="supporting-text extended-supporting-text sub-label message"
104
105
  aria-invalid="${this.invalid}"
105
106
  aria-required="${this.required}"
@@ -395,7 +396,7 @@ let GdsDropdown = class extends GdsFormControlElement {
395
396
  <gds-icon-triangle-exclamation
396
397
  solid
397
398
  ></gds-icon-triangle-exclamation>
398
- ${this.errorMessage}
399
+ ${this.invalid ? this.errorMessage : nothing}
399
400
  </slot>
400
401
  </gds-form-control-footer>
401
402
  `
@@ -114,6 +114,7 @@ let Input = class extends GdsFormControlElement {
114
114
  ${when(
115
115
  __privateMethod(this, _Input_instances, shouldShowFooter_fn).call(this),
116
116
  () => html` <gds-form-control-footer
117
+ id="message"
117
118
  class="size-${this.size}"
118
119
  .charCounter=${__privateGet(this, _Input_instances, shouldShowRemainingChars_get) ? this.maxlength - (this.value?.length || 0) : void 0}
119
120
  .errorMessage=${this.invalid ? this.errorMessage : void 0}
@@ -159,6 +160,7 @@ renderNativeInput_fn = function() {
159
160
  ?disabled=${this.disabled}
160
161
  aria-describedby="supporting-text extended-supporting-text sub-label message"
161
162
  aria-invalid=${this.invalid}
163
+ aria-errormessage="message"
162
164
  aria-label=${this.plain && this.label || nothing}
163
165
  placeholder=" "
164
166
  type=${this.type}
@@ -72,6 +72,7 @@ let RadioGroup = class extends GdsFormControlElement {
72
72
  radio.checked = radio.value === this.value;
73
73
  radio.size = this.size;
74
74
  radio.invalid = this.invalid;
75
+ radio.errorMessage = this.errorMessage;
75
76
  });
76
77
  }
77
78
  render() {
@@ -246,7 +247,8 @@ __decorateClass([
246
247
  watch("value")
247
248
  ], RadioGroup.prototype, "_handleValueChange", 1);
248
249
  __decorateClass([
249
- watch("invalid")
250
+ watch("invalid"),
251
+ watch("errorMessage")
250
252
  ], RadioGroup.prototype, "_syncRadioStates", 1);
251
253
  RadioGroup = __decorateClass([
252
254
  localized()
@@ -32,6 +32,13 @@ export declare class GdsRadio extends GdsElement {
32
32
  * Whether the radio button is invalid or not.
33
33
  */
34
34
  invalid: boolean;
35
+ /**
36
+ * The accessible error message text for the radio button.
37
+ *
38
+ * This text is not visually rendered, but will be announced by
39
+ * screen readers when the radio button is in an invalid state.
40
+ */
41
+ errorMessage?: string;
35
42
  private _isFocused;
36
43
  constructor();
37
44
  connectedCallback(): void;
@@ -50,6 +50,10 @@ let GdsRadio = class extends GdsElement {
50
50
  this.setAttribute("aria-checked", this.checked.toString());
51
51
  this.setAttribute("aria-disabled", this.disabled.toString());
52
52
  this.setAttribute("tabindex", this.disabled ? "-1" : "0");
53
+ this.setAttribute(
54
+ "aria-description",
55
+ this.errorMessage ? this.errorMessage : ""
56
+ );
53
57
  this.toggleAttribute("aria-invalid", this.invalid);
54
58
  }
55
59
  updated(changedProperties) {
@@ -94,6 +98,9 @@ __decorateClass([
94
98
  __decorateClass([
95
99
  property({ type: Boolean })
96
100
  ], GdsRadio.prototype, "invalid", 2);
101
+ __decorateClass([
102
+ property({ type: String })
103
+ ], GdsRadio.prototype, "errorMessage", 2);
97
104
  __decorateClass([
98
105
  state()
99
106
  ], GdsRadio.prototype, "_isFocused", 2);
package/gds-element.js CHANGED
@@ -14,7 +14,7 @@ class GdsElement extends LitElement {
14
14
  /**
15
15
  * The semantic version of this element. Can be used for troubleshooting to verify the version being used.
16
16
  */
17
- this.semanticVersion = "2.6.4";
17
+ this.semanticVersion = "2.6.5";
18
18
  this._isUsingTransitionalStyles = false;
19
19
  this._dynamicStylesController = new DynamicStylesController(this);
20
20
  }
@@ -7,6 +7,7 @@ export declare const GdsCheckbox: (props: React.ComponentProps<ReturnType<typeof
7
7
  indeterminate?: boolean | undefined;
8
8
  disabled?: boolean | undefined;
9
9
  value?: string | undefined;
10
+ focus?: ((options?: FocusOptions) => void) | undefined;
10
11
  render?: (() => any) | undefined;
11
12
  connectedCallback?: (() => void) | undefined;
12
13
  validator?: import("../../../components/form/form-control").GdsValidator | undefined;
@@ -382,7 +383,6 @@ export declare const GdsCheckbox: (props: React.ComponentProps<ReturnType<typeof
382
383
  nonce?: string | undefined;
383
384
  tabIndex?: number | undefined;
384
385
  blur?: (() => void) | undefined;
385
- focus?: ((options?: FocusOptions) => void) | undefined;
386
386
  }, "children"> & {
387
387
  children?: import("react").ReactNode;
388
388
  } & Omit<import("react").HTMLAttributes<HTMLElement>, "children"> & import("react").RefAttributes<HTMLElement>, string | import("react").JSXElementConstructor<any>>;
@@ -7,6 +7,7 @@ export declare const GdsRadio: (props: React.ComponentProps<ReturnType<typeof ge
7
7
  checked?: boolean | undefined;
8
8
  disabled?: boolean | undefined;
9
9
  invalid?: boolean | undefined;
10
+ errorMessage?: string | undefined;
10
11
  connectedCallback?: (() => void) | undefined;
11
12
  updated?: ((changedProperties: Map<string, unknown>) => void) | undefined;
12
13
  render?: (() => any) | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sebgroup/green-core",
3
3
  "description": "A carefully crafted set of Web Components, laying the foundation of the Green Design System.",
4
- "version": "2.6.4",
4
+ "version": "2.6.5",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  import "../../chunks/chunk.QU3DSPNU.js";
2
2
  import { html as litHtml } from "lit";
3
- const VER_SUFFIX = "-838d82";
3
+ const VER_SUFFIX = "-3d32ce";
4
4
  class ScopedElementRegistry {
5
5
  static get instance() {
6
6
  if (!globalThis.__gdsElementLookupTable?.[VER_SUFFIX])