mirror of
https://github.com/pdfme/pdfme.git
synced 2026-06-15 17:59:09 -04:00
* refactor(schemas): add generic split range metadata * refactor(schemas): remove legacy split range fields * refactor(schemas): polish split range helpers
25 lines
612 B
TypeScript
25 lines
612 B
TypeScript
import type { DynamicLayoutRange, DynamicLayoutSplitRange } from './types.js';
|
|
|
|
export const createDynamicLayoutSplitRange = (
|
|
unit: string,
|
|
start: number,
|
|
end?: number,
|
|
): DynamicLayoutSplitRange => ({
|
|
unit,
|
|
start,
|
|
...(end === undefined ? {} : { end }),
|
|
});
|
|
|
|
export const getDynamicLayoutSplitRange = (
|
|
schema: { __splitRange?: DynamicLayoutSplitRange },
|
|
unit: string,
|
|
): DynamicLayoutRange | undefined => {
|
|
const range = schema.__splitRange;
|
|
if (range?.unit !== unit) return undefined;
|
|
|
|
return {
|
|
start: range.start,
|
|
...(range.end === undefined ? {} : { end: range.end }),
|
|
};
|
|
};
|