Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/lib/table-context.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,39 @@ const defaultContextOptions: Required<TableContextOptions> = {
emptyCellContent: undefined
};

/**
* Class that collects and maintains reactive configuration options for Markdown-rendered tables.
*/
export class TableContext {
/**
* The media query used to determine how the table will be rendered.
*/
mq: MediaQuery;
/**
* The container context for the table header.
*/
header: ContainerContext | undefined;
/**
* The container context for the table body.
*/
body: ContainerContext | undefined;
/**
* The breakpoint at which the table will switch between table and list rendering.
*
* - If a number is provided, it will be treated as a pixel value.
* - If a string is provided, it will be treated as a CSS length value.
* - If a function is provided, it must return the entire media query string.
*/
breakpoint: number | string | (() => string);
/**
* The content to display in empty table cells. This can be a string or a Svelte snippet. If left undefined,
* then the term/definition pair will be omitted from the rendered table.
*/
emptyCellContent: string | Snippet | undefined;

/**
* Initializes a new instance of this class.
* @param options Initial set of values for the table context.
*/
constructor(options?: TableContextOptions) {
const { breakpoint, ssrBehavior, emptyCellContent } = {
...defaultContextOptions,
Expand Down
Loading