udp-stencil-component-library 26.3.0-beta.22 → 26.3.0-beta.24
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/dist/cjs/ag-grid-base_63.cjs.entry.js +145 -3
- package/dist/collection/components/grid/new-grid/ag-grid-base.js +11 -3
- package/dist/collection/components/grid/new-grid/grid-header.js +5 -0
- package/dist/collection/components/grid/new-grid/gridFunctionRegistry.js +2 -0
- package/dist/collection/components/grid/new-grid/gridFunctions/agGridExcelExport.js +15 -0
- package/dist/collection/components/grid/new-grid/helperFunctions/udpColumnExcelStyles.js +112 -0
- package/dist/components/ag-grid-base2.js +1 -1
- package/dist/components/grid-header2.js +1 -1
- package/dist/docs.json +1 -1
- package/dist/esm/ag-grid-base_63.entry.js +145 -3
- package/dist/stencil-library/ag-grid-base_63.entry.js +1 -1
- package/dist/types/components/grid/new-grid/gridFunctions/agGridExcelExport.d.ts +9 -0
- package/dist/types/components/grid/new-grid/helperFunctions/udpColumnExcelStyles.d.ts +12 -0
- package/package.json +1 -1
|
@@ -226,6 +226,22 @@ class AgGridExport {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
class AgGridExcelExport {
|
|
230
|
+
constructor(fileName = 'export.xlsx') {
|
|
231
|
+
this.fileName = fileName;
|
|
232
|
+
}
|
|
233
|
+
init(gridApi) {
|
|
234
|
+
this.gridApi = gridApi;
|
|
235
|
+
}
|
|
236
|
+
onAction(name) {
|
|
237
|
+
if (name === 'agGridExcelExport') {
|
|
238
|
+
// The udp-col-* preset styling is applied via `excelStyles` in
|
|
239
|
+
// ag-grid-base (excelStyles is an @initial option, set at grid creation).
|
|
240
|
+
this.gridApi.exportDataAsExcel({ fileName: this.fileName });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
229
245
|
function getUserId() {
|
|
230
246
|
return sessionStorage.getItem('user-id');
|
|
231
247
|
}
|
|
@@ -1380,6 +1396,7 @@ class AgGridExpandCollapseAll {
|
|
|
1380
1396
|
|
|
1381
1397
|
const gridFunctionRegistry = {
|
|
1382
1398
|
agGridExport: AgGridExport,
|
|
1399
|
+
agGridExcelExport: AgGridExcelExport,
|
|
1383
1400
|
openSavedViews: SavedViews,
|
|
1384
1401
|
agGridSizeColumnsToFit: AgGridSizeColumnsToFit,
|
|
1385
1402
|
agGridAutoSizeColumns: AgGridAutoSizeColumns,
|
|
@@ -1551,6 +1568,119 @@ const dateTimeValueFormatter = params => {
|
|
|
1551
1568
|
return `${dateObject.getFullYear()}-${String(dateObject.getMonth() + 1).padStart(2, '0')}-${String(dateObject.getDate()).padStart(2, '0')} ${String(dateObject.getHours()).padStart(2, '0')}:${String(dateObject.getMinutes()).padStart(2, '0')}`;
|
|
1552
1569
|
};
|
|
1553
1570
|
|
|
1571
|
+
// UDP column style presets (see ag-grid-base.css). Each maps to a cell class
|
|
1572
|
+
// `udp-col-<name>` and a header class `udp-col-<name>-header`.
|
|
1573
|
+
const UDP_COL_PRESETS = [
|
|
1574
|
+
'brand',
|
|
1575
|
+
'danger',
|
|
1576
|
+
'important',
|
|
1577
|
+
'informative',
|
|
1578
|
+
'severe',
|
|
1579
|
+
'subtle',
|
|
1580
|
+
'success',
|
|
1581
|
+
'warning',
|
|
1582
|
+
];
|
|
1583
|
+
let probeCtx;
|
|
1584
|
+
function getProbeCtx() {
|
|
1585
|
+
var _a;
|
|
1586
|
+
if (probeCtx !== undefined)
|
|
1587
|
+
return probeCtx;
|
|
1588
|
+
const canvas = document.createElement('canvas');
|
|
1589
|
+
canvas.width = 1;
|
|
1590
|
+
canvas.height = 1;
|
|
1591
|
+
probeCtx = (_a = canvas.getContext('2d', { willReadFrequently: true })) !== null && _a !== void 0 ? _a : null;
|
|
1592
|
+
return probeCtx;
|
|
1593
|
+
}
|
|
1594
|
+
/** Paint `cssColor` over an opaque background and read the resulting RGB pixel. */
|
|
1595
|
+
function paintOver(ctx, cssColor, bg) {
|
|
1596
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
1597
|
+
ctx.fillStyle = `rgb(${bg[0]}, ${bg[1]}, ${bg[2]})`;
|
|
1598
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
1599
|
+
// If the browser can't parse cssColor, fillStyle keeps the bg we just set, so
|
|
1600
|
+
// the color resolves to the background (treated as "no tint" below).
|
|
1601
|
+
ctx.fillStyle = cssColor;
|
|
1602
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
1603
|
+
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
1604
|
+
return [r, g, b];
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Resolve any computed CSS color to an opaque `#RRGGBB`, flattened over white
|
|
1608
|
+
* (the Excel sheet background). Uses a canvas so it handles every serialization
|
|
1609
|
+
* `getComputedStyle` can return — `rgb()/rgba()`, `color(srgb …)`, `color-mix`,
|
|
1610
|
+
* named colors. Returns null when the color is fully transparent (no tint to
|
|
1611
|
+
* export) or the canvas is unavailable.
|
|
1612
|
+
*/
|
|
1613
|
+
function resolveColor(cssColor) {
|
|
1614
|
+
if (!cssColor)
|
|
1615
|
+
return null;
|
|
1616
|
+
const ctx = getProbeCtx();
|
|
1617
|
+
if (!ctx)
|
|
1618
|
+
return null;
|
|
1619
|
+
const overWhite = paintOver(ctx, cssColor, [255, 255, 255]);
|
|
1620
|
+
const overBlack = paintOver(ctx, cssColor, [0, 0, 0]);
|
|
1621
|
+
// Fully transparent ⇒ matches whatever it's painted over ⇒ nothing to export.
|
|
1622
|
+
if (overWhite[0] === 255 && overWhite[1] === 255 && overWhite[2] === 255 &&
|
|
1623
|
+
overBlack[0] === 0 && overBlack[1] === 0 && overBlack[2] === 0) {
|
|
1624
|
+
return null;
|
|
1625
|
+
}
|
|
1626
|
+
const hex = (n) => Math.max(0, Math.min(255, n)).toString(16).padStart(2, '0');
|
|
1627
|
+
return `#${hex(overWhite[0])}${hex(overWhite[1])}${hex(overWhite[2])}`.toUpperCase();
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Excel never sees the grid's CSS, so the udp-col-* column tints don't carry over
|
|
1631
|
+
* to a `.xlsx` by default. This resolves each preset to its *live themed* color
|
|
1632
|
+
* (honoring the active theme and any `color-mix`) and returns matching ExcelStyle
|
|
1633
|
+
* entries keyed by the same class name, so cellClass / headerClass tints export.
|
|
1634
|
+
*
|
|
1635
|
+
* Must run after the grid's stylesheet is in the DOM (ag-grid-base.css is global
|
|
1636
|
+
* since the component is `shadow: false`). Resolved at grid creation because
|
|
1637
|
+
* `excelStyles` is an `@initial` grid option and cannot be updated at runtime.
|
|
1638
|
+
*/
|
|
1639
|
+
function buildUdpPresetExcelStyles() {
|
|
1640
|
+
if (typeof document === 'undefined' || typeof getComputedStyle === 'undefined') {
|
|
1641
|
+
return [];
|
|
1642
|
+
}
|
|
1643
|
+
// Offscreen probes resolving the same global rules AG Grid's real cells/headers
|
|
1644
|
+
// do. Header text color lives on a nested `.ag-header-cell-text`.
|
|
1645
|
+
const host = document.createElement('div');
|
|
1646
|
+
host.setAttribute('aria-hidden', 'true');
|
|
1647
|
+
host.style.cssText = 'position:fixed;left:-9999px;top:0;visibility:hidden;pointer-events:none;';
|
|
1648
|
+
const cell = document.createElement('div');
|
|
1649
|
+
const headerCell = document.createElement('div');
|
|
1650
|
+
const headerText = document.createElement('span');
|
|
1651
|
+
headerText.className = 'ag-header-cell-text';
|
|
1652
|
+
headerCell.appendChild(headerText);
|
|
1653
|
+
host.appendChild(cell);
|
|
1654
|
+
host.appendChild(headerCell);
|
|
1655
|
+
document.body.appendChild(host);
|
|
1656
|
+
const styles = [];
|
|
1657
|
+
try {
|
|
1658
|
+
for (const name of UDP_COL_PRESETS) {
|
|
1659
|
+
cell.className = `ag-cell udp-col-${name}`;
|
|
1660
|
+
const cellStyle = getComputedStyle(cell);
|
|
1661
|
+
const cellBg = resolveColor(cellStyle.backgroundColor);
|
|
1662
|
+
if (cellBg) {
|
|
1663
|
+
const cellFg = resolveColor(cellStyle.color);
|
|
1664
|
+
styles.push(Object.assign({ id: `udp-col-${name}`, interior: { color: cellBg, pattern: 'Solid' } }, (cellFg ? { font: { color: cellFg } } : {})));
|
|
1665
|
+
}
|
|
1666
|
+
headerCell.className = `ag-header-cell udp-col-${name}-header`;
|
|
1667
|
+
const headerBg = resolveColor(getComputedStyle(headerCell).backgroundColor);
|
|
1668
|
+
if (headerBg) {
|
|
1669
|
+
const headerFg = resolveColor(getComputedStyle(headerText).color);
|
|
1670
|
+
styles.push({
|
|
1671
|
+
id: `udp-col-${name}-header`,
|
|
1672
|
+
interior: { color: headerBg, pattern: 'Solid' },
|
|
1673
|
+
font: Object.assign({ bold: true }, (headerFg ? { color: headerFg } : {})),
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
finally {
|
|
1679
|
+
host.remove();
|
|
1680
|
+
}
|
|
1681
|
+
return styles;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1554
1684
|
const agGridBaseCss = () => `.variant-dark{--udp-grid-column-header-bg:#F8F9FA;--udp-grid-column-header-bg-hover:#dce6f2;--udp-grid-column-header-text:var(--primary-color-dark)}.variant-light{--udp-grid-column-header-bg:#f2f4f5;--udp-grid-column-header-bg-hover:#eef3f9;--udp-grid-column-header-text:var(--primary-color-dark)}::view-transition-group(*){animation-duration:0.2s}.grid-wrapper{display:flex;flex-direction:column;height:100%}#myNewGrid{flex:1}.ag-cell.udp-col-brand{background-color:var(--colorBrandBackground2) !important;color:var(--colorBrandForeground2)}.ag-header-cell.udp-col-brand-header{background-color:var(--colorBrandBackground2) !important}.ag-header-cell.udp-col-brand-header .ag-header-cell-text{color:var(--colorBrandForeground2)}.ag-cell.udp-col-danger{background-color:var(--colorPaletteRedBackground1) !important;color:var(--colorPaletteRedForeground1)}.ag-header-cell.udp-col-danger-header{background-color:var(--colorPaletteRedBackground1) !important}.ag-header-cell.udp-col-danger-header .ag-header-cell-text{color:var(--colorPaletteRedForeground1)}.ag-cell.udp-col-important{background-color:color-mix(in srgb, var(--colorNeutralForeground1) 20%, transparent) !important;color:var(--colorNeutralForeground1)}.ag-header-cell.udp-col-important-header{background-color:color-mix(in srgb, var(--colorNeutralForeground1) 20%, transparent) !important}.ag-header-cell.udp-col-important-header .ag-header-cell-text{color:var(--colorNeutralForeground1)}.ag-cell.udp-col-informative{background-color:color-mix(in srgb, var(--colorPaletteBlueBackground2) 20%, transparent) !important;color:color-mix(in srgb, var(--colorPaletteBlueForeground2) 85%, transparent)}.ag-header-cell.udp-col-informative-header{background-color:color-mix(in srgb, var(--colorPaletteBlueBackground2) 20%, transparent) !important}.ag-header-cell.udp-col-informative-header .ag-header-cell-text{color:color-mix(in srgb, var(--colorPaletteBlueForeground2) 85%, transparent)}.ag-cell.udp-col-severe{background-color:var(--colorPaletteDarkOrangeBackground1) !important;color:var(--colorPaletteDarkOrangeForeground1)}.ag-header-cell.udp-col-severe-header{background-color:var(--colorPaletteDarkOrangeBackground1) !important}.ag-header-cell.udp-col-severe-header .ag-header-cell-text{color:var(--colorPaletteDarkOrangeForeground1)}.ag-cell.udp-col-subtle{background-color:var(--colorNeutralBackground1) !important;color:var(--colorNeutralForeground3)}.ag-header-cell.udp-col-subtle-header{background-color:var(--colorNeutralBackground1) !important}.ag-header-cell.udp-col-subtle-header .ag-header-cell-text{color:var(--colorNeutralForeground3)}.ag-cell.udp-col-success{background-color:var(--colorPaletteGreenBackground1) !important;color:var(--colorPaletteGreenForeground1)}.ag-header-cell.udp-col-success-header{background-color:var(--colorPaletteGreenBackground1) !important}.ag-header-cell.udp-col-success-header .ag-header-cell-text{color:var(--colorPaletteGreenForeground1)}.ag-cell.udp-col-warning{background-color:var(--colorPaletteYellowBackground1) !important;color:var(--colorPaletteYellowForeground2)}.ag-header-cell.udp-col-warning-header{background-color:var(--colorPaletteYellowBackground1) !important}.ag-header-cell.udp-col-warning-header .ag-header-cell-text{color:var(--colorPaletteYellowForeground2)}`;
|
|
1555
1685
|
|
|
1556
1686
|
const AgGridBase = class {
|
|
@@ -1670,7 +1800,7 @@ const AgGridBase = class {
|
|
|
1670
1800
|
agGridEnterpriseV33.LicenseManager.setLicenseKey('Using_this_{AG_Grid}_Enterprise_key_{AG-080613}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Univerus_Software_Inc}_is_granted_a_{Single_Application}_Developer_License_for_the_application_{MAIS_eRec}_only_for_{1}_Front-End_JavaScript_developer___All_Front-End_JavaScript_developers_working_on_{MAIS_eRec}_need_to_be_licensed___{MAIS_eRec}_has_not_been_granted_a_Deployment_License_Add-on___This_key_works_with_{AG_Grid}_Enterprise_versions_released_before_{28_June_2026}____[v3]_[01]_MTc4MjYwMTIwMDAwMA==5c7d1487ecb13b28e75415d34b7cf694');
|
|
1671
1801
|
}
|
|
1672
1802
|
componentDidLoad() {
|
|
1673
|
-
var _a, _b, _c, _d;
|
|
1803
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1674
1804
|
const gridOptions = Object.assign(Object.assign({ tooltipShowMode: 'whenTruncated', tooltipShowDelay: 500 }, this.gridOptions), { columnTypes: {
|
|
1675
1805
|
booleanChip: {
|
|
1676
1806
|
cellRenderer: 'iconRenderer',
|
|
@@ -1692,7 +1822,14 @@ const AgGridBase = class {
|
|
|
1692
1822
|
extendsDataType: 'boolean',
|
|
1693
1823
|
columnTypes: 'booleanChip',
|
|
1694
1824
|
},
|
|
1695
|
-
}, gridId: this.gridId, onGridReady: e => void this.onGridReady(e), theme: getAgGridTheme(),
|
|
1825
|
+
}, gridId: this.gridId, onGridReady: e => void this.onGridReady(e), theme: getAgGridTheme(),
|
|
1826
|
+
// Carry the udp-col-* column tints into Excel exports. excelStyles is an
|
|
1827
|
+
// @initial option (cannot be set at runtime), so it's resolved here at grid
|
|
1828
|
+
// creation. Consumer-provided excelStyles win over the generated presets.
|
|
1829
|
+
excelStyles: [
|
|
1830
|
+
...buildUdpPresetExcelStyles().filter(preset => { var _a, _b; return !((_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.excelStyles) !== null && _b !== void 0 ? _b : []).some(s => s.id === preset.id); }),
|
|
1831
|
+
...((_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.excelStyles) !== null && _b !== void 0 ? _b : []),
|
|
1832
|
+
], components: Object.assign({ actionsRenderer: statusRenderer.ActionsRenderer, avatarRenderer: AvatarRenderer, iconRenderer: statusRenderer.IconRenderer, imageRenderer: ImageRenderer, linkRenderer: LinkRenderer, statusRenderer: statusRenderer.StatusRenderer, subtitleRenderer: AgGridSubtitleCellRenderer }, (_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.components), domLayout: 'normal', defaultColDef: Object.assign(Object.assign({ cellDataType: false, sortable: true, filter: true, flex: 1, minWidth: 150, suppressHeaderMenuButton: true }, (_d = this.gridOptions) === null || _d === void 0 ? void 0 : _d.defaultColDef), { filterParams: Object.assign({ buttons: ['reset', 'apply'], closeOnApply: true, maxNumConditions: 10 }, (_f = (_e = this.gridOptions) === null || _e === void 0 ? void 0 : _e.defaultColDef) === null || _f === void 0 ? void 0 : _f.filterParams) }) });
|
|
1696
1833
|
agGridEnterpriseV33.createGrid(this.gridEl, gridOptions);
|
|
1697
1834
|
window.addEventListener('theme-changed', this.themeChangedHandler);
|
|
1698
1835
|
if (this.gridHeight) {
|
|
@@ -1743,7 +1880,7 @@ const AgGridBase = class {
|
|
|
1743
1880
|
this.updateGridContextValues();
|
|
1744
1881
|
}
|
|
1745
1882
|
render() {
|
|
1746
|
-
return (index.h("div", { key: '
|
|
1883
|
+
return (index.h("div", { key: 'd390a4e4472211df84c8431dce95448861bd7cf8', ref: el => (this.gridContainerEl = el) }, index.h("ghost-render", { key: '6598aa469fbd486c45a1251185e46e163254ca74' }, index.h("div", { key: '8b4a74033bcbfee121ab2108a4312b8a0feb651b' }, index.h("udp-dialog", { key: '8bace417eb116aff9cbae2e76d340ea478c02eb0' }), index.h("udp-list-item", { key: '02fa2c8ab83e5a9296178366517d8cfb28779745' }), index.h("hint-panel", { key: '6e29b193c52c292e2d6dac6b4e64025e027148bf' }), index.h("udp-side-sheet", { key: 'daa39be7c760daa21244b6d7ad57217503ca9ec2' }), index.h("udp-fluent-dialog", { key: '9a703f20309d94629f3bd0dfcada241a826fea82' }), index.h("udp-fluent-text", { key: '7ae20805172f8bc59bd7d3427421144eb13f6ded' }), index.h("udp-fluent-text-input", { key: '77a58d878d712e247cc7f1e835def85df325dd70' }), index.h("udp-fluent-switch", { key: '47b13c7be1563969da9cad7850b6a9bc5b7c4a45' }), index.h("udp-fluent-button", { key: '3f8b1d78694b7bee699f0800c1d31a61d78ebf97' }), index.h("udp-text", { key: 'eaab0e6b5949f42619cc171fdc7c5cb32abcb1d9' }), index.h("udp-search-input", { key: 'a44cb53fca08b1c9e829789501efb339a501d8f5' }), index.h("udp-fluent-avatar", { key: '6ba0c2bd921f244c6f9c70566714fd2cbe0c2e80' }), index.h("udp-fluent-icon-button", { key: '67aea24100272ef7ba9936afcdbd1cde8db5647e' }), index.h("udp-fluent-icon", { key: '665398531aaa7c8acc52ec16cbb736fb92c4fe22' }), index.h("udp-fluent-badge", { key: '3a08b41829ad68400d93da40c45c506a06e6099b' }))), index.h("grid-header", { key: '795ec194aecacf9d43fb731b7a1390b6faab1965', headerConfig: this.headerConfig, gridFunctions: this.gridFunctions, gridFunctionInstances: this.gridFunctionInstances, refreshKey: this.refreshKey, onHeaderAction: this.onHeaderAction }), index.h("div", { key: 'fdce74fba0821732e808b266f1a2ecb694254490', ref: el => (this.gridEl = el) })));
|
|
1747
1884
|
}
|
|
1748
1885
|
static get watchers() { return {
|
|
1749
1886
|
"gridFunctions": [{
|
|
@@ -1996,6 +2133,11 @@ const GridHeader = class {
|
|
|
1996
2133
|
startIconName: 'export',
|
|
1997
2134
|
onClick: () => this.action('agGridExport'),
|
|
1998
2135
|
},
|
|
2136
|
+
enabledFunctionNames.has('agGridExcelExport') && {
|
|
2137
|
+
text: 'Export to Excel',
|
|
2138
|
+
startIconName: 'table',
|
|
2139
|
+
onClick: () => this.action('agGridExcelExport'),
|
|
2140
|
+
},
|
|
1999
2141
|
].filter(Boolean);
|
|
2000
2142
|
const hasUdpExport = enabledFunctionNames.has('udpExport');
|
|
2001
2143
|
const hasExpandCollapse = enabledFunctionNames.has('agGridExpandCollapseAll');
|
|
@@ -11,6 +11,7 @@ import StatusRenderer from "../renderers/status-renderer";
|
|
|
11
11
|
import SubtitleRenderer from "../renderers/subtitle-cell-renderer";
|
|
12
12
|
import { configureUdpColumnMods } from "./helperFunctions/configureUdpColumnMods";
|
|
13
13
|
import { dateTimeValueFormatter } from "./helperFunctions/valueFormatters";
|
|
14
|
+
import { buildUdpPresetExcelStyles } from "./helperFunctions/udpColumnExcelStyles";
|
|
14
15
|
import { isEqual } from "lodash-es";
|
|
15
16
|
export class AgGridBase {
|
|
16
17
|
constructor() {
|
|
@@ -127,7 +128,7 @@ export class AgGridBase {
|
|
|
127
128
|
LicenseManager.setLicenseKey('Using_this_{AG_Grid}_Enterprise_key_{AG-080613}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Univerus_Software_Inc}_is_granted_a_{Single_Application}_Developer_License_for_the_application_{MAIS_eRec}_only_for_{1}_Front-End_JavaScript_developer___All_Front-End_JavaScript_developers_working_on_{MAIS_eRec}_need_to_be_licensed___{MAIS_eRec}_has_not_been_granted_a_Deployment_License_Add-on___This_key_works_with_{AG_Grid}_Enterprise_versions_released_before_{28_June_2026}____[v3]_[01]_MTc4MjYwMTIwMDAwMA==5c7d1487ecb13b28e75415d34b7cf694');
|
|
128
129
|
}
|
|
129
130
|
componentDidLoad() {
|
|
130
|
-
var _a, _b, _c, _d;
|
|
131
|
+
var _a, _b, _c, _d, _e, _f;
|
|
131
132
|
const gridOptions = Object.assign(Object.assign({ tooltipShowMode: 'whenTruncated', tooltipShowDelay: 500 }, this.gridOptions), { columnTypes: {
|
|
132
133
|
booleanChip: {
|
|
133
134
|
cellRenderer: 'iconRenderer',
|
|
@@ -149,7 +150,14 @@ export class AgGridBase {
|
|
|
149
150
|
extendsDataType: 'boolean',
|
|
150
151
|
columnTypes: 'booleanChip',
|
|
151
152
|
},
|
|
152
|
-
}, gridId: this.gridId, onGridReady: e => void this.onGridReady(e), theme: getAgGridTheme(),
|
|
153
|
+
}, gridId: this.gridId, onGridReady: e => void this.onGridReady(e), theme: getAgGridTheme(),
|
|
154
|
+
// Carry the udp-col-* column tints into Excel exports. excelStyles is an
|
|
155
|
+
// @initial option (cannot be set at runtime), so it's resolved here at grid
|
|
156
|
+
// creation. Consumer-provided excelStyles win over the generated presets.
|
|
157
|
+
excelStyles: [
|
|
158
|
+
...buildUdpPresetExcelStyles().filter(preset => { var _a, _b; return !((_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.excelStyles) !== null && _b !== void 0 ? _b : []).some(s => s.id === preset.id); }),
|
|
159
|
+
...((_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.excelStyles) !== null && _b !== void 0 ? _b : []),
|
|
160
|
+
], components: Object.assign({ actionsRenderer: ActionsRenderer, avatarRenderer: AvatarRenderer, iconRenderer: IconRenderer, imageRenderer: ImageRenderer, linkRenderer: LinkRenderer, statusRenderer: StatusRenderer, subtitleRenderer: SubtitleRenderer }, (_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.components), domLayout: 'normal', defaultColDef: Object.assign(Object.assign({ cellDataType: false, sortable: true, filter: true, flex: 1, minWidth: 150, suppressHeaderMenuButton: true }, (_d = this.gridOptions) === null || _d === void 0 ? void 0 : _d.defaultColDef), { filterParams: Object.assign({ buttons: ['reset', 'apply'], closeOnApply: true, maxNumConditions: 10 }, (_f = (_e = this.gridOptions) === null || _e === void 0 ? void 0 : _e.defaultColDef) === null || _f === void 0 ? void 0 : _f.filterParams) }) });
|
|
153
161
|
createGrid(this.gridEl, gridOptions);
|
|
154
162
|
window.addEventListener('theme-changed', this.themeChangedHandler);
|
|
155
163
|
if (this.gridHeight) {
|
|
@@ -200,7 +208,7 @@ export class AgGridBase {
|
|
|
200
208
|
this.updateGridContextValues();
|
|
201
209
|
}
|
|
202
210
|
render() {
|
|
203
|
-
return (h("div", { key: '
|
|
211
|
+
return (h("div", { key: 'd390a4e4472211df84c8431dce95448861bd7cf8', ref: el => (this.gridContainerEl = el) }, h("ghost-render", { key: '6598aa469fbd486c45a1251185e46e163254ca74' }, h("div", { key: '8b4a74033bcbfee121ab2108a4312b8a0feb651b' }, h("udp-dialog", { key: '8bace417eb116aff9cbae2e76d340ea478c02eb0' }), h("udp-list-item", { key: '02fa2c8ab83e5a9296178366517d8cfb28779745' }), h("hint-panel", { key: '6e29b193c52c292e2d6dac6b4e64025e027148bf' }), h("udp-side-sheet", { key: 'daa39be7c760daa21244b6d7ad57217503ca9ec2' }), h("udp-fluent-dialog", { key: '9a703f20309d94629f3bd0dfcada241a826fea82' }), h("udp-fluent-text", { key: '7ae20805172f8bc59bd7d3427421144eb13f6ded' }), h("udp-fluent-text-input", { key: '77a58d878d712e247cc7f1e835def85df325dd70' }), h("udp-fluent-switch", { key: '47b13c7be1563969da9cad7850b6a9bc5b7c4a45' }), h("udp-fluent-button", { key: '3f8b1d78694b7bee699f0800c1d31a61d78ebf97' }), h("udp-text", { key: 'eaab0e6b5949f42619cc171fdc7c5cb32abcb1d9' }), h("udp-search-input", { key: 'a44cb53fca08b1c9e829789501efb339a501d8f5' }), h("udp-fluent-avatar", { key: '6ba0c2bd921f244c6f9c70566714fd2cbe0c2e80' }), h("udp-fluent-icon-button", { key: '67aea24100272ef7ba9936afcdbd1cde8db5647e' }), h("udp-fluent-icon", { key: '665398531aaa7c8acc52ec16cbb736fb92c4fe22' }), h("udp-fluent-badge", { key: '3a08b41829ad68400d93da40c45c506a06e6099b' }))), h("grid-header", { key: '795ec194aecacf9d43fb731b7a1390b6faab1965', headerConfig: this.headerConfig, gridFunctions: this.gridFunctions, gridFunctionInstances: this.gridFunctionInstances, refreshKey: this.refreshKey, onHeaderAction: this.onHeaderAction }), h("div", { key: 'fdce74fba0821732e808b266f1a2ecb694254490', ref: el => (this.gridEl = el) })));
|
|
204
212
|
}
|
|
205
213
|
static get is() { return "ag-grid-base"; }
|
|
206
214
|
static get originalStyleUrls() {
|
|
@@ -80,6 +80,11 @@ export class GridHeader {
|
|
|
80
80
|
startIconName: 'export',
|
|
81
81
|
onClick: () => this.action('agGridExport'),
|
|
82
82
|
},
|
|
83
|
+
enabledFunctionNames.has('agGridExcelExport') && {
|
|
84
|
+
text: 'Export to Excel',
|
|
85
|
+
startIconName: 'table',
|
|
86
|
+
onClick: () => this.action('agGridExcelExport'),
|
|
87
|
+
},
|
|
83
88
|
].filter(Boolean);
|
|
84
89
|
const hasUdpExport = enabledFunctionNames.has('udpExport');
|
|
85
90
|
const hasExpandCollapse = enabledFunctionNames.has('agGridExpandCollapseAll');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgGridExport } from "./gridFunctions/agGridExport";
|
|
2
|
+
import { AgGridExcelExport } from "./gridFunctions/agGridExcelExport";
|
|
2
3
|
import { SavedViews } from "./gridFunctions/savedViews";
|
|
3
4
|
import { AgGridSizeColumnsToFit } from "./gridFunctions/agGridSizeColumnsToFit";
|
|
4
5
|
import { AgGridAutoSizeColumns } from "./gridFunctions/agGridAutoSizeColumns";
|
|
@@ -12,6 +13,7 @@ import { agGridRefreshData } from "./gridFunctions/agGridRefreshData";
|
|
|
12
13
|
import { AgGridExpandCollapseAll } from "./gridFunctions/agGridExpandCollapseAll";
|
|
13
14
|
export const gridFunctionRegistry = {
|
|
14
15
|
agGridExport: AgGridExport,
|
|
16
|
+
agGridExcelExport: AgGridExcelExport,
|
|
15
17
|
openSavedViews: SavedViews,
|
|
16
18
|
agGridSizeColumnsToFit: AgGridSizeColumnsToFit,
|
|
17
19
|
agGridAutoSizeColumns: AgGridAutoSizeColumns,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AgGridExcelExport {
|
|
2
|
+
constructor(fileName = 'export.xlsx') {
|
|
3
|
+
this.fileName = fileName;
|
|
4
|
+
}
|
|
5
|
+
init(gridApi) {
|
|
6
|
+
this.gridApi = gridApi;
|
|
7
|
+
}
|
|
8
|
+
onAction(name) {
|
|
9
|
+
if (name === 'agGridExcelExport') {
|
|
10
|
+
// The udp-col-* preset styling is applied via `excelStyles` in
|
|
11
|
+
// ag-grid-base (excelStyles is an @initial option, set at grid creation).
|
|
12
|
+
this.gridApi.exportDataAsExcel({ fileName: this.fileName });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// UDP column style presets (see ag-grid-base.css). Each maps to a cell class
|
|
2
|
+
// `udp-col-<name>` and a header class `udp-col-<name>-header`.
|
|
3
|
+
const UDP_COL_PRESETS = [
|
|
4
|
+
'brand',
|
|
5
|
+
'danger',
|
|
6
|
+
'important',
|
|
7
|
+
'informative',
|
|
8
|
+
'severe',
|
|
9
|
+
'subtle',
|
|
10
|
+
'success',
|
|
11
|
+
'warning',
|
|
12
|
+
];
|
|
13
|
+
let probeCtx;
|
|
14
|
+
function getProbeCtx() {
|
|
15
|
+
var _a;
|
|
16
|
+
if (probeCtx !== undefined)
|
|
17
|
+
return probeCtx;
|
|
18
|
+
const canvas = document.createElement('canvas');
|
|
19
|
+
canvas.width = 1;
|
|
20
|
+
canvas.height = 1;
|
|
21
|
+
probeCtx = (_a = canvas.getContext('2d', { willReadFrequently: true })) !== null && _a !== void 0 ? _a : null;
|
|
22
|
+
return probeCtx;
|
|
23
|
+
}
|
|
24
|
+
/** Paint `cssColor` over an opaque background and read the resulting RGB pixel. */
|
|
25
|
+
function paintOver(ctx, cssColor, bg) {
|
|
26
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
27
|
+
ctx.fillStyle = `rgb(${bg[0]}, ${bg[1]}, ${bg[2]})`;
|
|
28
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
29
|
+
// If the browser can't parse cssColor, fillStyle keeps the bg we just set, so
|
|
30
|
+
// the color resolves to the background (treated as "no tint" below).
|
|
31
|
+
ctx.fillStyle = cssColor;
|
|
32
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
33
|
+
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
34
|
+
return [r, g, b];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve any computed CSS color to an opaque `#RRGGBB`, flattened over white
|
|
38
|
+
* (the Excel sheet background). Uses a canvas so it handles every serialization
|
|
39
|
+
* `getComputedStyle` can return — `rgb()/rgba()`, `color(srgb …)`, `color-mix`,
|
|
40
|
+
* named colors. Returns null when the color is fully transparent (no tint to
|
|
41
|
+
* export) or the canvas is unavailable.
|
|
42
|
+
*/
|
|
43
|
+
function resolveColor(cssColor) {
|
|
44
|
+
if (!cssColor)
|
|
45
|
+
return null;
|
|
46
|
+
const ctx = getProbeCtx();
|
|
47
|
+
if (!ctx)
|
|
48
|
+
return null;
|
|
49
|
+
const overWhite = paintOver(ctx, cssColor, [255, 255, 255]);
|
|
50
|
+
const overBlack = paintOver(ctx, cssColor, [0, 0, 0]);
|
|
51
|
+
// Fully transparent ⇒ matches whatever it's painted over ⇒ nothing to export.
|
|
52
|
+
if (overWhite[0] === 255 && overWhite[1] === 255 && overWhite[2] === 255 &&
|
|
53
|
+
overBlack[0] === 0 && overBlack[1] === 0 && overBlack[2] === 0) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const hex = (n) => Math.max(0, Math.min(255, n)).toString(16).padStart(2, '0');
|
|
57
|
+
return `#${hex(overWhite[0])}${hex(overWhite[1])}${hex(overWhite[2])}`.toUpperCase();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Excel never sees the grid's CSS, so the udp-col-* column tints don't carry over
|
|
61
|
+
* to a `.xlsx` by default. This resolves each preset to its *live themed* color
|
|
62
|
+
* (honoring the active theme and any `color-mix`) and returns matching ExcelStyle
|
|
63
|
+
* entries keyed by the same class name, so cellClass / headerClass tints export.
|
|
64
|
+
*
|
|
65
|
+
* Must run after the grid's stylesheet is in the DOM (ag-grid-base.css is global
|
|
66
|
+
* since the component is `shadow: false`). Resolved at grid creation because
|
|
67
|
+
* `excelStyles` is an `@initial` grid option and cannot be updated at runtime.
|
|
68
|
+
*/
|
|
69
|
+
export function buildUdpPresetExcelStyles() {
|
|
70
|
+
if (typeof document === 'undefined' || typeof getComputedStyle === 'undefined') {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
// Offscreen probes resolving the same global rules AG Grid's real cells/headers
|
|
74
|
+
// do. Header text color lives on a nested `.ag-header-cell-text`.
|
|
75
|
+
const host = document.createElement('div');
|
|
76
|
+
host.setAttribute('aria-hidden', 'true');
|
|
77
|
+
host.style.cssText = 'position:fixed;left:-9999px;top:0;visibility:hidden;pointer-events:none;';
|
|
78
|
+
const cell = document.createElement('div');
|
|
79
|
+
const headerCell = document.createElement('div');
|
|
80
|
+
const headerText = document.createElement('span');
|
|
81
|
+
headerText.className = 'ag-header-cell-text';
|
|
82
|
+
headerCell.appendChild(headerText);
|
|
83
|
+
host.appendChild(cell);
|
|
84
|
+
host.appendChild(headerCell);
|
|
85
|
+
document.body.appendChild(host);
|
|
86
|
+
const styles = [];
|
|
87
|
+
try {
|
|
88
|
+
for (const name of UDP_COL_PRESETS) {
|
|
89
|
+
cell.className = `ag-cell udp-col-${name}`;
|
|
90
|
+
const cellStyle = getComputedStyle(cell);
|
|
91
|
+
const cellBg = resolveColor(cellStyle.backgroundColor);
|
|
92
|
+
if (cellBg) {
|
|
93
|
+
const cellFg = resolveColor(cellStyle.color);
|
|
94
|
+
styles.push(Object.assign({ id: `udp-col-${name}`, interior: { color: cellBg, pattern: 'Solid' } }, (cellFg ? { font: { color: cellFg } } : {})));
|
|
95
|
+
}
|
|
96
|
+
headerCell.className = `ag-header-cell udp-col-${name}-header`;
|
|
97
|
+
const headerBg = resolveColor(getComputedStyle(headerCell).backgroundColor);
|
|
98
|
+
if (headerBg) {
|
|
99
|
+
const headerFg = resolveColor(getComputedStyle(headerText).color);
|
|
100
|
+
styles.push({
|
|
101
|
+
id: `udp-col-${name}-header`,
|
|
102
|
+
interior: { color: headerBg, pattern: 'Solid' },
|
|
103
|
+
font: Object.assign({ bold: true }, (headerFg ? { color: headerFg } : {})),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
host.remove();
|
|
110
|
+
}
|
|
111
|
+
return styles;
|
|
112
|
+
}
|