@eunomia/elements 1.0.0-beta.4 → 1.0.0-beta.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.
- package/dist/cdn/components/chunks/{chunk-SIHZFOTK.js → chunk-2XASWWKR.js} +1 -1
- package/dist/cdn/components/chunks/chunk-32DTNR52.js +1 -0
- package/dist/cdn/components/chunks/chunk-3MTUVMM5.js +1 -0
- package/dist/cdn/components/chunks/chunk-5GKM5DIB.js +1 -0
- package/dist/cdn/components/chunks/{chunk-GSJEJLFA.js → chunk-6ETDXUH2.js} +1 -1
- package/dist/cdn/components/chunks/{chunk-EJIX2D4Z.js → chunk-AIS3UICU.js} +7 -7
- package/dist/cdn/components/chunks/{chunk-BMQOI7HX.js → chunk-DKOPI7QA.js} +99 -55
- package/dist/cdn/components/chunks/{chunk-NHFWATVN.js → chunk-EAKYD33D.js} +3 -3
- package/dist/cdn/components/chunks/{chunk-EOWBYZV7.js → chunk-IDKZKLJR.js} +5 -5
- package/dist/cdn/components/chunks/chunk-JRGM3W7I.js +53 -0
- package/dist/cdn/components/chunks/{chunk-UAGCQF23.js → chunk-L65WUTXM.js} +5 -5
- package/dist/cdn/components/chunks/chunk-LFCXUVDO.js +1 -0
- package/dist/cdn/components/chunks/{chunk-YGUJJ25C.js → chunk-MPQP4R54.js} +2 -2
- package/dist/cdn/components/chunks/{chunk-RJCJXB7Y.js → chunk-NBIENHLV.js} +1 -1
- package/dist/cdn/components/chunks/{chunk-4MXL6PZC.js → chunk-OW7XKDCH.js} +13 -13
- package/dist/cdn/components/chunks/{chunk-IJ5WFMK4.js → chunk-SD2WHGPF.js} +7 -6
- package/dist/cdn/components/chunks/chunk-SJWRE6PW.js +1 -0
- package/dist/cdn/components/eun-animate.js +5 -3
- package/dist/cdn/components/eun-badge.js +7 -7
- package/dist/cdn/components/eun-breadcrumb-item.js +1 -1
- package/dist/cdn/components/eun-breadcrumb.js +1 -1
- package/dist/cdn/components/eun-button.js +1 -1
- package/dist/cdn/components/eun-calendar.js +13 -13
- package/dist/cdn/components/eun-card.js +42 -3
- package/dist/cdn/components/eun-carousel.js +2 -2
- package/dist/cdn/components/eun-check-card.js +1 -1
- package/dist/cdn/components/eun-checkbox-list.js +1 -1
- package/dist/cdn/components/eun-checkbox.js +1 -1
- package/dist/cdn/components/eun-chip.js +1 -1
- package/dist/cdn/components/eun-collapse.js +39 -20
- package/dist/cdn/components/eun-color-picker.js +3 -3
- package/dist/cdn/components/eun-counter.js +8 -8
- package/dist/cdn/components/eun-date-picker.js +19 -19
- package/dist/cdn/components/eun-drawer.js +9 -9
- package/dist/cdn/components/eun-dropdown-button.js +1 -1
- package/dist/cdn/components/eun-fab.js +6 -6
- package/dist/cdn/components/eun-icon.js +1 -1
- package/dist/cdn/components/eun-image-card.js +1 -1
- package/dist/cdn/components/eun-image-carousel.js +3 -3
- package/dist/cdn/components/eun-input-file.js +1 -1
- package/dist/cdn/components/eun-input-phone.js +18 -18
- package/dist/cdn/components/eun-input.js +1 -1
- package/dist/cdn/components/eun-link.js +116 -18
- package/dist/cdn/components/eun-modal.js +15 -15
- package/dist/cdn/components/eun-radio-card.js +1 -1
- package/dist/cdn/components/eun-radio-list.js +1 -1
- package/dist/cdn/components/eun-radio.js +1 -1
- package/dist/cdn/components/eun-scheduler-event-editor.js +7 -7
- package/dist/cdn/components/eun-scheduler-event.js +1 -1
- package/dist/cdn/components/eun-scheduler.js +18 -18
- package/dist/cdn/components/eun-search.js +15 -15
- package/dist/cdn/components/eun-select.js +2 -2
- package/dist/cdn/components/eun-slider.js +1 -1
- package/dist/cdn/components/eun-sliding-card.js +1 -1
- package/dist/cdn/components/eun-switch.js +1 -1
- package/dist/cdn/components/eun-tab-group.js +1 -1
- package/dist/cdn/components/eun-tab.js +1 -1
- package/dist/cdn/components/eun-table-action-bar.js +1 -1
- package/dist/cdn/components/eun-table.js +1 -1
- package/dist/cdn/components/eun-textarea.js +2 -2
- package/dist/cdn/components/eun-time-picker.js +11 -11
- package/dist/cdn/components/eun-toggle-group.js +30 -22
- package/dist/cdn/components/eun-toggle-item.js +10 -8
- package/dist/cdn/components/eun-toggle.js +1 -1
- package/dist/cdn/components/eun-toolbar.js +1 -1
- package/dist/components/action/button/button.d.ts +44 -17
- package/dist/components/action/button/button.js +100 -22
- package/dist/components/action/button/button.styles.js +77 -39
- package/dist/components/action/dropdown-button/dropdown-button.d.ts +8 -8
- package/dist/components/action/dropdown-button/dropdown-button.js +7 -7
- package/dist/components/action/fab/fab.d.ts +7 -6
- package/dist/components/action/fab/fab.js +11 -8
- package/dist/components/action/fab/fab.styles.js +4 -4
- package/dist/components/action/link/link.d.ts +65 -6
- package/dist/components/action/link/link.js +176 -20
- package/dist/components/action/link/link.styles.js +86 -1
- package/dist/components/action/shared-styles/button-palette.styles.d.ts +3 -3
- package/dist/components/action/shared-styles/button-palette.styles.js +14 -14
- package/dist/components/action/toggle/toggle-group.d.ts +15 -5
- package/dist/components/action/toggle/toggle-group.js +42 -17
- package/dist/components/action/toggle/toggle-group.styles.d.ts +2 -1
- package/dist/components/action/toggle/toggle-group.styles.js +15 -7
- package/dist/components/action/toggle/toggle-item.d.ts +4 -4
- package/dist/components/action/toggle/toggle-item.js +2 -2
- package/dist/components/action/toggle/toggle-item.styles.js +8 -6
- package/dist/components/alert/drawer/drawer.js +1 -1
- package/dist/components/alert/modal/modal.d.ts +8 -8
- package/dist/components/alert/modal/modal.js +11 -11
- package/dist/components/content/badge/badge.d.ts +6 -6
- package/dist/components/content/badge/badge.js +4 -4
- package/dist/components/content/badge/badge.styles.js +4 -4
- package/dist/components/content/card/card.d.ts +32 -4
- package/dist/components/content/card/card.js +64 -4
- package/dist/components/content/card/card.styles.js +33 -1
- package/dist/components/content/card/image-card.d.ts +2 -1
- package/dist/components/content/card/image-card.js +1 -0
- package/dist/components/content/card/sliding-card.d.ts +2 -1
- package/dist/components/content/card/sliding-card.js +1 -0
- package/dist/components/content/collapse/collapse.d.ts +29 -11
- package/dist/components/content/collapse/collapse.js +53 -23
- package/dist/components/content/collapse/collapse.styles.js +13 -0
- package/dist/components/content/icon/icon.d.ts +12 -2
- package/dist/components/content/icon/icon.js +52 -22
- package/dist/components/content/icon/icon.style.d.ts +2 -0
- package/dist/components/content/icon/icon.style.js +4 -1
- package/dist/components/content/shared-styles/card-link.styles.js +1 -0
- package/dist/components/form/color-picker/color-picker.d.ts +3 -3
- package/dist/components/form/color-picker/color-picker.js +4 -4
- package/dist/components/form/counter/counter.d.ts +3 -3
- package/dist/components/form/counter/counter.js +3 -3
- package/dist/components/form/counter/counter.styles.js +5 -5
- package/dist/components/form/date-picker/date-picker.d.ts +3 -3
- package/dist/components/form/date-picker/date-picker.js +3 -3
- package/dist/components/form/date-picker/date-picker.styles.js +5 -5
- package/dist/components/form/input/input.d.ts +3 -3
- package/dist/components/form/input/input.js +4 -4
- package/dist/components/form/input-phone/input-phone.d.ts +3 -3
- package/dist/components/form/input-phone/input-phone.js +3 -3
- package/dist/components/form/input-phone/input-phone.styles.js +12 -12
- package/dist/components/form/search/search.styles.js +3 -3
- package/dist/components/form/select/select.d.ts +3 -3
- package/dist/components/form/select/select.js +3 -3
- package/dist/components/form/shared-styles/field.styles.js +5 -5
- package/dist/components/form/textarea/textarea.d.ts +3 -3
- package/dist/components/form/textarea/textarea.js +4 -4
- package/dist/components/form/time-picker/time-picker.d.ts +3 -3
- package/dist/components/form/time-picker/time-picker.js +3 -3
- package/dist/components/form/time-picker/time-picker.styles.js +5 -5
- package/dist/components/layout/animate/animate.d.ts +8 -0
- package/dist/components/layout/animate/animate.js +20 -8
- package/dist/features/scheduler/calendar/calendar.d.ts +6 -6
- package/dist/features/scheduler/calendar/calendar.js +9 -9
- package/dist/features/scheduler/scheduler/scheduler.d.ts +6 -6
- package/dist/features/scheduler/scheduler/scheduler.js +13 -13
- package/dist/features/scheduler/scheduler-event/scheduler-event.d.ts +10 -8
- package/dist/features/scheduler/scheduler-event/scheduler-event.js +7 -7
- package/dist/features/scheduler/scheduler-event/scheduler-event.styles.js +6 -6
- package/dist/features/scheduler/scheduler-event-editor/scheduler-event-editor.js +5 -5
- package/dist/features/scheduler/shared/scheduler-event-popover.js +2 -2
- package/dist/features/scheduler/shared/scheduler-hour-grid.d.ts +2 -2
- package/dist/features/scheduler/shared/scheduler-hour-grid.js +3 -3
- package/dist/features/scheduler/shared/scheduler-month-view.d.ts +3 -3
- package/dist/features/scheduler/shared/scheduler-month-view.js +2 -2
- package/dist/features/table/table/table.types.d.ts +7 -3
- package/dist/features/table/table-action-bar/table-action-bar.js +3 -3
- package/dist/features/table/table-managed/table-managed.js +2 -2
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.js +3 -0
- package/dist/i18n/fr.js +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/jsx.d.ts +1 -1
- package/dist/mixins/button.mixin.d.ts +10 -9
- package/dist/mixins/button.mixin.js +14 -6
- package/dist/mixins/card-link.mixin.d.ts +3 -2
- package/dist/mixins/card-link.mixin.js +12 -5
- package/dist/mixins/disabled.mixin.d.ts +3 -3
- package/dist/mixins/disabled.mixin.js +10 -5
- package/dist/mixins/field-appearance.mixin.d.ts +19 -0
- package/dist/mixins/{field-variant.mixin.js → field-appearance.mixin.js} +11 -11
- package/dist/ssr/animate-ssr.css +26 -72
- package/dist/ssr/links-ssr.css +35 -0
- package/dist/ssr/overlay-ssr.css +0 -41
- package/dist/ssr/rich-text.css +38 -0
- package/dist/ssr/sidebar-ssr.css +0 -38
- package/dist/ssr/toolbar-ssr.css +73 -39
- package/dist/types/variant.type.d.ts +26 -10
- package/dist/utils/navigation.utils.d.ts +14 -0
- package/dist/utils/navigation.utils.js +33 -0
- package/dist/utils/new-tab-anchor.controller.d.ts +44 -0
- package/dist/utils/new-tab-anchor.controller.js +102 -0
- package/dist/utils/severity-icon.utils.d.ts +1 -1
- package/dist/utils/severity-icon.utils.js +1 -1
- package/dist/utils/theme-generator.utils.d.ts +3 -1
- package/dist/utils/theme-generator.utils.js +3 -1
- package/package.json +8 -2
- package/dist/cdn/components/chunks/chunk-2JLDJFYD.js +0 -48
- package/dist/cdn/components/chunks/chunk-ATH2OAMU.js +0 -1
- package/dist/cdn/components/chunks/chunk-BKHD4S57.js +0 -1
- package/dist/cdn/components/chunks/chunk-T7WABJEJ.js +0 -1
- package/dist/cdn/components/chunks/chunk-XSMCT4DF.js +0 -1
- package/dist/mixins/field-variant.mixin.d.ts +0 -22
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LitElement, PropertyValues, TemplateResult } from "lit";
|
|
2
|
-
import {
|
|
2
|
+
import { EunomiaActionColor, EunomiaCompactSize } from "../../../types/variant.type.js";
|
|
3
3
|
/**
|
|
4
4
|
* Tag name of the badge component.
|
|
5
5
|
*/
|
|
6
6
|
export declare const EunomiaBadgeTagName = "eun-badge";
|
|
7
7
|
/**
|
|
8
|
-
* All available badge
|
|
8
|
+
* All available badge colors.
|
|
9
9
|
*/
|
|
10
|
-
export type
|
|
10
|
+
export type EunomiaBadgeColor = EunomiaActionColor;
|
|
11
11
|
/**
|
|
12
12
|
* All available badge sizes.
|
|
13
13
|
*/
|
|
@@ -23,7 +23,7 @@ export type EunomiaBadgeSize = EunomiaCompactSize;
|
|
|
23
23
|
*
|
|
24
24
|
* @slot [default] - The badge's content, typically a short number. Left empty, the badge renders as a plain dot
|
|
25
25
|
* @csspart badge - The badge's own box, carrying its size, padding, and background. Exposed for effects the badge's CSS custom properties don't cover
|
|
26
|
-
* @prop {'primary' | 'secondary' | 'critical' | 'success' | 'warning'} [
|
|
26
|
+
* @prop {'primary' | 'secondary' | 'critical' | 'success' | 'warning'} [color='critical'] - The color to apply
|
|
27
27
|
* @prop {'s' | 'm' | 'l'} [size='m'] - The size of the badge
|
|
28
28
|
* @prop {string} label - An optional accessible name. When set, the badge announces this text instead of staying hidden from assistive technology
|
|
29
29
|
* @cssprop [--badge-background] - Sets the background color of the badge
|
|
@@ -43,10 +43,10 @@ export declare class EunomiaBadge extends LitElement {
|
|
|
43
43
|
*/
|
|
44
44
|
static readonly styles: import("lit").CSSResult;
|
|
45
45
|
/**
|
|
46
|
-
* The color
|
|
46
|
+
* The color to apply.
|
|
47
47
|
* @default critical
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
color: EunomiaBadgeColor;
|
|
50
50
|
/**
|
|
51
51
|
* The size of the badge.
|
|
52
52
|
* @default m
|
|
@@ -22,7 +22,7 @@ export const EunomiaBadgeTagName = "eun-badge";
|
|
|
22
22
|
*
|
|
23
23
|
* @slot [default] - The badge's content, typically a short number. Left empty, the badge renders as a plain dot
|
|
24
24
|
* @csspart badge - The badge's own box, carrying its size, padding, and background. Exposed for effects the badge's CSS custom properties don't cover
|
|
25
|
-
* @prop {'primary' | 'secondary' | 'critical' | 'success' | 'warning'} [
|
|
25
|
+
* @prop {'primary' | 'secondary' | 'critical' | 'success' | 'warning'} [color='critical'] - The color to apply
|
|
26
26
|
* @prop {'s' | 'm' | 'l'} [size='m'] - The size of the badge
|
|
27
27
|
* @prop {string} label - An optional accessible name. When set, the badge announces this text instead of staying hidden from assistive technology
|
|
28
28
|
* @cssprop [--badge-background] - Sets the background color of the badge
|
|
@@ -36,10 +36,10 @@ let EunomiaBadge = class EunomiaBadge extends LitElement {
|
|
|
36
36
|
constructor() {
|
|
37
37
|
super(...arguments);
|
|
38
38
|
/**
|
|
39
|
-
* The color
|
|
39
|
+
* The color to apply.
|
|
40
40
|
* @default critical
|
|
41
41
|
*/
|
|
42
|
-
this.
|
|
42
|
+
this.color = "critical";
|
|
43
43
|
/**
|
|
44
44
|
* The size of the badge.
|
|
45
45
|
* @default m
|
|
@@ -129,7 +129,7 @@ let EunomiaBadge = class EunomiaBadge extends LitElement {
|
|
|
129
129
|
EunomiaBadge.styles = badgeStyles;
|
|
130
130
|
__decorate([
|
|
131
131
|
property({ reflect: true })
|
|
132
|
-
], EunomiaBadge.prototype, "
|
|
132
|
+
], EunomiaBadge.prototype, "color", void 0);
|
|
133
133
|
__decorate([
|
|
134
134
|
property({ reflect: true })
|
|
135
135
|
], EunomiaBadge.prototype, "size", void 0);
|
|
@@ -69,7 +69,7 @@ const base = css `
|
|
|
69
69
|
--_fontSize: var(--badge-font-size, 12px);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
:host([
|
|
72
|
+
:host([color="primary"]) {
|
|
73
73
|
--_background: var(
|
|
74
74
|
--badge-background,
|
|
75
75
|
var(--eun-color-primary-500, #3d6fff)
|
|
@@ -77,7 +77,7 @@ const base = css `
|
|
|
77
77
|
--_color: var(--badge-color, var(--eun-color-on-primary-500, #ffffff));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
:host([
|
|
80
|
+
:host([color="secondary"]) {
|
|
81
81
|
--_background: var(
|
|
82
82
|
--badge-background,
|
|
83
83
|
var(--eun-color-secondary-500, #e5a030)
|
|
@@ -85,7 +85,7 @@ const base = css `
|
|
|
85
85
|
--_color: var(--badge-color, var(--eun-color-on-secondary-500, #000000de));
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
:host([
|
|
88
|
+
:host([color="success"]) {
|
|
89
89
|
--_background: var(
|
|
90
90
|
--badge-background,
|
|
91
91
|
var(--eun-color-success-100, #1a9948)
|
|
@@ -93,7 +93,7 @@ const base = css `
|
|
|
93
93
|
--_color: var(--badge-color, #fff);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
:host([
|
|
96
|
+
:host([color="warning"]) {
|
|
97
97
|
--_background: var(
|
|
98
98
|
--badge-background,
|
|
99
99
|
var(--eun-color-warning-100, #c85207)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { LitElement, TemplateResult } from "lit";
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from "lit";
|
|
2
2
|
import { EunomiaCardAppearance } from "../../../types/variant.type.js";
|
|
3
3
|
/**
|
|
4
4
|
* Tag name of the card component.
|
|
5
5
|
*/
|
|
6
6
|
export declare const EunomiaCardTagName = "eun-card";
|
|
7
|
-
declare const EunomiaCard_base: import("../../../utils/constructor.type.js").Constructor<import("../../../mixins/card-link.mixin.js").CardLinkMixinInterface> & typeof LitElement;
|
|
7
|
+
declare const EunomiaCard_base: import("../../../utils/constructor.type.js").Constructor<import("../../../mixins/card-link.mixin.js").CardLinkMixinInterface & import("../../../mixins/localizable.mixin.js").LocalizableMixinInterface> & typeof LitElement;
|
|
8
8
|
/**
|
|
9
9
|
* A padded, bordered surface around whatever's slotted in, with nothing
|
|
10
10
|
* else opinionated about the content : no dedicated slots, no forced
|
|
@@ -17,11 +17,19 @@ declare const EunomiaCard_base: import("../../../utils/constructor.type.js").Con
|
|
|
17
17
|
* slotting your own markup, styled with your own CSS, rather than
|
|
18
18
|
* reaching for a layout variant baked into the component.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* Without href, a native anchor placed as a direct child links the whole
|
|
21
|
+
* card instead, stretched over its surface, so the link exists in the
|
|
22
|
+
* server-rendered HTML and can be a framework's own link component. Its
|
|
23
|
+
* accessible name stays the anchor's own text, typically the card title.
|
|
24
|
+
* When it opens in a new tab, the card shows the same external link badge
|
|
25
|
+
* and announces it through the anchor's aria-description.
|
|
26
|
+
*
|
|
27
|
+
* @slot [default] - The card's content, arranged in a column by `--card-gap`. A native anchor as a direct child links the whole card when href is unset
|
|
21
28
|
* @csspart card - The outer box, a link once href is set, a plain container otherwise. Exposed for effects the card's CSS custom properties don't cover, such as a hover accent
|
|
22
29
|
* @prop {'default' | 'fill' | 'raised'} [appearance='default'] - The card's surface style. Default is a plain surface colored box with a border. Fill and raised both drop the border, fill for a muted tinted background and raised for a drop shadow. All three animate a border, tint, or shadow change on hover or focus regardless of whether the card is a link, though the accompanying lift is narrower
|
|
23
30
|
* @prop {string} href - The URL the card navigates to. When set, the card renders as a link instead of a plain wrapper
|
|
24
|
-
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology
|
|
31
|
+
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology, in the current locale
|
|
32
|
+
* @prop {string} [locale] - The locale used to resolve the "opens in a new tab" announcement. Defaults to the one set with setDefaultLocale, English otherwise
|
|
25
33
|
* @prop {string} download - The filename used when the linked URL is downloaded instead of navigated to. Only used when href is set
|
|
26
34
|
* @attr {string} aria-label - An accessible label that overrides the card content. When the card also opens in a new tab, a note announcing it is appended automatically
|
|
27
35
|
* @fires {NavigationEvent} eunnavigate - Fired before following href, so a client-side router can intercept the navigation. Not fired for downloads, and cancelable
|
|
@@ -48,6 +56,7 @@ declare const EunomiaCard_base: import("../../../utils/constructor.type.js").Con
|
|
|
48
56
|
* @element eun-card
|
|
49
57
|
*/
|
|
50
58
|
export declare class EunomiaCard extends EunomiaCard_base {
|
|
59
|
+
#private;
|
|
51
60
|
/**
|
|
52
61
|
* Styles to import to the component.
|
|
53
62
|
*
|
|
@@ -61,6 +70,25 @@ export declare class EunomiaCard extends EunomiaCard_base {
|
|
|
61
70
|
* @default default
|
|
62
71
|
*/
|
|
63
72
|
appearance: EunomiaCardAppearance;
|
|
73
|
+
/**
|
|
74
|
+
* Whether a native `<a>` slotted as a direct child links the card while
|
|
75
|
+
* `href` is unset (see the class doc). Navigation, `target`/`rel` and
|
|
76
|
+
* the new-tab hint are the consumer's own in this mode.
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
private get hasSlottedAnchor();
|
|
80
|
+
/**
|
|
81
|
+
* The native `<a>` slotted as a direct child while `href` is unset.
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
private get slottedAnchor();
|
|
85
|
+
/**
|
|
86
|
+
* Re-renders when the default slot changes, so an anchor added or removed
|
|
87
|
+
* after the first render switches between the two modes.
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
private handleSlotChange;
|
|
91
|
+
protected updated(changed: PropertyValues): void;
|
|
64
92
|
render(): TemplateResult;
|
|
65
93
|
}
|
|
66
94
|
declare global {
|
|
@@ -4,9 +4,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _EunomiaCard_newTab;
|
|
7
13
|
import { customElement, property } from "lit/decorators.js";
|
|
8
14
|
import { html, LitElement } from "lit";
|
|
15
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
9
16
|
import { CardLinkMixin } from "../../../mixins/card-link.mixin.js";
|
|
17
|
+
import { warnIgnoredHostLinkAttributes } from "../../../utils/navigation.utils.js";
|
|
18
|
+
import { NewTabAnchorController } from "../../../utils/new-tab-anchor.controller.js";
|
|
10
19
|
import { cardStyles } from "./card.styles.js";
|
|
11
20
|
import { cardLinkStyles } from "../shared-styles/card-link.styles.js";
|
|
12
21
|
/**
|
|
@@ -25,11 +34,19 @@ export const EunomiaCardTagName = "eun-card";
|
|
|
25
34
|
* slotting your own markup, styled with your own CSS, rather than
|
|
26
35
|
* reaching for a layout variant baked into the component.
|
|
27
36
|
*
|
|
28
|
-
*
|
|
37
|
+
* Without href, a native anchor placed as a direct child links the whole
|
|
38
|
+
* card instead, stretched over its surface, so the link exists in the
|
|
39
|
+
* server-rendered HTML and can be a framework's own link component. Its
|
|
40
|
+
* accessible name stays the anchor's own text, typically the card title.
|
|
41
|
+
* When it opens in a new tab, the card shows the same external link badge
|
|
42
|
+
* and announces it through the anchor's aria-description.
|
|
43
|
+
*
|
|
44
|
+
* @slot [default] - The card's content, arranged in a column by `--card-gap`. A native anchor as a direct child links the whole card when href is unset
|
|
29
45
|
* @csspart card - The outer box, a link once href is set, a plain container otherwise. Exposed for effects the card's CSS custom properties don't cover, such as a hover accent
|
|
30
46
|
* @prop {'default' | 'fill' | 'raised'} [appearance='default'] - The card's surface style. Default is a plain surface colored box with a border. Fill and raised both drop the border, fill for a muted tinted background and raised for a drop shadow. All three animate a border, tint, or shadow change on hover or focus regardless of whether the card is a link, though the accompanying lift is narrower
|
|
31
47
|
* @prop {string} href - The URL the card navigates to. When set, the card renders as a link instead of a plain wrapper
|
|
32
|
-
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology
|
|
48
|
+
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology, in the current locale
|
|
49
|
+
* @prop {string} [locale] - The locale used to resolve the "opens in a new tab" announcement. Defaults to the one set with setDefaultLocale, English otherwise
|
|
33
50
|
* @prop {string} download - The filename used when the linked URL is downloaded instead of navigated to. Only used when href is set
|
|
34
51
|
* @attr {string} aria-label - An accessible label that overrides the card content. When the card also opens in a new tab, a note announcing it is appended automatically
|
|
35
52
|
* @fires {NavigationEvent} eunnavigate - Fired before following href, so a client-side router can intercept the navigation. Not fired for downloads, and cancelable
|
|
@@ -63,15 +80,58 @@ let EunomiaCard = class EunomiaCard extends CardLinkMixin(LitElement) {
|
|
|
63
80
|
* @default default
|
|
64
81
|
*/
|
|
65
82
|
this.appearance = "default";
|
|
83
|
+
/**
|
|
84
|
+
* Announces the slotted anchor opening in a new tab.
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
_EunomiaCard_newTab.set(this, new NewTabAnchorController(this, () => this.slottedAnchor, () => this.dictionary.link.opensInNewTab));
|
|
88
|
+
/**
|
|
89
|
+
* Re-renders when the default slot changes, so an anchor added or removed
|
|
90
|
+
* after the first render switches between the two modes.
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
this.handleSlotChange = () => {
|
|
94
|
+
this.requestUpdate();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Whether a native `<a>` slotted as a direct child links the card while
|
|
99
|
+
* `href` is unset (see the class doc). Navigation, `target`/`rel` and
|
|
100
|
+
* the new-tab hint are the consumer's own in this mode.
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
get hasSlottedAnchor() {
|
|
104
|
+
return !!this.slottedAnchor;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The native `<a>` slotted as a direct child while `href` is unset.
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
get slottedAnchor() {
|
|
111
|
+
return this.href ? null : this.querySelector(":scope > a");
|
|
112
|
+
}
|
|
113
|
+
updated(changed) {
|
|
114
|
+
super.updated(changed);
|
|
115
|
+
if (this.hasSlottedAnchor) {
|
|
116
|
+
warnIgnoredHostLinkAttributes(this);
|
|
117
|
+
}
|
|
66
118
|
}
|
|
67
119
|
render() {
|
|
68
|
-
const inner = html `<slot
|
|
120
|
+
const inner = html `<slot @slotchange=${this.handleSlotChange}></slot
|
|
121
|
+
>${this.renderExternalLinkBadge(__classPrivateFieldGet(this, _EunomiaCard_newTab, "f").isBlank)}`;
|
|
69
122
|
if (this.href) {
|
|
70
123
|
return this.renderCardLink("card", inner);
|
|
71
124
|
}
|
|
72
|
-
return html `<div
|
|
125
|
+
return html `<div
|
|
126
|
+
id="card"
|
|
127
|
+
part="card"
|
|
128
|
+
class=${ifDefined(this.hasSlottedAnchor ? "slotted-link" : undefined)}
|
|
129
|
+
>
|
|
130
|
+
${inner}
|
|
131
|
+
</div>`;
|
|
73
132
|
}
|
|
74
133
|
};
|
|
134
|
+
_EunomiaCard_newTab = new WeakMap();
|
|
75
135
|
/**
|
|
76
136
|
* Styles to import to the component.
|
|
77
137
|
*
|
|
@@ -131,8 +131,40 @@ const base = css `
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
#card.slotted-link {
|
|
135
|
+
--_hoverLift: translateY(-4px);
|
|
136
|
+
--_hoverBorderDefault: var(--eun-color-primary-500, #3d6fff);
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
}
|
|
139
|
+
::slotted(a) {
|
|
140
|
+
color: inherit;
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
outline: none !important;
|
|
143
|
+
}
|
|
144
|
+
::slotted(a)::after {
|
|
145
|
+
content: "";
|
|
146
|
+
position: absolute;
|
|
147
|
+
inset: calc(-1 * var(--card-border-width, var(--eun-border-width-s, 1px)));
|
|
148
|
+
z-index: 1;
|
|
149
|
+
border-radius: var(--card-border-radius, var(--eun-border-radius-m, 8px));
|
|
150
|
+
outline: 2px solid transparent;
|
|
151
|
+
transition: outline 0.2s ease-out;
|
|
152
|
+
}
|
|
153
|
+
::slotted(a:focus-visible)::after {
|
|
154
|
+
outline-color: var(
|
|
155
|
+
--card-focus-outline-color,
|
|
156
|
+
var(--eun-color-primary-500, #3d6fff)
|
|
157
|
+
);
|
|
158
|
+
outline-offset: 2px;
|
|
159
|
+
}
|
|
160
|
+
:host(:focus-within) #card.slotted-link {
|
|
161
|
+
transform: var(--card-hover-transform, var(--_hoverLift));
|
|
162
|
+
border-color: var(--card-hover-border-color, var(--_hoverBorderDefault));
|
|
163
|
+
}
|
|
164
|
+
|
|
134
165
|
@media (prefers-reduced-motion: reduce) {
|
|
135
|
-
#card
|
|
166
|
+
#card,
|
|
167
|
+
::slotted(a)::after {
|
|
136
168
|
transition: none;
|
|
137
169
|
}
|
|
138
170
|
}
|
|
@@ -3,7 +3,7 @@ import { LitElement, TemplateResult } from "lit";
|
|
|
3
3
|
* Tag name of the image card component.
|
|
4
4
|
*/
|
|
5
5
|
export declare const EunomiaImageCardTagName = "eun-image-card";
|
|
6
|
-
declare const EunomiaImageCard_base: import("../../../utils/constructor.type.js").Constructor<import("../../../mixins/card-link.mixin.js").CardLinkMixinInterface> & typeof LitElement;
|
|
6
|
+
declare const EunomiaImageCard_base: import("../../../utils/constructor.type.js").Constructor<import("../../../mixins/card-link.mixin.js").CardLinkMixinInterface & import("../../../mixins/localizable.mixin.js").LocalizableMixinInterface> & typeof LitElement;
|
|
7
7
|
/**
|
|
8
8
|
* An image header with a title and description footer, such as a blog post
|
|
9
9
|
* preview, a product tile, or a team member card. It shares the same CSS
|
|
@@ -19,6 +19,7 @@ declare const EunomiaImageCard_base: import("../../../utils/constructor.type.js"
|
|
|
19
19
|
* @csspart card - The outer box, a link once href is set, a plain container otherwise. Exposed for effects the card's CSS custom properties don't cover, such as a hover accent
|
|
20
20
|
* @prop {string} href - The URL the card navigates to. When set, the card renders as a link instead of a plain wrapper
|
|
21
21
|
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology
|
|
22
|
+
* @prop {string} [locale] - The locale used to resolve the "opens in a new tab" announcement. Defaults to the one set with setDefaultLocale, English otherwise
|
|
22
23
|
* @prop {string} download - The filename used when the linked URL is downloaded instead of navigated to. Only used when href is set
|
|
23
24
|
* @attr {string} aria-label - An accessible label that overrides the card content. When the card also opens in a new tab, a note announcing it is appended automatically
|
|
24
25
|
* @fires {NavigationEvent} eunnavigate - Fired before following href, so a client-side router can intercept the navigation. Not fired for downloads, and cancelable
|
|
@@ -28,6 +28,7 @@ export const EunomiaImageCardTagName = "eun-image-card";
|
|
|
28
28
|
* @csspart card - The outer box, a link once href is set, a plain container otherwise. Exposed for effects the card's CSS custom properties don't cover, such as a hover accent
|
|
29
29
|
* @prop {string} href - The URL the card navigates to. When set, the card renders as a link instead of a plain wrapper
|
|
30
30
|
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology
|
|
31
|
+
* @prop {string} [locale] - The locale used to resolve the "opens in a new tab" announcement. Defaults to the one set with setDefaultLocale, English otherwise
|
|
31
32
|
* @prop {string} download - The filename used when the linked URL is downloaded instead of navigated to. Only used when href is set
|
|
32
33
|
* @attr {string} aria-label - An accessible label that overrides the card content. When the card also opens in a new tab, a note announcing it is appended automatically
|
|
33
34
|
* @fires {NavigationEvent} eunnavigate - Fired before following href, so a client-side router can intercept the navigation. Not fired for downloads, and cancelable
|
|
@@ -3,7 +3,7 @@ import { LitElement, TemplateResult } from "lit";
|
|
|
3
3
|
* Tag name of the sliding card component.
|
|
4
4
|
*/
|
|
5
5
|
export declare const EunomiaSlidingCardTagName = "eun-sliding-card";
|
|
6
|
-
declare const EunomiaSlidingCard_base: import("../../../utils/constructor.type.js").Constructor<import("../../../mixins/card-link.mixin.js").CardLinkMixinInterface> & typeof LitElement;
|
|
6
|
+
declare const EunomiaSlidingCard_base: import("../../../utils/constructor.type.js").Constructor<import("../../../mixins/card-link.mixin.js").CardLinkMixinInterface & import("../../../mixins/localizable.mixin.js").LocalizableMixinInterface> & typeof LitElement;
|
|
7
7
|
/**
|
|
8
8
|
* A card with a two layer slide reveal. The front layer is always visible
|
|
9
9
|
* and slides down to expose the back layer underneath.
|
|
@@ -35,6 +35,7 @@ declare const EunomiaSlidingCard_base: import("../../../utils/constructor.type.j
|
|
|
35
35
|
* @prop {boolean} [hint=false] - Loops a bounce animation on touch devices while closed, hinting that the card is interactive
|
|
36
36
|
* @prop {string} href - The URL the back layer navigates to. When set, the back layer renders as a link instead of a plain container
|
|
37
37
|
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology
|
|
38
|
+
* @prop {string} [locale] - The locale used to resolve the "opens in a new tab" announcement. Defaults to the one set with setDefaultLocale, English otherwise
|
|
38
39
|
* @prop {string} download - The filename used when the linked URL is downloaded instead of navigated to. Only used when href is set
|
|
39
40
|
* @attr {string} aria-label - The accessible label for the front layer's toggle control, touch devices only, since desktop has no such control. When the back layer also opens in a new tab, a note announcing it is appended automatically
|
|
40
41
|
* @fires {NavigationEvent} eunnavigate - Fired before following href, so a client-side router can intercept the navigation. Not fired for downloads, and cancelable
|
|
@@ -47,6 +47,7 @@ export const EunomiaSlidingCardTagName = "eun-sliding-card";
|
|
|
47
47
|
* @prop {boolean} [hint=false] - Loops a bounce animation on touch devices while closed, hinting that the card is interactive
|
|
48
48
|
* @prop {string} href - The URL the back layer navigates to. When set, the back layer renders as a link instead of a plain container
|
|
49
49
|
* @prop {'_blank' | '_self' | '_parent' | '_top'} target - Where to open the linked URL. Only used when href is set. Opening in a new tab automatically adds an external link badge and announces it to assistive technology
|
|
50
|
+
* @prop {string} [locale] - The locale used to resolve the "opens in a new tab" announcement. Defaults to the one set with setDefaultLocale, English otherwise
|
|
50
51
|
* @prop {string} download - The filename used when the linked URL is downloaded instead of navigated to. Only used when href is set
|
|
51
52
|
* @attr {string} aria-label - The accessible label for the front layer's toggle control, touch devices only, since desktop has no such control. When the back layer also opens in a new tab, a note announcing it is appended automatically
|
|
52
53
|
* @fires {NavigationEvent} eunnavigate - Fired before following href, so a client-side router can intercept the navigation. Not fired for downloads, and cancelable
|
|
@@ -37,14 +37,16 @@ export declare const EunomiaCollapseTagName = "eun-collapse";
|
|
|
37
37
|
* trigger, so it's never dropped into now-hidden content.
|
|
38
38
|
*
|
|
39
39
|
* @slot [default] - The panel's content, shown when expanded, combining with richText if both are set. Only the panel's own padding and text color apply to it, with no margins, typography, or list styles forced onto slotted content
|
|
40
|
+
* @slot [heading] - The trigger's heading as light DOM content, so it's part of the server-rendered HTML. Falls back to heading when empty. Keep it to text and inline phrasing, since it renders inside the trigger button
|
|
40
41
|
* @slot [icon] - Replaces the leading icon entirely with any content, not just an icon element. Falls back to icon when empty
|
|
41
|
-
* @slot [
|
|
42
|
+
* @slot [subheading] - The secondary text under the heading as light DOM content, so it's part of the server-rendered HTML. Falls back to subheading when empty
|
|
43
|
+
* @slot [tag] - The trigger's tag as light DOM content. Plain elements, such as a span of text, keep the default tag style, while a custom element, such as a colored eun-tag, replaces the tag entirely. Falls back to tag when empty
|
|
42
44
|
* @slot [chevron] - Replaces the trailing indicator entirely with any content, not just an icon element. Falls back to chevronIcon when empty. Whatever ends up there still rotates while open, unless that rotation is set to zero
|
|
43
|
-
* @prop {string} heading - The trigger's heading text
|
|
44
|
-
* @prop {string} [subheading] - Optional secondary text shown under the heading
|
|
45
|
+
* @prop {string} heading - The trigger's heading text. Ignored once something is slotted into heading
|
|
46
|
+
* @prop {string} [subheading] - Optional secondary text shown under the heading. Ignored once something is slotted into subheading
|
|
45
47
|
* @prop {2 | 3 | 4 | 5 | 6} [level] - Wraps the trigger in a heading element of this level, so screen reader users can jump between items, such as several FAQ entries, by heading. Matches the page's own outline, so it's opt-in rather than assumed
|
|
46
48
|
* @prop {import('../icon/icon.type.js').EunomiaIconName} [icon] - An optional leading icon for the trigger. Ignored once the icon slot has content
|
|
47
|
-
* @prop {string} [tag] - An optional short label rendered as a default tag in the trigger, such as a count or category.
|
|
49
|
+
* @prop {string} [tag] - An optional short label rendered as a default tag in the trigger, such as a count or category. Ignored once something is slotted into tag
|
|
48
50
|
* @prop {import('../icon/icon.type.js').EunomiaIconName} [chevronIcon='add'] - The trailing indicator icon. Ignored once the chevron slot has content. Pair a non-default icon with the chevron rotation custom property, since the default plus-sign-to-cross rotation doesn't suit every icon
|
|
49
51
|
* @prop {string} [richText] - Lightweight formatted content rendered above the default slot. Supports simple lists, links, bold, and italic text
|
|
50
52
|
* @prop {boolean} [open=false] - Whether the panel is currently expanded
|
|
@@ -82,11 +84,16 @@ export declare class EunomiaCollapse extends LitElement {
|
|
|
82
84
|
*/
|
|
83
85
|
static readonly styles: import("lit").CSSResult[];
|
|
84
86
|
/**
|
|
85
|
-
* The trigger's heading text.
|
|
87
|
+
* The trigger's heading text. Only rendered in the shadow root, so the
|
|
88
|
+
* `heading` slot is preferred wherever the text must be in the server
|
|
89
|
+
* HTML (an indexed FAQ, for example) ; ignored once that slot is filled.
|
|
86
90
|
*/
|
|
87
91
|
heading: string;
|
|
88
92
|
/**
|
|
89
|
-
* Optional secondary text shown under the heading.
|
|
93
|
+
* Optional secondary text shown under the heading. Only rendered in the
|
|
94
|
+
* shadow root, like {@link heading}, so the `subheading` slot is
|
|
95
|
+
* preferred wherever the text must be in the server HTML ; ignored once
|
|
96
|
+
* that slot is filled.
|
|
90
97
|
*/
|
|
91
98
|
subheading?: string;
|
|
92
99
|
/**
|
|
@@ -194,12 +201,12 @@ export declare class EunomiaCollapse extends LitElement {
|
|
|
194
201
|
*/
|
|
195
202
|
private readonly iconSlotEls;
|
|
196
203
|
/**
|
|
197
|
-
* Elements assigned to the `
|
|
198
|
-
* {@link render} can decide whether to
|
|
204
|
+
* Elements assigned to the `subheading` slot, if any ; queried live so
|
|
205
|
+
* {@link render} can decide whether to render the subheading line at all.
|
|
199
206
|
* @internal
|
|
200
207
|
* @readonly
|
|
201
208
|
*/
|
|
202
|
-
private readonly
|
|
209
|
+
private readonly subheadingSlotEls;
|
|
203
210
|
/**
|
|
204
211
|
* Elements assigned to the `chevron` slot, if any ; queried live so
|
|
205
212
|
* {@link render} can skip instantiating the fallback `eun-icon` (and its
|
|
@@ -212,8 +219,9 @@ export declare class EunomiaCollapse extends LitElement {
|
|
|
212
219
|
private readonly chevronSlotEls;
|
|
213
220
|
/**
|
|
214
221
|
* Re-renders when a named slot's assigned content changes, so the
|
|
215
|
-
* `icon`/`tag`/`chevron` prop fallback correctly
|
|
216
|
-
* content is slotted in or removed after the
|
|
222
|
+
* `icon`/`subheading`/`tag`/`chevron` prop fallback correctly
|
|
223
|
+
* appears/disappears as content is slotted in or removed after the
|
|
224
|
+
* initial render.
|
|
217
225
|
* @private
|
|
218
226
|
*/
|
|
219
227
|
private handleSlotChange;
|
|
@@ -332,6 +340,16 @@ export declare class EunomiaCollapse extends LitElement {
|
|
|
332
340
|
* @private
|
|
333
341
|
*/
|
|
334
342
|
private renderHeadingWrapper;
|
|
343
|
+
/**
|
|
344
|
+
* Renders the `tag` slot. Plain elements slotted into it (a span of
|
|
345
|
+
* text, typically) are wrapped in the default tag, so server-rendered
|
|
346
|
+
* text keeps the tag style ; a custom element (a colored `eun-tag`, a
|
|
347
|
+
* badge, ...) replaces the tag entirely instead. Read from the light DOM
|
|
348
|
+
* rather than the slot's assigned elements, so the first render already
|
|
349
|
+
* picks the right shape before the slot exists.
|
|
350
|
+
* @private
|
|
351
|
+
*/
|
|
352
|
+
private renderTag;
|
|
335
353
|
render(): TemplateResult;
|
|
336
354
|
}
|
|
337
355
|
declare global {
|
|
@@ -49,14 +49,16 @@ export const EunomiaCollapseTagName = "eun-collapse";
|
|
|
49
49
|
* trigger, so it's never dropped into now-hidden content.
|
|
50
50
|
*
|
|
51
51
|
* @slot [default] - The panel's content, shown when expanded, combining with richText if both are set. Only the panel's own padding and text color apply to it, with no margins, typography, or list styles forced onto slotted content
|
|
52
|
+
* @slot [heading] - The trigger's heading as light DOM content, so it's part of the server-rendered HTML. Falls back to heading when empty. Keep it to text and inline phrasing, since it renders inside the trigger button
|
|
52
53
|
* @slot [icon] - Replaces the leading icon entirely with any content, not just an icon element. Falls back to icon when empty
|
|
53
|
-
* @slot [
|
|
54
|
+
* @slot [subheading] - The secondary text under the heading as light DOM content, so it's part of the server-rendered HTML. Falls back to subheading when empty
|
|
55
|
+
* @slot [tag] - The trigger's tag as light DOM content. Plain elements, such as a span of text, keep the default tag style, while a custom element, such as a colored eun-tag, replaces the tag entirely. Falls back to tag when empty
|
|
54
56
|
* @slot [chevron] - Replaces the trailing indicator entirely with any content, not just an icon element. Falls back to chevronIcon when empty. Whatever ends up there still rotates while open, unless that rotation is set to zero
|
|
55
|
-
* @prop {string} heading - The trigger's heading text
|
|
56
|
-
* @prop {string} [subheading] - Optional secondary text shown under the heading
|
|
57
|
+
* @prop {string} heading - The trigger's heading text. Ignored once something is slotted into heading
|
|
58
|
+
* @prop {string} [subheading] - Optional secondary text shown under the heading. Ignored once something is slotted into subheading
|
|
57
59
|
* @prop {2 | 3 | 4 | 5 | 6} [level] - Wraps the trigger in a heading element of this level, so screen reader users can jump between items, such as several FAQ entries, by heading. Matches the page's own outline, so it's opt-in rather than assumed
|
|
58
60
|
* @prop {import('../icon/icon.type.js').EunomiaIconName} [icon] - An optional leading icon for the trigger. Ignored once the icon slot has content
|
|
59
|
-
* @prop {string} [tag] - An optional short label rendered as a default tag in the trigger, such as a count or category.
|
|
61
|
+
* @prop {string} [tag] - An optional short label rendered as a default tag in the trigger, such as a count or category. Ignored once something is slotted into tag
|
|
60
62
|
* @prop {import('../icon/icon.type.js').EunomiaIconName} [chevronIcon='add'] - The trailing indicator icon. Ignored once the chevron slot has content. Pair a non-default icon with the chevron rotation custom property, since the default plus-sign-to-cross rotation doesn't suit every icon
|
|
61
63
|
* @prop {string} [richText] - Lightweight formatted content rendered above the default slot. Supports simple lists, links, bold, and italic text
|
|
62
64
|
* @prop {boolean} [open=false] - Whether the panel is currently expanded
|
|
@@ -143,8 +145,9 @@ let EunomiaCollapse = class EunomiaCollapse extends LitElement {
|
|
|
143
145
|
this.openedViaFocus = false;
|
|
144
146
|
/**
|
|
145
147
|
* Re-renders when a named slot's assigned content changes, so the
|
|
146
|
-
* `icon`/`tag`/`chevron` prop fallback correctly
|
|
147
|
-
* content is slotted in or removed after the
|
|
148
|
+
* `icon`/`subheading`/`tag`/`chevron` prop fallback correctly
|
|
149
|
+
* appears/disappears as content is slotted in or removed after the
|
|
150
|
+
* initial render.
|
|
148
151
|
* @private
|
|
149
152
|
*/
|
|
150
153
|
this.handleSlotChange = () => {
|
|
@@ -364,6 +367,35 @@ let EunomiaCollapse = class EunomiaCollapse extends LitElement {
|
|
|
364
367
|
return trigger;
|
|
365
368
|
}
|
|
366
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Renders the `tag` slot. Plain elements slotted into it (a span of
|
|
372
|
+
* text, typically) are wrapped in the default tag, so server-rendered
|
|
373
|
+
* text keeps the tag style ; a custom element (a colored `eun-tag`, a
|
|
374
|
+
* badge, ...) replaces the tag entirely instead. Read from the light DOM
|
|
375
|
+
* rather than the slot's assigned elements, so the first render already
|
|
376
|
+
* picks the right shape before the slot exists.
|
|
377
|
+
* @private
|
|
378
|
+
*/
|
|
379
|
+
renderTag() {
|
|
380
|
+
const slotted = [
|
|
381
|
+
...this.querySelectorAll(':scope > [slot="tag"]'),
|
|
382
|
+
];
|
|
383
|
+
const replaced = slotted.some((el) => el.localName.includes("-"));
|
|
384
|
+
const slot = html `<slot name="tag" @slotchange=${this.handleSlotChange}
|
|
385
|
+
>${this.tag}</slot
|
|
386
|
+
>`;
|
|
387
|
+
if (replaced) {
|
|
388
|
+
return slot;
|
|
389
|
+
}
|
|
390
|
+
if (!this.tag && !slotted.length) {
|
|
391
|
+
return html `<slot
|
|
392
|
+
name="tag"
|
|
393
|
+
class="hidden"
|
|
394
|
+
@slotchange=${this.handleSlotChange}
|
|
395
|
+
></slot>`;
|
|
396
|
+
}
|
|
397
|
+
return html `<eun-tag color="primary" size="s" rounded>${slot}</eun-tag>`;
|
|
398
|
+
}
|
|
367
399
|
render() {
|
|
368
400
|
const trigger = html `
|
|
369
401
|
<button
|
|
@@ -388,24 +420,22 @@ let EunomiaCollapse = class EunomiaCollapse extends LitElement {
|
|
|
388
420
|
: nothing}
|
|
389
421
|
</slot>
|
|
390
422
|
<span id="heading-group">
|
|
391
|
-
<span id="heading"
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
423
|
+
<span id="heading"
|
|
424
|
+
><slot name="heading">${this.heading}</slot></span
|
|
425
|
+
>
|
|
426
|
+
<span
|
|
427
|
+
id="subheading"
|
|
428
|
+
class=${classMap({
|
|
429
|
+
hidden: !this.subheading && !this.subheadingSlotEls.length,
|
|
430
|
+
})}
|
|
431
|
+
><slot name="subheading" @slotchange=${this.handleSlotChange}
|
|
432
|
+
>${this.subheading}</slot
|
|
433
|
+
></span
|
|
434
|
+
>
|
|
395
435
|
</span>
|
|
396
436
|
</span>
|
|
397
437
|
<span id="actions">
|
|
398
|
-
|
|
399
|
-
name="tag"
|
|
400
|
-
class=${classMap({ hidden: !this.tag && !this.tagSlotEls.length })}
|
|
401
|
-
@slotchange=${this.handleSlotChange}
|
|
402
|
-
>
|
|
403
|
-
${this.tag
|
|
404
|
-
? html `<eun-tag color="primary" size="s" rounded
|
|
405
|
-
>${this.tag}</eun-tag
|
|
406
|
-
>`
|
|
407
|
-
: nothing}
|
|
408
|
-
</slot>
|
|
438
|
+
${this.renderTag()}
|
|
409
439
|
<span id="chevron">
|
|
410
440
|
<slot name="chevron" @slotchange=${this.handleSlotChange}>
|
|
411
441
|
${this.chevronSlotEls.length
|
|
@@ -497,8 +527,8 @@ __decorate([
|
|
|
497
527
|
queryAssignedElements({ slot: "icon" })
|
|
498
528
|
], EunomiaCollapse.prototype, "iconSlotEls", void 0);
|
|
499
529
|
__decorate([
|
|
500
|
-
queryAssignedElements({ slot: "
|
|
501
|
-
], EunomiaCollapse.prototype, "
|
|
530
|
+
queryAssignedElements({ slot: "subheading" })
|
|
531
|
+
], EunomiaCollapse.prototype, "subheadingSlotEls", void 0);
|
|
502
532
|
__decorate([
|
|
503
533
|
queryAssignedElements({ slot: "chevron" })
|
|
504
534
|
], EunomiaCollapse.prototype, "chevronSlotEls", void 0);
|
|
@@ -140,11 +140,24 @@ export const collapseStyles = css `
|
|
|
140
140
|
text-overflow: ellipsis;
|
|
141
141
|
font-size: var(--eun-font-size-s, 14px);
|
|
142
142
|
}
|
|
143
|
+
#heading ::slotted(*) {
|
|
144
|
+
margin: 0;
|
|
145
|
+
font: inherit;
|
|
146
|
+
color: inherit;
|
|
147
|
+
}
|
|
143
148
|
#subheading {
|
|
144
149
|
font-size: var(--eun-font-size-xs, 14px);
|
|
145
150
|
font-weight: var(--eun-font-weight-m);
|
|
146
151
|
color: var(--_subheadingColor);
|
|
147
152
|
}
|
|
153
|
+
#subheading.hidden {
|
|
154
|
+
display: none;
|
|
155
|
+
}
|
|
156
|
+
#subheading ::slotted(*) {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font: inherit;
|
|
159
|
+
color: inherit;
|
|
160
|
+
}
|
|
148
161
|
#actions {
|
|
149
162
|
display: flex;
|
|
150
163
|
align-items: center;
|