xv-webcomponents 2.0.0-beta.2 → 2.0.0-beta.28
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 +3 -2
- package/dist/angular/index.d.ts +1 -1
- package/dist/angular/index.js +3 -4
- package/dist/angular/proxies.d.ts +60 -34
- package/dist/angular/proxies.js +51 -67
- package/dist/angular/web-components.module.d.ts +1 -1
- package/dist/angular/web-components.module.js +10 -13
- package/dist/cjs/{index-Cfa6bBQW.js → index-DaTpiyaU.js} +1 -1
- package/dist/cjs/{index-Cixkr3sz.js → index-Dwhgrew8.js} +15 -10
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{xv-accordion-v2_50.cjs.entry.js → xv-accordion-v2_49.cjs.entry.js} +1529 -147
- package/dist/cjs/xv-header-next.cjs.entry.js +2 -2
- package/dist/cjs/xv-mega-menu-next.cjs.entry.js +2 -2
- package/dist/cjs/xv-webcomponents.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +1 -2
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu.js +9 -8
- package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.css +129 -61
- package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.js +277 -78
- package/dist/collection/components/xv-table/xv-table-row/xv-table-row.css +138 -24
- package/dist/collection/components/xv-table/xv-table-row/xv-table-row.js +334 -168
- package/dist/collection/components/xv-table/xv-table.css +240 -99
- package/dist/collection/components/xv-table/xv-table.js +2056 -63
- package/dist/collection/components/xv-table/xv-table.model.js +10 -0
- package/dist/collection/components/xv-table/xv-table.utils.js +243 -0
- package/dist/collection/components/xv-tabs/xv-tab/xv-tab.js +1 -1
- package/dist/collection/components/xv-tag/xv-tag.js +1 -1
- package/dist/collection/components/xv-tag-combobox/xv-tag-combobox.js +2 -2
- package/dist/collection/components/xv-text-input/xv-text-input.js +2 -2
- package/dist/collection/components/xv-textarea/xv-textarea.js +2 -2
- package/dist/collection/components/xv-tile/xv-tile.js +2 -2
- package/dist/collection/components/xv-toggle/xv-toggle.js +1 -1
- package/dist/collection/components/xv-toggle-tip/xv-toggle-tip.js +1 -1
- package/dist/collection/components/xv-tooltip/xv-tooltip.js +2 -2
- package/dist/collection/utils/table-layout.js +130 -0
- package/dist/components/index.js +1 -1
- package/dist/components/p-B0kwaJ8n.js +1 -0
- package/dist/components/{p-CbVZCn2p.js → p-BEoh0dZI.js} +1 -1
- package/dist/components/{p-ZYJfCCwX.js → p-BaZ-srfu.js} +1 -1
- package/dist/components/{p-DyGMZIub.js → p-Bej2l-wN.js} +1 -1
- package/dist/components/{p-Ddx5DwV5.js → p-BfhvpeQh.js} +1 -1
- package/dist/components/{p-kQVUwJXZ.js → p-CSYnNMKb.js} +1 -1
- package/dist/components/{p-BNP2Lw34.js → p-CspyoLL9.js} +1 -1
- package/dist/components/p-CvgDDcjp.js +1 -0
- package/dist/components/{p-COoj5JkZ.js → p-D4FwGeDJ.js} +1 -1
- package/dist/components/p-DCvH_Br_.js +1 -0
- package/dist/components/{p-CEjlxnKY.js → p-DFe9Mtw_.js} +1 -1
- package/dist/components/{p-BRZwUlfE.js → p-DFtMwE-h.js} +1 -1
- package/dist/components/p-DIvi4fI3.js +1 -0
- package/dist/components/{p-DTwz9Fsh.js → p-DNRISLNf.js} +1 -1
- package/dist/components/p-DPnvoOYj.js +1 -0
- package/dist/components/{p-Dzz9jxLm.js → p-Dwbe941A.js} +1 -1
- package/dist/components/{p-CMAJWZsP.js → p-JClekcEh.js} +1 -1
- package/dist/components/{p-DtUNYh73.js → p-NoM9oIJn.js} +1 -1
- package/dist/components/{p-DlLBjhuH.js → p-XEk4dHG3.js} +1 -1
- package/dist/components/p-i7_81si-.js +1 -0
- package/dist/components/{p-BRYrLHiz.js → p-i82EFiq6.js} +1 -1
- package/dist/components/{p-BXB4D7j4.js → p-jD7nSJaM.js} +1 -1
- package/dist/components/xv-accordion-v2-item.js +1 -1
- package/dist/components/xv-accordion-v2.js +1 -1
- package/dist/components/xv-breadcrumbs-v2.js +1 -1
- package/dist/components/xv-button-group-v2.js +1 -1
- package/dist/components/xv-button-v2.js +1 -1
- package/dist/components/xv-card-v2.js +1 -1
- package/dist/components/xv-checkbox-v2.js +1 -1
- package/dist/components/xv-content-switcher-item-v2.js +1 -1
- package/dist/components/xv-content-switcher-v2.js +1 -1
- package/dist/components/xv-data-table-cell.js +1 -1
- package/dist/components/xv-data-table-collapse.js +1 -1
- package/dist/components/xv-data-table-row.js +1 -1
- package/dist/components/xv-data-table.js +2 -2
- package/dist/components/xv-date-picker.js +1 -1
- package/dist/components/xv-datepicker.js +1 -1
- package/dist/components/xv-dropdown-v2-item.js +1 -1
- package/dist/components/xv-dropdown-v2.js +1 -1
- package/dist/components/xv-file-uploader.js +1 -1
- package/dist/components/xv-footer.js +1 -1
- package/dist/components/xv-geo-map-v2.js +1 -1
- package/dist/components/xv-header-next.js +1 -1
- package/dist/components/xv-header.js +1 -1
- package/dist/components/xv-image-viewer.js +1 -1
- package/dist/components/xv-link-v2.js +1 -1
- package/dist/components/xv-loader-v2.js +1 -1
- package/dist/components/xv-login-modal.js +1 -1
- package/dist/components/xv-mega-menu-next.js +1 -1
- package/dist/components/xv-mega-menu.js +1 -1
- package/dist/components/xv-modal-v2.js +1 -1
- package/dist/components/xv-notification-v2.js +1 -1
- package/dist/components/xv-number-input-v2.js +1 -1
- package/dist/components/xv-overflow-menu-v2-item.js +1 -1
- package/dist/components/xv-overflow-menu-v2.js +1 -1
- package/dist/components/xv-pagination.js +1 -1
- package/dist/components/xv-progress-indicator-v2-item.js +1 -1
- package/dist/components/xv-progress-indicator-v2.js +1 -1
- package/dist/components/xv-radio-v2.js +1 -1
- package/dist/components/xv-slider-v2.js +1 -1
- package/dist/components/xv-tab-v2.js +1 -1
- package/dist/components/{xv-table-v2-row.d.ts → xv-table-cell.d.ts} +4 -4
- package/dist/components/xv-table-cell.js +1 -0
- package/dist/components/{xv-table-v2-cell.d.ts → xv-table-row.d.ts} +4 -4
- package/dist/components/xv-table-row.js +1 -0
- package/dist/components/{xv-table-v2.d.ts → xv-table.d.ts} +4 -4
- package/dist/components/xv-table.js +1 -0
- package/dist/components/xv-tabs-v2.js +1 -1
- package/dist/components/xv-tag-combobox.js +1 -1
- package/dist/components/xv-tag-v2.js +1 -1
- package/dist/components/xv-text-input-v2.js +1 -1
- package/dist/components/xv-textarea.js +1 -1
- package/dist/components/xv-tile.js +1 -1
- package/dist/components/xv-toggle-tip.js +1 -1
- package/dist/components/xv-toggle.js +1 -1
- package/dist/components/xv-tooltip-v2.js +1 -1
- package/dist/custom-elements.json +1765 -294
- package/dist/docs.json +2749 -443
- package/dist/esm/{index-B6cY-_U1.js → index-ClusqSO5.js} +1 -1
- package/dist/esm/{index-Bu8SrOeR.js → index-DJC3-dS3.js} +15 -10
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{xv-accordion-v2_50.entry.js → xv-accordion-v2_49.entry.js} +1527 -144
- package/dist/esm/xv-header-next.entry.js +2 -2
- package/dist/esm/xv-mega-menu-next.entry.js +2 -2
- package/dist/esm/xv-webcomponents.js +4 -4
- package/dist/react/components.d.ts +3 -4
- package/dist/react/components.js +3 -4
- package/dist/react/{xv-table-v2-expand.d.ts → xv-table-cell.d.ts} +3 -3
- package/dist/react/xv-table-cell.js +14 -0
- package/dist/react/{xv-table-v2.d.ts → xv-table-row.d.ts} +3 -3
- package/dist/react/{xv-table-v2.js → xv-table-row.js} +5 -5
- package/dist/react/xv-table.d.ts +18 -0
- package/dist/react/xv-table.js +22 -0
- package/dist/types/components/xv-table/xv-table-cell/xv-table-cell.d.ts +43 -8
- package/dist/types/components/xv-table/xv-table-row/xv-table-row.d.ts +57 -18
- package/dist/types/components/xv-table/xv-table.d.ts +298 -9
- package/dist/types/components/xv-table/xv-table.model.d.ts +78 -0
- package/dist/types/components/xv-table/xv-table.utils.d.ts +47 -0
- package/dist/types/components.d.ts +899 -118
- package/dist/types/stencil-public-runtime.d.ts +61 -55
- package/dist/types/utils/table-layout.d.ts +7 -0
- package/dist/vscode-data.json +347 -56
- package/dist/xv-webcomponents/index.esm.js +1 -1
- package/dist/xv-webcomponents/{p-1ffb0b4f.entry.js → p-0c30d09f.entry.js} +1 -1
- package/dist/xv-webcomponents/{p-eb9d7750.entry.js → p-6b58979e.entry.js} +2 -2
- package/dist/xv-webcomponents/{p-Bu8SrOeR.js → p-DJC3-dS3.js} +2 -2
- package/dist/xv-webcomponents/{p-DB4KqDJz.js → p-DSFVdw3w.js} +1 -1
- package/dist/xv-webcomponents/{p-d4d26ff2.entry.js → p-c4173686.entry.js} +1 -1
- package/dist/xv-webcomponents/xv-webcomponents.esm.js +1 -1
- package/package.json +139 -139
- package/dist/collection/components/xv-table/_vars.js +0 -2
- package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.css +0 -58
- package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.js +0 -75
- package/dist/components/p-CHtssNO9.js +0 -1
- package/dist/components/p-CILNPUHH.js +0 -1
- package/dist/components/p-DVZ2BlIP.js +0 -1
- package/dist/components/p-bdaoJ1tx.js +0 -1
- package/dist/components/xv-table-v2-cell.js +0 -1
- package/dist/components/xv-table-v2-expand.d.ts +0 -11
- package/dist/components/xv-table-v2-expand.js +0 -1
- package/dist/components/xv-table-v2-row.js +0 -1
- package/dist/components/xv-table-v2.js +0 -1
- package/dist/react/xv-table-v2-cell.d.ts +0 -12
- package/dist/react/xv-table-v2-cell.js +0 -14
- package/dist/react/xv-table-v2-expand.js +0 -14
- package/dist/react/xv-table-v2-row.d.ts +0 -13
- package/dist/react/xv-table-v2-row.js +0 -17
- package/dist/types/components/xv-table/_vars.d.ts +0 -15
- package/dist/types/components/xv-table/xv-table-expand/xv-table-expand.d.ts +0 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const XV_TABLE_TAG = 'xv-table';
|
|
2
|
+
export const XV_TABLE_ROW_TAG = 'xv-table-row';
|
|
3
|
+
export const XV_TABLE_CELL_TAG = 'xv-table-cell';
|
|
4
|
+
export const XV_TABLE_LAYOUT_VERSION = 1;
|
|
5
|
+
/** The floor a resize drag may not cross, when the column names no minWidth. */
|
|
6
|
+
export const XV_TABLE_MIN_COLUMN_WIDTH = 64;
|
|
7
|
+
/** Per visible column, the width below which the table scrolls instead of squeezing. */
|
|
8
|
+
export const XV_TABLE_SCROLL_COLUMN_WIDTH = 120;
|
|
9
|
+
export const XV_TABLE_CONTROL_WIDTH = 48;
|
|
10
|
+
export const XV_TABLE_DEFAULT_PAGE_SIZES = [10, 20, 30, 40, 50, 100];
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { XV_SORT_DIR } from "../../types/enum";
|
|
2
|
+
import { XV_TABLE_DEFAULT_PAGE_SIZES, XV_TABLE_LAYOUT_VERSION, XV_TABLE_MIN_COLUMN_WIDTH, XV_TABLE_SCROLL_COLUMN_WIDTH, } from "./xv-table.model";
|
|
3
|
+
const ORDER_BY = /^(asc|desc)\((.+)\)$/;
|
|
4
|
+
/** Array and object props accept their JSON string form so they stay settable from plain markup. */
|
|
5
|
+
export const parseProp = (value, fallback) => {
|
|
6
|
+
if (typeof value !== 'string')
|
|
7
|
+
return value !== null && value !== void 0 ? value : fallback;
|
|
8
|
+
if (!value.trim())
|
|
9
|
+
return fallback;
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(value);
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return fallback;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const parsePageSizes = (value) => {
|
|
18
|
+
const parsed = typeof value === 'string' && value.includes(',')
|
|
19
|
+
? value.split(',').map(part => Number(part.trim()))
|
|
20
|
+
: parseProp(value, XV_TABLE_DEFAULT_PAGE_SIZES);
|
|
21
|
+
const sizes = (parsed || []).filter(size => Number.isFinite(size) && size > 0);
|
|
22
|
+
return sizes.length ? sizes : XV_TABLE_DEFAULT_PAGE_SIZES;
|
|
23
|
+
};
|
|
24
|
+
export const parseSortBy = (value) => {
|
|
25
|
+
if (!value)
|
|
26
|
+
return null;
|
|
27
|
+
if (typeof value !== 'string') {
|
|
28
|
+
return value.name ? { name: value.name, direction: value.direction || XV_SORT_DIR.ASC } : null;
|
|
29
|
+
}
|
|
30
|
+
const match = ORDER_BY.exec(value.trim());
|
|
31
|
+
if (!match)
|
|
32
|
+
return null;
|
|
33
|
+
return { name: match[2], direction: match[1] };
|
|
34
|
+
};
|
|
35
|
+
/** The `asc(field)` shape ListStateService already speaks, so an Angular binding needs no adapter. */
|
|
36
|
+
export const formatSortBy = (sort) => sort ? `${sort.direction}(${sort.name})` : '';
|
|
37
|
+
export const nextSortDirection = (current) => current === XV_SORT_DIR.ASC ? XV_SORT_DIR.DESC : XV_SORT_DIR.ASC;
|
|
38
|
+
export const sortName = (column) => column.sortName || column.id;
|
|
39
|
+
export const cellValue = (row, column) => {
|
|
40
|
+
if (typeof column.value === 'function')
|
|
41
|
+
return column.value(row);
|
|
42
|
+
const key = column.value || column.id;
|
|
43
|
+
return row === null || row === void 0 ? void 0 : row[key];
|
|
44
|
+
};
|
|
45
|
+
const isEmpty = (value) => value === null || value === undefined || value === '';
|
|
46
|
+
// Only a date-shaped string is read as a date: an article number must not sort as a year.
|
|
47
|
+
const DATE_LIKE = /^\d{4}-\d{2}-\d{2}([T ]|$)|^\d{1,2}[./-]\d{1,2}[./-]\d{2,4}$/;
|
|
48
|
+
const toComparable = (value) => {
|
|
49
|
+
if (value instanceof Date)
|
|
50
|
+
return value.getTime();
|
|
51
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
52
|
+
return value;
|
|
53
|
+
const text = String(value);
|
|
54
|
+
const asDate = DATE_LIKE.test(text.trim()) ? Date.parse(text) : NaN;
|
|
55
|
+
return Number.isNaN(asDate) ? text : asDate;
|
|
56
|
+
};
|
|
57
|
+
/** Empty values sort last in both directions — a blank cell is not "smallest", it is missing. */
|
|
58
|
+
export const compareValues = (a, b, locale) => {
|
|
59
|
+
if (isEmpty(a) && isEmpty(b))
|
|
60
|
+
return 0;
|
|
61
|
+
if (isEmpty(a))
|
|
62
|
+
return 1;
|
|
63
|
+
if (isEmpty(b))
|
|
64
|
+
return -1;
|
|
65
|
+
if (typeof a === 'number' && typeof b === 'number')
|
|
66
|
+
return a - b;
|
|
67
|
+
const left = toComparable(a);
|
|
68
|
+
const right = toComparable(b);
|
|
69
|
+
if (typeof left === 'string' || typeof right === 'string') {
|
|
70
|
+
return String(left).localeCompare(String(right), locale, { numeric: true, sensitivity: 'base' });
|
|
71
|
+
}
|
|
72
|
+
return Number(left) - Number(right);
|
|
73
|
+
};
|
|
74
|
+
export const sortRows = (rows, column, direction, locale) => {
|
|
75
|
+
if (!column || direction === XV_SORT_DIR.NONE)
|
|
76
|
+
return rows;
|
|
77
|
+
const factor = direction === XV_SORT_DIR.DESC ? -1 : 1;
|
|
78
|
+
// Read each cell once rather than four times per comparison.
|
|
79
|
+
const decorated = rows.map(row => ({ row, key: cellValue(row, column) }));
|
|
80
|
+
decorated.sort((a, b) => {
|
|
81
|
+
const result = compareValues(a.key, b.key, locale);
|
|
82
|
+
// Empty always trails, so it must not be flipped by a descending sort.
|
|
83
|
+
if (isEmpty(a.key) !== isEmpty(b.key))
|
|
84
|
+
return result;
|
|
85
|
+
return result * factor;
|
|
86
|
+
});
|
|
87
|
+
return decorated.map(item => item.row);
|
|
88
|
+
};
|
|
89
|
+
export const totalPages = (total, pageSize) => Math.ceil((total || 0) / (pageSize || 10)) || 1;
|
|
90
|
+
export const clampPage = (page, pages) => Math.min(Math.max(page || 1, 1), Math.max(pages, 1));
|
|
91
|
+
export const pageSlice = (rows, page, pageSize) => {
|
|
92
|
+
const size = pageSize || 10;
|
|
93
|
+
const start = (clampPage(page, totalPages(rows.length, size)) - 1) * size;
|
|
94
|
+
return rows.slice(start, start + size);
|
|
95
|
+
};
|
|
96
|
+
export const visibleColumns = (columns) => columns.filter(column => !column.hidden);
|
|
97
|
+
export const hideableColumns = (columns) => columns.filter(column => column.hideable);
|
|
98
|
+
/** A column may narrow a table-level switch, never widen it. */
|
|
99
|
+
export const columnAllows = (column, table, key) => { var _a; return table && ((_a = column[key]) !== null && _a !== void 0 ? _a : true); };
|
|
100
|
+
export const clampWidth = (width, column) => {
|
|
101
|
+
const min = column.minWidth || XV_TABLE_MIN_COLUMN_WIDTH;
|
|
102
|
+
const max = column.maxWidth || Number.MAX_SAFE_INTEGER;
|
|
103
|
+
return Math.round(Math.min(Math.max(width, min), max));
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* What the rigid parts of the table actually need. A pixel column needs its width; a percentage
|
|
107
|
+
* column squeezes by definition and asks for nothing; a column that named no width gets the
|
|
108
|
+
* scroll-width guess. Guessing for all of them made a table of narrow columns scroll for nothing.
|
|
109
|
+
*/
|
|
110
|
+
export const tableMinWidth = (columns, minWidth, controls = 0) => {
|
|
111
|
+
if (minWidth)
|
|
112
|
+
return minWidth + controls;
|
|
113
|
+
const declared = visibleColumns(columns).reduce((total, column) => {
|
|
114
|
+
if (typeof column.width === 'number')
|
|
115
|
+
return total + column.width;
|
|
116
|
+
return column.width ? total : total + XV_TABLE_SCROLL_COLUMN_WIDTH;
|
|
117
|
+
}, 0);
|
|
118
|
+
return declared + controls;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The grid track list. Resize rewrites this one string on the host, which is a single DOM write
|
|
122
|
+
* per pointermove — a colgroup would need one per `<col>`. One track per control column: a grip
|
|
123
|
+
* and a checkbox are separate cells, so they need separate tracks.
|
|
124
|
+
*/
|
|
125
|
+
export const buildColumnTracks = (columns, leading = [], trailing = []) => {
|
|
126
|
+
const shown = visibleColumns(columns);
|
|
127
|
+
// `table-layout: fixed`, which is what these tables were written against: while some column left
|
|
128
|
+
// its width open, a declared width is exact and the open ones take what is left. Once every
|
|
129
|
+
// column has named a width, the widths also become proportions and the table scales up to fit —
|
|
130
|
+
// but never below what was declared, so a narrow column keeps the room its content needs.
|
|
131
|
+
const proportional = shown.length > 0 && shown.every(column => !!column.width);
|
|
132
|
+
return [
|
|
133
|
+
...leading.map(width => `${width}px`),
|
|
134
|
+
// No space inside minmax(): the track list is indexed as an array during a resize drag.
|
|
135
|
+
...shown.map(column => {
|
|
136
|
+
if (!column.width)
|
|
137
|
+
return `minmax(${column.minWidth || XV_TABLE_MIN_COLUMN_WIDTH}px,1fr)`;
|
|
138
|
+
if (typeof column.width === 'number') {
|
|
139
|
+
return proportional
|
|
140
|
+
? `minmax(${column.width}px,${column.width}fr)`
|
|
141
|
+
: `${column.width}px`;
|
|
142
|
+
}
|
|
143
|
+
// A percentage keeps its exact share of the table and squeezes with it, never forcing a scroll.
|
|
144
|
+
const percent = /^([0-9.]+)%$/.test(column.width);
|
|
145
|
+
return percent ? `minmax(0,${column.width})` : column.width;
|
|
146
|
+
}),
|
|
147
|
+
...trailing.map(width => `${width}px`),
|
|
148
|
+
];
|
|
149
|
+
};
|
|
150
|
+
export const buildColumnTemplate = (columns, leading = [], trailing = []) => buildColumnTracks(columns, leading, trailing).join(' ');
|
|
151
|
+
export const moveItem = (items, from, to) => {
|
|
152
|
+
const next = [...items];
|
|
153
|
+
next.splice(to, 0, next.splice(from, 1)[0]);
|
|
154
|
+
return next;
|
|
155
|
+
};
|
|
156
|
+
/** Hidden columns keep their absolute slot while the visible ones move around them. */
|
|
157
|
+
export const mergeVisibleOrder = (columns, ordered) => {
|
|
158
|
+
const queue = [...ordered];
|
|
159
|
+
return columns.map(column => (column.hidden ? column : queue.shift() || column));
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Only the deviations from the declared columns are stored. An untouched column follows the code,
|
|
163
|
+
* so a later default still reaches everyone who once dragged a column edge.
|
|
164
|
+
*/
|
|
165
|
+
export const diffLayout = (columns, declared) => {
|
|
166
|
+
const defaults = new Map(declared.map(column => [column.id, column]));
|
|
167
|
+
const order = columns.map(column => column.id);
|
|
168
|
+
const widths = {};
|
|
169
|
+
const hidden = {};
|
|
170
|
+
columns.forEach(column => {
|
|
171
|
+
const base = defaults.get(column.id);
|
|
172
|
+
// Only a resize writes a width, and a resize always writes pixels: a declared `25%` is not a
|
|
173
|
+
// deviation, and storing it would freeze the layout the next time the code changes.
|
|
174
|
+
if (typeof column.width === 'number' && column.width !== (base === null || base === void 0 ? void 0 : base.width)) {
|
|
175
|
+
widths[column.id] = column.width;
|
|
176
|
+
}
|
|
177
|
+
if (!!column.hidden !== !!(base === null || base === void 0 ? void 0 : base.hidden))
|
|
178
|
+
hidden[column.id] = !!column.hidden;
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
v: XV_TABLE_LAYOUT_VERSION,
|
|
182
|
+
order: order.join() === declared.map(column => column.id).join() ? [] : order,
|
|
183
|
+
widths,
|
|
184
|
+
hidden,
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
export const isLayoutChanged = (layout) => !!layout && (!!layout.order.length || !!Object.keys(layout.widths).length || !!Object.keys(layout.hidden).length);
|
|
188
|
+
/** Merges onto clones, so a stored width never writes back into the page's declared preset. */
|
|
189
|
+
export const applyLayout = (declared, layout) => {
|
|
190
|
+
const clones = declared.map(column => (Object.assign({}, column)));
|
|
191
|
+
if (!layout || layout.v !== XV_TABLE_LAYOUT_VERSION)
|
|
192
|
+
return clones;
|
|
193
|
+
const byId = new Map(clones.map(column => [column.id, column]));
|
|
194
|
+
const ordered = layout.order.map(id => byId.get(id)).filter(Boolean);
|
|
195
|
+
clones.forEach((column, index) => {
|
|
196
|
+
if (!ordered.includes(column))
|
|
197
|
+
ordered.splice(Math.min(index, ordered.length), 0, column);
|
|
198
|
+
});
|
|
199
|
+
ordered.forEach(column => {
|
|
200
|
+
const width = layout.widths[column.id];
|
|
201
|
+
if (width)
|
|
202
|
+
column.width = width;
|
|
203
|
+
const hidden = layout.hidden[column.id];
|
|
204
|
+
if (hidden !== undefined && column.hideable)
|
|
205
|
+
column.hidden = hidden;
|
|
206
|
+
});
|
|
207
|
+
return ordered;
|
|
208
|
+
};
|
|
209
|
+
export const formatCell = (value, column, locale) => {
|
|
210
|
+
if (isEmpty(value))
|
|
211
|
+
return '';
|
|
212
|
+
switch (column.format) {
|
|
213
|
+
case 'number':
|
|
214
|
+
return new Intl.NumberFormat(locale).format(Number(value));
|
|
215
|
+
case 'currency':
|
|
216
|
+
return new Intl.NumberFormat(locale, {
|
|
217
|
+
style: 'currency',
|
|
218
|
+
currency: column.formatArg || 'EUR',
|
|
219
|
+
}).format(Number(value));
|
|
220
|
+
case 'date': {
|
|
221
|
+
const date = value instanceof Date ? value : new Date(String(value));
|
|
222
|
+
return Number.isNaN(date.getTime()) ? String(value) : new Intl.DateTimeFormat(locale).format(date);
|
|
223
|
+
}
|
|
224
|
+
case 'period': {
|
|
225
|
+
const [start, end] = Array.isArray(value) ? value : [];
|
|
226
|
+
const part = (input, options) => {
|
|
227
|
+
if (isEmpty(input))
|
|
228
|
+
return '';
|
|
229
|
+
const date = input instanceof Date ? input : new Date(String(input));
|
|
230
|
+
return Number.isNaN(date.getTime()) ? '' : new Intl.DateTimeFormat(locale, options).format(date);
|
|
231
|
+
};
|
|
232
|
+
// A missing end leaves no dangling separator, and the year is only spelled once.
|
|
233
|
+
return [
|
|
234
|
+
part(start, { day: '2-digit', month: '2-digit' }),
|
|
235
|
+
part(end, { day: '2-digit', month: '2-digit', year: '2-digit' }),
|
|
236
|
+
].filter(Boolean).join(' - ');
|
|
237
|
+
}
|
|
238
|
+
case 'list':
|
|
239
|
+
return Array.isArray(value) ? value.join(column.formatArg || ', ') : String(value);
|
|
240
|
+
default:
|
|
241
|
+
return String(value);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
@@ -6,7 +6,7 @@ export class XvTab {
|
|
|
6
6
|
this.loading = false;
|
|
7
7
|
}
|
|
8
8
|
render() {
|
|
9
|
-
return (h(Host, { key: '
|
|
9
|
+
return (h(Host, { key: '7147f87058327e099ad257d3821447dac8e3affb', disabled: this.disabled, name: this.name }, this.loading ? h("xv-loader-v2", { size: SIZE_VAR.LG }) : h("slot", null)));
|
|
10
10
|
}
|
|
11
11
|
static get is() { return "xv-tab-v2"; }
|
|
12
12
|
static get encapsulation() { return "shadow"; }
|
|
@@ -13,7 +13,7 @@ export class XvTag {
|
|
|
13
13
|
this.closeClick.emit(e);
|
|
14
14
|
}
|
|
15
15
|
render() {
|
|
16
|
-
return (h(Host, { key: '
|
|
16
|
+
return (h(Host, { key: '138d2cd5c76589ffd98054c7af17905921725aab', style: { color: this.color, background: this.bg }, class: `xv-tag ${this.disabled ? 'disabled' : ''} ${this.size}` }, h("div", { key: 'd3fe0db007cf464d64a63ed907c60dc0fd61c19c', class: "xv-tag_content", part: "details-content" }, h("slot", { key: 'caaebab8bce651040ac5c3291ffa2668b04cac56' })), this.closeable && (h("button", { key: 'ab6790f6b80906dcf28aee7fc739e375ae774df4', onClick: this.closeHandler.bind(this), class: "xv-tag_close" }))));
|
|
17
17
|
}
|
|
18
18
|
static get is() { return "xv-tag-v2"; }
|
|
19
19
|
static get encapsulation() { return "shadow"; }
|
|
@@ -242,12 +242,12 @@ export class XvTagCombobox {
|
|
|
242
242
|
const ariaOwns = suggestionsVisible ? `${this.uid}-listbox` : undefined;
|
|
243
243
|
const activedesc = this.highlighted >= 0 ? this.optionId(this.highlighted) : undefined;
|
|
244
244
|
const message = resolveFieldMessage({ error: this.error, warning: this.warning, helper: this.helper });
|
|
245
|
-
return (h(Host, { key: '
|
|
245
|
+
return (h(Host, { key: '5351ddba9ec53411d14582d3e4c013000f560540', class: "xv-combobox", part: "root", size: this.size }, this.label && h("label", { key: '9072c85cbd926b16e08827dacccd4d7f0a86d411', class: "label" }, this.label), h("div", { key: 'd63f9438b385fc05b53f29be87d5e1cf77a02f88', class: {
|
|
246
246
|
'control': true,
|
|
247
247
|
'control--disabled': this.disabled,
|
|
248
248
|
'control--error': !!this.error,
|
|
249
249
|
'control--readonly': !!this.readonly,
|
|
250
|
-
}, onClick: () => this.blockClick() }, h("div", { key: '
|
|
250
|
+
}, onClick: () => this.blockClick() }, h("div", { key: 'e303fef8789d9f1df8a9febe667f8fa0d72f4aaa', class: "control-chips", role: "list" }, this.selected.map((s, i) => (h("xv-tag-v2", { role: "listitem", part: "chip", "data-value": s.value, size: this.COMPARE_TAG_SIZE[this.size], disabled: this.disabled, bg: (s === null || s === void 0 ? void 0 : s.bg) || 'var(--layer-accent-01, #F7F7F7)', color: (s === null || s === void 0 ? void 0 : s.color) || 'var(--text-primary, #333)', closeable: !this.readonly, onCloseClick: ({ detail }) => this.removeTag(i, detail) }, s.label))), h("input", { key: '08ec28c65696a36238aa4f2c7f9ba2a89c34e31c', ref: (el) => (this.inputEl = el), class: "control-input", readonly: this.readonly, placeholder: this.selected.length ? '' : this.placeholder, value: this.inputValue, onInput: (e) => this.onInput(e), onKeyDown: (e) => this.onKeyDown(e), onFocus: () => { this.onOpen(); this.recomputeFiltered(); }, "aria-autocomplete": "list", "aria-expanded": this.open ? 'true' : 'false', "aria-controls": ariaOwns, "aria-activedescendant": activedesc, disabled: this.disabled })), this.loading && (h("span", { key: '434666b2391399635cfe9c18320e4e10c0b67abf', class: "control-loader", part: "loader", "aria-hidden": "true" }, h("xv-loader-v2", { key: '66ffdb3f446ee255495d05c9a456a868b208c52a', size: "sm", variant: "horizontal" })))), message && (h("p", { key: '47f10c7a1e7a0eb5f9cfef0a303a667278833673', class: { message: true, [message.level]: true } }, message.text)), suggestionsVisible && (h("ul", { key: 'cba3064999cd0fa1159bb1a5b0967633de6d2e6f', id: `${this.uid}-listbox`, class: "suggestions", role: "listbox", part: "listbox" }, this.filtered.map((opt, idx) => (h("li", { id: this.optionId(idx), class: { 'suggestions-opt': true, 'suggestions-opt--highlight': idx === this.highlighted }, role: "option", "aria-selected": idx === this.highlighted, onMouseEnter: () => this.onOptionMouseEnter(idx), onMouseDown: (ev) => ev.preventDefault(), onClick: () => this.selectOption(opt) }, h("div", { class: "suggestions-opt-content" }, opt.bg ? h("span", { class: "suggestions-opt-content--color", style: { background: opt.bg } }) : null, h("span", { class: "suggestions-opt-content--label" }, this.highlightLabel(opt.label).map((seg, i) => typeof seg === 'string' ? h("span", { key: i }, seg) : h("strong", { key: i }, seg.match)))))))))));
|
|
251
251
|
}
|
|
252
252
|
static get is() { return "xv-tag-combobox"; }
|
|
253
253
|
static get encapsulation() { return "shadow"; }
|
|
@@ -30,13 +30,13 @@ export class XvTextInput {
|
|
|
30
30
|
}
|
|
31
31
|
render() {
|
|
32
32
|
const message = resolveFieldMessage({ error: this.error, warning: this.warning, helper: this.helper });
|
|
33
|
-
return (h(Host, { key: '
|
|
33
|
+
return (h(Host, { key: '9aec75a885d16f416708047095897ac987b9e1ec', class: { disabled: !!this.disabled } }, h("label", { key: '4d6934a4208df6e858277366e7a74da9ec7c0ed3', class: "control" }, this.label && h("span", { key: '57c1974e09512b744aecc18dacfe7cae0bac6921', class: "control_label" }, this.label), h("div", { key: '5b0dd4d878da6e8bfc05a0f704954081e9b8058d', class: {
|
|
34
34
|
'control_input': true,
|
|
35
35
|
readonly: !!this.readonly,
|
|
36
36
|
[this.size]: true,
|
|
37
37
|
error: !!this.error,
|
|
38
38
|
warning: !!this.warning,
|
|
39
|
-
} }, h("input", { key: '
|
|
39
|
+
} }, h("input", { key: '0a5d8923bbcf54a551618557037a96b2e3c2166f', autocomplete: this.autocomplete, type: (this.type === 'password' && this.isPasswordVisible && 'text') || this.type, placeholder: this.placeholder, disabled: this.disabled, readonly: this.readonly, onInput: this.handleInput, name: this.name, value: this.value }), h("div", { key: 'a627fa606172a1e8d198b8dc8daadc280d39cfa2', class: "control_input__icons" }, this.loading && h("xv-loader-v2", { key: 'e2e9bb121daf4aedc173909545b80961db442002', size: SIZE_VAR.XS }), this.clearable && this.value && !this.loading && !this.disabled && !this.readonly && (h("button", { key: '45e514e856569d54bb4c98a8ac78a0aedc70ce37', type: "button", class: "status-icon clear", "aria-label": "Clear", onClick: this.handleClear }, "\u00D7")), !!this.error ? (h("span", { class: "status-icon error", "aria-hidden": "true" }, "!")) : !!this.warning ? (h("span", { class: "status-icon warning", "aria-hidden": "true" }, "\u26A0")) : null, this.type === 'password' && (h("button", { key: 'f7ae4b875d4a515e79fa1699d0fe3d4aa8b27586', onClick: this.togglePassword, disabled: this.disabled, class: "status-icon" }, h("svg", { key: '08bf622486f686fba2309004145c4c340faf8cd0', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 640 512", width: 16, height: 16 }, this.isPasswordVisible ? (h("path", { fill: "currentColor", d: "M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z" })) : (h("path", { fill: "currentColor", d: "M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z" })))))))), message && (h("p", { key: '2c1d43925fd56c86e47dfd88c4644b030639f81e', class: { message: true, [message.level]: true } }, message.text))));
|
|
40
40
|
}
|
|
41
41
|
static get is() { return "xv-text-input-v2"; }
|
|
42
42
|
static get encapsulation() { return "shadow"; }
|
|
@@ -22,12 +22,12 @@ export class XvTextarea {
|
|
|
22
22
|
}
|
|
23
23
|
render() {
|
|
24
24
|
const message = resolveFieldMessage({ error: this.error, warning: this.warning, helper: this.helper });
|
|
25
|
-
return (h(Host, { key: '
|
|
25
|
+
return (h(Host, { key: '8f8a6e5f1886e21e52ffc3e006c4d43b1de420eb', class: { disabled: !!this.disabled } }, h("label", { key: '2097cfb9d893772a0aa1e2aa3aeadd5484ebb48e', class: "control" }, (this.label || this.max) && (h("p", { key: '4a5ce1d5ad1d62ba1ab1249b2f15504eafc727af', class: "control_label" }, h("span", { key: 'f8344446dcf38978181473292c6a748d394538f6' }, this.label, this.info && h("xv-tooltip-v2", { key: 'bf23e43f1b7f0ea94ba9cb376c4893ea413ec5df', message: this.info })), this.max !== undefined && !this.counterHide && (h("span", { key: '7b377f47c6b426428fbaee01746415032b75d0b5', class: "control_label__count" }, this.value.length || 0, "/", this.max)))), h("div", { key: 'b7e1937e704f7493544443d159e7b3c1783a1e45', class: {
|
|
26
26
|
'control_input': true,
|
|
27
27
|
readonly: !!this.readonly,
|
|
28
28
|
error: !!this.error,
|
|
29
29
|
warning: this.warning !== undefined,
|
|
30
|
-
} }, h("textarea", { key: '
|
|
30
|
+
} }, h("textarea", { key: '4c09ca41ec313fca1f2df3e4e941d342d6121b6a', class: { 'no-resize': !!this.noResize }, name: this.name, rows: this.rows, value: this.value, maxLength: this.max, disabled: this.disabled, readOnly: this.readonly, placeholder: this.placeholder, onInput: this.onInput }), h("div", { key: '68dcba186158bf977193f908cf2a129452ba904e', class: "control_input__icons" }, this._renderIcon()))), message && (h("p", { key: '150534971f182c93c131fee2b00eae5cc78e7c30', class: { message: true, [message.level]: true } }, message.text))));
|
|
31
31
|
}
|
|
32
32
|
_renderIcon() {
|
|
33
33
|
if (this.loading)
|
|
@@ -29,7 +29,7 @@ export class XvTile {
|
|
|
29
29
|
this.checked = !this.checked;
|
|
30
30
|
}
|
|
31
31
|
render() {
|
|
32
|
-
return (h(Host, { key: '
|
|
32
|
+
return (h(Host, { key: '7a4262c881da376efbba73e6ecdeef845caefa0e', class: "xv-tile--host" }, h("label", { key: '9e3fcc2f59463c39d61352e84f89c6905b8b6754', class: {
|
|
33
33
|
[this.el.className]: !!this.el.className,
|
|
34
34
|
'xv-tile': true,
|
|
35
35
|
[`xv-tile--variant-${this.variant}`]: !!this.variant,
|
|
@@ -37,7 +37,7 @@ export class XvTile {
|
|
|
37
37
|
'xv-tile--disabled': !!this.disabled,
|
|
38
38
|
'selected': !!this.checked,
|
|
39
39
|
'xv-tile--error': !!this.error,
|
|
40
|
-
} }, h("div", { key: '
|
|
40
|
+
} }, h("div", { key: 'aacc76f7706cef6b3f7dc642e07f0aa0ed641368', class: "xv-tile_content" }, this.label && h("p", { key: 'c52856112766b1047581570dadd3ca3daa09e191', class: "xv-tile_content__title" }, this.label), h("slot", { key: 'c23faffc735f62a7007ad6ab25caad10278543d8' })), this.variant === 'selectable' && (h("div", { key: 'c9005b66ccb8feea162b43079762f7e2f8a7c5cf', class: "xv-tile_control" }, this.multiple ? (h("input", { type: "checkbox", disabled: this.disabled || this.readonly, readonly: this.readonly, onChange: this.handleChange, name: this.name, value: this.value, checked: this.checked })) : (h("input", { type: "radio", disabled: this.disabled || this.readonly, readonly: this.readonly, onChange: this.handleChange, name: this.name, value: this.value, checked: this.checked })))), (this.variant === 'clickable' || this.variant === 'expandable') && (h("div", { key: '08d6633d4a19ea03c761d18b20f164ae23002479', class: "xv-tile_footer" }, h("button", { key: 'ff242c00e2dadf564d146a02ac944d1bee7c7ec7', class: { 'xv-tile_footer__icon': true, [`icon--${this.variant}`]: true, open: this.checked } }))), h("div", { key: '27350c54f82cf8c78e49c04fc2b2b4fb0e4bbb96', class: { 'xv-tile_expandable': true, open: this.checked } }, h("slot", { key: '85f9a007a422ca5e7c06239d771cc8ede86a4e21', name: "expandable" })))));
|
|
41
41
|
}
|
|
42
42
|
static get is() { return "xv-tile"; }
|
|
43
43
|
static get originalStyleUrls() {
|
|
@@ -15,7 +15,7 @@ export class XvToggle {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
render() {
|
|
18
|
-
return (h(Host, { key: '
|
|
18
|
+
return (h(Host, { key: '752b686c9e361b4ca0a0ad48d61072a2c819373c', class: { 'xv-toggle': true, disabled: this.disabled, readonly: !!this.readonly, block: !!this.block } }, this.label && h("span", { key: 'c99e7d648d7886db04fbfaf16bedf40b982f6b72', class: "label" }, this.label), h("label", { key: 'ff15e59d5b7ace403030f997d8b1ddf3640f0bf6', class: "control" }, h("slot", { key: 'bea4d7593d2c7caca6b69e5cc219c1b8dbb55d09', name: "before" }), h("div", { key: '7ad81dc90a00339c8653605cfeb5468377be366b', class: "control_input" }, h("input", { key: 'ffbcaac266859de781476ba06e9e56069fd11ad4', type: "checkbox", readonly: this.readonly, name: this.name, value: this.value, checked: this.checked, disabled: this.disabled || this.readonly, onChange: this.onChange }), h("span", { key: 'd0b1915cd7ab776eb3b573802f5ee73ec417edde', class: "toggle" })), h("slot", { key: '4de504f5a68a747e097fed0260fe55b4dd93de57', name: "after" }))));
|
|
19
19
|
}
|
|
20
20
|
static get is() { return "xv-toggle"; }
|
|
21
21
|
static get encapsulation() { return "shadow"; }
|
|
@@ -67,7 +67,7 @@ export class XvToggleTip {
|
|
|
67
67
|
}
|
|
68
68
|
;
|
|
69
69
|
render() {
|
|
70
|
-
return (h(Host, { key: '
|
|
70
|
+
return (h(Host, { key: '355065995790b620e5ed8b5d561b2898f787ac15', class: "xv-toggle-tip" }, h("div", { key: 'ff20f44061ee280105d53176e5c508e0845df871', class: { 'trigger': true, 'trigger--block': this.block }, role: "button", tabindex: "0", "aria-expanded": this.open ? 'true' : 'false', "aria-controls": "popover", onClick: () => this.setPopover(!this.open), ref: (el) => (this.triggerEl = el) }, h("slot", { key: 'd407db9a0df2a9f90b628ed79d6c648eed2c2c70', name: "trigger" }, h("svg", { key: 'f82ed966ca4436d8dde8bf5c2b992466f541224f', class: "trigger_icon", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", width: 16, height: 16 }, h("path", { key: '6f5187fbf1560ebd7a3f2e529d3fdd15fa80fea0', fill: "currentColor", d: "M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-8 0 0-88c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l24 0 0 64-24 0zm40-144a32 32 0 1 0 0-64 32 32 0 1 0 0 64z" })))), h("div", { key: '76fc29909a52ce4701d71e3509c4ebe8d1d32ee2', class: { popover: true, autoSize: !!this.autoSize }, role: "tooltip", tabindex: "-1", ref: (el) => (this.popoverEl = el) }, h("div", { key: 'afabe0c85104f8c5e204677b53f5815f314a5039', class: "popover-tip", part: "tip", "data-popper-arrow": "" }), h("div", { key: 'f274e790046bcf6edc8123b2b0bcda895931772c', class: "popover-content" }, h("slot", { key: '8f28653ab605ae2eee5c7027532b024e914a8c13', name: "header" }), h("slot", { key: '1c26b3cb17db7fc9256fd42f7dcddb51eb182db5', name: "body" }), h("slot", { key: '3b537a669336579f2285784f469d4425d0f1cc31', name: "footer" })))));
|
|
71
71
|
}
|
|
72
72
|
disconnectedCallback() {
|
|
73
73
|
this.destroyPopper();
|
|
@@ -38,11 +38,11 @@ export class XvTooltip {
|
|
|
38
38
|
this.destroyTooltip();
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return (h(Host, { key: '
|
|
41
|
+
return (h(Host, { key: 'a6853dc450f6d063a702a1791297963f1530c003', role: "tooltip", class: {
|
|
42
42
|
'xv-tooltip-wrapper': true,
|
|
43
43
|
[`xv-tooltip-wrapper__block`]: !!this.block,
|
|
44
44
|
[`xv-tooltip-wrapper__dashed`]: !!this.dashed,
|
|
45
|
-
} }, h("slot", { key: '
|
|
45
|
+
} }, h("slot", { key: 'db5ea6da812b85930e8c74dc2ceaf59f8e6197b1' }, h("svg", { key: '7ac24beb22b912f77ec3535309019833f28fd375', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", width: 16, height: 16 }, h("path", { key: 'b86e5339a9af99e6011fceea6d8b77e89dcd0e19', fill: "currentColor", d: "M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-8 0 0-88c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l24 0 0 64-24 0zm40-144a32 32 0 1 0 0-64 32 32 0 1 0 0 64z" })))));
|
|
46
46
|
}
|
|
47
47
|
static get is() { return "xv-tooltip-v2"; }
|
|
48
48
|
static get originalStyleUrls() {
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const DB_NAME = 'xv-webcomponents';
|
|
2
|
+
const DB_VERSION = 1;
|
|
3
|
+
const STORE = 'table-layouts';
|
|
4
|
+
const MAX_AGE_MS = 180 * 24 * 60 * 60 * 1000;
|
|
5
|
+
const READ_TIMEOUT_MS = 1500;
|
|
6
|
+
let connection = null;
|
|
7
|
+
let pruned = false;
|
|
8
|
+
const layoutId = (owner, storageKey) => `${owner || 'anonymous'}:${storageKey}`;
|
|
9
|
+
const request = (req) => new Promise((resolve, reject) => {
|
|
10
|
+
req.onsuccess = () => resolve(req.result);
|
|
11
|
+
req.onerror = () => reject(req.error);
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Our own database on purpose. XvMarketplaceNG's origin already carries a Dexie database, and Dexie
|
|
15
|
+
* multiplies its version by ten — sharing a name loses the version race and kills the feature (MAR-15943).
|
|
16
|
+
*/
|
|
17
|
+
const openDb = () => {
|
|
18
|
+
if (connection)
|
|
19
|
+
return connection;
|
|
20
|
+
connection = new Promise(resolve => {
|
|
21
|
+
if (typeof indexedDB === 'undefined')
|
|
22
|
+
return resolve(null);
|
|
23
|
+
let req;
|
|
24
|
+
try {
|
|
25
|
+
req = indexedDB.open(DB_NAME, DB_VERSION);
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
return resolve(null);
|
|
29
|
+
}
|
|
30
|
+
req.onupgradeneeded = () => {
|
|
31
|
+
const db = req.result;
|
|
32
|
+
if (db.objectStoreNames.contains(STORE))
|
|
33
|
+
return;
|
|
34
|
+
const store = db.createObjectStore(STORE, { keyPath: 'id' });
|
|
35
|
+
store.createIndex('owner', 'owner');
|
|
36
|
+
store.createIndex('updatedAt', 'updatedAt');
|
|
37
|
+
};
|
|
38
|
+
req.onsuccess = () => resolve(req.result);
|
|
39
|
+
req.onerror = () => resolve(null);
|
|
40
|
+
req.onblocked = () => resolve(null);
|
|
41
|
+
});
|
|
42
|
+
return connection;
|
|
43
|
+
};
|
|
44
|
+
const store = async (mode) => {
|
|
45
|
+
const db = await openDb();
|
|
46
|
+
if (!db)
|
|
47
|
+
return null;
|
|
48
|
+
try {
|
|
49
|
+
return db.transaction(STORE, mode).objectStore(STORE);
|
|
50
|
+
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/** A cold database must not hold the first paint hostage — past this, the declared columns win. */
|
|
56
|
+
const withTimeout = (promise, fallback, ms = READ_TIMEOUT_MS) => Promise.race([promise, new Promise(resolve => setTimeout(() => resolve(fallback), ms))]);
|
|
57
|
+
export const readLayout = async (owner, storageKey) => {
|
|
58
|
+
if (!storageKey)
|
|
59
|
+
return null;
|
|
60
|
+
const read = (async () => {
|
|
61
|
+
var _a;
|
|
62
|
+
try {
|
|
63
|
+
const objectStore = await store('readonly');
|
|
64
|
+
if (!objectStore)
|
|
65
|
+
return null;
|
|
66
|
+
const record = await request(objectStore.get(layoutId(owner, storageKey)));
|
|
67
|
+
return (_a = record === null || record === void 0 ? void 0 : record.layout) !== null && _a !== void 0 ? _a : null;
|
|
68
|
+
}
|
|
69
|
+
catch (_b) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
const layout = await withTimeout(read, null);
|
|
74
|
+
void pruneLayouts();
|
|
75
|
+
return layout;
|
|
76
|
+
};
|
|
77
|
+
export const writeLayout = async (owner, storageKey, layout) => {
|
|
78
|
+
if (!storageKey)
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
const objectStore = await store('readwrite');
|
|
82
|
+
if (!objectStore)
|
|
83
|
+
return;
|
|
84
|
+
const record = {
|
|
85
|
+
id: layoutId(owner, storageKey),
|
|
86
|
+
owner: owner || 'anonymous',
|
|
87
|
+
storageKey,
|
|
88
|
+
layout,
|
|
89
|
+
updatedAt: Date.now(),
|
|
90
|
+
};
|
|
91
|
+
await request(objectStore.put(record));
|
|
92
|
+
}
|
|
93
|
+
catch (_a) {
|
|
94
|
+
// Private mode and a full quota both degrade to "this table does not remember".
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
export const deleteLayout = async (owner, storageKey) => {
|
|
98
|
+
if (!storageKey)
|
|
99
|
+
return;
|
|
100
|
+
try {
|
|
101
|
+
const objectStore = await store('readwrite');
|
|
102
|
+
if (!objectStore)
|
|
103
|
+
return;
|
|
104
|
+
await request(objectStore.delete(layoutId(owner, storageKey)));
|
|
105
|
+
}
|
|
106
|
+
catch (_a) {
|
|
107
|
+
// See writeLayout.
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
export const pruneLayouts = async () => {
|
|
111
|
+
if (pruned)
|
|
112
|
+
return;
|
|
113
|
+
pruned = true;
|
|
114
|
+
try {
|
|
115
|
+
const objectStore = await store('readwrite');
|
|
116
|
+
if (!objectStore)
|
|
117
|
+
return;
|
|
118
|
+
const range = IDBKeyRange.upperBound(Date.now() - MAX_AGE_MS);
|
|
119
|
+
const stale = await request(objectStore.index('updatedAt').getAll(range));
|
|
120
|
+
stale.forEach(record => objectStore.delete(record.id));
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
// See writeLayout.
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/** Test seam: drops the cached connection and the once-per-run prune guard. */
|
|
127
|
+
export const resetLayoutStore = () => {
|
|
128
|
+
connection = null;
|
|
129
|
+
pruned = false;
|
|
130
|
+
};
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{g as getAssetPath,r as render,s as setAssetPath,b as setNonce,d as setPlatformOptions,e as setTagTransformer,t as transformTag}from"./p-
|
|
1
|
+
export{g as getAssetPath,r as render,s as setAssetPath,b as setNonce,d as setPlatformOptions,e as setTagTransformer,t as transformTag}from"./p-CspyoLL9.js";function o(t,e,o){return(t||"")+(e?" "+e:"")+(o?" "+o:"")}const n=t=>{const{error:e,warning:o,helper:r}=t;return"string"==typeof e&&e?{level:"error",text:e}:"string"==typeof o&&o?{level:"warning",text:o}:"string"==typeof r&&r?{level:"helper",text:r}:null};function a(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16)))}const i=(t,e,o)=>Array.prototype.forEach.call(t,e,o),c=(t,e=500)=>{let o;return function(...r){clearTimeout(o),o=setTimeout((()=>{t.apply(this,r)}),e)}},l=(t,e,o)=>"string"==typeof o?(!t.hasAttribute(e)&&t.setAttribute(e,o),t):(o?!t.hasAttribute(e)&&t.setAttribute(e,""):t.hasAttribute(e)&&t.removeAttribute(e),t),u=()=>{try{const t=localStorage.getItem("metaNav");return t?JSON.parse(t):{}}catch(t){return console.warn("Could not parse metaNav from localStorage:",t),{}}},v=()=>{var t;return window.__xvWhitelabelOverride||(()=>{var t;if("undefined"==typeof document)return;const e="ApplicationContext=";return null===(t=document.cookie.split(";").map((t=>t.trim())).find((t=>t.startsWith(e))))||void 0===t?void 0:t.slice(19)})()||(null===(t=u())||void 0===t?void 0:t.WhitelabelName)||void 0},p=(t="")=>{var e;return`${null!==(e={"sitefinity-qa.crossvertise.com":"https://qa.crossvertise.com","www.crossvertise.com":"https://market.crossvertise.com","sitefinity-staging.crossvertise.com":"https://staging.crossvertise.com",localhost:"https://qa.crossvertise.com"}[window.location.hostname])&&void 0!==e?e:window.location.origin}${t}`},m=async(t,e)=>{const o=e||{},{awaitWl:r,raw:s}=o,n=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(o[r[s]]=t[r[s]])}return o}(o,["awaitWl","raw"]),a=r?await((t=2e3,e=100)=>{const o=v();return o?Promise.resolve(o):new Promise((o=>{const r=Date.now(),s=()=>{const n=v();return n?o(n):Date.now()-r>=t?o("Xv"):void setTimeout(s,e)};s()}))})():v()||"Xv",i=/^https?:\/\//i.test(t)?t:`${p()}/${t.replace(/^\//,"")}`,c=Object.assign(Object.assign({},s?{}:{"Content-Type":"application/json","Application-Context":a}),null==n?void 0:n.headers);return fetch(i,Object.assign(Object.assign({},n),{headers:c})).then((t=>{var e;if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return(null!==(e=t.headers.get("Content-Type"))&&void 0!==e?e:"").includes("application/json")?t.json():t.text()}))},f={get:(t,e)=>m(t,Object.assign(Object.assign({},e),{method:"GET"})),post:(t,e,o)=>m(t,Object.assign(Object.assign({},o),{method:"POST",body:void 0!==e?JSON.stringify(e):void 0})),put:(t,e,o)=>m(t,Object.assign(Object.assign({},o),{method:"PUT",body:void 0!==e?JSON.stringify(e):void 0})),patch:(t,e,o)=>m(t,Object.assign(Object.assign({},o),{method:"PATCH",body:void 0!==e?JSON.stringify(e):void 0})),delete:(t,e)=>m(t,Object.assign(Object.assign({},e),{method:"DELETE"}))};export{u as a,f as b,v as c,c as d,i as f,o as format,p as g,n as r,l as s,a as u}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as t,H as e,h as o,a,t as i}from"./p-CspyoLL9.js";import{X as r}from"./p-HjYAjHna.js";import{d as s}from"./p-DFtMwE-h.js";const l=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.columnId="",this.align="start",this.overflow="ellipsis",this.clampLines=2,this.tooltip="",this.width="",this.header=!1,this.sortable=!1,this.sortDirection="",this.hideable=!1,this.resizable=!1,this.reorderable=!1,this.reorderLabel="Drag to reorder"}get ariaSort(){return this.header&&this.sortable?this.sortDirection===r.ASC?"ascending":this.sortDirection===r.DESC?"descending":"none":null}render(){const t=o("div",{key:"eefd1609b456cdcc9e802c27e524613b64a9ce39",class:"content",part:"content",style:"clamp"===this.overflow?{"--xv-table-cell-clamp":`${this.clampLines}`}:void 0},o("slot",{key:"a00460b7e2fbf775c7607af68b078a4fcff70c11"}));return o(a,{key:"54976b9c9740d576bb4a81a15af65aa79a2f0888",role:this.header?"columnheader":"cell",part:"cell","aria-sort":this.ariaSort,tabindex:this.header&&this.sortable?0:null},this.header&&this.reorderable&&o("span",{key:"f443393d1ea62a0c94bfa59b77c377bf5fc04a66",class:"grip",part:"grip","aria-label":this.reorderLabel}),this.tooltip?o("xv-tooltip-v2",{part:"tooltip",dashed:!0,position:"top-start",message:this.tooltip},t):t,this.header&&this.sortable&&o("span",{key:"c26fa895c0a9a17cbe6c33c68f9e14b05781554e",class:"sort","aria-hidden":"true"}),this.header&&this.resizable&&o("span",{key:"37fa59799c363ed83f2dd0052b3203aa3bf01a6c",class:"resize",part:"resize","aria-hidden":"true"}))}get el(){return this}static get style(){return":host{--xv-table-cell-padding-x:var(--xv-table-padding-x, var(--spacing-05));--xv-table-cell-padding-y:var(--xv-table-padding-y, var(--spacing-03));--xv-table-cell-clamp:2;display:flex;align-items:center;box-sizing:border-box;min-width:0;padding-block:var(--xv-table-cell-padding-y);padding-inline:min(var(--xv-table-cell-padding-x), 25%);color:var(--text-primary);font-family:var(--ff-body);font-size:var(--fz-md);line-height:18px;letter-spacing:0.16px}:host([align=center]){justify-content:center;text-align:center}:host([align=end]){justify-content:flex-end;text-align:right}.content{min-width:0;max-width:100%}[part=tooltip]{min-width:0;max-width:100%}:host([overflow=ellipsis]) .content{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([overflow=ellipsis]) .content ::slotted(*){min-width:0;max-width:100%}:host([overflow=clamp]) .content{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--xv-table-cell-clamp);overflow:hidden}:host([overflow=clamp]) .content ::slotted(*){display:inline}:host([overflow=wrap]) .content{overflow:visible;white-space:normal}:host([header]){position:relative;gap:var(--spacing-02);font-weight:600}:host([header]) .content{flex:1}:host([header][align=end]) .sort{order:-1}:host([header][sortable]){cursor:pointer}:host([header][sortable]):hover{background:var(--layer-accent-hover-01)}:host([header][sortable]):focus-visible{outline:2px solid var(--focus);outline-offset:0}:host([header][sortable]):focus-visible{outline-offset:-2px}:host([header][sort-direction=asc]),:host([header][sort-direction=desc]){background:var(--layer-accent-active-01)}.sort{flex:none;width:8px;height:8px;border-right:1px solid currentColor;border-bottom:1px solid currentColor;opacity:0;transform:rotate(45deg) translate(-2px, -2px)}:host([header][sortable]:hover) .sort{opacity:0.5}:host([header][sort-direction=asc]) .sort,:host([header][sort-direction=desc]) .sort{opacity:1}:host([header][sort-direction=asc]) .sort{transform:rotate(-135deg) translate(-2px, -2px)}.grip{position:absolute;top:50%;left:4px;transform:translateY(-50%);width:8px;height:14px;opacity:0;cursor:grab;background-image:radial-gradient(currentColor 1px, transparent 1px);background-size:4px 4px}:host([header]:hover) .grip{opacity:0.5}:host(.drag-over){box-shadow:inset 2px 0 0 0 var(--interactive-01)}.resize{position:absolute;top:0;right:0;z-index:1;width:6px;height:100%;cursor:col-resize;touch-action:none}.resize:hover,.resize:active{background:var(--interactive-01)}:host([hidden]){display:none}"}},[257,"xv-table-cell",{columnId:[513,"column-id"],align:[513],overflow:[513],clampLines:[2,"clamp-lines"],tooltip:[1],width:[1],header:[516],sortable:[516],sortDirection:[513,"sort-direction"],hideable:[516],resizable:[516],reorderable:[516],reorderLabel:[1,"reorder-label"]}]);function n(){"undefined"!=typeof customElements&&["xv-table-cell","xv-tooltip-v2"].forEach((t=>{switch(t){case"xv-table-cell":customElements.get(i(t))||customElements.define(i(t),l);break;case"xv-tooltip-v2":customElements.get(i(t))||s()}}))}n();export{l as X,n as d}
|