@fluid-topics/ft-collapsible 0.3.32 → 0.3.34
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/build/ft-collapsible.css.js +18 -6
- package/build/ft-collapsible.d.ts +16 -2
- package/build/ft-collapsible.js +81 -19
- package/build/ft-collapsible.light.js +77 -61
- package/build/ft-collapsible.min.js +191 -176
- package/build/ft-collapsible.properties.d.ts +19 -8
- package/package.json +4 -4
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
// language=CSS
|
|
2
2
|
import { css } from "lit";
|
|
3
3
|
export const styles = css `
|
|
4
|
-
:host
|
|
5
|
-
display:
|
|
4
|
+
:host {
|
|
5
|
+
display: contents;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
.
|
|
9
|
-
|
|
8
|
+
.ft-collapsible--hidden:not(.ft-collapsible--animation-in-progress) {
|
|
9
|
+
display: none;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
.hidden {
|
|
13
|
-
|
|
12
|
+
.ft-collapsible--hidden.ft-collapsible--animated, .ft-collapsible--hidden.ft-collapsible--animated::slotted(*) {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ft-collapsible--animated, .ft-collapsible--animated::slotted(*) {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ft-collapsible--animated, .ft-collapsible--animated::slotted(*) {
|
|
21
|
+
transition: opacity 300ms 150ms;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ft-collapsible--animated.ft-collapsible--hidden, .ft-collapsible--animated.ft-collapsible--hidden::slotted(*) {
|
|
25
|
+
transition: opacity 300ms;
|
|
14
26
|
}
|
|
15
27
|
`;
|
|
16
28
|
//# sourceMappingURL=ft-collapsible.css.js.map
|
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
import { PropertyValues } from "lit";
|
|
2
2
|
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtCollapsibleProperties } from "./ft-collapsible.properties";
|
|
4
|
+
import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
|
|
5
|
+
import { Position } from "@fluid-topics/ft-tooltip/build/ft-tooltip.properties";
|
|
4
6
|
export declare class FtCollapsible extends FtLitElement implements FtCollapsibleProperties {
|
|
5
7
|
static elementDefinitions: ElementDefinitionsMap;
|
|
6
|
-
content: HTMLElement;
|
|
7
8
|
open: boolean;
|
|
8
|
-
|
|
9
|
+
animated: boolean;
|
|
10
|
+
closeCollapsibleMatchers: string[];
|
|
11
|
+
label?: string;
|
|
12
|
+
openLabel?: string;
|
|
13
|
+
closedLabel?: string;
|
|
14
|
+
text?: string;
|
|
15
|
+
openText?: string;
|
|
16
|
+
closedText?: string;
|
|
9
17
|
primary: boolean;
|
|
10
18
|
secondary: boolean;
|
|
11
19
|
disabled: boolean;
|
|
12
20
|
dense: boolean;
|
|
13
21
|
round: boolean;
|
|
22
|
+
tooltipPosition: Position;
|
|
23
|
+
iconVariant: FtIconVariants;
|
|
14
24
|
openIcon: string;
|
|
15
25
|
closedIcon: string;
|
|
16
26
|
trailingIcon: boolean;
|
|
17
27
|
private toggleSlot?;
|
|
28
|
+
private content;
|
|
29
|
+
private animationInProgress;
|
|
18
30
|
static styles: import("lit").CSSResult;
|
|
19
31
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
20
32
|
private onCustomToggleSlotChange;
|
|
21
33
|
private hasCustomToggle;
|
|
34
|
+
private animationEndSafeguard;
|
|
22
35
|
private toggleOpen;
|
|
23
36
|
protected update(changedProperties: PropertyValues): void;
|
|
37
|
+
private onContentClick;
|
|
24
38
|
}
|
|
25
39
|
//# sourceMappingURL=ft-collapsible.d.ts.map
|
package/build/ft-collapsible.js
CHANGED
|
@@ -5,30 +5,45 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, } from "lit";
|
|
8
|
-
import { property, query } from "lit/decorators.js";
|
|
9
|
-
import {
|
|
8
|
+
import { property, query, state } from "lit/decorators.js";
|
|
9
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
10
|
+
import { Debouncer, FtLitElement, jsonProperty } from "@fluid-topics/ft-wc-utils";
|
|
10
11
|
import { FtButton } from "@fluid-topics/ft-button";
|
|
11
12
|
import { styles } from "./ft-collapsible.css";
|
|
13
|
+
import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
|
|
12
14
|
export class FtCollapsible extends FtLitElement {
|
|
13
15
|
constructor() {
|
|
14
16
|
super(...arguments);
|
|
15
17
|
this.open = false;
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
+
this.animated = false;
|
|
19
|
+
this.closeCollapsibleMatchers = [];
|
|
18
20
|
this.primary = false;
|
|
19
21
|
this.secondary = false;
|
|
20
22
|
this.disabled = false;
|
|
21
23
|
this.dense = false;
|
|
22
24
|
this.round = false;
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
+
this.tooltipPosition = "right";
|
|
26
|
+
this.iconVariant = FtIconVariants.fluid_topics;
|
|
27
|
+
this.openIcon = "THIN_ARROW";
|
|
28
|
+
this.closedIcon = "THIN_ARROW_RIGHT";
|
|
25
29
|
this.trailingIcon = false;
|
|
30
|
+
this.animationInProgress = false;
|
|
31
|
+
this.animationEndSafeguard = new Debouncer(800);
|
|
26
32
|
}
|
|
27
33
|
render() {
|
|
34
|
+
const contentClasses = {
|
|
35
|
+
"ft-collapsible--content": true,
|
|
36
|
+
"ft-collapsible--hidden": !this.open,
|
|
37
|
+
"ft-collapsible--animated": this.animated,
|
|
38
|
+
"ft-collapsible--animation-in-progress": this.animated && this.animationInProgress,
|
|
39
|
+
};
|
|
28
40
|
return html `
|
|
29
41
|
<ft-button
|
|
30
42
|
part="toggle"
|
|
31
|
-
|
|
43
|
+
.tooltipPosition=${this.tooltipPosition}
|
|
44
|
+
.iconVariant=${this.iconVariant}
|
|
45
|
+
.icon=${this.open ? this.openIcon : this.closedIcon}
|
|
46
|
+
.label=${(this.open ? this.openLabel : this.closedLabel) || this.label}
|
|
32
47
|
?primary=${this.primary}
|
|
33
48
|
?secondary=${this.secondary}
|
|
34
49
|
?disabled=${this.disabled}
|
|
@@ -36,17 +51,18 @@ export class FtCollapsible extends FtLitElement {
|
|
|
36
51
|
?round=${this.round}
|
|
37
52
|
?trailingIcon=${this.trailingIcon}
|
|
38
53
|
@click=${this.toggleOpen}
|
|
39
|
-
class="${this.hasCustomToggle() ? "hidden" : ""}"
|
|
54
|
+
class="${this.hasCustomToggle() ? "ft-collapsible--hidden" : ""}"
|
|
40
55
|
>
|
|
41
|
-
${this.
|
|
56
|
+
${(this.open ? this.openText : this.closedText) || this.text}
|
|
42
57
|
</ft-button>
|
|
43
58
|
<slot name="toggle"
|
|
44
59
|
part="toggle"
|
|
60
|
+
class="${this.hasCustomToggle() ? "" : "ft-collapsible--hidden"}"
|
|
45
61
|
@click=${this.toggleOpen}
|
|
46
|
-
@slotchange=${this.onCustomToggleSlotChange}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
@slotchange=${this.onCustomToggleSlotChange}></slot>
|
|
63
|
+
<slot class="${classMap(contentClasses)}"
|
|
64
|
+
@click=${this.onContentClick}
|
|
65
|
+
@transitionend=${() => this.animationInProgress = false}></slot>
|
|
50
66
|
`;
|
|
51
67
|
}
|
|
52
68
|
onCustomToggleSlotChange() {
|
|
@@ -57,7 +73,9 @@ export class FtCollapsible extends FtLitElement {
|
|
|
57
73
|
return ((_b = (_a = this.toggleSlot) === null || _a === void 0 ? void 0 : _a.assignedNodes().length) !== null && _b !== void 0 ? _b : 0) !== 0;
|
|
58
74
|
}
|
|
59
75
|
toggleOpen() {
|
|
60
|
-
this.
|
|
76
|
+
this.animationInProgress = true;
|
|
77
|
+
setTimeout(() => this.open = !this.open, 5);
|
|
78
|
+
this.animationEndSafeguard.run(() => this.animationInProgress = false);
|
|
61
79
|
}
|
|
62
80
|
update(changedProperties) {
|
|
63
81
|
super.update(changedProperties);
|
|
@@ -65,20 +83,52 @@ export class FtCollapsible extends FtLitElement {
|
|
|
65
83
|
this.dispatchEvent(new CustomEvent("change", { detail: { open: this.open } }));
|
|
66
84
|
}
|
|
67
85
|
}
|
|
86
|
+
onContentClick(e) {
|
|
87
|
+
if (this.closeCollapsibleMatchers.length > 0) {
|
|
88
|
+
const path = e.composedPath();
|
|
89
|
+
for (let e of path) {
|
|
90
|
+
if (e === this) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (e.matches && this.closeCollapsibleMatchers.some(matcher => e.matches(matcher))) {
|
|
94
|
+
this.toggleOpen();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
68
100
|
}
|
|
69
101
|
FtCollapsible.elementDefinitions = {
|
|
70
102
|
"ft-button": FtButton,
|
|
71
103
|
};
|
|
72
104
|
FtCollapsible.styles = styles;
|
|
73
|
-
__decorate([
|
|
74
|
-
query(".content")
|
|
75
|
-
], FtCollapsible.prototype, "content", void 0);
|
|
76
105
|
__decorate([
|
|
77
106
|
property({ type: Boolean, reflect: true })
|
|
78
107
|
], FtCollapsible.prototype, "open", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
property({ type: Boolean })
|
|
110
|
+
], FtCollapsible.prototype, "animated", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
jsonProperty([])
|
|
113
|
+
], FtCollapsible.prototype, "closeCollapsibleMatchers", void 0);
|
|
79
114
|
__decorate([
|
|
80
115
|
property()
|
|
81
116
|
], FtCollapsible.prototype, "label", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
property()
|
|
119
|
+
], FtCollapsible.prototype, "openLabel", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
property()
|
|
122
|
+
], FtCollapsible.prototype, "closedLabel", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
property()
|
|
125
|
+
], FtCollapsible.prototype, "text", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
property()
|
|
128
|
+
], FtCollapsible.prototype, "openText", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
property()
|
|
131
|
+
], FtCollapsible.prototype, "closedText", void 0);
|
|
82
132
|
__decorate([
|
|
83
133
|
property({ type: Boolean })
|
|
84
134
|
], FtCollapsible.prototype, "primary", void 0);
|
|
@@ -95,10 +145,16 @@ __decorate([
|
|
|
95
145
|
property({ type: Boolean })
|
|
96
146
|
], FtCollapsible.prototype, "round", void 0);
|
|
97
147
|
__decorate([
|
|
98
|
-
property(
|
|
148
|
+
property()
|
|
149
|
+
], FtCollapsible.prototype, "tooltipPosition", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property()
|
|
152
|
+
], FtCollapsible.prototype, "iconVariant", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property()
|
|
99
155
|
], FtCollapsible.prototype, "openIcon", void 0);
|
|
100
156
|
__decorate([
|
|
101
|
-
property(
|
|
157
|
+
property()
|
|
102
158
|
], FtCollapsible.prototype, "closedIcon", void 0);
|
|
103
159
|
__decorate([
|
|
104
160
|
property({ type: Boolean })
|
|
@@ -106,4 +162,10 @@ __decorate([
|
|
|
106
162
|
__decorate([
|
|
107
163
|
query("slot[name=\"toggle\"]")
|
|
108
164
|
], FtCollapsible.prototype, "toggleSlot", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
query(".content")
|
|
167
|
+
], FtCollapsible.prototype, "content", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
state()
|
|
170
|
+
], FtCollapsible.prototype, "animationInProgress", void 0);
|
|
109
171
|
//# sourceMappingURL=ft-collapsible.js.map
|