UNPKG

@tldraw/tlschema

Version:

A tiny little drawing app (schema).

188 lines (187 loc) • 5.33 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var TLGeoShape_exports = {}; __export(TLGeoShape_exports, { GeoShapeGeoStyle: () => GeoShapeGeoStyle, geoShapeMigrations: () => geoShapeMigrations, geoShapeProps: () => geoShapeProps, geoShapeVersions: () => geoShapeVersions }); module.exports = __toCommonJS(TLGeoShape_exports); var import_validate = require("@tldraw/validate"); var import_TLRichText = require("../misc/TLRichText"); var import_TLShape = require("../records/TLShape"); var import_StyleProp = require("../styles/StyleProp"); var import_TLColorStyle = require("../styles/TLColorStyle"); var import_TLDashStyle = require("../styles/TLDashStyle"); var import_TLFillStyle = require("../styles/TLFillStyle"); var import_TLFontStyle = require("../styles/TLFontStyle"); var import_TLHorizontalAlignStyle = require("../styles/TLHorizontalAlignStyle"); var import_TLSizeStyle = require("../styles/TLSizeStyle"); var import_TLVerticalAlignStyle = require("../styles/TLVerticalAlignStyle"); const GeoShapeGeoStyle = import_StyleProp.StyleProp.defineEnum("tldraw:geo", { defaultValue: "rectangle", values: [ "cloud", "rectangle", "ellipse", "triangle", "diamond", "pentagon", "hexagon", "octagon", "star", "rhombus", "rhombus-2", "oval", "trapezoid", "arrow-right", "arrow-left", "arrow-up", "arrow-down", "x-box", "check-box", "heart" ] }); const geoShapeProps = { geo: GeoShapeGeoStyle, labelColor: import_TLColorStyle.DefaultLabelColorStyle, color: import_TLColorStyle.DefaultColorStyle, fill: import_TLFillStyle.DefaultFillStyle, dash: import_TLDashStyle.DefaultDashStyle, size: import_TLSizeStyle.DefaultSizeStyle, font: import_TLFontStyle.DefaultFontStyle, align: import_TLHorizontalAlignStyle.DefaultHorizontalAlignStyle, verticalAlign: import_TLVerticalAlignStyle.DefaultVerticalAlignStyle, url: import_validate.T.linkUrl, w: import_validate.T.nonZeroNumber, h: import_validate.T.nonZeroNumber, growY: import_validate.T.positiveNumber, richText: import_TLRichText.richTextValidator, scale: import_validate.T.nonZeroNumber }; const geoShapeVersions = (0, import_TLShape.createShapePropsMigrationIds)("geo", { AddUrlProp: 1, AddLabelColor: 2, RemoveJustify: 3, AddCheckBox: 4, AddVerticalAlign: 5, MigrateLegacyAlign: 6, AddCloud: 7, MakeUrlsValid: 8, AddScale: 9, AddRichText: 10 }); const geoShapeMigrations = (0, import_TLShape.createShapePropsMigrationSequence)({ sequence: [ { id: geoShapeVersions.AddUrlProp, up: (props) => { props.url = ""; }, down: "retired" }, { id: geoShapeVersions.AddLabelColor, up: (props) => { props.labelColor = "black"; }, down: "retired" }, { id: geoShapeVersions.RemoveJustify, up: (props) => { if (props.align === "justify") { props.align = "start"; } }, down: "retired" }, { id: geoShapeVersions.AddCheckBox, up: (_props) => { }, down: "retired" }, { id: geoShapeVersions.AddVerticalAlign, up: (props) => { props.verticalAlign = "middle"; }, down: "retired" }, { id: geoShapeVersions.MigrateLegacyAlign, up: (props) => { let newAlign; switch (props.align) { case "start": newAlign = "start-legacy"; break; case "end": newAlign = "end-legacy"; break; default: newAlign = "middle-legacy"; break; } props.align = newAlign; }, down: "retired" }, { id: geoShapeVersions.AddCloud, up: (_props) => { }, down: "retired" }, { id: geoShapeVersions.MakeUrlsValid, up: (props) => { if (!import_validate.T.linkUrl.isValid(props.url)) { props.url = ""; } }, down: (_props) => { } }, { id: geoShapeVersions.AddScale, up: (props) => { props.scale = 1; }, down: (props) => { delete props.scale; } }, { id: geoShapeVersions.AddRichText, up: (props) => { props.richText = (0, import_TLRichText.toRichText)(props.text); delete props.text; } // N.B. Explicitly no down state so that we force clients to update. // down: (props) => { // delete props.richText // }, } ] }); //# sourceMappingURL=TLGeoShape.js.map