@sebgroup/green-core 1.88.2 → 1.88.3

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.
@@ -35,10 +35,7 @@ export declare class GdsCheckbox extends GdsFormControlElement {
35
35
  get value(): string;
36
36
  set value(value: string);
37
37
  private _elCheckbox;
38
- connectedCallback(): void;
39
- private _updateAriaState;
40
38
  private _handleIndeterminateChange;
41
- protected updated(changedProperties: Map<string, unknown>): void;
42
39
  render(): any;
43
40
  protected _getValidityAnchor(): HTMLElement;
44
41
  protected formResetCallback(): void;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  __decorateClass,
3
3
  __privateAdd,
4
- __privateGet,
5
4
  __privateMethod
6
5
  } from "../../chunks/chunk.QTSIPXV3.js";
7
- var _handleClick, _handleKeyDown, _toggleChecked, toggleChecked_fn;
6
+ var _toggleChecked, toggleChecked_fn, _dispatchChangeEvents, dispatchChangeEvents_fn;
8
7
  import { property, query } from "lit/decorators.js";
8
+ import { ifDefined } from "lit/directives/if-defined.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";
@@ -13,29 +13,18 @@ import { checkboxToggle } from "../../shared-styles/rbcb-toggle.template.js";
13
13
  import { tokens } from "../../tokens.style.js";
14
14
  import { watch } from "../../utils/decorators/watch.js";
15
15
  import { GdsFormControlElement } from "../form/form-control.js";
16
- import { IconCheckmark } from "../pure.js";
16
+ import { IconCheckmark, IconMinusSmall } from "../pure.js";
17
17
  import { styles } from "./checkbox.styles.js";
