UNPKG

@tldraw/tlschema

Version:

A tiny little drawing app (schema).

8 lines (7 loc) 2.08 kB
{ "version": 3, "sources": ["../../src/shapes/TLFrameShape.ts"], "sourcesContent": ["import { T } from '@tldraw/validate'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/TLShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DefaultColorStyle, TLDefaultColorStyle } from '../styles/TLColorStyle'\nimport { TLBaseShape } from './TLBaseShape'\n\n/** @public */\nexport interface TLFrameShapeProps {\n\tw: number\n\th: number\n\tname: string\n\tcolor: TLDefaultColorStyle\n}\n\n/** @public */\nexport type TLFrameShape = TLBaseShape<'frame', TLFrameShapeProps>\n\n/** @public */\nexport const frameShapeProps: RecordProps<TLFrameShape> = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\tname: T.string,\n\t// because shape colors are an option, we don't want them to be picked up by the editor as a\n\t// style prop by default, so instead of a proper style we just supply an equivalent validator.\n\t// Check `FrameShapeUtil.configure` for how we replace this with the original\n\t// `DefaultColorStyle` style when the option is turned on.\n\tcolor: T.literalEnum(...DefaultColorStyle.values),\n}\n\nconst Versions = createShapePropsMigrationIds('frame', {\n\tAddColorProp: 1,\n})\n\nexport { Versions as frameShapeVersions }\n\n/** @public */\nexport const frameShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddColorProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.color = 'black'\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.color\n\t\t\t},\n\t\t},\n\t],\n})\n"], "mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,8BAA8B,yCAAyC;AAEhF,SAAS,yBAA8C;AAehD,MAAM,kBAA6C;AAAA,EACzD,GAAG,EAAE;AAAA,EACL,GAAG,EAAE;AAAA,EACL,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAKR,OAAO,EAAE,YAAY,GAAG,kBAAkB,MAAM;AACjD;AAEA,MAAM,WAAW,6BAA6B,SAAS;AAAA,EACtD,cAAc;AACf,CAAC;AAKM,MAAM,uBAAuB,kCAAkC;AAAA,EACrE,UAAU;AAAA,IACT;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,QAAQ;AAAA,MACf;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,eAAO,MAAM;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD,CAAC;", "names": [] }