kanto-ds 1.4.0 → 1.5.2
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/README.md +10 -10
- package/dist/chunks/{defaults-BwgjMcww.js → defaults-CFrjqae2.js} +22 -21
- package/dist/chunks/{defaults-BwgjMcww.js.map → defaults-CFrjqae2.js.map} +1 -1
- package/dist/chunks/events-r51msXNf.js +22 -0
- package/dist/chunks/{events-Bjl5Zmmq.js.map → events-r51msXNf.js.map} +1 -1
- package/dist/chunks/floating-B7_Dahpn.js +54 -0
- package/dist/chunks/floating-B7_Dahpn.js.map +1 -0
- package/dist/chunks/{form-control-CxjBTt1c.js → form-control-B74_EHtG.js} +7 -7
- package/dist/chunks/form-control-B74_EHtG.js.map +1 -0
- package/dist/chunks/{index-DSSLJirw.js → index-STEEvEP7.js} +24 -12
- package/dist/chunks/index-STEEvEP7.js.map +1 -0
- package/dist/chunks/kt-calendar-B_hFdD9V.js +640 -0
- package/dist/chunks/kt-calendar-B_hFdD9V.js.map +1 -0
- package/dist/chunks/{kt-element-E-tfJpGQ.js → kt-element-Djx2JcGl.js} +2 -2
- package/dist/chunks/{kt-element-E-tfJpGQ.js.map → kt-element-Djx2JcGl.js.map} +1 -1
- package/dist/chunks/{listbox-Sm3nvsC6.js → listbox-llcUu_V-.js} +18 -14
- package/dist/chunks/{listbox-Sm3nvsC6.js.map → listbox-llcUu_V-.js.map} +1 -1
- package/dist/chunks/locale-C5xLkGx5.js +14 -0
- package/dist/chunks/locale-C5xLkGx5.js.map +1 -0
- package/dist/chunks/position-Cx_ZH5zh.js +39 -0
- package/dist/chunks/position-Cx_ZH5zh.js.map +1 -0
- package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
- package/dist/components/core/kt-badge/kt-badge.js +3 -3
- package/dist/components/core/kt-button/kt-button.js +1 -1
- package/dist/components/core/kt-card/kt-card.js +2 -2
- package/dist/components/core/kt-code/kt-code.js +3 -3
- package/dist/components/core/kt-icon/kt-icon.js +2 -2
- package/dist/components/core/kt-kbd/kt-kbd.js +1 -1
- package/dist/components/core/kt-split-button/kt-split-button.js +4 -4
- package/dist/components/data/kt-chart/kt-chart.js +3 -3
- package/dist/components/data/kt-meter/kt-meter.js +1 -1
- package/dist/components/data/kt-pagination/kt-pagination.js +3 -3
- package/dist/components/data/kt-stat/kt-stat.js +1 -1
- package/dist/components/data/kt-table/kt-table.d.ts +53 -3
- package/dist/components/data/kt-table/kt-table.js +286 -131
- package/dist/components/data/kt-table/kt-table.js.map +1 -1
- package/dist/components/data/kt-table/window.d.ts +19 -0
- package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
- package/dist/components/feedback/kt-alert/kt-alert.js +3 -3
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +10 -10
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -1
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js +1 -1
- package/dist/components/feedback/kt-toast/kt-toast.js +58 -42
- package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
- package/dist/components/feedback/kt-tooltip/kt-tooltip.d.ts +20 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js +95 -51
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js.map +1 -1
- package/dist/components/forms/kt-calendar/kt-calendar.d.ts +96 -0
- package/dist/components/forms/kt-calendar/kt-calendar.js +13 -0
- package/dist/components/forms/kt-calendar/kt-calendar.js.map +1 -0
- package/dist/components/forms/kt-checkbox/kt-checkbox.d.ts +9 -0
- package/dist/components/forms/kt-checkbox/kt-checkbox.js +34 -20
- package/dist/components/forms/kt-checkbox/kt-checkbox.js.map +1 -1
- package/dist/components/forms/kt-date-picker/kt-date-picker.d.ts +105 -0
- package/dist/components/forms/kt-date-picker/kt-date-picker.js +382 -0
- package/dist/components/forms/kt-date-picker/kt-date-picker.js.map +1 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +9 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +36 -22
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
- package/dist/components/forms/kt-form/kt-form.js +2 -2
- package/dist/components/forms/kt-input/kt-input.d.ts +37 -1
- package/dist/components/forms/kt-input/kt-input.js +380 -194
- package/dist/components/forms/kt-input/kt-input.js.map +1 -1
- package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +13 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.js +73 -42
- package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -1
- package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
- package/dist/components/forms/kt-radio-group/kt-radio-group.d.ts +9 -0
- package/dist/components/forms/kt-radio-group/kt-radio-group.js +67 -53
- package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -1
- package/dist/components/forms/kt-select/kt-select.d.ts +13 -0
- package/dist/components/forms/kt-select/kt-select.js +87 -56
- package/dist/components/forms/kt-select/kt-select.js.map +1 -1
- package/dist/components/forms/kt-textarea/kt-textarea.d.ts +9 -0
- package/dist/components/forms/kt-textarea/kt-textarea.js +28 -14
- package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -1
- package/dist/components/forms/kt-toggle/kt-toggle.d.ts +9 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js +43 -29
- package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -1
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +3 -3
- package/dist/components/navigation/kt-header/kt-header.js +3 -3
- package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +9 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +40 -22
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -1
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +3 -3
- package/dist/components/navigation/kt-tabs/kt-tabs.js +2 -2
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +2 -2
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +3 -3
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js +2 -2
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +3 -3
- package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +7 -5
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js +67 -57
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
- package/dist/components/overlays/kt-modal/kt-modal.js +3 -3
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js +3 -3
- package/dist/custom-elements.json +2110 -124
- package/dist/icons/defaults.d.ts +1 -0
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +91 -87
- package/dist/index.js.map +1 -1
- package/dist/internal/countries.d.ts +24 -9
- package/dist/internal/date.d.ts +53 -0
- package/dist/internal/events.d.ts +5 -0
- package/dist/internal/floating.d.ts +48 -0
- package/dist/internal/form-control.d.ts +5 -1
- package/dist/internal/locale.d.ts +15 -0
- package/dist/internal/position.d.ts +27 -0
- package/dist/internal/strings.d.ts +15 -0
- package/dist/react/index.d.ts +12 -0
- package/dist/react/index.js +180 -166
- package/dist/react/index.js.map +1 -1
- package/dist/react/jsx.d.ts +11 -1
- package/dist/strings/index.js +1 -1
- package/dist/tokens/base.css +2 -0
- package/dist/tokens/responsive.css +1 -0
- package/dist/tokens/spacing.css +1 -0
- package/dist/vscode.css-custom-data.json +8 -0
- package/dist/vscode.html-custom-data.json +138 -11
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +9 -7
- package/dist/vue/index.js.map +1 -1
- package/dist/web-types.json +292 -14
- package/package.json +10 -1
- package/dist/chunks/events-Bjl5Zmmq.js +0 -18
- package/dist/chunks/form-control-CxjBTt1c.js.map +0 -1
- package/dist/chunks/index-DSSLJirw.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kt-table.js","sources":["../../../../src/components/data/kt-table/kt-table.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { emit } from '#internal/events';\nimport { strings } from '#internal/strings';\nimport '../kt-pagination/kt-pagination.js';\n\nexport type KtSortDirection = 'asc' | 'desc' | null;\nexport type KtTableRow = Record<string, unknown>;\n\nexport interface KtTableColumn {\n /** Key into the row object. */\n readonly key: string;\n /** Header text. Falls back to `key`. */\n readonly label?: string;\n readonly sortable?: boolean;\n readonly align?: 'left' | 'center' | 'right';\n /** Any CSS width. */\n readonly width?: string;\n}\n\nexport interface KtSortState {\n readonly key: string | null;\n readonly direction: KtSortDirection;\n}\n\n/** Renders a cell. Return `undefined` to fall back to the raw value. */\nexport type KtCellRenderer = (row: KtTableRow, column: KtTableColumn) => unknown;\n\n/**\n * Sorts with a locale-aware collator, so \"Ångström\" files next to \"Angstrom\"\n * instead of after \"Zeta\". `numeric` also makes \"Entity 2\" precede\n * \"Entity 10\".\n */\nconst collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' });\n\n/**\n * A sortable string for any cell value.\n *\n * Objects get their JSON rather than \"[object Object]\", which at least sorts\n * consistently instead of collapsing every object in the column to one key.\n */\nfunction sortableText(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {\n return String(value);\n }\n try {\n return JSON.stringify(value) ?? '';\n } catch {\n return '';\n }\n}\n\n/** A row's identity: `id`, else `uid`, else the row itself. */\nfunction rowKey(row: KtTableRow): unknown {\n return row['id'] ?? row['uid'] ?? row;\n}\n\n/**\n * A data table: tri-state sorting, single or multiple selection, paging.\n *\n * @element kt-table\n *\n * @csspart table - The `<table>`.\n * @csspart header-cell - A `<th>`.\n * @csspart row - A `<tr>`.\n * @csspart cell - A `<td>`.\n *\n * @fires kt-sort-change - Sorting changed. `detail: { key, direction }`.\n * @fires kt-selection-change - Selection changed. `detail: { selected, rows }`.\n * @fires kt-row-click - A row was clicked. `detail: { row, index }`.\n * @fires kt-page-change - The page changed. `detail: { page }`.\n *\n * @example\n * ```js\n * table.columns = [\n * { key: 'name', label: 'Name', sortable: true },\n * { key: 'amount', label: 'Amount', sortable: true, align: 'right' },\n * ];\n * table.data = rows;\n * ```\n */\nexport class KtTable extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n width: 100%;\n color: var(--text-body);\n font: var(--font-normal-regular);\n }\n\n .scroller {\n overflow: auto;\n border-radius: var(--border-radius);\n }\n\n table {\n width: 100%;\n min-width: 600px;\n border-spacing: 0;\n border-collapse: separate;\n }\n\n thead {\n background: var(--surface-card);\n color: var(--text-muted);\n }\n\n th {\n padding: 16px 18px;\n font-size: 13px;\n font-weight: inherit;\n text-align: left;\n white-space: nowrap;\n vertical-align: middle;\n user-select: none;\n }\n\n /* Sortable headers are buttons, not clickable <th>s: a header you can\n only sort with a mouse is a table half the users cannot sort. */\n th button {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 0;\n color: inherit;\n font: inherit;\n text-align: inherit;\n background: none;\n border: none;\n cursor: pointer;\n }\n\n th button:focus-visible {\n outline: var(--outline-width) solid var(--color-primary-base);\n outline-offset: 2px;\n }\n\n .indicator {\n color: var(--color-primary-text);\n font-size: 10px;\n }\n\n tbody tr {\n transition: background-color 120ms linear;\n }\n\n tbody tr:hover {\n background: var(--color-dark-14);\n }\n\n tbody tr.selected {\n background: var(--color-primary-soft);\n }\n\n td {\n padding: 14px 18px;\n font-size: 14px;\n border-bottom: var(--border-width) solid var(--surface-hover);\n }\n\n :host([compact]) td {\n padding: 8px 12px;\n }\n :host([compact]) th {\n padding: 10px 12px;\n }\n\n .select-cell {\n width: 56px;\n text-align: center;\n }\n\n .placeholder {\n padding: 28px 0;\n color: var(--text-muted);\n text-align: center;\n }\n\n footer {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 12px;\n padding-top: 12px;\n }\n\n @media (max-width: 680px) {\n table {\n min-width: 100%;\n }\n td,\n th {\n padding: 10px 12px;\n }\n }\n `,\n ];\n\n @state()\n private page = 1;\n\n @property({ attribute: false })\n columns: readonly KtTableColumn[] = [];\n\n @property({ attribute: false })\n data: readonly KtTableRow[] = [];\n\n @property({ type: Boolean, reflect: true })\n selectable = false;\n\n @property({ type: String, attribute: 'selection-mode' })\n selectionMode: 'single' | 'multiple' = 'multiple';\n\n /** The identities of the selected rows. */\n @property({ attribute: false })\n selected: readonly unknown[] = [];\n\n /** Rows per page. Zero shows everything and hides the footer. */\n @property({ type: Number, attribute: 'page-size' })\n pageSize = 0;\n\n @property({ type: Boolean, reflect: true })\n loading = false;\n\n @property({ type: Boolean, reflect: true })\n compact = false;\n\n @property({ type: String, attribute: 'sort-key' })\n sortKey: string | null = null;\n\n @property({ type: String, attribute: 'sort-direction' })\n sortDirection: KtSortDirection = null;\n\n /** Renders a cell. Return `undefined` to fall back to the raw value. */\n @property({ attribute: false })\n renderCell: KtCellRenderer | undefined;\n\n @property({ type: String, attribute: 'empty-text' })\n emptyText: string | undefined = undefined;\n\n @property({ type: String, attribute: 'loading-text' })\n loadingText: string | undefined = undefined;\n\n /** Accessible name for the table. */\n @property({ type: String })\n label = '';\n\n /** The rows after sorting, before paging. */\n get sortedRows(): readonly KtTableRow[] {\n if (!this.sortKey || !this.sortDirection) return this.data;\n\n const key = this.sortKey;\n const sign = this.sortDirection === 'asc' ? 1 : -1;\n\n return [...this.data].sort((a, b) => {\n const left = a[key];\n const right = b[key];\n\n // Empty values sort to the end whichever way the column points, so a\n // descending sort does not open with a screen of blanks.\n const leftEmpty = left === null || left === undefined;\n const rightEmpty = right === null || right === undefined;\n if (leftEmpty && rightEmpty) return 0;\n if (leftEmpty) return 1;\n if (rightEmpty) return -1;\n\n if (typeof left === 'number' && typeof right === 'number') return (left - right) * sign;\n return collator.compare(sortableText(left), sortableText(right)) * sign;\n });\n }\n\n get totalPages(): number {\n if (this.pageSize <= 0) return 1;\n return Math.max(1, Math.ceil(this.data.length / this.pageSize));\n }\n\n /** The rows actually on screen. */\n get visibleRows(): readonly KtTableRow[] {\n const rows = this.sortedRows;\n if (this.pageSize <= 0) return rows;\n\n const page = Math.min(this.page, this.totalPages);\n return rows.slice((page - 1) * this.pageSize, page * this.pageSize);\n }\n\n /**\n * Cycles a column: unsorted → ascending → descending → unsorted. The third\n * press restoring the original order is what makes sorting undoable.\n */\n private toggleSort(column: KtTableColumn): void {\n if (!column.sortable) return;\n\n if (this.sortKey !== column.key) {\n this.sortKey = column.key;\n this.sortDirection = 'asc';\n } else if (this.sortDirection === 'asc') {\n this.sortDirection = 'desc';\n } else {\n this.sortKey = null;\n this.sortDirection = null;\n }\n\n emit(this, 'kt-sort-change', { key: this.sortKey, direction: this.sortDirection });\n }\n\n private isSelected(row: KtTableRow): boolean {\n return this.selected.includes(rowKey(row));\n }\n\n private toggleSelection(row: KtTableRow): void {\n const key = rowKey(row);\n\n if (this.selectionMode === 'single') {\n this.selected = this.isSelected(row) ? [] : [key];\n } else {\n this.selected = this.isSelected(row)\n ? this.selected.filter((candidate) => candidate !== key)\n : [...this.selected, key];\n }\n\n emit(this, 'kt-selection-change', { selected: this.selected, rows: this.selectedRows });\n }\n\n /** Selects or clears every row on the current page. */\n private toggleAll(): void {\n const rows = this.visibleRows;\n const keys = rows.map(rowKey);\n const allSelected = keys.every((key) => this.selected.includes(key));\n\n this.selected = allSelected\n ? this.selected.filter((key) => !keys.includes(key))\n : [...new Set([...this.selected, ...keys])];\n\n emit(this, 'kt-selection-change', { selected: this.selected, rows: this.selectedRows });\n }\n\n /** The selected rows themselves, not just their identities. */\n get selectedRows(): readonly KtTableRow[] {\n return this.data.filter((row) => this.selected.includes(rowKey(row)));\n }\n\n private onPageChange(event: Event): void {\n event.stopPropagation();\n this.page = (event as CustomEvent<{ page: number }>).detail.page;\n emit(this, 'kt-page-change', { page: this.page });\n }\n\n /**\n * The aria-sort value for a column.\n *\n * Not named ariaSort: HTMLElement reflects that ARIA attribute as a string\n * property, and shadowing it with a method breaks the element's own typing.\n */\n private sortStateFor(column: KtTableColumn): 'ascending' | 'descending' | 'none' {\n if (this.sortKey !== column.key || !this.sortDirection) return 'none';\n return this.sortDirection === 'asc' ? 'ascending' : 'descending';\n }\n\n private renderHeaderCell(column: KtTableColumn): TemplateResult {\n const title = column.label ?? column.key;\n const active = this.sortKey === column.key && this.sortDirection !== null;\n\n return html`<th\n part=\"header-cell\"\n scope=\"col\"\n style=${styleMap(column.width ? { width: column.width } : {})}\n aria-sort=${this.sortStateFor(column)}\n >\n ${\n column.sortable\n ? html`<button type=\"button\" @click=${() => this.toggleSort(column)}>\n <span>${title}</span>\n <span class=\"indicator\" aria-hidden=\"true\"\n >${active ? (this.sortDirection === 'asc' ? '▲' : '▼') : ''}</span\n >\n </button>`\n : html`<span>${title}</span>`\n }\n </th>`;\n }\n\n private renderBody(): TemplateResult {\n const rows = this.visibleRows;\n const columnCount = this.columns.length + (this.selectable ? 1 : 0);\n\n if (rows.length === 0) {\n return html`<tr>\n <td colspan=${columnCount}>\n <div class=\"placeholder\">${this.emptyText ?? strings().noData}</div>\n </td>\n </tr>`;\n }\n\n return html`${rows.map((row, index) => {\n const selected = this.isSelected(row);\n\n return html`<tr\n part=\"row\"\n class=${classMap({ selected })}\n aria-selected=${this.selectable ? String(selected) : nothing}\n @click=${() => emit(this, 'kt-row-click', { row, index })}\n >\n ${\n this.selectable\n ? html`<td class=\"select-cell\">\n <input\n type=${this.selectionMode === 'single' ? 'radio' : 'checkbox'}\n name=${this.selectionMode === 'single' ? 'kt-table-selection' : nothing}\n .checked=${selected}\n aria-label=${strings().selectRow}\n @click=${(event: Event) => event.stopPropagation()}\n @change=${() => this.toggleSelection(row)}\n />\n </td>`\n : nothing\n }\n ${this.columns.map((column) => {\n const rendered = this.renderCell?.(row, column);\n return html`<td part=\"cell\" style=${styleMap({ textAlign: column.align ?? 'left' })}>\n ${rendered === undefined ? row[column.key] : rendered}\n </td>`;\n })}\n </tr>`;\n })}`;\n }\n\n override render(): TemplateResult {\n if (this.loading) {\n return html`<div class=\"placeholder\" role=\"status\" aria-live=\"polite\">\n ${this.loadingText ?? strings().loading}\n </div>`;\n }\n\n const rows = this.visibleRows;\n const allSelected = rows.length > 0 && rows.every((row) => this.isSelected(row));\n const someSelected = rows.some((row) => this.isSelected(row));\n\n return html`<div class=\"scroller\">\n <table part=\"table\" aria-label=${this.label || nothing}>\n <thead>\n <tr>\n ${\n this.selectable\n ? html`<th class=\"select-cell\" scope=\"col\">\n ${\n this.selectionMode === 'multiple'\n ? html`<input\n type=\"checkbox\"\n .checked=${allSelected}\n .indeterminate=${someSelected && !allSelected}\n aria-label=${strings().selectAll}\n @change=${this.toggleAll}\n />`\n : nothing\n }\n </th>`\n : nothing\n }\n ${this.columns.map((column) => this.renderHeaderCell(column))}\n </tr>\n </thead>\n <tbody>\n ${this.renderBody()}\n </tbody>\n </table>\n </div>\n\n ${\n this.pageSize > 0\n ? html`<footer>\n <kt-pagination\n .page=${Math.min(this.page, this.totalPages)}\n .totalPages=${this.totalPages}\n @kt-page-change=${this.onPageChange}\n ></kt-pagination>\n </footer>`\n : nothing\n }`;\n }\n}\n\ndefineElement('kt-table', KtTable);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-table': KtTable;\n }\n}\n"],"names":["collator","sortableText","value","rowKey","row","KtTable","KtElement","css","key","sign","a","b","left","right","leftEmpty","rightEmpty","rows","page","column","emit","candidate","keys","allSelected","event","title","active","html","styleMap","columnCount","strings","index","selected","classMap","nothing","rendered","someSelected","__decorateClass","state","property","defineElement"],"mappings":";;;;;;;;;;;;;AAoCA,MAAMA,IAAW,IAAI,KAAK,SAAS,MAAM,EAAE,SAAS,IAAM,a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AQ,WAAW,YAAY;AAAA,GArJtCjC,EAsJX,WAAA,SAAA;AAGA+B,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,QAAQ,WAAW,kBAAkB;AAAA,GAxJ5CjC,EAyJX,WAAA,eAAA;AAIA+B,EAAA;AAAA,EADCE,EAAS,EAAE,WAAW,GAAA,CAAO;AAAA,GA5JnBjC,EA6JX,WAAA,YAAA;AAGA+B,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,QAAQ,WAAW,cAAc;AAAA,GA/JxCjC,EAgKX,WAAA,WAAA;AAGA+B,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,GAlK1CjC,EAmKX,WAAA,aAAA;AAIA+B,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAtKfjC,EAuKX,WAAA,OAAA;AA4OFkC,EAAc,YAAYlC,CAAO;"}
|
|
1
|
+
{"version":3,"file":"kt-table.js","sources":["../../../../src/components/data/kt-table/window.ts","../../../../src/components/data/kt-table/kt-table.ts"],"sourcesContent":["/**\n * Which rows a virtual table renders: those under the viewport, and a few\n * either side so a fast scroll does not show blank space before the next\n * render lands.\n */\n\n/** Rendered before the first row has been measured, to measure it. */\nconst FIRST_BATCH = 50;\n\nexport interface RowWindowInput {\n readonly rowCount: number;\n /** Every row's height, in px; 0 until one has been measured. */\n readonly rowHeight: number;\n readonly viewportHeight: number;\n readonly scrollTop: number;\n /** Extra rows rendered above and below the viewport. */\n readonly overscan: number;\n}\n\n/** Rows `start` (inclusive) to `end` (exclusive). */\nexport function rowWindow({\n rowCount,\n rowHeight,\n viewportHeight,\n scrollTop,\n overscan,\n}: RowWindowInput): { start: number; end: number } {\n if (rowCount === 0) return { start: 0, end: 0 };\n if (rowHeight <= 0) return { start: 0, end: Math.min(rowCount, FIRST_BATCH) };\n\n // Past the end — a scroll position left over from longer data — the window\n // settles on the last screenful rather than on nothing.\n const fits = Math.ceil(viewportHeight / rowHeight);\n const first = Math.min(Math.floor(scrollTop / rowHeight), Math.max(0, rowCount - fits));\n const last = Math.ceil((scrollTop + viewportHeight) / rowHeight);\n\n return {\n start: Math.max(0, first - overscan),\n end: Math.min(rowCount, last + overscan),\n };\n}\n","import { css, html, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { emit } from '#internal/events';\nimport { resolveLocale } from '#internal/locale';\nimport { strings } from '#internal/strings';\nimport '../../core/kt-icon/kt-icon.js';\nimport '../kt-pagination/kt-pagination.js';\nimport { rowWindow } from './window.js';\n\nexport type KtSortDirection = 'asc' | 'desc' | null;\nexport type KtTableRow = Record<string, unknown>;\n\nexport interface KtTableColumn {\n /** Key into the row object. */\n readonly key: string;\n /** Header text. Falls back to `key`. */\n readonly label?: string;\n readonly sortable?: boolean;\n readonly align?: 'left' | 'center' | 'right';\n /** Any CSS width. */\n readonly width?: string;\n}\n\nexport interface KtSortState {\n readonly key: string | null;\n readonly direction: KtSortDirection;\n}\n\n/** Renders a cell. Return `undefined` to fall back to the raw value. */\nexport type KtCellRenderer = (row: KtTableRow, column: KtTableColumn) => unknown;\n\n/** Rows rendered above and below the viewport of a virtual table. */\nconst OVERSCAN = 8;\n\nconst collators = new Map<string, Intl.Collator>();\n\n/**\n * A collator for `locale`, made once. Locale-aware, so each language files\n * accented letters its own way — \"Ångström\" next to \"Angstrom\" in English,\n * after \"Zeta\" in Swedish. `numeric` also makes \"Entity 2\" precede\n * \"Entity 10\".\n */\nfunction collatorFor(locale: string): Intl.Collator {\n let collator = collators.get(locale);\n if (!collator) {\n collator = new Intl.Collator(locale, { numeric: true, sensitivity: 'base' });\n collators.set(locale, collator);\n }\n return collator;\n}\n\n/**\n * A sortable string for any cell value.\n *\n * Objects get their JSON rather than \"[object Object]\", which at least sorts\n * consistently instead of collapsing every object in the column to one key.\n */\nfunction sortableText(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {\n return String(value);\n }\n try {\n return JSON.stringify(value) ?? '';\n } catch {\n return '';\n }\n}\n\n/** A row's identity: `id`, else `uid`, else the row itself. */\nfunction rowKey(row: KtTableRow): unknown {\n return row['id'] ?? row['uid'] ?? row;\n}\n\n/**\n * A data table: tri-state sorting, single or multiple selection, paging.\n *\n * @element kt-table\n *\n * @csspart table - The `<table>`.\n * @csspart header-cell - A `<th>`.\n * @csspart row - A `<tr>`.\n * @csspart cell - A `<td>`.\n *\n * @fires kt-sort-change - Sorting changed. `detail: { key, direction }`.\n * @fires kt-selection-change - Selection changed. `detail: { selected, rows }`.\n * @fires kt-row-click - A row was clicked. `detail: { row, index }`.\n * @fires kt-page-change - The page changed. `detail: { page }`.\n *\n * @example\n * ```js\n * table.columns = [\n * { key: 'name', label: 'Name', sortable: true },\n * { key: 'amount', label: 'Amount', sortable: true, align: 'right' },\n * ];\n * table.data = rows;\n * ```\n */\nexport class KtTable extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n width: 100%;\n color: var(--text-body);\n font: var(--font-normal-regular);\n }\n\n .scroller {\n overflow: auto;\n border-radius: var(--border-radius);\n }\n\n table {\n width: 100%;\n min-width: 600px;\n border-spacing: 0;\n border-collapse: separate;\n }\n\n thead {\n background: var(--surface-card);\n color: var(--text-muted);\n }\n\n th {\n padding: 16px 18px;\n font-size: 13px;\n font-weight: inherit;\n text-align: left;\n white-space: nowrap;\n vertical-align: middle;\n user-select: none;\n }\n\n /* Sortable headers are buttons, not clickable <th>s: a header you can\n only sort with a mouse is a table half the users cannot sort. */\n th button {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 0;\n color: inherit;\n font: inherit;\n text-align: inherit;\n background: none;\n border: none;\n cursor: pointer;\n }\n\n th button:focus-visible {\n outline: var(--outline-width) solid var(--color-primary-base);\n outline-offset: 2px;\n }\n\n .indicator {\n display: inline-flex;\n color: var(--color-primary-text);\n }\n\n tbody tr {\n transition: background-color var(--duration-instant) linear;\n }\n\n table[aria-busy='true'] tbody {\n opacity: 0.5;\n transition: opacity var(--duration-fast) var(--easing-standard);\n }\n\n tbody tr:hover {\n background: var(--color-dark-14);\n }\n\n tbody tr.selected {\n background: var(--color-primary-soft);\n }\n\n td {\n padding: 14px 18px;\n font-size: 14px;\n border-bottom: var(--border-width) solid var(--surface-hover);\n }\n\n :host([compact]) td {\n padding: 8px 12px;\n }\n\n /* === VIRTUAL ===\n The table scrolls inside its own box, whose height the page sets,\n and the header stays on top of the rows passing under it. */\n :host([virtual]) {\n display: flex;\n flex-direction: column;\n }\n :host([virtual]) .scroller {\n flex: 1;\n min-height: 0;\n }\n :host([virtual]) thead th {\n position: sticky;\n top: 0;\n z-index: 1;\n background: var(--surface-card);\n }\n\n /* Stand-ins for the rows above and below the window: height only. */\n tbody tr.spacer,\n tbody tr.spacer:hover {\n background: none;\n }\n tr.spacer td {\n padding: 0;\n border: none;\n }\n :host([compact]) th {\n padding: 10px 12px;\n }\n\n .select-cell {\n width: 56px;\n text-align: center;\n }\n\n .placeholder {\n padding: 28px 0;\n color: var(--text-muted);\n text-align: center;\n }\n\n footer {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 12px;\n padding-top: 12px;\n }\n\n @media (max-width: 680px) {\n table {\n min-width: 100%;\n }\n td,\n th {\n padding: 10px 12px;\n }\n }\n `,\n ];\n\n /** The page on screen, from 1. Set it to open on another page. */\n @property({ type: Number })\n page = 1;\n\n /**\n * For data sorted and paged on a server: `data` is the current page, shown\n * as given. Headers and the pager still update the state and fire their\n * events, and the application loads what they ask for.\n */\n @property({ type: Boolean, reflect: true })\n manual = false;\n\n /**\n * Renders only the rows in view, for thousands of rows without paging. The\n * table scrolls inside its own box: give it a height (`kt-table { height:\n * 480px }`). Every row must be the same height — the first one rendered is\n * measured. A page size takes precedence.\n */\n @property({ type: Boolean, reflect: true })\n virtual = false;\n\n /** How far the scroller is scrolled. Not `scrollTop`, which the host already has. */\n @state()\n private scrollOffset = 0;\n\n /** The scroller's height, and the header's inside it, in px. */\n @state()\n private viewportHeight = 0;\n\n @state()\n private headerHeight = 0;\n\n /** A body row's height, in px; 0 until one has been measured. */\n @state()\n private rowHeight = 0;\n\n private resizeObserver: ResizeObserver | undefined;\n private observed: Element | undefined;\n\n /** In manual mode, how many rows the server holds — what the pager counts. */\n @property({ type: Number, attribute: 'total-rows' })\n totalRows = 0;\n\n @property({ attribute: false })\n columns: readonly KtTableColumn[] = [];\n\n @property({ attribute: false })\n data: readonly KtTableRow[] = [];\n\n @property({ type: Boolean, reflect: true })\n selectable = false;\n\n @property({ type: String, attribute: 'selection-mode' })\n selectionMode: 'single' | 'multiple' = 'multiple';\n\n /** The identities of the selected rows. */\n @property({ attribute: false })\n selected: readonly unknown[] = [];\n\n /** Rows per page. Zero shows everything and hides the footer. */\n @property({ type: Number, attribute: 'page-size' })\n pageSize = 0;\n\n @property({ type: Boolean, reflect: true })\n loading = false;\n\n @property({ type: Boolean, reflect: true })\n compact = false;\n\n @property({ type: String, attribute: 'sort-key' })\n sortKey: string | null = null;\n\n @property({ type: String, attribute: 'sort-direction' })\n sortDirection: KtSortDirection = null;\n\n /** Renders a cell. Return `undefined` to fall back to the raw value. */\n @property({ attribute: false })\n renderCell: KtCellRenderer | undefined;\n\n @property({ type: String, attribute: 'empty-text' })\n emptyText: string | undefined = undefined;\n\n @property({ type: String, attribute: 'loading-text' })\n loadingText: string | undefined = undefined;\n\n /** Accessible name for the table. */\n @property({ type: String })\n label = '';\n\n /**\n * BCP 47 locale text is sorted in. Empty means the page's `<html lang>`,\n * then the browser's language.\n */\n @property({ type: String })\n locale = '';\n\n /** The last sort, and what it was computed from. */\n private sortCache:\n | {\n data: readonly KtTableRow[];\n key: string | null;\n direction: KtSortDirection;\n locale: string;\n rows: readonly KtTableRow[];\n }\n | undefined;\n\n /**\n * The rows after sorting, before paging.\n *\n * Sorted once per change of `data`, `sortKey`, `sortDirection` or locale, not on\n * every render: hovering a row or ticking a box re-renders the table, and\n * re-sorting a few thousand rows each time is what made that lag. Assign a\n * new array to `data` rather than changing it in place.\n */\n get sortedRows(): readonly KtTableRow[] {\n if (this.manual) return this.data;\n\n const cache = this.sortCache;\n const locale = resolveLocale(this.locale);\n if (\n cache?.data === this.data &&\n cache.key === this.sortKey &&\n cache.direction === this.sortDirection &&\n cache.locale === locale\n ) {\n return cache.rows;\n }\n\n const rows = this.sort(collatorFor(locale));\n this.sortCache = {\n data: this.data,\n key: this.sortKey,\n direction: this.sortDirection,\n locale,\n rows,\n };\n return rows;\n }\n\n private sort(collator: Intl.Collator): readonly KtTableRow[] {\n if (!this.sortKey || !this.sortDirection) return this.data;\n\n const key = this.sortKey;\n const sign = this.sortDirection === 'asc' ? 1 : -1;\n\n return [...this.data].sort((a, b) => {\n const left = a[key];\n const right = b[key];\n\n // Empty values sort to the end whichever way the column points, so a\n // descending sort does not open with a screen of blanks.\n const leftEmpty = left === null || left === undefined;\n const rightEmpty = right === null || right === undefined;\n if (leftEmpty && rightEmpty) return 0;\n if (leftEmpty) return 1;\n if (rightEmpty) return -1;\n\n if (typeof left === 'number' && typeof right === 'number') return (left - right) * sign;\n return collator.compare(sortableText(left), sortableText(right)) * sign;\n });\n }\n\n get totalPages(): number {\n if (this.pageSize <= 0) return 1;\n const rows = this.manual ? this.totalRows || this.data.length : this.data.length;\n return Math.max(1, Math.ceil(rows / this.pageSize));\n }\n\n /** The rows actually on screen. */\n get visibleRows(): readonly KtTableRow[] {\n const rows = this.sortedRows;\n if (this.pageSize <= 0 || this.manual) return rows;\n\n const page = Math.min(this.page, this.totalPages);\n return rows.slice((page - 1) * this.pageSize, page * this.pageSize);\n }\n\n /**\n * Cycles a column: unsorted → ascending → descending → unsorted. The third\n * press restoring the original order is what makes sorting undoable.\n */\n private toggleSort(column: KtTableColumn): void {\n if (!column.sortable) return;\n\n if (this.sortKey !== column.key) {\n this.sortKey = column.key;\n this.sortDirection = 'asc';\n } else if (this.sortDirection === 'asc') {\n this.sortDirection = 'desc';\n } else {\n this.sortKey = null;\n this.sortDirection = null;\n }\n // A new order starts from its first page. No kt-page-change: the sort\n // event is the one reload the application needs.\n if (this.manual) this.page = 1;\n\n emit(this, 'kt-sort-change', { key: this.sortKey, direction: this.sortDirection });\n }\n\n private isSelected(row: KtTableRow): boolean {\n return this.selected.includes(rowKey(row));\n }\n\n private toggleSelection(row: KtTableRow): void {\n const key = rowKey(row);\n\n if (this.selectionMode === 'single') {\n this.selected = this.isSelected(row) ? [] : [key];\n } else {\n this.selected = this.isSelected(row)\n ? this.selected.filter((candidate) => candidate !== key)\n : [...this.selected, key];\n }\n\n emit(this, 'kt-selection-change', { selected: this.selected, rows: this.selectedRows });\n }\n\n /** Selects or clears every row on the current page. */\n private toggleAll(): void {\n const rows = this.visibleRows;\n const keys = rows.map(rowKey);\n const allSelected = keys.every((key) => this.selected.includes(key));\n\n this.selected = allSelected\n ? this.selected.filter((key) => !keys.includes(key))\n : [...new Set([...this.selected, ...keys])];\n\n emit(this, 'kt-selection-change', { selected: this.selected, rows: this.selectedRows });\n }\n\n /** The selected rows themselves, not just their identities. */\n get selectedRows(): readonly KtTableRow[] {\n return this.data.filter((row) => this.selected.includes(rowKey(row)));\n }\n\n /** Virtual rendering, unless a page size pages the rows instead. */\n private get isVirtual(): boolean {\n return this.virtual && this.pageSize <= 0;\n }\n\n private onScroll = (event: Event): void => {\n this.scrollOffset = (event.currentTarget as HTMLElement).scrollTop;\n };\n\n // Untyped: the measurements are private, so not among PropertyValues<this>.\n override updated(changed: PropertyValues): void {\n if (changed.has('compact')) this.rowHeight = 0;\n if (!this.isVirtual) {\n this.observe(undefined);\n return;\n }\n\n const scroller = this.shadowRoot?.querySelector<HTMLElement>('.scroller') ?? undefined;\n this.observe(scroller);\n\n // Measured from what was just rendered; each assignment is a no-op once\n // the numbers settle, so this converges in one extra render.\n const row = this.shadowRoot?.querySelector<HTMLElement>('tbody tr[part=\"row\"]');\n if (row && this.rowHeight === 0) this.rowHeight = row.getBoundingClientRect().height;\n const header = this.shadowRoot?.querySelector('thead');\n if (header) this.headerHeight = header.getBoundingClientRect().height;\n if (scroller) this.viewportHeight = scroller.clientHeight;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observe(undefined);\n }\n\n /** Follows the scroller's height, which the page can change at any time. */\n private observe(scroller: HTMLElement | undefined): void {\n if (scroller === this.observed) return;\n this.resizeObserver?.disconnect();\n this.observed = scroller;\n if (!scroller || typeof ResizeObserver === 'undefined') return;\n\n this.resizeObserver ??= new ResizeObserver(([entry]) => {\n if (entry) this.viewportHeight = (entry.target as HTMLElement).clientHeight;\n });\n this.resizeObserver.observe(scroller);\n }\n\n private onPageChange(event: Event): void {\n event.stopPropagation();\n this.page = (event as CustomEvent<{ page: number }>).detail.page;\n emit(this, 'kt-page-change', { page: this.page });\n }\n\n /**\n * The aria-sort value for a column.\n *\n * Not named ariaSort: HTMLElement reflects that ARIA attribute as a string\n * property, and shadowing it with a method breaks the element's own typing.\n */\n private sortStateFor(column: KtTableColumn): 'ascending' | 'descending' | 'none' {\n if (this.sortKey !== column.key || !this.sortDirection) return 'none';\n return this.sortDirection === 'asc' ? 'ascending' : 'descending';\n }\n\n private renderHeaderCell(column: KtTableColumn): TemplateResult {\n const title = column.label ?? column.key;\n const active = this.sortKey === column.key && this.sortDirection !== null;\n\n return html`<th\n part=\"header-cell\"\n scope=\"col\"\n style=${styleMap(column.width ? { width: column.width } : {})}\n aria-sort=${this.sortStateFor(column)}\n >\n ${\n column.sortable\n ? html`<button type=\"button\" @click=${() => this.toggleSort(column)}>\n <span>${title}</span>\n <span class=\"indicator\" aria-hidden=\"true\">\n ${\n active\n ? html`<kt-icon\n name=${this.sortDirection === 'asc' ? 'arrow-up' : 'arrow-down'}\n size=\"14\"\n ></kt-icon>`\n : nothing\n }\n </span>\n </button>`\n : html`<span>${title}</span>`\n }\n </th>`;\n }\n\n private renderBody(): TemplateResult {\n const rows = this.visibleRows;\n const columnCount = this.columns.length + (this.selectable ? 1 : 0);\n\n if (rows.length === 0) {\n return html`<tr>\n <td colspan=${columnCount}>\n <div class=\"placeholder\">${this.emptyText ?? strings().noData}</div>\n </td>\n </tr>`;\n }\n\n if (!this.isVirtual) {\n return html`${rows.map((row, index) => this.renderRow(row, index))}`;\n }\n\n const { start, end } = rowWindow({\n rowCount: rows.length,\n rowHeight: this.rowHeight,\n viewportHeight: Math.max(0, this.viewportHeight - this.headerHeight),\n scrollTop: Math.max(0, this.scrollOffset - this.headerHeight),\n overscan: OVERSCAN,\n });\n const spacer = (count: number) =>\n count > 0 && this.rowHeight > 0\n ? html`<tr class=\"spacer\" aria-hidden=\"true\">\n <td colspan=${columnCount} style=${`height: ${count * this.rowHeight}px`}></td>\n </tr>`\n : nothing;\n\n return html`${spacer(start)}${rows\n .slice(start, end)\n .map((row, offset) => this.renderRow(row, start + offset))}${spacer(rows.length - end)}`;\n }\n\n /** `index` counts from the first row of the data, not of the rows rendered. */\n private renderRow(row: KtTableRow, index: number): TemplateResult {\n const selected = this.isSelected(row);\n\n return html`<tr\n part=\"row\"\n class=${classMap({ selected })}\n aria-selected=${this.selectable ? String(selected) : nothing}\n aria-rowindex=${this.isVirtual ? index + 2 : nothing}\n @click=${() => emit(this, 'kt-row-click', { row, index })}\n >\n ${\n this.selectable\n ? html`<td class=\"select-cell\">\n <input\n type=${this.selectionMode === 'single' ? 'radio' : 'checkbox'}\n name=${this.selectionMode === 'single' ? 'kt-table-selection' : nothing}\n .checked=${selected}\n aria-label=${strings().selectRow}\n @click=${(event: Event) => event.stopPropagation()}\n @change=${() => this.toggleSelection(row)}\n />\n </td>`\n : nothing\n }\n ${this.columns.map((column) => {\n const rendered = this.renderCell?.(row, column);\n return html`<td part=\"cell\" style=${styleMap({ textAlign: column.align ?? 'left' })}>\n ${rendered === undefined ? row[column.key] : rendered}\n </td>`;\n })}\n </tr>`;\n }\n\n override render(): TemplateResult {\n // A manual table reloading a page keeps the one on screen, dimmed, so the\n // pager that asked for it — and the focus on it — stay where they are.\n const reloading = this.loading && this.manual && this.data.length > 0;\n if (this.loading && !reloading) {\n return html`<div class=\"placeholder\" role=\"status\" aria-live=\"polite\">\n ${this.loadingText ?? strings().loading}\n </div>`;\n }\n\n const rows = this.visibleRows;\n const allSelected = rows.length > 0 && rows.every((row) => this.isSelected(row));\n const someSelected = rows.some((row) => this.isSelected(row));\n\n const virtual = this.isVirtual;\n\n return html`<div class=\"scroller\" @scroll=${virtual ? this.onScroll : nothing}>\n <table\n part=\"table\"\n aria-label=${this.label || nothing}\n aria-busy=${reloading ? 'true' : nothing}\n aria-rowcount=${virtual ? rows.length + 1 : nothing}\n >\n <thead>\n <tr aria-rowindex=${virtual ? 1 : nothing}>\n ${\n this.selectable\n ? html`<th class=\"select-cell\" scope=\"col\">\n ${\n this.selectionMode === 'multiple'\n ? html`<input\n type=\"checkbox\"\n .checked=${allSelected}\n .indeterminate=${someSelected && !allSelected}\n aria-label=${strings().selectAll}\n @change=${this.toggleAll}\n />`\n : nothing\n }\n </th>`\n : nothing\n }\n ${this.columns.map((column) => this.renderHeaderCell(column))}\n </tr>\n </thead>\n <tbody>\n ${this.renderBody()}\n </tbody>\n </table>\n </div>\n\n ${\n this.pageSize > 0\n ? html`<footer>\n <kt-pagination\n .page=${Math.min(this.page, this.totalPages)}\n .totalPages=${this.totalPages}\n @kt-page-change=${this.onPageChange}\n ></kt-pagination>\n </footer>`\n : nothing\n }`;\n }\n}\n\ndefineElement('kt-table', KtTable);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-table': KtTable;\n }\n}\n"],"names":["FIRST_BATCH","rowWindow","rowCount","rowHeight","viewportHeight","scrollTop","overscan","fits","first","last","OVERSCAN","collators","collatorFor","locale","collator","sortableText","value","rowKey","row","KtTable","KtElement","event","css","cache","resolveLocale","rows","key","sign","a","b","left","right","leftEmpty","rightEmpty","page","column","emit","candidate","keys","allSelected","changed","scroller","header","entry","title","active","html","styleMap","nothing","columnCount","strings","index","start","end","spacer","count","offset","selected","classMap","rendered","reloading","someSelected","virtual","__decorateClass","property","state","defineElement"],"mappings":";;;;;;;;;;AAOA,MAAMA,IAAc;AAab,SAASC,EAAU;AAAA,EACxB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AACF,GAAmD;AACjD,MAAIJ,MAAa,EAAG,QAAO,EAAE,OAAO,GAAG,KAAK,EAAA;AAC5C,MAAIC,KAAa,EAAG,QAAO,EAAE,OAAO,GAAG,KAAK,KAAK,IAAID,GAAUF,CAAW,EAAA;AAI1E,QAAMO,IAAO,KAAK,KAAKH,IAAiBD,CAAS,GAC3CK,IAAQ,KAAK,IAAI,KAAK,MAAMH,IAAYF,CAAS,GAAG,KAAK,IAAI,GAAGD,IAAWK,CAAI,CAAC,GAChFE,IAAO,KAAK,MAAMJ,IAAYD,KAAkBD,CAAS;AAE/D,SAAO;AAAA,IACL,OAAO,KAAK,IAAI,GAAGK,IAAQF,CAAQ;AAAA,IACnC,KAAK,KAAK,IAAIJ,GAAUO,IAAOH,CAAQ;AAAA,EAAA;AAE3C;;;;;;ACLA,MAAMI,IAAW,GAEXC,wBAAgB,IAAA;AAQtB,SAASC,EAAYC,GAA+B;AAClD,MAAIC,IAAWH,EAAU,IAAIE,CAAM;AACnC,SAAKC,MACHA,IAAW,IAAI,KAAK,SAASD,GAAQ,EAAE,SAAS,IAAM,aAAa,QAAQ,GAC3EF,EAAU,IAAIE,GAAQC,CAAQ,IAEzBA;AACT;AAQA,SAASC,EAAaC,GAAwB;AAC5C,MAAI,OAAOA,KAAU,SAAU,QAAOA;AACtC,MAAI,OAAOA,KAAU,YAAY,OAAOA,KAAU,aAAa,OAAOA,KAAU;AAC9E,WAAO,OAAOA,CAAK;AAErB,MAAI;AACF,WAAO,KAAK,UAAUA,CAAK,KAAK;AAAA,EAClC,QAAQ;AACN,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AAM,QAAQ,WAAW,cAAc;AAAA,GAxOxC7C,EAyOX,WAAA,WAAA;AAGA4C,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,GA3O1C7C,EA4OX,WAAA,aAAA;AAIA4C,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/Of7C,EAgPX,WAAA,OAAA;AAOA4C,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAtPf7C,EAuPX,WAAA,QAAA;AAmXF+C,EAAc,YAAY/C,CAAO;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which rows a virtual table renders: those under the viewport, and a few
|
|
3
|
+
* either side so a fast scroll does not show blank space before the next
|
|
4
|
+
* render lands.
|
|
5
|
+
*/
|
|
6
|
+
export interface RowWindowInput {
|
|
7
|
+
readonly rowCount: number;
|
|
8
|
+
/** Every row's height, in px; 0 until one has been measured. */
|
|
9
|
+
readonly rowHeight: number;
|
|
10
|
+
readonly viewportHeight: number;
|
|
11
|
+
readonly scrollTop: number;
|
|
12
|
+
/** Extra rows rendered above and below the viewport. */
|
|
13
|
+
readonly overscan: number;
|
|
14
|
+
}
|
|
15
|
+
/** Rows `start` (inclusive) to `end` (exclusive). */
|
|
16
|
+
export declare function rowWindow({ rowCount, rowHeight, viewportHeight, scrollTop, overscan, }: RowWindowInput): {
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { css as h, html as s, nothing as m } from "lit";
|
|
2
2
|
import { property as a } from "lit/decorators.js";
|
|
3
3
|
import { classMap as k } from "lit/directives/class-map.js";
|
|
4
|
-
import { K as c, d as f } from "../../../chunks/kt-element-
|
|
4
|
+
import { K as c, d as f } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
5
5
|
import "../../core/kt-icon/kt-icon.js";
|
|
6
6
|
var v = Object.defineProperty, i = (l, r, o, n) => {
|
|
7
7
|
for (var e = void 0, p = l.length - 1, d; p >= 0; p--)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { css as v, nothing as s, html as e } from "lit";
|
|
2
2
|
import { property as t } from "lit/decorators.js";
|
|
3
|
-
import { K as p, d as g } from "../../../chunks/kt-element-
|
|
4
|
-
import { e as h } from "../../../chunks/events-
|
|
5
|
-
import { s as f } from "../../../chunks/index-
|
|
3
|
+
import { K as p, d as g } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
4
|
+
import { e as h } from "../../../chunks/events-r51msXNf.js";
|
|
5
|
+
import { s as f } from "../../../chunks/index-STEEvEP7.js";
|
|
6
6
|
import "../../core/kt-icon/kt-icon.js";
|
|
7
7
|
var u = Object.defineProperty, a = (n, i, c, b) => {
|
|
8
8
|
for (var r = void 0, l = n.length - 1, d; l >= 0; l--)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css as h, nothing as r, html as i } from "lit";
|
|
2
2
|
import { property as n } from "lit/decorators.js";
|
|
3
|
-
import { K as d, d as m } from "../../../chunks/kt-element-
|
|
3
|
+
import { K as d, d as m } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
4
4
|
import "../../core/kt-icon/kt-icon.js";
|
|
5
5
|
var g = Object.defineProperty, o = (s, p, c, f) => {
|
|
6
6
|
for (var t = void 0, a = s.length - 1, l; a >= 0; a--)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { css as v, nothing as p, html as o } from "lit";
|
|
2
2
|
import { property as t } from "lit/decorators.js";
|
|
3
|
-
import { classMap as
|
|
3
|
+
import { classMap as d } from "lit/directives/class-map.js";
|
|
4
4
|
import { styleMap as m } from "lit/directives/style-map.js";
|
|
5
|
-
import { K as u, d as b } from "../../../chunks/kt-element-
|
|
5
|
+
import { K as u, d as b } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
6
6
|
var f = Object.defineProperty, r = (n, e, i, c) => {
|
|
7
|
-
for (var s = void 0, l = n.length - 1,
|
|
8
|
-
(
|
|
7
|
+
for (var s = void 0, l = n.length - 1, h; l >= 0; l--)
|
|
8
|
+
(h = n[l]) && (s = h(e, i, s) || s);
|
|
9
9
|
return s && f(e, i, s), s;
|
|
10
10
|
};
|
|
11
11
|
class a extends u {
|
|
@@ -77,7 +77,7 @@ class a extends u {
|
|
|
77
77
|
width: 0;
|
|
78
78
|
height: 100%;
|
|
79
79
|
background: var(--color-primary-base);
|
|
80
|
-
transition: width
|
|
80
|
+
transition: width var(--duration-slow) var(--easing-standard);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
:host([variant='info']) .fill {
|
|
@@ -106,11 +106,11 @@ class a extends u {
|
|
|
106
106
|
.fill.striped {
|
|
107
107
|
background-image: linear-gradient(
|
|
108
108
|
45deg,
|
|
109
|
-
|
|
109
|
+
color-mix(in srgb, var(--color-white) 7%, transparent) 25%,
|
|
110
110
|
transparent 25%,
|
|
111
111
|
transparent 50%,
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
color-mix(in srgb, var(--color-white) 7%, transparent) 50%,
|
|
113
|
+
color-mix(in srgb, var(--color-white) 7%, transparent) 75%,
|
|
114
114
|
transparent 75%,
|
|
115
115
|
transparent
|
|
116
116
|
);
|
|
@@ -148,7 +148,7 @@ class a extends u {
|
|
|
148
148
|
}
|
|
149
149
|
render() {
|
|
150
150
|
const e = this.percent, i = this.value >= (this.max > 0 ? this.max : 100), c = this.showLabel && this.label || this.showValue;
|
|
151
|
-
return o`<div part="base" class=${
|
|
151
|
+
return o`<div part="base" class=${d({ bar: !0, complete: i })}>
|
|
152
152
|
${c ? o`<div part="caption" class="caption">
|
|
153
153
|
${this.showLabel && this.label ? o`<span class="caption-label">${this.label}</span>` : o`<span></span>`}
|
|
154
154
|
${this.showValue ? o`<span part="value" class="caption-value">${e}%</span>` : p}
|
|
@@ -166,7 +166,7 @@ class a extends u {
|
|
|
166
166
|
>
|
|
167
167
|
<div
|
|
168
168
|
part="fill"
|
|
169
|
-
class=${
|
|
169
|
+
class=${d({
|
|
170
170
|
fill: !0,
|
|
171
171
|
complete: i,
|
|
172
172
|
striped: this.striped,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kt-progress-bar.js","sources":["../../../../src/components/feedback/kt-progress-bar/kt-progress-bar.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\n\nexport type KtProgressVariant = 'primary' | 'info' | 'success' | 'warning' | 'danger' | 'neutral';\nexport type KtProgressSize = 'small' | 'medium' | 'large';\n\n/**\n * A determinate progress bar.\n *\n * Reaching `max` switches the fill to the success colour, so \"done\" reads at a\n * glance without the caller having to swap the variant.\n *\n * @element kt-progress-bar\n *\n * @csspart track - The groove.\n * @csspart fill - The filled portion.\n * @csspart base - The container.\n * @csspart caption - The row above the bar.\n * @csspart value - The percentage, when `show-value` is set.\n *\n * @example\n * ```html\n * <kt-progress-bar value=\"64\" show-value></kt-progress-bar>\n * <kt-progress-bar value=\"90\" variant=\"warning\" striped animated></kt-progress-bar>\n * ```\n */\nexport class KtProgressBar extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n width: 100%;\n }\n\n .bar {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n\n /* The caption sits above the track, not inside it. A label centred over\n an 8px bar is half on the fill and half off it, so it is unreadable at\n one end of the range whatever colour it is given — and at size=\"small\"\n the track is 4px and clips it outright. Above the bar it reads in every\n theme, at every size, at every value. */\n .caption {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n }\n\n .caption-label {\n overflow: hidden;\n color: var(--text-body);\n font: var(--font-normal-regular);\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n\n .caption-value {\n flex: none;\n color: var(--text-muted);\n font: var(--font-normal-small);\n font-variant-numeric: tabular-nums;\n }\n\n .complete .caption-value {\n color: var(--color-success-text);\n }\n\n .track {\n position: relative;\n height: 8px;\n overflow: hidden;\n background: var(--surface-raised);\n border-radius: var(--border-radius);\n }\n\n :host([size='small']) .track {\n height: 4px;\n }\n :host([size='large']) .track {\n height: 12px;\n }\n\n .fill {\n width: 0;\n height: 100%;\n background: var(--color-primary-base);\n transition: width 0.4s var(--easing-standard);\n }\n\n :host([variant='info']) .fill {\n background: var(--color-info-base);\n }\n :host([variant='success']) .fill {\n background: var(--color-success-base);\n }\n :host([variant='warning']) .fill {\n background: var(--color-warning-base);\n }\n :host([variant='danger']) .fill {\n background: var(--color-danger-base);\n }\n :host([variant='neutral']) .fill {\n background: var(--color-text-500);\n }\n\n /* Completion reads as success whatever the variant was. */\n .fill.complete {\n background: var(--color-success-base);\n }\n\n /* The one decorative animation in Kanto, and it earns its place: a\n striped bar is how an operation says it is still working. */\n .fill.striped {\n background-image: linear-gradient(\n 45deg,\n rgba(255, 255, 255, 0.07) 25%,\n transparent 25%,\n transparent 50%,\n rgba(255, 255, 255, 0.07) 50%,\n rgba(255, 255, 255, 0.07) 75%,\n transparent 75%,\n transparent\n );\n background-size: 1rem 1rem;\n }\n\n .fill.striped.animated {\n animation: kt-progress-stripes 1s linear infinite;\n }\n\n @keyframes kt-progress-stripes {\n from {\n background-position: 0 0;\n }\n to {\n background-position: 1rem 0;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .fill {\n transition: none;\n }\n .fill.striped.animated {\n animation: none;\n }\n }\n `,\n ];\n\n @property({ type: Number })\n value = 0;\n\n @property({ type: Number })\n max = 100;\n\n @property({ type: String, reflect: true })\n size: KtProgressSize = 'medium';\n\n @property({ type: String, reflect: true })\n variant: KtProgressVariant = 'primary';\n\n /** Draws the percentage in a caption above the bar. */\n @property({ type: Boolean, attribute: 'show-value' })\n showValue = false;\n\n /**\n * Shows `label` above the bar as visible text, beside the value.\n *\n * `label` alone is the accessible name and stays invisible, which is right\n * when the surrounding copy already says what is progressing.\n */\n @property({ type: Boolean, attribute: 'show-label' })\n showLabel = false;\n\n @property({ type: Boolean, reflect: true })\n striped = false;\n\n /** Animates the stripes. Requires `striped`. */\n @property({ type: Boolean, reflect: true })\n animated = false;\n\n /** Accessible name — what is progressing. */\n @property({ type: String })\n label = '';\n\n /** The value as a whole percentage, clamped to 0–100. */\n get percent(): number {\n const max = this.max > 0 ? this.max : 100;\n const clamped = Math.min(Math.max(this.value, 0), max);\n return Math.round((clamped / max) * 100);\n }\n\n override render(): TemplateResult {\n const percent = this.percent;\n const complete = this.value >= (this.max > 0 ? this.max : 100);\n\n const caption = (this.showLabel && this.label) || this.showValue;\n\n return html`<div part=\"base\" class=${classMap({ bar: true, complete })}>\n ${\n caption\n ? html`<div part=\"caption\" class=\"caption\">\n ${\n this.showLabel && this.label\n ? html`<span class=\"caption-label\">${this.label}</span>`\n : html`<span></span>`\n }\n ${\n this.showValue\n ? html`<span part=\"value\" class=\"caption-value\">${percent}%</span>`\n : nothing\n }\n </div>`\n : nothing\n }\n\n <div\n part=\"track\"\n class=\"track\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=${this.max}\n aria-valuenow=${this.value}\n aria-valuetext=${`${percent}%`}\n aria-label=${this.label || nothing}\n >\n <div\n part=\"fill\"\n class=${classMap({\n fill: true,\n complete,\n striped: this.striped,\n animated: this.animated,\n })}\n style=${styleMap({ width: `${percent}%` })}\n ></div>\n </div>\n </div>`;\n }\n}\n\ndefineElement('kt-progress-bar', KtProgressBar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-progress-bar': KtProgressBar;\n }\n}\n"],"names":["KtProgressBar","KtElement","css","max","clamped","percent","complete","caption","html","classMap","nothing","styleMap","__decorateClass","property","defineElement"],"mappings":";;;;;;;;;;AA6BO,MAAMA,UAAsBC,EAAU;AAAA,EAAtC,cAAA;AAAA,UAAA,GAAA,SAAA,GAkIL,KAAA,QAAQ,GAGR,KAAA,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AAE,MAAM,SAAS,WAAW,cAAc;AAAA,GAvJzCb,EAwJX,WAAA,WAAA;AAGAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA1J/Bb,EA2JX,WAAA,SAAA;AAIAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA9J/Bb,EA+JX,WAAA,UAAA;AAIAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAlKfb,EAmKX,WAAA,OAAA;AA0DFc,EAAc,mBAAmBd,CAAa;"}
|
|
1
|
+
{"version":3,"file":"kt-progress-bar.js","sources":["../../../../src/components/feedback/kt-progress-bar/kt-progress-bar.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\n\nexport type KtProgressVariant = 'primary' | 'info' | 'success' | 'warning' | 'danger' | 'neutral';\nexport type KtProgressSize = 'small' | 'medium' | 'large';\n\n/**\n * A determinate progress bar.\n *\n * Reaching `max` switches the fill to the success colour, so \"done\" reads at a\n * glance without the caller having to swap the variant.\n *\n * @element kt-progress-bar\n *\n * @csspart track - The groove.\n * @csspart fill - The filled portion.\n * @csspart base - The container.\n * @csspart caption - The row above the bar.\n * @csspart value - The percentage, when `show-value` is set.\n *\n * @example\n * ```html\n * <kt-progress-bar value=\"64\" show-value></kt-progress-bar>\n * <kt-progress-bar value=\"90\" variant=\"warning\" striped animated></kt-progress-bar>\n * ```\n */\nexport class KtProgressBar extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n width: 100%;\n }\n\n .bar {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n\n /* The caption sits above the track, not inside it. A label centred over\n an 8px bar is half on the fill and half off it, so it is unreadable at\n one end of the range whatever colour it is given — and at size=\"small\"\n the track is 4px and clips it outright. Above the bar it reads in every\n theme, at every size, at every value. */\n .caption {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n }\n\n .caption-label {\n overflow: hidden;\n color: var(--text-body);\n font: var(--font-normal-regular);\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n\n .caption-value {\n flex: none;\n color: var(--text-muted);\n font: var(--font-normal-small);\n font-variant-numeric: tabular-nums;\n }\n\n .complete .caption-value {\n color: var(--color-success-text);\n }\n\n .track {\n position: relative;\n height: 8px;\n overflow: hidden;\n background: var(--surface-raised);\n border-radius: var(--border-radius);\n }\n\n :host([size='small']) .track {\n height: 4px;\n }\n :host([size='large']) .track {\n height: 12px;\n }\n\n .fill {\n width: 0;\n height: 100%;\n background: var(--color-primary-base);\n transition: width var(--duration-slow) var(--easing-standard);\n }\n\n :host([variant='info']) .fill {\n background: var(--color-info-base);\n }\n :host([variant='success']) .fill {\n background: var(--color-success-base);\n }\n :host([variant='warning']) .fill {\n background: var(--color-warning-base);\n }\n :host([variant='danger']) .fill {\n background: var(--color-danger-base);\n }\n :host([variant='neutral']) .fill {\n background: var(--color-text-500);\n }\n\n /* Completion reads as success whatever the variant was. */\n .fill.complete {\n background: var(--color-success-base);\n }\n\n /* The one decorative animation in Kanto, and it earns its place: a\n striped bar is how an operation says it is still working. */\n .fill.striped {\n background-image: linear-gradient(\n 45deg,\n color-mix(in srgb, var(--color-white) 7%, transparent) 25%,\n transparent 25%,\n transparent 50%,\n color-mix(in srgb, var(--color-white) 7%, transparent) 50%,\n color-mix(in srgb, var(--color-white) 7%, transparent) 75%,\n transparent 75%,\n transparent\n );\n background-size: 1rem 1rem;\n }\n\n .fill.striped.animated {\n animation: kt-progress-stripes 1s linear infinite;\n }\n\n @keyframes kt-progress-stripes {\n from {\n background-position: 0 0;\n }\n to {\n background-position: 1rem 0;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .fill {\n transition: none;\n }\n .fill.striped.animated {\n animation: none;\n }\n }\n `,\n ];\n\n @property({ type: Number })\n value = 0;\n\n @property({ type: Number })\n max = 100;\n\n @property({ type: String, reflect: true })\n size: KtProgressSize = 'medium';\n\n @property({ type: String, reflect: true })\n variant: KtProgressVariant = 'primary';\n\n /** Draws the percentage in a caption above the bar. */\n @property({ type: Boolean, attribute: 'show-value' })\n showValue = false;\n\n /**\n * Shows `label` above the bar as visible text, beside the value.\n *\n * `label` alone is the accessible name and stays invisible, which is right\n * when the surrounding copy already says what is progressing.\n */\n @property({ type: Boolean, attribute: 'show-label' })\n showLabel = false;\n\n @property({ type: Boolean, reflect: true })\n striped = false;\n\n /** Animates the stripes. Requires `striped`. */\n @property({ type: Boolean, reflect: true })\n animated = false;\n\n /** Accessible name — what is progressing. */\n @property({ type: String })\n label = '';\n\n /** The value as a whole percentage, clamped to 0–100. */\n get percent(): number {\n const max = this.max > 0 ? this.max : 100;\n const clamped = Math.min(Math.max(this.value, 0), max);\n return Math.round((clamped / max) * 100);\n }\n\n override render(): TemplateResult {\n const percent = this.percent;\n const complete = this.value >= (this.max > 0 ? this.max : 100);\n\n const caption = (this.showLabel && this.label) || this.showValue;\n\n return html`<div part=\"base\" class=${classMap({ bar: true, complete })}>\n ${\n caption\n ? html`<div part=\"caption\" class=\"caption\">\n ${\n this.showLabel && this.label\n ? html`<span class=\"caption-label\">${this.label}</span>`\n : html`<span></span>`\n }\n ${\n this.showValue\n ? html`<span part=\"value\" class=\"caption-value\">${percent}%</span>`\n : nothing\n }\n </div>`\n : nothing\n }\n\n <div\n part=\"track\"\n class=\"track\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=${this.max}\n aria-valuenow=${this.value}\n aria-valuetext=${`${percent}%`}\n aria-label=${this.label || nothing}\n >\n <div\n part=\"fill\"\n class=${classMap({\n fill: true,\n complete,\n striped: this.striped,\n animated: this.animated,\n })}\n style=${styleMap({ width: `${percent}%` })}\n ></div>\n </div>\n </div>`;\n }\n}\n\ndefineElement('kt-progress-bar', KtProgressBar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-progress-bar': KtProgressBar;\n }\n}\n"],"names":["KtProgressBar","KtElement","css","max","clamped","percent","complete","caption","html","classMap","nothing","styleMap","__decorateClass","property","defineElement"],"mappings":";;;;;;;;;;AA6BO,MAAMA,UAAsBC,EAAU;AAAA,EAAtC,cAAA;AAAA,UAAA,GAAA,SAAA,GAkIL,KAAA,QAAQ,GAGR,KAAA,MAAM,KAGN,KAAA,OAAuB,UAGvB,KAAA,UAA6B,WAI7B,KAAA,YAAY,IASZ,KAAA,YAAY,IAGZ,KAAA,UAAU,IAIV,KAAA,WAAW,IAIX,KAAA,QAAQ;AAAA,EAAA;AAAA,EAlKR,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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QAAQ,SAAS,IAAM;AAAA,GAvI9Bb,EAwIX,WAAA,MAAA;AAGAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GA1I9Bb,EA2IX,WAAA,SAAA;AAIAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,WAAW,cAAc;AAAA,GA9IzCb,EA+IX,WAAA,WAAA;AASAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,WAAW,cAAc;AAAA,GAvJzCb,EAwJX,WAAA,WAAA;AAGAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA1J/Bb,EA2JX,WAAA,SAAA;AAIAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA9J/Bb,EA+JX,WAAA,UAAA;AAIAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAlKfb,EAmKX,WAAA,OAAA;AA0DFc,EAAc,mBAAmBd,CAAa;"}
|
|
@@ -2,7 +2,7 @@ import { css as c, html as d } from "lit";
|
|
|
2
2
|
import { property as s } from "lit/decorators.js";
|
|
3
3
|
import { classMap as h } from "lit/directives/class-map.js";
|
|
4
4
|
import { styleMap as m } from "lit/directives/style-map.js";
|
|
5
|
-
import { K as u, d as f } from "../../../chunks/kt-element-
|
|
5
|
+
import { K as u, d as f } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
6
6
|
var y = Object.defineProperty, a = (n, i, t, p) => {
|
|
7
7
|
for (var e = void 0, o = n.length - 1, l; o >= 0; o--)
|
|
8
8
|
(l = n[o]) && (e = l(i, t, e) || e);
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { state as
|
|
3
|
-
import { K as p, d as m } from "../../../chunks/kt-element-
|
|
4
|
-
import { e as
|
|
5
|
-
import { s as h } from "../../../chunks/index-
|
|
1
|
+
import { css as v, nothing as n, html as a } from "lit";
|
|
2
|
+
import { state as u, property as s } from "lit/decorators.js";
|
|
3
|
+
import { K as p, d as m } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
4
|
+
import { e as b } from "../../../chunks/events-r51msXNf.js";
|
|
5
|
+
import { s as h } from "../../../chunks/index-STEEvEP7.js";
|
|
6
6
|
import "../../core/kt-icon/kt-icon.js";
|
|
7
7
|
import "../kt-progress-bar/kt-progress-bar.js";
|
|
8
|
-
var
|
|
9
|
-
for (var
|
|
10
|
-
(
|
|
11
|
-
return
|
|
8
|
+
var f = Object.defineProperty, o = (c, i, e, w) => {
|
|
9
|
+
for (var t = void 0, l = c.length - 1, d; l >= 0; l--)
|
|
10
|
+
(d = c[l]) && (t = d(i, e, t) || t);
|
|
11
|
+
return t && f(i, e, t), t;
|
|
12
12
|
};
|
|
13
|
-
const
|
|
13
|
+
const x = {
|
|
14
14
|
success: { icon: "circle-check", progress: "success" },
|
|
15
15
|
information: { icon: "info", progress: "info" },
|
|
16
16
|
warning: { icon: "triangle-alert", progress: "warning" },
|
|
17
17
|
error: { icon: "circle-alert", progress: "danger" }
|
|
18
18
|
}, g = 50;
|
|
19
|
-
class
|
|
19
|
+
class r extends p {
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments), this.remaining = 0, this.variant = "information", this.heading = "", this.description = "", this.dismissible = !1, this.duration = 0;
|
|
22
22
|
}
|
|
23
23
|
static {
|
|
24
24
|
this.styles = [
|
|
25
25
|
p.styles,
|
|
26
|
-
|
|
26
|
+
v`
|
|
27
27
|
:host {
|
|
28
28
|
display: block;
|
|
29
29
|
}
|
|
@@ -39,7 +39,7 @@ class t extends p {
|
|
|
39
39
|
overflow: hidden;
|
|
40
40
|
color: var(--text-body);
|
|
41
41
|
background: var(--surface-card);
|
|
42
|
-
border: var(--border-width) solid
|
|
42
|
+
border: var(--border-width) solid color-mix(in srgb, var(--color-white) 10%, transparent);
|
|
43
43
|
border-radius: var(--border-radius);
|
|
44
44
|
box-shadow: var(--shadow-toast);
|
|
45
45
|
backdrop-filter: blur(10px);
|
|
@@ -50,22 +50,38 @@ class t extends p {
|
|
|
50
50
|
contrast. */
|
|
51
51
|
:host([variant='success']) .toast {
|
|
52
52
|
background:
|
|
53
|
-
linear-gradient(
|
|
53
|
+
linear-gradient(
|
|
54
|
+
135deg,
|
|
55
|
+
color-mix(in srgb, var(--color-success-base) 25%, transparent),
|
|
56
|
+
color-mix(in srgb, var(--color-success-base) 15%, transparent)
|
|
57
|
+
),
|
|
54
58
|
var(--surface-card);
|
|
55
59
|
}
|
|
56
60
|
:host([variant='information']) .toast {
|
|
57
61
|
background:
|
|
58
|
-
linear-gradient(
|
|
62
|
+
linear-gradient(
|
|
63
|
+
135deg,
|
|
64
|
+
color-mix(in srgb, var(--color-info-base) 25%, transparent),
|
|
65
|
+
color-mix(in srgb, var(--color-info-base) 15%, transparent)
|
|
66
|
+
),
|
|
59
67
|
var(--surface-card);
|
|
60
68
|
}
|
|
61
69
|
:host([variant='warning']) .toast {
|
|
62
70
|
background:
|
|
63
|
-
linear-gradient(
|
|
71
|
+
linear-gradient(
|
|
72
|
+
135deg,
|
|
73
|
+
color-mix(in srgb, var(--color-warning-base) 25%, transparent),
|
|
74
|
+
color-mix(in srgb, var(--color-warning-base) 15%, transparent)
|
|
75
|
+
),
|
|
64
76
|
var(--surface-card);
|
|
65
77
|
}
|
|
66
78
|
:host([variant='error']) .toast {
|
|
67
79
|
background:
|
|
68
|
-
linear-gradient(
|
|
80
|
+
linear-gradient(
|
|
81
|
+
135deg,
|
|
82
|
+
color-mix(in srgb, var(--color-danger-base) 25%, transparent),
|
|
83
|
+
color-mix(in srgb, var(--color-danger-base) 15%, transparent)
|
|
84
|
+
),
|
|
69
85
|
var(--surface-card);
|
|
70
86
|
}
|
|
71
87
|
|
|
@@ -172,10 +188,10 @@ class t extends p {
|
|
|
172
188
|
}
|
|
173
189
|
/** Asks to be removed. The container is what actually removes it. */
|
|
174
190
|
close() {
|
|
175
|
-
this.stopCountdown(),
|
|
191
|
+
this.stopCountdown(), b(this, "kt-toast-close");
|
|
176
192
|
}
|
|
177
193
|
render() {
|
|
178
|
-
const
|
|
194
|
+
const i = x[this.variant], e = this.duration > 0;
|
|
179
195
|
return a`<div
|
|
180
196
|
part="base"
|
|
181
197
|
class="toast"
|
|
@@ -183,7 +199,7 @@ class t extends p {
|
|
|
183
199
|
aria-live=${this.variant === "error" ? "assertive" : "polite"}
|
|
184
200
|
>
|
|
185
201
|
<div class="body">
|
|
186
|
-
<span class="icon"><kt-icon name=${
|
|
202
|
+
<span class="icon"><kt-icon name=${i.icon} size="24"></kt-icon></span>
|
|
187
203
|
<div class="content">
|
|
188
204
|
${this.heading ? a`<div class="heading">${this.heading}</div>` : n}
|
|
189
205
|
${this.description ? a`<div class="description">${this.description}</div>` : n}
|
|
@@ -198,10 +214,10 @@ class t extends p {
|
|
|
198
214
|
>
|
|
199
215
|
<kt-icon name="x" size="18"></kt-icon>
|
|
200
216
|
</button>` : n}
|
|
201
|
-
${
|
|
217
|
+
${e ? a`<div class="countdown">
|
|
202
218
|
<kt-progress-bar
|
|
203
219
|
size="small"
|
|
204
|
-
variant=${
|
|
220
|
+
variant=${i.progress}
|
|
205
221
|
striped
|
|
206
222
|
animated
|
|
207
223
|
.value=${this.remaining}
|
|
@@ -212,26 +228,26 @@ class t extends p {
|
|
|
212
228
|
</div>`;
|
|
213
229
|
}
|
|
214
230
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
],
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
],
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
],
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
],
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
],
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
],
|
|
233
|
-
m("kt-toast",
|
|
231
|
+
o([
|
|
232
|
+
u()
|
|
233
|
+
], r.prototype, "remaining");
|
|
234
|
+
o([
|
|
235
|
+
s({ type: String, reflect: !0 })
|
|
236
|
+
], r.prototype, "variant");
|
|
237
|
+
o([
|
|
238
|
+
s({ type: String })
|
|
239
|
+
], r.prototype, "heading");
|
|
240
|
+
o([
|
|
241
|
+
s({ type: String })
|
|
242
|
+
], r.prototype, "description");
|
|
243
|
+
o([
|
|
244
|
+
s({ type: Boolean })
|
|
245
|
+
], r.prototype, "dismissible");
|
|
246
|
+
o([
|
|
247
|
+
s({ type: Number })
|
|
248
|
+
], r.prototype, "duration");
|
|
249
|
+
m("kt-toast", r);
|
|
234
250
|
export {
|
|
235
|
-
|
|
251
|
+
r as KtToast
|
|
236
252
|
};
|
|
237
253
|
//# sourceMappingURL=kt-toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kt-toast.js","sources":["../../../../src/components/feedback/kt-toast/kt-toast.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { emit } from '#internal/events';\nimport { strings } from '#internal/strings';\nimport '../../core/kt-icon/kt-icon.js';\nimport '../kt-progress-bar/kt-progress-bar.js';\n\nexport type KtToastVariant = 'success' | 'information' | 'warning' | 'error';\n\ninterface VariantMeta {\n readonly icon: string;\n readonly progress: 'success' | 'info' | 'warning' | 'danger';\n}\n\nconst META: Record<KtToastVariant, VariantMeta> = {\n success: { icon: 'circle-check', progress: 'success' },\n information: { icon: 'info', progress: 'info' },\n warning: { icon: 'triangle-alert', progress: 'warning' },\n error: { icon: 'circle-alert', progress: 'danger' },\n};\n\n/** Countdown refresh interval. 50ms is smooth without being a busy loop. */\nconst TICK_MS = 50;\n\n/**\n * A transient notification.\n *\n * The only element in Kanto with a real shadow, and the only one that blurs\n * what is behind it: a toast floats above the page, so it has to say so.\n *\n * @element kt-toast\n *\n * @csspart base - The toast surface.\n * @csspart close - The dismiss button.\n *\n * @fires kt-toast-close - The toast asked to be removed, by timeout or by the\n * dismiss button. `<kt-toast-container>` listens for this.\n */\nexport class KtToast extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n }\n\n .toast {\n position: relative;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: var(--gap-form);\n max-width: 480px;\n padding: var(--padding-form);\n overflow: hidden;\n color: var(--text-body);\n background: var(--surface-card);\n border: var(--border-width) solid rgba(255, 255, 255, 0.1);\n border-radius: var(--border-radius);\n box-shadow: var(--shadow-toast);\n backdrop-filter: blur(10px);\n }\n\n /* A wash of the variant's hue over the card surface, rather than a\n solid fill: the text stays on a neutral background and keeps its\n contrast. */\n :host([variant='success']) .toast {\n background:\n linear-gradient(135deg, rgba(53, 221, 131, 0.25), rgba(53, 221, 131, 0.15)),\n var(--surface-card);\n }\n :host([variant='information']) .toast {\n background:\n linear-gradient(135deg, rgba(53, 175, 243, 0.25), rgba(53, 175, 243, 0.15)),\n var(--surface-card);\n }\n :host([variant='warning']) .toast {\n background:\n linear-gradient(135deg, rgba(245, 171, 61, 0.25), rgba(245, 171, 61, 0.15)),\n var(--surface-card);\n }\n :host([variant='error']) .toast {\n background:\n linear-gradient(135deg, rgba(245, 61, 92, 0.25), rgba(245, 61, 92, 0.15)),\n var(--surface-card);\n }\n\n :host([variant='success']) .heading {\n color: var(--color-success-text);\n }\n :host([variant='information']) .heading {\n color: var(--color-info-text);\n }\n :host([variant='warning']) .heading {\n color: var(--color-warning-text);\n }\n :host([variant='error']) .heading {\n color: var(--color-danger-text);\n }\n\n :host([variant='success']) .icon {\n color: var(--color-success-text);\n }\n :host([variant='information']) .icon {\n color: var(--color-info-text);\n }\n :host([variant='warning']) .icon {\n color: var(--color-warning-text);\n }\n :host([variant='error']) .icon {\n color: var(--color-danger-text);\n }\n\n .body {\n display: flex;\n align-items: center;\n gap: var(--gap-form);\n }\n\n .icon {\n display: flex;\n align-items: center;\n }\n\n .content {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: var(--gap-element);\n }\n\n .heading {\n font: var(--font-normal-medium);\n }\n\n .description {\n font: var(--font-normal-regular);\n }\n\n .close {\n display: flex;\n align-items: center;\n padding: 4px;\n color: currentcolor;\n background: transparent;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n .close:focus-visible {\n outline: var(--outline-width) solid var(--color-primary-base);\n }\n\n .countdown {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n }\n `,\n ];\n\n private timer: ReturnType<typeof setInterval> | undefined;\n\n @state()\n private remaining = 0;\n\n @property({ type: String, reflect: true })\n variant: KtToastVariant = 'information';\n\n /**\n * The toast's title.\n *\n * Named `heading` because every element already has a `title`, and shadowing\n * it would turn the toast into its own tooltip.\n */\n @property({ type: String })\n heading = '';\n\n @property({ type: String })\n description = '';\n\n @property({ type: Boolean })\n dismissible = false;\n\n /**\n * Auto-dismiss after this many milliseconds, with a countdown bar. Zero\n * keeps the toast until something removes it.\n */\n @property({ type: Number })\n duration = 0;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.startCountdown();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.stopCountdown();\n }\n\n private startCountdown(): void {\n this.stopCountdown();\n if (this.duration <= 0) return;\n\n this.remaining = this.duration;\n this.tick();\n }\n\n /** Runs the countdown from whatever `remaining` currently is. */\n private tick(): void {\n this.timer = setInterval(() => {\n this.remaining -= TICK_MS;\n if (this.remaining > 0) return;\n\n this.stopCountdown();\n this.close();\n }, TICK_MS);\n }\n\n private stopCountdown(): void {\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n /** Pauses the countdown. The container calls this while the pointer is over the stack. */\n pause(): void {\n if (this.timer !== undefined) this.stopCountdown();\n }\n\n /** Resumes a paused countdown from where it stopped. */\n resume(): void {\n if (this.duration <= 0 || this.timer !== undefined || this.remaining <= 0) return;\n this.tick();\n }\n\n /** Asks to be removed. The container is what actually removes it. */\n close(): void {\n this.stopCountdown();\n emit(this, 'kt-toast-close');\n }\n\n override render(): TemplateResult {\n const meta = META[this.variant];\n const showCountdown = this.duration > 0;\n\n return html`<div\n part=\"base\"\n class=\"toast\"\n role=${this.variant === 'error' ? 'alert' : 'status'}\n aria-live=${this.variant === 'error' ? 'assertive' : 'polite'}\n >\n <div class=\"body\">\n <span class=\"icon\"><kt-icon name=${meta.icon} size=\"24\"></kt-icon></span>\n <div class=\"content\">\n ${this.heading ? html`<div class=\"heading\">${this.heading}</div>` : nothing}\n ${this.description ? html`<div class=\"description\">${this.description}</div>` : nothing}\n </div>\n </div>\n\n ${\n this.dismissible\n ? html`<button\n part=\"close\"\n class=\"close\"\n aria-label=${strings().close}\n @click=${this.close}\n >\n <kt-icon name=\"x\" size=\"18\"></kt-icon>\n </button>`\n : nothing\n }\n ${\n showCountdown\n ? html`<div class=\"countdown\">\n <kt-progress-bar\n size=\"small\"\n variant=${meta.progress}\n striped\n animated\n .value=${this.remaining}\n .max=${this.duration}\n label=${strings().timeRemaining}\n ></kt-progress-bar>\n </div>`\n : nothing\n }\n </div>`;\n }\n}\n\ndefineElement('kt-toast', KtToast);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-toast': KtToast;\n }\n}\n"],"names":["META","TICK_MS","KtToast","KtElement","css","emit","meta","showCountdown","html","nothing","strings","__decorateClass","state","property","defineElement"],"mappings":";;;;;;;;;;;;AAeA,MAAMA,IAA4C;AAAA,EAChD,SAAS,EAAE,MAAM,gBAAgB,UAAU,UAAA;AAAA,EAC3C,aAAa,EAAE,MAAM,QAAQ,UAAU,OAAA;AAAA,EACvC,SAAS,EAAE,MAAM,kBAAkB,UAAU,UAAA;AAAA,EAC7C,OAAO,EAAE,MAAM,gBAAgB,UAAU,SAAA;AAC3C,GAGMC,IAAU;AAgBT,MAAMC,UAAgBC,EAAU;AAAA,EAAhC,cAAA;AAAA,UAAA,GAAA,SAAA,GA+HL,KAAQ,YAAY,GAGpB,KAAA,UAA0B,eAS1B,KAAA,UAAU,IAGV,KAAA,cAAc,IAGd,KAAA,cAAc,IAOd,KA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GAjI9BX,EAkIX,WAAA,SAAA;AASAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA1IfX,EA2IX,WAAA,SAAA;AAGAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA7IfX,EA8IX,WAAA,aAAA;AAGAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAhJhBX,EAiJX,WAAA,aAAA;AAOAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAvJfX,EAwJX,WAAA,UAAA;AAsGFY,EAAc,YAAYZ,CAAO;"}
|
|
1
|
+
{"version":3,"file":"kt-toast.js","sources":["../../../../src/components/feedback/kt-toast/kt-toast.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { emit } from '#internal/events';\nimport { strings } from '#internal/strings';\nimport '../../core/kt-icon/kt-icon.js';\nimport '../kt-progress-bar/kt-progress-bar.js';\n\nexport type KtToastVariant = 'success' | 'information' | 'warning' | 'error';\n\ninterface VariantMeta {\n readonly icon: string;\n readonly progress: 'success' | 'info' | 'warning' | 'danger';\n}\n\nconst META: Record<KtToastVariant, VariantMeta> = {\n success: { icon: 'circle-check', progress: 'success' },\n information: { icon: 'info', progress: 'info' },\n warning: { icon: 'triangle-alert', progress: 'warning' },\n error: { icon: 'circle-alert', progress: 'danger' },\n};\n\n/** Countdown refresh interval. 50ms is smooth without being a busy loop. */\nconst TICK_MS = 50;\n\n/**\n * A transient notification.\n *\n * The only element in Kanto with a real shadow, and the only one that blurs\n * what is behind it: a toast floats above the page, so it has to say so.\n *\n * @element kt-toast\n *\n * @csspart base - The toast surface.\n * @csspart close - The dismiss button.\n *\n * @fires kt-toast-close - The toast asked to be removed, by timeout or by the\n * dismiss button. `<kt-toast-container>` listens for this.\n */\nexport class KtToast extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n }\n\n .toast {\n position: relative;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: var(--gap-form);\n max-width: 480px;\n padding: var(--padding-form);\n overflow: hidden;\n color: var(--text-body);\n background: var(--surface-card);\n border: var(--border-width) solid color-mix(in srgb, var(--color-white) 10%, transparent);\n border-radius: var(--border-radius);\n box-shadow: var(--shadow-toast);\n backdrop-filter: blur(10px);\n }\n\n /* A wash of the variant's hue over the card surface, rather than a\n solid fill: the text stays on a neutral background and keeps its\n contrast. */\n :host([variant='success']) .toast {\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, var(--color-success-base) 25%, transparent),\n color-mix(in srgb, var(--color-success-base) 15%, transparent)\n ),\n var(--surface-card);\n }\n :host([variant='information']) .toast {\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, var(--color-info-base) 25%, transparent),\n color-mix(in srgb, var(--color-info-base) 15%, transparent)\n ),\n var(--surface-card);\n }\n :host([variant='warning']) .toast {\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, var(--color-warning-base) 25%, transparent),\n color-mix(in srgb, var(--color-warning-base) 15%, transparent)\n ),\n var(--surface-card);\n }\n :host([variant='error']) .toast {\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, var(--color-danger-base) 25%, transparent),\n color-mix(in srgb, var(--color-danger-base) 15%, transparent)\n ),\n var(--surface-card);\n }\n\n :host([variant='success']) .heading {\n color: var(--color-success-text);\n }\n :host([variant='information']) .heading {\n color: var(--color-info-text);\n }\n :host([variant='warning']) .heading {\n color: var(--color-warning-text);\n }\n :host([variant='error']) .heading {\n color: var(--color-danger-text);\n }\n\n :host([variant='success']) .icon {\n color: var(--color-success-text);\n }\n :host([variant='information']) .icon {\n color: var(--color-info-text);\n }\n :host([variant='warning']) .icon {\n color: var(--color-warning-text);\n }\n :host([variant='error']) .icon {\n color: var(--color-danger-text);\n }\n\n .body {\n display: flex;\n align-items: center;\n gap: var(--gap-form);\n }\n\n .icon {\n display: flex;\n align-items: center;\n }\n\n .content {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: var(--gap-element);\n }\n\n .heading {\n font: var(--font-normal-medium);\n }\n\n .description {\n font: var(--font-normal-regular);\n }\n\n .close {\n display: flex;\n align-items: center;\n padding: 4px;\n color: currentcolor;\n background: transparent;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n .close:focus-visible {\n outline: var(--outline-width) solid var(--color-primary-base);\n }\n\n .countdown {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n }\n `,\n ];\n\n private timer: ReturnType<typeof setInterval> | undefined;\n\n @state()\n private remaining = 0;\n\n @property({ type: String, reflect: true })\n variant: KtToastVariant = 'information';\n\n /**\n * The toast's title.\n *\n * Named `heading` because every element already has a `title`, and shadowing\n * it would turn the toast into its own tooltip.\n */\n @property({ type: String })\n heading = '';\n\n @property({ type: String })\n description = '';\n\n @property({ type: Boolean })\n dismissible = false;\n\n /**\n * Auto-dismiss after this many milliseconds, with a countdown bar. Zero\n * keeps the toast until something removes it.\n */\n @property({ type: Number })\n duration = 0;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.startCountdown();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.stopCountdown();\n }\n\n private startCountdown(): void {\n this.stopCountdown();\n if (this.duration <= 0) return;\n\n this.remaining = this.duration;\n this.tick();\n }\n\n /** Runs the countdown from whatever `remaining` currently is. */\n private tick(): void {\n this.timer = setInterval(() => {\n this.remaining -= TICK_MS;\n if (this.remaining > 0) return;\n\n this.stopCountdown();\n this.close();\n }, TICK_MS);\n }\n\n private stopCountdown(): void {\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n /** Pauses the countdown. The container calls this while the pointer is over the stack. */\n pause(): void {\n if (this.timer !== undefined) this.stopCountdown();\n }\n\n /** Resumes a paused countdown from where it stopped. */\n resume(): void {\n if (this.duration <= 0 || this.timer !== undefined || this.remaining <= 0) return;\n this.tick();\n }\n\n /** Asks to be removed. The container is what actually removes it. */\n close(): void {\n this.stopCountdown();\n emit(this, 'kt-toast-close');\n }\n\n override render(): TemplateResult {\n const meta = META[this.variant];\n const showCountdown = this.duration > 0;\n\n return html`<div\n part=\"base\"\n class=\"toast\"\n role=${this.variant === 'error' ? 'alert' : 'status'}\n aria-live=${this.variant === 'error' ? 'assertive' : 'polite'}\n >\n <div class=\"body\">\n <span class=\"icon\"><kt-icon name=${meta.icon} size=\"24\"></kt-icon></span>\n <div class=\"content\">\n ${this.heading ? html`<div class=\"heading\">${this.heading}</div>` : nothing}\n ${this.description ? html`<div class=\"description\">${this.description}</div>` : nothing}\n </div>\n </div>\n\n ${\n this.dismissible\n ? html`<button\n part=\"close\"\n class=\"close\"\n aria-label=${strings().close}\n @click=${this.close}\n >\n <kt-icon name=\"x\" size=\"18\"></kt-icon>\n </button>`\n : nothing\n }\n ${\n showCountdown\n ? html`<div class=\"countdown\">\n <kt-progress-bar\n size=\"small\"\n variant=${meta.progress}\n striped\n animated\n .value=${this.remaining}\n .max=${this.duration}\n label=${strings().timeRemaining}\n ></kt-progress-bar>\n </div>`\n : nothing\n }\n </div>`;\n }\n}\n\ndefineElement('kt-toast', KtToast);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-toast': KtToast;\n }\n}\n"],"names":["META","TICK_MS","KtToast","KtElement","css","emit","meta","showCountdown","html","nothing","strings","__decorateClass","state","property","defineElement"],"mappings":";;;;;;;;;;;;AAeA,MAAMA,IAA4C;AAAA,EAChD,SAAS,EAAE,MAAM,gBAAgB,UAAU,UAAA;AAAA,EAC3C,aAAa,EAAE,MAAM,QAAQ,UAAU,OAAA;AAAA,EACvC,SAAS,EAAE,MAAM,kBAAkB,UAAU,UAAA;AAAA,EAC7C,OAAO,EAAE,MAAM,gBAAgB,UAAU,SAAA;AAC3C,GAGMC,IAAU;AAgBT,MAAMC,UAAgBC,EAAU;AAAA,EAAhC,cAA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AK,QAAQ;AAAA,wBACZI,EAAA,EAAU,aAAa;AAAA;AAAA,sBAGnCD,CACN;AAAA;AAAA,EAEJ;AACF;AA7HUE,EAAA;AAAA,EADPC,EAAA;AAAM,GA9IIV,EA+IH,WAAA,WAAA;AAGRS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAjJ9BX,EAkJX,WAAA,SAAA;AASAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA1JfX,EA2JX,WAAA,SAAA;AAGAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA7JfX,EA8JX,WAAA,aAAA;AAGAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAhKhBX,EAiKX,WAAA,aAAA;AAOAS,EAAA;AAAA,EADCE,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAvKfX,EAwKX,WAAA,UAAA;AAsGFY,EAAc,YAAYZ,CAAO;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css as c, html as m } from "lit";
|
|
2
2
|
import { property as p } from "lit/decorators.js";
|
|
3
|
-
import { K as l, d } from "../../../chunks/kt-element-
|
|
3
|
+
import { K as l, d } from "../../../chunks/kt-element-Djx2JcGl.js";
|
|
4
4
|
import "../kt-toast/kt-toast.js";
|
|
5
5
|
var f = Object.defineProperty, h = (i, t, e, n) => {
|
|
6
6
|
for (var s = void 0, o = i.length - 1, a; o >= 0; o--)
|
|
@@ -27,13 +27,33 @@ export declare class KtTooltip extends KtElement {
|
|
|
27
27
|
private readonly descriptionId;
|
|
28
28
|
private description;
|
|
29
29
|
private visible;
|
|
30
|
+
private bubble;
|
|
30
31
|
text: string;
|
|
32
|
+
/**
|
|
33
|
+
* The side the bubble prefers. It takes the opposite one when this one has
|
|
34
|
+
* no room — "top" on a trigger at the top of the page shows below it.
|
|
35
|
+
*/
|
|
31
36
|
placement: KtTooltipPlacement;
|
|
37
|
+
/**
|
|
38
|
+
* Shows the bubble whatever the pointer and focus do — for a trigger that
|
|
39
|
+
* cannot take focus itself, like an icon beside a field, whose owner shows
|
|
40
|
+
* it while the field is focused.
|
|
41
|
+
*/
|
|
42
|
+
open: boolean;
|
|
32
43
|
/** Suppresses the tooltip without removing it from the markup. */
|
|
33
44
|
disabled: boolean;
|
|
34
45
|
connectedCallback(): void;
|
|
35
46
|
disconnectedCallback(): void;
|
|
36
47
|
willUpdate(changed: PropertyValues<this>): void;
|
|
48
|
+
/** Hovered, focused or held open — and something to say. */
|
|
49
|
+
private get shown();
|
|
50
|
+
updated(changed: PropertyValues): void;
|
|
51
|
+
/**
|
|
52
|
+
* Opens the bubble in the top layer, then places it: it has to be open to be
|
|
53
|
+
* measured. Where popovers are missing — a test DOM — it stays in place.
|
|
54
|
+
*/
|
|
55
|
+
private openBubble;
|
|
56
|
+
private closeBubble;
|
|
37
57
|
/**
|
|
38
58
|
* `aria-describedby` cannot reach across a shadow boundary: an id inside this
|
|
39
59
|
* element's shadow root is invisible to a trigger sitting in the light DOM.
|