UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

42 lines (41 loc) 1.83 kB
import { LinkResolver } from 'alinea/backend/resolver/LinkResolver'; import * as Y from 'yjs'; import { Label } from '../Label.js'; import { Shape, ShapeInfo } from '../Shape.js'; import { PostProcess } from '../pages/PostProcess.js'; import { RecordShape } from './RecordShape.js'; export type ListRow = { id: string; index: string; type: string; }; export type ListMutator<T> = { replace: (id: string, row: T) => void; push: (row: Omit<T, 'id' | 'index'>, insertAt?: number) => void; remove: (id: string) => void; move: (oldIndex: number, newIndex: number) => void; }; export declare class ListShape<T extends ListRow> implements Shape<Array<T>, ListMutator<T>> { label: Label; shapes: Record<string, RecordShape>; initialValue?: T[] | undefined; protected postProcess?: PostProcess<T[]> | undefined; values: Record<string, RecordShape>; constructor(label: Label, shapes: Record<string, RecordShape>, initialValue?: T[] | undefined, postProcess?: PostProcess<T[]> | undefined); innerTypes(parents: Array<string>): Array<ShapeInfo>; create(): T[]; typeOfChild<C>(yValue: Y.Map<any>, child: string): Shape<C>; toY(value: Array<T>): Y.Map<unknown>; fromY(map: Y.Map<any>): Array<T>; applyY(value: T[], parent: Y.Map<any>, key: string): void; init(parent: Y.Map<any>, key: string): void; watch(parent: Y.Map<any>, key: string): (fun: () => void) => () => void; mutator(parent: Y.Map<any>, key: string, readOnly: boolean): { readOnly: boolean; replace: (id: string, row: T) => void; push: (row: Omit<T, 'id' | 'index'>, insertAt?: number) => void; remove(id: string): void; move: (oldIndex: number, newIndex: number) => void; }; applyLinks(value: Array<T>, loader: LinkResolver): Promise<void>; }