UNPKG

@lottiefiles/last-builder

Version:

Composable functions to easily build last structures

81 lines (77 loc) 3.12 kB
import { Position, PrimitiveValue, PrimitiveValueType, Primitive, KeyNode, ObjectTitle, ObjectNodeValue, ObjectNode, ArrayTitle, ArrayNodeValue, ArrayNode, KeyValue, AttributeTitle, Attribute, ElementTitle, Element, CollectionTitle, Collection, Root } from '@lottiefiles/last'; /** * Copyright 2023 Design Barn Inc. */ interface Parts { position?: Position; } interface PrimitiveParts<T> extends Parts { valueType?: T; } declare type Children<T> = T | T[]; declare type MemberChild<T> = T | [T] | T[]; /** * Create a Primitive Node * @param value - Primitive's value, e.g. 7 * @param parts - additional data props e.g. Position * @returns (last) Primitive node */ declare const pt: (value?: PrimitiveValue, parts?: PrimitiveParts<PrimitiveValueType>) => Primitive; /** * Create a Key node * @param value - Key property name. e.g "ef" * @param parts - additional data props e.g. Position * @returns (last) Key node */ declare const ky: (value: string, parts?: Parts) => KeyNode; /** * Create an Object node * @param title - Lottie's qualified name. e.g. "anchor-point" * @param kids - Can have many children, ObjectNodeValue[] * @param parts - additional data props e.g. Position * @returns (last) Object node */ declare const ob: (title: ObjectTitle, kids?: Children<ObjectNodeValue>, parts?: Parts) => ObjectNode; /** * Create an Array node * @param title - Lottie's qualified name * @param kids - Can have many children, ArrayNodeValue[] * @param parts - additional data props e.g. Position * @returns (last) Array node */ declare const ar: (title: ArrayTitle, kids?: Children<ArrayNodeValue>, parts?: Parts) => ArrayNode; /** * Create an Attribute node * @param key - Object's key property * @param title - Lottie's qualified name * @param kid - Can have a single child only - [Primitive] * @param parts - additional data props e.g. Position * @returns (last) Attribute node */ declare const at: (key: KeyValue, title: AttributeTitle, kid?: MemberChild<Primitive>, parts?: Parts) => Attribute; /** * Create an Element node * @param key - Object's key property * @param title - Lottie's qualified name * @param kid - Can have a single child only, [ObjectNode] * @param parts - additional data props e.g. Position * @returns (last) Element node */ declare const el: (key: KeyValue, title: ElementTitle, kid?: MemberChild<ObjectNode>, parts?: Parts) => Element; /** * Create a Collection node * @param key - Object's key property * @param title - Lottie's qualified name * @param kid - Can have a single child only, [ArrayNode] * @param parts - additional data props e.g. Position * @returns (last) Collection node */ declare const cl: (key: KeyValue, title: CollectionTitle, kid?: MemberChild<ArrayNode>, parts?: Parts) => Collection; /** * Create a Root node * @param kids - Can have many children, ObjectNodeValue[] * @param parts - additional data props e.g. Position * @returns (last) Root node */ declare const rt: (kids?: Children<ObjectNodeValue>, parts?: Parts) => Root; export { type Parts, type PrimitiveParts, ar, at, cl, el, ky, ob, pt, rt };