docs: add JSDoc to CellStyle.baseStyleNames (#222)

development
Thomas Bouffard 2023-08-28 08:36:11 +02:00 committed by GitHub
parent e48f3fa052
commit e5a28b3f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -38,7 +38,23 @@ export type Properties = {
[k: string]: any;
};
export type CellStyle = CellStateStyle & { baseStyleNames?: string[] };
export type CellStyle = CellStateStyle & {
/**
* Names of styles used to fill properties before applying the specific properties defined in {@link CellStateStyle}.
*
* Here's the initial algorithm for populating properties:
* - Take the style name in order from the table
* - Retrieve the style associated with the style registered in {@link StyleSheet}.
* Ignore unknown styles
* - Merge the current style with the style retrieved from `StyleSheet`.
*
* Once the initial population of properties is complete, merge the style with the properties defined {@link CellStateStyle}.
*
**NOTE**: the order of styles in the array is important: if the same property is defined in several styles,
* the value actually used is that defined in the last style declared in the array.
*/
baseStyleNames?: string[];
};
export type CellStateStyle = {
/**

View File

@ -184,10 +184,10 @@ export class Stylesheet {
// creates style with the given baseStyleNames. (merges from left to right)
style = cellStyle.baseStyleNames.reduce(
(acc, styleName) => {
return (acc = {
return {
...acc,
...this.styles.get(styleName),
});
};
},
{ ...defaultStyle }
);