@logosphere-ui/core 0.0.0-alpha.5 → 0.0.0-alpha.51
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/AGENTS.md +1204 -0
- package/dist/AGENTS.md +1204 -0
- package/dist/accordion-CYuCj7nB.cjs +21 -0
- package/dist/accordion-cDabqwu6.js +96 -0
- package/dist/accordion.cjs +1 -0
- package/dist/accordion.js +4 -0
- package/dist/atoms/Badge/badge.d.ts +1 -1
- package/dist/atoms/Button/button.d.ts +5 -3
- package/dist/atoms/Checkbox/checkbox.d.ts +13 -3
- package/dist/atoms/FormField/formfield.d.ts +12 -0
- package/dist/atoms/Slider/index.d.ts +1 -0
- package/dist/atoms/Slider/slider.d.ts +54 -0
- package/dist/badge-BhINg1p5.js +72 -0
- package/dist/badge-CKSG_MyA.cjs +13 -0
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/breadcrumb-BOuCLUJh.cjs +12 -0
- package/dist/breadcrumb-BeJqq-5C.js +41 -0
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button-CVkIa7M0.js +58 -0
- package/dist/button-vdNReBMi.cjs +10 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar-C71sj3Ki.js +652 -0
- package/dist/calendar-DZJM5Tyu.cjs +88 -0
- package/dist/calendar.cjs +1 -0
- package/dist/calendar.js +4 -0
- package/dist/{card-CUhlTJyJ.js → card-C7xXMV3h.js} +26 -25
- package/dist/card-DmQRNKtk.cjs +43 -0
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/chatbot-BAou4THb.cjs +183 -0
- package/dist/chatbot-BRfqXYYt.js +564 -0
- package/dist/chatbot.cjs +1 -1
- package/dist/chatbot.js +2 -2
- package/dist/checkbox-BAbPDN6x.cjs +53 -0
- package/dist/checkbox-CTfbav6M.js +152 -0
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/chip-group-D4DwnC37.cjs +26 -0
- package/dist/chip-group-DzfOd6Vw.js +89 -0
- package/dist/chip-group.cjs +1 -0
- package/dist/chip-group.js +4 -0
- package/dist/collapse-CbRE8ABx.cjs +47 -0
- package/dist/collapse-DY6SJ9jS.js +141 -0
- package/dist/collapse.cjs +1 -0
- package/dist/collapse.js +4 -0
- package/dist/combobox-BAa3UAQs.cjs +113 -0
- package/dist/combobox-BR05Tgfd.js +460 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/datepicker-BFYWQRrJ.js +382 -0
- package/dist/datepicker-BWE4qDJM.cjs +85 -0
- package/dist/datepicker.cjs +1 -1
- package/dist/datepicker.js +2 -2
- package/dist/{download-manager-A4fOxGWJ.js → download-manager-BPg-6Qfg.js} +4 -4
- package/dist/download-manager-DDeTYRPs.cjs +97 -0
- package/dist/download-manager.cjs +1 -1
- package/dist/download-manager.js +1 -1
- package/dist/drawer-CRu4G2zu.cjs +32 -0
- package/dist/drawer-DhuBPWHP.js +114 -0
- package/dist/drawer.cjs +1 -0
- package/dist/drawer.js +4 -0
- package/dist/formfield-JXiv9mvJ.cjs +33 -0
- package/dist/formfield-ss2mFweu.js +161 -0
- package/dist/formfield.cjs +1 -1
- package/dist/formfield.js +1 -1
- package/dist/icon.cjs +1 -0
- package/dist/icon.js +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.js +65 -32
- package/dist/index.umd.js +1613 -521
- package/dist/input-DyLKo7h6.cjs +60 -0
- package/dist/input-N3Z8D7q1.js +278 -0
- package/dist/input-group-C6sA1lzj.cjs +5 -0
- package/dist/input-group-DUPlrpug.js +66 -0
- package/dist/input-group.cjs +1 -0
- package/dist/input-group.js +4 -0
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/left-menu.cjs +1 -0
- package/dist/left-menu.js +5 -0
- package/dist/leftmenu-DiKo8iud.cjs +120 -0
- package/dist/leftmenu-DlU_G4Sj.js +373 -0
- package/dist/modal-g3KbWncV.cjs +84 -0
- package/dist/modal-vSjEpYrG.js +250 -0
- package/dist/modal.cjs +1 -1
- package/dist/modal.js +1 -1
- package/dist/molecules/Accordion/accordion.d.ts +42 -0
- package/dist/molecules/Accordion/index.d.ts +2 -0
- package/dist/molecules/Chip/chip-group.d.ts +29 -0
- package/dist/molecules/Chip/index.d.ts +2 -0
- package/dist/molecules/Collapse/collapse.d.ts +42 -0
- package/dist/molecules/Collapse/index.d.ts +2 -0
- package/dist/molecules/Input/input.d.ts +24 -1
- package/dist/molecules/InputGroup/index.d.ts +1 -0
- package/dist/molecules/InputGroup/input-group.d.ts +40 -0
- package/dist/molecules/Pagination/index.d.ts +1 -0
- package/dist/molecules/Pagination/pagination.d.ts +60 -0
- package/dist/molecules/Popover/popover.d.ts +5 -0
- package/dist/molecules/SplitButton/index.d.ts +2 -0
- package/dist/molecules/SplitButton/split-button.d.ts +53 -0
- package/dist/molecules/Stepper/index.d.ts +2 -0
- package/dist/molecules/Stepper/stepper.d.ts +34 -0
- package/dist/molecules/Textarea/text-area.d.ts +5 -2
- package/dist/molecules/TimePicker/index.d.ts +2 -0
- package/dist/molecules/TimePicker/timepicker.d.ts +62 -0
- package/dist/organisms/Calendar/calendar.d.ts +54 -0
- package/dist/organisms/Calendar/index.d.ts +1 -0
- package/dist/organisms/Calendar/shared.d.ts +9 -0
- package/dist/organisms/Chatbot/chatbot.d.ts +10 -1
- package/dist/organisms/Chatbot/index.d.ts +1 -1
- package/dist/organisms/Combobox/combobox.d.ts +39 -0
- package/dist/organisms/DatePicker/datepicker.d.ts +35 -33
- package/dist/organisms/Drawer/drawer.d.ts +30 -0
- package/dist/organisms/Drawer/index.d.ts +1 -0
- package/dist/organisms/LeftMenu/index.d.ts +2 -0
- package/dist/organisms/LeftMenu/leftmenu-types.d.ts +24 -0
- package/dist/organisms/LeftMenu/leftmenu.d.ts +60 -0
- package/dist/organisms/Modal/modal.d.ts +29 -4
- package/dist/organisms/Tab/tab.d.ts +13 -1
- package/dist/organisms/Toast/index.d.ts +2 -0
- package/dist/organisms/Toast/toast-container.d.ts +42 -0
- package/dist/organisms/Toast/toast.d.ts +48 -0
- package/dist/organisms/TreeMenu/index.d.ts +1 -0
- package/dist/organisms/TreeMenu/tree-menu.d.ts +59 -0
- package/dist/pagination-CjXvpE2j.js +360 -0
- package/dist/pagination-Nnzacqdo.cjs +169 -0
- package/dist/pagination.cjs +1 -0
- package/dist/pagination.js +4 -0
- package/dist/popover-CrXUbUR-.cjs +30 -0
- package/dist/popover-M5ZcS5rj.js +161 -0
- package/dist/popover.cjs +1 -1
- package/dist/popover.js +1 -1
- package/dist/shared/icons/index.d.ts +1 -0
- package/dist/shared/types/button.types.d.ts +7 -0
- package/dist/slider-DSRs5uhl.cjs +108 -0
- package/dist/slider-ntLRajQa.js +280 -0
- package/dist/slider.cjs +1 -0
- package/dist/slider.js +4 -0
- package/dist/split-button-BdBweoip.js +177 -0
- package/dist/split-button-BpffPlVg.cjs +63 -0
- package/dist/split-button.cjs +1 -0
- package/dist/split-button.js +4 -0
- package/dist/stepper-CZhwgLNp.js +122 -0
- package/dist/stepper-ZOMaU6aZ.cjs +52 -0
- package/dist/stepper.cjs +1 -0
- package/dist/stepper.js +4 -0
- package/dist/styles/main.css +186 -182
- package/dist/switch-Do6SCkPJ.cjs +17 -0
- package/dist/switch-uYVuohJ-.js +68 -0
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -1
- package/dist/tab-BvRVHpWs.cjs +41 -0
- package/dist/tab-Byh4UgFB.js +204 -0
- package/dist/tab.cjs +1 -1
- package/dist/tab.js +1 -1
- package/dist/text-area-1rALZ0iy.js +239 -0
- package/dist/text-area-D_TYL4_q.cjs +51 -0
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/timepicker-B9l6HN-d.js +320 -0
- package/dist/timepicker-Bpf2d4Nn.cjs +119 -0
- package/dist/timepicker.cjs +1 -0
- package/dist/timepicker.js +4 -0
- package/dist/toast-container-C5qYjInG.js +274 -0
- package/dist/toast-container-D2dyP20J.cjs +64 -0
- package/dist/toast.cjs +1 -0
- package/dist/toast.js +6 -0
- package/dist/tree-menu-BZ7aBC7R.js +237 -0
- package/dist/tree-menu-DDQ_DYl7.cjs +78 -0
- package/dist/tree-menu.cjs +1 -0
- package/dist/tree-menu.js +4 -0
- package/dist/ui-icon-BeR-PaPg.js +75 -0
- package/dist/ui-icon-DWl7I5BQ.cjs +22 -0
- package/package.json +104 -15
- package/dist/badge-BbhaO73N.cjs +0 -13
- package/dist/badge-DE7Tgd8Z.js +0 -71
- package/dist/breadcrumb-B-4yqoJZ.js +0 -41
- package/dist/breadcrumb-Cop-B1J7.cjs +0 -12
- package/dist/button-C1EwOosO.js +0 -58
- package/dist/button-CDRccsk9.cjs +0 -10
- package/dist/card-n8ka8Zk-.cjs +0 -43
- package/dist/chatbot-Da_itUdJ.cjs +0 -160
- package/dist/chatbot-zkxngMRH.js +0 -481
- package/dist/checkbox-7Rb3WKGx.js +0 -119
- package/dist/checkbox-CdDTRdKV.cjs +0 -37
- package/dist/combobox-BJbI-Tgi.js +0 -268
- package/dist/combobox-pmE7bgEL.cjs +0 -99
- package/dist/datepicker-DFJx45C-.js +0 -750
- package/dist/datepicker-b9JGTTMx.cjs +0 -115
- package/dist/download-manager-BSIMTGaK.cjs +0 -97
- package/dist/formfield-D_7NFFoe.cjs +0 -27
- package/dist/formfield-d8fp9FTV.js +0 -118
- package/dist/input-BcnI1w3_.cjs +0 -46
- package/dist/input-Bj_7u8Iv.js +0 -192
- package/dist/modal-Bfc6WQSL.js +0 -110
- package/dist/modal-DQ8VFL-P.cjs +0 -39
- package/dist/popover-B7tCqk3R.js +0 -140
- package/dist/popover-C2p5Pmts.cjs +0 -30
- package/dist/switch-Cpl53nRW.js +0 -64
- package/dist/switch-Rnnn10bn.cjs +0 -17
- package/dist/tab-BKdN4xAz.js +0 -176
- package/dist/tab-DcjAlXzU.cjs +0 -40
- package/dist/text-area-BkHdLnZj.cjs +0 -44
- package/dist/text-area-CC24lj8v.js +0 -204
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { unsafeCSS as g, css as f, LitElement as v, nothing as p, html as h } from "lit";
|
|
2
|
+
import { property as n, state as b, customElement as T } from "lit/decorators.js";
|
|
3
|
+
import { repeat as y } from "lit/directives/repeat.js";
|
|
4
|
+
import "./ui-icon-BeR-PaPg.js";
|
|
5
|
+
import "./button-CVkIa7M0.js";
|
|
6
|
+
const _ = ":host{display:block}.toast{position:relative;display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:start;width:100%;box-sizing:border-box;border-radius:var(--radius-md);border-left:4px solid var(--toast-accent);background:#fff;box-shadow:var(--shadow-md);padding:var(--spacing-4);color:#3d3d3d;font-family:var(--font-family-base);animation:toast-enter .22s cubic-bezier(.2,.8,.2,1);transform-origin:top right}.toast__icon{display:inline-flex;margin-top:2px;color:var(--toast-accent)}.toast__content{min-width:0}.toast__title{margin:0;font-size:var(--font-size-lg);line-height:var(--line-height-tight);font-weight:var(--font-weight-semibold)}.toast__title--as-text{font-size:var(--font-size-base);line-height:var(--line-height-normal);font-weight:var(--font-weight-regular);color:#555}.toast__text{margin:4px 0 0;font-size:var(--font-size-base);line-height:var(--line-height-normal);color:#555}.toast__actions{display:flex;gap:10px;margin-top:12px}.toast__close{border:0;background:transparent;color:#5a5a5a;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;margin-top:2px}.toast__close:hover{color:#2f2f2f}.toast--success{--toast-accent: var(--color-success-active)}.toast--danger{--toast-accent: var(--color-danger-active)}.toast--warning{--toast-accent: var(--color-warning-active)}.toast--info{--toast-accent: var(--color-info-active)}.toast[data-closing=true]{pointer-events:none;animation:toast-exit .22s cubic-bezier(.4,0,1,1) forwards}@keyframes toast-enter{0%{opacity:0;transform:translate3d(18px,-8px,0) scale(.98)}to{opacity:1;transform:translateZ(0) scale(1)}}@keyframes toast-exit{0%{opacity:1;transform:translateZ(0) scale(1);max-height:240px;margin-bottom:0}to{opacity:0;transform:translate3d(20px,-6px,0) scale(.97);max-height:0;margin-bottom:-12px}}";
|
|
7
|
+
var $ = Object.defineProperty, w = Object.getOwnPropertyDescriptor, a = (t, e, s, r) => {
|
|
8
|
+
for (var i = r > 1 ? void 0 : r ? w(e, s) : e, c = t.length - 1, l; c >= 0; c--)
|
|
9
|
+
(l = t[c]) && (i = (r ? l(e, s, i) : l(i)) || i);
|
|
10
|
+
return r && i && $(e, s, i), i;
|
|
11
|
+
};
|
|
12
|
+
const m = 6e3, C = 220, D = {
|
|
13
|
+
success: "uil-check-circle",
|
|
14
|
+
danger: "uil-exclamation-octagon",
|
|
15
|
+
warning: "uil-exclamation-triangle",
|
|
16
|
+
info: "uil-info-circle"
|
|
17
|
+
};
|
|
18
|
+
let o = class extends v {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments), this.type = "info", this.title = "", this.text = "", this.icon = "", this.closeable = !0, this.duration = m, this.autoDismiss = !0, this.isClosing = !1, this.remainingMs = m, this.startedAt = 0;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback(), this.remainingMs = this.duration, this.startTimer();
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
super.disconnectedCallback(), this.clearTimer(), this.closeTimerId && (clearTimeout(this.closeTimerId), this.closeTimerId = void 0);
|
|
27
|
+
}
|
|
28
|
+
updated(t) {
|
|
29
|
+
t.has("duration") && (this.remainingMs = this.duration, this.restartTimer()), (t.has("action") || t.has("autoDismiss") || t.has("type")) && this.restartTimer();
|
|
30
|
+
}
|
|
31
|
+
close(t = "manual") {
|
|
32
|
+
this.isClosing || (this.clearTimer(), this.isClosing = !0, this.closeTimerId = setTimeout(() => {
|
|
33
|
+
this.dispatchEvent(
|
|
34
|
+
new CustomEvent("toast-close", {
|
|
35
|
+
detail: { reason: t },
|
|
36
|
+
bubbles: !0,
|
|
37
|
+
composed: !0
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
}, C));
|
|
41
|
+
}
|
|
42
|
+
get canAutoDismiss() {
|
|
43
|
+
return this.autoDismiss && this.type !== "danger" && !this.hasActions;
|
|
44
|
+
}
|
|
45
|
+
get resolvedTitle() {
|
|
46
|
+
return this.title || this.text;
|
|
47
|
+
}
|
|
48
|
+
get resolvedText() {
|
|
49
|
+
return this.title ? this.text : "";
|
|
50
|
+
}
|
|
51
|
+
get resolvedIcon() {
|
|
52
|
+
return this.icon || D[this.type];
|
|
53
|
+
}
|
|
54
|
+
get hasActions() {
|
|
55
|
+
return !!this.action;
|
|
56
|
+
}
|
|
57
|
+
onActionClick(t) {
|
|
58
|
+
this.action && (t === "okay" ? this.action.onOkay?.() : this.action.onCancel?.(), (this.action.closeOnAction ?? !0) && this.close("manual"));
|
|
59
|
+
}
|
|
60
|
+
clearTimer() {
|
|
61
|
+
this.timerId && (clearTimeout(this.timerId), this.timerId = void 0);
|
|
62
|
+
}
|
|
63
|
+
startTimer() {
|
|
64
|
+
this.clearTimer(), !(!this.canAutoDismiss || this.remainingMs <= 0) && (this.startedAt = Date.now(), this.timerId = setTimeout(() => this.close("auto"), this.remainingMs));
|
|
65
|
+
}
|
|
66
|
+
pauseTimer() {
|
|
67
|
+
this.timerId && (this.clearTimer(), this.remainingMs = Math.max(0, this.remainingMs - (Date.now() - this.startedAt)));
|
|
68
|
+
}
|
|
69
|
+
resumeTimer() {
|
|
70
|
+
this.canAutoDismiss && this.startTimer();
|
|
71
|
+
}
|
|
72
|
+
restartTimer() {
|
|
73
|
+
this.clearTimer(), this.startTimer();
|
|
74
|
+
}
|
|
75
|
+
render() {
|
|
76
|
+
return h`
|
|
77
|
+
<article
|
|
78
|
+
class="toast toast--${this.type}"
|
|
79
|
+
data-closing=${this.isClosing ? "true" : "false"}
|
|
80
|
+
role="status"
|
|
81
|
+
aria-live=${this.type === "danger" ? "assertive" : "polite"}
|
|
82
|
+
@mouseenter=${this.pauseTimer}
|
|
83
|
+
@mouseleave=${this.resumeTimer}
|
|
84
|
+
>
|
|
85
|
+
<span class="toast__icon">
|
|
86
|
+
<ui-icon name=${this.resolvedIcon} size="20"></ui-icon>
|
|
87
|
+
</span>
|
|
88
|
+
|
|
89
|
+
<div class="toast__content">
|
|
90
|
+
<h4 class=${this.title ? "toast__title" : "toast__title toast__title--as-text"}>
|
|
91
|
+
${this.resolvedTitle}
|
|
92
|
+
</h4>
|
|
93
|
+
${this.resolvedText ? h`<p class="toast__text">${this.resolvedText}</p>` : p}
|
|
94
|
+
${this.hasActions ? h`
|
|
95
|
+
<div class="toast__actions">
|
|
96
|
+
<logosphere-button
|
|
97
|
+
variant="outline"
|
|
98
|
+
theme="primary"
|
|
99
|
+
@click=${() => this.onActionClick("okay")}
|
|
100
|
+
>
|
|
101
|
+
${this.action?.okayLabel || "Tamam"}
|
|
102
|
+
</logosphere-button>
|
|
103
|
+
<logosphere-button
|
|
104
|
+
variant="text"
|
|
105
|
+
theme="secondary"
|
|
106
|
+
@click=${() => this.onActionClick("cancel")}
|
|
107
|
+
>
|
|
108
|
+
${this.action?.cancelLabel || "İptal"}
|
|
109
|
+
</logosphere-button>
|
|
110
|
+
</div>
|
|
111
|
+
` : p}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
${this.closeable ? h`
|
|
115
|
+
<button class="toast__close" @click=${() => this.close("manual")} aria-label="Close">
|
|
116
|
+
<ui-icon name="uil-times" size="20"></ui-icon>
|
|
117
|
+
</button>
|
|
118
|
+
` : p}
|
|
119
|
+
</article>
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
o.styles = [
|
|
124
|
+
f`
|
|
125
|
+
${g(_)}
|
|
126
|
+
`
|
|
127
|
+
];
|
|
128
|
+
a([
|
|
129
|
+
n({ type: String })
|
|
130
|
+
], o.prototype, "type", 2);
|
|
131
|
+
a([
|
|
132
|
+
n({ type: String })
|
|
133
|
+
], o.prototype, "title", 2);
|
|
134
|
+
a([
|
|
135
|
+
n({ type: String })
|
|
136
|
+
], o.prototype, "text", 2);
|
|
137
|
+
a([
|
|
138
|
+
n({ type: String })
|
|
139
|
+
], o.prototype, "icon", 2);
|
|
140
|
+
a([
|
|
141
|
+
n({ type: Boolean })
|
|
142
|
+
], o.prototype, "closeable", 2);
|
|
143
|
+
a([
|
|
144
|
+
n({ type: Number })
|
|
145
|
+
], o.prototype, "duration", 2);
|
|
146
|
+
a([
|
|
147
|
+
n({ type: Boolean })
|
|
148
|
+
], o.prototype, "autoDismiss", 2);
|
|
149
|
+
a([
|
|
150
|
+
n({ attribute: !1 })
|
|
151
|
+
], o.prototype, "action", 2);
|
|
152
|
+
a([
|
|
153
|
+
b()
|
|
154
|
+
], o.prototype, "isClosing", 2);
|
|
155
|
+
o = a([
|
|
156
|
+
T("logosphere-toast")
|
|
157
|
+
], o);
|
|
158
|
+
const I = ":host{position:fixed;top:16px;right:16px;z-index:9999;width:min(420px,calc(100vw - 24px));box-sizing:border-box}.toast-container{display:flex;flex-direction:column;gap:12px}";
|
|
159
|
+
var A = Object.defineProperty, S = Object.getOwnPropertyDescriptor, x = (t, e, s, r) => {
|
|
160
|
+
for (var i = r > 1 ? void 0 : r ? S(e, s) : e, c = t.length - 1, l; c >= 0; c--)
|
|
161
|
+
(l = t[c]) && (i = (r ? l(e, s, i) : l(i)) || i);
|
|
162
|
+
return r && i && A(e, s, i), i;
|
|
163
|
+
};
|
|
164
|
+
const d = 4;
|
|
165
|
+
let u = class extends v {
|
|
166
|
+
constructor() {
|
|
167
|
+
super(...arguments), this.visibleToasts = [], this.queuedToasts = [];
|
|
168
|
+
}
|
|
169
|
+
show(t) {
|
|
170
|
+
const e = this.toToast(t);
|
|
171
|
+
return this.visibleToasts.length < d ? (this.visibleToasts = [e, ...this.visibleToasts], e.id) : (this.queuedToasts.push(e), e.id);
|
|
172
|
+
}
|
|
173
|
+
close(t) {
|
|
174
|
+
const e = this.visibleToasts.findIndex((s) => s.id === t);
|
|
175
|
+
if (e !== -1) {
|
|
176
|
+
const s = this.visibleToasts.slice();
|
|
177
|
+
s.splice(e, 1), this.visibleToasts = s, this.dequeue();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.queuedToasts = this.queuedToasts.filter((s) => s.id !== t);
|
|
181
|
+
}
|
|
182
|
+
clear() {
|
|
183
|
+
this.visibleToasts = [], this.queuedToasts = [];
|
|
184
|
+
}
|
|
185
|
+
dequeue() {
|
|
186
|
+
if (!this.queuedToasts.length || this.visibleToasts.length >= d) return;
|
|
187
|
+
const t = this.queuedToasts.shift();
|
|
188
|
+
t && (this.visibleToasts = [t, ...this.visibleToasts]);
|
|
189
|
+
}
|
|
190
|
+
toToast(t) {
|
|
191
|
+
return {
|
|
192
|
+
id: t.id || this.createId(),
|
|
193
|
+
type: t.type || "info",
|
|
194
|
+
title: t.title || "",
|
|
195
|
+
text: t.text,
|
|
196
|
+
icon: t.icon || "",
|
|
197
|
+
closeable: t.closeable ?? !0,
|
|
198
|
+
autoDismiss: t.autoDismiss ?? !0,
|
|
199
|
+
duration: t.duration ?? 6e3,
|
|
200
|
+
action: t.action
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
createId() {
|
|
204
|
+
return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
205
|
+
}
|
|
206
|
+
render() {
|
|
207
|
+
return h`
|
|
208
|
+
<div class="toast-container" role="region" aria-label="Notifications">
|
|
209
|
+
${y(
|
|
210
|
+
this.visibleToasts,
|
|
211
|
+
(t) => t.id,
|
|
212
|
+
(t) => h`
|
|
213
|
+
<logosphere-toast
|
|
214
|
+
.type=${t.type}
|
|
215
|
+
.title=${t.title}
|
|
216
|
+
.text=${t.text}
|
|
217
|
+
.icon=${t.icon}
|
|
218
|
+
.closeable=${t.closeable}
|
|
219
|
+
.autoDismiss=${t.autoDismiss}
|
|
220
|
+
.duration=${t.duration}
|
|
221
|
+
.action=${t.action}
|
|
222
|
+
@toast-close=${() => this.close(t.id)}
|
|
223
|
+
>
|
|
224
|
+
</logosphere-toast>
|
|
225
|
+
`
|
|
226
|
+
)}
|
|
227
|
+
</div>
|
|
228
|
+
`;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
u.styles = [f`${g(I)}`];
|
|
232
|
+
x([
|
|
233
|
+
b()
|
|
234
|
+
], u.prototype, "visibleToasts", 2);
|
|
235
|
+
u = x([
|
|
236
|
+
T("logosphere-toast-container")
|
|
237
|
+
], u);
|
|
238
|
+
class E {
|
|
239
|
+
static show(e) {
|
|
240
|
+
return this.getContainer().show(e);
|
|
241
|
+
}
|
|
242
|
+
static success(e) {
|
|
243
|
+
return this.show({ ...e, type: "success" });
|
|
244
|
+
}
|
|
245
|
+
static danger(e) {
|
|
246
|
+
return this.show({ ...e, type: "danger", autoDismiss: !1 });
|
|
247
|
+
}
|
|
248
|
+
static warning(e) {
|
|
249
|
+
return this.show({ ...e, type: "warning" });
|
|
250
|
+
}
|
|
251
|
+
static info(e) {
|
|
252
|
+
return this.show({ ...e, type: "info" });
|
|
253
|
+
}
|
|
254
|
+
static close(e) {
|
|
255
|
+
this.getContainer().close(e);
|
|
256
|
+
}
|
|
257
|
+
static clear() {
|
|
258
|
+
this.getContainer().clear();
|
|
259
|
+
}
|
|
260
|
+
static getContainer() {
|
|
261
|
+
if (this.container && document.body.contains(this.container))
|
|
262
|
+
return this.container;
|
|
263
|
+
const e = document.querySelector("logosphere-toast-container");
|
|
264
|
+
if (e && e instanceof u)
|
|
265
|
+
return this.container = e, e;
|
|
266
|
+
const s = document.createElement("logosphere-toast-container");
|
|
267
|
+
return document.body.appendChild(s), this.container = s, s;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
o as L,
|
|
272
|
+
E as T,
|
|
273
|
+
u as a
|
|
274
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";const o=require("lit"),a=require("lit/decorators.js"),m=require("lit/directives/repeat.js");require("./ui-icon-DWl7I5BQ.cjs");require("./button-vdNReBMi.cjs");const d=":host{display:block}.toast{position:relative;display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:start;width:100%;box-sizing:border-box;border-radius:var(--radius-md);border-left:4px solid var(--toast-accent);background:#fff;box-shadow:var(--shadow-md);padding:var(--spacing-4);color:#3d3d3d;font-family:var(--font-family-base);animation:toast-enter .22s cubic-bezier(.2,.8,.2,1);transform-origin:top right}.toast__icon{display:inline-flex;margin-top:2px;color:var(--toast-accent)}.toast__content{min-width:0}.toast__title{margin:0;font-size:var(--font-size-lg);line-height:var(--line-height-tight);font-weight:var(--font-weight-semibold)}.toast__title--as-text{font-size:var(--font-size-base);line-height:var(--line-height-normal);font-weight:var(--font-weight-regular);color:#555}.toast__text{margin:4px 0 0;font-size:var(--font-size-base);line-height:var(--line-height-normal);color:#555}.toast__actions{display:flex;gap:10px;margin-top:12px}.toast__close{border:0;background:transparent;color:#5a5a5a;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;margin-top:2px}.toast__close:hover{color:#2f2f2f}.toast--success{--toast-accent: var(--color-success-active)}.toast--danger{--toast-accent: var(--color-danger-active)}.toast--warning{--toast-accent: var(--color-warning-active)}.toast--info{--toast-accent: var(--color-info-active)}.toast[data-closing=true]{pointer-events:none;animation:toast-exit .22s cubic-bezier(.4,0,1,1) forwards}@keyframes toast-enter{0%{opacity:0;transform:translate3d(18px,-8px,0) scale(.98)}to{opacity:1;transform:translateZ(0) scale(1)}}@keyframes toast-exit{0%{opacity:1;transform:translateZ(0) scale(1);max-height:240px;margin-bottom:0}to{opacity:0;transform:translate3d(20px,-6px,0) scale(.97);max-height:0;margin-bottom:-12px}}";var g=Object.defineProperty,f=Object.getOwnPropertyDescriptor,r=(n,t,e,s)=>{for(var i=s>1?void 0:s?f(t,e):t,c=n.length-1,l;c>=0;c--)(l=n[c])&&(i=(s?l(t,e,i):l(i))||i);return s&&i&&g(t,e,i),i};const h=6e3,T=220,v={success:"uil-check-circle",danger:"uil-exclamation-octagon",warning:"uil-exclamation-triangle",info:"uil-info-circle"};exports.LogosphereToast=class extends o.LitElement{constructor(){super(...arguments),this.type="info",this.title="",this.text="",this.icon="",this.closeable=!0,this.duration=h,this.autoDismiss=!0,this.isClosing=!1,this.remainingMs=h,this.startedAt=0}connectedCallback(){super.connectedCallback(),this.remainingMs=this.duration,this.startTimer()}disconnectedCallback(){super.disconnectedCallback(),this.clearTimer(),this.closeTimerId&&(clearTimeout(this.closeTimerId),this.closeTimerId=void 0)}updated(t){t.has("duration")&&(this.remainingMs=this.duration,this.restartTimer()),(t.has("action")||t.has("autoDismiss")||t.has("type"))&&this.restartTimer()}close(t="manual"){this.isClosing||(this.clearTimer(),this.isClosing=!0,this.closeTimerId=setTimeout(()=>{this.dispatchEvent(new CustomEvent("toast-close",{detail:{reason:t},bubbles:!0,composed:!0}))},T))}get canAutoDismiss(){return this.autoDismiss&&this.type!=="danger"&&!this.hasActions}get resolvedTitle(){return this.title||this.text}get resolvedText(){return this.title?this.text:""}get resolvedIcon(){return this.icon||v[this.type]}get hasActions(){return!!this.action}onActionClick(t){this.action&&(t==="okay"?this.action.onOkay?.():this.action.onCancel?.(),(this.action.closeOnAction??!0)&&this.close("manual"))}clearTimer(){this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0)}startTimer(){this.clearTimer(),!(!this.canAutoDismiss||this.remainingMs<=0)&&(this.startedAt=Date.now(),this.timerId=setTimeout(()=>this.close("auto"),this.remainingMs))}pauseTimer(){this.timerId&&(this.clearTimer(),this.remainingMs=Math.max(0,this.remainingMs-(Date.now()-this.startedAt)))}resumeTimer(){this.canAutoDismiss&&this.startTimer()}restartTimer(){this.clearTimer(),this.startTimer()}render(){return o.html`
|
|
2
|
+
<article
|
|
3
|
+
class="toast toast--${this.type}"
|
|
4
|
+
data-closing=${this.isClosing?"true":"false"}
|
|
5
|
+
role="status"
|
|
6
|
+
aria-live=${this.type==="danger"?"assertive":"polite"}
|
|
7
|
+
@mouseenter=${this.pauseTimer}
|
|
8
|
+
@mouseleave=${this.resumeTimer}
|
|
9
|
+
>
|
|
10
|
+
<span class="toast__icon">
|
|
11
|
+
<ui-icon name=${this.resolvedIcon} size="20"></ui-icon>
|
|
12
|
+
</span>
|
|
13
|
+
|
|
14
|
+
<div class="toast__content">
|
|
15
|
+
<h4 class=${this.title?"toast__title":"toast__title toast__title--as-text"}>
|
|
16
|
+
${this.resolvedTitle}
|
|
17
|
+
</h4>
|
|
18
|
+
${this.resolvedText?o.html`<p class="toast__text">${this.resolvedText}</p>`:o.nothing}
|
|
19
|
+
${this.hasActions?o.html`
|
|
20
|
+
<div class="toast__actions">
|
|
21
|
+
<logosphere-button
|
|
22
|
+
variant="outline"
|
|
23
|
+
theme="primary"
|
|
24
|
+
@click=${()=>this.onActionClick("okay")}
|
|
25
|
+
>
|
|
26
|
+
${this.action?.okayLabel||"Tamam"}
|
|
27
|
+
</logosphere-button>
|
|
28
|
+
<logosphere-button
|
|
29
|
+
variant="text"
|
|
30
|
+
theme="secondary"
|
|
31
|
+
@click=${()=>this.onActionClick("cancel")}
|
|
32
|
+
>
|
|
33
|
+
${this.action?.cancelLabel||"İptal"}
|
|
34
|
+
</logosphere-button>
|
|
35
|
+
</div>
|
|
36
|
+
`:o.nothing}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
${this.closeable?o.html`
|
|
40
|
+
<button class="toast__close" @click=${()=>this.close("manual")} aria-label="Close">
|
|
41
|
+
<ui-icon name="uil-times" size="20"></ui-icon>
|
|
42
|
+
</button>
|
|
43
|
+
`:o.nothing}
|
|
44
|
+
</article>
|
|
45
|
+
`}};exports.LogosphereToast.styles=[o.css`
|
|
46
|
+
${o.unsafeCSS(d)}
|
|
47
|
+
`];r([a.property({type:String})],exports.LogosphereToast.prototype,"type",2);r([a.property({type:String})],exports.LogosphereToast.prototype,"title",2);r([a.property({type:String})],exports.LogosphereToast.prototype,"text",2);r([a.property({type:String})],exports.LogosphereToast.prototype,"icon",2);r([a.property({type:Boolean})],exports.LogosphereToast.prototype,"closeable",2);r([a.property({type:Number})],exports.LogosphereToast.prototype,"duration",2);r([a.property({type:Boolean})],exports.LogosphereToast.prototype,"autoDismiss",2);r([a.property({attribute:!1})],exports.LogosphereToast.prototype,"action",2);r([a.state()],exports.LogosphereToast.prototype,"isClosing",2);exports.LogosphereToast=r([a.customElement("logosphere-toast")],exports.LogosphereToast);const b=":host{position:fixed;top:16px;right:16px;z-index:9999;width:min(420px,calc(100vw - 24px));box-sizing:border-box}.toast-container{display:flex;flex-direction:column;gap:12px}";var y=Object.defineProperty,x=Object.getOwnPropertyDescriptor,p=(n,t,e,s)=>{for(var i=s>1?void 0:s?x(t,e):t,c=n.length-1,l;c>=0;c--)(l=n[c])&&(i=(s?l(t,e,i):l(i))||i);return s&&i&&y(t,e,i),i};const u=4;exports.LogosphereToastContainer=class extends o.LitElement{constructor(){super(...arguments),this.visibleToasts=[],this.queuedToasts=[]}show(t){const e=this.toToast(t);return this.visibleToasts.length<u?(this.visibleToasts=[e,...this.visibleToasts],e.id):(this.queuedToasts.push(e),e.id)}close(t){const e=this.visibleToasts.findIndex(s=>s.id===t);if(e!==-1){const s=this.visibleToasts.slice();s.splice(e,1),this.visibleToasts=s,this.dequeue();return}this.queuedToasts=this.queuedToasts.filter(s=>s.id!==t)}clear(){this.visibleToasts=[],this.queuedToasts=[]}dequeue(){if(!this.queuedToasts.length||this.visibleToasts.length>=u)return;const t=this.queuedToasts.shift();t&&(this.visibleToasts=[t,...this.visibleToasts])}toToast(t){return{id:t.id||this.createId(),type:t.type||"info",title:t.title||"",text:t.text,icon:t.icon||"",closeable:t.closeable??!0,autoDismiss:t.autoDismiss??!0,duration:t.duration??6e3,action:t.action}}createId(){return`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}render(){return o.html`
|
|
48
|
+
<div class="toast-container" role="region" aria-label="Notifications">
|
|
49
|
+
${m.repeat(this.visibleToasts,t=>t.id,t=>o.html`
|
|
50
|
+
<logosphere-toast
|
|
51
|
+
.type=${t.type}
|
|
52
|
+
.title=${t.title}
|
|
53
|
+
.text=${t.text}
|
|
54
|
+
.icon=${t.icon}
|
|
55
|
+
.closeable=${t.closeable}
|
|
56
|
+
.autoDismiss=${t.autoDismiss}
|
|
57
|
+
.duration=${t.duration}
|
|
58
|
+
.action=${t.action}
|
|
59
|
+
@toast-close=${()=>this.close(t.id)}
|
|
60
|
+
>
|
|
61
|
+
</logosphere-toast>
|
|
62
|
+
`)}
|
|
63
|
+
</div>
|
|
64
|
+
`}};exports.LogosphereToastContainer.styles=[o.css`${o.unsafeCSS(b)}`];p([a.state()],exports.LogosphereToastContainer.prototype,"visibleToasts",2);exports.LogosphereToastContainer=p([a.customElement("logosphere-toast-container")],exports.LogosphereToastContainer);class _{static show(t){return this.getContainer().show(t)}static success(t){return this.show({...t,type:"success"})}static danger(t){return this.show({...t,type:"danger",autoDismiss:!1})}static warning(t){return this.show({...t,type:"warning"})}static info(t){return this.show({...t,type:"info"})}static close(t){this.getContainer().close(t)}static clear(){this.getContainer().clear()}static getContainer(){if(this.container&&document.body.contains(this.container))return this.container;const t=document.querySelector("logosphere-toast-container");if(t&&t instanceof exports.LogosphereToastContainer)return this.container=t,t;const e=document.createElement("logosphere-toast-container");return document.body.appendChild(e),this.container=e,e}}exports.ToastService=_;
|
package/dist/toast.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toast-container-D2dyP20J.cjs");Object.defineProperty(exports,"LogosphereToast",{enumerable:!0,get:()=>e.LogosphereToast});Object.defineProperty(exports,"LogosphereToastContainer",{enumerable:!0,get:()=>e.LogosphereToastContainer});exports.ToastService=e.ToastService;
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { unsafeCSS as _, css as u, LitElement as v, html as o, nothing as d } from "lit";
|
|
2
|
+
import { property as c, state as p, customElement as g } from "lit/decorators.js";
|
|
3
|
+
import "./badge-BhINg1p5.js";
|
|
4
|
+
import "./popover-M5ZcS5rj.js";
|
|
5
|
+
import "./ui-icon-BeR-PaPg.js";
|
|
6
|
+
const f = ':host{display:block}.tree{width:100%;font-family:var(--font-family-base)}.tree__list,.tree__children{list-style:none;margin:0;padding:0}.tree__item{margin:0;padding:0}.tree__row{display:flex;align-items:center;gap:var(--spacing-1);min-width:0;padding:var(--spacing-2) var(--spacing-3);padding-left:calc(var(--spacing-3) + (var(--tree-level, 0) * 14px));border-radius:var(--radius-sm);color:var(--color-body-color);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.tree--icons .tree__row{justify-content:center;padding:0;width:44px;min-width:44px;height:44px;min-height:44px;margin:0 auto;box-sizing:border-box}.tree__row:hover{background-color:var(--color-light)}.tree__row:focus-visible{outline:2px solid var(--color-secondary);outline-offset:1px}.tree__row--disabled{opacity:.5;cursor:not-allowed}.tree__row--active .tree__label,.tree__row--active .tree__icon{color:var(--color-primary)}.tree:not(.tree--icons) .tree__row--active{background-color:var(--color-light)}.tree__icon{width:20px;min-width:20px;display:inline-flex;align-items:center;justify-content:center;color:inherit;margin-right:calc(var(--spacing-2) - var(--spacing-1))}.tree__leading{width:20px;min-width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;color:var(--color-tertiary);margin-right:calc(var(--spacing-2) - var(--spacing-1))}.tree__leading--bullet:after{content:"";width:8px;height:8px;border:1.5px solid var(--color-tertiary);border-radius:var(--radius-full);background:transparent;box-sizing:border-box}.tree__leading--dash:after{content:"";display:block;width:10px;height:2px;background:var(--color-tertiary);border-radius:1px 0 0 1px}.tree__row--active .tree__leading--bullet:after{border-color:var(--color-primary)}.tree__row--active .tree__leading--dash:after{background:var(--color-primary)}.tree--icons .tree__icon{width:24px;min-width:24px;height:24px;margin-right:0}.tree--icons .tree__row--active{background-color:var(--color-light)}.tree--icons .tree__row--active .tree__icon{color:var(--color-primary)}.tree--icons .tree__row--active:hover{background-color:var(--color-light)}.tree__chevron-btn{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;color:var(--color-secondary);cursor:pointer;padding:0;flex-shrink:0}.tree__chevron-btn--right{margin-left:auto}.tree__chevron{transform:rotate(-90deg);transition:transform var(--transition-speed-fast) var(--transition-timing)}.tree__chevron--open{transform:rotate(0)}.tree__chevron-spacer{width:20px;height:20px;flex-shrink:0}.tree__label{display:block;min-width:0;width:100%;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--font-size-sm);color:inherit}.tree__label-popover{display:block;min-width:0;flex:1 1 auto;width:100%;max-width:100%;overflow:hidden;--popover-wrapper-display: block;--popover-wrapper-width: 100%;--popover-wrapper-min-width: 0;--popover-wrapper-max-width: 100%;--popover-trigger-display: flex;--popover-trigger-width: 100%;--popover-trigger-min-width: 0;--popover-trigger-max-width: 100%;--popover-min-width: max-content;--popover-max-width: min(320px, calc(100vw - 16px) );--popover-body-padding: var(--spacing-2) var(--spacing-3)}.tree__label-popover::part(trigger){display:flex;min-width:0;width:100%}.tree__label-tooltip{display:block;overflow-wrap:anywhere;color:var(--color-body-color)}.tree__suffix{margin-left:auto;display:inline-flex;align-items:center;gap:var(--spacing-1);flex-shrink:0}.tree__suffix+.tree__chevron-btn--right{margin-left:var(--spacing-1)}';
|
|
7
|
+
var b = Object.defineProperty, w = Object.getOwnPropertyDescriptor, a = (e, r, t, i) => {
|
|
8
|
+
for (var s = i > 1 ? void 0 : i ? w(r, t) : r, h = e.length - 1, l; h >= 0; h--)
|
|
9
|
+
(l = e[h]) && (s = (i ? l(r, t, s) : l(s)) || s);
|
|
10
|
+
return i && s && b(r, t, s), s;
|
|
11
|
+
};
|
|
12
|
+
let n = class extends v {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.items = [], this.expandedIds = [], this.expandOnLabelClick = !0, this.chevronPosition = "left", this.showLabels = !0, this.leading = !0, this.iconSize = 16, this._expandedSet = /* @__PURE__ */ new Set(), this._overflowedLabelIds = /* @__PURE__ */ new Set(), this._overflowMeasureFrame = 0;
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
super.connectedCallback(), !(typeof ResizeObserver > "u") && (this._resizeObserver = new ResizeObserver(() => {
|
|
18
|
+
this._scheduleOverflowedLabelSync();
|
|
19
|
+
}), this._resizeObserver.observe(this));
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
super.disconnectedCallback(), this._resizeObserver?.disconnect(), this._resizeObserver = void 0, this._overflowMeasureFrame && cancelAnimationFrame(this._overflowMeasureFrame);
|
|
23
|
+
}
|
|
24
|
+
willUpdate(e) {
|
|
25
|
+
e.has("expandedIds") && (this._expandedSet = new Set(this.expandedIds ?? []));
|
|
26
|
+
}
|
|
27
|
+
updated(e) {
|
|
28
|
+
(e.has("items") || e.has("showLabels") || e.has("expandedIds")) && this._scheduleOverflowedLabelSync();
|
|
29
|
+
}
|
|
30
|
+
_scheduleOverflowedLabelSync() {
|
|
31
|
+
!this.showLabels || this._overflowMeasureFrame || (this._overflowMeasureFrame = requestAnimationFrame(() => {
|
|
32
|
+
this._overflowMeasureFrame = 0, this._syncOverflowedLabels();
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
_syncOverflowedLabels() {
|
|
36
|
+
const e = Array.from(this.shadowRoot?.querySelectorAll("[data-tree-label]") ?? []), r = /* @__PURE__ */ new Set();
|
|
37
|
+
e.forEach((t) => {
|
|
38
|
+
const i = t.dataset.itemId;
|
|
39
|
+
i && t.scrollWidth > t.clientWidth && r.add(i);
|
|
40
|
+
}), !this._setsEqual(this._overflowedLabelIds, r) && (this._overflowedLabelIds = r);
|
|
41
|
+
}
|
|
42
|
+
_setsEqual(e, r) {
|
|
43
|
+
if (e.size !== r.size) return !1;
|
|
44
|
+
for (const t of e)
|
|
45
|
+
if (!r.has(t)) return !1;
|
|
46
|
+
return !0;
|
|
47
|
+
}
|
|
48
|
+
_hasActiveDescendant(e) {
|
|
49
|
+
return !!e.children?.some((r) => r.active || this._hasActiveDescendant(r));
|
|
50
|
+
}
|
|
51
|
+
_isExpanded(e) {
|
|
52
|
+
return this._expandedSet.has(e);
|
|
53
|
+
}
|
|
54
|
+
_emitToggle(e, r) {
|
|
55
|
+
this.dispatchEvent(
|
|
56
|
+
new CustomEvent("toggle", {
|
|
57
|
+
detail: { item: e, expanded: r },
|
|
58
|
+
bubbles: !0,
|
|
59
|
+
composed: !0
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
_emitItemClick(e) {
|
|
64
|
+
this.dispatchEvent(
|
|
65
|
+
new CustomEvent("item-click", {
|
|
66
|
+
detail: { item: e },
|
|
67
|
+
bubbles: !0,
|
|
68
|
+
composed: !0
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
_emitNodeClick(e, r) {
|
|
73
|
+
this.dispatchEvent(
|
|
74
|
+
new CustomEvent("node-click", {
|
|
75
|
+
detail: { item: e, hasChildren: r },
|
|
76
|
+
bubbles: !0,
|
|
77
|
+
composed: !0
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
_setExpanded(e, r) {
|
|
82
|
+
r ? this._expandedSet.add(e.id) : this._expandedSet.delete(e.id), this.expandedIds = Array.from(this._expandedSet), this._emitToggle(e, r);
|
|
83
|
+
}
|
|
84
|
+
_toggle(e, r) {
|
|
85
|
+
r.stopPropagation(), !(e.disabled || !e.children?.length) && this._setExpanded(e, !this._isExpanded(e.id));
|
|
86
|
+
}
|
|
87
|
+
_handleItemClick(e, r) {
|
|
88
|
+
if (r.stopPropagation(), e.disabled) return;
|
|
89
|
+
const t = !!e.children?.length;
|
|
90
|
+
if (this._emitNodeClick(e, t), t && this.expandOnLabelClick) {
|
|
91
|
+
this._setExpanded(e, !this._isExpanded(e.id));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
t || (e.onClick?.(e), this._emitItemClick(e));
|
|
95
|
+
}
|
|
96
|
+
_handleRowKeydown(e, r) {
|
|
97
|
+
r.key !== "Enter" && r.key !== " " || (r.preventDefault(), this._handleItemClick(e, r));
|
|
98
|
+
}
|
|
99
|
+
_renderRootIcon(e) {
|
|
100
|
+
return e.iconName ? o`
|
|
101
|
+
<span class="tree__icon">
|
|
102
|
+
<ui-icon name=${e.iconName} .size=${this.iconSize}></ui-icon>
|
|
103
|
+
</span>
|
|
104
|
+
` : o`
|
|
105
|
+
<span class="tree__icon">
|
|
106
|
+
<slot name="icon-${e.id}"></slot>
|
|
107
|
+
</span>
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
_renderLeading(e, r) {
|
|
111
|
+
return this.showLabels ? r === 0 ? this._renderRootIcon(e) : this.leading ? r === 1 ? o`<span class="tree__leading tree__leading--bullet" aria-hidden="true"></span>` : r === 2 ? o`<span class="tree__leading tree__leading--dash" aria-hidden="true"></span>` : o`<span class="tree__leading tree__leading--empty" aria-hidden="true"></span>` : d : this._renderRootIcon(e);
|
|
112
|
+
}
|
|
113
|
+
_renderBadges(e) {
|
|
114
|
+
return !this.showLabels || !e.badges?.length ? d : o`
|
|
115
|
+
<span class="tree__suffix">
|
|
116
|
+
${e.badges.map(
|
|
117
|
+
(r) => o`
|
|
118
|
+
<logosphere-badge
|
|
119
|
+
text=${r.text}
|
|
120
|
+
variant=${r.variant ?? "default"}
|
|
121
|
+
size=${r.size ?? "default"}
|
|
122
|
+
?isRound=${r.isRound ?? !1}
|
|
123
|
+
></logosphere-badge>
|
|
124
|
+
`
|
|
125
|
+
)}
|
|
126
|
+
</span>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
_renderLabel(e) {
|
|
130
|
+
if (!this.showLabels) return d;
|
|
131
|
+
const r = this._overflowedLabelIds.has(e.id);
|
|
132
|
+
return o`
|
|
133
|
+
<logosphere-popover
|
|
134
|
+
class="tree__label-popover"
|
|
135
|
+
trigger="hover"
|
|
136
|
+
placement="top"
|
|
137
|
+
.offset=${4}
|
|
138
|
+
.delay=${500}
|
|
139
|
+
?disabled=${!r}
|
|
140
|
+
noArrow
|
|
141
|
+
>
|
|
142
|
+
<span slot="trigger" class="tree__label" data-tree-label data-item-id=${e.id}>
|
|
143
|
+
${e.label}
|
|
144
|
+
</span>
|
|
145
|
+
<span class="tree__label-tooltip">${e.label}</span>
|
|
146
|
+
</logosphere-popover>
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
_renderChevron(e, r) {
|
|
150
|
+
const t = !!e.children?.length;
|
|
151
|
+
return this.showLabels ? t ? o`
|
|
152
|
+
<button
|
|
153
|
+
type="button"
|
|
154
|
+
class="tree__chevron-btn ${this.chevronPosition === "right" ? "tree__chevron-btn--right" : ""}"
|
|
155
|
+
aria-label=${r ? "Collapse" : "Expand"}
|
|
156
|
+
@click=${(i) => this._toggle(e, i)}
|
|
157
|
+
>
|
|
158
|
+
<ui-icon
|
|
159
|
+
class="tree__chevron ${r ? "tree__chevron--open" : ""}"
|
|
160
|
+
name="uil-angle-down"
|
|
161
|
+
size="14"
|
|
162
|
+
></ui-icon>
|
|
163
|
+
</button>
|
|
164
|
+
` : o`<span class="tree__chevron-spacer"></span>` : d;
|
|
165
|
+
}
|
|
166
|
+
_renderNode(e, r) {
|
|
167
|
+
const t = !!e.children?.length, i = t ? this._isExpanded(e.id) : !1, s = this.showLabels ? `--tree-level:${r};` : "--tree-level:0;", h = e.active || !this.showLabels && this._hasActiveDescendant(e);
|
|
168
|
+
return o`
|
|
169
|
+
<li class="tree__item">
|
|
170
|
+
<div
|
|
171
|
+
class="tree__row ${e.disabled ? "tree__row--disabled" : ""} ${h ? "tree__row--active" : ""}"
|
|
172
|
+
style=${s}
|
|
173
|
+
role="button"
|
|
174
|
+
tabindex=${e.disabled ? -1 : 0}
|
|
175
|
+
@click=${(l) => this._handleItemClick(e, l)}
|
|
176
|
+
@keydown=${(l) => this._handleRowKeydown(e, l)}
|
|
177
|
+
title=${this.showLabels ? "" : e.label}
|
|
178
|
+
>
|
|
179
|
+
${this.chevronPosition === "left" ? this._renderChevron(e, i) : d}
|
|
180
|
+
${this._renderLeading(e, r)}
|
|
181
|
+
${this._renderLabel(e)}
|
|
182
|
+
${this._renderBadges(e)}
|
|
183
|
+
${this.chevronPosition === "right" ? this._renderChevron(e, i) : d}
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
${this.showLabels && t && i ? o`
|
|
187
|
+
<ul class="tree__children">
|
|
188
|
+
${e.children.map((l) => this._renderNode(l, r + 1))}
|
|
189
|
+
</ul>
|
|
190
|
+
` : d}
|
|
191
|
+
</li>
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
render() {
|
|
195
|
+
return o`
|
|
196
|
+
<nav class="tree ${this.showLabels ? "" : "tree--icons"}" aria-label="Tree Menu">
|
|
197
|
+
<ul class="tree__list">
|
|
198
|
+
${this.items.map((e) => this._renderNode(e, 0))}
|
|
199
|
+
</ul>
|
|
200
|
+
</nav>
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
n.styles = [u`${_(f)}`];
|
|
205
|
+
a([
|
|
206
|
+
c({ attribute: !1 })
|
|
207
|
+
], n.prototype, "items", 2);
|
|
208
|
+
a([
|
|
209
|
+
c({ type: Array })
|
|
210
|
+
], n.prototype, "expandedIds", 2);
|
|
211
|
+
a([
|
|
212
|
+
c({ type: Boolean })
|
|
213
|
+
], n.prototype, "expandOnLabelClick", 2);
|
|
214
|
+
a([
|
|
215
|
+
c({ type: String })
|
|
216
|
+
], n.prototype, "chevronPosition", 2);
|
|
217
|
+
a([
|
|
218
|
+
c({ type: Boolean })
|
|
219
|
+
], n.prototype, "showLabels", 2);
|
|
220
|
+
a([
|
|
221
|
+
c({ type: Boolean, reflect: !0 })
|
|
222
|
+
], n.prototype, "leading", 2);
|
|
223
|
+
a([
|
|
224
|
+
c({ type: Number })
|
|
225
|
+
], n.prototype, "iconSize", 2);
|
|
226
|
+
a([
|
|
227
|
+
p()
|
|
228
|
+
], n.prototype, "_expandedSet", 2);
|
|
229
|
+
a([
|
|
230
|
+
p()
|
|
231
|
+
], n.prototype, "_overflowedLabelIds", 2);
|
|
232
|
+
n = a([
|
|
233
|
+
g("logosphere-tree-menu")
|
|
234
|
+
], n);
|
|
235
|
+
export {
|
|
236
|
+
n as T
|
|
237
|
+
};
|