@sebgroup/green-core 1.71.2 → 1.73.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/components/datepicker/datepicker.component.d.ts +7 -2
- package/components/datepicker/datepicker.component.js +41 -32
- package/components/datepicker/datepicker.styles.js +5 -11
- package/components/details/details-icon/details-icon.component.d.ts +14 -0
- package/components/details/details-icon/details-icon.component.js +71 -0
- package/components/details/details-icon/details-icon.d.ts +2 -0
- package/components/details/details-icon/details-icon.js +6 -0
- package/components/details/details-icon/details-icon.style.d.ts +1 -0
- package/components/details/details-icon/details-icon.style.js +10 -0
- package/components/details/details.component.d.ts +45 -0
- package/components/details/details.component.js +167 -0
- package/components/details/details.d.ts +2 -0
- package/components/details/details.js +6 -0
- package/components/details/details.styles.d.ts +1 -0
- package/components/details/details.styles.js +118 -0
- package/components/details/index.d.ts +1 -0
- package/components/details/index.js +1 -0
- package/components/dropdown/dropdown.component.d.ts +9 -2
- package/components/dropdown/dropdown.component.js +24 -19
- package/components/dropdown/dropdown.styles.js +5 -25
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/input/input.component.d.ts +6 -11
- package/components/input/input.component.js +40 -40
- package/components/input/input.styles.js +1 -61
- package/components/pure.d.ts +1 -0
- package/components/pure.js +1 -0
- package/components/select/select.component.d.ts +6 -0
- package/components/select/select.component.js +36 -13
- package/components/select/select.styles.js +1 -17
- package/components/textarea/textarea.component.d.ts +6 -11
- package/components/textarea/textarea.component.js +48 -48
- package/components/textarea/textarea.styles.js +14 -58
- package/components/theme/chlorophyll-tokens.scss.js +1 -1
- package/generated/react/datepicker/index.d.ts +1 -0
- package/generated/react/details/index.d.ts +385 -0
- package/generated/react/details/index.js +13 -0
- package/generated/react/dropdown/index.d.ts +1 -0
- package/generated/react/icons/icon-details/index.d.ts +367 -0
- package/generated/react/icons/icon-details/index.js +13 -0
- package/generated/react/index.d.ts +4 -2
- package/generated/react/index.js +4 -2
- package/generated/react/input/index.d.ts +1 -1
- package/generated/react/select/index.d.ts +1 -0
- package/generated/react/textarea/index.d.ts +1 -1
- package/package.json +4 -1
- package/primitives/field-base/field-base.trans.styles.scss.js +1 -1
- package/primitives/form-control-header/form-control-header.component.js +1 -0
- package/shared-styles/form-control-host.style.d.ts +2 -0
- package/shared-styles/form-control-host.style.js +65 -0
- package/tokens/dark.css.js +1 -1
- package/tokens/light.css.js +1 -1
- package/tokens/motion.css.js +1 -1
- package/tokens/shadow.css.js +1 -1
- package/tokens/size.css.js +1 -1
- package/tokens/text.css.js +1 -1
- package/utils/helpers/custom-element-scoping.js +1 -1
|
@@ -29,6 +29,12 @@ declare class Datepicker extends GdsFormControlElement<Date> {
|
|
|
29
29
|
* Whether to use the small variant of the datepicker field.
|
|
30
30
|
*/
|
|
31
31
|
size: 'large' | 'small';
|
|
32
|
+
/**
|
|
33
|
+
* Hides the header and the footer, while still keeping the accessible label
|
|
34
|
+
*
|
|
35
|
+
* Always set the `label` attribute, and if you need to hide it, add this attribute and keep `label` set.
|
|
36
|
+
*/
|
|
37
|
+
plain: boolean;
|
|
32
38
|
/**
|
|
33
39
|
* Whether to show a column of week numbers in the calendar.
|
|
34
40
|
*/
|
|
@@ -96,10 +102,9 @@ declare const GdsDatepicker_base: (new (...args: any[]) => import("../../utils/m
|
|
|
96
102
|
*
|
|
97
103
|
* @status beta
|
|
98
104
|
*
|
|
99
|
-
* @slot supporting-text - A supporting text that will be displayed below the label and above the input field.
|
|
100
105
|
* @slot extended-supporting-text - A longer supporting text can be placed here. It will be displayed in a panel when the user clicks the info button.
|
|
101
106
|
* @slot message - ***(deprecated - use `errorMessage` property instead)*** Error message to show below the input field whem there is a validation error.
|
|
102
|
-
* @slot sub-label - ***(deprecated - use `supporting-text`
|
|
107
|
+
* @slot sub-label - ***(deprecated - use `supporting-text` property instead)*** Renders between the label and the trigger button.
|
|
103
108
|
*
|
|
104
109
|
* @event change - Fired when the value of the dropdown is changed through user interaction (not when value prop is set programatically).
|
|
105
110
|
* @event gds-ui-state - Fired when the dropdown is opened or closed.
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__privateMethod,
|
|
6
6
|
__privateSet
|
|
7
7
|
} from "../../chunks/chunk.QTSIPXV3.js";
|
|
8
|
-
var _valueOnOpen, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent, dispatchChangeEvent_fn, _dispatchInputEvent, dispatchInputEvent_fn, _handleFieldFocusOut, _handleSpinnerFocus, _handleClipboardCopy, _handleClipboardPaste, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleCalendarFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
|
|
8
|
+
var _valueOnOpen, _shouldShowFooter, shouldShowFooter_fn, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent, dispatchChangeEvent_fn, _dispatchInputEvent, dispatchInputEvent_fn, _handleFieldFocusOut, _handleSpinnerFocus, _handleClipboardCopy, _handleClipboardPaste, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleCalendarFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
|
|
9
9
|
import { localized, msg } from "@lit/localize";
|
|
10
10
|
import { nothing } from "lit";
|
|
11
11
|
import { property, query, queryAll, queryAsync, state } from "lit/decorators.js";
|
|
@@ -19,6 +19,7 @@ import { GdsButton } from "../../components/button/button.component.js";
|
|
|
19
19
|
import { GdsDropdown } from "../../components/dropdown/dropdown.component.js";
|
|
20
20
|
import { GdsFlex } from "../../components/flex/flex.component.js";
|
|
21
21
|
import { gdsCustomElement, html } from "../../scoping.js";
|
|
22
|
+
import formControlHostStyle from "../../shared-styles/form-control-host.style.js";
|
|
22
23
|
import { tokens } from "../../tokens.style.js";
|
|
23
24
|
import { TransitionalStyles } from "../../transitional-styles.js";
|
|
24
25
|
import { watch } from "../../utils/decorators/index.js";
|
|
@@ -43,6 +44,7 @@ import { styles } from "./datepicker.styles.js";
|
|
|
43
44
|
let Datepicker = class extends GdsFormControlElement {
|
|
44
45
|
constructor() {
|
|
45
46
|
super();
|
|
47
|
+
__privateAdd(this, _shouldShowFooter);
|
|
46
48
|
__privateAdd(this, _renderBackToValidRangeButton);
|
|
47
49
|
__privateAdd(this, _focusDate);
|
|
48
50
|
__privateAdd(this, _getSpinnerLabel);
|
|
@@ -64,6 +66,7 @@ let Datepicker = class extends GdsFormControlElement {
|
|
|
64
66
|
this.open = false;
|
|
65
67
|
this.supportingText = "";
|
|
66
68
|
this.size = "large";
|
|
69
|
+
this.plain = false;
|
|
67
70
|
this.showWeekNumbers = false;
|
|
68
71
|
this.hideLabel = false;
|
|
69
72
|
this.disabledWeekends = false;
|
|
@@ -273,26 +276,29 @@ let Datepicker = class extends GdsFormControlElement {
|
|
|
273
276
|
}
|
|
274
277
|
render() {
|
|
275
278
|
return html`
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
${when(
|
|
280
|
+
!this.plain,
|
|
281
|
+
() => html`<gds-form-control-header class="size-${this.size}">
|
|
282
|
+
<label id="label" for="spinner-0" slot="label">${this.label}</label>
|
|
283
|
+
${when(
|
|
284
|
+
this.supportingText.length > 0,
|
|
285
|
+
() => html`<span slot="supporting-text" id="supporting-text">
|
|
286
|
+
${this.supportingText}
|
|
287
|
+
</span>`
|
|
288
|
+
)}
|
|
289
|
+
<slot
|
|
290
|
+
id="supporting-text-slot"
|
|
291
|
+
name="extended-supporting-text"
|
|
292
|
+
slot="extended-supporting-text"
|
|
293
|
+
></slot>
|
|
294
|
+
<!-- @deprecated: use 'supporting-text' slot instead. Remove in 2.0 release. -->
|
|
295
|
+
<slot
|
|
296
|
+
id="sub-label-slot"
|
|
297
|
+
name="sub-label"
|
|
298
|
+
slot="supporting-text"
|
|
299
|
+
></slot>
|
|
300
|
+
</gds-form-control-header>`
|
|
283
301
|
)}
|
|
284
|
-
<slot
|
|
285
|
-
id="supporting-text-slot"
|
|
286
|
-
name="extended-supporting-text"
|
|
287
|
-
slot="extended-supporting-text"
|
|
288
|
-
></slot>
|
|
289
|
-
<!-- @deprecated: use 'supporting-text' slot instead. Remove in 2.0 release. -->
|
|
290
|
-
<slot
|
|
291
|
-
id="sub-label-slot"
|
|
292
|
-
name="sub-label"
|
|
293
|
-
slot="supporting-text"
|
|
294
|
-
></slot>
|
|
295
|
-
</gds-form-control-header>
|
|
296
302
|
<gds-field-base
|
|
297
303
|
.size=${this.size}
|
|
298
304
|
.disabled=${this.disabled}
|
|
@@ -315,7 +321,7 @@ let Datepicker = class extends GdsFormControlElement {
|
|
|
315
321
|
aria-valuemin=${__privateMethod(this, _getMinSpinnerValue, getMinSpinnerValue_fn).call(this, f.name)}
|
|
316
322
|
aria-valuemax=${__privateMethod(this, _getMaxSpinnerValue, getMaxSpinnerValue_fn).call(this, f.name)}
|
|
317
323
|
aria-label=${__privateMethod(this, _getSpinnerLabel, getSpinnerLabel_fn).call(this, f.name)}
|
|
318
|
-
aria-describedby="
|
|
324
|
+
aria-describedby="supporting-text supporting-text-slot sub-label-slot message"
|
|
319
325
|
data-max-width=${__privateMethod(this, _getMaxSpinnerValue, getMaxSpinnerValue_fn).call(this, f.name).toString().length}
|
|
320
326
|
@keydown=${__privateGet(this, _handleSpinnerKeydown)}
|
|
321
327
|
@change=${(e) => __privateGet(this, _handleSpinnerChange).call(this, e.detail.value, f.name)}
|
|
@@ -355,22 +361,18 @@ let Datepicker = class extends GdsFormControlElement {
|
|
|
355
361
|
</gds-button>
|
|
356
362
|
</gds-field-base>
|
|
357
363
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
this.
|
|
361
|
-
|
|
362
|
-
// Wrapped in a slot for backwards compatibility with the deprecated message slot
|
|
363
|
-
// Remove for 2.0 release
|
|
364
|
-
() => html`
|
|
364
|
+
${when(
|
|
365
|
+
__privateMethod(this, _shouldShowFooter, shouldShowFooter_fn).call(this),
|
|
366
|
+
() => html`<gds-form-control-footer class="size-${this.size}">
|
|
367
|
+
${``}
|
|
365
368
|
<slot id="message" name="message" slot="message">
|
|
366
369
|
<gds-icon-triangle-exclamation
|
|
367
370
|
solid
|
|
368
371
|
></gds-icon-triangle-exclamation>
|
|
369
372
|
${this.errorMessage || this.validationMessage}
|
|
370
373
|
</slot>
|
|
371
|
-
|
|
374
|
+
</gds-form-control-footer>`
|
|
372
375
|
)}
|
|
373
|
-
</gds-form-control-footer>
|
|
374
376
|
|
|
375
377
|
<gds-popover
|
|
376
378
|
autofocus
|
|
@@ -529,6 +531,10 @@ let Datepicker = class extends GdsFormControlElement {
|
|
|
529
531
|
}
|
|
530
532
|
};
|
|
531
533
|
_valueOnOpen = new WeakMap();
|
|
534
|
+
_shouldShowFooter = new WeakSet();
|
|
535
|
+
shouldShowFooter_fn = function() {
|
|
536
|
+
return !this.plain && this.invalid;
|
|
537
|
+
};
|
|
532
538
|
_renderBackToValidRangeButton = new WeakSet();
|
|
533
539
|
renderBackToValidRangeButton_fn = async function() {
|
|
534
540
|
const focusedDate = await this.getFocusedDate();
|
|
@@ -567,7 +573,7 @@ getSpinnerLabel_fn = function(name) {
|
|
|
567
573
|
month: msg("Month"),
|
|
568
574
|
day: msg("Day")
|
|
569
575
|
};
|
|
570
|
-
return labels[name]
|
|
576
|
+
return `${labels[name]} ${this.label}`;
|
|
571
577
|
};
|
|
572
578
|
_getMinSpinnerValue = new WeakSet();
|
|
573
579
|
getMinSpinnerValue_fn = function(name) {
|
|
@@ -655,7 +661,7 @@ isValueOutsideRange_get = function() {
|
|
|
655
661
|
return false;
|
|
656
662
|
return this.value.getFullYear() < this.min.getFullYear() || this.value.getFullYear() > this.max.getFullYear();
|
|
657
663
|
};
|
|
658
|
-
Datepicker.styles = [tokens, styles];
|
|
664
|
+
Datepicker.styles = [tokens, formControlHostStyle, styles];
|
|
659
665
|
__decorateClass([
|
|
660
666
|
property({ converter: dateConverter })
|
|
661
667
|
], Datepicker.prototype, "value", 1);
|
|
@@ -674,6 +680,9 @@ __decorateClass([
|
|
|
674
680
|
__decorateClass([
|
|
675
681
|
property({ type: String })
|
|
676
682
|
], Datepicker.prototype, "size", 2);
|
|
683
|
+
__decorateClass([
|
|
684
|
+
property({ type: Boolean })
|
|
685
|
+
], Datepicker.prototype, "plain", 2);
|
|
677
686
|
__decorateClass([
|
|
678
687
|
property({ type: Boolean, attribute: "show-week-numbers" })
|
|
679
688
|
], Datepicker.prototype, "showWeekNumbers", 2);
|
|
@@ -4,17 +4,6 @@ const styles = css`
|
|
|
4
4
|
@layer base, reset;
|
|
5
5
|
|
|
6
6
|
@layer base {
|
|
7
|
-
:host {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
width: 100%;
|
|
11
|
-
contain: layout;
|
|
12
|
-
isolation: isolate;
|
|
13
|
-
gap: var(--gds-space-xs);
|
|
14
|
-
font-family: inherit;
|
|
15
|
-
min-width: 200px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
7
|
::part(_button) {
|
|
19
8
|
outline-offset: -1px;
|
|
20
9
|
}
|
|
@@ -29,6 +18,11 @@ const styles = css`
|
|
|
29
18
|
font-weight: var(--gds-text-weight-regular);
|
|
30
19
|
}
|
|
31
20
|
|
|
21
|
+
:host([size='small']) .spinners {
|
|
22
|
+
font-size: var(--gds-text-size-detail-s);
|
|
23
|
+
line-height: var(--gds-text-line-height-detail-s);
|
|
24
|
+
}
|
|
25
|
+
|
|
32
26
|
.spinner {
|
|
33
27
|
display: flex;
|
|
34
28
|
align-items: center;
|
|
@@ -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 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
private __handleOpenChange;
|
|
43
|
+
render(): any;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__privateAdd,
|
|
4
|
+
__privateGet
|
|
5
|
+
} from "../../chunks/chunk.QTSIPXV3.js";
|
|
6
|
+
var _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, _handleToggle, () => {
|
|
34
|
+
this.open = !this.open;
|
|
35
|
+
__privateGet(this, _dispatchStateEvent).call(this);
|
|
36
|
+
});
|
|
37
|
+
__privateAdd(this, _handleKeydown, (event) => {
|
|
38
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
__privateGet(this, _handleToggle).call(this);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
__privateAdd(this, _syncGroupState, () => {
|
|
44
|
+
if (!this.open || !this.name)
|
|
45
|
+
return;
|
|
46
|
+
document.querySelectorAll('[gds-element="gds-details"]').forEach((details) => {
|
|
47
|
+
var _a;
|
|
48
|
+
if (details !== this && details.name === this.name) {
|
|
49
|
+
const other = details;
|
|
50
|
+
other.open = false;
|
|
51
|
+
__privateGet(_a = other, _dispatchStateEvent).call(_a);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
__privateAdd(this, _dispatchStateEvent, () => {
|
|
56
|
+
this.dispatchEvent(
|
|
57
|
+
new CustomEvent("gds-ui-state", {
|
|
58
|
+
bubbles: true,
|
|
59
|
+
composed: true,
|
|
60
|
+
detail: this.open
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
__privateAdd(this, _renderHeader, () => {
|
|
65
|
+
return html`
|
|
66
|
+
<div
|
|
67
|
+
class="summary"
|
|
68
|
+
part="summary"
|
|
69
|
+
role="button"
|
|
70
|
+
tabindex="0"
|
|
71
|
+
@click=${__privateGet(this, _handleToggle)}
|
|
72
|
+
@keydown=${__privateGet(this, _handleKeydown)}
|
|
73
|
+
aria-expanded="${this.open}"
|
|
74
|
+
aria-controls="content-${this.name || "default"}"
|
|
75
|
+
>
|
|
76
|
+
<div id="summary-${this.name || "default"}" class="summary-label">
|
|
77
|
+
${this.summary || "Summary"}
|
|
78
|
+
</div>
|
|
79
|
+
${__privateGet(this, _renderIconButton).call(this)}
|
|
80
|
+
</div>
|
|
81
|
+
`;
|
|
82
|
+
});
|
|
83
|
+
__privateAdd(this, _renderIconButton, () => {
|
|
84
|
+
return html`
|
|
85
|
+
<div class="summary-icon" role="presentation" aria-hidden="true">
|
|
86
|
+
<gds-button
|
|
87
|
+
rank="tertiary"
|
|
88
|
+
size=${this.size === "small" ? "xs" : "medium"}
|
|
89
|
+
role="presentation"
|
|
90
|
+
tabindex="-1"
|
|
91
|
+
>
|
|
92
|
+
<gds-icon-details .open=${this.open}></gds-icon-details>
|
|
93
|
+
</gds-button>
|
|
94
|
+
</div>
|
|
95
|
+
`;
|
|
96
|
+
});
|
|
97
|
+
__privateAdd(this, _renderContent, () => {
|
|
98
|
+
return html`
|
|
99
|
+
<div
|
|
100
|
+
id="content-${this.name || "default"}"
|
|
101
|
+
class=${classMap({
|
|
102
|
+
content: true,
|
|
103
|
+
open: this.open,
|
|
104
|
+
small: this.size === "small"
|
|
105
|
+
})}
|
|
106
|
+
aria-hidden="${!this.open}"
|
|
107
|
+
>
|
|
108
|
+
<slot></slot>
|
|
109
|
+
</div>
|
|
110
|
+
`;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
__handleOpenChange() {
|
|
114
|
+
__privateGet(this, _syncGroupState).call(this);
|
|
115
|
+
}
|
|
116
|
+
render() {
|
|
117
|
+
return html`
|
|
118
|
+
<div
|
|
119
|
+
class=${classMap({
|
|
120
|
+
details: true,
|
|
121
|
+
open: this.open,
|
|
122
|
+
small: this.size === "small"
|
|
123
|
+
})}
|
|
124
|
+
>
|
|
125
|
+
${__privateGet(this, _renderHeader).call(this)} ${__privateGet(this, _renderContent).call(this)}
|
|
126
|
+
</div>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
_handleToggle = new WeakMap();
|
|
131
|
+
_handleKeydown = new WeakMap();
|
|
132
|
+
_syncGroupState = new WeakMap();
|
|
133
|
+
_dispatchStateEvent = new WeakMap();
|
|
134
|
+
_renderHeader = new WeakMap();
|
|
135
|
+
_renderIconButton = new WeakMap();
|
|
136
|
+
_renderContent = new WeakMap();
|
|
137
|
+
GdsDetails.styles = [tokens, styles];
|
|
138
|
+
__decorateClass([
|
|
139
|
+
property({ type: String })
|
|
140
|
+
], GdsDetails.prototype, "summary", 2);
|
|
141
|
+
__decorateClass([
|
|
142
|
+
property({ type: String })
|
|
143
|
+
], GdsDetails.prototype, "name", 2);
|
|
144
|
+
__decorateClass([
|
|
145
|
+
property({ type: Boolean, reflect: true })
|
|
146
|
+
], GdsDetails.prototype, "open", 2);
|
|
147
|
+
__decorateClass([
|
|
148
|
+
property({ type: String })
|
|
149
|
+
], GdsDetails.prototype, "size", 2);
|
|
150
|
+
__decorateClass([
|
|
151
|
+
query(".content")
|
|
152
|
+
], GdsDetails.prototype, "_content", 2);
|
|
153
|
+
__decorateClass([
|
|
154
|
+
query('slot[name="summary-icon-open"]')
|
|
155
|
+
], GdsDetails.prototype, "_openIconSlot", 2);
|
|
156
|
+
__decorateClass([
|
|
157
|
+
query('slot[name="summary-icon-closed"]')
|
|
158
|
+
], GdsDetails.prototype, "_closedIconSlot", 2);
|
|
159
|
+
__decorateClass([
|
|
160
|
+
watch("open")
|
|
161
|
+
], GdsDetails.prototype, "__handleOpenChange", 1);
|
|
162
|
+
GdsDetails = __decorateClass([
|
|
163
|
+
gdsCustomElement("gds-details", { dependsOn: [GdsButton, GdsIconDetails] })
|
|
164
|
+
], GdsDetails);
|
|
165
|
+
export {
|
|
166
|
+
GdsDetails
|
|
167
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
padding-block-end: var(--gds-space-l);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.details.small.open .content {
|
|
98
|
+
padding-block-end: var(--gds-space-s);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.content {
|
|
102
|
+
interpolate-size: allow-keywords;
|
|
103
|
+
height: 0;
|
|
104
|
+
transition: height 0.35s ease;
|
|
105
|
+
overflow-y: clip;
|
|
106
|
+
outline: none;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.content.open {
|
|
110
|
+
height: max-content;
|
|
111
|
+
max-height: 100vh;
|
|
112
|
+
overflow-y: auto;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
export {
|
|
117
|
+
styles
|
|
118
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './details';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./details.js";
|