@sebgroup/green-core 1.71.2 → 1.72.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.
@@ -0,0 +1,14 @@
1
+ import { GdsElement } from '../../../gds-element';
2
+ /**
3
+ * @element gds-icon-details
4
+ * @status beta
5
+ */
6
+ export declare class GdsIconDetails extends GdsElement {
7
+ static styles: import("lit").CSSResult[];
8
+ /**
9
+ * Controls if the details is open
10
+ */
11
+ open: boolean;
12
+ render(): any;
13
+ updated(changedProperties: Map<string, any>): void;
14
+ }
@@ -0,0 +1,71 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../../chunks/chunk.QTSIPXV3.js";
4
+ import { property } from "lit/decorators.js";
5
+ import { GdsElement } from "../../../gds-element.js";
6
+ import {
7
+ gdsCustomElement,
8
+ html
9
+ } from "../../../utils/helpers/custom-element-scoping.js";
10
+ import { styles } from "./details-icon.style.js";
11
+ let GdsIconDetails = class extends GdsElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.open = false;
15
+ }
16
+ render() {
17
+ return html`
18
+ <svg
19
+ width="20"
20
+ height="20"
21
+ viewBox="0 0 20 20"
22
+ stroke="currentColor"
23
+ strokeWidth="1.5"
24
+ strokeLinecap="round"
25
+ id="plus"
26
+ >
27
+ <line x1="4" y1="10" x2="16" y2="10" />
28
+ <line x1="10" y1="4" x2="10" y2="16">
29
+ <animate
30
+ attributeName="y1"
31
+ dur="240ms"
32
+ from="${this.open ? "4" : "10"}"
33
+ to="${this.open ? "10" : "4"}"
34
+ begin="plus.toggle"
35
+ fill="freeze"
36
+ />
37
+ <animate
38
+ attributeName="y2"
39
+ dur="240ms"
40
+ from="${this.open ? "16" : "10"}"
41
+ to="${this.open ? "10" : "16"}"
42
+ begin="plus.toggle"
43
+ fill="freeze"
44
+ />
45
+ </line>
46
+ </svg>
47
+ `;
48
+ }
49
+ updated(changedProperties) {
50
+ if (changedProperties.has("open")) {
51
+ const svg = this.shadowRoot?.querySelector("svg");
52
+ if (svg) {
53
+ const event = new CustomEvent("toggle", {
54
+ bubbles: true,
55
+ composed: true
56
+ });
57
+ svg.dispatchEvent(event);
58
+ }
59
+ }
60
+ }
61
+ };
62
+ GdsIconDetails.styles = [styles];
63
+ __decorateClass([
64
+ property({ type: Boolean, reflect: true })
65
+ ], GdsIconDetails.prototype, "open", 2);
66
+ GdsIconDetails = __decorateClass([
67
+ gdsCustomElement("gds-icon-details")
68
+ ], GdsIconDetails);
69
+ export {
70
+ GdsIconDetails
71
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsIconDetails } from './details-icon.component';
2
+ export { GdsIconDetails };
@@ -0,0 +1,6 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsIconDetails } from "./details-icon.component.js";
3
+ GdsIconDetails.define();
4
+ export {
5
+ GdsIconDetails
6
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,10 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ import { css } from "lit";
3
+ const styles = css`
4
+ :host {
5
+ display: contents;
6
+ }
7
+ `;
8
+ export {
9
+ styles
10
+ };
@@ -0,0 +1,46 @@
1
+ import { GdsElement } from '../../gds-element';
2
+ export type DetailsSize = 'large' | 'small';
3
+ declare const GdsDetails_base: (new (...args: any[]) => import("../../utils/mixins/declarative-layout-mixins").SizeXProps) & (new (...args: any[]) => import("../../utils/mixins/declarative-layout-mixins").MarginProps) & (new (...args: any[]) => import("../../utils/mixins/declarative-layout-mixins").LayoutChildProps) & typeof GdsElement;
4
+ /**
5
+ * Details component that provides collapsible content sections.
6
+ *
7
+ * @element gds-details
8
+ * @status beta
9
+ *
10
+ * @slot - Default slot for details content
11
+ * @event gds-ui-state - Fired when details opens or closes
12
+ *
13
+ * @example
14
+ * ```html
15
+ * <gds-details summary="Section Title">
16
+ * <p>Details content here</p>
17
+ * </gds-details>
18
+ * ```
19
+ */
20
+ export declare class GdsDetails extends GdsDetails_base {
21
+ #private;
22
+ static styles: (import("lit").CSSResult | import("lit").CSSResult[])[];
23
+ /**
24
+ * The summary text displayed in the details header
25
+ */
26
+ summary: string;
27
+ /**
28
+ * Group identifier for details behavior synchronization
29
+ */
30
+ name: string;
31
+ /**
32
+ * Controls the expanded state of the details
33
+ */
34
+ open: boolean;
35
+ /**
36
+ * Controls the size variant of the details
37
+ */
38
+ size: DetailsSize;
39
+ private _content?;
40
+ private _openIconSlot?;
41
+ private _closedIconSlot?;
42
+ protected firstUpdated(): void;
43
+ private __handleOpenChange;
44
+ render(): any;
45
+ }
46
+ export {};
@@ -0,0 +1,185 @@
1
+ import {
2
+ __decorateClass,
3
+ __privateAdd,
4
+ __privateGet
5
+ } from "../../chunks/chunk.QTSIPXV3.js";
6
+ var _initializeContentHeight, _updateContentHeight, _handleToggle, _handleKeydown, _syncGroupState, _dispatchStateEvent, _renderHeader, _renderIconButton, _renderContent;
7
+ import { property, query } from "lit/decorators.js";
8
+ import { classMap } from "lit/directives/class-map.js";
9
+ import { GdsElement } from "../../gds-element.js";
10
+ import { tokens } from "../../tokens.style.js";
11
+ import { watch } from "../../utils/decorators/watch.js";
12
+ import {
13
+ gdsCustomElement,
14
+ html
15
+ } from "../../utils/helpers/custom-element-scoping.js";
16
+ import {
17
+ withLayoutChildProps,
18
+ withMarginProps,
19
+ withSizeXProps
20
+ } from "../../utils/mixins/declarative-layout-mixins.js";
21
+ import { GdsButton } from "../button/button.component.js";
22
+ import { GdsIconDetails } from "./details-icon/details-icon.component.js";
23
+ import { styles } from "./details.styles.js";
24
+ let GdsDetails = class extends withSizeXProps(
25
+ withMarginProps(withLayoutChildProps(GdsElement))
26
+ ) {
27
+ constructor() {
28
+ super(...arguments);
29
+ this.summary = "";
30
+ this.name = "";
31
+ this.open = false;
32
+ this.size = "large";
33
+ __privateAdd(this, _initializeContentHeight, () => {
34
+ if (!this._content)
35
+ return;
36
+ __privateGet(this, _updateContentHeight).call(this);
37
+ });
38
+ __privateAdd(this, _updateContentHeight, () => {
39
+ if (!this._content)
40
+ return;
41
+ requestAnimationFrame(() => {
42
+ this._content?.style.setProperty(
43
+ "--_max-height",
44
+ this.open ? `${this._content.scrollHeight}px` : "0"
45
+ );
46
+ });
47
+ });
48
+ __privateAdd(this, _handleToggle, () => {
49
+ this.open = !this.open;
50
+ __privateGet(this, _dispatchStateEvent).call(this);
51
+ });
52
+ __privateAdd(this, _handleKeydown, (event) => {
53
+ if (event.key === "Enter" || event.key === " ") {
54
+ event.preventDefault();
55
+ __privateGet(this, _handleToggle).call(this);
56
+ }
57
+ });
58
+ __privateAdd(this, _syncGroupState, () => {
59
+ if (!this.open || !this.name)
60
+ return;
61
+ document.querySelectorAll('[gds-element="gds-details"]').forEach((details) => {
62
+ var _a, _b;
63
+ if (details !== this && details.name === this.name) {
64
+ const other = details;
65
+ other.open = false;
66
+ __privateGet(_a = other, _updateContentHeight).call(_a);
67
+ __privateGet(_b = other, _dispatchStateEvent).call(_b);
68
+ }
69
+ });
70
+ });
71
+ __privateAdd(this, _dispatchStateEvent, () => {
72
+ this.dispatchEvent(
73
+ new CustomEvent("gds-ui-state", {
74
+ bubbles: true,
75
+ composed: true,
76
+ detail: this.open
77
+ })
78
+ );
79
+ });
80
+ __privateAdd(this, _renderHeader, () => {
81
+ return html`
82
+ <div
83
+ class="summary"
84
+ part="summary"
85
+ role="button"
86
+ tabindex="0"
87
+ @click=${__privateGet(this, _handleToggle)}
88
+ @keydown=${__privateGet(this, _handleKeydown)}
89
+ aria-expanded="${this.open}"
90
+ aria-controls="content-${this.name || "default"}"
91
+ >
92
+ <div id="summary-${this.name || "default"}" class="summary-label">
93
+ ${this.summary || "Summary"}
94
+ </div>
95
+ ${__privateGet(this, _renderIconButton).call(this)}
96
+ </div>
97
+ `;
98
+ });
99
+ __privateAdd(this, _renderIconButton, () => {
100
+ return html`
101
+ <div class="summary-icon" role="presentation" aria-hidden="true">
102
+ <gds-button
103
+ rank="tertiary"
104
+ size=${this.size === "small" ? "xs" : "medium"}
105
+ role="presentation"
106
+ tabindex="-1"
107
+ >
108
+ <gds-icon-details .open=${this.open}></gds-icon-details>
109
+ </gds-button>
110
+ </div>
111
+ `;
112
+ });
113
+ __privateAdd(this, _renderContent, () => {
114
+ return html`
115
+ <div
116
+ id="content-${this.name || "default"}"
117
+ class="content"
118
+ aria-hidden="${!this.open}"
119
+ >
120
+ <slot></slot>
121
+ </div>
122
+ `;
123
+ });
124
+ }
125
+ firstUpdated() {
126
+ __privateGet(this, _initializeContentHeight).call(this);
127
+ }
128
+ __handleOpenChange() {
129
+ __privateGet(this, _updateContentHeight).call(this);
130
+ __privateGet(this, _syncGroupState).call(this);
131
+ }
132
+ render() {
133
+ return html`
134
+ <div
135
+ class=${classMap({
136
+ details: true,
137
+ open: this.open,
138
+ small: this.size === "small"
139
+ })}
140
+ >
141
+ ${__privateGet(this, _renderHeader).call(this)} ${__privateGet(this, _renderContent).call(this)}
142
+ </div>
143
+ `;
144
+ }
145
+ };
146
+ _initializeContentHeight = new WeakMap();
147
+ _updateContentHeight = new WeakMap();
148
+ _handleToggle = new WeakMap();
149
+ _handleKeydown = new WeakMap();
150
+ _syncGroupState = new WeakMap();
151
+ _dispatchStateEvent = new WeakMap();
152
+ _renderHeader = new WeakMap();
153
+ _renderIconButton = new WeakMap();
154
+ _renderContent = new WeakMap();
155
+ GdsDetails.styles = [tokens, styles];
156
+ __decorateClass([
157
+ property({ type: String })
158
+ ], GdsDetails.prototype, "summary", 2);
159
+ __decorateClass([
160
+ property({ type: String })
161
+ ], GdsDetails.prototype, "name", 2);
162
+ __decorateClass([
163
+ property({ type: Boolean, reflect: true })
164
+ ], GdsDetails.prototype, "open", 2);
165
+ __decorateClass([
166
+ property({ type: String })
167
+ ], GdsDetails.prototype, "size", 2);
168
+ __decorateClass([
169
+ query(".content")
170
+ ], GdsDetails.prototype, "_content", 2);
171
+ __decorateClass([
172
+ query('slot[name="summary-icon-open"]')
173
+ ], GdsDetails.prototype, "_openIconSlot", 2);
174
+ __decorateClass([
175
+ query('slot[name="summary-icon-closed"]')
176
+ ], GdsDetails.prototype, "_closedIconSlot", 2);
177
+ __decorateClass([
178
+ watch("open")
179
+ ], GdsDetails.prototype, "__handleOpenChange", 1);
180
+ GdsDetails = __decorateClass([
181
+ gdsCustomElement("gds-details", { dependsOn: [GdsButton, GdsIconDetails] })
182
+ ], GdsDetails);
183
+ export {
184
+ GdsDetails
185
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsDetails } from './details.component';
2
+ export { GdsDetails };
@@ -0,0 +1,6 @@
1
+ import "../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsDetails } from "./details.component.js";
3
+ GdsDetails.define();
4
+ export {
5
+ GdsDetails
6
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,112 @@
1
+ import "../../chunks/chunk.QTSIPXV3.js";
2
+ import { css } from "lit";
3
+ const styles = css`
4
+ @layer base, reset;
5
+ @layer base {
6
+ .details {
7
+ border-bottom: solid var(--gds-space-4xs)
8
+ var(--gds-color-l2-border-primary);
9
+ font-size: var(--gds-text-size-body-m);
10
+ line-height: var(--gds-text-line-height-body-m);
11
+ color: var(--gds-color-l2-content-secondary);
12
+ transition: border-color 240ms linear;
13
+ }
14
+
15
+ .summary {
16
+ display: flex;
17
+ justify-content: space-between;
18
+ align-items: center;
19
+ list-style: none;
20
+ user-select: none;
21
+ outline-offset: var(--gds-space-2xs);
22
+ outline-color: currentColor;
23
+ transition: all 120ms;
24
+ color: var(--gds-color-l2-content-primary);
25
+ }
26
+
27
+ .summary-icon {
28
+ border-radius: var(--gds-space-max);
29
+ background-color: transparent;
30
+ transition: all 280ms;
31
+ aspect-ratio: 1;
32
+ width: max-content;
33
+ height: max-content;
34
+ line-height: 1;
35
+ }
36
+
37
+ .summary:focus {
38
+ outline-color: var(--gds-color-l3-content-tertiary);
39
+
40
+ &:not(:focus-visible) {
41
+ outline-color: transparent;
42
+ }
43
+ }
44
+
45
+ @media (pointer: fine) {
46
+ .summary:is(:hover, :focus-within) .summary-icon {
47
+ background-color: color-mix(
48
+ in srgb,
49
+ transparent,
50
+ var(--gds-color-l3-states-light-hover)
51
+ );
52
+ }
53
+
54
+ .summary:active .summary-icon {
55
+ background-color: color-mix(
56
+ in srgb,
57
+ transparent,
58
+ var(--gds-color-l3-states-light-pressed)
59
+ );
60
+ }
61
+
62
+ .details:hover,
63
+ .details:focus-within {
64
+ border-color: var(--gds-color-l2-border-quaternary);
65
+ }
66
+ }
67
+
68
+ .summary-label {
69
+ font-size: var(--gds-text-size-heading-xs);
70
+ line-height: var(--gds-text-line-height-heading-xs);
71
+ font-weight: var(--gds-text-weight-regular);
72
+ padding-block: var(--gds-space-m);
73
+ cursor: pointer;
74
+ flex: 1;
75
+ outline: none;
76
+ }
77
+
78
+ .details.small .summary-label {
79
+ font-size: var(--gds-text-size-heading-2xs);
80
+ line-height: var(--gds-text-line-height-heading-2xs);
81
+ padding-block: var(--gds-space-s);
82
+ }
83
+
84
+ .details.small .content {
85
+ font-size: var(--gds-text-size-heading-2xs);
86
+ line-height: var(--gds-text-line-height-heading-2xs);
87
+ }
88
+
89
+ .details:focus-visible {
90
+ border-radius: var(--gds-space-2xs);
91
+ }
92
+
93
+ .details.open .content {
94
+ display: flex;
95
+ padding-block-end: var(--gds-space-l);
96
+ }
97
+
98
+ .details.small.open .content {
99
+ padding-block-end: var(--gds-space-s);
100
+ }
101
+
102
+ .content {
103
+ max-height: var(--_max-height, 0);
104
+ overflow: hidden;
105
+ transition: all 240ms cubic-bezier(0.4, 0, 0.2, 1);
106
+ outline: none;
107
+ }
108
+ }
109
+ `;
110
+ export {
111
+ styles
112
+ };
@@ -0,0 +1 @@
1
+ export * from './details';
@@ -0,0 +1 @@
1
+ export * from "./details.js";