-
Notifications
You must be signed in to change notification settings - Fork 3
Model workbook-defined (custom) table styles #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0316a9b
Model workbook-defined (custom) table styles
gthb 252f345
Accept custom style names in TableStyle/PivotTableStyle
gthb b84f4d1
Merge remote-tracking branch 'origin/main' into pivot-custom-table-st…
gthb 29921e8
Extract LooseAutocomplete helper for widened style name unions
gthb a266fe5
Revert LooseAutocomplete; use plain `| string` for custom style names
gthb 4bf2b53
Model table-style applicability as an enum, not two booleans
gthb 57ef8aa
Document TableStyleElementType regions as a JSDoc table
gthb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { TableStyleElement } from './TableStyleElement.ts'; | ||
|
|
||
| /** | ||
| * A workbook-defined (custom) style for tables and/or pivot tables. | ||
| * | ||
| * Definitions live in {@link Workbook.tableStyles} and are referenced by name from | ||
| * {@link TableStyle.name} and {@link PivotTableStyle.name}, the same way built-in style | ||
| * names are referenced. | ||
| * | ||
| * A definition only describes the regions it lists; regions without an element get no | ||
| * formatting from the style. Regions overlap (e.g. a header-row cell is also part of the | ||
| * whole table), in which case the more specific region's formatting wins, property by | ||
| * property. | ||
| * | ||
| * @group Workbooks | ||
| */ | ||
| export type TableStyleDefinition = { | ||
| /** | ||
| * The name of the style, as referenced from tables and pivot tables. Must match the | ||
| * definition's key in {@link Workbook.tableStyles}. | ||
| */ | ||
| name: string; | ||
| /** | ||
| * Whether this style may be applied to pivot tables, regular tables, or both. | ||
| * | ||
| * @default "all" | ||
| */ | ||
| table?: 'table' | 'pivot' | 'all'; | ||
| /** The formatting of each table region that this style defines. */ | ||
| elements?: TableStyleElement[]; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import type { integer } from '../integer.ts'; | ||
| import type { Style } from '../styles/index.ts'; | ||
| import type { TableStyleElementType } from './TableStyleElementType.ts'; | ||
|
|
||
| /** | ||
| * The formatting of one region of a table or pivot table, within a | ||
| * {@link TableStyleDefinition}. | ||
| * | ||
| * @group Workbooks | ||
| */ | ||
| export type TableStyleElement = { | ||
| /** The table region this element's formatting applies to. */ | ||
| type: TableStyleElementType; | ||
| /** | ||
| * The number of consecutive rows or columns in each stripe band. Only meaningful for the | ||
| * four stripe element types. | ||
| * | ||
| * @default 1 | ||
| */ | ||
| size?: integer; | ||
| /** | ||
| * The formatting to overlay on the region's cells. Only the properties present apply; | ||
| * everything else on a cell is left as-is (differential-format semantics). An element | ||
| * without a style has no visual effect (a stripe element may still carry a meaningful | ||
| * {@link size}). | ||
| */ | ||
| style?: Style; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * The region of a table or pivot table that a {@link TableStyleElement} applies to. | ||
| * | ||
| * Some regions only occur in tables (e.g. `totalRow`), others only in pivot tables (e.g. | ||
| * `pageFieldLabels`, the subheading and subtotal regions); a style definition usable for | ||
| * both kinds of table may include elements for both. | ||
| * | ||
| * The `Kind` column below indicates which kind of table each region applies to. | ||
| * | ||
| * | Value | Kind | Region | ||
| * |--------------------------|-------|----------------------------------------------------------- | ||
| * | `wholeTable` | both | The entire table. | ||
| * | `headerRow` | both | The header row. | ||
| * | `totalRow` | table | The totals row. | ||
| * | `firstColumn` | both | The first column. | ||
| * | `lastColumn` | both | The last column. | ||
| * | `firstRowStripe` | both | Odd row stripes (the first, third, … band of rows). | ||
| * | `secondRowStripe` | both | Even row stripes (the second, fourth, … band of rows). | ||
| * | `firstColumnStripe` | both | Odd column stripes (the first, third, … band of columns). | ||
| * | `secondColumnStripe` | both | Even column stripes (the second, fourth, … band of columns). | ||
| * | `firstHeaderCell` | table | The first cell of the header row. | ||
| * | `lastHeaderCell` | table | The last cell of the header row. | ||
| * | `firstTotalCell` | table | The first cell of the totals row. | ||
| * | `lastTotalCell` | table | The last cell of the totals row. | ||
| * | `firstSubtotalColumn` | pivot | First-level subtotal columns. | ||
| * | `secondSubtotalColumn` | pivot | Second-level subtotal columns. | ||
| * | `thirdSubtotalColumn` | pivot | Third-level subtotal columns. | ||
| * | `firstSubtotalRow` | pivot | First-level subtotal rows. | ||
| * | `secondSubtotalRow` | pivot | Second-level subtotal rows. | ||
| * | `thirdSubtotalRow` | pivot | Third-level subtotal rows. | ||
| * | `blankRow` | pivot | Blank rows. | ||
| * | `firstColumnSubheading` | pivot | First-level column subheadings. | ||
| * | `secondColumnSubheading` | pivot | Second-level column subheadings. | ||
| * | `thirdColumnSubheading` | pivot | Third-level column subheadings. | ||
| * | `firstRowSubheading` | pivot | First-level row subheadings. | ||
| * | `secondRowSubheading` | pivot | Second-level row subheadings. | ||
| * | `thirdRowSubheading` | pivot | Third-level row subheadings. | ||
| * | `pageFieldLabels` | pivot | Page field label cells (the filter-field name cells). | ||
| * | `pageFieldValues` | pivot | Page field value cells (the filter-field selection cells). | ||
| * | ||
| * @group Workbooks | ||
| */ | ||
| export type TableStyleElementType = | ||
| 'wholeTable' | | ||
| 'headerRow' | | ||
| 'totalRow' | | ||
| 'firstColumn' | | ||
| 'lastColumn' | | ||
| 'firstRowStripe' | | ||
| 'secondRowStripe' | | ||
| 'firstColumnStripe' | | ||
| 'secondColumnStripe' | | ||
| 'firstHeaderCell' | | ||
| 'lastHeaderCell' | | ||
| 'firstTotalCell' | | ||
| 'lastTotalCell' | | ||
| 'firstSubtotalColumn' | | ||
| 'secondSubtotalColumn' | | ||
| 'thirdSubtotalColumn' | | ||
| 'firstSubtotalRow' | | ||
| 'secondSubtotalRow' | | ||
| 'thirdSubtotalRow' | | ||
| 'blankRow' | | ||
| 'firstColumnSubheading' | | ||
| 'secondColumnSubheading' | | ||
| 'thirdColumnSubheading' | | ||
| 'firstRowSubheading' | | ||
| 'secondRowSubheading' | | ||
| 'thirdRowSubheading' | | ||
| 'pageFieldLabels' | | ||
| 'pageFieldValues'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be converting differential styles to regular styles. We should be using indexes into a list of differential styles. Dxf's will be shared between at least pivot tables, dynamic styles, and this and we should model them correctly instead of creating legacy (which I fear I have already done by merging and shipping #53).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK! Does it make sense for me to try to draft something towards this, or is there no point because it will call on a bunch of latent domain-knowledge that currently exists only in your head and those of a couple of ex-Microsoft retirees? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question. It appears to me that dxf's are pretty much what we think they are, ie. what is captured in this PR + what we know about the general indexing of styles (named- or cell-). So I think this is pretty much a "do the same as with cell styles but make sure docs & types reflect how dxf's work". I don't have much time right now to think about this because I'm doing something that's on a semi-deadline, but if you don't mind a bit of a delay before I can reasonably catch up with you, then just go for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And ... we already have PivotFormat.style released ... will that need to change to
dxfId?: integer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. We've never shipped a reader so it might be simplest just to flip to the int and bump a major version.
Of course we are free to pick a simpler prop name: We use s for style, so we can be justified in just d, ds, dxf or whatever we like. Kinda depends on whether we're able to think of anything catcher than .differentialStyles[] for the list. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A draft is up in #55, some things still left to hash out there. Went with
diffStylesfor the list name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And stacked on that, a draft of a dxf-based replacement superseding this, up at #56.