18
18
  let GdsCheckbox = class extends GdsFormControlElement {
19
19
  constructor() {
20
20
  super(...arguments);
21
21
  __privateAdd(this, _toggleChecked);
22
+ __privateAdd(this, _dispatchChangeEvents);
22
23
  this.label = "";
23
24
  this.supportingText = "";
24
25
  this.checked = false;
25
26
  this.indeterminate = false;
26
27
  this.disabled = false;
27
- __privateAdd(this, _handleClick, (e) => {
28
- this.focus();
29
- __privateMethod(this, _toggleChecked, toggleChecked_fn).call(this);
30
- });
31
- __privateAdd(this, _handleKeyDown, (e) => {
32
- if (this.disabled)
33
- return;
34
- if (e.key === "Enter" || e.key === " ") {
35
- e.preventDefault();
36
- __privateMethod(this, _toggleChecked, toggleChecked_fn).call(this);
37
- }
38
- });
39
28
  }
40
29
  get value() {
41
30
  return this._internalValue || "";
@@ -43,40 +32,37 @@ let GdsCheckbox = class extends GdsFormControlElement {
43
32
  set value(value) {
44
33
  this._internalValue = value;
45
34
  }
46
- connectedCallback() {
47
- super.connectedCallback();
48
- this.setAttribute("role", "checkbox");
49
- this._updateAriaState();
50
- this.addEventListener("keydown", __privateGet(this, _handleKeyDown));
51
- this.addEventListener("click", __privateGet(this, _handleClick));
52
- }
53
- _updateAriaState() {
54
- this.setAttribute(
55
- "aria-checked",
56
- this.indeterminate ? "mixed" : this.checked.toString()
57
- );
58
- this.setAttribute("aria-disabled", this.disabled.toString());
59
- this.setAttribute("tabindex", this.disabled ? "-1" : "0");
60
- this.toggleAttribute("aria-invalid", this.invalid);
61
- }
62
35
  _handleIndeterminateChange() {
63
36
  if (this.indeterminate) {
64
37
  this.checked = false;
65
38
  }
66
39
  }
67
- updated(changedProperties) {
68
- super.updated(changedProperties);
69
- if (changedProperties.has("checked") || changedProperties.has("indeterminate") || changedProperties.has("disabled") || changedProperties.has("invalid")) {
70
- this._updateAriaState();
71
- }
72
- }
73
40
  render() {
74
41
  return html`
75
- <gds-toggle-control-base
76
- supporting-text=${this.supportingText}
77
- label=${this.label}
42
+ <input
78
43
  type="checkbox"
79
- >
44
+ ?checked=${this.checked}
45
+ ?disabled=${this.disabled}
46
+ ?indeterminate=${this.indeterminate}
47
+ aria-invalid=${this.invalid}
48
+ aria-describedby=${ifDefined(
49
+ this.supportingText ? "supporting-text" : ""
50
+ )}
51
+ id="checkbox-input"
52
+ @change=${() => {
53
+ this.checked = this._elCheckbox.checked;
54
+ __privateMethod(this, _dispatchChangeEvents, dispatchChangeEvents_fn).call(this);
55
+ }}
56
+ />
57
+ <gds-toggle-control-base type="checkbox" @click=${__privateMethod(this, _toggleChecked, toggleChecked_fn)}>
58
+ <label for="checkbox-input" slot="label"> ${this.label} </label>
59
+ <span
60
+ slot="supporting-text"
61
+ class="supporting-text"
62
+ id="supporting-text"
63
+ >
64
+ ${this.supportingText}
65
+ </span>
80
66
  ${checkboxToggle({
81
67
  checked: this.checked,
82
68
  indeterminate: this.indeterminate,
@@ -93,16 +79,19 @@ let GdsCheckbox = class extends GdsFormControlElement {
93
79
  this.checked = false;
94
80
  }
95
81
  };
96
- _handleClick = new WeakMap();
97
- _handleKeyDown = new WeakMap();
98
82
  _toggleChecked = new WeakSet();
99
- toggleChecked_fn = function() {
83
+ toggleChecked_fn = function(e) {
84
+ if (this.disabled || e.target instanceof HTMLLabelElement)
85
+ return;
100
86
  if (this.indeterminate) {
101
87
  this.indeterminate = false;
102
- this.checked = true;
103
88
  } else {
104
89
  this.checked = !this.checked;
105
90
  }
91
+ __privateMethod(this, _dispatchChangeEvents, dispatchChangeEvents_fn).call(this);
92
+ };
93
+ _dispatchChangeEvents = new WeakSet();
94
+ dispatchChangeEvents_fn = function() {
106
95
  this.dispatchStandardEvent("change", {
107
96
  bubbles: true,
108
97
  composed: true
@@ -129,14 +118,14 @@ __decorateClass([
129
118
  property({ type: Boolean, reflect: true })
130
119
  ], GdsCheckbox.prototype, "disabled", 2);
131
120
  __decorateClass([
132
- query(".rbcb")
121
+ query('input[type="checkbox"]')
133
122
  ], GdsCheckbox.prototype, "_elCheckbox", 2);
134
123
  __decorateClass([
135
124
  watch("indeterminate")
136
125
  ], GdsCheckbox.prototype, "_handleIndeterminateChange", 1);
137
126
  GdsCheckbox = __decorateClass([
138
127
  gdsCustomElement("gds-checkbox", {
139
- dependsOn: [GdsToggleControlBase, IconCheckmark]
128
+ dependsOn: [GdsToggleControlBase, IconCheckmark, IconMinusSmall]
140
129
  })
141
130
  ], GdsCheckbox);
142
131
  export {
@@ -17,6 +17,14 @@ const styles = css`
17
17
  :host(:focus) {
18
18
  outline: none;
19
19
  }
20
+
21
+ input[type='checkbox'] {
22
+ position: absolute;
23
+ opacity: 0;
24
+ width: 0;
25
+ height: 0;
26
+ pointer-events: none;
27
+ }
20
28
  `;
21
29
  export {
22
30
  styles
@@ -62,11 +62,9 @@ let GdsRadio = class extends GdsElement {
62
62
  }
63
63
  render() {
64
64
  return html`
65
- <gds-toggle-control-base
66
- supporting-text=${this.supportingText}
67
- label=${this.label}
68
- type="radio"
69
- >
65
+ <gds-toggle-control-base type="radio">
66
+ <label slot="label" @click=${__privateGet(this, _handleClick)}> ${this.label} </label>
67
+ <span slot="supporting-text"> ${this.supportingText} </span>
70
68
  ${radioToggle({
71
69
  checked: this.checked,
72
70
  disabled: this.disabled,
@@ -7,7 +7,6 @@ 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
- connectedCallback?: (() => void) | undefined;
11
10
  render?: (() => any) | undefined;
12
11
  validator?: import("../../../components/form/form-control").GdsValidator | undefined;
13
12
  required?: boolean | undefined;
@@ -23,6 +22,7 @@ export declare const GdsCheckbox: (props: React.ComponentProps<ReturnType<typeof
23
22
  gdsElementName?: string | undefined;
24
23
  _isUsingTransitionalStyles?: boolean | undefined;
25
24
  _dynamicStylesController?: import("../../../utils/controllers/dynamic-styles-controller").DynamicStylesController | undefined;
25
+ connectedCallback?: (() => void) | undefined;
26
26
  disconnectedCallback?: (() => void) | undefined;
27
27
  dispatchStandardEvent?: ((name: string, options?: EventInit) => boolean) | undefined;
28
28
  dispatchCustomEvent?: (<T>(name: string, options?: CustomEventInit<T>) => boolean) | undefined;
@@ -11,8 +11,8 @@ export * from './container/index.js';
11
11
  export * from './context-menu/index.js';
12
12
  export * from './datepicker/index.js';
13
13
  export * from './details/index.js';
14
- export * from './div/index.js';
15
14
  export * from './dialog/index.js';
15
+ export * from './div/index.js';
16
16
  export * from './divider/index.js';
17
17
  export * from './dropdown/index.js';
18
18
  export * from './fab/index.js';
@@ -43,8 +43,8 @@ export * from './theme/index.js';
43
43
  export * from './video/index.js';
44
44
  export * from './form-control-footer/index.js';
45
45
  export * from './form-control-header/index.js';
46
- export * from './option/index.js';
47
46
  export * from './menu-item/index.js';
47
+ export * from './option/index.js';
48
48
  export * from './checkbox-group/index.js';
49
49
  export * from './icons/icon-details/index.js';
50
50
  export * from './filter-chip/index.js';
@@ -11,8 +11,8 @@ export * from "./container/index.js";
11
11
  export * from "./context-menu/index.js";
12
12
  export * from "./datepicker/index.js";
13
13
  export * from "./details/index.js";
14
- export * from "./div/index.js";
15
14
  export * from "./dialog/index.js";
15
+ export * from "./div/index.js";
16
16
  export * from "./divider/index.js";
17
17
  export * from "./dropdown/index.js";
18
18
  export * from "./fab/index.js";
@@ -43,8 +43,8 @@ export * from "./theme/index.js";
43
43
  export * from "./video/index.js";
44
44
  export * from "./form-control-footer/index.js";
45
45
  export * from "./form-control-header/index.js";
46
- export * from "./option/index.js";
47
46
  export * from "./menu-item/index.js";
47
+ export * from "./option/index.js";
48
48
  export * from "./checkbox-group/index.js";
49
49
  export * from "./icons/icon-details/index.js";
50
50
  export * from "./filter-chip/index.js";
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": "1.88.2",
4
+ "version": "1.88.3",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -25,10 +25,8 @@ let GdsToggleControlBase = class extends GdsElement {
25
25
  <slot></slot>
26
26
  </div>
27
27
  <div class="${classMap(classes)}">
28
- <label class="primary-label"> ${this.label} </label>
29
- ${this.label ? html`
30
- <span class="supporting-text"> ${this.supportingText} </span>
31
- ` : ""}
28
+ <slot name="label"></slot>
29
+ <slot name="supporting-text"></slot>
32
30
  </div>
33
31
  </div>
34
32
  `;
@@ -27,12 +27,12 @@ const styles = css`
27
27
  justify-content: center;
28
28
  }
29
29
 
30
- .primary-label {
30
+ slot[name='label']::slotted(*) {
31
31
  font-weight: var(--gds-sys-text-weight-book);
32
32
  cursor: inherit;
33
33
  }
34
34
 
35
- .supporting-text {
35
+ slot[name='supporting-text']::slotted(*) {
36
36
  font-size: var(--_font-size-supporting-text);
37
37
  line-height: var(--_line-height-supporting-text);
38
38
  font-weight: var(--gds-sys-text-weight-regular);
@@ -140,7 +140,8 @@ var rbcb_toggle_style_default = css`
140
140
  color: var(--gds-sys-color-l3-content-negative);
141
141
  }
142
142
 
143
- :host(:focus-visible) .rbcb__perimeter {
143
+ :host(:focus-visible) .rbcb__perimeter,
144
+ :host(:focus-within) .rbcb__perimeter {
144
145
  outline-width: var(--gds-sys-space-3xs);
145
146
  scale: 1;
146
147
  }
@@ -1,6 +1,6 @@
1
1
  import "../../chunks/chunk.QTSIPXV3.js";
2
2
  import { html as litHtml } from "lit";
3
- const VER_SUFFIX = "-f27f4b";
3
+ const VER_SUFFIX = "-10d557";
4
4
  class ScopedElementRegistry {
5
5
  static get instance() {
6
6
  if (!globalThis.__gdsElementLookupTable?.[VER_SUFFIX])