@logosphere-ui/core 0.0.0-alpha.54 → 0.0.0-alpha.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,521 @@
1
+ import { unsafeCSS as $, css as z, LitElement as K, nothing as _, html as c } from "lit";
2
+ import { property as h, state as y, customElement as W } from "lit/decorators.js";
3
+ import { repeat as m } from "lit/directives/repeat.js";
4
+ import "./checkbox-CTfbav6M.js";
5
+ import "./input-N3Z8D7q1.js";
6
+ import "./ui-icon-BeR-PaPg.js";
7
+ const E = ':host{display:block;width:100%;box-sizing:border-box;font-family:var(--font-family-base)}*{box-sizing:border-box}.table{width:100%;border:1px solid var(--color-border);border-radius:var(--radius-md);overflow:hidden}.table--borderless{border:0;border-radius:0}.table__scroll{width:100%;overflow-x:auto;overflow-y:auto;-webkit-overflow-scrolling:touch;scrollbar-width:thin;scrollbar-color:var(--color-tertiary) var(--color-light)}.table__inner{display:flex;flex-direction:column}.table__header{display:flex;position:sticky;top:0;z-index:10;border-radius:var(--radius-md) var(--radius-md) 0 0}.table__body{display:flex;flex-direction:column}.table__row{display:flex;cursor:default;background-color:var(--color-body-bg);transition:background-color var(--transition-speed-fast) var(--transition-timing)}.table__row:hover{background-color:var(--color-light)}.table__body .table__row:last-child .table__cell{border-bottom:0}.table__cell{display:flex;align-items:center;flex-grow:1;flex-shrink:0;height:36px;padding:var(--spacing-0-5) var(--spacing-2);border-bottom:1px solid var(--color-border);overflow:hidden}.table__cell--selection{flex-grow:0;padding-right:0;padding-left:0}.table__cell--selection logosphere-checkbox{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;line-height:0}.table__cell--action{flex-grow:0;gap:var(--spacing-1)}.table__cell--header{position:relative;gap:var(--spacing-1);background-color:var(--color-light);padding:var(--spacing-1) var(--spacing-2)}.table__cell--searchable{padding-right:var(--spacing-2)}.table__cell--search-active{justify-content:center!important}.table__cell--sortable{cursor:pointer;-webkit-user-select:none;user-select:none}.table__cell--sortable:focus-visible{outline:2px solid var(--color-primary);outline-offset:-2px}.table__cell--header:first-child{border-top-left-radius:var(--radius-md)}.table__cell--header:last-child{border-top-right-radius:var(--radius-md)}.table--borderless .table__header,.table--borderless .table__cell--header:first-child,.table--borderless .table__cell--header:last-child{border-radius:0}.table__cell--sticky{position:sticky;z-index:2;background-color:var(--color-body-bg)}.table__row:hover .table__cell--sticky{background-color:var(--color-light)}.table__cell--header.table__cell--sticky{top:0;z-index:1;background-color:var(--color-light)}.table__cell--selection.table__cell--sticky{z-index:2}.table__cell--header.table__cell--selection.table__cell--sticky{top:0;z-index:2}.table__cell--sticky-edge{box-shadow:2px 0 4px -2px #00000026}.table__resize-handle{position:absolute;top:0;right:-4px;width:8px;height:100%;cursor:col-resize;touch-action:none;z-index:10}.table__resize-handle:before{content:"";position:absolute;top:10px;bottom:10px;left:50%;width:3px;background-color:var(--color-border);transform:translate(-50%)}.table__resize-handle:hover:before,.table__resize-handle:active:before{background-color:var(--color-primary)}.table__header-main{display:flex;align-items:center;flex:1 1 auto;min-width:0}.table__header-label{font-family:var(--font-family-base);font-size:var(--font-size-xs);font-weight:var(--font-weight-semibold);line-height:18px;letter-spacing:-.12px;color:var(--color-body-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table__header-actions{display:inline-flex;align-items:center;justify-content:flex-end;flex:0 0 auto;margin-left:auto}.table__sort-indicator{display:inline-flex;align-items:center;pointer-events:none}.table__sort-arrow{width:16px;height:16px;color:var(--color-primary)}.table__sort-order{min-width:0;height:auto;display:inline-flex;align-items:center;justify-content:center;margin-left:-2px;color:var(--color-primary);font-size:10px;font-weight:var(--font-weight-semibold);line-height:1}.table__search-toggle{width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:var(--radius-sm);background:transparent;color:var(--color-tertiary);cursor:pointer}.table__search-toggle:hover,.table__search-toggle[aria-pressed=true]{color:var(--color-primary);background-color:var(--color-body-bg)}.table__search-toggle-icon{width:16px;height:16px}.table__search-input{width:100%;min-width:0;--formfield-height: 24px;--formfield-min-height: 24px;--formfield-padding: 0 var(--spacing-1);--input-field-height: 16px;--formfield-border-radius: var(--radius-sm)}.table__cell-text{font-family:var(--font-family-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-regular);line-height:20px;letter-spacing:-.14px;color:var(--color-body-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table__empty{display:flex;align-items:center;justify-content:center;min-height:120px;padding:var(--spacing-4);color:var(--color-tertiary);font-family:var(--font-family-base);font-size:var(--font-size-sm);box-sizing:border-box}.table__scroll::-webkit-scrollbar{height:8px;width:8px}.table__scroll::-webkit-scrollbar-track{background:var(--color-light);border-radius:var(--radius-sm)}.table__scroll::-webkit-scrollbar-thumb{background-color:var(--color-tertiary);border-radius:var(--radius-sm)}.table__scroll::-webkit-scrollbar-thumb:hover{background-color:var(--color-secondary)}';
8
+ var H = Object.defineProperty, R = Object.getOwnPropertyDescriptor, n = (e, t, i, s) => {
9
+ for (var r = s > 1 ? void 0 : s ? R(t, i) : t, l = e.length - 1, d; l >= 0; l--)
10
+ (d = e[l]) && (r = (s ? d(t, i, r) : d(r)) || r);
11
+ return s && r && H(t, i, r), r;
12
+ };
13
+ const T = 160, x = 96, w = 48, M = 300, g = "__selection__", P = 60;
14
+ function D(e) {
15
+ return e === "center" ? "center" : e === "right" ? "flex-end" : "flex-start";
16
+ }
17
+ let o = class extends K {
18
+ constructor() {
19
+ super(...arguments), this.columns = [], this.rows = [], this.rowKey = "id", this.emptyMessage = "Kayıt bulunamadı", this.selection = !1, this.stickySelection = !1, this.resizable = !1, this.borderless = !1, this.sortStates = [], this.selectedKeys = /* @__PURE__ */ new Set(), this.searchValues = /* @__PURE__ */ new Map(), this.activeSearchKeys = /* @__PURE__ */ new Set(), this.columnWidths = /* @__PURE__ */ new Map(), this.warnedSortableWithoutHandlerKey = "", this.warnedSearchableWithoutHandlerKey = "", this.warnedSelectionWithoutHandler = !1, this.searchTimers = /* @__PURE__ */ new Map(), this.resizing = !1, this.resizeStartX = 0, this.resizeStartWidth = 0, this._handleResizePointerDown = (e, t) => {
20
+ e.preventDefault(), e.stopPropagation(), this.resizing = !0, this.resizeColumn = t, this.resizeStartX = e.clientX, this.resizeStartWidth = this._effectiveWidth(t), window.addEventListener("pointermove", this._handleResizePointerMove), window.addEventListener("pointerup", this._handleResizePointerUp), window.addEventListener("pointercancel", this._handleResizePointerUp);
21
+ }, this._handleResizePointerMove = (e) => {
22
+ if (!this.resizing || !this.resizeColumn) return;
23
+ const t = e.clientX - this.resizeStartX, i = Math.max(P, Math.round(this.resizeStartWidth + t)), s = new Map(this.columnWidths);
24
+ s.set(this.resizeColumn.key, i), this.columnWidths = s;
25
+ }, this._handleResizePointerUp = () => {
26
+ if (!this.resizing || !this.resizeColumn) return;
27
+ const e = this.resizeColumn;
28
+ this.resizing = !1, this.resizeColumn = void 0, this._removeResizeListeners();
29
+ const t = { column: e, key: e.key, width: this._effectiveWidth(e) };
30
+ this.onWidthChange?.(t), this.dispatchEvent(
31
+ new CustomEvent("width-change", {
32
+ detail: t,
33
+ bubbles: !0,
34
+ composed: !0
35
+ })
36
+ );
37
+ }, this._renderRow = (e, t, i) => {
38
+ const s = i.get(g);
39
+ return c`
40
+ <div class="table__row" role="row" @click=${() => this._handleRowClick(e, t)}>
41
+ ${this.selection ? c`
42
+ <div
43
+ class=${this._selectionCellClass(!1, s)}
44
+ style=${this._selectionCellStyle(s)}
45
+ role="cell"
46
+ >
47
+ <logosphere-checkbox
48
+ .checked=${this.selectedKeys.has(this._rowSelectionKey(e, t))}
49
+ @click=${(r) => r.stopPropagation()}
50
+ @lgsChange=${(r) => this._handleRowSelectionChange(r, e, t)}
51
+ ></logosphere-checkbox>
52
+ </div>
53
+ ` : _}
54
+ ${m(
55
+ this.columns,
56
+ (r) => r.key,
57
+ (r) => {
58
+ const l = i.get(r.key);
59
+ return c`
60
+ <div
61
+ class=${`table__cell${this._stickyCellClass(l)}`}
62
+ style=${this._cellStyle(r, l)}
63
+ role="cell"
64
+ >
65
+ ${this._renderCellValue(r, e, t)}
66
+ </div>
67
+ `;
68
+ }
69
+ )}
70
+ ${this.actionColumn ? c`
71
+ <div
72
+ class="table__cell table__cell--action"
73
+ style=${this._actionCellStyle()}
74
+ role="cell"
75
+ @click=${(r) => r.stopPropagation()}
76
+ >
77
+ ${this.actionColumn.render({ row: e, rowIndex: t })}
78
+ </div>
79
+ ` : _}
80
+ </div>
81
+ `;
82
+ };
83
+ }
84
+ firstUpdated() {
85
+ this._warnSortableWithoutHandler(), this._warnSearchableWithoutHandler(), this._warnSelectionWithoutHandler();
86
+ }
87
+ willUpdate(e) {
88
+ e.has("columns") && this._pruneStaleColumnState();
89
+ }
90
+ updated(e) {
91
+ (e.has("columns") || e.has("onSortChange")) && this._warnSortableWithoutHandler(), (e.has("columns") || e.has("onSearch")) && this._warnSearchableWithoutHandler(), this._warnSelectionWithoutHandler();
92
+ }
93
+ /**
94
+ * `columns` is passed in fresh from the consumer on every change (new array/column
95
+ * objects, columns removed or replaced). Internal state keyed by `column.key`
96
+ * (resize widths, active sort, in-progress search text) would otherwise keep
97
+ * referencing keys that no longer exist — a slow memory leak, and a correctness
98
+ * bug if a key is later reused for a semantically different column. This drops
99
+ * any entries whose key is no longer present in the current `columns`.
100
+ */
101
+ _pruneStaleColumnState() {
102
+ const e = new Set(this.columns.map((t) => t.key));
103
+ Array.from(this.columnWidths.keys()).some((t) => !e.has(t)) && (this.columnWidths = new Map(Array.from(this.columnWidths).filter(([t]) => e.has(t)))), Array.from(this.searchValues.keys()).some((t) => !e.has(t)) && (this.searchValues = new Map(Array.from(this.searchValues).filter(([t]) => e.has(t)))), Array.from(this.activeSearchKeys.keys()).some((t) => !e.has(t)) && (this.activeSearchKeys = new Set(Array.from(this.activeSearchKeys).filter((t) => e.has(t)))), this.sortStates.some((t) => !e.has(t.key)) && (this.sortStates = this.sortStates.filter((t) => e.has(t.key))), this.resizeColumn && !e.has(this.resizeColumn.key) && (this.resizing = !1, this.resizeColumn = void 0, this._removeResizeListeners());
104
+ }
105
+ disconnectedCallback() {
106
+ this.searchTimers.forEach((e) => clearTimeout(e)), this.searchTimers.clear(), this._removeResizeListeners(), super.disconnectedCallback();
107
+ }
108
+ _effectiveWidth(e) {
109
+ return this.columnWidths.get(e.key) ?? e.width ?? T;
110
+ }
111
+ _totalWidth() {
112
+ return this.columns.reduce((t, i) => t + this._effectiveWidth(i), 0) + (this.selection ? w : 0) + (this.actionColumn ? this.actionColumn.width ?? x : 0);
113
+ }
114
+ /**
115
+ * Pinned (sticky) columns are laid out left-to-right in `columns` order. The selection
116
+ * checkbox column only joins the pinned group when `stickySelection` is explicitly set —
117
+ * it does not become sticky automatically just because a data column is sticky. Only the
118
+ * single right-most pinned cell (by its resolved `left` offset) gets the divider shadow,
119
+ * even if the sticky columns aren't contiguous in `columns`.
120
+ */
121
+ _stickyLayout() {
122
+ const e = /* @__PURE__ */ new Map(), t = this.columns.filter((l) => l.sticky), i = this.selection && this.stickySelection;
123
+ if (!t.length && !i) return e;
124
+ let s = 0, r;
125
+ return i && (e.set(g, { left: s, isEdge: !1 }), r = g, s += w), this.columns.forEach((l) => {
126
+ l.sticky && (e.set(l.key, { left: s, isEdge: !1 }), r = l.key, s += this._effectiveWidth(l));
127
+ }), r && e.set(r, { ...e.get(r), isEdge: !0 }), e;
128
+ }
129
+ _stickyCellStyle(e) {
130
+ return e ? `left:${e.left}px;` : "";
131
+ }
132
+ _stickyCellClass(e) {
133
+ return e ? ` table__cell--sticky${e.isEdge ? " table__cell--sticky-edge" : ""}` : "";
134
+ }
135
+ /** Shared by the header and body selection (checkbox) cell — kept in sync in one place. */
136
+ _selectionCellClass(e, t) {
137
+ return `table__cell${e ? " table__cell--header" : ""} table__cell--selection${this._stickyCellClass(t)}`;
138
+ }
139
+ _selectionCellStyle(e) {
140
+ return `width:${w}px; justify-content:center; ${this._stickyCellStyle(e)}`;
141
+ }
142
+ _warnSortableWithoutHandler() {
143
+ const e = this.columns.filter((i) => i.sortable).map((i) => i.key);
144
+ if (this.onSortChange || !e.length) {
145
+ this.warnedSortableWithoutHandlerKey = "";
146
+ return;
147
+ }
148
+ const t = e.join("|");
149
+ this.warnedSortableWithoutHandlerKey !== t && (this.warnedSortableWithoutHandlerKey = t, console.warn(
150
+ `[logosphere-table] sortable true verilen kolonlar var (${e.join(", ")}), ancak onSortChange callback'i verilmemiş. Sort etkileşimi için onSortChange sağlayın.`
151
+ ));
152
+ }
153
+ _warnSelectionWithoutHandler() {
154
+ if (!this.selection || this.onSelectChange) {
155
+ this.warnedSelectionWithoutHandler = !1;
156
+ return;
157
+ }
158
+ this.warnedSelectionWithoutHandler || (this.warnedSelectionWithoutHandler = !0, console.warn(
159
+ "[logosphere-table] selection true verilmiş, ancak onSelectChange callback'i verilmemiş. Selection değişikliklerini almak için onSelectChange sağlayın."
160
+ ));
161
+ }
162
+ _warnSearchableWithoutHandler() {
163
+ const e = this.columns.filter((i) => i.searchable).map((i) => i.key);
164
+ if (this.onSearch || !e.length) {
165
+ this.warnedSearchableWithoutHandlerKey = "";
166
+ return;
167
+ }
168
+ const t = e.join("|");
169
+ this.warnedSearchableWithoutHandlerKey !== t && (this.warnedSearchableWithoutHandlerKey = t, console.warn(
170
+ `[logosphere-table] searchable true verilen kolonlar var (${e.join(", ")}), ancak onSearch callback'i verilmemiş. Search etkileşimi için onSearch sağlayın.`
171
+ ));
172
+ }
173
+ _rowSelectionKey(e, t) {
174
+ return e[this.rowKey] ?? t;
175
+ }
176
+ _selectedRows() {
177
+ return this.rows.filter((e, t) => this.selectedKeys.has(this._rowSelectionKey(e, t)));
178
+ }
179
+ _emitSelectionChange() {
180
+ const e = {
181
+ selectedRows: this._selectedRows(),
182
+ selectedKeys: Array.from(this.selectedKeys)
183
+ };
184
+ this.onSelectChange?.(e), this.dispatchEvent(
185
+ new CustomEvent("select-change", {
186
+ detail: e,
187
+ bubbles: !0,
188
+ composed: !0
189
+ })
190
+ );
191
+ }
192
+ _setSelectedKeys(e) {
193
+ this.selectedKeys = e, this._emitSelectionChange();
194
+ }
195
+ _handleSelectAllChange(e) {
196
+ e.stopPropagation();
197
+ const t = e.detail.checked ? new Set(this.rows.map((i, s) => this._rowSelectionKey(i, s))) : /* @__PURE__ */ new Set();
198
+ this._setSelectedKeys(t);
199
+ }
200
+ _handleRowSelectionChange(e, t, i) {
201
+ e.stopPropagation();
202
+ const s = new Set(this.selectedKeys), r = this._rowSelectionKey(t, i);
203
+ e.detail.checked ? s.add(r) : s.delete(r), this._setSelectedKeys(s);
204
+ }
205
+ _handleRowClick(e, t) {
206
+ this.onRowClick?.(e, t), this.dispatchEvent(
207
+ new CustomEvent("row-click", {
208
+ detail: { row: e, rowIndex: t },
209
+ bubbles: !0,
210
+ composed: !0
211
+ })
212
+ );
213
+ }
214
+ _sortDetailStates(e) {
215
+ return e.map((t, i) => {
216
+ const s = this.columns.find((r) => r.key === t.key);
217
+ if (s)
218
+ return {
219
+ column: s,
220
+ key: t.key,
221
+ direction: t.direction,
222
+ order: i + 1
223
+ };
224
+ }).filter((t) => !!t);
225
+ }
226
+ _nextSortDirection(e) {
227
+ if (!e) return "asc";
228
+ if (e === "asc") return "desc";
229
+ }
230
+ _handleSortClick(e, t) {
231
+ if (!e.sortable || !this.onSortChange) return;
232
+ const i = this.sortStates.findIndex((p) => p.key === e.key);
233
+ let s, r;
234
+ if (t?.shiftKey)
235
+ if (s = [...this.sortStates], i >= 0) {
236
+ const p = s[i];
237
+ r = this._nextSortDirection(p.direction), r ? s[i] = { ...p, direction: r } : s.splice(i, 1);
238
+ } else
239
+ r = "asc", s.push({ key: e.key, direction: "asc" });
240
+ else {
241
+ const p = this.sortStates.length === 1 ? this.sortStates[0] : void 0;
242
+ r = this._nextSortDirection(p?.key === e.key ? p.direction : void 0), s = r ? [{ key: e.key, direction: r }] : [];
243
+ }
244
+ const l = this._sortDetailStates(s), d = {
245
+ column: e,
246
+ key: e.key,
247
+ direction: r,
248
+ sorts: l,
249
+ multi: l.length > 1
250
+ };
251
+ this.sortStates = s, this.onSortChange(d), this.dispatchEvent(
252
+ new CustomEvent("sort-change", {
253
+ detail: d,
254
+ bubbles: !0,
255
+ composed: !0
256
+ })
257
+ );
258
+ }
259
+ _handleSearchInput(e, t) {
260
+ e.stopPropagation();
261
+ const i = e.currentTarget, s = e.detail?.value ?? i.value ?? "", r = new Map(this.searchValues);
262
+ r.set(t.key, s), this.searchValues = r;
263
+ const l = this.searchTimers.get(t.key);
264
+ l && clearTimeout(l);
265
+ const d = setTimeout(() => {
266
+ this.searchTimers.delete(t.key);
267
+ const a = { values: this.columns.filter((b) => b.searchable).map((b) => ({
268
+ key: b.key,
269
+ value: this.searchValues.get(b.key) ?? ""
270
+ })).filter((b) => b.value.trim() !== "") };
271
+ this.onSearch?.(a), this.dispatchEvent(
272
+ new CustomEvent("search-change", {
273
+ detail: a,
274
+ bubbles: !0,
275
+ composed: !0
276
+ })
277
+ );
278
+ }, M);
279
+ this.searchTimers.set(t.key, d);
280
+ }
281
+ _toggleSearchInput(e, t) {
282
+ e.stopPropagation();
283
+ const i = new Set(this.activeSearchKeys);
284
+ i.has(t.key) ? i.delete(t.key) : i.add(t.key), this.activeSearchKeys = i;
285
+ }
286
+ _renderCellValue(e, t, i) {
287
+ const s = t[e.key];
288
+ return e.render ? e.render({ value: s, row: t, rowIndex: i, column: e }) : c`<span class="table__cell-text">${s == null ? "" : String(s)}</span>`;
289
+ }
290
+ _cellStyle(e, t) {
291
+ return `width:${this._effectiveWidth(e)}px; justify-content:${D(e.align)}; ${this._stickyCellStyle(t)}`;
292
+ }
293
+ _actionCellStyle() {
294
+ return `width:${this.actionColumn?.width ?? x}px; justify-content:flex-end;`;
295
+ }
296
+ _headerCellClass(e) {
297
+ const { sortable: t, sorted: i, searchable: s, searchActive: r, resizable: l, sticky: d } = e;
298
+ return [
299
+ "table__cell",
300
+ "table__cell--header",
301
+ t ? "table__cell--sortable" : "",
302
+ i ? "table__cell--sorted" : "",
303
+ s ? "table__cell--searchable" : "",
304
+ r ? "table__cell--search-active" : "",
305
+ l ? "table__cell--resizable" : ""
306
+ ].filter(Boolean).join(" ").concat(this._stickyCellClass(d));
307
+ }
308
+ _renderSortIndicator(e, t = !1) {
309
+ return e ? c`
310
+ <span class="table__sort-indicator" aria-hidden="true">
311
+ <ui-icon
312
+ class="table__sort-arrow"
313
+ name=${e.direction === "asc" ? "uil-arrow-up" : "uil-arrow-down"}
314
+ size="16"
315
+ ></ui-icon>
316
+ ${t ? c`<span class="table__sort-order">${e.order}</span>` : _}
317
+ </span>
318
+ ` : _;
319
+ }
320
+ _renderSearchToggle(e, t) {
321
+ return e.searchable ? c`
322
+ <button
323
+ class="table__search-toggle"
324
+ type="button"
325
+ aria-label=${t ? `${e.label} aramasını kapat` : `${e.label} ara`}
326
+ aria-pressed=${t ? "true" : "false"}
327
+ @click=${(i) => this._toggleSearchInput(i, e)}
328
+ @keydown=${(i) => i.stopPropagation()}
329
+ >
330
+ <ui-icon class="table__search-toggle-icon" name="uil-search" size="16"></ui-icon>
331
+ </button>
332
+ ` : _;
333
+ }
334
+ _renderSearchInput(e, t) {
335
+ return !e.searchable || !t ? _ : c`
336
+ <logosphere-input
337
+ class="table__search-input"
338
+ placeholder=${e.label}
339
+ .value=${this.searchValues.get(e.key) ?? ""}
340
+ @click=${(i) => i.stopPropagation()}
341
+ @keydown=${(i) => i.stopPropagation()}
342
+ @input=${(i) => this._handleSearchInput(i, e)}
343
+ ></logosphere-input>
344
+ `;
345
+ }
346
+ _renderHeaderMain(e, t) {
347
+ return t ? c`<span class="table__header-main">${this._renderSearchInput(e, t)}</span>` : c`<span class="table__header-main">
348
+ <span class="table__header-label">${e.label}</span>
349
+ </span>`;
350
+ }
351
+ _removeResizeListeners() {
352
+ window.removeEventListener("pointermove", this._handleResizePointerMove), window.removeEventListener("pointerup", this._handleResizePointerUp), window.removeEventListener("pointercancel", this._handleResizePointerUp);
353
+ }
354
+ _renderResizeHandle(e) {
355
+ return this.resizable ? c`
356
+ <span
357
+ class="table__resize-handle"
358
+ role="separator"
359
+ aria-orientation="vertical"
360
+ aria-label=${`${e.label} genişliğini yeniden boyutlandır`}
361
+ @pointerdown=${(t) => this._handleResizePointerDown(t, e)}
362
+ @click=${(t) => t.stopPropagation()}
363
+ ></span>
364
+ ` : _;
365
+ }
366
+ _renderHeader(e) {
367
+ const t = this.selectedKeys.size, i = this.rows.length > 0 && t === this.rows.length, s = t > 0 && t < this.rows.length, r = e.get(g), l = this._sortDetailStates(this.sortStates), d = new Map(l.map((a) => [a.key, a])), p = l.length > 1;
368
+ return c`
369
+ <div class="table__header" role="row">
370
+ ${this.selection ? c`
371
+ <div
372
+ class=${this._selectionCellClass(!0, r)}
373
+ style=${this._selectionCellStyle(r)}
374
+ role="columnheader"
375
+ >
376
+ <logosphere-checkbox
377
+ .checked=${i}
378
+ .indeterminate=${s}
379
+ @click=${(a) => a.stopPropagation()}
380
+ @lgsChange=${(a) => this._handleSelectAllChange(a)}
381
+ ></logosphere-checkbox>
382
+ </div>
383
+ ` : _}
384
+ ${m(
385
+ this.columns,
386
+ (a) => a.key,
387
+ (a) => {
388
+ const b = !!(a.sortable && this.onSortChange), f = b ? d.get(a.key) : void 0, C = !!f, S = !!a.searchable, v = S && this.activeSearchKeys.has(a.key), k = e.get(a.key);
389
+ return c`
390
+ <div
391
+ class=${this._headerCellClass({ sortable: b, sorted: C, searchable: S, searchActive: v, resizable: this.resizable, sticky: k })}
392
+ style=${this._cellStyle(a, k)}
393
+ role="columnheader"
394
+ tabindex=${b ? "0" : _}
395
+ aria-sort=${b ? f ? f.direction === "asc" ? "ascending" : "descending" : "none" : _}
396
+ @click=${(u) => this._handleSortClick(a, u)}
397
+ @keydown=${(u) => {
398
+ u.key !== "Enter" && u.key !== " " || (u.preventDefault(), this._handleSortClick(a, u));
399
+ }}
400
+ >
401
+ ${this._renderHeaderMain(a, v)}
402
+ <span class="table__header-actions">
403
+ ${this._renderSearchToggle(a, v)}
404
+ ${this._renderSortIndicator(f, p)}
405
+ </span>
406
+ ${this._renderResizeHandle(a)}
407
+ </div>
408
+ `;
409
+ }
410
+ )}
411
+ ${this.actionColumn ? c`
412
+ <div
413
+ class="table__cell table__cell--header table__cell--action"
414
+ style=${this._actionCellStyle()}
415
+ role="columnheader"
416
+ aria-label="Actions"
417
+ ></div>
418
+ ` : _}
419
+ </div>
420
+ `;
421
+ }
422
+ _renderBody(e, t) {
423
+ return this.rows.length ? c`
424
+ <div class="table__body">
425
+ ${m(
426
+ this.rows,
427
+ (i, s) => i[this.rowKey] ?? s,
428
+ (i, s) => this._renderRow(i, s, t)
429
+ )}
430
+ </div>
431
+ ` : c`<div class="table__empty" style=${`min-width:${e}px; width:100%;`}>
432
+ ${this.emptyMessage}
433
+ </div>`;
434
+ }
435
+ _tableClass() {
436
+ return ["table", this.borderless ? "table--borderless" : ""].filter(Boolean).join(" ");
437
+ }
438
+ render() {
439
+ const e = this._totalWidth(), t = this.maxHeight ? `max-height:${this.maxHeight}px;` : _, i = this._stickyLayout();
440
+ return c`
441
+ <div class=${this._tableClass()}>
442
+ <div class="table__scroll" style=${t}>
443
+ <div class="table__inner" style=${`min-width:${e}px; width:100%;`}>
444
+ ${this._renderHeader(i)} ${this._renderBody(e, i)}
445
+ </div>
446
+ </div>
447
+ </div>
448
+ `;
449
+ }
450
+ };
451
+ o.styles = [
452
+ z`
453
+ ${$(E)}
454
+ `
455
+ ];
456
+ n([
457
+ h({ attribute: !1 })
458
+ ], o.prototype, "columns", 2);
459
+ n([
460
+ h({ attribute: !1 })
461
+ ], o.prototype, "actionColumn", 2);
462
+ n([
463
+ h({ attribute: !1 })
464
+ ], o.prototype, "rows", 2);
465
+ n([
466
+ h({ type: String, attribute: "row-key" })
467
+ ], o.prototype, "rowKey", 2);
468
+ n([
469
+ h({ type: String, attribute: "empty-message" })
470
+ ], o.prototype, "emptyMessage", 2);
471
+ n([
472
+ h({ type: Number, attribute: "max-height" })
473
+ ], o.prototype, "maxHeight", 2);
474
+ n([
475
+ h({ type: Boolean })
476
+ ], o.prototype, "selection", 2);
477
+ n([
478
+ h({ type: Boolean, attribute: "sticky-selection" })
479
+ ], o.prototype, "stickySelection", 2);
480
+ n([
481
+ h({ type: Boolean })
482
+ ], o.prototype, "resizable", 2);
483
+ n([
484
+ h({ type: Boolean })
485
+ ], o.prototype, "borderless", 2);
486
+ n([
487
+ h({ attribute: !1 })
488
+ ], o.prototype, "onRowClick", 2);
489
+ n([
490
+ h({ attribute: !1 })
491
+ ], o.prototype, "onSortChange", 2);
492
+ n([
493
+ h({ attribute: !1 })
494
+ ], o.prototype, "onSelectChange", 2);
495
+ n([
496
+ h({ attribute: !1 })
497
+ ], o.prototype, "onSearch", 2);
498
+ n([
499
+ h({ attribute: !1 })
500
+ ], o.prototype, "onWidthChange", 2);
501
+ n([
502
+ y()
503
+ ], o.prototype, "sortStates", 2);
504
+ n([
505
+ y()
506
+ ], o.prototype, "selectedKeys", 2);
507
+ n([
508
+ y()
509
+ ], o.prototype, "searchValues", 2);
510
+ n([
511
+ y()
512
+ ], o.prototype, "activeSearchKeys", 2);
513
+ n([
514
+ y()
515
+ ], o.prototype, "columnWidths", 2);
516
+ o = n([
517
+ W("logosphere-table")
518
+ ], o);
519
+ export {
520
+ o as T
521
+ };