@nocopypaste/vue-grid 0.5.0 → 0.7.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/AGENTS.md +10 -2
- package/CHANGELOG.md +37 -0
- package/README.md +177 -79
- package/agent/api.json +63 -9
- package/agent/api.md +16 -6
- package/agent/grid-config.schema.json +9 -11
- package/dist/agent/api.js +63 -9
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +545 -518
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +4 -3
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js +58 -53
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js +50 -49
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js +151 -146
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js +44 -43
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +10 -8
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +62 -57
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js +59 -58
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js +62 -55
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js +60 -59
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js +27 -26
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js +12 -11
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js +37 -30
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useGridExport.js +98 -51
- package/dist/composables/useGridExport.js.map +1 -1
- package/dist/composables/useGridMenus.js +41 -41
- package/dist/composables/useGridMenus.js.map +1 -1
- package/dist/composables/useStatusBar.js +9 -0
- package/dist/composables/useStatusBar.js.map +1 -1
- package/dist/core/xlsx.js +172 -0
- package/dist/core/xlsx.js.map +1 -0
- package/dist/features/export.js.map +1 -1
- package/dist/index.js +55 -54
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/messages.js +20 -0
- package/dist/internal/messages.js.map +1 -0
- package/dist/internal/print.js +51 -0
- package/dist/internal/print.js.map +1 -0
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js +31 -30
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js +28 -27
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js +22 -21
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js +37 -36
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js +16 -15
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js +18 -17
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js +35 -34
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/types/components/VGrid.vue.d.ts +34 -7
- package/dist/types/components/VGridColumnMenu.vue.d.ts +4 -5
- package/dist/types/components/VGridMenu.vue.d.ts +1 -1
- package/dist/types/components/VGridPagination.vue.d.ts +8 -3
- package/dist/types/components/VGridSearch.vue.d.ts +2 -2
- package/dist/types/composables/useGridExport.d.ts +6 -1
- package/dist/types/composables/useGridMenus.d.ts +3 -1
- package/dist/types/composables/useStatusBar.d.ts +7 -0
- package/dist/types/core/xlsx.d.ts +34 -0
- package/dist/types/features/export.d.ts +6 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/internal/context.d.ts +5 -1
- package/dist/types/internal/messages.d.ts +16 -0
- package/dist/types/internal/print.d.ts +16 -0
- package/dist/types/renderers/parts/CopyButton.vue.d.ts +1 -3
- package/dist/types/types.d.ts +314 -0
- package/llms-full.txt +203 -87
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatusBar.js","names":["DEFAULT_AGGREGATES","useStatusBar","config","computed","o","opts","selectedRows","picked","out","walk","row","rows","kids","text","ctx","col","definition","fallback","options","shown","value","formatNumber","summary","keys","aggregates","key","c","values","getCellValue","items","aggregateValues","name","item"],"sources":["../../src/composables/useStatusBar.ts"],"sourcesContent":["import { computed, type Ref } from 'vue'\nimport { aggregateValues } from '../core/aggregate'\nimport { getCellValue } from '../core/value'\nimport { formatNumber } from '../renderers/format'\nimport type {\n CellRendererDefinition,\n ColumnDef,\n FormatContext,\n RowKey,\n StatusBarAggregate,\n StatusBarOptions,\n StatusBarScope,\n StatusBarSummary,\n} from '../types'\n\nexport interface UseStatusBarOptions<T> {\n /** The `status-bar` prop. */\n options: () => boolean | StatusBarOptions | undefined\n /** Top-level rows that pass the filters, on every page (the server's total with a data source). */\n rowCount: () => number\n /** Top-level rows before filtering; undefined when unknown (server data). */\n totalRowCount: () => number | undefined\n /** Top-level rows, all of them, to find the selected ones in. */\n rows: () => readonly T[]\n /** The selection feature's state (its `count` includes \"all matching\"), if the grid has it. */\n selection: { count: Ref<number> } | undefined\n selected: Ref<RowKey[]>\n /** \"Select all N matching rows\" is on (server data): the loaded rows aren't all of them. */\n allMatching: Ref<boolean>\n /** Active column filters plus the quick search. */\n filterCount: Ref<number>\n /** The grid can filter, so Clear can do something. */\n canClear: boolean\n clearFilters: () => void\n /** Known child rows of a row (sync or loaded). */\n children: (row: T) => readonly T[] | undefined\n getKey: (row: T) => RowKey\n columns: () => readonly ColumnDef<T>[]\n /** The grid's renderer lookup for a column. */\n resolve: (col: ColumnDef<T>) => { definition?: CellRendererDefinition; fallback?: boolean }\n format: Ref<FormatContext>\n}\n\nconst DEFAULT_AGGREGATES: readonly StatusBarAggregate[] = ['sum', 'avg']\n\n/**\n * The status bar (status bar feature): row, selection and filter counts, and a spreadsheet-like\n * summary (sum, average…) of chosen columns over the selected rows.\n */\nexport function useStatusBar<T>(opts: UseStatusBarOptions<T>) {\n const config = computed<StatusBarOptions | null>(() => {\n const o = opts.options()\n return o ? (o === true ? {} : o) : null\n })\n\n /** The selected rows the grid knows (nested ones included). */\n function selectedRows(): T[] {\n const picked = new Set(opts.selected.value)\n const out: T[] = []\n const walk = (rows: readonly T[]) => {\n for (const row of rows) {\n if (picked.has(opts.getKey(row))) out.push(row)\n const kids = opts.children(row)\n if (kids?.length) walk(kids)\n }\n }\n if (picked.size) walk(opts.rows())\n return out\n }\n\n /** As the column's cells show it: the renderer's text, else a locale number. */\n function text(value: unknown, col: ColumnDef<T>): string {\n const ctx = opts.format.value\n const { definition, fallback } = opts.resolve(col)\n if (definition?.format && !fallback) {\n try {\n const options = { ...(definition.defaults as object), ...(col.rendererOptions as object) }\n const shown = definition.format(value, options, ctx, undefined)\n if (shown) return shown\n } catch {\n // an option function that needs a row (e.g. a per-row currency): a plain number below\n }\n }\n return formatNumber(value, ctx, { maximumFractionDigits: 2 })\n }\n\n const summary = computed<StatusBarSummary[]>(() => {\n const keys = config.value?.summary\n // With \"all matching\" only the loaded rows are known: a sum of those would mislead.\n if (!keys?.length || opts.allMatching.value) return []\n const rows = selectedRows()\n if (!rows.length) return []\n const aggregates = config.value?.aggregates ?? DEFAULT_AGGREGATES\n const out: StatusBarSummary[] = []\n for (const key of keys) {\n const col = opts.columns().find((c) => c.key === key)\n if (!col) continue\n const values = rows.map((row) => getCellValue(row, col))\n const items = aggregates\n .map((name) => ({ name, value: aggregateValues(name, values, rows) }))\n .filter((item) => item.value !== null && item.value !== undefined)\n .map((item) => ({ ...item, text: text(item.value, col) }))\n if (items.length) out.push({ key, label: col.header || key, items })\n }\n return out\n })\n\n return {\n enabled: computed(() => !!config.value),\n canClear: opts.canClear,\n scope: computed<StatusBarScope>(() => ({\n rowCount: opts.rowCount(),\n totalRowCount: opts.totalRowCount(),\n selectedCount: opts.selection?.count.value ?? 0,\n allSelected: opts.allMatching.value,\n filterCount: opts.filterCount.value,\n summary: summary.value,\n clearFilters: opts.clearFilters,\n })),\n }\n}\n\n/** What the status bar component gets from the grid. */\nexport type StatusBarState = ReturnType<typeof useStatusBar>\n"],"mappings":";;;;;AA2CA,IAAMA,IAAoD,CAAC,OAAO,KAAK;AAMvE,SAAgBC,EAAgB,GAA8B;CAC5D,IAAMC,IAASC,QAAwC;EACrD,IAAMC,IAAIC,EAAK,QAAQ;EACvB,OAAOD,IAAKA,MAAM,KAAO,CAAC,IAAIA,IAAK;CACrC,CAAC;CAGD,SAASE,IAAoB;EAC3B,IAAMC,IAAS,IAAI,IAAIF,EAAK,SAAS,KAAK,GACpCG,IAAW,CAAC,GACZC,KAAQ,MAAuB;GACnC,KAAK,IAAMC,KAAOC,GAAM;IACtB,AAAIJ,EAAO,IAAIF,EAAK,OAAOK,CAAG,CAAC,KAAGF,EAAI,KAAKE,CAAG;IAC9C,IAAME,IAAOP,EAAK,SAASK,CAAG;IAC9B,AAAIE,GAAM,UAAQH,EAAKG,CAAI;GAC7B;EACF;EAEA,OADIL,EAAO,QAAME,EAAKJ,EAAK,KAAK,CAAC,GAC1BG;CACT;CAGA,SAASK,EAAK,GAAgB,GAA2B;EACvD,IAAMC,IAAMT,EAAK,OAAO,OAClB,EAAE,eAAY,gBAAaA,EAAK,QAAQU,CAAG;EACjD,IAAIC,GAAY,UAAU,CAACC,GACzB,IAAI;GACF,IAAMC,IAAU;IAAE,GAAIF,EAAW;IAAqB,GAAID,EAAI;GAA2B,GACnFI,IAAQH,EAAW,OAAOI,GAAOF,GAASJ,GAAK,KAAA,CAAS;GAC9D,IAAIK,GAAO,OAAOA;EACpB,QAAQ,CAER;EAEF,OAAOE,EAAaD,GAAON,GAAK,EAAE,uBAAuB,EAAE,CAAC;CAC9D;CAEA,IAAMQ,IAAUnB,QAAmC;EACjD,IAAMoB,IAAOrB,EAAO,OAAO;EAE3B,IAAI,CAACqB,GAAM,UAAUlB,EAAK,YAAY,OAAO,OAAO,CAAC;EACrD,IAAMM,IAAOL,EAAa;EAC1B,IAAI,CAACK,EAAK,QAAQ,OAAO,CAAC;EAC1B,IAAMa,IAAatB,EAAO,OAAO,cAAcF,GACzCQ,IAA0B,CAAC;EACjC,KAAK,IAAMiB,KAAOF,GAAM;GACtB,IAAMR,IAAMV,EAAK,QAAQ,CAAC,CAAC,MAAM,MAAMqB,EAAE,QAAQD,CAAG;GACpD,IAAI,CAACV,GAAK;GACV,IAAMY,IAAShB,EAAK,KAAK,MAAQiB,EAAalB,GAAKK,CAAG,CAAC,GACjDc,IAAQL,EACX,KAAK,OAAU;IAAE;IAAM,OAAOM,EAAgBC,GAAMJ,GAAQhB,CAAI;GAAE,EAAE,CAAC,CACrE,QAAQ,MAASqB,EAAK,UAAU,QAAQA,EAAK,UAAU,KAAA,CAAS,CAAC,CACjE,KAAK,OAAU;IAAE,GAAGA;IAAM,MAAMnB,EAAKmB,EAAK,OAAOjB,CAAG;GAAE,EAAE;GAC3D,AAAIc,EAAM,UAAQrB,EAAI,KAAK;IAAE;IAAK,OAAOO,EAAI,UAAUU;IAAK;GAAM,CAAC;EACrE;EACA,OAAOjB;CACT,CAAC;CAED,OAAO;EACL,SAASL,QAAe,CAAC,CAACD,EAAO,KAAK;
|
|
1
|
+
{"version":3,"file":"useStatusBar.js","names":["DEFAULT_AGGREGATES","useStatusBar","config","computed","o","opts","selectedRows","picked","out","walk","row","rows","kids","text","ctx","col","definition","fallback","options","shown","value","formatNumber","summary","keys","aggregates","key","c","values","getCellValue","items","aggregateValues","name","item"],"sources":["../../src/composables/useStatusBar.ts"],"sourcesContent":["import { computed, type Ref } from 'vue'\nimport { aggregateValues } from '../core/aggregate'\nimport { getCellValue } from '../core/value'\nimport { formatNumber } from '../renderers/format'\nimport type {\n CellRendererDefinition,\n ColumnDef,\n FormatContext,\n RowKey,\n StatusBarAggregate,\n StatusBarOptions,\n StatusBarScope,\n StatusBarSummary,\n} from '../types'\n\nexport interface UseStatusBarOptions<T> {\n /** The `status-bar` prop. */\n options: () => boolean | StatusBarOptions | undefined\n /** Top-level rows that pass the filters, on every page (the server's total with a data source). */\n rowCount: () => number\n /** Top-level rows before filtering; undefined when unknown (server data). */\n totalRowCount: () => number | undefined\n /** Top-level rows, all of them, to find the selected ones in. */\n rows: () => readonly T[]\n /** The selection feature's state (its `count` includes \"all matching\"), if the grid has it. */\n selection: { count: Ref<number> } | undefined\n selected: Ref<RowKey[]>\n /** \"Select all N matching rows\" is on (server data): the loaded rows aren't all of them. */\n allMatching: Ref<boolean>\n /** Active column filters plus the quick search. */\n filterCount: Ref<number>\n /** The grid can filter, so Clear can do something. */\n canClear: boolean\n clearFilters: () => void\n /** Known child rows of a row (sync or loaded). */\n children: (row: T) => readonly T[] | undefined\n getKey: (row: T) => RowKey\n columns: () => readonly ColumnDef<T>[]\n /** The grid's renderer lookup for a column. */\n resolve: (col: ColumnDef<T>) => { definition?: CellRendererDefinition; fallback?: boolean }\n format: Ref<FormatContext>\n}\n\nconst DEFAULT_AGGREGATES: readonly StatusBarAggregate[] = ['sum', 'avg']\n\n/**\n * The status bar (status bar feature): row, selection and filter counts, and a spreadsheet-like\n * summary (sum, average…) of chosen columns over the selected rows.\n */\nexport function useStatusBar<T>(opts: UseStatusBarOptions<T>) {\n const config = computed<StatusBarOptions | null>(() => {\n const o = opts.options()\n return o ? (o === true ? {} : o) : null\n })\n\n /** The selected rows the grid knows (nested ones included). */\n function selectedRows(): T[] {\n const picked = new Set(opts.selected.value)\n const out: T[] = []\n const walk = (rows: readonly T[]) => {\n for (const row of rows) {\n if (picked.has(opts.getKey(row))) out.push(row)\n const kids = opts.children(row)\n if (kids?.length) walk(kids)\n }\n }\n if (picked.size) walk(opts.rows())\n return out\n }\n\n /** As the column's cells show it: the renderer's text, else a locale number. */\n function text(value: unknown, col: ColumnDef<T>): string {\n const ctx = opts.format.value\n const { definition, fallback } = opts.resolve(col)\n if (definition?.format && !fallback) {\n try {\n const options = { ...(definition.defaults as object), ...(col.rendererOptions as object) }\n const shown = definition.format(value, options, ctx, undefined)\n if (shown) return shown\n } catch {\n // an option function that needs a row (e.g. a per-row currency): a plain number below\n }\n }\n return formatNumber(value, ctx, { maximumFractionDigits: 2 })\n }\n\n const summary = computed<StatusBarSummary[]>(() => {\n const keys = config.value?.summary\n // With \"all matching\" only the loaded rows are known: a sum of those would mislead.\n if (!keys?.length || opts.allMatching.value) return []\n const rows = selectedRows()\n if (!rows.length) return []\n const aggregates = config.value?.aggregates ?? DEFAULT_AGGREGATES\n const out: StatusBarSummary[] = []\n for (const key of keys) {\n const col = opts.columns().find((c) => c.key === key)\n if (!col) continue\n const values = rows.map((row) => getCellValue(row, col))\n const items = aggregates\n .map((name) => ({ name, value: aggregateValues(name, values, rows) }))\n .filter((item) => item.value !== null && item.value !== undefined)\n .map((item) => ({ ...item, text: text(item.value, col) }))\n if (items.length) out.push({ key, label: col.header || key, items })\n }\n return out\n })\n\n return {\n enabled: computed(() => !!config.value),\n /** Which items show (each on unless `false`). */\n show: computed(() => {\n const c = config.value ?? {}\n return {\n rows: c.rows !== false,\n selected: c.selected !== false,\n filters: c.filters !== false,\n clear: c.clear !== false,\n }\n }),\n canClear: opts.canClear,\n scope: computed<StatusBarScope>(() => ({\n rowCount: opts.rowCount(),\n totalRowCount: opts.totalRowCount(),\n selectedCount: opts.selection?.count.value ?? 0,\n allSelected: opts.allMatching.value,\n filterCount: opts.filterCount.value,\n summary: summary.value,\n clearFilters: opts.clearFilters,\n })),\n }\n}\n\n/** What the status bar component gets from the grid. */\nexport type StatusBarState = ReturnType<typeof useStatusBar>\n"],"mappings":";;;;;AA2CA,IAAMA,IAAoD,CAAC,OAAO,KAAK;AAMvE,SAAgBC,EAAgB,GAA8B;CAC5D,IAAMC,IAASC,QAAwC;EACrD,IAAMC,I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,IAAI,CAACV,GAAK;GACV,IAAMY,IAAShB,EAAK,KAAK,MAAQiB,EAAalB,GAAKK,CAAG,CAAC,GACjDc,IAAQL,EACX,KAAK,OAAU;IAAE;IAAM,OAAOM,EAAgBC,GAAMJ,GAAQhB,CAAI;GAAE,EAAE,CAAC,CACrE,QAAQ,MAASqB,EAAK,UAAU,QAAQA,EAAK,UAAU,KAAA,CAAS,CAAC,CACjE,KAAK,OAAU;IAAE,GAAGA;IAAM,MAAMnB,EAAKmB,EAAK,OAAOjB,CAAG;GAAE,EAAE;GAC3D,AAAIc,EAAM,UAAQrB,EAAI,KAAK;IAAE;IAAK,OAAOO,EAAI,UAAUU;IAAK;GAAM,CAAC;EACrE;EACA,OAAOjB;CACT,CAAC;CAED,OAAO;EACL,SAASL,QAAe,CAAC,CAACD,EAAO,KAAK;EAEtC,MAAMC,QAAe;GACnB,IAAMuB,IAAIxB,EAAO,SAAS,CAAC;GAC3B,OAAO;IACL,MAAMwB,EAAE,SAAS;IACjB,UAAUA,EAAE,aAAa;IACzB,SAASA,EAAE,YAAY;IACvB,OAAOA,EAAE,UAAU;GACrB;EACF,CAAC;EACD,UAAUrB,EAAK;EACf,OAAOF,SAAgC;GACrC,UAAUE,EAAK,SAAS;GACxB,eAAeA,EAAK,cAAc;GAClC,eAAeA,EAAK,WAAW,MAAM,SAAS;GAC9C,aAAaA,EAAK,YAAY;GAC9B,aAAaA,EAAK,YAAY;GAC9B,SAASiB,EAAQ;GACjB,cAAcjB,EAAK;EACrB,EAAE;CACJ;AACF"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { toDate as e, toNumber as t } from "../renderers/format.js";
|
|
2
|
+
import { plainText as n } from "./csv.js";
|
|
3
|
+
import { getCellValue as r } from "./value.js";
|
|
4
|
+
// src/core/xlsx.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let t = e.renderer, n = typeof t == "string" ? t : t && typeof t == "object" && "name" in t ? String(t.name) : "", r = e.rendererOptions ?? {};
|
|
7
|
+
switch (n) {
|
|
8
|
+
case "currency": return "money";
|
|
9
|
+
case "change": return r.currency ? "money" : "number";
|
|
10
|
+
case "number":
|
|
11
|
+
case "signed-number": return r.format?.style === "percent" ? "percent" : "number";
|
|
12
|
+
case "date": return "date";
|
|
13
|
+
case "datetime": return "datetime";
|
|
14
|
+
default: return "auto";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function a(e, t, n = {}) {
|
|
18
|
+
let a = t.filter((e) => e.exportable !== !1);
|
|
19
|
+
return b({
|
|
20
|
+
name: n.sheetName,
|
|
21
|
+
header: n.header === !1 ? void 0 : a.map((e) => e.header ?? e.key),
|
|
22
|
+
formats: a.map((e) => n.formats?.[e.key] ?? i(e)),
|
|
23
|
+
rows: e.map((e) => a.map((t) => t.exportValue ? t.exportValue(e) : r(e, t))),
|
|
24
|
+
timeZone: n.timeZone
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var o = [
|
|
28
|
+
"#,##0.00",
|
|
29
|
+
"yyyy-mm-dd",
|
|
30
|
+
"yyyy-mm-dd hh:mm"
|
|
31
|
+
], s = {
|
|
32
|
+
auto: 0,
|
|
33
|
+
number: 0,
|
|
34
|
+
money: 164,
|
|
35
|
+
date: 165,
|
|
36
|
+
datetime: 166,
|
|
37
|
+
percent: 10
|
|
38
|
+
}, c = [
|
|
39
|
+
0,
|
|
40
|
+
164,
|
|
41
|
+
165,
|
|
42
|
+
166,
|
|
43
|
+
10
|
|
44
|
+
], l = (e, t) => c.indexOf(e) * 2 + +!!t, u = 864e5, d = Date.UTC(1899, 11, 30), f = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
45
|
+
function p(t, n) {
|
|
46
|
+
if (typeof t == "string") {
|
|
47
|
+
let e = f.exec(t.trim());
|
|
48
|
+
if (e) return (Date.UTC(+e[1], e[2] - 1, +e[3]) - d) / u;
|
|
49
|
+
}
|
|
50
|
+
let r = e(t);
|
|
51
|
+
if (!r) return null;
|
|
52
|
+
let i;
|
|
53
|
+
if (n) {
|
|
54
|
+
let e = {};
|
|
55
|
+
for (let t of new Intl.DateTimeFormat("en-US", {
|
|
56
|
+
timeZone: n,
|
|
57
|
+
hourCycle: "h23",
|
|
58
|
+
year: "numeric",
|
|
59
|
+
month: "numeric",
|
|
60
|
+
day: "numeric",
|
|
61
|
+
hour: "numeric",
|
|
62
|
+
minute: "numeric",
|
|
63
|
+
second: "numeric"
|
|
64
|
+
}).formatToParts(r)) t.type !== "literal" && (e[t.type] = Number(t.value));
|
|
65
|
+
i = Date.UTC(e.year, e.month - 1, e.day, e.hour, e.minute, e.second, r.getMilliseconds());
|
|
66
|
+
} else i = r.getTime() - r.getTimezoneOffset() * 6e4;
|
|
67
|
+
return (i - d) / u;
|
|
68
|
+
}
|
|
69
|
+
var m = (e) => e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
70
|
+
function h(e) {
|
|
71
|
+
let t = "";
|
|
72
|
+
for (let n = e + 1; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
|
|
73
|
+
return t;
|
|
74
|
+
}
|
|
75
|
+
function g(e, r, i, a, o) {
|
|
76
|
+
if (r == null || r === "") return null;
|
|
77
|
+
let c = (t, n, r) => ({
|
|
78
|
+
xml: `<c r="${e}" s="${l(n, a)}"><v>${t}</v></c>`,
|
|
79
|
+
width: r
|
|
80
|
+
});
|
|
81
|
+
if (i === "date" || i === "datetime" || r instanceof Date) {
|
|
82
|
+
let e = p(r, o);
|
|
83
|
+
if (e !== null) {
|
|
84
|
+
let t = i === "date" ? s.date : s.datetime;
|
|
85
|
+
return c(e, t, t === s.date ? 10 : 16);
|
|
86
|
+
}
|
|
87
|
+
} else if (i === "money" || i === "number" || i === "percent") {
|
|
88
|
+
let e = t(r);
|
|
89
|
+
if (e !== null) return c(e, s[i], String(Math.round(e * 100) / 100).length + 4);
|
|
90
|
+
} else if (typeof r == "number" && Number.isFinite(r)) return c(r, 0, String(r).length);
|
|
91
|
+
else if (typeof r == "boolean") return {
|
|
92
|
+
xml: `<c r="${e}" s="${l(0, a)}" t="b"><v>${+!!r}</v></c>`,
|
|
93
|
+
width: 5
|
|
94
|
+
};
|
|
95
|
+
let u = n(r).slice(0, 32767);
|
|
96
|
+
if (!u) return null;
|
|
97
|
+
let d = /^\s|\s$/.test(u) ? " xml:space=\"preserve\"" : "";
|
|
98
|
+
return {
|
|
99
|
+
xml: `<c r="${e}" s="${l(0, a)}" t="inlineStr"><is><t${d}>${m(u)}</t></is></c>`,
|
|
100
|
+
width: Math.max(...u.split("\n").map((e) => e.length))
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function _(e) {
|
|
104
|
+
let t = e.formats.map(() => 8), n = [], r = (r, i, a) => {
|
|
105
|
+
let o = n.length + 1, s = [];
|
|
106
|
+
r.forEach((n, r) => {
|
|
107
|
+
let c = g(`${h(r)}${o}`, n, a[r] ?? "auto", i, e.timeZone);
|
|
108
|
+
c && (s.push(c.xml), t[r] = Math.max(t[r] ?? 8, c.width + 2));
|
|
109
|
+
}), n.push(`<row r="${o}">${s.join("")}</row>`);
|
|
110
|
+
}, i = e.formats.map(() => "auto");
|
|
111
|
+
e.header && r(e.header, !0, i);
|
|
112
|
+
for (let t of e.rows) r(t, !1, e.formats);
|
|
113
|
+
e.footer && r(e.footer, !0, e.formats);
|
|
114
|
+
let a = t.map((e, t) => `<col min="${t + 1}" max="${t + 1}" width="${Math.min(60, e)}" customWidth="1"/>`).join("");
|
|
115
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
116
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetViews><sheetView workbookViewId="0">${e.header ? "<pane ySplit=\"1\" topLeftCell=\"A2\" activePane=\"bottomLeft\" state=\"frozen\"/>" : ""}</sheetView></sheetViews>` + (a ? `<cols>${a}</cols>` : "") + `<sheetData>${n.join("")}</sheetData></worksheet>`;
|
|
117
|
+
}
|
|
118
|
+
function v() {
|
|
119
|
+
let e = o.map((e, t) => `<numFmt numFmtId="${164 + t}" formatCode="${m(e)}"/>`).join(""), t = c.flatMap((e) => [0, 1].map((t) => `<xf numFmtId="${e}" fontId="${t}" fillId="0" borderId="0" xfId="0"${e ? " applyNumberFormat=\"1\"" : ""}${t ? " applyFont=\"1\"" : ""}/>`)).join("");
|
|
120
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
121
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="${o.length}">${e}</numFmts><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></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="${c.length * 2}">${t}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`;
|
|
122
|
+
}
|
|
123
|
+
var y = (e) => (e ?? "").replace(/[[\]:*?/\\]/g, "").trim().slice(0, 31) || "Sheet1";
|
|
124
|
+
function b(e) {
|
|
125
|
+
let t = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
126
|
+
return C([
|
|
127
|
+
["[Content_Types].xml", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/><Override PartName=\"/xl/worksheets/sheet1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/><Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/></Types>"],
|
|
128
|
+
["_rels/.rels", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
129
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${t}/officeDocument" Target="xl/workbook.xml"/></Relationships>`],
|
|
130
|
+
["xl/workbook.xml", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
131
|
+
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="${t}"><sheets><sheet name="${m(y(e.name))}" sheetId="1" r:id="rId1"/></sheets></workbook>`],
|
|
132
|
+
["xl/_rels/workbook.xml.rels", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
133
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${t}/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="${t}/styles" Target="styles.xml"/></Relationships>`],
|
|
134
|
+
["xl/worksheets/sheet1.xml", _(e)],
|
|
135
|
+
["xl/styles.xml", v()]
|
|
136
|
+
].map(([e, t]) => [e, new TextEncoder().encode(t)]));
|
|
137
|
+
}
|
|
138
|
+
var x;
|
|
139
|
+
function S(e) {
|
|
140
|
+
if (!x) {
|
|
141
|
+
x = /* @__PURE__ */ new Uint32Array(256);
|
|
142
|
+
for (let e = 0; e < 256; e++) {
|
|
143
|
+
let t = e;
|
|
144
|
+
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
145
|
+
x[e] = t >>> 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let t = 4294967295;
|
|
149
|
+
for (let n of e) t = x[(t ^ n) & 255] ^ t >>> 8;
|
|
150
|
+
return (t ^ 4294967295) >>> 0;
|
|
151
|
+
}
|
|
152
|
+
function C(e) {
|
|
153
|
+
let t = new TextEncoder(), n = [], r = [], i = 0;
|
|
154
|
+
for (let [a, o] of e) {
|
|
155
|
+
let e = t.encode(a), s = S(o), c = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(30));
|
|
156
|
+
c.setUint32(0, 67324752, !0), c.setUint16(4, 20, !0), c.setUint16(6, 2048, !0), c.setUint16(8, 0, !0), c.setUint16(10, 0, !0), c.setUint16(12, 33, !0), c.setUint32(14, s, !0), c.setUint32(18, o.length, !0), c.setUint32(22, o.length, !0), c.setUint16(26, e.length, !0), n.push(new Uint8Array(c.buffer), e, o);
|
|
157
|
+
let l = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(46));
|
|
158
|
+
l.setUint32(0, 33639248, !0), l.setUint16(4, 20, !0), l.setUint16(6, 20, !0), l.setUint16(8, 2048, !0), l.setUint16(10, 0, !0), l.setUint16(12, 0, !0), l.setUint16(14, 33, !0), l.setUint32(16, s, !0), l.setUint32(20, o.length, !0), l.setUint32(24, o.length, !0), l.setUint16(28, e.length, !0), l.setUint32(42, i, !0), r.push(new Uint8Array(l.buffer), e), i += 30 + e.length + o.length;
|
|
159
|
+
}
|
|
160
|
+
let a = r.reduce((e, t) => e + t.length, 0), o = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(22));
|
|
161
|
+
o.setUint32(0, 101010256, !0), o.setUint16(8, e.length, !0), o.setUint16(10, e.length, !0), o.setUint32(12, a, !0), o.setUint32(16, i, !0);
|
|
162
|
+
let s = [
|
|
163
|
+
...n,
|
|
164
|
+
...r,
|
|
165
|
+
new Uint8Array(o.buffer)
|
|
166
|
+
], c = new Uint8Array(s.reduce((e, t) => e + t.length, 0)), l = 0;
|
|
167
|
+
for (let e of s) c.set(e, l), l += e.length;
|
|
168
|
+
return c;
|
|
169
|
+
}
|
|
170
|
+
export { a as toXlsx, b as writeXlsx, i as xlsxFormatOf };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=xlsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xlsx.js","names":["xlsxFormatOf","renderer","col","name","options","toXlsx","cols","columns","c","writeXlsx","rows","row","getCellValue","NUM_FMTS","FMT_ID","STYLE_FMTS","styleOf","fmt","DAY","EPOCH","DATE_ONLY","dateSerial","value","m","d","toDate","wall","timeZone","parts","p","xml","s","columnName","i","cell","num","ref","bold","n","format","serial","tz","toNumber","text","plainText","space","l","sheetXml","widths","sheet","lines","addRow","r","cells","values","formats","w","stylesXml","numFmts","code","xfs","sheetName","rel","zip","crcTable","crc32","k","crc","byte","data","enc","central","offset","files","nameBytes","local","entry","centralSize","end","all","out","at"],"sources":["../../src/core/xlsx.ts"],"sourcesContent":["/**\n * A minimal Excel (.xlsx) writer: one sheet, typed cells (numbers, dates, booleans, text), a bold\n * frozen header, an optional bold totals line, number formats for money, percentages and dates,\n * column widths from the content. No dependencies: the workbook's XML parts in a ZIP container\n * (stored, not compressed). Text is written as inline strings, never as formulas.\n */\nimport { toDate, toNumber } from '../renderers/format'\nimport type { ColumnDef } from '../types'\nimport { plainText } from './csv'\nimport { getCellValue } from './value'\n\n/** How a column's values are written: Excel number formats for money, percentages and dates. */\nexport type XlsxFormat = 'auto' | 'number' | 'money' | 'percent' | 'date' | 'datetime'\n\nexport interface ToXlsxOptions {\n /** The sheet's name (31 characters at most; `[]:*?/\\` are dropped). Default `Sheet1`. */\n sheetName?: string\n /** A bold header line with the column headers, frozen. Default `true`. */\n header?: boolean\n /** Time zone that date-times are written in (Excel dates have none). Default: the browser's. */\n timeZone?: string\n /** Formats by column key, instead of the ones guessed from each column's renderer. */\n formats?: Record<string, XlsxFormat>\n}\n\n/** One sheet, ready to write: values are raw (typed) or text. */\nexport interface XlsxSheet {\n name?: string\n header?: readonly string[]\n formats: readonly XlsxFormat[]\n rows: readonly (readonly unknown[])[]\n /** A last, bold line (the totals row). */\n footer?: readonly unknown[]\n timeZone?: string\n}\n\n/** The Excel format a column's renderer implies (`currency` → money, `date` → date, …). */\nexport function xlsxFormatOf(col: ColumnDef): XlsxFormat {\n const renderer = col.renderer as unknown\n const name =\n typeof renderer === 'string'\n ? renderer\n : renderer && typeof renderer === 'object' && 'name' in renderer\n ? String((renderer as { name: unknown }).name)\n : ''\n const options = (col.rendererOptions ?? {}) as {\n currency?: unknown\n format?: Intl.NumberFormatOptions\n }\n switch (name) {\n case 'currency':\n return 'money'\n case 'change':\n return options.currency ? 'money' : 'number'\n case 'number':\n case 'signed-number':\n return options.format?.style === 'percent' ? 'percent' : 'number'\n case 'date':\n return 'date'\n case 'datetime':\n return 'datetime'\n default:\n return 'auto'\n }\n}\n\n/**\n * Rows as an Excel workbook (the bytes of an .xlsx file): one row per row, one cell per column\n * (its `exportValue`, else the cell value), typed: numbers, dates and booleans stay what they are.\n * Columns with `exportable: false` are left out. For the grid's own rows, filters and sort, use\n * the export feature (`grid.exportXlsx()`).\n */\nexport function toXlsx<T>(\n rows: readonly T[],\n columns: readonly ColumnDef<T>[],\n options: ToXlsxOptions = {},\n): Uint8Array {\n const cols = columns.filter((c) => c.exportable !== false)\n return writeXlsx({\n name: options.sheetName,\n header: options.header === false ? undefined : cols.map((c) => c.header ?? c.key),\n formats: cols.map((c) => options.formats?.[c.key] ?? xlsxFormatOf(c as ColumnDef)),\n rows: rows.map((row) =>\n cols.map((c) => (c.exportValue ? c.exportValue(row) : getCellValue(row, c))),\n ),\n timeZone: options.timeZone,\n })\n}\n\n// ── Cells ─────────────────────────────────────────────────────────────────────────────────────\n\n// Number formats: built-in 10 is `0.00%`; 164+ are ours.\nconst NUM_FMTS = ['#,##0.00', 'yyyy-mm-dd', 'yyyy-mm-dd hh:mm']\nconst FMT_ID: Record<XlsxFormat, number> = {\n auto: 0,\n number: 0,\n money: 164,\n date: 165,\n datetime: 166,\n percent: 10,\n}\nconst STYLE_FMTS = [0, 164, 165, 166, 10]\n/** The cellXfs index: one style per number format, plain and bold. */\nconst styleOf = (fmt: number, bold: boolean) => STYLE_FMTS.indexOf(fmt) * 2 + (bold ? 1 : 0)\n\nconst DAY = 86_400_000\nconst EPOCH = Date.UTC(1899, 11, 30)\nconst DATE_ONLY = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\n/** An Excel date serial: the wall-clock time in `timeZone` (date-only strings: that day). */\nfunction dateSerial(value: unknown, timeZone: string | undefined): number | null {\n if (typeof value === 'string') {\n const m = DATE_ONLY.exec(value.trim())\n if (m) return (Date.UTC(+m[1]!, +m[2]! - 1, +m[3]!) - EPOCH) / DAY\n }\n const d = toDate(value)\n if (!d) return null\n let wall: number\n if (timeZone) {\n const parts: Record<string, number> = {}\n for (const p of new Intl.DateTimeFormat('en-US', {\n timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n }).formatToParts(d))\n if (p.type !== 'literal') parts[p.type] = Number(p.value)\n wall = Date.UTC(\n parts.year!,\n parts.month! - 1,\n parts.day!,\n parts.hour!,\n parts.minute!,\n parts.second!,\n d.getMilliseconds(),\n )\n } else {\n wall = d.getTime() - d.getTimezoneOffset() * 60_000\n }\n return (wall - EPOCH) / DAY\n}\n\nconst xml = (s: string) =>\n s\n // characters XML 1.0 doesn't allow\n .replace(/[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]/g, '')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n\n/** A1-style column letters: 0 → A, 26 → AA. */\nfunction columnName(i: number): string {\n let s = ''\n for (let n = i + 1; n > 0; n = Math.floor((n - 1) / 26))\n s = String.fromCharCode(65 + ((n - 1) % 26)) + s\n return s\n}\n\ninterface Cell {\n xml: string\n /** Characters shown, for the column width. */\n width: number\n}\n\nfunction cell(\n ref: string,\n value: unknown,\n format: XlsxFormat,\n bold: boolean,\n tz?: string,\n): Cell | null {\n if (value === null || value === undefined || value === '') return null\n const num = (n: number, fmt: number, width: number): Cell => ({\n xml: `<c r=\"${ref}\" s=\"${styleOf(fmt, bold)}\"><v>${n}</v></c>`,\n width,\n })\n if (format === 'date' || format === 'datetime' || value instanceof Date) {\n const serial = dateSerial(value, tz)\n if (serial !== null) {\n const fmt = format === 'date' ? FMT_ID.date : FMT_ID.datetime\n return num(serial, fmt, fmt === FMT_ID.date ? 10 : 16)\n }\n } else if (format === 'money' || format === 'number' || format === 'percent') {\n const n = toNumber(value)\n if (n !== null) return num(n, FMT_ID[format], String(Math.round(n * 100) / 100).length + 4)\n } else if (typeof value === 'number' && Number.isFinite(value)) {\n return num(value, 0, String(value).length)\n } else if (typeof value === 'boolean') {\n return {\n xml: `<c r=\"${ref}\" s=\"${styleOf(0, bold)}\" t=\"b\"><v>${value ? 1 : 0}</v></c>`,\n width: 5,\n }\n }\n const text = plainText(value).slice(0, 32_767) // a cell's limit\n if (!text) return null\n const space = /^\\s|\\s$/.test(text) ? ' xml:space=\"preserve\"' : ''\n return {\n xml: `<c r=\"${ref}\" s=\"${styleOf(0, bold)}\" t=\"inlineStr\"><is><t${space}>${xml(text)}</t></is></c>`,\n width: Math.max(...text.split('\\n').map((l) => l.length)),\n }\n}\n\n// ── Workbook ──────────────────────────────────────────────────────────────────────────────────\n\nfunction sheetXml(sheet: XlsxSheet): string {\n const widths = sheet.formats.map(() => 8)\n const lines: string[] = []\n const addRow = (values: readonly unknown[], bold: boolean, formats: readonly XlsxFormat[]) => {\n const r = lines.length + 1\n const cells: string[] = []\n values.forEach((value, i) => {\n const c = cell(`${columnName(i)}${r}`, value, formats[i] ?? 'auto', bold, sheet.timeZone)\n if (!c) return\n cells.push(c.xml)\n widths[i] = Math.max(widths[i] ?? 8, c.width + 2)\n })\n lines.push(`<row r=\"${r}\">${cells.join('')}</row>`)\n }\n const text = sheet.formats.map((): XlsxFormat => 'auto')\n if (sheet.header) addRow(sheet.header, true, text)\n for (const row of sheet.rows) addRow(row, false, sheet.formats)\n if (sheet.footer) addRow(sheet.footer, true, sheet.formats)\n\n const cols = widths\n .map(\n (w, i) => `<col min=\"${i + 1}\" max=\"${i + 1}\" width=\"${Math.min(60, w)}\" customWidth=\"1\"/>`,\n )\n .join('')\n const pane = sheet.header\n ? '<pane ySplit=\"1\" topLeftCell=\"A2\" activePane=\"bottomLeft\" state=\"frozen\"/>'\n : ''\n return (\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\\n' +\n '<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">' +\n `<sheetViews><sheetView workbookViewId=\"0\">${pane}</sheetView></sheetViews>` +\n (cols ? `<cols>${cols}</cols>` : '') +\n `<sheetData>${lines.join('')}</sheetData></worksheet>`\n )\n}\n\nfunction stylesXml(): string {\n const numFmts = NUM_FMTS.map(\n (code, i) => `<numFmt numFmtId=\"${164 + i}\" formatCode=\"${xml(code)}\"/>`,\n ).join('')\n const xfs = STYLE_FMTS.flatMap((fmt) =>\n [0, 1].map(\n (bold) =>\n `<xf numFmtId=\"${fmt}\" fontId=\"${bold}\" fillId=\"0\" borderId=\"0\" xfId=\"0\"` +\n `${fmt ? ' applyNumberFormat=\"1\"' : ''}${bold ? ' applyFont=\"1\"' : ''}/>`,\n ),\n ).join('')\n return (\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\\n' +\n '<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">' +\n `<numFmts count=\"${NUM_FMTS.length}\">${numFmts}</numFmts>` +\n '<fonts count=\"2\"><font><sz val=\"11\"/><name val=\"Calibri\"/></font>' +\n '<font><b/><sz val=\"11\"/><name val=\"Calibri\"/></font></fonts>' +\n '<fills count=\"2\"><fill><patternFill patternType=\"none\"/></fill>' +\n '<fill><patternFill patternType=\"gray125\"/></fill></fills>' +\n '<borders count=\"1\"><border><left/><right/><top/><bottom/><diagonal/></border></borders>' +\n '<cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs>' +\n `<cellXfs count=\"${STYLE_FMTS.length * 2}\">${xfs}</cellXfs>` +\n '<cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles>' +\n '</styleSheet>'\n )\n}\n\n/** A valid sheet name: 1–31 characters, none of `[]:*?/\\`. */\nconst sheetName = (name: string | undefined) =>\n (name ?? '')\n .replace(/[[\\]:*?/\\\\]/g, '')\n .trim()\n .slice(0, 31) || 'Sheet1'\n\n/** The bytes of an .xlsx file with one sheet. */\nexport function writeXlsx(sheet: XlsxSheet): Uint8Array {\n const head = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\\n'\n const rel = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'\n const files: [string, string][] = [\n [\n '[Content_Types].xml',\n head +\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">' +\n '<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>' +\n '<Default Extension=\"xml\" ContentType=\"application/xml\"/>' +\n '<Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/>' +\n '<Override PartName=\"/xl/worksheets/sheet1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/>' +\n '<Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/>' +\n '</Types>',\n ],\n [\n '_rels/.rels',\n head +\n '<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">' +\n `<Relationship Id=\"rId1\" Type=\"${rel}/officeDocument\" Target=\"xl/workbook.xml\"/>` +\n '</Relationships>',\n ],\n [\n 'xl/workbook.xml',\n head +\n `<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"${rel}\">` +\n `<sheets><sheet name=\"${xml(sheetName(sheet.name))}\" sheetId=\"1\" r:id=\"rId1\"/></sheets>` +\n '</workbook>',\n ],\n [\n 'xl/_rels/workbook.xml.rels',\n head +\n '<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">' +\n `<Relationship Id=\"rId1\" Type=\"${rel}/worksheet\" Target=\"worksheets/sheet1.xml\"/>` +\n `<Relationship Id=\"rId2\" Type=\"${rel}/styles\" Target=\"styles.xml\"/>` +\n '</Relationships>',\n ],\n ['xl/worksheets/sheet1.xml', sheetXml(sheet)],\n ['xl/styles.xml', stylesXml()],\n ]\n return zip(files.map(([name, text]) => [name, new TextEncoder().encode(text)]))\n}\n\n// ── ZIP (stored) ──────────────────────────────────────────────────────────────────────────────\n\nlet crcTable: Uint32Array | undefined\nfunction crc32(data: Uint8Array): number {\n if (!crcTable) {\n crcTable = new Uint32Array(256)\n for (let n = 0; n < 256; n++) {\n let c = n\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1\n crcTable[n] = c >>> 0\n }\n }\n let crc = 0xffffffff\n for (const byte of data) crc = crcTable[(crc ^ byte) & 0xff]! ^ (crc >>> 8)\n return (crc ^ 0xffffffff) >>> 0\n}\n\n/** A ZIP archive of the files, stored (no compression), dated 1980-01-01. */\nfunction zip(files: [string, Uint8Array][]): Uint8Array {\n const enc = new TextEncoder()\n const DOS_DATE = (0 << 9) | (1 << 5) | 1 // 1980-01-01\n const parts: Uint8Array[] = []\n const central: Uint8Array[] = []\n let offset = 0\n for (const [name, data] of files) {\n const nameBytes = enc.encode(name)\n const crc = crc32(data)\n const local = new DataView(new ArrayBuffer(30))\n local.setUint32(0, 0x04034b50, true)\n local.setUint16(4, 20, true) // version needed\n local.setUint16(6, 0x0800, true) // UTF-8 names\n local.setUint16(8, 0, true) // stored\n local.setUint16(10, 0, true) // time\n local.setUint16(12, DOS_DATE, true)\n local.setUint32(14, crc, true)\n local.setUint32(18, data.length, true)\n local.setUint32(22, data.length, true)\n local.setUint16(26, nameBytes.length, true)\n parts.push(new Uint8Array(local.buffer), nameBytes, data)\n\n const entry = new DataView(new ArrayBuffer(46))\n entry.setUint32(0, 0x02014b50, true)\n entry.setUint16(4, 20, true) // version made by\n entry.setUint16(6, 20, true)\n entry.setUint16(8, 0x0800, true)\n entry.setUint16(10, 0, true)\n entry.setUint16(12, 0, true)\n entry.setUint16(14, DOS_DATE, true)\n entry.setUint32(16, crc, true)\n entry.setUint32(20, data.length, true)\n entry.setUint32(24, data.length, true)\n entry.setUint16(28, nameBytes.length, true)\n entry.setUint32(42, offset, true)\n central.push(new Uint8Array(entry.buffer), nameBytes)\n offset += 30 + nameBytes.length + data.length\n }\n const centralSize = central.reduce((n, p) => n + p.length, 0)\n const end = new DataView(new ArrayBuffer(22))\n end.setUint32(0, 0x06054b50, true)\n end.setUint16(8, files.length, true)\n end.setUint16(10, files.length, true)\n end.setUint32(12, centralSize, true)\n end.setUint32(16, offset, true)\n const all = [...parts, ...central, new Uint8Array(end.buffer)]\n const out = new Uint8Array(all.reduce((n, p) => n + p.length, 0))\n let at = 0\n for (const p of all) {\n out.set(p, at)\n at += p.length\n }\n return out\n}\n"],"mappings":";;;;AAqCA,SAAgBA,EAAa,GAA4B;CACvD,IAAMC,IAAWC,EAAI,UACfC,IACJ,OAAOF,KAAa,WAChBA,IACAA,KAAY,OAAOA,KAAa,YAAY,UAAUA,IACpD,OAAQA,EAA+B,IAAI,IAC3C,IACFG,IAAWF,EAAI,mBAAmB,CAAC;CAIzC,QAAQC,GAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,UACH,OAAOC,EAAQ,WAAW,UAAU;EACtC,KAAK;EACL,KAAK,iBACH,OAAOA,EAAQ,QAAQ,UAAU,YAAY,YAAY;EAC3D,KAAK,QACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAQA,SAAgBC,EACd,GACA,GACA,IAAyB,CAAC,GACd;CACZ,IAAMC,IAAOC,EAAQ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UAAU,IAAIL,EAAM,QAAQ,EAAI,GACpCK,EAAI,UAAU,IAAID,GAAa,EAAI,GACnCC,EAAI,UAAU,IAAIN,GAAQ,EAAI;CAC9B,IAAMO,IAAM;EAAC,GAAGnD;EAAO,GAAG2C;EAAS,IAAI,WAAWO,EAAI,MAAM;CAAC,GACvDE,IAAM,IAAI,WAAWD,EAAI,QAAQ,GAAG,MAAMzC,IAAIT,EAAE,QAAQ,CAAC,CAAC,GAC5DoD,IAAK;CACT,KAAK,IAAMpD,KAAKkD,GAEd,AADAC,EAAI,IAAInD,GAAGoD,CAAE,GACb,KAAMpD,EAAE;CAEV,OAAOmD;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","names":["exportFeature","useGridExport"],"sources":["../../src/features/export.ts"],"sourcesContent":["import { useGridExport } from '../composables/useGridExport'\nimport type { ExportFeature } from '../types'\n\n/**\n * CSV export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a CSV file
|
|
1
|
+
{"version":3,"file":"export.js","names":["exportFeature","useGridExport"],"sources":["../../src/features/export.ts"],"sourcesContent":["import { useGridExport } from '../composables/useGridExport'\nimport type { ExportFeature } from '../types'\n\n/**\n * CSV and Excel export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a\n * CSV file, `grid.getCsv()` returns the text, `grid.exportXlsx()` / `grid.getXlsx()` write an Excel\n * workbook with typed cells (the writer loads on demand), `grid.print()` prints every matching row\n * as a table with the header on each page, `grid.copyRows()` copies rows as\n * tab-separated text, and Ctrl/⌘+C copies the selected rows, else the focused cell, as displayed.\n * Columns can set `exportValue` and `exportable: false`. Without it those methods only warn.\n */\nexport const exportFeature: ExportFeature = { feature: 'export', useExport: useGridExport }\n"],"mappings":";;AAWA,IAAaA,IAA+B;CAAE,SAAS;CAAU,WAAWC;AAAc"}
|
package/dist/index.js
CHANGED
|
@@ -16,57 +16,58 @@ import { compareValues as U, nextSort as W, sortRows as G } from "./core/sort.js
|
|
|
16
16
|
import { aggregateRows as K, aggregateValues as q } from "./core/aggregate.js";
|
|
17
17
|
import { groupRows as J, isRowGroup as Y } from "./core/grouping.js";
|
|
18
18
|
import { guardFormula as X, plainText as Z, toCsv as Q, toDelimited as $ } from "./core/csv.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import pe from "./
|
|
25
|
-
import me from "./renderers/
|
|
26
|
-
import he from "./renderers/
|
|
27
|
-
import ge from "./renderers/
|
|
28
|
-
import _e from "./renderers/
|
|
29
|
-
import ve from "./renderers/
|
|
30
|
-
import ye from "./renderers/
|
|
31
|
-
import be from "./renderers/
|
|
32
|
-
import xe from "./renderers/
|
|
33
|
-
import Se from "./renderers/
|
|
34
|
-
import Ce from "./renderers/
|
|
35
|
-
import we from "./renderers/
|
|
36
|
-
import Te from "./renderers/
|
|
37
|
-
import Ee from "./renderers/
|
|
38
|
-
import De from "./renderers/
|
|
39
|
-
import Oe from "./renderers/
|
|
40
|
-
import ke from "./renderers/
|
|
41
|
-
import Ae from "./renderers/
|
|
42
|
-
import je from "./renderers/
|
|
43
|
-
import Me from "./renderers/
|
|
44
|
-
import Ne from "./renderers/
|
|
45
|
-
import Pe from "./renderers/
|
|
46
|
-
import Fe from "./renderers/
|
|
47
|
-
import Ie from "./renderers/
|
|
48
|
-
import Le from "./renderers/
|
|
49
|
-
import Re from "./renderers/
|
|
50
|
-
import ze from "./renderers/
|
|
51
|
-
import
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
|
|
19
|
+
import { toXlsx as ee } from "./core/xlsx.js";
|
|
20
|
+
import { patchRows as te } from "./core/patch.js";
|
|
21
|
+
import { activeFilterCount as ne, emptyFilters as re, filterTree as ie, foldText as ae, isFilterActive as oe, localFilterStorage as se, matchesFilter as ce, parseQuickFilter as le, setKey as ue } from "./core/filter.js";
|
|
22
|
+
import { localStorageAdapter as de } from "./core/storage.js";
|
|
23
|
+
import { pageItems as fe } from "./core/pagination.js";
|
|
24
|
+
import { createColumnHelper as pe } from "./core/helpers.js";
|
|
25
|
+
import me from "./renderers/ActionButtonCell.js";
|
|
26
|
+
import he from "./renderers/ActionsMenuCell.js";
|
|
27
|
+
import ge from "./renderers/BooleanCell.js";
|
|
28
|
+
import _e from "./renderers/ChangeCell.js";
|
|
29
|
+
import ve from "./renderers/CurrencyCell.js";
|
|
30
|
+
import ye from "./renderers/DateCell.js";
|
|
31
|
+
import be from "./renderers/DateTimeCell.js";
|
|
32
|
+
import xe from "./renderers/IconCell.js";
|
|
33
|
+
import Se from "./renderers/JsonCell.js";
|
|
34
|
+
import Ce from "./renderers/JsonTreeCell.js";
|
|
35
|
+
import we from "./renderers/LinkCell.js";
|
|
36
|
+
import Te from "./renderers/NumberCell.js";
|
|
37
|
+
import Ee from "./renderers/StatusCell.js";
|
|
38
|
+
import De from "./renderers/ToggleTextCell.js";
|
|
39
|
+
import Oe from "./renderers/ButtonGroupCell.js";
|
|
40
|
+
import ke from "./renderers/CheckboxCell.js";
|
|
41
|
+
import Ae from "./renderers/ChipCell.js";
|
|
42
|
+
import je from "./renderers/CodeCell.js";
|
|
43
|
+
import Me from "./renderers/CopyCell.js";
|
|
44
|
+
import Ne from "./renderers/DetailsCell.js";
|
|
45
|
+
import Pe from "./renderers/EditCell.js";
|
|
46
|
+
import Fe from "./renderers/IconToggleCell.js";
|
|
47
|
+
import Ie from "./renderers/ImageCell.js";
|
|
48
|
+
import Le from "./renderers/ListCell.js";
|
|
49
|
+
import Re from "./renderers/MultiLineCell.js";
|
|
50
|
+
import ze from "./renderers/RadioCell.js";
|
|
51
|
+
import Be from "./renderers/SwitchCell.js";
|
|
52
|
+
import { actionButtonRenderer as Ve, actionsMenuRenderer as He, allRenderers as Ue, booleanRenderer as We, buttonGroupRenderer as Ge, changeRenderer as Ke, checkboxRenderer as qe, chipRenderer as Je, codeRenderer as Ye, copyRenderer as Xe, currencyRenderer as Ze, dateRenderer as Qe, dateTimeRenderer as $e, detailsRenderer as et, editRenderer as tt, iconRenderer as nt, iconToggleRenderer as rt, imageRenderer as it, jsonRenderer as at, jsonTreeRenderer as ot, linkRenderer as st, listRenderer as ct, multiLineRenderer as lt, numberRenderer as ut, radioRenderer as dt, signedNumberRenderer as ft, statusRenderer as pt, switchRenderer as mt, toggleTextRenderer as ht } from "./renderers/index.js";
|
|
53
|
+
import { aggregationFeature as gt } from "./features/aggregation.js";
|
|
54
|
+
import { columnGroupsFeature as _t } from "./features/columnGroups.js";
|
|
55
|
+
import { columnPinningFeature as vt } from "./features/columnPinning.js";
|
|
56
|
+
import { columnResizingFeature as yt } from "./features/columnResizing.js";
|
|
57
|
+
import { columnReorderFeature as bt } from "./features/columnReorder.js";
|
|
58
|
+
import { columnVisibilityFeature as xt } from "./features/columnVisibility.js";
|
|
59
|
+
import { exportFeature as St } from "./features/export.js";
|
|
60
|
+
import { filteringFeature as Ct } from "./features/filtering.js";
|
|
61
|
+
import { keyboardNavigationFeature as wt } from "./features/keyboardNavigation.js";
|
|
62
|
+
import { menusFeature as Tt } from "./features/menus.js";
|
|
63
|
+
import { paginationFeature as Et } from "./features/pagination.js";
|
|
64
|
+
import { rowGroupingFeature as Dt } from "./features/rowGrouping.js";
|
|
65
|
+
import { rowPinningFeature as Ot } from "./features/rowPinning.js";
|
|
66
|
+
import { selectionFeature as kt } from "./features/selection.js";
|
|
67
|
+
import { serverDataFeature as At } from "./features/serverData.js";
|
|
68
|
+
import { sortingFeature as jt } from "./features/sorting.js";
|
|
69
|
+
import { statusBarFeature as Mt } from "./features/statusBar.js";
|
|
70
|
+
import { subGridsFeature as Nt } from "./features/subGrids.js";
|
|
71
|
+
import { virtualScrollingFeature as Pt } from "./features/virtualScrolling.js";
|
|
72
|
+
import { allFeatures as Ft } from "./features/index.js";
|
|
73
|
+
export { me as ActionButtonCell, he as ActionsMenuCell, ge as BooleanCell, Oe as ButtonGroupCell, _e as ChangeCell, ke as CheckboxCell, Ae as ChipCell, je as CodeCell, Me as CopyCell, ve as CurrencyCell, d as DATE_DEFAULT, ye as DateCell, be as DateTimeCell, Ne as DetailsCell, Pe as EditCell, D as GRID_CONFIG_KEY, xe as IconCell, Fe as IconToggleCell, Ie as ImageCell, Se as JsonCell, Ce as JsonTreeCell, we as LinkCell, Le as ListCell, Re as MultiLineCell, Te as NumberCell, ze as RadioCell, Ee as StatusCell, Be as SwitchCell, f as TIME_DEFAULT, l as TextCell, De as ToggleTextCell, e as VGrid, n as VGridColumnMenu, r as VGridMenu, t as VGridPagination, i as VGridSearch, Ve as actionButtonRenderer, He as actionsMenuRenderer, ne as activeFilterCount, K as aggregateRows, q as aggregateValues, gt as aggregationFeature, Ft as allFeatures, Ue as allRenderers, T as anchorNameFor, We as booleanRenderer, Ge as buttonGroupRenderer, Ke as changeRenderer, qe as checkboxRenderer, Je as chipRenderer, Ye as codeRenderer, _t as columnGroupsFeature, vt as columnPinningFeature, bt as columnReorderFeature, yt as columnResizingFeature, xt as columnVisibilityFeature, U as compareValues, Xe as copyRenderer, pe as createColumnHelper, A as createRendererRegistry, O as createVueGrid, Ze as currencyRenderer, Qe as dateRenderer, $e as dateTimeRenderer, j as defineCellRenderer, et as detailsRenderer, tt as editRenderer, I as effectivePin, re as emptyFilters, St as exportFeature, ie as filterTree, Ct as filteringFeature, ae as foldText, p as formatCurrency, m as formatDate, h as formatNumber, g as formatSigned, N as getByPath, P as getCellValue, J as groupRows, X as guardFormula, nt as iconRenderer, rt as iconToggleRenderer, it as imageRenderer, oe as isFilterActive, M as isRendererDefinition, Y as isRowGroup, at as jsonRenderer, ot as jsonTreeRenderer, wt as keyboardNavigationFeature, st as linkRenderer, ct as listRenderer, se as localFilterStorage, de as localStorageAdapter, a as lookup, ce as matchesFilter, Tt as menusFeature, L as moveColumn, R as moveColumnRelative, lt as multiLineRenderer, W as nextSort, z as normalizeColumnState, ut as numberRenderer, fe as pageItems, Et as paginationFeature, _ as parseJsonish, le as parseQuickFilter, te as patchRows, Z as plainText, dt as radioRenderer, v as readableTextColor, y as resolveImageSrc, o as resolveOption, F as resolveRowKey, s as resolveTone, Dt as rowGroupingFeature, Ot as rowPinningFeature, b as safeHref, c as safeTone, kt as selectionFeature, At as serverDataFeature, B as setColumnHidden, V as setColumnPinned, ue as setKey, ft as signedNumberRenderer, G as sortRows, jt as sortingFeature, Mt as statusBarFeature, pt as statusRenderer, x as stringifyJson, Nt as subGridsFeature, E as supportsAnchorPositioning, mt as switchRenderer, u as textRenderer, Q as toCsv, S as toDate, $ as toDelimited, C as toNumber, ee as toXlsx, ht as toggleTextRenderer, w as tokenizeJson, k as useGridContext, Pt as virtualScrollingFeature, H as visibleColumns };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["SELECT_COLUMN_KEY","GRID_CONTEXT_KEY","useInternalGrid","ctx","inject"],"sources":["../../src/internal/context.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rows are an opaque, type-erased T inside the grid internals; the public <VGrid generic=\"T\"> API stays fully typed. */\nimport { inject, type Component, type ComputedRef, type InjectionKey, type Slots } from 'vue'\nimport type {\n Align,\n CellRendererDefinition,\n ClassValue,\n ColumnDef,\n FlashMode,\n GridPart,\n RowKey,\n} from '../types'\nimport type { ColumnFilter, FilterState, FilterType } from '../core/filter'\nimport type { SelectionSummary } from '../core/selection'\nimport type { SubRowEntry } from '../composables/useSubRows'\nimport type { DistinctValue } from '../composables/useGridFilters'\nimport type { VirtualRowsContext } from '../composables/useVirtualRows'\n\nexport const SELECT_COLUMN_KEY = '__vg_select'\n\n/** A visible column with everything the cells need precomputed. */\nexport interface ResolvedColumn {\n key: string\n kind: 'data' | 'select'\n def: ColumnDef\n component: Component | undefined\n definition: CellRendererDefinition | undefined\n options: Record<string, unknown>\n align: Align\n pinned: 'left' | 'right' | undefined\n /** Last left-pinned or first right-pinned column. Only set where CSS `:has()` is unsupported. */\n pinEdge: boolean\n /** First data column — hosts the expander and the depth indent. */\n isTree: boolean\n}\n\nexport interface GridContext {\n columns: ComputedRef<ResolvedColumn[]>\n slots: Slots\n ui: ComputedRef<Partial<Record<GridPart, ClassValue>>>\n getKey(row: any): RowKey\n /**\n * Keyboard navigation (ARIA grid) is on: cells are `gridcell`s and the grid's own controls are\n * `tabindex=\"-1\"` (reached with the arrow keys). Off: an ARIA `table` with tabbable controls.\n */\n keyboardNav: boolean\n /** `gridcell` or `cell`, by `keyboardNav`. */\n cellRole: 'gridcell' | 'cell'\n /** Tabindex for the grid's own controls and cells: `-1` with keyboard navigation, else none. */\n rovingTabindex: -1 | undefined\n /** Filters (client mode) and sorts one level of rows. */\n sortRows(rows: readonly any[]): any[]\n /** The sorting feature is on and the column is `sortable`. */\n sortable(col: ColumnDef): boolean\n /** Only with the column resizing feature. */\n resize?: {\n /** The header edge grip component. */\n Handle: Component\n can(col: ColumnDef): boolean\n start(event: PointerEvent, key: string): void\n autosize(key: string): void\n step(key: string, delta: number): void\n /** Has a resized width (or is being resized): its cells clip their content. */\n isSized(key: string): boolean\n }\n /** Header rows above the body (2 with column groups). */\n headerRows: ComputedRef<number>\n /** Pinned rows (and a totals row) above the body: offsets the body's `aria-rowindex`. */\n pinnedTopCount: ComputedRef<number>\n /** Aggregation feature with a totals row: the values by column key, and the row's label. */\n totals?: {\n values: ComputedRef<Record<string, unknown>>\n label: ComputedRef<string>\n }\n /** Row grouping feature, with rows grouped: renders the cells of group rows. */\n grouping?: { GroupCells: Component; isGroup(row: any): boolean }\n // expansion\n /** Rows nest (sub-grids, or grouped rows): the first column has the expander gutter. */\n treeMode: ComputedRef<boolean>\n hasDetail: ComputedRef<boolean>\n canExpand(row: any): boolean\n isExpanded(key: RowKey): boolean\n toggleExpanded(row: any): void\n children(row: any): any[] | undefined\n subRowState(row: any): SubRowEntry | undefined\n ensureSubRows(row: any): void\n retrySubRows(row: any): void\n // selection\n selectMode: ComputedRef<false | 'multi' | 'single'>\n /** The selection checkbox (from the selection feature; only rendered when `selectMode` is set). */\n Checkbox: Component | undefined\n isRowSelectable(row: any): boolean\n rowCheckState(row: any): SelectionSummary\n /** `range`: Shift was held — select from the last toggled row to this one. */\n toggleRow(row: any, range?: boolean): void\n // presentation & events\n isHighlighted(key: RowKey): boolean\n rowClass(row: any, index: number): ClassValue\n rowClickable: ComputedRef<boolean>\n /** Grid-wide change highlight (columns may override with `flash`). */\n flash: ComputedRef<FlashMode>\n /** Only with the filtering feature. */\n filters?: {\n FilterButton: Component\n FilterInput: Component\n state: ComputedRef<FilterState>\n setSearch(search: string): void\n setColumnFilter(key: string, filter: ColumnFilter | undefined): void\n isActive(key: string): boolean\n typeOf(col: ColumnDef): FilterType | 'custom'\n /** Show the filter row (inputs inside the header cells). */\n filterRow: ComputedRef<boolean>\n /** Distinct values of a column, for its value-list filter. */\n distinct(key: string): DistinctValue[]\n /** DOM id of a column's filter popover. */\n idFor(key: string): string\n /** Opens a column's filter popover (header menu, filter row). */\n open(key: string): void\n }\n virtual: ComputedRef<boolean>\n /** With the virtual scrolling feature: windowing of each level of rows, and measuring. */\n virtualRows?: VirtualRowsContext\n pinStyle(key: string): Record<string, string> | undefined\n onRowClick(row: any, key: RowKey, event: MouseEvent | KeyboardEvent): void\n onCellClick(\n row: any,\n key: RowKey,\n column: ResolvedColumn,\n event: MouseEvent | KeyboardEvent,\n ): void\n onCellAction(row: any, key: RowKey, column: ResolvedColumn, name: string, payload: unknown): void\n onCellContextMenu(\n row: any,\n key: RowKey,\n column: ResolvedColumn,\n event: MouseEvent,\n el: HTMLElement,\n ): void\n onHeaderContextMenu(column: ResolvedColumn, event: MouseEvent, el: HTMLElement): void\n /** Menus feature: a `pointerdown` on a body cell (touch: hold for its menu). */\n onCellPointerDown?(\n row: any,\n key: RowKey,\n column: ResolvedColumn,\n event: PointerEvent,\n el: HTMLElement,\n ): void\n}\n\n/** A row in a pinned section: a pinned data row, or the totals row. */\nexport interface PinnedRowItem {\n /** Unique within the grid's pinned rows. */\n id: string\n kind: 'row' | 'total'\n row: any\n key: RowKey\n /** Shows the selection checkbox (pinned rows of the data, not the app's extra rows). */\n selectable: boolean\n}\n\nexport const GRID_CONTEXT_KEY: InjectionKey<GridContext> = Symbol('vue-grid:context')\n\nexport function useInternalGrid(): GridContext {\n const ctx = inject(GRID_CONTEXT_KEY)\n if (!ctx) throw new Error('[vue-grid] internal component used outside <VGrid>')\n return ctx\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"context.js","names":["SELECT_COLUMN_KEY","GRID_CONTEXT_KEY","useInternalGrid","ctx","inject"],"sources":["../../src/internal/context.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rows are an opaque, type-erased T inside the grid internals; the public <VGrid generic=\"T\"> API stays fully typed. */\nimport { inject, type Component, type ComputedRef, type InjectionKey, type Slots } from 'vue'\nimport type {\n Align,\n CellRendererDefinition,\n ClassValue,\n ColumnDef,\n FlashMode,\n GridMessages,\n GridPart,\n GridParts,\n RowKey,\n} from '../types'\nimport type { ColumnFilter, FilterState, FilterType } from '../core/filter'\nimport type { SelectionSummary } from '../core/selection'\nimport type { SubRowEntry } from '../composables/useSubRows'\nimport type { DistinctValue } from '../composables/useGridFilters'\nimport type { VirtualRowsContext } from '../composables/useVirtualRows'\n\nexport const SELECT_COLUMN_KEY = '__vg_select'\n\n/** A visible column with everything the cells need precomputed. */\nexport interface ResolvedColumn {\n key: string\n kind: 'data' | 'select'\n def: ColumnDef\n component: Component | undefined\n definition: CellRendererDefinition | undefined\n options: Record<string, unknown>\n align: Align\n pinned: 'left' | 'right' | undefined\n /** Last left-pinned or first right-pinned column. Only set where CSS `:has()` is unsupported. */\n pinEdge: boolean\n /** First data column — hosts the expander and the depth indent. */\n isTree: boolean\n}\n\nexport interface GridContext {\n columns: ComputedRef<ResolvedColumn[]>\n slots: Slots\n /** Built-in text (the grid's over the app's); each use keeps its English default. */\n messages: ComputedRef<GridMessages>\n /** Built-in parts; a part is on unless `false`. */\n parts: ComputedRef<GridParts>\n ui: ComputedRef<Partial<Record<GridPart, ClassValue>>>\n getKey(row: any): RowKey\n /**\n * Keyboard navigation (ARIA grid) is on: cells are `gridcell`s and the grid's own controls are\n * `tabindex=\"-1\"` (reached with the arrow keys). Off: an ARIA `table` with tabbable controls.\n */\n keyboardNav: boolean\n /** `gridcell` or `cell`, by `keyboardNav`. */\n cellRole: 'gridcell' | 'cell'\n /** Tabindex for the grid's own controls and cells: `-1` with keyboard navigation, else none. */\n rovingTabindex: -1 | undefined\n /** Filters (client mode) and sorts one level of rows. */\n sortRows(rows: readonly any[]): any[]\n /** The sorting feature is on and the column is `sortable`. */\n sortable(col: ColumnDef): boolean\n /** Only with the column resizing feature. */\n resize?: {\n /** The header edge grip component. */\n Handle: Component\n can(col: ColumnDef): boolean\n start(event: PointerEvent, key: string): void\n autosize(key: string): void\n step(key: string, delta: number): void\n /** Has a resized width (or is being resized): its cells clip their content. */\n isSized(key: string): boolean\n }\n /** Header rows above the body (2 with column groups). */\n headerRows: ComputedRef<number>\n /** Pinned rows (and a totals row) above the body: offsets the body's `aria-rowindex`. */\n pinnedTopCount: ComputedRef<number>\n /** Aggregation feature with a totals row: the values by column key, and the row's label. */\n totals?: {\n values: ComputedRef<Record<string, unknown>>\n label: ComputedRef<string>\n }\n /** Row grouping feature, with rows grouped: renders the cells of group rows. */\n grouping?: { GroupCells: Component; isGroup(row: any): boolean }\n // expansion\n /** Rows nest (sub-grids, or grouped rows): the first column has the expander gutter. */\n treeMode: ComputedRef<boolean>\n hasDetail: ComputedRef<boolean>\n canExpand(row: any): boolean\n isExpanded(key: RowKey): boolean\n toggleExpanded(row: any): void\n children(row: any): any[] | undefined\n subRowState(row: any): SubRowEntry | undefined\n ensureSubRows(row: any): void\n retrySubRows(row: any): void\n // selection\n selectMode: ComputedRef<false | 'multi' | 'single'>\n /** The selection checkbox (from the selection feature; only rendered when `selectMode` is set). */\n Checkbox: Component | undefined\n isRowSelectable(row: any): boolean\n rowCheckState(row: any): SelectionSummary\n /** `range`: Shift was held — select from the last toggled row to this one. */\n toggleRow(row: any, range?: boolean): void\n // presentation & events\n isHighlighted(key: RowKey): boolean\n rowClass(row: any, index: number): ClassValue\n rowClickable: ComputedRef<boolean>\n /** Grid-wide change highlight (columns may override with `flash`). */\n flash: ComputedRef<FlashMode>\n /** Only with the filtering feature. */\n filters?: {\n FilterButton: Component\n FilterInput: Component\n state: ComputedRef<FilterState>\n setSearch(search: string): void\n setColumnFilter(key: string, filter: ColumnFilter | undefined): void\n isActive(key: string): boolean\n typeOf(col: ColumnDef): FilterType | 'custom'\n /** Show the filter row (inputs inside the header cells). */\n filterRow: ComputedRef<boolean>\n /** Distinct values of a column, for its value-list filter. */\n distinct(key: string): DistinctValue[]\n /** DOM id of a column's filter popover. */\n idFor(key: string): string\n /** Opens a column's filter popover (header menu, filter row). */\n open(key: string): void\n }\n virtual: ComputedRef<boolean>\n /** With the virtual scrolling feature: windowing of each level of rows, and measuring. */\n virtualRows?: VirtualRowsContext\n pinStyle(key: string): Record<string, string> | undefined\n onRowClick(row: any, key: RowKey, event: MouseEvent | KeyboardEvent): void\n onCellClick(\n row: any,\n key: RowKey,\n column: ResolvedColumn,\n event: MouseEvent | KeyboardEvent,\n ): void\n onCellAction(row: any, key: RowKey, column: ResolvedColumn, name: string, payload: unknown): void\n onCellContextMenu(\n row: any,\n key: RowKey,\n column: ResolvedColumn,\n event: MouseEvent,\n el: HTMLElement,\n ): void\n onHeaderContextMenu(column: ResolvedColumn, event: MouseEvent, el: HTMLElement): void\n /** Menus feature: a `pointerdown` on a body cell (touch: hold for its menu). */\n onCellPointerDown?(\n row: any,\n key: RowKey,\n column: ResolvedColumn,\n event: PointerEvent,\n el: HTMLElement,\n ): void\n}\n\n/** A row in a pinned section: a pinned data row, or the totals row. */\nexport interface PinnedRowItem {\n /** Unique within the grid's pinned rows. */\n id: string\n kind: 'row' | 'total'\n row: any\n key: RowKey\n /** Shows the selection checkbox (pinned rows of the data, not the app's extra rows). */\n selectable: boolean\n}\n\nexport const GRID_CONTEXT_KEY: InjectionKey<GridContext> = Symbol('vue-grid:context')\n\nexport function useInternalGrid(): GridContext {\n const ctx = inject(GRID_CONTEXT_KEY)\n if (!ctx) throw new Error('[vue-grid] internal component used outside <VGrid>')\n return ctx\n}\n"],"mappings":";;AAmBA,IAAaA,IAAoB,eAkJpBC,IAA8C,OAAO,kBAAkB;AAEpF,SAAgBC,IAA+B;CAC7C,IAAMC,IAAMC,EAAOH,CAAgB;CACnC,IAAI,CAACE,GAAK,MAAU,MAAM,oDAAoD;CAC9E,OAAOA;AACT"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GRID_CONFIG_KEY as e } from "../registry/plugin.js";
|
|
2
|
+
import { computed as t, inject as n } from "vue";
|
|
3
|
+
// src/internal/messages.ts
|
|
4
|
+
var r = Symbol("vue-grid:messages"), i = Symbol("vue-grid:parts");
|
|
5
|
+
function a() {
|
|
6
|
+
let i = n(r, void 0);
|
|
7
|
+
if (i) return i;
|
|
8
|
+
let a = n(e, void 0);
|
|
9
|
+
return t(() => a?.messages ?? {});
|
|
10
|
+
}
|
|
11
|
+
function o() {
|
|
12
|
+
let r = n(i, void 0);
|
|
13
|
+
if (r) return r;
|
|
14
|
+
let a = n(e, void 0);
|
|
15
|
+
return t(() => a?.parts ?? {});
|
|
16
|
+
}
|
|
17
|
+
var s = (e, t) => e[t] !== !1;
|
|
18
|
+
export { r as MESSAGES_KEY, i as PARTS_KEY, s as partOn, a as useMessages, o as useParts };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","names":["MESSAGES_KEY","PARTS_KEY","useMessages","grid","inject","config","GRID_CONFIG_KEY","computed","useParts","partOn","parts","name"],"sources":["../../src/internal/messages.ts"],"sourcesContent":["import { computed, inject, type ComputedRef, type InjectionKey } from 'vue'\nimport { GRID_CONFIG_KEY } from '../registry/plugin'\nimport type { GridMessages, GridParts } from '../types'\n\n/** A grid's messages and parts: its own props over `createVueGrid` config. */\nexport const MESSAGES_KEY: InjectionKey<ComputedRef<GridMessages>> = Symbol('vue-grid:messages')\nexport const PARTS_KEY: InjectionKey<ComputedRef<GridParts>> = Symbol('vue-grid:parts')\n\n/**\n * The built-in text in effect: the nearest grid's, else the app's (`createVueGrid({ messages })`),\n * for components used on their own (`<VGridPagination>`, `<VGridSearch>`…). Each caller keeps its\n * English default next to the text (`m.value.retry ?? 'Retry'`), so unused features' text\n * tree-shakes away with them.\n */\nexport function useMessages(): ComputedRef<GridMessages> {\n const grid = inject(MESSAGES_KEY, undefined)\n if (grid) return grid\n const config = inject(GRID_CONFIG_KEY, undefined)\n return computed(() => config?.messages ?? {})\n}\n\n/** The built-in parts in effect (each `true` unless turned off). */\nexport function useParts(): ComputedRef<GridParts> {\n const grid = inject(PARTS_KEY, undefined)\n if (grid) return grid\n const config = inject(GRID_CONFIG_KEY, undefined)\n return computed(() => config?.parts ?? {})\n}\n\n/** Is a part on? Parts are on unless set to `false`. */\nexport const partOn = (parts: GridParts, name: keyof GridParts) => parts[name] !== false\n"],"mappings":";;;AAKA,IAAaA,IAAwD,OAAO,mBAAmB,GAClFC,IAAkD,OAAO,gBAAgB;AAQtF,SAAgBC,IAAyC;CACvD,IAAMC,IAAOC,EAAOJ,GAAc,KAAA,CAAS;CAC3C,IAAIG,GAAM,OAAOA;CACjB,IAAME,IAASD,EAAOE,GAAiB,KAAA,CAAS;CAChD,OAAOC,QAAeF,GAAQ,YAAY,CAAC,CAAC;AAC9C;AAGA,SAAgBG,IAAmC;CACjD,IAAML,IAAOC,EAAOH,GAAW,KAAA,CAAS;CACxC,IAAIE,GAAM,OAAOA;CACjB,IAAME,IAASD,EAAOE,GAAiB,KAAA,CAAS;CAChD,OAAOC,QAAeF,GAAQ,SAAS,CAAC,CAAC;AAC3C;AAGA,IAAaI,KAAU,GAAkB,MAA0BC,EAAMC,OAAU"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function e(e) {
|
|
2
|
+
return new Promise((t) => {
|
|
3
|
+
let n = document.createElement("iframe");
|
|
4
|
+
n.setAttribute("aria-hidden", "true"), n.tabIndex = -1, n.title = e.title ?? "Print", Object.assign(n.style, {
|
|
5
|
+
position: "fixed",
|
|
6
|
+
insetInlineStart: "-10000px",
|
|
7
|
+
insetBlockStart: "0",
|
|
8
|
+
width: "1000px",
|
|
9
|
+
height: "1000px",
|
|
10
|
+
border: "0"
|
|
11
|
+
}), document.body.appendChild(n);
|
|
12
|
+
let r = n.contentWindow, i = n.contentDocument, a = (e, t, n) => {
|
|
13
|
+
let r = i.createElement(e);
|
|
14
|
+
return t !== void 0 && (r.textContent = t), n && (r.className = n), r;
|
|
15
|
+
}, o = (t) => e.align[t] === "start" ? void 0 : e.align[t];
|
|
16
|
+
i.title = e.title ?? "", i.documentElement.lang = document.documentElement.lang || "en";
|
|
17
|
+
let s = a("style", "\n@page { margin: 12mm; }\n@page landscape { size: landscape; }\nhtml { font: 9.5pt/1.35 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #111; }\nbody { margin: 0; }\nh1 { font-size: 12pt; margin: 0 0 6pt; }\ntable { border-collapse: collapse; width: 100%; }\nth, td { border: 0.5pt solid #bbb; padding: 2pt 4pt; text-align: start; vertical-align: top;\n overflow-wrap: anywhere; white-space: pre-line; }\nthead th { background: #eef1f5; font-weight: 600; -webkit-print-color-adjust: exact; print-color-adjust: exact; }\n.total td { font-weight: 700; border-top: 1pt solid #666; }\ntr { break-inside: avoid; }\n.end { text-align: end; font-variant-numeric: tabular-nums; }\n.center { text-align: center; }\n" + (e.landscape ? "body { page: landscape; }" : ""));
|
|
18
|
+
i.head.append(s), e.title && i.body.append(a("h1", e.title));
|
|
19
|
+
let c = a("table");
|
|
20
|
+
if (e.header) {
|
|
21
|
+
let t = a("tr");
|
|
22
|
+
e.header.forEach((e, n) => {
|
|
23
|
+
let r = a("th", e, o(n));
|
|
24
|
+
r.scope = "col", t.append(r);
|
|
25
|
+
});
|
|
26
|
+
let n = a("thead");
|
|
27
|
+
n.append(t), c.append(n);
|
|
28
|
+
}
|
|
29
|
+
let l = a("tbody");
|
|
30
|
+
for (let t of e.body) {
|
|
31
|
+
let e = a("tr");
|
|
32
|
+
t.forEach((t, n) => e.append(a("td", t, o(n)))), l.append(e);
|
|
33
|
+
}
|
|
34
|
+
if (c.append(l), e.footer) {
|
|
35
|
+
let t = a("tr");
|
|
36
|
+
e.footer.forEach((e, n) => t.append(a("td", e, o(n)))), t.className = "total", l.append(t);
|
|
37
|
+
}
|
|
38
|
+
i.body.append(c);
|
|
39
|
+
let u = !1, d = () => {
|
|
40
|
+
u || (u = !0, window.removeEventListener("focus", d), n.remove(), t());
|
|
41
|
+
};
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
r.addEventListener("afterprint", d, { once: !0 }), r.focus();
|
|
44
|
+
let e = Date.now();
|
|
45
|
+
r.print(), Date.now() - e > 250 ? d() : u || window.addEventListener("focus", d, { once: !0 });
|
|
46
|
+
}, 0);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { e as printTable };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","names":["printTable","frame","t","win","doc","el","node","tag","text","className","cls","i","style","table","row","th","h","thead","body","line","done","finish","resolve","started"],"sources":["../../src/internal/print.ts"],"sourcesContent":["import type { Align } from '../types'\n\n/** A table to print: text cells, with the header repeated on every page. */\nexport interface PrintTable {\n title?: string\n header?: readonly string[]\n body: readonly (readonly string[])[]\n /** A last, bold line (the totals row). */\n footer?: readonly string[]\n align: readonly Align[]\n landscape?: boolean\n}\n\nconst CSS = `\n@page { margin: 12mm; }\n@page landscape { size: landscape; }\nhtml { font: 9.5pt/1.35 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #111; }\nbody { margin: 0; }\nh1 { font-size: 12pt; margin: 0 0 6pt; }\ntable { border-collapse: collapse; width: 100%; }\nth, td { border: 0.5pt solid #bbb; padding: 2pt 4pt; text-align: start; vertical-align: top;\n overflow-wrap: anywhere; white-space: pre-line; }\nthead th { background: #eef1f5; font-weight: 600; -webkit-print-color-adjust: exact; print-color-adjust: exact; }\n.total td { font-weight: 700; border-top: 1pt solid #666; }\ntr { break-inside: avoid; }\n.end { text-align: end; font-variant-numeric: tabular-nums; }\n.center { text-align: center; }\n`\n\n/**\n * Prints a table from a hidden frame: the browser's print dialog, with a real `<table>` (so the\n * header repeats on each page), built with DOM calls only. Resolves when printing is over.\n */\nexport function printTable(t: PrintTable): Promise<void> {\n return new Promise((resolve) => {\n const frame = document.createElement('iframe')\n frame.setAttribute('aria-hidden', 'true')\n frame.tabIndex = -1\n frame.title = t.title ?? 'Print'\n // Off-screen but laid out: some browsers print an invisible frame blank.\n Object.assign(frame.style, {\n position: 'fixed',\n insetInlineStart: '-10000px',\n insetBlockStart: '0',\n width: '1000px',\n height: '1000px',\n border: '0',\n })\n document.body.appendChild(frame)\n const win = frame.contentWindow!\n const doc = frame.contentDocument!\n const el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n text?: string,\n className?: string,\n ) => {\n const node = doc.createElement(tag)\n if (text !== undefined) node.textContent = text\n if (className) node.className = className\n return node\n }\n const cls = (i: number) => (t.align[i] === 'start' ? undefined : t.align[i])\n\n doc.title = t.title ?? ''\n doc.documentElement.lang = document.documentElement.lang || 'en'\n const style = el('style', CSS + (t.landscape ? 'body { page: landscape; }' : ''))\n doc.head.append(style)\n if (t.title) doc.body.append(el('h1', t.title))\n const table = el('table')\n if (t.header) {\n const row = el('tr')\n t.header.forEach((h, i) => {\n const th = el('th', h, cls(i))\n th.scope = 'col'\n row.append(th)\n })\n const thead = el('thead')\n thead.append(row)\n table.append(thead)\n }\n const body = el('tbody')\n for (const line of t.body) {\n const row = el('tr')\n line.forEach((text, i) => row.append(el('td', text, cls(i))))\n body.append(row)\n }\n table.append(body)\n if (t.footer) {\n const row = el('tr')\n t.footer.forEach((text, i) => row.append(el('td', text, cls(i))))\n // A last body row, not a <tfoot>: browsers repeat a table footer on every printed page.\n row.className = 'total'\n body.append(row)\n }\n doc.body.append(table)\n\n let done = false\n const finish = () => {\n if (done) return\n done = true\n window.removeEventListener('focus', finish)\n frame.remove()\n resolve()\n }\n // After layout. `print()` blocks until the dialog closes in most browsers; where it doesn't,\n // `afterprint` (or the page getting focus back) ends it.\n setTimeout(() => {\n win.addEventListener('afterprint', finish, { once: true })\n win.focus()\n const started = Date.now()\n win.print()\n // It blocked while the dialog was open: printing is over.\n if (Date.now() - started > 250) finish()\n else if (!done) window.addEventListener('focus', finish, { once: true })\n }, 0)\n })\n}\n"],"mappings":"AAiCA,SAAgBA,EAAW,GAA8B;CACvD,OAAO,IAAI,SAAS,MAAY;EAC9B,IAAMC,IAAQ,SAAS,cAAc,QAAQ;EAa7C,AAZAA,EAAM,aAAa,eAAe,MAAM,GACxC,EAAM,WAAW,IACjB,EAAM,QAAQC,EAAE,SAAS,SAEzB,OAAO,OAAOD,EAAM,OAAO;GACzB,UAAU;GACV,kBAAkB;GAClB,iBAAiB;GACjB,OAAO;GACP,QAAQ;GACR,QAAQ;EACV,CAAC,GACD,SAAS,KAAK,YAAYA,CAAK;EAC/B,IAAME,IAAMF,EAAM,eACZG,IAAMH,EAAM,iBACZI,KACJ,GACA,GACA,MACG;GACH,IAAMC,IAAOF,EAAI,cAAcG,CAAG;GAGlC,OAFIC,MAAS,KAAA,MAAW,EAAK,cAAcA,IACvCC,MAAW,EAAK,YAAYA,IACzBH;EACT,GACMI,KAAO,MAA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