@nanahoshi/mona-ui 0.39.1 → 0.41.0
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/docs/api/common.md +1 -1
- package/docs/api/grid.md +214 -17
- package/docs/api/i18n.md +36 -0
- package/docs/api/kanban.md +222 -0
- package/docs/api/locales.md +14 -14
- package/docs/api/sortable.md +189 -0
- package/docs/api/tabs.md +20 -0
- package/docs/grid-selection.md +134 -9
- package/docs/grid-state-export.md +56 -6
- package/docs/grid-tree.md +279 -0
- package/docs/kanban.md +293 -0
- package/docs/sortable.md +320 -0
- package/docs/tabs.md +59 -10
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs → nanahoshi-mona-ui-grid-grid-colgroup.component-DpszxgFY.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-CpvzAcX8.mjs} +4 -3
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BoSXXLKQ.mjs → nanahoshi-mona-ui-grid-grid-list.component-tRmEWiQR.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-Df2gfS0X.mjs → nanahoshi-mona-ui-grid-grid-row.component-eET6dh2Q.mjs} +52 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-xjrcCXXF.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-8h2EMexB.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs → nanahoshi-mona-ui-grid-grid.styles-wAf6jsT9.mjs} +646 -20
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1663 -22
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +56 -0
- package/fesm2022/nanahoshi-mona-ui-kanban.mjs +660 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +21 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +21 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-sortable.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +112 -5
- package/i18n/catalogs/en-US.messages.json +11 -0
- package/kanban/package.json +4 -0
- package/llms.txt +10 -5
- package/locales/ar-sa/ar-sa.messages.json +11 -0
- package/locales/de-de/de-de.messages.json +11 -0
- package/locales/es-es/es-es.messages.json +11 -0
- package/locales/fr-fr/fr-fr.messages.json +11 -0
- package/locales/id-id/id-id.messages.json +11 -0
- package/locales/it-it/it-it.messages.json +11 -0
- package/locales/ja-jp/ja-jp.messages.json +11 -0
- package/locales/ko-kr/ko-kr.messages.json +11 -0
- package/locales/pl-pl/pl-pl.messages.json +11 -0
- package/locales/pt-br/pt-br.messages.json +11 -0
- package/locales/ru-ru/ru-ru.messages.json +11 -0
- package/locales/tr-tr/tr-tr.messages.json +11 -0
- package/locales/zh-cn/zh-cn.messages.json +11 -0
- package/locales/zh-tw/zh-tw.messages.json +11 -0
- package/package.json +9 -1
- package/sortable/package.json +4 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +305 -3
- package/types/nanahoshi-mona-ui-i18n.d.ts +23 -0
- package/types/nanahoshi-mona-ui-kanban.d.ts +270 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +11 -0
- package/types/nanahoshi-mona-ui-sortable.d.ts +245 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +46 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { n as removeGridRow, t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-
|
|
1
|
+
import { $ as getGridCellText, A as gridHeaderThemeVariants, C as gridHeaderGroupTableRowThemeVariants, D as gridHeaderTableColumnWrapThemeVariants, E as gridHeaderTableColumnTitleThemeVariants, F as gridNoDataThemeVariants, G as observeGridCellTabStops, H as GridLogicalCellDirective, J as getColumnGroupDepth, K as GridLockedCellDirective, O as gridHeaderTableRowThemeVariants, R as gridSelectAllCellThemeVariants, S as gridHeaderGroupSpacerCellThemeVariants, T as gridHeaderTableCellThemeVariants, W as isKeyboardEntryElement, X as getColumnStepTarget, Y as getColumnGroups, Z as getSiblingRuns, _ as gridFooterThemeVariants, at as GridEditEvent, c as gridColumnActionsThemeVariants, ct as RowEditEvent, d as gridColumnResizerThemeVariants, et as RowReorderEvent, f as gridFilterRowCellThemeVariants, g as gridFooterTableThemeVariants, it as GridRemoveEvent, k as gridHeaderTableThemeVariants, l as gridColumnDragPreviewThemeVariants, lt as CellEditEvent, nt as GRID_DEFAULT_MESSAGES, ot as GridCancelEvent, p as gridFilterRowHeaderCellThemeVariants, q as GridService, rt as GridSaveEvent, st as GridAddEvent, t as gridBaseThemeVariants, tt as GridNavigationService, u as gridColumnDropHintThemeVariants, v as gridGroupPanelPlaceholderThemeVariants, w as gridHeaderGroupTitleThemeVariants, x as gridHeaderGroupCellThemeVariants, y as gridGroupPanelThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-wAf6jsT9.mjs";
|
|
2
|
+
import { n as removeGridRow, t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-DpszxgFY.mjs";
|
|
3
3
|
import { PreventableEvent, deepEquals } from "@nanahoshi/mona-ui/common";
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
|
-
import { Component, DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, PLATFORM_ID, Pipe, TemplateRef, afterEveryRender, afterNextRender, booleanAttribute, computed, contentChild, contentChildren, effect, forwardRef, inject, input, isDevMode, linkedSignal, model, output, signal, untracked, viewChild, viewChildren } from "@angular/core";
|
|
5
|
+
import { Component, DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, LOCALE_ID, PLATFORM_ID, Pipe, TemplateRef, afterEveryRender, afterNextRender, booleanAttribute, computed, contentChild, contentChildren, effect, forwardRef, inject, input, isDevMode, linkedSignal, model, output, signal, untracked, viewChild, viewChildren } from "@angular/core";
|
|
6
6
|
import { DialogService } from "@nanahoshi/mona-ui/dialog";
|
|
7
7
|
import { MonaI18nService, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
8
8
|
import { v4 } from "uuid";
|
|
9
9
|
import { DOCUMENT as DOCUMENT$1, NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
10
10
|
import { ImmutableSet } from "@mirei/ts-collections";
|
|
11
|
-
import { Subject, fromEvent, map, of, pairwise, startWith, switchMap, take, timer } from "rxjs";
|
|
11
|
+
import { Subject, filter, fromEvent, map, merge, of, pairwise, startWith, switchMap, take, takeUntil, timer } from "rxjs";
|
|
12
12
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
13
13
|
import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
|
|
14
14
|
import { ContextMenuItemComponent } from "@nanahoshi/mona-ui/contextmenu";
|
|
@@ -1287,6 +1287,194 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1287
1287
|
args: [{ selector: "ng-template[monaGridNoDataTemplate]" }]
|
|
1288
1288
|
}]
|
|
1289
1289
|
});
|
|
1290
|
+
const OWN_PRESS_SELECTOR = "a, button, input, select, textarea, [contenteditable], [data-grid-tree-toggle]";
|
|
1291
|
+
var GridRangeSelectableDirective = class GridRangeSelectableDirective {
|
|
1292
|
+
#destroyRef;
|
|
1293
|
+
#gridNavigationService;
|
|
1294
|
+
#gridService;
|
|
1295
|
+
#hostElementRef;
|
|
1296
|
+
#pasteEventSeen;
|
|
1297
|
+
constructor() {
|
|
1298
|
+
this.#destroyRef = inject(DestroyRef);
|
|
1299
|
+
this.#gridNavigationService = inject(GridNavigationService);
|
|
1300
|
+
this.#gridService = inject(GridService);
|
|
1301
|
+
this.#hostElementRef = inject(ElementRef);
|
|
1302
|
+
this.#pasteEventSeen = true;
|
|
1303
|
+
this.enabled = input(true, {
|
|
1304
|
+
...ngDevMode ? { debugName: "enabled" } : /* istanbul ignore next */ {},
|
|
1305
|
+
alias: "monaGridRangeSelectable",
|
|
1306
|
+
transform: (value) => value === "" || booleanAttribute(value)
|
|
1307
|
+
});
|
|
1308
|
+
this.rangeChange = output();
|
|
1309
|
+
this.rangePaste = output();
|
|
1310
|
+
effect(() => {
|
|
1311
|
+
const enabled = this.enabled();
|
|
1312
|
+
untracked(() => this.#gridService.setRangeSelectionEnabled(enabled));
|
|
1313
|
+
});
|
|
1314
|
+
this.#gridService.cellRangeChange$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1315
|
+
const range = this.#gridService.getCellRange();
|
|
1316
|
+
this.rangeChange.emit(range == null ? null : {
|
|
1317
|
+
fields: range.columns.map((column) => column.field),
|
|
1318
|
+
rows: range.rows.map((row) => row.data)
|
|
1319
|
+
});
|
|
1320
|
+
});
|
|
1321
|
+
this.#destroyRef.onDestroy(() => this.#gridService.setRangeSelectionEnabled(false));
|
|
1322
|
+
this.#setPointerSelection();
|
|
1323
|
+
this.#setPaste();
|
|
1324
|
+
}
|
|
1325
|
+
clearRange() {
|
|
1326
|
+
this.#gridService.clearCellRange();
|
|
1327
|
+
}
|
|
1328
|
+
selectAll() {
|
|
1329
|
+
this.#gridService.selectAllCells();
|
|
1330
|
+
}
|
|
1331
|
+
#cellOf(target) {
|
|
1332
|
+
if (!(target instanceof Element) || target.closest(OWN_PRESS_SELECTOR) != null) return null;
|
|
1333
|
+
const cell = this.#gridNavigationService.getCellAt(target);
|
|
1334
|
+
return cell != null && isRangeCell(cell) ? cell : null;
|
|
1335
|
+
}
|
|
1336
|
+
#paste(text) {
|
|
1337
|
+
const focused = this.#gridNavigationService.getFocusedCell();
|
|
1338
|
+
const at = focused != null && isRangeCell(focused) ? toAddress(focused) : null;
|
|
1339
|
+
const result = this.#gridService.pasteIntoCells(text, at);
|
|
1340
|
+
if (result != null) this.rangePaste.emit(result);
|
|
1341
|
+
}
|
|
1342
|
+
#setPaste() {
|
|
1343
|
+
const host = this.#hostElementRef.nativeElement;
|
|
1344
|
+
fromEvent(host, "paste").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
|
|
1345
|
+
this.#pasteEventSeen = true;
|
|
1346
|
+
if (!this.#gridService.rangeSelectionEnabled() || isTextEntry(event.target)) return;
|
|
1347
|
+
const text = event.clipboardData?.getData("text/plain") ?? "";
|
|
1348
|
+
if (text !== "") {
|
|
1349
|
+
event.preventDefault();
|
|
1350
|
+
this.#paste(text);
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
fromEvent(host, "keydown").pipe(filter((event) => (event.ctrlKey || event.metaKey) && !event.altKey && event.code === "KeyV" && this.#gridService.rangeSelectionEnabled() && !isTextEntry(event.target)), takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1354
|
+
this.#pasteEventSeen = false;
|
|
1355
|
+
setTimeout(() => {
|
|
1356
|
+
const clipboard = host.ownerDocument.defaultView?.navigator.clipboard;
|
|
1357
|
+
if (this.#pasteEventSeen || typeof clipboard?.readText !== "function") return;
|
|
1358
|
+
clipboard.readText().then((text) => {
|
|
1359
|
+
if (text !== "") this.#paste(text);
|
|
1360
|
+
}, () => void 0);
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
#setPointerSelection() {
|
|
1365
|
+
const host = this.#hostElementRef.nativeElement;
|
|
1366
|
+
const document = host.ownerDocument;
|
|
1367
|
+
fromEvent(host, "pointerdown").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
|
|
1368
|
+
if (event.button !== 0 || event.ctrlKey || event.metaKey || event.altKey || !this.#gridService.rangeSelectionEnabled() || this.#gridService.isInEditMode()) return;
|
|
1369
|
+
const cell = this.#cellOf(event.target);
|
|
1370
|
+
if (cell == null) return;
|
|
1371
|
+
if (event.shiftKey) {
|
|
1372
|
+
const focused = this.#gridNavigationService.getFocusedCell();
|
|
1373
|
+
const anchor = this.#gridService.cellRange()?.anchor ?? (focused != null && isRangeCell(focused) ? toAddress(focused) : toAddress(cell));
|
|
1374
|
+
event.preventDefault();
|
|
1375
|
+
this.#gridService.setCellRange(anchor, toAddress(cell));
|
|
1376
|
+
cell.element.focus();
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
this.#gridService.clearCellRange();
|
|
1380
|
+
if (event.pointerType === "touch") return;
|
|
1381
|
+
const anchor = toAddress(cell);
|
|
1382
|
+
const end$ = merge(fromEvent(document, "pointerup"), fromEvent(document, "pointercancel"));
|
|
1383
|
+
let dragged = false;
|
|
1384
|
+
fromEvent(document, "pointermove").pipe(takeUntil(end$), takeUntilDestroyed(this.#destroyRef)).subscribe({
|
|
1385
|
+
complete: () => {
|
|
1386
|
+
const range = this.#gridService.cellRange();
|
|
1387
|
+
if (dragged && range != null) this.#gridNavigationService.focusBodyCell(range.focus.rowUid, range.focus.columnId);
|
|
1388
|
+
},
|
|
1389
|
+
next: (move) => {
|
|
1390
|
+
const over = this.#cellOf(document.elementFromPoint(move.clientX, move.clientY));
|
|
1391
|
+
if (over == null) return;
|
|
1392
|
+
const focus = toAddress(over);
|
|
1393
|
+
if (!dragged && focus.rowUid === anchor.rowUid && focus.columnId === anchor.columnId) return;
|
|
1394
|
+
dragged = true;
|
|
1395
|
+
move.preventDefault();
|
|
1396
|
+
this.#gridService.setCellRange(anchor, focus);
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
static {
|
|
1402
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1403
|
+
minVersion: "12.0.0",
|
|
1404
|
+
version: "22.2.6",
|
|
1405
|
+
ngImport: i0,
|
|
1406
|
+
type: GridRangeSelectableDirective,
|
|
1407
|
+
deps: [],
|
|
1408
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
static {
|
|
1412
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
1413
|
+
minVersion: "17.1.0",
|
|
1414
|
+
version: "22.2.6",
|
|
1415
|
+
type: GridRangeSelectableDirective,
|
|
1416
|
+
isStandalone: true,
|
|
1417
|
+
selector: "mona-grid[monaGridRangeSelectable]",
|
|
1418
|
+
inputs: { enabled: {
|
|
1419
|
+
classPropertyName: "enabled",
|
|
1420
|
+
publicName: "monaGridRangeSelectable",
|
|
1421
|
+
isSignal: true,
|
|
1422
|
+
isRequired: false,
|
|
1423
|
+
transformFunction: null
|
|
1424
|
+
} },
|
|
1425
|
+
outputs: {
|
|
1426
|
+
rangeChange: "rangeChange",
|
|
1427
|
+
rangePaste: "rangePaste"
|
|
1428
|
+
},
|
|
1429
|
+
exportAs: ["monaGridRangeSelectable"],
|
|
1430
|
+
ngImport: i0
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1435
|
+
minVersion: "12.0.0",
|
|
1436
|
+
version: "22.2.6",
|
|
1437
|
+
ngImport: i0,
|
|
1438
|
+
type: GridRangeSelectableDirective,
|
|
1439
|
+
decorators: [{
|
|
1440
|
+
type: Directive,
|
|
1441
|
+
args: [{
|
|
1442
|
+
selector: "mona-grid[monaGridRangeSelectable]",
|
|
1443
|
+
exportAs: "monaGridRangeSelectable"
|
|
1444
|
+
}]
|
|
1445
|
+
}],
|
|
1446
|
+
ctorParameters: () => [],
|
|
1447
|
+
propDecorators: {
|
|
1448
|
+
enabled: [{
|
|
1449
|
+
type: i0.Input,
|
|
1450
|
+
args: [{
|
|
1451
|
+
isSignal: true,
|
|
1452
|
+
alias: "monaGridRangeSelectable",
|
|
1453
|
+
required: false
|
|
1454
|
+
}]
|
|
1455
|
+
}],
|
|
1456
|
+
rangeChange: [{
|
|
1457
|
+
type: i0.Output,
|
|
1458
|
+
args: ["rangeChange"]
|
|
1459
|
+
}],
|
|
1460
|
+
rangePaste: [{
|
|
1461
|
+
type: i0.Output,
|
|
1462
|
+
args: ["rangePaste"]
|
|
1463
|
+
}]
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
function isRangeCell(cell) {
|
|
1467
|
+
return cell.section === "body" && cell.cellKind === "data" && cell.rowUid != null && cell.columnId != null;
|
|
1468
|
+
}
|
|
1469
|
+
function isTextEntry(target) {
|
|
1470
|
+
return target instanceof Element && target.closest("input, textarea, select, [contenteditable]") != null;
|
|
1471
|
+
}
|
|
1472
|
+
function toAddress(cell) {
|
|
1473
|
+
return {
|
|
1474
|
+
columnId: cell.columnId,
|
|
1475
|
+
rowUid: cell.rowUid
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1290
1478
|
var GridReorderableDirective = class GridReorderableDirective {
|
|
1291
1479
|
#destroyRef;
|
|
1292
1480
|
#gridService;
|
|
@@ -2074,6 +2262,1322 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2074
2262
|
args: [{ selector: "ng-template[monaGridToolbarTemplate]" }]
|
|
2075
2263
|
}]
|
|
2076
2264
|
});
|
|
2265
|
+
var GridTreeDirective = class GridTreeDirective {
|
|
2266
|
+
#destroyRef;
|
|
2267
|
+
#gridService;
|
|
2268
|
+
constructor() {
|
|
2269
|
+
this.#destroyRef = inject(DestroyRef);
|
|
2270
|
+
this.#gridService = inject(GridService);
|
|
2271
|
+
this.children = input("", ...ngDevMode ? [{ debugName: "children" }] : /* istanbul ignore next */ []);
|
|
2272
|
+
this.parentKey = input("", ...ngDevMode ? [{ debugName: "parentKey" }] : /* istanbul ignore next */ []);
|
|
2273
|
+
this.treeExpandedKeys = input([], ...ngDevMode ? [{ debugName: "treeExpandedKeys" }] : /* istanbul ignore next */ []);
|
|
2274
|
+
this.treeExpandedKeysChange = output();
|
|
2275
|
+
effect(() => {
|
|
2276
|
+
const children = this.children();
|
|
2277
|
+
const parentKey = this.parentKey();
|
|
2278
|
+
untracked(() => this.#gridService.setTreeOptions({
|
|
2279
|
+
children: children || null,
|
|
2280
|
+
parentKey: parentKey || null
|
|
2281
|
+
}));
|
|
2282
|
+
});
|
|
2283
|
+
effect(() => {
|
|
2284
|
+
const keys = this.treeExpandedKeys();
|
|
2285
|
+
untracked(() => this.#gridService.loadTreeExpandedKeys(keys));
|
|
2286
|
+
});
|
|
2287
|
+
effect(() => {
|
|
2288
|
+
const ancestors = this.#gridService.treeMatchAncestorUids();
|
|
2289
|
+
untracked(() => this.#gridService.expandTreeRows(ancestors));
|
|
2290
|
+
});
|
|
2291
|
+
this.#gridService.treeExpandedKeysChange$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((keys) => this.treeExpandedKeysChange.emit(keys));
|
|
2292
|
+
this.#destroyRef.onDestroy(() => this.#gridService.setTreeOptions(null));
|
|
2293
|
+
}
|
|
2294
|
+
collapseAll() {
|
|
2295
|
+
this.#gridService.setAllTreeRowsExpanded(false);
|
|
2296
|
+
}
|
|
2297
|
+
expandAll() {
|
|
2298
|
+
this.#gridService.setAllTreeRowsExpanded(true);
|
|
2299
|
+
}
|
|
2300
|
+
static {
|
|
2301
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2302
|
+
minVersion: "12.0.0",
|
|
2303
|
+
version: "22.2.6",
|
|
2304
|
+
ngImport: i0,
|
|
2305
|
+
type: GridTreeDirective,
|
|
2306
|
+
deps: [],
|
|
2307
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
static {
|
|
2311
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
2312
|
+
minVersion: "17.1.0",
|
|
2313
|
+
version: "22.2.6",
|
|
2314
|
+
type: GridTreeDirective,
|
|
2315
|
+
isStandalone: true,
|
|
2316
|
+
selector: "mona-grid[monaGridTree]",
|
|
2317
|
+
inputs: {
|
|
2318
|
+
children: {
|
|
2319
|
+
classPropertyName: "children",
|
|
2320
|
+
publicName: "children",
|
|
2321
|
+
isSignal: true,
|
|
2322
|
+
isRequired: false,
|
|
2323
|
+
transformFunction: null
|
|
2324
|
+
},
|
|
2325
|
+
parentKey: {
|
|
2326
|
+
classPropertyName: "parentKey",
|
|
2327
|
+
publicName: "parentKey",
|
|
2328
|
+
isSignal: true,
|
|
2329
|
+
isRequired: false,
|
|
2330
|
+
transformFunction: null
|
|
2331
|
+
},
|
|
2332
|
+
treeExpandedKeys: {
|
|
2333
|
+
classPropertyName: "treeExpandedKeys",
|
|
2334
|
+
publicName: "treeExpandedKeys",
|
|
2335
|
+
isSignal: true,
|
|
2336
|
+
isRequired: false,
|
|
2337
|
+
transformFunction: null
|
|
2338
|
+
}
|
|
2339
|
+
},
|
|
2340
|
+
outputs: { treeExpandedKeysChange: "treeExpandedKeysChange" },
|
|
2341
|
+
exportAs: ["monaGridTree"],
|
|
2342
|
+
ngImport: i0
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2347
|
+
minVersion: "12.0.0",
|
|
2348
|
+
version: "22.2.6",
|
|
2349
|
+
ngImport: i0,
|
|
2350
|
+
type: GridTreeDirective,
|
|
2351
|
+
decorators: [{
|
|
2352
|
+
type: Directive,
|
|
2353
|
+
args: [{
|
|
2354
|
+
selector: "mona-grid[monaGridTree]",
|
|
2355
|
+
exportAs: "monaGridTree"
|
|
2356
|
+
}]
|
|
2357
|
+
}],
|
|
2358
|
+
ctorParameters: () => [],
|
|
2359
|
+
propDecorators: {
|
|
2360
|
+
children: [{
|
|
2361
|
+
type: i0.Input,
|
|
2362
|
+
args: [{
|
|
2363
|
+
isSignal: true,
|
|
2364
|
+
alias: "children",
|
|
2365
|
+
required: false
|
|
2366
|
+
}]
|
|
2367
|
+
}],
|
|
2368
|
+
parentKey: [{
|
|
2369
|
+
type: i0.Input,
|
|
2370
|
+
args: [{
|
|
2371
|
+
isSignal: true,
|
|
2372
|
+
alias: "parentKey",
|
|
2373
|
+
required: false
|
|
2374
|
+
}]
|
|
2375
|
+
}],
|
|
2376
|
+
treeExpandedKeys: [{
|
|
2377
|
+
type: i0.Input,
|
|
2378
|
+
args: [{
|
|
2379
|
+
isSignal: true,
|
|
2380
|
+
alias: "treeExpandedKeys",
|
|
2381
|
+
required: false
|
|
2382
|
+
}]
|
|
2383
|
+
}],
|
|
2384
|
+
treeExpandedKeysChange: [{
|
|
2385
|
+
type: i0.Output,
|
|
2386
|
+
args: ["treeExpandedKeysChange"]
|
|
2387
|
+
}]
|
|
2388
|
+
}
|
|
2389
|
+
});
|
|
2390
|
+
const HELVETICA_ASCII = [
|
|
2391
|
+
278,
|
|
2392
|
+
278,
|
|
2393
|
+
355,
|
|
2394
|
+
556,
|
|
2395
|
+
556,
|
|
2396
|
+
889,
|
|
2397
|
+
667,
|
|
2398
|
+
191,
|
|
2399
|
+
333,
|
|
2400
|
+
333,
|
|
2401
|
+
389,
|
|
2402
|
+
584,
|
|
2403
|
+
278,
|
|
2404
|
+
333,
|
|
2405
|
+
278,
|
|
2406
|
+
278,
|
|
2407
|
+
556,
|
|
2408
|
+
556,
|
|
2409
|
+
556,
|
|
2410
|
+
556,
|
|
2411
|
+
556,
|
|
2412
|
+
556,
|
|
2413
|
+
556,
|
|
2414
|
+
556,
|
|
2415
|
+
556,
|
|
2416
|
+
556,
|
|
2417
|
+
278,
|
|
2418
|
+
278,
|
|
2419
|
+
584,
|
|
2420
|
+
584,
|
|
2421
|
+
584,
|
|
2422
|
+
556,
|
|
2423
|
+
1015,
|
|
2424
|
+
667,
|
|
2425
|
+
667,
|
|
2426
|
+
722,
|
|
2427
|
+
722,
|
|
2428
|
+
667,
|
|
2429
|
+
611,
|
|
2430
|
+
778,
|
|
2431
|
+
722,
|
|
2432
|
+
278,
|
|
2433
|
+
500,
|
|
2434
|
+
667,
|
|
2435
|
+
556,
|
|
2436
|
+
833,
|
|
2437
|
+
722,
|
|
2438
|
+
778,
|
|
2439
|
+
667,
|
|
2440
|
+
778,
|
|
2441
|
+
722,
|
|
2442
|
+
667,
|
|
2443
|
+
611,
|
|
2444
|
+
722,
|
|
2445
|
+
667,
|
|
2446
|
+
944,
|
|
2447
|
+
667,
|
|
2448
|
+
667,
|
|
2449
|
+
611,
|
|
2450
|
+
278,
|
|
2451
|
+
278,
|
|
2452
|
+
278,
|
|
2453
|
+
469,
|
|
2454
|
+
556,
|
|
2455
|
+
333,
|
|
2456
|
+
556,
|
|
2457
|
+
556,
|
|
2458
|
+
500,
|
|
2459
|
+
556,
|
|
2460
|
+
556,
|
|
2461
|
+
278,
|
|
2462
|
+
556,
|
|
2463
|
+
556,
|
|
2464
|
+
222,
|
|
2465
|
+
222,
|
|
2466
|
+
500,
|
|
2467
|
+
222,
|
|
2468
|
+
833,
|
|
2469
|
+
556,
|
|
2470
|
+
556,
|
|
2471
|
+
556,
|
|
2472
|
+
556,
|
|
2473
|
+
333,
|
|
2474
|
+
500,
|
|
2475
|
+
278,
|
|
2476
|
+
556,
|
|
2477
|
+
500,
|
|
2478
|
+
722,
|
|
2479
|
+
500,
|
|
2480
|
+
500,
|
|
2481
|
+
500,
|
|
2482
|
+
334,
|
|
2483
|
+
260,
|
|
2484
|
+
334,
|
|
2485
|
+
584
|
|
2486
|
+
];
|
|
2487
|
+
const HELVETICA_BOLD_ASCII = [
|
|
2488
|
+
278,
|
|
2489
|
+
333,
|
|
2490
|
+
474,
|
|
2491
|
+
556,
|
|
2492
|
+
556,
|
|
2493
|
+
889,
|
|
2494
|
+
722,
|
|
2495
|
+
238,
|
|
2496
|
+
333,
|
|
2497
|
+
333,
|
|
2498
|
+
389,
|
|
2499
|
+
584,
|
|
2500
|
+
278,
|
|
2501
|
+
333,
|
|
2502
|
+
278,
|
|
2503
|
+
278,
|
|
2504
|
+
556,
|
|
2505
|
+
556,
|
|
2506
|
+
556,
|
|
2507
|
+
556,
|
|
2508
|
+
556,
|
|
2509
|
+
556,
|
|
2510
|
+
556,
|
|
2511
|
+
556,
|
|
2512
|
+
556,
|
|
2513
|
+
556,
|
|
2514
|
+
333,
|
|
2515
|
+
333,
|
|
2516
|
+
584,
|
|
2517
|
+
584,
|
|
2518
|
+
584,
|
|
2519
|
+
611,
|
|
2520
|
+
975,
|
|
2521
|
+
722,
|
|
2522
|
+
722,
|
|
2523
|
+
722,
|
|
2524
|
+
722,
|
|
2525
|
+
667,
|
|
2526
|
+
611,
|
|
2527
|
+
778,
|
|
2528
|
+
722,
|
|
2529
|
+
278,
|
|
2530
|
+
556,
|
|
2531
|
+
722,
|
|
2532
|
+
611,
|
|
2533
|
+
833,
|
|
2534
|
+
722,
|
|
2535
|
+
778,
|
|
2536
|
+
667,
|
|
2537
|
+
778,
|
|
2538
|
+
722,
|
|
2539
|
+
667,
|
|
2540
|
+
611,
|
|
2541
|
+
722,
|
|
2542
|
+
667,
|
|
2543
|
+
944,
|
|
2544
|
+
667,
|
|
2545
|
+
667,
|
|
2546
|
+
611,
|
|
2547
|
+
333,
|
|
2548
|
+
278,
|
|
2549
|
+
333,
|
|
2550
|
+
584,
|
|
2551
|
+
556,
|
|
2552
|
+
333,
|
|
2553
|
+
556,
|
|
2554
|
+
611,
|
|
2555
|
+
556,
|
|
2556
|
+
611,
|
|
2557
|
+
556,
|
|
2558
|
+
333,
|
|
2559
|
+
611,
|
|
2560
|
+
611,
|
|
2561
|
+
278,
|
|
2562
|
+
278,
|
|
2563
|
+
556,
|
|
2564
|
+
278,
|
|
2565
|
+
889,
|
|
2566
|
+
611,
|
|
2567
|
+
611,
|
|
2568
|
+
611,
|
|
2569
|
+
611,
|
|
2570
|
+
389,
|
|
2571
|
+
556,
|
|
2572
|
+
333,
|
|
2573
|
+
611,
|
|
2574
|
+
556,
|
|
2575
|
+
778,
|
|
2576
|
+
556,
|
|
2577
|
+
556,
|
|
2578
|
+
500,
|
|
2579
|
+
389,
|
|
2580
|
+
280,
|
|
2581
|
+
389,
|
|
2582
|
+
584
|
|
2583
|
+
];
|
|
2584
|
+
const HELVETICA_HIGH_CONTROL = [
|
|
2585
|
+
556,
|
|
2586
|
+
0,
|
|
2587
|
+
222,
|
|
2588
|
+
556,
|
|
2589
|
+
333,
|
|
2590
|
+
1e3,
|
|
2591
|
+
556,
|
|
2592
|
+
556,
|
|
2593
|
+
333,
|
|
2594
|
+
1e3,
|
|
2595
|
+
667,
|
|
2596
|
+
333,
|
|
2597
|
+
1e3,
|
|
2598
|
+
0,
|
|
2599
|
+
611,
|
|
2600
|
+
0,
|
|
2601
|
+
0,
|
|
2602
|
+
222,
|
|
2603
|
+
222,
|
|
2604
|
+
333,
|
|
2605
|
+
333,
|
|
2606
|
+
350,
|
|
2607
|
+
556,
|
|
2608
|
+
1e3,
|
|
2609
|
+
333,
|
|
2610
|
+
1e3,
|
|
2611
|
+
500,
|
|
2612
|
+
333,
|
|
2613
|
+
944,
|
|
2614
|
+
0,
|
|
2615
|
+
500,
|
|
2616
|
+
667
|
|
2617
|
+
];
|
|
2618
|
+
const HELVETICA_BOLD_HIGH_CONTROL = [
|
|
2619
|
+
556,
|
|
2620
|
+
0,
|
|
2621
|
+
278,
|
|
2622
|
+
556,
|
|
2623
|
+
500,
|
|
2624
|
+
1e3,
|
|
2625
|
+
556,
|
|
2626
|
+
556,
|
|
2627
|
+
333,
|
|
2628
|
+
1e3,
|
|
2629
|
+
667,
|
|
2630
|
+
333,
|
|
2631
|
+
1e3,
|
|
2632
|
+
0,
|
|
2633
|
+
611,
|
|
2634
|
+
0,
|
|
2635
|
+
0,
|
|
2636
|
+
278,
|
|
2637
|
+
278,
|
|
2638
|
+
500,
|
|
2639
|
+
500,
|
|
2640
|
+
350,
|
|
2641
|
+
556,
|
|
2642
|
+
1e3,
|
|
2643
|
+
333,
|
|
2644
|
+
1e3,
|
|
2645
|
+
556,
|
|
2646
|
+
333,
|
|
2647
|
+
944,
|
|
2648
|
+
0,
|
|
2649
|
+
500,
|
|
2650
|
+
667
|
|
2651
|
+
];
|
|
2652
|
+
const HELVETICA_LATIN1 = [
|
|
2653
|
+
278,
|
|
2654
|
+
333,
|
|
2655
|
+
556,
|
|
2656
|
+
556,
|
|
2657
|
+
556,
|
|
2658
|
+
556,
|
|
2659
|
+
260,
|
|
2660
|
+
556,
|
|
2661
|
+
333,
|
|
2662
|
+
737,
|
|
2663
|
+
370,
|
|
2664
|
+
556,
|
|
2665
|
+
584,
|
|
2666
|
+
333,
|
|
2667
|
+
737,
|
|
2668
|
+
333,
|
|
2669
|
+
400,
|
|
2670
|
+
584,
|
|
2671
|
+
333,
|
|
2672
|
+
333,
|
|
2673
|
+
333,
|
|
2674
|
+
556,
|
|
2675
|
+
537,
|
|
2676
|
+
278,
|
|
2677
|
+
333,
|
|
2678
|
+
333,
|
|
2679
|
+
365,
|
|
2680
|
+
556,
|
|
2681
|
+
834,
|
|
2682
|
+
834,
|
|
2683
|
+
834,
|
|
2684
|
+
611,
|
|
2685
|
+
667,
|
|
2686
|
+
667,
|
|
2687
|
+
667,
|
|
2688
|
+
667,
|
|
2689
|
+
667,
|
|
2690
|
+
667,
|
|
2691
|
+
1e3,
|
|
2692
|
+
722,
|
|
2693
|
+
667,
|
|
2694
|
+
667,
|
|
2695
|
+
667,
|
|
2696
|
+
667,
|
|
2697
|
+
278,
|
|
2698
|
+
278,
|
|
2699
|
+
278,
|
|
2700
|
+
278,
|
|
2701
|
+
722,
|
|
2702
|
+
722,
|
|
2703
|
+
778,
|
|
2704
|
+
778,
|
|
2705
|
+
778,
|
|
2706
|
+
778,
|
|
2707
|
+
778,
|
|
2708
|
+
584,
|
|
2709
|
+
778,
|
|
2710
|
+
722,
|
|
2711
|
+
722,
|
|
2712
|
+
722,
|
|
2713
|
+
722,
|
|
2714
|
+
667,
|
|
2715
|
+
667,
|
|
2716
|
+
611,
|
|
2717
|
+
556,
|
|
2718
|
+
556,
|
|
2719
|
+
556,
|
|
2720
|
+
556,
|
|
2721
|
+
556,
|
|
2722
|
+
556,
|
|
2723
|
+
889,
|
|
2724
|
+
500,
|
|
2725
|
+
556,
|
|
2726
|
+
556,
|
|
2727
|
+
556,
|
|
2728
|
+
556,
|
|
2729
|
+
278,
|
|
2730
|
+
278,
|
|
2731
|
+
278,
|
|
2732
|
+
278,
|
|
2733
|
+
556,
|
|
2734
|
+
556,
|
|
2735
|
+
556,
|
|
2736
|
+
556,
|
|
2737
|
+
556,
|
|
2738
|
+
556,
|
|
2739
|
+
556,
|
|
2740
|
+
584,
|
|
2741
|
+
611,
|
|
2742
|
+
556,
|
|
2743
|
+
556,
|
|
2744
|
+
556,
|
|
2745
|
+
556,
|
|
2746
|
+
500,
|
|
2747
|
+
556,
|
|
2748
|
+
500
|
|
2749
|
+
];
|
|
2750
|
+
const HELVETICA_BOLD_LATIN1 = [
|
|
2751
|
+
278,
|
|
2752
|
+
333,
|
|
2753
|
+
556,
|
|
2754
|
+
556,
|
|
2755
|
+
556,
|
|
2756
|
+
556,
|
|
2757
|
+
280,
|
|
2758
|
+
556,
|
|
2759
|
+
333,
|
|
2760
|
+
737,
|
|
2761
|
+
370,
|
|
2762
|
+
556,
|
|
2763
|
+
584,
|
|
2764
|
+
333,
|
|
2765
|
+
737,
|
|
2766
|
+
333,
|
|
2767
|
+
400,
|
|
2768
|
+
584,
|
|
2769
|
+
333,
|
|
2770
|
+
333,
|
|
2771
|
+
333,
|
|
2772
|
+
611,
|
|
2773
|
+
556,
|
|
2774
|
+
278,
|
|
2775
|
+
333,
|
|
2776
|
+
333,
|
|
2777
|
+
365,
|
|
2778
|
+
556,
|
|
2779
|
+
834,
|
|
2780
|
+
834,
|
|
2781
|
+
834,
|
|
2782
|
+
611,
|
|
2783
|
+
722,
|
|
2784
|
+
722,
|
|
2785
|
+
722,
|
|
2786
|
+
722,
|
|
2787
|
+
722,
|
|
2788
|
+
722,
|
|
2789
|
+
1e3,
|
|
2790
|
+
722,
|
|
2791
|
+
667,
|
|
2792
|
+
667,
|
|
2793
|
+
667,
|
|
2794
|
+
667,
|
|
2795
|
+
278,
|
|
2796
|
+
278,
|
|
2797
|
+
278,
|
|
2798
|
+
278,
|
|
2799
|
+
722,
|
|
2800
|
+
722,
|
|
2801
|
+
778,
|
|
2802
|
+
778,
|
|
2803
|
+
778,
|
|
2804
|
+
778,
|
|
2805
|
+
778,
|
|
2806
|
+
584,
|
|
2807
|
+
778,
|
|
2808
|
+
722,
|
|
2809
|
+
722,
|
|
2810
|
+
722,
|
|
2811
|
+
722,
|
|
2812
|
+
667,
|
|
2813
|
+
667,
|
|
2814
|
+
611,
|
|
2815
|
+
556,
|
|
2816
|
+
556,
|
|
2817
|
+
556,
|
|
2818
|
+
556,
|
|
2819
|
+
556,
|
|
2820
|
+
556,
|
|
2821
|
+
889,
|
|
2822
|
+
556,
|
|
2823
|
+
556,
|
|
2824
|
+
556,
|
|
2825
|
+
556,
|
|
2826
|
+
556,
|
|
2827
|
+
278,
|
|
2828
|
+
278,
|
|
2829
|
+
278,
|
|
2830
|
+
278,
|
|
2831
|
+
611,
|
|
2832
|
+
611,
|
|
2833
|
+
611,
|
|
2834
|
+
611,
|
|
2835
|
+
611,
|
|
2836
|
+
611,
|
|
2837
|
+
611,
|
|
2838
|
+
584,
|
|
2839
|
+
611,
|
|
2840
|
+
611,
|
|
2841
|
+
611,
|
|
2842
|
+
611,
|
|
2843
|
+
611,
|
|
2844
|
+
556,
|
|
2845
|
+
611,
|
|
2846
|
+
556
|
|
2847
|
+
];
|
|
2848
|
+
const WIN_ANSI_BY_CODE_POINT = new Map(Array.from("€\0‚ƒ„…†‡ˆ‰Š‹Œ\0Ž\0\0‘’“”•–—˜™š›œ\0žŸ", (char, index) => [char.codePointAt(0), 128 + index]).filter(([codePoint]) => codePoint !== 0));
|
|
2849
|
+
function toWinAnsiCode(codePoint) {
|
|
2850
|
+
if (codePoint >= 32 && codePoint <= 126 || codePoint >= 160 && codePoint <= 255) return codePoint;
|
|
2851
|
+
return WIN_ANSI_BY_CODE_POINT.get(codePoint) ?? null;
|
|
2852
|
+
}
|
|
2853
|
+
function getStandardFontWidth(font, code) {
|
|
2854
|
+
const bold = font === "Helvetica-Bold";
|
|
2855
|
+
if (code >= 32 && code <= 126) return (bold ? HELVETICA_BOLD_ASCII : HELVETICA_ASCII)[code - 32];
|
|
2856
|
+
if (code >= 128 && code <= 159) return (bold ? HELVETICA_BOLD_HIGH_CONTROL : HELVETICA_HIGH_CONTROL)[code - 128];
|
|
2857
|
+
if (code >= 160 && code <= 255) return (bold ? HELVETICA_BOLD_LATIN1 : HELVETICA_LATIN1)[code - 160];
|
|
2858
|
+
return 0;
|
|
2859
|
+
}
|
|
2860
|
+
const PDF_MIME_TYPE = "application/pdf";
|
|
2861
|
+
const PIXELS_TO_POINTS = .75;
|
|
2862
|
+
const LINE_HEIGHT = 1.25;
|
|
2863
|
+
const MIN_FONT_SIZE = 5;
|
|
2864
|
+
const TREE_INDENT = 10;
|
|
2865
|
+
const HEADER_FILL = "0.94 g";
|
|
2866
|
+
const BORDER_STROKE = "0.78 G";
|
|
2867
|
+
const CJK_RANGES = "⺀- -〿-ヿ-ㇿ㐀-䶿一-鿿가-豈--";
|
|
2868
|
+
const TOKEN_PATTERN = new RegExp(`\\s+|[${CJK_RANGES}]|[^\\s${CJK_RANGES}]+`, "gu");
|
|
2869
|
+
var StandardFace = class {
|
|
2870
|
+
constructor(font, resource) {
|
|
2871
|
+
this.font = font;
|
|
2872
|
+
this.resource = resource;
|
|
2873
|
+
this.fakeBold = false;
|
|
2874
|
+
}
|
|
2875
|
+
covers(codePoint) {
|
|
2876
|
+
return toWinAnsiCode(codePoint) != null;
|
|
2877
|
+
}
|
|
2878
|
+
encode(text) {
|
|
2879
|
+
let hex = "";
|
|
2880
|
+
for (const char of text) hex += hex2(toWinAnsiCode(char.codePointAt(0)) ?? 63);
|
|
2881
|
+
return `<${hex}>`;
|
|
2882
|
+
}
|
|
2883
|
+
width(codePoint) {
|
|
2884
|
+
return getStandardFontWidth(this.font, toWinAnsiCode(codePoint) ?? 63);
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
var EmbeddedFace = class {
|
|
2888
|
+
constructor(font, resource, fakeBold, used = /* @__PURE__ */ new Map()) {
|
|
2889
|
+
this.font = font;
|
|
2890
|
+
this.resource = resource;
|
|
2891
|
+
this.fakeBold = fakeBold;
|
|
2892
|
+
this.used = used;
|
|
2893
|
+
}
|
|
2894
|
+
covers(codePoint) {
|
|
2895
|
+
return this.font.glyphOf(codePoint) !== 0;
|
|
2896
|
+
}
|
|
2897
|
+
encode(text) {
|
|
2898
|
+
let hex = "";
|
|
2899
|
+
for (const char of text) {
|
|
2900
|
+
const glyph = this.font.glyphOf(char.codePointAt(0));
|
|
2901
|
+
if (!this.used.has(glyph)) this.used.set(glyph, char);
|
|
2902
|
+
hex += hex4(glyph);
|
|
2903
|
+
}
|
|
2904
|
+
return `<${hex}>`;
|
|
2905
|
+
}
|
|
2906
|
+
width(codePoint) {
|
|
2907
|
+
return this.font.widthOf(this.font.glyphOf(codePoint));
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
var FontSet = class {
|
|
2911
|
+
#bold;
|
|
2912
|
+
#regular;
|
|
2913
|
+
constructor(fonts) {
|
|
2914
|
+
this.embedded = [];
|
|
2915
|
+
const regular = fonts.regular == null ? null : new EmbeddedFace(fonts.regular, "F3", false);
|
|
2916
|
+
const bold = fonts.bold != null ? new EmbeddedFace(fonts.bold, "F4", false) : regular != null ? new EmbeddedFace(regular.font, regular.resource, true, regular.used) : null;
|
|
2917
|
+
this.#regular = {
|
|
2918
|
+
embedded: regular,
|
|
2919
|
+
standard: new StandardFace("Helvetica", "F1")
|
|
2920
|
+
};
|
|
2921
|
+
this.#bold = {
|
|
2922
|
+
embedded: bold,
|
|
2923
|
+
standard: new StandardFace("Helvetica-Bold", "F2")
|
|
2924
|
+
};
|
|
2925
|
+
for (const face of [regular, bold]) if (face != null && !this.embedded.some((known) => known.resource === face.resource)) this.embedded.push(face);
|
|
2926
|
+
}
|
|
2927
|
+
measure(text, bold, fontSize) {
|
|
2928
|
+
return this.runs(text, bold).reduce((sum, run) => sum + run.width, 0) * fontSize / 1e3;
|
|
2929
|
+
}
|
|
2930
|
+
runs(text, bold) {
|
|
2931
|
+
const faces = bold ? this.#bold : this.#regular;
|
|
2932
|
+
const runs = [];
|
|
2933
|
+
for (const char of text) {
|
|
2934
|
+
const codePoint = char.codePointAt(0);
|
|
2935
|
+
const face = faces.embedded?.covers(codePoint) ? faces.embedded : faces.standard;
|
|
2936
|
+
const width = face.width(codePoint);
|
|
2937
|
+
const last = runs.at(-1);
|
|
2938
|
+
if (last?.face === face) {
|
|
2939
|
+
last.text += char;
|
|
2940
|
+
last.width += width;
|
|
2941
|
+
} else runs.push({
|
|
2942
|
+
face,
|
|
2943
|
+
text: char,
|
|
2944
|
+
width
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
return runs;
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
async function writePdfTable(table, options) {
|
|
2951
|
+
const fonts = new FontSet(options.fonts);
|
|
2952
|
+
const pages = layOutPages(table, options, fonts);
|
|
2953
|
+
const writer = new PdfObjectWriter();
|
|
2954
|
+
const catalog = writer.reserve();
|
|
2955
|
+
const pageTree = writer.reserve();
|
|
2956
|
+
const info = writer.reserve();
|
|
2957
|
+
const standardFonts = [writer.add(`<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>`), writer.add(`<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>`)];
|
|
2958
|
+
const contents = pages.map((page) => page.draw());
|
|
2959
|
+
const fontResources = [`/F1 ${standardFonts[0]} 0 R`, `/F2 ${standardFonts[1]} 0 R`];
|
|
2960
|
+
for (const face of fonts.embedded) {
|
|
2961
|
+
if (face.used.size === 0) continue;
|
|
2962
|
+
fontResources.push(`/${face.resource} ${await writeEmbeddedFont(writer, face)} 0 R`);
|
|
2963
|
+
}
|
|
2964
|
+
const resources = `<< /Font << ${fontResources.join(" ")} >> >>`;
|
|
2965
|
+
const [width, height] = options.pageSize;
|
|
2966
|
+
const pageIds = [];
|
|
2967
|
+
for (const content of contents) {
|
|
2968
|
+
const stream = await writer.addStream("", new TextEncoder().encode(content));
|
|
2969
|
+
pageIds.push(writer.add(`<< /Type /Page /Parent ${pageTree} 0 R /MediaBox [0 0 ${num(width)} ${num(height)}] /Resources ${resources} /Contents ${stream} 0 R >>`));
|
|
2970
|
+
}
|
|
2971
|
+
writer.set(pageTree, `<< /Type /Pages /Kids [${pageIds.map((id) => `${id} 0 R`).join(" ")}] /Count ${pageIds.length} >>`);
|
|
2972
|
+
writer.set(catalog, `<< /Type /Catalog /Pages ${pageTree} 0 R >>`);
|
|
2973
|
+
const title = options.title == null ? "" : `/Title ${toTextString(options.title)} `;
|
|
2974
|
+
writer.set(info, `<< ${title}/Producer ${toTextString("Mona UI")} /CreationDate (${toPdfDate(options.modified)}) >>`);
|
|
2975
|
+
return writer.finish(catalog, info);
|
|
2976
|
+
}
|
|
2977
|
+
function layOutPages(table, options, fonts) {
|
|
2978
|
+
const [pageWidth, pageHeight] = options.pageSize;
|
|
2979
|
+
const margin = options.margin;
|
|
2980
|
+
const contentWidth = pageWidth - margin * 2;
|
|
2981
|
+
const naturalWidths = table.columnWidths.map((width) => Math.max(1, width) * PIXELS_TO_POINTS);
|
|
2982
|
+
const naturalWidth = naturalWidths.reduce((sum, width) => sum + width, 0);
|
|
2983
|
+
const scale = naturalWidth > contentWidth ? contentWidth / naturalWidth : 1;
|
|
2984
|
+
const widths = naturalWidths.map((width) => width * scale);
|
|
2985
|
+
const fontSize = Math.max(MIN_FONT_SIZE, options.fontSize * Math.max(scale, .65));
|
|
2986
|
+
const lineHeight = fontSize * LINE_HEIGHT;
|
|
2987
|
+
const padX = Math.max(2, 4 * scale);
|
|
2988
|
+
const padY = Math.max(1.5, fontSize * .35);
|
|
2989
|
+
const footerHeight = fontSize * 2.5;
|
|
2990
|
+
const left = (column, lastColumn = column) => {
|
|
2991
|
+
let x = 0;
|
|
2992
|
+
for (let index = 0; index < column; index++) x += widths[index];
|
|
2993
|
+
if (!table.rightToLeft) return margin + x;
|
|
2994
|
+
let span = 0;
|
|
2995
|
+
for (let index = column; index <= lastColumn; index++) span += widths[index];
|
|
2996
|
+
return margin + contentWidth - x - span;
|
|
2997
|
+
};
|
|
2998
|
+
const spanWidth = (first, last) => {
|
|
2999
|
+
let width = 0;
|
|
3000
|
+
for (let index = first; index <= last; index++) width += widths[index];
|
|
3001
|
+
return width;
|
|
3002
|
+
};
|
|
3003
|
+
const headerCells = table.header.flatMap((cells, rowIndex) => cells.map((cell) => ({
|
|
3004
|
+
...cell,
|
|
3005
|
+
lines: wrapText(cell.text, spanWidth(cell.firstColumn, cell.lastColumn) - padX * 2, (text) => fonts.measure(text, true, fontSize)),
|
|
3006
|
+
rowIndex
|
|
3007
|
+
})));
|
|
3008
|
+
const headerHeights = table.header.map(() => lineHeight + padY * 2);
|
|
3009
|
+
for (const cell of headerCells.filter((cell) => cell.rowSpan === 1)) headerHeights[cell.rowIndex] = Math.max(headerHeights[cell.rowIndex], cell.lines.length * lineHeight + padY * 2);
|
|
3010
|
+
for (const cell of headerCells.filter((cell) => cell.rowSpan > 1)) {
|
|
3011
|
+
const last = Math.min(table.header.length - 1, cell.rowIndex + cell.rowSpan - 1);
|
|
3012
|
+
const spanned = headerHeights.slice(cell.rowIndex, last + 1).reduce((sum, height) => sum + height, 0);
|
|
3013
|
+
const needed = cell.lines.length * lineHeight + padY * 2;
|
|
3014
|
+
if (needed > spanned) headerHeights[last] += needed - spanned;
|
|
3015
|
+
}
|
|
3016
|
+
const headerHeight = headerHeights.reduce((sum, height) => sum + height, 0);
|
|
3017
|
+
const titleSize = fontSize * 1.5;
|
|
3018
|
+
const titleLines = options.title == null || options.title === "" ? [] : wrapText(options.title, contentWidth, (text) => fonts.measure(text, true, titleSize));
|
|
3019
|
+
const titleHeight = titleLines.length === 0 ? 0 : titleLines.length * titleSize * LINE_HEIGHT + fontSize;
|
|
3020
|
+
const bodyTop = (first) => pageHeight - margin - (first ? titleHeight : 0) - headerHeight;
|
|
3021
|
+
const bodyBottom = margin + footerHeight;
|
|
3022
|
+
const maxLines = Math.max(1, Math.floor((bodyTop(true) - bodyBottom - padY * 2) / lineHeight));
|
|
3023
|
+
const rows = table.rows.map((row) => {
|
|
3024
|
+
const cells = row.cells.map((text, column) => {
|
|
3025
|
+
const indent = column === table.treeColumn ? row.indent * TREE_INDENT * Math.max(scale, .65) : 0;
|
|
3026
|
+
return {
|
|
3027
|
+
indent,
|
|
3028
|
+
lines: wrapText(text, widths[column] - padX * 2 - indent, (line) => fonts.measure(line, false, fontSize), maxLines)
|
|
3029
|
+
};
|
|
3030
|
+
});
|
|
3031
|
+
return {
|
|
3032
|
+
cells,
|
|
3033
|
+
height: Math.max(1, ...cells.map((cell) => cell.lines.length)) * lineHeight + padY * 2
|
|
3034
|
+
};
|
|
3035
|
+
});
|
|
3036
|
+
const pageRows = [];
|
|
3037
|
+
let current = [];
|
|
3038
|
+
let y = bodyTop(true);
|
|
3039
|
+
for (const row of rows) {
|
|
3040
|
+
if (y - row.height < bodyBottom && current.length > 0) {
|
|
3041
|
+
pageRows.push(current);
|
|
3042
|
+
current = [];
|
|
3043
|
+
y = bodyTop(false);
|
|
3044
|
+
}
|
|
3045
|
+
current.push(row);
|
|
3046
|
+
y -= row.height;
|
|
3047
|
+
}
|
|
3048
|
+
pageRows.push(current);
|
|
3049
|
+
const textOps = (lines, x, width, top, height, align, bold, size = fontSize) => {
|
|
3050
|
+
const leading = size * LINE_HEIGHT;
|
|
3051
|
+
let lineTop = top - (height - lines.length * leading) / 2;
|
|
3052
|
+
const ops = [];
|
|
3053
|
+
for (const line of lines) {
|
|
3054
|
+
const runs = fonts.runs(line, bold);
|
|
3055
|
+
const lineWidth = runs.reduce((sum, run) => sum + run.width, 0) * size / 1e3;
|
|
3056
|
+
const physical = table.rightToLeft && align !== "center" ? align === "start" ? "end" : "start" : align;
|
|
3057
|
+
let runX = physical === "start" ? x : physical === "end" ? x + width - lineWidth : x + (width - lineWidth) / 2;
|
|
3058
|
+
const baseline = lineTop - (leading - size) / 2 - size * .8;
|
|
3059
|
+
for (const run of runs) {
|
|
3060
|
+
const stroke = run.face.fakeBold ? `2 Tr ${num(size * .03)} w ` : "";
|
|
3061
|
+
ops.push(`BT /${run.face.resource} ${num(size)} Tf ${stroke}1 0 0 1 ${num(runX)} ${num(baseline)} Tm ${run.face.encode(run.text)} Tj${stroke === "" ? "" : " 0 Tr"} ET`);
|
|
3062
|
+
runX += run.width * size / 1e3;
|
|
3063
|
+
}
|
|
3064
|
+
lineTop -= leading;
|
|
3065
|
+
}
|
|
3066
|
+
return ops.join("\n");
|
|
3067
|
+
};
|
|
3068
|
+
const pageCount = pageRows.length;
|
|
3069
|
+
return pageRows.map((bodyRows, pageIndex) => ({ draw: () => {
|
|
3070
|
+
const fills = [];
|
|
3071
|
+
const strokes = [];
|
|
3072
|
+
const texts = [];
|
|
3073
|
+
let top = pageHeight - margin;
|
|
3074
|
+
if (pageIndex === 0 && titleLines.length > 0) {
|
|
3075
|
+
texts.push(textOps(titleLines, margin, contentWidth, top, titleLines.length * titleSize * LINE_HEIGHT, "start", true, titleSize));
|
|
3076
|
+
top -= titleHeight;
|
|
3077
|
+
}
|
|
3078
|
+
const rowTops = [];
|
|
3079
|
+
for (const height of headerHeights) {
|
|
3080
|
+
rowTops.push(top);
|
|
3081
|
+
top -= height;
|
|
3082
|
+
}
|
|
3083
|
+
for (const cell of headerCells) {
|
|
3084
|
+
const last = Math.min(table.header.length - 1, cell.rowIndex + cell.rowSpan - 1);
|
|
3085
|
+
const height = headerHeights.slice(cell.rowIndex, last + 1).reduce((sum, value) => sum + value, 0);
|
|
3086
|
+
const x = left(cell.firstColumn, cell.lastColumn);
|
|
3087
|
+
const width = spanWidth(cell.firstColumn, cell.lastColumn);
|
|
3088
|
+
const cellTop = rowTops[cell.rowIndex];
|
|
3089
|
+
fills.push(`${num(x)} ${num(cellTop - height)} ${num(width)} ${num(height)} re`);
|
|
3090
|
+
strokes.push(`${num(x)} ${num(cellTop - height)} ${num(width)} ${num(height)} re`);
|
|
3091
|
+
texts.push(textOps(cell.lines, x + padX, width - padX * 2, cellTop - padY, height - padY * 2, cell.group ? "center" : "start", true));
|
|
3092
|
+
}
|
|
3093
|
+
for (const row of bodyRows) {
|
|
3094
|
+
row.cells.forEach((cell, column) => {
|
|
3095
|
+
const x = left(column);
|
|
3096
|
+
const width = widths[column];
|
|
3097
|
+
strokes.push(`${num(x)} ${num(top - row.height)} ${num(width)} ${num(row.height)} re`);
|
|
3098
|
+
const indentStart = table.rightToLeft ? 0 : cell.indent;
|
|
3099
|
+
const indentEnd = table.rightToLeft ? cell.indent : 0;
|
|
3100
|
+
texts.push(textOps(cell.lines, x + padX + indentStart, width - padX * 2 - indentStart - indentEnd, top - padY, row.height - padY * 2, table.alignments[column] ?? "start", false));
|
|
3101
|
+
});
|
|
3102
|
+
top -= row.height;
|
|
3103
|
+
}
|
|
3104
|
+
const pageNumber = `${pageIndex + 1} / ${pageCount}`;
|
|
3105
|
+
const footerWidth = fonts.measure(pageNumber, false, fontSize);
|
|
3106
|
+
texts.push(`BT /F1 ${num(fontSize)} Tf 1 0 0 1 ${num((pageWidth - footerWidth) / 2)} ${num(margin)} Tm ${new StandardFace("Helvetica", "F1").encode(pageNumber)} Tj ET`);
|
|
3107
|
+
return [
|
|
3108
|
+
`q ${HEADER_FILL}`,
|
|
3109
|
+
fills.length === 0 ? "" : `${fills.join("\n")}\nf`,
|
|
3110
|
+
`Q q ${BORDER_STROKE} 0.5 w`,
|
|
3111
|
+
strokes.length === 0 ? "" : `${strokes.join("\n")}\nS`,
|
|
3112
|
+
"Q 0 g",
|
|
3113
|
+
...texts
|
|
3114
|
+
].filter((part) => part !== "").join("\n");
|
|
3115
|
+
} }));
|
|
3116
|
+
}
|
|
3117
|
+
function wrapText(text, width, measure, maxLines = Number.POSITIVE_INFINITY) {
|
|
3118
|
+
const lines = [];
|
|
3119
|
+
for (const paragraph of text.split(/\r\n|\r|\n/)) {
|
|
3120
|
+
let line = "";
|
|
3121
|
+
for (const token of paragraph.match(TOKEN_PATTERN) ?? []) {
|
|
3122
|
+
const candidate = line + token;
|
|
3123
|
+
if (measure(candidate.trimEnd()) <= width || line.trim() === "") {
|
|
3124
|
+
if (line.trim() === "" && measure(token) > width && !/^\s+$/.test(token)) {
|
|
3125
|
+
for (const char of token) {
|
|
3126
|
+
if (line !== "" && measure(line + char) > width) {
|
|
3127
|
+
lines.push(line);
|
|
3128
|
+
line = "";
|
|
3129
|
+
}
|
|
3130
|
+
line += char;
|
|
3131
|
+
}
|
|
3132
|
+
continue;
|
|
3133
|
+
}
|
|
3134
|
+
line = line.trim() === "" && /^\s+$/.test(token) ? "" : candidate;
|
|
3135
|
+
continue;
|
|
3136
|
+
}
|
|
3137
|
+
lines.push(line.trimEnd());
|
|
3138
|
+
line = /^\s+$/.test(token) ? "" : token;
|
|
3139
|
+
if (measure(line) > width) {
|
|
3140
|
+
const chars = Array.from(line);
|
|
3141
|
+
line = "";
|
|
3142
|
+
for (const char of chars) {
|
|
3143
|
+
if (line !== "" && measure(line + char) > width) {
|
|
3144
|
+
lines.push(line);
|
|
3145
|
+
line = "";
|
|
3146
|
+
}
|
|
3147
|
+
line += char;
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
lines.push(line.trimEnd());
|
|
3152
|
+
}
|
|
3153
|
+
if (lines.length <= maxLines) return lines;
|
|
3154
|
+
const kept = lines.slice(0, maxLines);
|
|
3155
|
+
let last = kept[maxLines - 1];
|
|
3156
|
+
while (last !== "" && measure(`${last}…`) > width) last = Array.from(last).slice(0, -1).join("");
|
|
3157
|
+
kept[maxLines - 1] = `${last}…`;
|
|
3158
|
+
return kept;
|
|
3159
|
+
}
|
|
3160
|
+
var PdfObjectWriter = class {
|
|
3161
|
+
#encoder = new TextEncoder();
|
|
3162
|
+
#objects = [];
|
|
3163
|
+
add(body) {
|
|
3164
|
+
this.#objects.push(this.#encoder.encode(body));
|
|
3165
|
+
return this.#objects.length;
|
|
3166
|
+
}
|
|
3167
|
+
async addStream(entries, data, extra = "") {
|
|
3168
|
+
const compressed = await deflate(data);
|
|
3169
|
+
const content = compressed ?? data;
|
|
3170
|
+
const filter = compressed == null ? "" : " /Filter /FlateDecode";
|
|
3171
|
+
const head = this.#encoder.encode(`<< /Length ${content.length}${filter}${entries}${extra} >>\nstream\n`);
|
|
3172
|
+
const tail = this.#encoder.encode("\nendstream");
|
|
3173
|
+
const body = new Uint8Array(head.length + content.length + tail.length);
|
|
3174
|
+
body.set(head);
|
|
3175
|
+
body.set(content, head.length);
|
|
3176
|
+
body.set(tail, head.length + content.length);
|
|
3177
|
+
this.#objects.push(body);
|
|
3178
|
+
return this.#objects.length;
|
|
3179
|
+
}
|
|
3180
|
+
finish(root, info) {
|
|
3181
|
+
const parts = [];
|
|
3182
|
+
let offset = 0;
|
|
3183
|
+
const push = (part) => {
|
|
3184
|
+
parts.push(part);
|
|
3185
|
+
offset += part.length;
|
|
3186
|
+
};
|
|
3187
|
+
push(new Uint8Array([
|
|
3188
|
+
...this.#encoder.encode("%PDF-1.7\n%"),
|
|
3189
|
+
226,
|
|
3190
|
+
227,
|
|
3191
|
+
207,
|
|
3192
|
+
211,
|
|
3193
|
+
10
|
|
3194
|
+
]));
|
|
3195
|
+
const offsets = [];
|
|
3196
|
+
this.#objects.forEach((body, index) => {
|
|
3197
|
+
offsets.push(offset);
|
|
3198
|
+
push(this.#encoder.encode(`${index + 1} 0 obj\n`));
|
|
3199
|
+
push(body ?? this.#encoder.encode("null"));
|
|
3200
|
+
push(this.#encoder.encode("\nendobj\n"));
|
|
3201
|
+
});
|
|
3202
|
+
const xref = offset;
|
|
3203
|
+
const id = randomId();
|
|
3204
|
+
push(this.#encoder.encode(`xref\n0 ${this.#objects.length + 1}\n0000000000 65535 f \n` + offsets.map((value) => `${String(value).padStart(10, "0")} 00000 n \n`).join("") + `trailer\n<< /Size ${this.#objects.length + 1} /Root ${root} 0 R /Info ${info} 0 R /ID [<${id}> <${id}>] >>\nstartxref\n${xref}\n%%EOF\n`));
|
|
3205
|
+
const file = new Uint8Array(offset);
|
|
3206
|
+
let position = 0;
|
|
3207
|
+
for (const part of parts) {
|
|
3208
|
+
file.set(part, position);
|
|
3209
|
+
position += part.length;
|
|
3210
|
+
}
|
|
3211
|
+
return file;
|
|
3212
|
+
}
|
|
3213
|
+
reserve() {
|
|
3214
|
+
this.#objects.push(null);
|
|
3215
|
+
return this.#objects.length;
|
|
3216
|
+
}
|
|
3217
|
+
set(id, body) {
|
|
3218
|
+
this.#objects[id - 1] = this.#encoder.encode(body);
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3221
|
+
async function writeEmbeddedFont(writer, face) {
|
|
3222
|
+
const glyphs = [...face.used.keys()].sort((left, right) => left - right);
|
|
3223
|
+
const font = face.font;
|
|
3224
|
+
const name = `${subsetTag(glyphs)}+${font.postScriptName}`;
|
|
3225
|
+
const program = font.subset(glyphs);
|
|
3226
|
+
const file = await writer.addStream("", program, ` /Length1 ${program.length}`);
|
|
3227
|
+
const flags = 4 | (font.monospace ? 1 : 0) | (font.italicAngle !== 0 ? 64 : 0);
|
|
3228
|
+
const descriptor = writer.add(`<< /Type /FontDescriptor /FontName /${name} /Flags ${flags} /FontBBox [${font.bbox.join(" ")}] /ItalicAngle ${num(font.italicAngle)} /Ascent ${font.ascent} /Descent ${font.descent} /CapHeight ${font.capHeight} /StemV 80 /FontFile2 ${file} 0 R >>`);
|
|
3229
|
+
const widths = [];
|
|
3230
|
+
for (let index = 0; index < glyphs.length;) {
|
|
3231
|
+
const first = glyphs[index];
|
|
3232
|
+
const run = [];
|
|
3233
|
+
while (index < glyphs.length && glyphs[index] === first + run.length) {
|
|
3234
|
+
run.push(font.widthOf(glyphs[index]));
|
|
3235
|
+
index++;
|
|
3236
|
+
}
|
|
3237
|
+
widths.push(`${first} [${run.join(" ")}]`);
|
|
3238
|
+
}
|
|
3239
|
+
const cidFont = writer.add(`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /${name} /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${descriptor} 0 R /W [${widths.join(" ")}] /CIDToGIDMap /Identity >>`);
|
|
3240
|
+
const toUnicode = await writer.addStream("", new TextEncoder().encode(toUnicodeCMap(face.used)));
|
|
3241
|
+
return writer.add(`<< /Type /Font /Subtype /Type0 /BaseFont /${name} /Encoding /Identity-H /DescendantFonts [${cidFont} 0 R] /ToUnicode ${toUnicode} 0 R >>`);
|
|
3242
|
+
}
|
|
3243
|
+
function toUnicodeCMap(used) {
|
|
3244
|
+
const entries = [...used.entries()].sort(([left], [right]) => left - right);
|
|
3245
|
+
const blocks = [];
|
|
3246
|
+
for (let index = 0; index < entries.length; index += 100) {
|
|
3247
|
+
const block = entries.slice(index, index + 100);
|
|
3248
|
+
blocks.push(`${block.length} beginbfchar\n` + block.map(([glyph, text]) => `<${hex4(glyph)}> <${utf16Hex(text)}>`).join("\n") + `\nendbfchar`);
|
|
3249
|
+
}
|
|
3250
|
+
return "/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n" + blocks.join("\n") + "\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend";
|
|
3251
|
+
}
|
|
3252
|
+
async function deflate(data) {
|
|
3253
|
+
if (typeof CompressionStream === "undefined") return null;
|
|
3254
|
+
try {
|
|
3255
|
+
const stream = new Blob([data]).stream().pipeThrough(new CompressionStream("deflate"));
|
|
3256
|
+
return new Uint8Array(await new Response(stream).arrayBuffer());
|
|
3257
|
+
} catch {
|
|
3258
|
+
return null;
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
function hex2(value) {
|
|
3262
|
+
return value.toString(16).toUpperCase().padStart(2, "0");
|
|
3263
|
+
}
|
|
3264
|
+
function hex4(value) {
|
|
3265
|
+
return value.toString(16).toUpperCase().padStart(4, "0");
|
|
3266
|
+
}
|
|
3267
|
+
function num(value) {
|
|
3268
|
+
const rounded = Math.round(value * 100) / 100;
|
|
3269
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
3270
|
+
}
|
|
3271
|
+
function randomId() {
|
|
3272
|
+
const bytes = /* @__PURE__ */ new Uint8Array(16);
|
|
3273
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") crypto.getRandomValues(bytes);
|
|
3274
|
+
else for (let index = 0; index < bytes.length; index++) bytes[index] = Math.floor(Math.random() * 256);
|
|
3275
|
+
return Array.from(bytes, hex2).join("");
|
|
3276
|
+
}
|
|
3277
|
+
function subsetTag(glyphs) {
|
|
3278
|
+
let hash = 2166136261;
|
|
3279
|
+
for (const glyph of glyphs) hash = Math.imul(hash ^ glyph, 16777619) >>> 0;
|
|
3280
|
+
let tag = "";
|
|
3281
|
+
for (let index = 0; index < 6; index++) {
|
|
3282
|
+
tag += String.fromCharCode(65 + hash % 26);
|
|
3283
|
+
hash = Math.floor(hash / 26) + index * 7919;
|
|
3284
|
+
}
|
|
3285
|
+
return tag;
|
|
3286
|
+
}
|
|
3287
|
+
function toPdfDate(date) {
|
|
3288
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
3289
|
+
const offset = -date.getTimezoneOffset();
|
|
3290
|
+
const sign = offset >= 0 ? "+" : "-";
|
|
3291
|
+
return `D:${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}${sign}${pad(Math.floor(Math.abs(offset) / 60))}'${pad(Math.abs(offset) % 60)}'`;
|
|
3292
|
+
}
|
|
3293
|
+
function toTextString(text) {
|
|
3294
|
+
return `<FEFF${utf16Hex(text)}>`;
|
|
3295
|
+
}
|
|
3296
|
+
function utf16Hex(text) {
|
|
3297
|
+
let hex = "";
|
|
3298
|
+
for (let index = 0; index < text.length; index++) hex += hex4(text.charCodeAt(index));
|
|
3299
|
+
return hex;
|
|
3300
|
+
}
|
|
3301
|
+
const TRUETYPE_VERSION = 65536;
|
|
3302
|
+
const TRUE_TAG = 1953658213;
|
|
3303
|
+
const COLLECTION_TAG = 1953784678;
|
|
3304
|
+
const OPENTYPE_CFF_TAG = 1330926671;
|
|
3305
|
+
const WOFF_TAG = 2001684038;
|
|
3306
|
+
const WOFF2_TAG = 2001684018;
|
|
3307
|
+
const SUBSET_TABLES = [
|
|
3308
|
+
"cvt ",
|
|
3309
|
+
"fpgm",
|
|
3310
|
+
"glyf",
|
|
3311
|
+
"head",
|
|
3312
|
+
"hhea",
|
|
3313
|
+
"hmtx",
|
|
3314
|
+
"loca",
|
|
3315
|
+
"maxp",
|
|
3316
|
+
"prep"
|
|
3317
|
+
];
|
|
3318
|
+
function parseTrueTypeFont(data, collectionIndex = 0) {
|
|
3319
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
3320
|
+
let fontOffset = 0;
|
|
3321
|
+
const tag = readUint32(view, 0);
|
|
3322
|
+
if (tag === COLLECTION_TAG) {
|
|
3323
|
+
const count = readUint32(view, 8);
|
|
3324
|
+
if (collectionIndex < 0 || collectionIndex >= count) throw new Error(`The font collection has ${count} fonts; there's no font ${collectionIndex}.`);
|
|
3325
|
+
fontOffset = readUint32(view, 12 + collectionIndex * 4);
|
|
3326
|
+
} else if (tag === OPENTYPE_CFF_TAG) throw new Error("The font has CFF outlines (.otf). Use a TrueType font (.ttf or .ttc) instead.");
|
|
3327
|
+
else if (tag === WOFF_TAG || tag === WOFF2_TAG) throw new Error("The font is a web font (WOFF). Use a TrueType font (.ttf or .ttc) instead.");
|
|
3328
|
+
const version = readUint32(view, fontOffset);
|
|
3329
|
+
if (version === OPENTYPE_CFF_TAG) throw new Error("The font has CFF outlines (.otf). Use a TrueType font (.ttf or .ttc) instead.");
|
|
3330
|
+
if (version !== TRUETYPE_VERSION && version !== TRUE_TAG) throw new Error("The data isn't a TrueType font.");
|
|
3331
|
+
const tables = /* @__PURE__ */ new Map();
|
|
3332
|
+
const tableCount = view.getUint16(fontOffset + 4);
|
|
3333
|
+
for (let index = 0; index < tableCount; index++) {
|
|
3334
|
+
const record = fontOffset + 12 + index * 16;
|
|
3335
|
+
const name = String.fromCharCode(data[record], data[record + 1], data[record + 2], data[record + 3]);
|
|
3336
|
+
tables.set(name, {
|
|
3337
|
+
length: readUint32(view, record + 12),
|
|
3338
|
+
offset: readUint32(view, record + 8)
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
for (const required of [
|
|
3342
|
+
"cmap",
|
|
3343
|
+
"glyf",
|
|
3344
|
+
"head",
|
|
3345
|
+
"hhea",
|
|
3346
|
+
"hmtx",
|
|
3347
|
+
"loca",
|
|
3348
|
+
"maxp"
|
|
3349
|
+
]) if (!tables.has(required)) throw new Error(`The font has no '${required}' table, which a TrueType font needs.`);
|
|
3350
|
+
const table = (name) => tables.get(name);
|
|
3351
|
+
const head = table("head").offset;
|
|
3352
|
+
const scale = 1e3 / view.getUint16(head + 18);
|
|
3353
|
+
const longLoca = view.getInt16(head + 50) === 1;
|
|
3354
|
+
const bbox = [
|
|
3355
|
+
Math.round(view.getInt16(head + 36) * scale),
|
|
3356
|
+
Math.round(view.getInt16(head + 38) * scale),
|
|
3357
|
+
Math.round(view.getInt16(head + 40) * scale),
|
|
3358
|
+
Math.round(view.getInt16(head + 42) * scale)
|
|
3359
|
+
];
|
|
3360
|
+
const numGlyphs = view.getUint16(table("maxp").offset + 4);
|
|
3361
|
+
const hhea = table("hhea").offset;
|
|
3362
|
+
const numberOfHMetrics = view.getUint16(hhea + 34);
|
|
3363
|
+
let ascent = view.getInt16(hhea + 4) * scale;
|
|
3364
|
+
let descent = view.getInt16(hhea + 6) * scale;
|
|
3365
|
+
let capHeight = ascent * .7;
|
|
3366
|
+
const os2 = tables.get("OS/2");
|
|
3367
|
+
if (os2 != null && os2.length >= 72) {
|
|
3368
|
+
ascent = view.getInt16(os2.offset + 68) * scale;
|
|
3369
|
+
descent = view.getInt16(os2.offset + 70) * scale;
|
|
3370
|
+
if (view.getUint16(os2.offset) >= 2 && os2.length >= 90) capHeight = view.getInt16(os2.offset + 88) * scale || capHeight;
|
|
3371
|
+
}
|
|
3372
|
+
const post = tables.get("post");
|
|
3373
|
+
const italicAngle = post == null ? 0 : view.getInt32(post.offset + 4) / 65536;
|
|
3374
|
+
const monospace = post != null && post.length >= 16 && readUint32(view, post.offset + 12) !== 0;
|
|
3375
|
+
const hmtx = table("hmtx").offset;
|
|
3376
|
+
const lastAdvance = view.getUint16(hmtx + (numberOfHMetrics - 1) * 4);
|
|
3377
|
+
const widthOf = (glyph) => {
|
|
3378
|
+
if (glyph < 0 || glyph >= numGlyphs) return 0;
|
|
3379
|
+
const advance = glyph < numberOfHMetrics ? view.getUint16(hmtx + glyph * 4) : lastAdvance;
|
|
3380
|
+
return Math.round(advance * scale);
|
|
3381
|
+
};
|
|
3382
|
+
const loca = table("loca").offset;
|
|
3383
|
+
const glyphRange = (glyph) => {
|
|
3384
|
+
if (longLoca) return [readUint32(view, loca + glyph * 4), readUint32(view, loca + glyph * 4 + 4)];
|
|
3385
|
+
return [view.getUint16(loca + glyph * 2) * 2, view.getUint16(loca + glyph * 2 + 2) * 2];
|
|
3386
|
+
};
|
|
3387
|
+
const glyphOf = createCharacterMap(view, table("cmap").offset);
|
|
3388
|
+
return {
|
|
3389
|
+
ascent: Math.round(ascent),
|
|
3390
|
+
bbox,
|
|
3391
|
+
capHeight: Math.round(capHeight),
|
|
3392
|
+
descent: Math.round(descent),
|
|
3393
|
+
glyphOf: (codePoint) => {
|
|
3394
|
+
const glyph = glyphOf(codePoint);
|
|
3395
|
+
return glyph < numGlyphs ? glyph : 0;
|
|
3396
|
+
},
|
|
3397
|
+
italicAngle,
|
|
3398
|
+
monospace,
|
|
3399
|
+
numGlyphs,
|
|
3400
|
+
postScriptName: readPostScriptName(view, tables.get("name")) ?? "Font",
|
|
3401
|
+
subset: (glyphs) => writeSubset(data, tables, numGlyphs, glyphRange, table("glyf").offset, withComponents(glyphs)),
|
|
3402
|
+
widthOf
|
|
3403
|
+
};
|
|
3404
|
+
function withComponents(glyphs) {
|
|
3405
|
+
const result = /* @__PURE__ */ new Set([0]);
|
|
3406
|
+
const pending = [...glyphs];
|
|
3407
|
+
const glyf = table("glyf").offset;
|
|
3408
|
+
while (pending.length > 0) {
|
|
3409
|
+
const glyph = pending.pop();
|
|
3410
|
+
if (glyph < 0 || glyph >= numGlyphs || result.has(glyph) && glyph !== 0) continue;
|
|
3411
|
+
result.add(glyph);
|
|
3412
|
+
const [start, end] = glyphRange(glyph);
|
|
3413
|
+
if (end - start < 10 || view.getInt16(glyf + start) >= 0) continue;
|
|
3414
|
+
let position = glyf + start + 10;
|
|
3415
|
+
for (;;) {
|
|
3416
|
+
const flags = view.getUint16(position);
|
|
3417
|
+
pending.push(view.getUint16(position + 2));
|
|
3418
|
+
position += 4 + (flags & 1 ? 4 : 2);
|
|
3419
|
+
if (flags & 8) position += 2;
|
|
3420
|
+
else if (flags & 64) position += 4;
|
|
3421
|
+
else if (flags & 128) position += 8;
|
|
3422
|
+
if (!(flags & 32)) break;
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
return result;
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
function createCharacterMap(view, cmap) {
|
|
3429
|
+
const count = view.getUint16(cmap + 2);
|
|
3430
|
+
let format4 = null;
|
|
3431
|
+
let format12 = null;
|
|
3432
|
+
for (let index = 0; index < count; index++) {
|
|
3433
|
+
const record = cmap + 4 + index * 8;
|
|
3434
|
+
const platform = view.getUint16(record);
|
|
3435
|
+
const encoding = view.getUint16(record + 2);
|
|
3436
|
+
const offset = cmap + readUint32(view, record + 4);
|
|
3437
|
+
const format = view.getUint16(offset);
|
|
3438
|
+
if (!(platform === 0 || platform === 3 && (encoding === 1 || encoding === 10))) continue;
|
|
3439
|
+
if (format === 12 && format12 == null) format12 = offset;
|
|
3440
|
+
else if (format === 4 && format4 == null) format4 = offset;
|
|
3441
|
+
}
|
|
3442
|
+
if (format12 != null) {
|
|
3443
|
+
const groups = readUint32(view, format12 + 12);
|
|
3444
|
+
return (codePoint) => {
|
|
3445
|
+
let low = 0;
|
|
3446
|
+
let high = groups - 1;
|
|
3447
|
+
while (low <= high) {
|
|
3448
|
+
const middle = low + high >> 1;
|
|
3449
|
+
const group = format12 + 16 + middle * 12;
|
|
3450
|
+
const start = readUint32(view, group);
|
|
3451
|
+
const end = readUint32(view, group + 4);
|
|
3452
|
+
if (codePoint < start) high = middle - 1;
|
|
3453
|
+
else if (codePoint > end) low = middle + 1;
|
|
3454
|
+
else return readUint32(view, group + 8) + (codePoint - start);
|
|
3455
|
+
}
|
|
3456
|
+
return 0;
|
|
3457
|
+
};
|
|
3458
|
+
}
|
|
3459
|
+
if (format4 != null) {
|
|
3460
|
+
const segments = view.getUint16(format4 + 6) / 2;
|
|
3461
|
+
const ends = format4 + 14;
|
|
3462
|
+
const starts = ends + segments * 2 + 2;
|
|
3463
|
+
const deltas = starts + segments * 2;
|
|
3464
|
+
const rangeOffsets = deltas + segments * 2;
|
|
3465
|
+
return (codePoint) => {
|
|
3466
|
+
if (codePoint > 65535) return 0;
|
|
3467
|
+
let low = 0;
|
|
3468
|
+
let high = segments - 1;
|
|
3469
|
+
while (low <= high) {
|
|
3470
|
+
const middle = low + high >> 1;
|
|
3471
|
+
const end = view.getUint16(ends + middle * 2);
|
|
3472
|
+
const start = view.getUint16(starts + middle * 2);
|
|
3473
|
+
if (codePoint > end) low = middle + 1;
|
|
3474
|
+
else if (codePoint < start) high = middle - 1;
|
|
3475
|
+
else {
|
|
3476
|
+
const delta = view.getInt16(deltas + middle * 2);
|
|
3477
|
+
const rangeOffset = view.getUint16(rangeOffsets + middle * 2);
|
|
3478
|
+
if (rangeOffset === 0) return codePoint + delta & 65535;
|
|
3479
|
+
const glyphAddress = rangeOffsets + middle * 2 + rangeOffset + (codePoint - start) * 2;
|
|
3480
|
+
const glyph = view.getUint16(glyphAddress);
|
|
3481
|
+
return glyph === 0 ? 0 : glyph + delta & 65535;
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
return 0;
|
|
3485
|
+
};
|
|
3486
|
+
}
|
|
3487
|
+
throw new Error("The font has no Unicode character map.");
|
|
3488
|
+
}
|
|
3489
|
+
function readPostScriptName(view, name) {
|
|
3490
|
+
if (name == null) return null;
|
|
3491
|
+
const count = view.getUint16(name.offset + 2);
|
|
3492
|
+
const strings = name.offset + view.getUint16(name.offset + 4);
|
|
3493
|
+
for (let index = 0; index < count; index++) {
|
|
3494
|
+
const record = name.offset + 6 + index * 12;
|
|
3495
|
+
if (view.getUint16(record + 6) !== 6) continue;
|
|
3496
|
+
const platform = view.getUint16(record);
|
|
3497
|
+
const length = view.getUint16(record + 8);
|
|
3498
|
+
const offset = strings + view.getUint16(record + 10);
|
|
3499
|
+
let text = "";
|
|
3500
|
+
if (platform === 3 || platform === 0) for (let char = 0; char + 1 < length; char += 2) text += String.fromCharCode(view.getUint16(offset + char));
|
|
3501
|
+
else for (let char = 0; char < length; char++) text += String.fromCharCode(view.getUint8(offset + char));
|
|
3502
|
+
const cleaned = text.replace(/[^\x21-\x7e]|[()<>[\]{}/%#]/g, "");
|
|
3503
|
+
if (cleaned !== "") return cleaned;
|
|
3504
|
+
}
|
|
3505
|
+
return null;
|
|
3506
|
+
}
|
|
3507
|
+
function readUint32(view, offset) {
|
|
3508
|
+
return view.getUint32(offset);
|
|
3509
|
+
}
|
|
3510
|
+
function tableChecksum(bytes) {
|
|
3511
|
+
const padded = new Uint8Array(Math.ceil(bytes.length / 4) * 4);
|
|
3512
|
+
padded.set(bytes);
|
|
3513
|
+
const view = new DataView(padded.buffer);
|
|
3514
|
+
let sum = 0;
|
|
3515
|
+
for (let offset = 0; offset < padded.length; offset += 4) sum = sum + view.getUint32(offset) >>> 0;
|
|
3516
|
+
return sum;
|
|
3517
|
+
}
|
|
3518
|
+
function writeSubset(data, tables, numGlyphs, glyphRange, glyf, glyphs) {
|
|
3519
|
+
const parts = [];
|
|
3520
|
+
const loca = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer((numGlyphs + 1) * 4));
|
|
3521
|
+
let glyfLength = 0;
|
|
3522
|
+
for (let glyph = 0; glyph < numGlyphs; glyph++) {
|
|
3523
|
+
loca.setUint32(glyph * 4, glyfLength);
|
|
3524
|
+
if (!glyphs.has(glyph)) continue;
|
|
3525
|
+
const [start, end] = glyphRange(glyph);
|
|
3526
|
+
if (end <= start) continue;
|
|
3527
|
+
const outline = data.subarray(glyf + start, glyf + end);
|
|
3528
|
+
const paddedLength = Math.ceil(outline.length / 4) * 4;
|
|
3529
|
+
const padded = new Uint8Array(paddedLength);
|
|
3530
|
+
padded.set(outline);
|
|
3531
|
+
parts.push(padded);
|
|
3532
|
+
glyfLength += paddedLength;
|
|
3533
|
+
}
|
|
3534
|
+
loca.setUint32(numGlyphs * 4, glyfLength);
|
|
3535
|
+
const glyfBytes = new Uint8Array(glyfLength);
|
|
3536
|
+
let position = 0;
|
|
3537
|
+
for (const part of parts) {
|
|
3538
|
+
glyfBytes.set(part, position);
|
|
3539
|
+
position += part.length;
|
|
3540
|
+
}
|
|
3541
|
+
const output = /* @__PURE__ */ new Map();
|
|
3542
|
+
for (const name of SUBSET_TABLES) {
|
|
3543
|
+
const record = tables.get(name);
|
|
3544
|
+
if (name === "glyf") output.set(name, glyfBytes);
|
|
3545
|
+
else if (name === "loca") output.set(name, new Uint8Array(loca.buffer));
|
|
3546
|
+
else if (record != null) output.set(name, data.slice(record.offset, record.offset + record.length));
|
|
3547
|
+
}
|
|
3548
|
+
const head = output.get("head");
|
|
3549
|
+
const headView = new DataView(head.buffer, head.byteOffset, head.byteLength);
|
|
3550
|
+
headView.setUint32(8, 0);
|
|
3551
|
+
headView.setInt16(50, 1);
|
|
3552
|
+
const names = [...output.keys()].sort();
|
|
3553
|
+
const headerLength = 12 + names.length * 16;
|
|
3554
|
+
let fileLength = headerLength;
|
|
3555
|
+
for (const name of names) fileLength += Math.ceil(output.get(name).length / 4) * 4;
|
|
3556
|
+
const file = new Uint8Array(fileLength);
|
|
3557
|
+
const fileView = new DataView(file.buffer);
|
|
3558
|
+
const entrySelector = Math.floor(Math.log2(names.length));
|
|
3559
|
+
const searchRange = 2 ** entrySelector * 16;
|
|
3560
|
+
fileView.setUint32(0, TRUETYPE_VERSION);
|
|
3561
|
+
fileView.setUint16(4, names.length);
|
|
3562
|
+
fileView.setUint16(6, searchRange);
|
|
3563
|
+
fileView.setUint16(8, entrySelector);
|
|
3564
|
+
fileView.setUint16(10, names.length * 16 - searchRange);
|
|
3565
|
+
let offset = headerLength;
|
|
3566
|
+
let headOffset = 0;
|
|
3567
|
+
names.forEach((name, index) => {
|
|
3568
|
+
const bytes = output.get(name);
|
|
3569
|
+
const record = 12 + index * 16;
|
|
3570
|
+
for (let char = 0; char < 4; char++) file[record + char] = name.charCodeAt(char);
|
|
3571
|
+
fileView.setUint32(record + 4, tableChecksum(bytes));
|
|
3572
|
+
fileView.setUint32(record + 8, offset);
|
|
3573
|
+
fileView.setUint32(record + 12, bytes.length);
|
|
3574
|
+
file.set(bytes, offset);
|
|
3575
|
+
if (name === "head") headOffset = offset;
|
|
3576
|
+
offset += Math.ceil(bytes.length / 4) * 4;
|
|
3577
|
+
});
|
|
3578
|
+
fileView.setUint32(headOffset + 8, 2981146554 - tableChecksum(file) >>> 0);
|
|
3579
|
+
return file;
|
|
3580
|
+
}
|
|
2077
3581
|
const LOCAL_HEADER_SIGNATURE = 67324752;
|
|
2078
3582
|
const CENTRAL_HEADER_SIGNATURE = 33639248;
|
|
2079
3583
|
const END_OF_CENTRAL_DIRECTORY_SIGNATURE = 101010256;
|
|
@@ -2186,6 +3690,8 @@ function toDosDateTime(value) {
|
|
|
2186
3690
|
const XLSX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
2187
3691
|
const MAX_CELL_TEXT_LENGTH = 32767;
|
|
2188
3692
|
const MAX_SHEET_NAME_LENGTH = 31;
|
|
3693
|
+
const MAX_INDENT = 15;
|
|
3694
|
+
const MAX_OUTLINE_LEVEL = 7;
|
|
2189
3695
|
const MAX_DIGIT_WIDTH = 7;
|
|
2190
3696
|
const MILLISECONDS_PER_DAY = 864e5;
|
|
2191
3697
|
const EXCEL_EPOCH = Date.UTC(1899, 11, 30);
|
|
@@ -2198,6 +3704,7 @@ const STYLE_INDEX = {
|
|
|
2198
3704
|
group: 2,
|
|
2199
3705
|
header: 1
|
|
2200
3706
|
};
|
|
3707
|
+
const FIRST_INDENT_STYLE_INDEX = 4;
|
|
2201
3708
|
async function writeXlsx(sheet) {
|
|
2202
3709
|
const encoder = new TextEncoder();
|
|
2203
3710
|
return createZip([
|
|
@@ -2205,7 +3712,7 @@ async function writeXlsx(sheet) {
|
|
|
2205
3712
|
["_rels/.rels", rootRelationshipsXml()],
|
|
2206
3713
|
["xl/workbook.xml", workbookXml(toSheetName(sheet.name))],
|
|
2207
3714
|
["xl/_rels/workbook.xml.rels", workbookRelationshipsXml()],
|
|
2208
|
-
["xl/styles.xml", stylesXml()],
|
|
3715
|
+
["xl/styles.xml", stylesXml(maxIndent(sheet))],
|
|
2209
3716
|
["xl/worksheets/sheet1.xml", worksheetXml(sheet)]
|
|
2210
3717
|
].map(([name, xml]) => ({
|
|
2211
3718
|
data: encoder.encode(xml),
|
|
@@ -2227,7 +3734,9 @@ function toSheetName(name) {
|
|
|
2227
3734
|
}
|
|
2228
3735
|
function cellXml(cell, reference) {
|
|
2229
3736
|
const value = cell.value;
|
|
2230
|
-
const
|
|
3737
|
+
const indent = toIndent(cell.indent);
|
|
3738
|
+
const styleIndex = cell.style != null ? STYLE_INDEX[cell.style] : indent > 0 ? FIRST_INDENT_STYLE_INDEX + indent - 1 : null;
|
|
3739
|
+
const style = styleIndex == null ? "" : ` s="${styleIndex}"`;
|
|
2231
3740
|
if (value == null) return style === "" ? "" : `<c r="${reference}"${style}/>`;
|
|
2232
3741
|
if (typeof value === "number") return Number.isFinite(value) ? `<c r="${reference}"${style}><v>${value}</v></c>` : "";
|
|
2233
3742
|
if (typeof value === "boolean") return `<c r="${reference}"${style} t="b"><v>${value ? 1 : 0}</v></c>`;
|
|
@@ -2244,6 +3753,11 @@ function contentTypesXml() {
|
|
|
2244
3753
|
function escapeXml(text) {
|
|
2245
3754
|
return text.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "").replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2246
3755
|
}
|
|
3756
|
+
function maxIndent(sheet) {
|
|
3757
|
+
let deepest = 0;
|
|
3758
|
+
for (const row of sheet.rows) for (const cell of row) deepest = Math.max(deepest, toIndent(cell?.indent));
|
|
3759
|
+
return deepest;
|
|
3760
|
+
}
|
|
2247
3761
|
function rootRelationshipsXml() {
|
|
2248
3762
|
return XML_DECLARATION + `<Relationships xmlns="${PACKAGE_RELATIONSHIP_NAMESPACE}"><Relationship Id="rId1" Type="${RELATIONSHIP_NAMESPACE}/officeDocument" Target="xl/workbook.xml"/></Relationships>`;
|
|
2249
3763
|
}
|
|
@@ -2257,9 +3771,13 @@ function sheetViewXml(sheet) {
|
|
|
2257
3771
|
const topLeft = `${toColumnName(columns)}${rows + 1}`;
|
|
2258
3772
|
return `<sheetViews><sheetView workbookViewId="0"${rightToLeft}><pane${split} topLeftCell="${topLeft}" activePane="${pane}" state="frozen"/><selection pane="${pane}" activeCell="${topLeft}" sqref="${topLeft}"/></sheetView></sheetViews>`;
|
|
2259
3773
|
}
|
|
2260
|
-
function stylesXml() {
|
|
3774
|
+
function stylesXml(indents) {
|
|
2261
3775
|
const font = `<sz val="11"/><name val="Calibri"/><family val="2"/>`;
|
|
2262
|
-
|
|
3776
|
+
const indentStyles = Array.from({ length: indents }, (_, index) => `<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment indent="${index + 1}"/></xf>`).join("");
|
|
3777
|
+
return XML_DECLARATION + `<styleSheet xmlns="${SPREADSHEET_NAMESPACE}"><fonts count="2"><font>${font}</font><font><b/>${font}</font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${FIRST_INDENT_STYLE_INDEX + indents}"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1" applyAlignment="1"><alignment horizontal="center"/></xf><xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>` + indentStyles + "</cellXfs><cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles></styleSheet>";
|
|
3778
|
+
}
|
|
3779
|
+
function toIndent(indent) {
|
|
3780
|
+
return indent == null || !Number.isFinite(indent) ? 0 : Math.min(MAX_INDENT, Math.max(0, Math.floor(indent)));
|
|
2263
3781
|
}
|
|
2264
3782
|
function toColumnWidth(pixels) {
|
|
2265
3783
|
return Math.max(0, Math.round((pixels - 5) / MAX_DIGIT_WIDTH * 100) / 100);
|
|
@@ -2277,14 +3795,20 @@ function worksheetXml(sheet) {
|
|
|
2277
3795
|
const columns = sheet.columnWidths.map((width, index) => width == null ? "" : `<col min="${index + 1}" max="${index + 1}" width="${toColumnWidth(width)}" customWidth="1"/>`).join("");
|
|
2278
3796
|
const rows = sheet.rows.map((row, rowIndex) => {
|
|
2279
3797
|
const cells = row.map((cell, columnIndex) => cell == null ? "" : cellXml(cell, `${toColumnName(columnIndex)}${rowIndex + 1}`)).join("");
|
|
2280
|
-
|
|
3798
|
+
if (cells === "") return "";
|
|
3799
|
+
const level = Math.min(MAX_OUTLINE_LEVEL, Math.max(0, Math.floor(sheet.rowOutlineLevels?.[rowIndex] ?? 0)));
|
|
3800
|
+
const outline = level > 0 ? ` outlineLevel="${level}"` : "";
|
|
3801
|
+
return `<row r="${rowIndex + 1}"${outline}>${cells}</row>`;
|
|
2281
3802
|
}).join("");
|
|
3803
|
+
const deepestOutline = (sheet.rowOutlineLevels ?? []).reduce((deepest, level) => Math.max(deepest, Math.min(MAX_OUTLINE_LEVEL, Math.floor(level))), 0);
|
|
2282
3804
|
const merges = sheet.merges.length === 0 ? "" : `<mergeCells count="${sheet.merges.length}">` + sheet.merges.map((merge) => `<mergeCell ref="${toColumnName(merge.firstColumn)}${merge.firstRow + 1}:${toColumnName(merge.lastColumn)}${merge.lastRow + 1}"/>`).join("") + `</mergeCells>`;
|
|
2283
|
-
return XML_DECLARATION + `<worksheet xmlns="${SPREADSHEET_NAMESPACE}" xmlns:r="${RELATIONSHIP_NAMESPACE}"><dimension ref="${dimension}"/>` + sheetViewXml(sheet) + `<sheetFormatPr defaultRowHeight="15"/>` + (columns === "" ? "" : `<cols>${columns}</cols>`) + `<sheetData>${rows}</sheetData>` + merges + `</worksheet>`;
|
|
3805
|
+
return XML_DECLARATION + `<worksheet xmlns="${SPREADSHEET_NAMESPACE}" xmlns:r="${RELATIONSHIP_NAMESPACE}">` + (deepestOutline > 0 ? `<sheetPr><outlinePr summaryBelow="0"/></sheetPr>` : "") + `<dimension ref="${dimension}"/>` + sheetViewXml(sheet) + `<sheetFormatPr defaultRowHeight="15"${deepestOutline > 0 ? ` outlineLevelRow="${deepestOutline}"` : ""}/>` + (columns === "" ? "" : `<cols>${columns}</cols>`) + `<sheetData>${rows}</sheetData>` + merges + `</worksheet>`;
|
|
2284
3806
|
}
|
|
2285
3807
|
var GridExportService = class GridExportService {
|
|
2286
3808
|
#document = inject(DOCUMENT$1);
|
|
2287
3809
|
#gridService = inject(GridService);
|
|
3810
|
+
#i18n = inject(MonaI18nService);
|
|
3811
|
+
#locale = inject(LOCALE_ID);
|
|
2288
3812
|
#platformId = inject(PLATFORM_ID);
|
|
2289
3813
|
exportCsv(filename) {
|
|
2290
3814
|
if (!isPlatformBrowser(this.#platformId)) return;
|
|
@@ -2292,7 +3816,7 @@ var GridExportService = class GridExportService {
|
|
|
2292
3816
|
if (columns.length === 0) return;
|
|
2293
3817
|
const header = columns.map((c) => this.#escapeCsvValue(c.title)).join(",");
|
|
2294
3818
|
const rowLines = [];
|
|
2295
|
-
this.#gridService.
|
|
3819
|
+
this.#gridService.getExportRows().forEach((row) => {
|
|
2296
3820
|
const line = columns.map((col) => this.#formatValue(row.data[col.field], col.dataType)).join(",");
|
|
2297
3821
|
rowLines.push(line);
|
|
2298
3822
|
});
|
|
@@ -2307,6 +3831,76 @@ var GridExportService = class GridExportService {
|
|
|
2307
3831
|
const workbook = await writeXlsx(this.#createSheet(columns, name.replace(/\.xlsx$/i, "")));
|
|
2308
3832
|
this.#download(new Blob([workbook], { type: XLSX_MIME_TYPE }), name);
|
|
2309
3833
|
}
|
|
3834
|
+
async exportPdf(options = {}) {
|
|
3835
|
+
if (!isPlatformBrowser(this.#platformId)) return;
|
|
3836
|
+
const settings = typeof options === "string" ? { filename: options } : options;
|
|
3837
|
+
const columns = this.#exportedColumns();
|
|
3838
|
+
if (columns.length === 0) return;
|
|
3839
|
+
const font = settings.font;
|
|
3840
|
+
const [regular, bold] = await Promise.all([font == null ? null : this.#loadFont(font.regular), font?.bold == null ? null : this.#loadFont(font.bold)]);
|
|
3841
|
+
const [width, height] = toPageSize(settings.paperSize ?? "A4");
|
|
3842
|
+
const landscape = settings.orientation === "landscape";
|
|
3843
|
+
const pdf = await writePdfTable(this.#createPdfTable(columns), {
|
|
3844
|
+
fontSize: settings.fontSize ?? 9,
|
|
3845
|
+
fonts: {
|
|
3846
|
+
bold: bold == null ? null : parseTrueTypeFont(bold, font?.collectionIndex),
|
|
3847
|
+
regular: regular == null ? null : parseTrueTypeFont(regular, font?.collectionIndex)
|
|
3848
|
+
},
|
|
3849
|
+
margin: settings.margin ?? 36,
|
|
3850
|
+
modified: /* @__PURE__ */ new Date(),
|
|
3851
|
+
pageSize: landscape ? [Math.max(width, height), Math.min(width, height)] : [width, height],
|
|
3852
|
+
title: settings.title ?? null
|
|
3853
|
+
});
|
|
3854
|
+
this.#download(new Blob([pdf], { type: PDF_MIME_TYPE }), settings.filename ?? "export.pdf");
|
|
3855
|
+
}
|
|
3856
|
+
#createPdfTable(columns) {
|
|
3857
|
+
const depth = getColumnGroupDepth(columns);
|
|
3858
|
+
const header = Array.from({ length: depth + 1 }, () => []);
|
|
3859
|
+
for (let level = 0; level < depth; level++) {
|
|
3860
|
+
let start = 0;
|
|
3861
|
+
for (let index = 1; index <= columns.length; index++) {
|
|
3862
|
+
const group = getColumnGroups(columns[start])[level];
|
|
3863
|
+
if (index < columns.length && group != null && getColumnGroups(columns[index])[level]?.id === group.id) continue;
|
|
3864
|
+
if (group != null) header[level].push({
|
|
3865
|
+
firstColumn: start,
|
|
3866
|
+
group: true,
|
|
3867
|
+
lastColumn: index - 1,
|
|
3868
|
+
rowSpan: 1,
|
|
3869
|
+
text: group.title
|
|
3870
|
+
});
|
|
3871
|
+
start = index;
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
for (const [index, column] of columns.entries()) {
|
|
3875
|
+
const titleRow = getColumnGroups(column).length;
|
|
3876
|
+
header[titleRow].push({
|
|
3877
|
+
firstColumn: index,
|
|
3878
|
+
group: false,
|
|
3879
|
+
lastColumn: index,
|
|
3880
|
+
rowSpan: depth - titleRow + 1,
|
|
3881
|
+
text: column.title
|
|
3882
|
+
});
|
|
3883
|
+
}
|
|
3884
|
+
const locales = {
|
|
3885
|
+
angularLocale: this.#locale,
|
|
3886
|
+
localeId: this.#i18n.localeId()
|
|
3887
|
+
};
|
|
3888
|
+
const treeColumnId = this.#gridService.treeColumnId();
|
|
3889
|
+
const treeColumn = columns.findIndex((column) => column.id === treeColumnId);
|
|
3890
|
+
const headerTable = this.#gridService.headerTableElement();
|
|
3891
|
+
const view = headerTable?.ownerDocument.defaultView;
|
|
3892
|
+
return {
|
|
3893
|
+
alignments: columns.map((column) => column.dataType === "number" ? "end" : "start"),
|
|
3894
|
+
columnWidths: columns.map((column) => column.calculatedWidth ?? column.width ?? DEFAULT_PDF_COLUMN_WIDTH),
|
|
3895
|
+
header,
|
|
3896
|
+
rightToLeft: headerTable != null && view?.getComputedStyle(headerTable).direction === "rtl",
|
|
3897
|
+
rows: this.#gridService.getExportRows().map((row) => ({
|
|
3898
|
+
cells: columns.map((column) => getGridCellText(row.data, column, locales)),
|
|
3899
|
+
indent: (this.#gridService.getTreeRowInfo(row)?.level ?? 1) - 1
|
|
3900
|
+
})),
|
|
3901
|
+
treeColumn: treeColumn < 0 ? null : treeColumn
|
|
3902
|
+
};
|
|
3903
|
+
}
|
|
2310
3904
|
#createSheet(columns, name) {
|
|
2311
3905
|
const depth = getColumnGroupDepth(columns);
|
|
2312
3906
|
const header = Array.from({ length: depth + 1 }, () => columns.map(() => null));
|
|
@@ -2344,7 +3938,13 @@ var GridExportService = class GridExportService {
|
|
|
2344
3938
|
lastRow: depth
|
|
2345
3939
|
});
|
|
2346
3940
|
}
|
|
2347
|
-
const
|
|
3941
|
+
const treeColumnId = this.#gridService.treeColumnId();
|
|
3942
|
+
const rows = this.#gridService.getExportRows();
|
|
3943
|
+
const levels = rows.map((row) => (this.#gridService.getTreeRowInfo(row)?.level ?? 1) - 1);
|
|
3944
|
+
const body = rows.map((row, rowIndex) => columns.map((column) => ({
|
|
3945
|
+
indent: column.id === treeColumnId ? levels[rowIndex] : void 0,
|
|
3946
|
+
value: this.#toCellValue(row.data[column.field], column.dataType)
|
|
3947
|
+
})));
|
|
2348
3948
|
const frozenColumns = columns.findIndex((column) => !(column.locked && column.lockedPosition === "left"));
|
|
2349
3949
|
const headerTable = this.#gridService.headerTableElement();
|
|
2350
3950
|
const view = headerTable?.ownerDocument.defaultView;
|
|
@@ -2355,6 +3955,7 @@ var GridExportService = class GridExportService {
|
|
|
2355
3955
|
merges,
|
|
2356
3956
|
name,
|
|
2357
3957
|
rightToLeft: headerTable != null && view?.getComputedStyle(headerTable).direction === "rtl",
|
|
3958
|
+
rowOutlineLevels: treeColumnId == null ? void 0 : [...header.map(() => 0), ...levels],
|
|
2358
3959
|
rows: [...header, ...body]
|
|
2359
3960
|
};
|
|
2360
3961
|
}
|
|
@@ -2377,6 +3978,12 @@ var GridExportService = class GridExportService {
|
|
|
2377
3978
|
#exportedColumns() {
|
|
2378
3979
|
return this.#gridService.columns().where((c) => !!c.field && !c.hidden && c.kind !== "command").toArray();
|
|
2379
3980
|
}
|
|
3981
|
+
async #loadFont(source) {
|
|
3982
|
+
if (typeof source !== "string") return source instanceof Uint8Array ? source : new Uint8Array(source);
|
|
3983
|
+
const response = await this.#document.defaultView.fetch(source);
|
|
3984
|
+
if (!response.ok) throw new Error(`The font at ${source} couldn't be loaded: ${response.status} ${response.statusText}`);
|
|
3985
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
3986
|
+
}
|
|
2380
3987
|
#formatValue(value, dataType) {
|
|
2381
3988
|
if (value == null) return "";
|
|
2382
3989
|
switch (dataType) {
|
|
@@ -2419,6 +4026,16 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2419
4026
|
type: GridExportService,
|
|
2420
4027
|
decorators: [{ type: Injectable }]
|
|
2421
4028
|
});
|
|
4029
|
+
const DEFAULT_PDF_COLUMN_WIDTH = 120;
|
|
4030
|
+
function toPageSize(size) {
|
|
4031
|
+
switch (size) {
|
|
4032
|
+
case "A3": return [841.89, 1190.55];
|
|
4033
|
+
case "A4": return [595.28, 841.89];
|
|
4034
|
+
case "Legal": return [612, 1008];
|
|
4035
|
+
case "Letter": return [612, 792];
|
|
4036
|
+
default: return size;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
2422
4039
|
function formatLocalDate(value) {
|
|
2423
4040
|
if (Number.isNaN(value.getTime())) return "";
|
|
2424
4041
|
const pad = (part) => String(part).padStart(2, "0");
|
|
@@ -2432,6 +4049,9 @@ var GridExportDirective = class GridExportDirective {
|
|
|
2432
4049
|
exportExcel(filename) {
|
|
2433
4050
|
return this.#exportService.exportExcel(filename);
|
|
2434
4051
|
}
|
|
4052
|
+
exportPdf(options) {
|
|
4053
|
+
return this.#exportService.exportPdf(options);
|
|
4054
|
+
}
|
|
2435
4055
|
static {
|
|
2436
4056
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2437
4057
|
minVersion: "12.0.0",
|
|
@@ -2589,6 +4209,7 @@ var GridColumnComponent = class GridColumnComponent {
|
|
|
2589
4209
|
editTemplate: this.editTemplate() ?? null,
|
|
2590
4210
|
configuredEditable: this.editable(),
|
|
2591
4211
|
editable: this.editable() ?? true,
|
|
4212
|
+
expandable: this.expandable(),
|
|
2592
4213
|
field: this.field(),
|
|
2593
4214
|
filterable: this.filterable(),
|
|
2594
4215
|
filtered: false,
|
|
@@ -2646,6 +4267,10 @@ var GridColumnComponent = class GridColumnComponent {
|
|
|
2646
4267
|
...ngDevMode ? { debugName: "editable" } : /* istanbul ignore next */ {},
|
|
2647
4268
|
transform: nullableBooleanAttribute
|
|
2648
4269
|
});
|
|
4270
|
+
this.expandable = input(false, {
|
|
4271
|
+
...ngDevMode ? { debugName: "expandable" } : /* istanbul ignore next */ {},
|
|
4272
|
+
transform: booleanAttribute
|
|
4273
|
+
});
|
|
2649
4274
|
this.field = input("", ...ngDevMode ? [{ debugName: "field" }] : /* istanbul ignore next */ []);
|
|
2650
4275
|
this.filterable = input(true, {
|
|
2651
4276
|
...ngDevMode ? { debugName: "filterable" } : /* istanbul ignore next */ {},
|
|
@@ -2711,6 +4336,13 @@ var GridColumnComponent = class GridColumnComponent {
|
|
|
2711
4336
|
isRequired: false,
|
|
2712
4337
|
transformFunction: null
|
|
2713
4338
|
},
|
|
4339
|
+
expandable: {
|
|
4340
|
+
classPropertyName: "expandable",
|
|
4341
|
+
publicName: "expandable",
|
|
4342
|
+
isSignal: true,
|
|
4343
|
+
isRequired: false,
|
|
4344
|
+
transformFunction: null
|
|
4345
|
+
},
|
|
2714
4346
|
field: {
|
|
2715
4347
|
classPropertyName: "field",
|
|
2716
4348
|
publicName: "field",
|
|
@@ -2945,6 +4577,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2945
4577
|
required: false
|
|
2946
4578
|
}]
|
|
2947
4579
|
}],
|
|
4580
|
+
expandable: [{
|
|
4581
|
+
type: i0.Input,
|
|
4582
|
+
args: [{
|
|
4583
|
+
isSignal: true,
|
|
4584
|
+
alias: "expandable",
|
|
4585
|
+
required: false
|
|
4586
|
+
}]
|
|
4587
|
+
}],
|
|
2948
4588
|
field: [{
|
|
2949
4589
|
type: i0.Input,
|
|
2950
4590
|
args: [{
|
|
@@ -4412,7 +6052,7 @@ var GridComponent = class GridComponent {
|
|
|
4412
6052
|
});
|
|
4413
6053
|
this.gridHeaderElement = viewChild.required("gridHeaderElement", ...ngDevMode ? [{ debugName: "gridHeaderElement" }] : /* istanbul ignore next */ []);
|
|
4414
6054
|
this.gridHeaderTableElement = viewChild.required("headerTable", ...ngDevMode ? [{ debugName: "gridHeaderTableElement" }] : /* istanbul ignore next */ []);
|
|
4415
|
-
this.gridRole = computed(() => this.gridService.groupColumns().length > 0 ? "treegrid" : "grid", ...ngDevMode ? [{ debugName: "gridRole" }] : /* istanbul ignore next */ []);
|
|
6055
|
+
this.gridRole = computed(() => this.gridService.groupColumns().length > 0 || this.gridService.treeEnabled() ? "treegrid" : "grid", ...ngDevMode ? [{ debugName: "gridRole" }] : /* istanbul ignore next */ []);
|
|
4416
6056
|
this.gridService = inject(GridService);
|
|
4417
6057
|
this.gridWidthSet = signal(false, ...ngDevMode ? [{ debugName: "gridWidthSet" }] : /* istanbul ignore next */ []);
|
|
4418
6058
|
this.groupColumnList = viewChild("groupColumnList", ...ngDevMode ? [{ debugName: "groupColumnList" }] : /* istanbul ignore next */ []);
|
|
@@ -4465,7 +6105,7 @@ var GridComponent = class GridComponent {
|
|
|
4465
6105
|
this.messages = this.gridService.messages;
|
|
4466
6106
|
this.multiselectable = computed(() => {
|
|
4467
6107
|
const options = this.gridService.selectableOptions();
|
|
4468
|
-
return options.enabled && options.mode === "multiple";
|
|
6108
|
+
return options.enabled && options.mode === "multiple" || this.gridService.rangeSelectionEnabled();
|
|
4469
6109
|
}, ...ngDevMode ? [{ debugName: "multiselectable" }] : /* istanbul ignore next */ []);
|
|
4470
6110
|
this.noDataClass = computed(() => {
|
|
4471
6111
|
return gridNoDataThemeVariants();
|
|
@@ -5470,7 +7110,8 @@ var GridComponent = class GridComponent {
|
|
|
5470
7110
|
"readOnly",
|
|
5471
7111
|
"rowIndex",
|
|
5472
7112
|
"rowUid",
|
|
5473
|
-
"section"
|
|
7113
|
+
"section",
|
|
7114
|
+
"treeCell"
|
|
5474
7115
|
],
|
|
5475
7116
|
outputs: [
|
|
5476
7117
|
"edit",
|
|
@@ -5566,9 +7207,9 @@ var GridComponent = class GridComponent {
|
|
|
5566
7207
|
deferBlockDependencies: [() => [
|
|
5567
7208
|
NgTemplateOutlet,
|
|
5568
7209
|
GridColgroupComponent,
|
|
5569
|
-
import("./nanahoshi-mona-ui-grid-grid-footer-row.component-
|
|
5570
|
-
import("./nanahoshi-mona-ui-grid-grid-list.component-
|
|
5571
|
-
import("./nanahoshi-mona-ui-grid-grid-virtual-list.component-
|
|
7210
|
+
import("./nanahoshi-mona-ui-grid-grid-footer-row.component-CpvzAcX8.mjs").then((m) => m.GridFooterRowComponent),
|
|
7211
|
+
import("./nanahoshi-mona-ui-grid-grid-list.component-tRmEWiQR.mjs").then((m) => m.GridListComponent),
|
|
7212
|
+
import("./nanahoshi-mona-ui-grid-grid-virtual-list.component-8h2EMexB.mjs").then((m) => m.GridVirtualListComponent),
|
|
5572
7213
|
import("@nanahoshi/mona-ui/spinner").then((m) => m.SpinnerComponent)
|
|
5573
7214
|
]]
|
|
5574
7215
|
});
|
|
@@ -5580,9 +7221,9 @@ i0.ɵɵngDeclareClassMetadataAsync({
|
|
|
5580
7221
|
ngImport: i0,
|
|
5581
7222
|
type: GridComponent,
|
|
5582
7223
|
resolveDeferredDeps: () => [
|
|
5583
|
-
import("./nanahoshi-mona-ui-grid-grid-footer-row.component-
|
|
5584
|
-
import("./nanahoshi-mona-ui-grid-grid-list.component-
|
|
5585
|
-
import("./nanahoshi-mona-ui-grid-grid-virtual-list.component-
|
|
7224
|
+
import("./nanahoshi-mona-ui-grid-grid-footer-row.component-CpvzAcX8.mjs").then((m) => m.GridFooterRowComponent),
|
|
7225
|
+
import("./nanahoshi-mona-ui-grid-grid-list.component-tRmEWiQR.mjs").then((m) => m.GridListComponent),
|
|
7226
|
+
import("./nanahoshi-mona-ui-grid-grid-virtual-list.component-8h2EMexB.mjs").then((m) => m.GridVirtualListComponent),
|
|
5586
7227
|
import("@nanahoshi/mona-ui/spinner").then((m) => m.SpinnerComponent)
|
|
5587
7228
|
],
|
|
5588
7229
|
resolveMetadata: (GridFooterRowComponent, GridListComponent, GridVirtualListComponent, SpinnerComponent) => ({
|
|
@@ -5811,6 +7452,6 @@ i0.ɵɵngDeclareClassMetadataAsync({
|
|
|
5811
7452
|
}
|
|
5812
7453
|
})
|
|
5813
7454
|
});
|
|
5814
|
-
export { CellEditEvent, GRID_DEFAULT_MESSAGES, GridAddCommandDirective, GridAddEvent, GridCancelCommandDirective, GridCancelEvent, GridCellTemplateDirective, GridColumnComponent, GridColumnGroupComponent, GridColumnTitleTemplateDirective, GridCommandColumnComponent, GridComponent, GridContextMenuDirective, GridDetailTemplateDirective, GridEditCommandDirective, GridEditEvent, GridEditTemplateDirective, GridEditableDirective, GridExportDirective, GridFilterableDirective, GridFooterTemplateDirective, GridGroupFooterTemplateDirective, GridGroupableDirective, GridHeaderTemplateDirective, GridNoDataTemplateDirective, GridRemoveCommandDirective, GridRemoveEvent, GridReorderableDirective, GridResizableDirective, GridRowReorderableDirective, GridSaveCommandDirective, GridSaveEvent, GridSelectableDirective, GridServerBindingDirective, GridSortableDirective, GridStatePersistenceDirective, GridToolbarTemplateDirective, GridVirtualScrollDirective, RowEditEvent, RowReorderEvent };
|
|
7455
|
+
export { CellEditEvent, GRID_DEFAULT_MESSAGES, GridAddCommandDirective, GridAddEvent, GridCancelCommandDirective, GridCancelEvent, GridCellTemplateDirective, GridColumnComponent, GridColumnGroupComponent, GridColumnTitleTemplateDirective, GridCommandColumnComponent, GridComponent, GridContextMenuDirective, GridDetailTemplateDirective, GridEditCommandDirective, GridEditEvent, GridEditTemplateDirective, GridEditableDirective, GridExportDirective, GridFilterableDirective, GridFooterTemplateDirective, GridGroupFooterTemplateDirective, GridGroupableDirective, GridHeaderTemplateDirective, GridNoDataTemplateDirective, GridRangeSelectableDirective, GridRemoveCommandDirective, GridRemoveEvent, GridReorderableDirective, GridResizableDirective, GridRowReorderableDirective, GridSaveCommandDirective, GridSaveEvent, GridSelectableDirective, GridServerBindingDirective, GridSortableDirective, GridStatePersistenceDirective, GridToolbarTemplateDirective, GridTreeDirective, GridVirtualScrollDirective, RowEditEvent, RowReorderEvent };
|
|
5815
7456
|
|
|
5816
7457
|
//# sourceMappingURL=nanahoshi-mona-ui-grid.mjs.map
|