@tldraw/tlschema 4.2.0-next.f100cedfc45b → 4.3.0-canary.03ae87dcc44b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/bindings/TLBaseBinding.js.map +2 -2
- package/dist-cjs/createTLSchema.js.map +2 -2
- package/dist-cjs/index.d.ts +194 -38
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/misc/TLHandle.js.map +1 -1
- package/dist-cjs/records/TLAsset.js.map +1 -1
- package/dist-cjs/records/TLBinding.js.map +2 -2
- package/dist-cjs/records/TLShape.js.map +2 -2
- package/dist-cjs/shapes/ShapeWithCrop.js.map +1 -1
- package/dist-cjs/shapes/TLBaseShape.js.map +2 -2
- package/dist-cjs/store-migrations.js +1 -1
- package/dist-cjs/store-migrations.js.map +2 -2
- package/dist-cjs/styles/TLColorStyle.js +26 -0
- package/dist-cjs/styles/TLColorStyle.js.map +2 -2
- package/dist-cjs/styles/TLFillStyle.js +1 -1
- package/dist-cjs/styles/TLFillStyle.js.map +2 -2
- package/dist-esm/bindings/TLBaseBinding.mjs.map +2 -2
- package/dist-esm/createTLSchema.mjs.map +2 -2
- package/dist-esm/index.d.mts +194 -38
- package/dist-esm/index.mjs +3 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/misc/TLHandle.mjs.map +1 -1
- package/dist-esm/records/TLAsset.mjs.map +1 -1
- package/dist-esm/records/TLBinding.mjs.map +2 -2
- package/dist-esm/records/TLShape.mjs.map +2 -2
- package/dist-esm/shapes/TLBaseShape.mjs.map +2 -2
- package/dist-esm/store-migrations.mjs +1 -1
- package/dist-esm/store-migrations.mjs.map +2 -2
- package/dist-esm/styles/TLColorStyle.mjs +26 -0
- package/dist-esm/styles/TLColorStyle.mjs.map +2 -2
- package/dist-esm/styles/TLFillStyle.mjs +1 -1
- package/dist-esm/styles/TLFillStyle.mjs.map +2 -2
- package/package.json +5 -5
- package/src/bindings/TLBaseBinding.ts +25 -14
- package/src/createTLSchema.ts +8 -2
- package/src/index.ts +7 -0
- package/src/misc/TLHandle.ts +2 -0
- package/src/records/TLAsset.ts +2 -2
- package/src/records/TLBinding.ts +65 -23
- package/src/records/TLRecord.test.ts +17 -5
- package/src/records/TLShape.ts +100 -5
- package/src/shapes/ShapeWithCrop.ts +2 -2
- package/src/shapes/TLBaseShape.ts +34 -10
- package/src/store-migrations.ts +2 -1
- package/src/styles/TLColorStyle.ts +27 -0
- package/src/styles/TLFillStyle.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styles/TLColorStyle.ts"],
|
|
4
|
-
"sourcesContent": ["import { Expand } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Array of default color names available in tldraw's color palette.\n * These colors form the basis for the default color style system and are available\n * in both light and dark theme variants.\n *\n * @example\n * ```ts\n * import { defaultColorNames } from '@tldraw/tlschema'\n *\n * // Create a color picker with all default colors\n * const colorOptions = defaultColorNames.map(color => ({\n * name: color,\n * value: color\n * }))\n * ```\n *\n * @public\n */\nexport const defaultColorNames = [\n\t'black',\n\t'grey',\n\t'light-violet',\n\t'violet',\n\t'blue',\n\t'light-blue',\n\t'yellow',\n\t'orange',\n\t'green',\n\t'light-green',\n\t'light-red',\n\t'red',\n\t'white',\n] as const\n\n/**\n * Defines the color variants available for each color in the default theme.\n * Each color has multiple variants for different use cases like fills, strokes,\n * patterns, and UI elements like frames and notes.\n *\n * @example\n * ```ts\n * import { TLDefaultColorThemeColor } from '@tldraw/tlschema'\n *\n * const blueColor: TLDefaultColorThemeColor = {\n * solid: '#4465e9',\n * semi: '#dce1f8',\n * pattern: '#6681ee',\n * fill: '#4465e9',\n * // ... other variants\n * }\n * ```\n *\n * @public\n */\nexport interface TLDefaultColorThemeColor {\n\tsolid: string\n\tsemi: string\n\tpattern: string\n\tfill: string // usually same as solid\n\tframeHeadingStroke: string\n\tframeHeadingFill: string\n\tframeStroke: string\n\tframeFill: string\n\tframeText: string\n\tnoteFill: string\n\tnoteText: string\n\thighlightSrgb: string\n\thighlightP3: string\n}\n\n/**\n * Complete color theme definition containing all colors and their variants\n * for either light or dark mode. Includes base theme properties and all\n * default colors with their respective color variants.\n *\n * @example\n * ```ts\n * import { TLDefaultColorTheme } from '@tldraw/tlschema'\n *\n * const customTheme: TLDefaultColorTheme = {\n * id: 'light',\n * text: '#000000',\n * background: '#ffffff',\n * solid: '#fcfffe',\n * black: { solid: '#000000', semi: '#cccccc', ... },\n * // ... other colors\n * }\n * ```\n *\n * @public\n */\nexport type TLDefaultColorTheme = Expand<\n\t{\n\t\tid: 'light' | 'dark'\n\t\ttext: string\n\t\tbackground: string\n\t\tsolid: string\n\t} & Record<(typeof defaultColorNames)[number], TLDefaultColorThemeColor>\n>\n\n/**\n * Complete color palette containing both light and dark theme definitions.\n * This object provides the full color system used by tldraw's default themes,\n * including all color variants and theme-specific adjustments.\n *\n * @example\n * ```ts\n * import { DefaultColorThemePalette } from '@tldraw/tlschema'\n *\n * // Get the dark theme colors\n * const darkTheme = DefaultColorThemePalette.darkMode\n * const redColor = darkTheme.red.solid // '#e03131'\n *\n * // Access light theme colors\n * const lightTheme = DefaultColorThemePalette.lightMode\n * const blueColor = lightTheme.blue.fill // '#4465e9'\n * ```\n *\n * @public\n */\nexport const DefaultColorThemePalette: {\n\tlightMode: TLDefaultColorTheme\n\tdarkMode: TLDefaultColorTheme\n} = {\n\tlightMode: {\n\t\tid: 'light',\n\t\ttext: '#000000',\n\t\tbackground: '#f9fafb',\n\t\tsolid: '#fcfffe',\n\t\tblack: {\n\t\t\tsolid: '#1d1d1d',\n\t\t\tfill: '#1d1d1d',\n\t\t\tframeHeadingStroke: '#717171',\n\t\t\tframeHeadingFill: '#ffffff',\n\t\t\tframeStroke: '#717171',\n\t\t\tframeFill: '#ffffff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FCE19C',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#e8e8e8',\n\t\t\tpattern: '#494949',\n\t\t\thighlightSrgb: '#fddd00',\n\t\t\thighlightP3: 'color(display-p3 0.972 0.8205 0.05)',\n\t\t},\n\t\tblue: {\n\t\t\tsolid: '#4465e9',\n\t\t\tfill: '#4465e9',\n\t\t\tframeHeadingStroke: '#6681ec',\n\t\t\tframeHeadingFill: '#f9fafe',\n\t\t\tframeStroke: '#6681ec',\n\t\t\tframeFill: '#f9fafe',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#8AA3FF',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#dce1f8',\n\t\t\tpattern: '#6681ee',\n\t\t\thighlightSrgb: '#10acff',\n\t\t\thighlightP3: 'color(display-p3 0.308 0.6632 0.9996)',\n\t\t},\n\t\tgreen: {\n\t\t\tsolid: '#099268',\n\t\t\tfill: '#099268',\n\t\t\tframeHeadingStroke: '#37a684',\n\t\t\tframeHeadingFill: '#f8fcfa',\n\t\t\tframeStroke: '#37a684',\n\t\t\tframeFill: '#f8fcfa',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#6FC896',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#d3e9e3',\n\t\t\tpattern: '#39a785',\n\t\t\thighlightSrgb: '#00ffc8',\n\t\t\thighlightP3: 'color(display-p3 0.2536 0.984 0.7981)',\n\t\t},\n\t\tgrey: {\n\t\t\tsolid: '#9fa8b2',\n\t\t\tfill: '#9fa8b2',\n\t\t\tframeHeadingStroke: '#aaaaab',\n\t\t\tframeHeadingFill: '#fbfcfc',\n\t\t\tframeStroke: '#aaaaab',\n\t\t\tframeFill: '#fcfcfd',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#C0CAD3',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#eceef0',\n\t\t\tpattern: '#bcc3c9',\n\t\t\thighlightSrgb: '#cbe7f1',\n\t\t\thighlightP3: 'color(display-p3 0.8163 0.9023 0.9416)',\n\t\t},\n\t\t'light-blue': {\n\t\t\tsolid: '#4ba1f1',\n\t\t\tfill: '#4ba1f1',\n\t\t\tframeHeadingStroke: '#6cb2f3',\n\t\t\tframeHeadingFill: '#f8fbfe',\n\t\t\tframeStroke: '#6cb2f3',\n\t\t\tframeFill: '#fafcff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#9BC4FD',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#ddedfa',\n\t\t\tpattern: '#6fbbf8',\n\t\t\thighlightSrgb: '#00f4ff',\n\t\t\thighlightP3: 'color(display-p3 0.1512 0.9414 0.9996)',\n\t\t},\n\t\t'light-green': {\n\t\t\tsolid: '#4cb05e',\n\t\t\tfill: '#4cb05e',\n\t\t\tframeHeadingStroke: '#6dbe7c',\n\t\t\tframeHeadingFill: '#f8fcf9',\n\t\t\tframeStroke: '#6dbe7c',\n\t\t\tframeFill: '#fafdfa',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#98D08A',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#dbf0e0',\n\t\t\tpattern: '#65cb78',\n\t\t\thighlightSrgb: '#65f641',\n\t\t\thighlightP3: 'color(display-p3 0.563 0.9495 0.3857)',\n\t\t},\n\t\t'light-red': {\n\t\t\tsolid: '#f87777',\n\t\t\tfill: '#f87777',\n\t\t\tframeHeadingStroke: '#f89090',\n\t\t\tframeHeadingFill: '#fffafa',\n\t\t\tframeStroke: '#f89090',\n\t\t\tframeFill: '#fffbfb',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#F7A5A1',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f4dadb',\n\t\t\tpattern: '#fe9e9e',\n\t\t\thighlightSrgb: '#ff7fa3',\n\t\t\thighlightP3: 'color(display-p3 0.9988 0.5301 0.6397)',\n\t\t},\n\t\t'light-violet': {\n\t\t\tsolid: '#e085f4',\n\t\t\tfill: '#e085f4',\n\t\t\tframeHeadingStroke: '#e59bf5',\n\t\t\tframeHeadingFill: '#fefaff',\n\t\t\tframeStroke: '#e59bf5',\n\t\t\tframeFill: '#fefbff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#DFB0F9',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f5eafa',\n\t\t\tpattern: '#e9acf8',\n\t\t\thighlightSrgb: '#ff88ff',\n\t\t\thighlightP3: 'color(display-p3 0.9676 0.5652 0.9999)',\n\t\t},\n\t\torange: {\n\t\t\tsolid: '#e16919',\n\t\t\tfill: '#e16919',\n\t\t\tframeHeadingStroke: '#e68544',\n\t\t\tframeHeadingFill: '#fef9f6',\n\t\t\tframeStroke: '#e68544',\n\t\t\tframeFill: '#fef9f6',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FAA475',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f8e2d4',\n\t\t\tpattern: '#f78438',\n\t\t\thighlightSrgb: '#ffa500',\n\t\t\thighlightP3: 'color(display-p3 0.9988 0.6905 0.266)',\n\t\t},\n\t\tred: {\n\t\t\tsolid: '#e03131',\n\t\t\tfill: '#e03131',\n\t\t\tframeHeadingStroke: '#e55757',\n\t\t\tframeHeadingFill: '#fef7f7',\n\t\t\tframeStroke: '#e55757',\n\t\t\tframeFill: '#fef9f9',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FC8282',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f4dadb',\n\t\t\tpattern: '#e55959',\n\t\t\thighlightSrgb: '#ff636e',\n\t\t\thighlightP3: 'color(display-p3 0.9992 0.4376 0.45)',\n\t\t},\n\t\tviolet: {\n\t\t\tsolid: '#ae3ec9',\n\t\t\tfill: '#ae3ec9',\n\t\t\tframeHeadingStroke: '#bc62d3',\n\t\t\tframeHeadingFill: '#fcf7fd',\n\t\t\tframeStroke: '#bc62d3',\n\t\t\tframeFill: '#fdf9fd',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#DB91FD',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#ecdcf2',\n\t\t\tpattern: '#bd63d3',\n\t\t\thighlightSrgb: '#c77cff',\n\t\t\thighlightP3: 'color(display-p3 0.7469 0.5089 0.9995)',\n\t\t},\n\t\tyellow: {\n\t\t\tsolid: '#f1ac4b',\n\t\t\tfill: '#f1ac4b',\n\t\t\tframeHeadingStroke: '#f3bb6c',\n\t\t\tframeHeadingFill: '#fefcf8',\n\t\t\tframeStroke: '#f3bb6c',\n\t\t\tframeFill: '#fffdfa',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FED49A',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f9f0e6',\n\t\t\tpattern: '#fecb92',\n\t\t\thighlightSrgb: '#fddd00',\n\t\t\thighlightP3: 'color(display-p3 0.972 0.8705 0.05)',\n\t\t},\n\t\twhite: {\n\t\t\tsolid: '#FFFFFF',\n\t\t\tfill: '#FFFFFF',\n\t\t\tsemi: '#f5f5f5',\n\t\t\tpattern: '#f9f9f9',\n\t\t\tframeHeadingStroke: '#7d7d7d',\n\t\t\tframeHeadingFill: '#ffffff',\n\t\t\tframeStroke: '#7d7d7d',\n\t\t\tframeFill: '#ffffff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FFFFFF',\n\t\t\tnoteText: '#000000',\n\t\t\thighlightSrgb: '#ffffff',\n\t\t\thighlightP3: 'color(display-p3 1 1 1)',\n\t\t},\n\t},\n\tdarkMode: {\n\t\tid: 'dark',\n\t\ttext: 'hsl(210, 17%, 98%)',\n\t\tbackground: 'hsl(240, 5%, 6.5%)',\n\t\tsolid: '#010403',\n\n\t\tblack: {\n\t\t\tsolid: '#f2f2f2',\n\t\t\tfill: '#f2f2f2',\n\t\t\tframeHeadingStroke: '#5c5c5c',\n\t\t\tframeHeadingFill: '#252525',\n\t\t\tframeStroke: '#5c5c5c',\n\t\t\tframeFill: '#0c0c0c',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#2c2c2c',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#2c3036',\n\t\t\tpattern: '#989898',\n\t\t\thighlightSrgb: '#d2b700',\n\t\t\thighlightP3: 'color(display-p3 0.8078 0.6225 0.0312)',\n\t\t},\n\t\tblue: {\n\t\t\tsolid: '#4f72fc', // 3c60f0\n\t\t\tfill: '#4f72fc',\n\t\t\tframeHeadingStroke: '#384994',\n\t\t\tframeHeadingFill: '#1C2036',\n\t\t\tframeStroke: '#384994',\n\t\t\tframeFill: '#11141f',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#2A3F98',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#262d40',\n\t\t\tpattern: '#3a4b9e',\n\t\t\thighlightSrgb: '#0079d2',\n\t\t\thighlightP3: 'color(display-p3 0.0032 0.4655 0.7991)',\n\t\t},\n\t\tgreen: {\n\t\t\tsolid: '#099268',\n\t\t\tfill: '#099268',\n\t\t\tframeHeadingStroke: '#10513C',\n\t\t\tframeHeadingFill: '#14241f',\n\t\t\tframeStroke: '#10513C',\n\t\t\tframeFill: '#0E1614',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#014429',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#253231',\n\t\t\tpattern: '#366a53',\n\t\t\thighlightSrgb: '#009774',\n\t\t\thighlightP3: 'color(display-p3 0.0085 0.582 0.4604)',\n\t\t},\n\t\tgrey: {\n\t\t\tsolid: '#9398b0',\n\t\t\tfill: '#9398b0',\n\t\t\tframeHeadingStroke: '#42474D',\n\t\t\tframeHeadingFill: '#23262A',\n\t\t\tframeStroke: '#42474D',\n\t\t\tframeFill: '#151719',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#56595F',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#33373c',\n\t\t\tpattern: '#7c8187',\n\t\t\thighlightSrgb: '#9cb4cb',\n\t\t\thighlightP3: 'color(display-p3 0.6299 0.7012 0.7856)',\n\t\t},\n\t\t'light-blue': {\n\t\t\tsolid: '#4dabf7',\n\t\t\tfill: '#4dabf7',\n\t\t\tframeHeadingStroke: '#075797',\n\t\t\tframeHeadingFill: '#142839',\n\t\t\tframeStroke: '#075797',\n\t\t\tframeFill: '#0B1823',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#1F5495',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#2a3642',\n\t\t\tpattern: '#4d7aa9',\n\t\t\thighlightSrgb: '#00bdc8',\n\t\t\thighlightP3: 'color(display-p3 0.0023 0.7259 0.7735)',\n\t\t},\n\t\t'light-green': {\n\t\t\tsolid: '#40c057',\n\t\t\tfill: '#40c057',\n\t\t\tframeHeadingStroke: '#1C5427',\n\t\t\tframeHeadingFill: '#18251A',\n\t\t\tframeStroke: '#1C5427',\n\t\t\tframeFill: '#0F1911',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#21581D',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#2a3830',\n\t\t\tpattern: '#4e874e',\n\t\t\thighlightSrgb: '#00a000',\n\t\t\thighlightP3: 'color(display-p3 0.2711 0.6172 0.0195)',\n\t\t},\n\t\t'light-red': {\n\t\t\tsolid: '#ff8787',\n\t\t\tfill: '#ff8787',\n\t\t\tframeHeadingStroke: '#6f3232', // Darker and desaturated variant of solid\n\t\t\tframeHeadingFill: '#341818', // Deep, muted dark red\n\t\t\tframeStroke: '#6f3232', // Matches headingStroke\n\t\t\tframeFill: '#181212', // Darker, muted background shade\n\t\t\tframeText: '#f2f2f2', // Consistent bright text color\n\t\t\tnoteFill: '#7a3333', // Medium-dark, muted variant of solid\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#3c2b2b', // Subdued, darker neutral-red tone\n\t\t\tpattern: '#a56767', // Existing pattern shade retained\n\t\t\thighlightSrgb: '#db005b',\n\t\t\thighlightP3: 'color(display-p3 0.7849 0.0585 0.3589)',\n\t\t},\n\t\t'light-violet': {\n\t\t\tsolid: '#e599f7',\n\t\t\tfill: '#e599f7',\n\t\t\tframeHeadingStroke: '#6c367a',\n\t\t\tframeHeadingFill: '#2D2230',\n\t\t\tframeStroke: '#6c367a',\n\t\t\tframeFill: '#1C151E',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#762F8E',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#383442',\n\t\t\tpattern: '#9770a9',\n\t\t\thighlightSrgb: '#c400c7',\n\t\t\thighlightP3: 'color(display-p3 0.7024 0.0403 0.753)',\n\t\t},\n\t\torange: {\n\t\t\tsolid: '#f76707',\n\t\t\tfill: '#f76707',\n\t\t\tframeHeadingStroke: '#773a0e', // Darker, muted version of solid\n\t\t\tframeHeadingFill: '#2f1d13', // Deep, warm, muted background\n\t\t\tframeStroke: '#773a0e', // Matches headingStroke\n\t\t\tframeFill: '#1c1512', // Darker, richer muted background\n\t\t\tframeText: '#f2f2f2', // Bright text for contrast\n\t\t\tnoteFill: '#7c3905', // Muted dark variant for note fill\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#3b2e27', // Muted neutral-orange tone\n\t\t\tpattern: '#9f552d', // Retained existing shade\n\t\t\thighlightSrgb: '#d07a00',\n\t\t\thighlightP3: 'color(display-p3 0.7699 0.4937 0.0085)',\n\t\t},\n\t\tred: {\n\t\t\tsolid: '#e03131',\n\t\t\tfill: '#e03131',\n\t\t\tframeHeadingStroke: '#701e1e', // Darker, muted variation of solid\n\t\t\tframeHeadingFill: '#301616', // Deep, muted reddish backdrop\n\t\t\tframeStroke: '#701e1e', // Matches headingStroke\n\t\t\tframeFill: '#1b1313', // Rich, dark muted background\n\t\t\tframeText: '#f2f2f2', // Bright text for readability\n\t\t\tnoteFill: '#7e201f', // Muted dark variant for note fill\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#382726', // Dark neutral-red tone\n\t\t\tpattern: '#8f3734', // Existing pattern color retained\n\t\t\thighlightSrgb: '#de002c',\n\t\t\thighlightP3: 'color(display-p3 0.7978 0.0509 0.2035)',\n\t\t},\n\t\tviolet: {\n\t\t\tsolid: '#ae3ec9',\n\t\t\tfill: '#ae3ec9',\n\t\t\tframeHeadingStroke: '#6d1583', // Darker, muted variation of solid\n\t\t\tframeHeadingFill: '#27152e', // Deep, rich muted violet backdrop\n\t\t\tframeStroke: '#6d1583', // Matches headingStroke\n\t\t\tframeFill: '#1b0f21', // Darker muted violet background\n\t\t\tframeText: '#f2f2f2', // Consistent bright text color\n\t\t\tnoteFill: '#5f1c70', // Muted dark variant for note fill\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#342938', // Dark neutral-violet tone\n\t\t\tpattern: '#763a8b', // Retained existing pattern color\n\t\t\thighlightSrgb: '#9e00ee',\n\t\t\thighlightP3: 'color(display-p3 0.5651 0.0079 0.8986)',\n\t\t},\n\t\tyellow: {\n\t\t\tsolid: '#ffc034',\n\t\t\tfill: '#ffc034',\n\t\t\tframeHeadingStroke: '#684e12', // Darker, muted variant of solid\n\t\t\tframeHeadingFill: '#2a2113', // Rich, muted dark-yellow background\n\t\t\tframeStroke: '#684e12', // Matches headingStroke\n\t\t\tframeFill: '#1e1911', // Darker muted shade for background fill\n\t\t\tframeText: '#f2f2f2', // Bright text color for readability\n\t\t\tnoteFill: '#8a5e1c', // Muted, dark complementary variant\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#3b352b', // Dark muted neutral-yellow tone\n\t\t\tpattern: '#fecb92', // Existing shade retained\n\t\t\thighlightSrgb: '#d2b700',\n\t\t\thighlightP3: 'color(display-p3 0.8078 0.7225 0.0312)',\n\t\t},\n\t\twhite: {\n\t\t\tsolid: '#f3f3f3',\n\t\t\tfill: '#f3f3f3',\n\t\t\tsemi: '#f5f5f5',\n\t\t\tpattern: '#f9f9f9',\n\t\t\tframeHeadingStroke: '#ffffff',\n\t\t\tframeHeadingFill: '#ffffff',\n\t\t\tframeStroke: '#ffffff',\n\t\t\tframeFill: '#ffffff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#eaeaea',\n\t\t\tnoteText: '#1d1d1d',\n\t\t\thighlightSrgb: '#ffffff',\n\t\t\thighlightP3: 'color(display-p3 1 1 1)',\n\t\t},\n\t},\n}\n\n/**\n * Returns the appropriate default color theme based on the dark mode preference.\n *\n * @param opts - Configuration options\n * - isDarkMode - Whether to return the dark theme (true) or light theme (false)\n * @returns The corresponding TLDefaultColorTheme (light or dark)\n *\n * @example\n * ```ts\n * import { getDefaultColorTheme } from '@tldraw/tlschema'\n *\n * // Get light theme\n * const lightTheme = getDefaultColorTheme({ isDarkMode: false })\n *\n * // Get dark theme\n * const darkTheme = getDefaultColorTheme({ isDarkMode: true })\n *\n * // Use with editor\n * const theme = getDefaultColorTheme({ isDarkMode: window.matchMedia('(prefers-color-scheme: dark)').matches })\n * ```\n *\n * @public\n */\nexport function getDefaultColorTheme(opts: { isDarkMode: boolean }): TLDefaultColorTheme {\n\treturn opts.isDarkMode ? DefaultColorThemePalette.darkMode : DefaultColorThemePalette.lightMode\n}\n\n/**\n * Default color style property used by tldraw shapes for their primary color.\n * This style prop allows shapes to use any of the default color names and\n * automatically saves the last used value for new shapes.\n *\n * @example\n * ```ts\n * import { DefaultColorStyle } from '@tldraw/tlschema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * color: typeof DefaultColorStyle\n * // other props...\n * }\n *\n * // Set color on a shape\n * const shape = {\n * // ... other properties\n * props: {\n * color: 'red' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultColorStyle = StyleProp.defineEnum('tldraw:color', {\n\tdefaultValue: 'black',\n\tvalues: defaultColorNames,\n})\n\n/**\n * Default label color style property used for text labels on shapes.\n * This is separate from the main color style to allow different colors\n * for shape fills/strokes versus their text labels.\n *\n * @example\n * ```ts\n * import { DefaultLabelColorStyle } from '@tldraw/tlschema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * labelColor: typeof DefaultLabelColorStyle\n * // other props...\n * }\n *\n * // Create a shape with different fill and label colors\n * const shape = {\n * // ... other properties\n * props: {\n * color: 'blue' as const,\n * labelColor: 'white' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultLabelColorStyle = StyleProp.defineEnum('tldraw:labelColor', {\n\tdefaultValue: 'black',\n\tvalues: defaultColorNames,\n})\n\n/**\n * Type representing a default color style value.\n * This is a union type of all available default color names.\n *\n * @example\n * ```ts\n * import { TLDefaultColorStyle } from '@tldraw/tlschema'\n *\n * // Valid color values\n * const redColor: TLDefaultColorStyle = 'red'\n * const blueColor: TLDefaultColorStyle = 'blue'\n *\n * // Type guard usage\n * function isValidColor(color: string): color is TLDefaultColorStyle {\n * return ['black', 'red', 'blue'].includes(color as TLDefaultColorStyle)\n * }\n * ```\n *\n * @public\n */\nexport type TLDefaultColorStyle = T.TypeOf<typeof DefaultColorStyle>\n\nconst defaultColorNamesSet = new Set(defaultColorNames)\n\n/**\n * Type guard to check if a color value is one of the default theme colors.\n * Useful for determining if a color can be looked up in the theme palette.\n *\n * @param color - The color value to check\n * @returns True if the color is a default theme color, false otherwise\n *\n * @example\n * ```ts\n * import { isDefaultThemeColor, TLDefaultColorStyle } from '@tldraw/tlschema'\n *\n * const color: TLDefaultColorStyle = 'red'\n *\n * if (isDefaultThemeColor(color)) {\n * // color is guaranteed to be a default theme color\n * console.log(`${color} is a default theme color`)\n * } else {\n * // color might be a custom hex value or other format\n * console.log(`${color} is a custom color`)\n * }\n * ```\n *\n * @public\n */\nexport function isDefaultThemeColor(\n\tcolor: TLDefaultColorStyle\n): color is (typeof defaultColorNames)[number] {\n\treturn defaultColorNamesSet.has(color as (typeof defaultColorNames)[number])\n}\n\n/**\n * Resolves a color style value to its actual CSS color string for a given theme and variant.\n * If the color is not a default theme color, returns the color value as-is.\n *\n * @param theme - The color theme to use for resolution\n * @param color - The color style value to resolve\n * @param variant - Which variant of the color to return (solid, fill, pattern, etc.)\n * @returns The CSS color string for the specified color and variant\n *\n * @example\n * ```ts\n * import { getColorValue, getDefaultColorTheme } from '@tldraw/tlschema'\n *\n * const theme = getDefaultColorTheme({ isDarkMode: false })\n *\n * // Get the solid variant of red\n * const redSolid = getColorValue(theme, 'red', 'solid') // '#e03131'\n *\n * // Get the fill variant of blue\n * const blueFill = getColorValue(theme, 'blue', 'fill') // '#4465e9'\n *\n * // Custom color passes through unchanged\n * const customColor = getColorValue(theme, '#ff0000', 'solid') // '#ff0000'\n * ```\n *\n * @public\n */\nexport function getColorValue(\n\ttheme: TLDefaultColorTheme,\n\tcolor: TLDefaultColorStyle,\n\tvariant: keyof TLDefaultColorThemeColor\n): string {\n\tif (!isDefaultThemeColor(color)) {\n\t\treturn color\n\t}\n\n\treturn theme[color][variant]\n}\n"],
|
|
5
|
-
"mappings": "AAEA,SAAS,iBAAiB;AAoBnB,MAAM,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;
|
|
4
|
+
"sourcesContent": ["import { Expand } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Array of default color names available in tldraw's color palette.\n * These colors form the basis for the default color style system and are available\n * in both light and dark theme variants.\n *\n * @example\n * ```ts\n * import { defaultColorNames } from '@tldraw/tlschema'\n *\n * // Create a color picker with all default colors\n * const colorOptions = defaultColorNames.map(color => ({\n * name: color,\n * value: color\n * }))\n * ```\n *\n * @public\n */\nexport const defaultColorNames = [\n\t'black',\n\t'grey',\n\t'light-violet',\n\t'violet',\n\t'blue',\n\t'light-blue',\n\t'yellow',\n\t'orange',\n\t'green',\n\t'light-green',\n\t'light-red',\n\t'red',\n\t'white',\n] as const\n\n/**\n * Defines the color variants available for each color in the default theme.\n * Each color has multiple variants for different use cases like fills, strokes,\n * patterns, and UI elements like frames and notes.\n *\n * @example\n * ```ts\n * import { TLDefaultColorThemeColor } from '@tldraw/tlschema'\n *\n * const blueColor: TLDefaultColorThemeColor = {\n * solid: '#4465e9',\n * semi: '#dce1f8',\n * pattern: '#6681ee',\n * fill: '#4465e9',\n * // ... other variants\n * }\n * ```\n *\n * @public\n */\nexport interface TLDefaultColorThemeColor {\n\tsolid: string\n\tsemi: string\n\tpattern: string\n\tfill: string // usually same as solid\n\tlinedFill: string // usually slightly lighter than fill\n\tframeHeadingStroke: string\n\tframeHeadingFill: string\n\tframeStroke: string\n\tframeFill: string\n\tframeText: string\n\tnoteFill: string\n\tnoteText: string\n\thighlightSrgb: string\n\thighlightP3: string\n}\n\n/**\n * Complete color theme definition containing all colors and their variants\n * for either light or dark mode. Includes base theme properties and all\n * default colors with their respective color variants.\n *\n * @example\n * ```ts\n * import { TLDefaultColorTheme } from '@tldraw/tlschema'\n *\n * const customTheme: TLDefaultColorTheme = {\n * id: 'light',\n * text: '#000000',\n * background: '#ffffff',\n * solid: '#fcfffe',\n * black: { solid: '#000000', semi: '#cccccc', ... },\n * // ... other colors\n * }\n * ```\n *\n * @public\n */\nexport type TLDefaultColorTheme = Expand<\n\t{\n\t\tid: 'light' | 'dark'\n\t\ttext: string\n\t\tbackground: string\n\t\tsolid: string\n\t} & Record<(typeof defaultColorNames)[number], TLDefaultColorThemeColor>\n>\n\n/**\n * Complete color palette containing both light and dark theme definitions.\n * This object provides the full color system used by tldraw's default themes,\n * including all color variants and theme-specific adjustments.\n *\n * @example\n * ```ts\n * import { DefaultColorThemePalette } from '@tldraw/tlschema'\n *\n * // Get the dark theme colors\n * const darkTheme = DefaultColorThemePalette.darkMode\n * const redColor = darkTheme.red.solid // '#e03131'\n *\n * // Access light theme colors\n * const lightTheme = DefaultColorThemePalette.lightMode\n * const blueColor = lightTheme.blue.fill // '#4465e9'\n * ```\n *\n * @public\n */\nexport const DefaultColorThemePalette: {\n\tlightMode: TLDefaultColorTheme\n\tdarkMode: TLDefaultColorTheme\n} = {\n\tlightMode: {\n\t\tid: 'light',\n\t\ttext: '#000000',\n\t\tbackground: '#f9fafb',\n\t\tsolid: '#fcfffe',\n\t\tblack: {\n\t\t\tsolid: '#1d1d1d',\n\t\t\tfill: '#1d1d1d',\n\t\t\tlinedFill: '#363636',\n\t\t\tframeHeadingStroke: '#717171',\n\t\t\tframeHeadingFill: '#ffffff',\n\t\t\tframeStroke: '#717171',\n\t\t\tframeFill: '#ffffff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FCE19C',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#e8e8e8',\n\t\t\tpattern: '#494949',\n\t\t\thighlightSrgb: '#fddd00',\n\t\t\thighlightP3: 'color(display-p3 0.972 0.8205 0.05)',\n\t\t},\n\t\tblue: {\n\t\t\tsolid: '#4465e9',\n\t\t\tfill: '#4465e9',\n\t\t\tlinedFill: '#6580ec',\n\t\t\tframeHeadingStroke: '#6681ec',\n\t\t\tframeHeadingFill: '#f9fafe',\n\t\t\tframeStroke: '#6681ec',\n\t\t\tframeFill: '#f9fafe',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#8AA3FF',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#dce1f8',\n\t\t\tpattern: '#6681ee',\n\t\t\thighlightSrgb: '#10acff',\n\t\t\thighlightP3: 'color(display-p3 0.308 0.6632 0.9996)',\n\t\t},\n\t\tgreen: {\n\t\t\tsolid: '#099268',\n\t\t\tfill: '#099268',\n\t\t\tlinedFill: '#0bad7c',\n\t\t\tframeHeadingStroke: '#37a684',\n\t\t\tframeHeadingFill: '#f8fcfa',\n\t\t\tframeStroke: '#37a684',\n\t\t\tframeFill: '#f8fcfa',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#6FC896',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#d3e9e3',\n\t\t\tpattern: '#39a785',\n\t\t\thighlightSrgb: '#00ffc8',\n\t\t\thighlightP3: 'color(display-p3 0.2536 0.984 0.7981)',\n\t\t},\n\t\tgrey: {\n\t\t\tsolid: '#9fa8b2',\n\t\t\tfill: '#9fa8b2',\n\t\t\tlinedFill: '#bbc1c9',\n\t\t\tframeHeadingStroke: '#aaaaab',\n\t\t\tframeHeadingFill: '#fbfcfc',\n\t\t\tframeStroke: '#aaaaab',\n\t\t\tframeFill: '#fcfcfd',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#C0CAD3',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#eceef0',\n\t\t\tpattern: '#bcc3c9',\n\t\t\thighlightSrgb: '#cbe7f1',\n\t\t\thighlightP3: 'color(display-p3 0.8163 0.9023 0.9416)',\n\t\t},\n\t\t'light-blue': {\n\t\t\tsolid: '#4ba1f1',\n\t\t\tfill: '#4ba1f1',\n\t\t\tlinedFill: '#7abaf5',\n\t\t\tframeHeadingStroke: '#6cb2f3',\n\t\t\tframeHeadingFill: '#f8fbfe',\n\t\t\tframeStroke: '#6cb2f3',\n\t\t\tframeFill: '#fafcff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#9BC4FD',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#ddedfa',\n\t\t\tpattern: '#6fbbf8',\n\t\t\thighlightSrgb: '#00f4ff',\n\t\t\thighlightP3: 'color(display-p3 0.1512 0.9414 0.9996)',\n\t\t},\n\t\t'light-green': {\n\t\t\tsolid: '#4cb05e',\n\t\t\tfill: '#4cb05e',\n\t\t\tlinedFill: '#7ec88c',\n\t\t\tframeHeadingStroke: '#6dbe7c',\n\t\t\tframeHeadingFill: '#f8fcf9',\n\t\t\tframeStroke: '#6dbe7c',\n\t\t\tframeFill: '#fafdfa',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#98D08A',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#dbf0e0',\n\t\t\tpattern: '#65cb78',\n\t\t\thighlightSrgb: '#65f641',\n\t\t\thighlightP3: 'color(display-p3 0.563 0.9495 0.3857)',\n\t\t},\n\t\t'light-red': {\n\t\t\tsolid: '#f87777',\n\t\t\tfill: '#f87777',\n\t\t\tlinedFill: '#f99a9a',\n\t\t\tframeHeadingStroke: '#f89090',\n\t\t\tframeHeadingFill: '#fffafa',\n\t\t\tframeStroke: '#f89090',\n\t\t\tframeFill: '#fffbfb',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#F7A5A1',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f4dadb',\n\t\t\tpattern: '#fe9e9e',\n\t\t\thighlightSrgb: '#ff7fa3',\n\t\t\thighlightP3: 'color(display-p3 0.9988 0.5301 0.6397)',\n\t\t},\n\t\t'light-violet': {\n\t\t\tsolid: '#e085f4',\n\t\t\tfill: '#e085f4',\n\t\t\tlinedFill: '#e9abf7',\n\t\t\tframeHeadingStroke: '#e59bf5',\n\t\t\tframeHeadingFill: '#fefaff',\n\t\t\tframeStroke: '#e59bf5',\n\t\t\tframeFill: '#fefbff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#DFB0F9',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f5eafa',\n\t\t\tpattern: '#e9acf8',\n\t\t\thighlightSrgb: '#ff88ff',\n\t\t\thighlightP3: 'color(display-p3 0.9676 0.5652 0.9999)',\n\t\t},\n\t\torange: {\n\t\t\tsolid: '#e16919',\n\t\t\tfill: '#e16919',\n\t\t\tlinedFill: '#ea8643',\n\t\t\tframeHeadingStroke: '#e68544',\n\t\t\tframeHeadingFill: '#fef9f6',\n\t\t\tframeStroke: '#e68544',\n\t\t\tframeFill: '#fef9f6',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FAA475',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f8e2d4',\n\t\t\tpattern: '#f78438',\n\t\t\thighlightSrgb: '#ffa500',\n\t\t\thighlightP3: 'color(display-p3 0.9988 0.6905 0.266)',\n\t\t},\n\t\tred: {\n\t\t\tsolid: '#e03131',\n\t\t\tfill: '#e03131',\n\t\t\tlinedFill: '#e75f5f',\n\t\t\tframeHeadingStroke: '#e55757',\n\t\t\tframeHeadingFill: '#fef7f7',\n\t\t\tframeStroke: '#e55757',\n\t\t\tframeFill: '#fef9f9',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FC8282',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f4dadb',\n\t\t\tpattern: '#e55959',\n\t\t\thighlightSrgb: '#ff636e',\n\t\t\thighlightP3: 'color(display-p3 0.9992 0.4376 0.45)',\n\t\t},\n\t\tviolet: {\n\t\t\tsolid: '#ae3ec9',\n\t\t\tfill: '#ae3ec9',\n\t\t\tlinedFill: '#be68d4',\n\t\t\tframeHeadingStroke: '#bc62d3',\n\t\t\tframeHeadingFill: '#fcf7fd',\n\t\t\tframeStroke: '#bc62d3',\n\t\t\tframeFill: '#fdf9fd',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#DB91FD',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#ecdcf2',\n\t\t\tpattern: '#bd63d3',\n\t\t\thighlightSrgb: '#c77cff',\n\t\t\thighlightP3: 'color(display-p3 0.7469 0.5089 0.9995)',\n\t\t},\n\t\tyellow: {\n\t\t\tsolid: '#f1ac4b',\n\t\t\tfill: '#f1ac4b',\n\t\t\tlinedFill: '#f5c27a',\n\t\t\tframeHeadingStroke: '#f3bb6c',\n\t\t\tframeHeadingFill: '#fefcf8',\n\t\t\tframeStroke: '#f3bb6c',\n\t\t\tframeFill: '#fffdfa',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FED49A',\n\t\t\tnoteText: '#000000',\n\t\t\tsemi: '#f9f0e6',\n\t\t\tpattern: '#fecb92',\n\t\t\thighlightSrgb: '#fddd00',\n\t\t\thighlightP3: 'color(display-p3 0.972 0.8705 0.05)',\n\t\t},\n\t\twhite: {\n\t\t\tsolid: '#FFFFFF',\n\t\t\tfill: '#FFFFFF',\n\t\t\tlinedFill: '#ffffff',\n\t\t\tsemi: '#f5f5f5',\n\t\t\tpattern: '#f9f9f9',\n\t\t\tframeHeadingStroke: '#7d7d7d',\n\t\t\tframeHeadingFill: '#ffffff',\n\t\t\tframeStroke: '#7d7d7d',\n\t\t\tframeFill: '#ffffff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#FFFFFF',\n\t\t\tnoteText: '#000000',\n\t\t\thighlightSrgb: '#ffffff',\n\t\t\thighlightP3: 'color(display-p3 1 1 1)',\n\t\t},\n\t},\n\tdarkMode: {\n\t\tid: 'dark',\n\t\ttext: 'hsl(210, 17%, 98%)',\n\t\tbackground: 'hsl(240, 5%, 6.5%)',\n\t\tsolid: '#010403',\n\n\t\tblack: {\n\t\t\tsolid: '#f2f2f2',\n\t\t\tfill: '#f2f2f2',\n\t\t\tlinedFill: '#ffffff',\n\t\t\tframeHeadingStroke: '#5c5c5c',\n\t\t\tframeHeadingFill: '#252525',\n\t\t\tframeStroke: '#5c5c5c',\n\t\t\tframeFill: '#0c0c0c',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#2c2c2c',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#2c3036',\n\t\t\tpattern: '#989898',\n\t\t\thighlightSrgb: '#d2b700',\n\t\t\thighlightP3: 'color(display-p3 0.8078 0.6225 0.0312)',\n\t\t},\n\t\tblue: {\n\t\t\tsolid: '#4f72fc', // 3c60f0\n\t\t\tfill: '#4f72fc',\n\t\t\tlinedFill: '#3c5cdd',\n\t\t\tframeHeadingStroke: '#384994',\n\t\t\tframeHeadingFill: '#1C2036',\n\t\t\tframeStroke: '#384994',\n\t\t\tframeFill: '#11141f',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#2A3F98',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#262d40',\n\t\t\tpattern: '#3a4b9e',\n\t\t\thighlightSrgb: '#0079d2',\n\t\t\thighlightP3: 'color(display-p3 0.0032 0.4655 0.7991)',\n\t\t},\n\t\tgreen: {\n\t\t\tsolid: '#099268',\n\t\t\tfill: '#099268',\n\t\t\tlinedFill: '#087856',\n\t\t\tframeHeadingStroke: '#10513C',\n\t\t\tframeHeadingFill: '#14241f',\n\t\t\tframeStroke: '#10513C',\n\t\t\tframeFill: '#0E1614',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#014429',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#253231',\n\t\t\tpattern: '#366a53',\n\t\t\thighlightSrgb: '#009774',\n\t\t\thighlightP3: 'color(display-p3 0.0085 0.582 0.4604)',\n\t\t},\n\t\tgrey: {\n\t\t\tsolid: '#9398b0',\n\t\t\tfill: '#9398b0',\n\t\t\tlinedFill: '#8388a5',\n\t\t\tframeHeadingStroke: '#42474D',\n\t\t\tframeHeadingFill: '#23262A',\n\t\t\tframeStroke: '#42474D',\n\t\t\tframeFill: '#151719',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#56595F',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#33373c',\n\t\t\tpattern: '#7c8187',\n\t\t\thighlightSrgb: '#9cb4cb',\n\t\t\thighlightP3: 'color(display-p3 0.6299 0.7012 0.7856)',\n\t\t},\n\t\t'light-blue': {\n\t\t\tsolid: '#4dabf7',\n\t\t\tfill: '#4dabf7',\n\t\t\tlinedFill: '#2793ec',\n\t\t\tframeHeadingStroke: '#075797',\n\t\t\tframeHeadingFill: '#142839',\n\t\t\tframeStroke: '#075797',\n\t\t\tframeFill: '#0B1823',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#1F5495',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#2a3642',\n\t\t\tpattern: '#4d7aa9',\n\t\t\thighlightSrgb: '#00bdc8',\n\t\t\thighlightP3: 'color(display-p3 0.0023 0.7259 0.7735)',\n\t\t},\n\t\t'light-green': {\n\t\t\tsolid: '#40c057',\n\t\t\tfill: '#40c057',\n\t\t\tlinedFill: '#37a44b',\n\t\t\tframeHeadingStroke: '#1C5427',\n\t\t\tframeHeadingFill: '#18251A',\n\t\t\tframeStroke: '#1C5427',\n\t\t\tframeFill: '#0F1911',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#21581D',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#2a3830',\n\t\t\tpattern: '#4e874e',\n\t\t\thighlightSrgb: '#00a000',\n\t\t\thighlightP3: 'color(display-p3 0.2711 0.6172 0.0195)',\n\t\t},\n\t\t'light-red': {\n\t\t\tsolid: '#ff8787',\n\t\t\tfill: '#ff8787',\n\t\t\tlinedFill: '#ff6666',\n\t\t\tframeHeadingStroke: '#6f3232', // Darker and desaturated variant of solid\n\t\t\tframeHeadingFill: '#341818', // Deep, muted dark red\n\t\t\tframeStroke: '#6f3232', // Matches headingStroke\n\t\t\tframeFill: '#181212', // Darker, muted background shade\n\t\t\tframeText: '#f2f2f2', // Consistent bright text color\n\t\t\tnoteFill: '#7a3333', // Medium-dark, muted variant of solid\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#3c2b2b', // Subdued, darker neutral-red tone\n\t\t\tpattern: '#a56767', // Existing pattern shade retained\n\t\t\thighlightSrgb: '#db005b',\n\t\t\thighlightP3: 'color(display-p3 0.7849 0.0585 0.3589)',\n\t\t},\n\t\t'light-violet': {\n\t\t\tsolid: '#e599f7',\n\t\t\tfill: '#e599f7',\n\t\t\tlinedFill: '#dc71f4',\n\t\t\tframeHeadingStroke: '#6c367a',\n\t\t\tframeHeadingFill: '#2D2230',\n\t\t\tframeStroke: '#6c367a',\n\t\t\tframeFill: '#1C151E',\n\t\t\tframeText: '#f2f2f2',\n\t\t\tnoteFill: '#762F8E',\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#383442',\n\t\t\tpattern: '#9770a9',\n\t\t\thighlightSrgb: '#c400c7',\n\t\t\thighlightP3: 'color(display-p3 0.7024 0.0403 0.753)',\n\t\t},\n\t\torange: {\n\t\t\tsolid: '#f76707',\n\t\t\tfill: '#f76707',\n\t\t\tlinedFill: '#f54900',\n\t\t\tframeHeadingStroke: '#773a0e', // Darker, muted version of solid\n\t\t\tframeHeadingFill: '#2f1d13', // Deep, warm, muted background\n\t\t\tframeStroke: '#773a0e', // Matches headingStroke\n\t\t\tframeFill: '#1c1512', // Darker, richer muted background\n\t\t\tframeText: '#f2f2f2', // Bright text for contrast\n\t\t\tnoteFill: '#7c3905', // Muted dark variant for note fill\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#3b2e27', // Muted neutral-orange tone\n\t\t\tpattern: '#9f552d', // Retained existing shade\n\t\t\thighlightSrgb: '#d07a00',\n\t\t\thighlightP3: 'color(display-p3 0.7699 0.4937 0.0085)',\n\t\t},\n\t\tred: {\n\t\t\tsolid: '#e03131',\n\t\t\tfill: '#e03131',\n\t\t\tlinedFill: '#c31d1d',\n\t\t\tframeHeadingStroke: '#701e1e', // Darker, muted variation of solid\n\t\t\tframeHeadingFill: '#301616', // Deep, muted reddish backdrop\n\t\t\tframeStroke: '#701e1e', // Matches headingStroke\n\t\t\tframeFill: '#1b1313', // Rich, dark muted background\n\t\t\tframeText: '#f2f2f2', // Bright text for readability\n\t\t\tnoteFill: '#7e201f', // Muted dark variant for note fill\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#382726', // Dark neutral-red tone\n\t\t\tpattern: '#8f3734', // Existing pattern color retained\n\t\t\thighlightSrgb: '#de002c',\n\t\t\thighlightP3: 'color(display-p3 0.7978 0.0509 0.2035)',\n\t\t},\n\t\tviolet: {\n\t\t\tsolid: '#ae3ec9',\n\t\t\tfill: '#ae3ec9',\n\t\t\tlinedFill: '#8f2fa7',\n\t\t\tframeHeadingStroke: '#6d1583', // Darker, muted variation of solid\n\t\t\tframeHeadingFill: '#27152e', // Deep, rich muted violet backdrop\n\t\t\tframeStroke: '#6d1583', // Matches headingStroke\n\t\t\tframeFill: '#1b0f21', // Darker muted violet background\n\t\t\tframeText: '#f2f2f2', // Consistent bright text color\n\t\t\tnoteFill: '#5f1c70', // Muted dark variant for note fill\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#342938', // Dark neutral-violet tone\n\t\t\tpattern: '#763a8b', // Retained existing pattern color\n\t\t\thighlightSrgb: '#9e00ee',\n\t\t\thighlightP3: 'color(display-p3 0.5651 0.0079 0.8986)',\n\t\t},\n\t\tyellow: {\n\t\t\tsolid: '#ffc034',\n\t\t\tfill: '#ffc034',\n\t\t\tlinedFill: '#ffae00',\n\t\t\tframeHeadingStroke: '#684e12', // Darker, muted variant of solid\n\t\t\tframeHeadingFill: '#2a2113', // Rich, muted dark-yellow background\n\t\t\tframeStroke: '#684e12', // Matches headingStroke\n\t\t\tframeFill: '#1e1911', // Darker muted shade for background fill\n\t\t\tframeText: '#f2f2f2', // Bright text color for readability\n\t\t\tnoteFill: '#8a5e1c', // Muted, dark complementary variant\n\t\t\tnoteText: '#f2f2f2',\n\t\t\tsemi: '#3b352b', // Dark muted neutral-yellow tone\n\t\t\tpattern: '#fecb92', // Existing shade retained\n\t\t\thighlightSrgb: '#d2b700',\n\t\t\thighlightP3: 'color(display-p3 0.8078 0.7225 0.0312)',\n\t\t},\n\t\twhite: {\n\t\t\tsolid: '#f3f3f3',\n\t\t\tfill: '#f3f3f3',\n\t\t\tlinedFill: '#f3f3f3',\n\t\t\tsemi: '#f5f5f5',\n\t\t\tpattern: '#f9f9f9',\n\t\t\tframeHeadingStroke: '#ffffff',\n\t\t\tframeHeadingFill: '#ffffff',\n\t\t\tframeStroke: '#ffffff',\n\t\t\tframeFill: '#ffffff',\n\t\t\tframeText: '#000000',\n\t\t\tnoteFill: '#eaeaea',\n\t\t\tnoteText: '#1d1d1d',\n\t\t\thighlightSrgb: '#ffffff',\n\t\t\thighlightP3: 'color(display-p3 1 1 1)',\n\t\t},\n\t},\n}\n\n/**\n * Returns the appropriate default color theme based on the dark mode preference.\n *\n * @param opts - Configuration options\n * - isDarkMode - Whether to return the dark theme (true) or light theme (false)\n * @returns The corresponding TLDefaultColorTheme (light or dark)\n *\n * @example\n * ```ts\n * import { getDefaultColorTheme } from '@tldraw/tlschema'\n *\n * // Get light theme\n * const lightTheme = getDefaultColorTheme({ isDarkMode: false })\n *\n * // Get dark theme\n * const darkTheme = getDefaultColorTheme({ isDarkMode: true })\n *\n * // Use with editor\n * const theme = getDefaultColorTheme({ isDarkMode: window.matchMedia('(prefers-color-scheme: dark)').matches })\n * ```\n *\n * @public\n */\nexport function getDefaultColorTheme(opts: { isDarkMode: boolean }): TLDefaultColorTheme {\n\treturn opts.isDarkMode ? DefaultColorThemePalette.darkMode : DefaultColorThemePalette.lightMode\n}\n\n/**\n * Default color style property used by tldraw shapes for their primary color.\n * This style prop allows shapes to use any of the default color names and\n * automatically saves the last used value for new shapes.\n *\n * @example\n * ```ts\n * import { DefaultColorStyle } from '@tldraw/tlschema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * color: typeof DefaultColorStyle\n * // other props...\n * }\n *\n * // Set color on a shape\n * const shape = {\n * // ... other properties\n * props: {\n * color: 'red' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultColorStyle = StyleProp.defineEnum('tldraw:color', {\n\tdefaultValue: 'black',\n\tvalues: defaultColorNames,\n})\n\n/**\n * Default label color style property used for text labels on shapes.\n * This is separate from the main color style to allow different colors\n * for shape fills/strokes versus their text labels.\n *\n * @example\n * ```ts\n * import { DefaultLabelColorStyle } from '@tldraw/tlschema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * labelColor: typeof DefaultLabelColorStyle\n * // other props...\n * }\n *\n * // Create a shape with different fill and label colors\n * const shape = {\n * // ... other properties\n * props: {\n * color: 'blue' as const,\n * labelColor: 'white' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultLabelColorStyle = StyleProp.defineEnum('tldraw:labelColor', {\n\tdefaultValue: 'black',\n\tvalues: defaultColorNames,\n})\n\n/**\n * Type representing a default color style value.\n * This is a union type of all available default color names.\n *\n * @example\n * ```ts\n * import { TLDefaultColorStyle } from '@tldraw/tlschema'\n *\n * // Valid color values\n * const redColor: TLDefaultColorStyle = 'red'\n * const blueColor: TLDefaultColorStyle = 'blue'\n *\n * // Type guard usage\n * function isValidColor(color: string): color is TLDefaultColorStyle {\n * return ['black', 'red', 'blue'].includes(color as TLDefaultColorStyle)\n * }\n * ```\n *\n * @public\n */\nexport type TLDefaultColorStyle = T.TypeOf<typeof DefaultColorStyle>\n\nconst defaultColorNamesSet = new Set(defaultColorNames)\n\n/**\n * Type guard to check if a color value is one of the default theme colors.\n * Useful for determining if a color can be looked up in the theme palette.\n *\n * @param color - The color value to check\n * @returns True if the color is a default theme color, false otherwise\n *\n * @example\n * ```ts\n * import { isDefaultThemeColor, TLDefaultColorStyle } from '@tldraw/tlschema'\n *\n * const color: TLDefaultColorStyle = 'red'\n *\n * if (isDefaultThemeColor(color)) {\n * // color is guaranteed to be a default theme color\n * console.log(`${color} is a default theme color`)\n * } else {\n * // color might be a custom hex value or other format\n * console.log(`${color} is a custom color`)\n * }\n * ```\n *\n * @public\n */\nexport function isDefaultThemeColor(\n\tcolor: TLDefaultColorStyle\n): color is (typeof defaultColorNames)[number] {\n\treturn defaultColorNamesSet.has(color as (typeof defaultColorNames)[number])\n}\n\n/**\n * Resolves a color style value to its actual CSS color string for a given theme and variant.\n * If the color is not a default theme color, returns the color value as-is.\n *\n * @param theme - The color theme to use for resolution\n * @param color - The color style value to resolve\n * @param variant - Which variant of the color to return (solid, fill, pattern, etc.)\n * @returns The CSS color string for the specified color and variant\n *\n * @example\n * ```ts\n * import { getColorValue, getDefaultColorTheme } from '@tldraw/tlschema'\n *\n * const theme = getDefaultColorTheme({ isDarkMode: false })\n *\n * // Get the solid variant of red\n * const redSolid = getColorValue(theme, 'red', 'solid') // '#e03131'\n *\n * // Get the fill variant of blue\n * const blueFill = getColorValue(theme, 'blue', 'fill') // '#4465e9'\n *\n * // Custom color passes through unchanged\n * const customColor = getColorValue(theme, '#ff0000', 'solid') // '#ff0000'\n * ```\n *\n * @public\n */\nexport function getColorValue(\n\ttheme: TLDefaultColorTheme,\n\tcolor: TLDefaultColorStyle,\n\tvariant: keyof TLDefaultColorThemeColor\n): string {\n\tif (!isDefaultThemeColor(color)) {\n\t\treturn color\n\t}\n\n\treturn theme[color][variant]\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,iBAAiB;AAoBnB,MAAM,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAyFO,MAAM,2BAGT;AAAA,EACH,WAAW;AAAA,IACV,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,OAAO;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,MAClB,aAAa;AAAA,MACb,WAAW;AAAA,MACX,WAAW;AAAA,MACX,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,eAAe;AAAA,MACf,aAAa;AAAA,IACd;AAAA,IACA,MAAM;AAAA,MACL,OAAO;AAAA,MACP,MAAM;AAAA,MACN,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,MAClB,aAAa;AAAA,MACb,WAAW;AAAA,MACX,WAAW;AAAA,MACX,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,eAAe;AAAA,MACf,aAAa;AAAA,IACd;AAAA,IACA,OAAO;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,WAAW;AAAA,MAC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"./StyleProp.mjs";
|
|
2
2
|
const DefaultFillStyle = StyleProp.defineEnum("tldraw:fill", {
|
|
3
3
|
defaultValue: "none",
|
|
4
|
-
values: ["none", "semi", "solid", "pattern", "fill"]
|
|
4
|
+
values: ["none", "semi", "solid", "pattern", "fill", "lined-fill"]
|
|
5
5
|
});
|
|
6
6
|
export {
|
|
7
7
|
DefaultFillStyle
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styles/TLFillStyle.ts"],
|
|
4
|
-
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default fill style property used by tldraw shapes for interior styling.\n * Controls how the inside of shapes are filled or left empty.\n *\n * Available values:\n * - `none` - No fill, shape interior is transparent\n * - `semi` - Semi-transparent fill using the shape's color\n * - `solid` - Solid fill using the shape's color\n * - `pattern` - Crosshatch pattern fill using the shape's color\n * - `fill` - Alternative solid fill variant\n *\n * @example\n * ```ts\n * import { DefaultFillStyle } from '@tldraw/tlschema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * fill: typeof DefaultFillStyle\n * // other props...\n * }\n *\n * // Create a shape with solid fill\n * const shape = {\n * // ... other properties\n * props: {\n * fill: 'solid' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultFillStyle = StyleProp.defineEnum('tldraw:fill', {\n\tdefaultValue: 'none',\n\tvalues: ['none', 'semi', 'solid', 'pattern', 'fill'],\n})\n\n/**\n * Type representing a default fill style value.\n * This is a union type of all available fill style options.\n *\n * @example\n * ```ts\n * import { TLDefaultFillStyle } from '@tldraw/tlschema'\n *\n * // Valid fill style values\n * const noFill: TLDefaultFillStyle = 'none'\n * const solidFill: TLDefaultFillStyle = 'solid'\n * const patternFill: TLDefaultFillStyle = 'pattern'\n *\n * // Use in a function parameter\n * function setShapeFill(fill: TLDefaultFillStyle) {\n * // Apply fill style to shape\n * }\n * ```\n *\n * @public\n */\nexport type TLDefaultFillStyle = T.TypeOf<typeof DefaultFillStyle>\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,iBAAiB;AAmCnB,MAAM,mBAAmB,UAAU,WAAW,eAAe;AAAA,EACnE,cAAc;AAAA,EACd,QAAQ,CAAC,QAAQ,QAAQ,SAAS,WAAW,
|
|
4
|
+
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default fill style property used by tldraw shapes for interior styling.\n * Controls how the inside of shapes are filled or left empty.\n *\n * Available values:\n * - `none` - No fill, shape interior is transparent\n * - `semi` - Semi-transparent fill using the shape's color\n * - `solid` - Solid fill using the shape's color\n * - `pattern` - Crosshatch pattern fill using the shape's color\n * - `fill` - Alternative solid fill variant\n *\n * @example\n * ```ts\n * import { DefaultFillStyle } from '@tldraw/tlschema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * fill: typeof DefaultFillStyle\n * // other props...\n * }\n *\n * // Create a shape with solid fill\n * const shape = {\n * // ... other properties\n * props: {\n * fill: 'solid' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultFillStyle = StyleProp.defineEnum('tldraw:fill', {\n\tdefaultValue: 'none',\n\tvalues: ['none', 'semi', 'solid', 'pattern', 'fill', 'lined-fill'],\n})\n\n/**\n * Type representing a default fill style value.\n * This is a union type of all available fill style options.\n *\n * @example\n * ```ts\n * import { TLDefaultFillStyle } from '@tldraw/tlschema'\n *\n * // Valid fill style values\n * const noFill: TLDefaultFillStyle = 'none'\n * const solidFill: TLDefaultFillStyle = 'solid'\n * const patternFill: TLDefaultFillStyle = 'pattern'\n *\n * // Use in a function parameter\n * function setShapeFill(fill: TLDefaultFillStyle) {\n * // Apply fill style to shape\n * }\n * ```\n *\n * @public\n */\nexport type TLDefaultFillStyle = T.TypeOf<typeof DefaultFillStyle>\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,iBAAiB;AAmCnB,MAAM,mBAAmB,UAAU,WAAW,eAAe;AAAA,EACnE,cAAc;AAAA,EACd,QAAQ,CAAC,QAAQ,QAAQ,SAAS,WAAW,QAAQ,YAAY;AAClE,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/tlschema",
|
|
3
3
|
"description": "tldraw infinite canvas SDK (schema).",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0-canary.03ae87dcc44b",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"vitest": "^3.2.4"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@tldraw/state": "4.
|
|
55
|
-
"@tldraw/store": "4.
|
|
56
|
-
"@tldraw/utils": "4.
|
|
57
|
-
"@tldraw/validate": "4.
|
|
54
|
+
"@tldraw/state": "4.3.0-canary.03ae87dcc44b",
|
|
55
|
+
"@tldraw/store": "4.3.0-canary.03ae87dcc44b",
|
|
56
|
+
"@tldraw/utils": "4.3.0-canary.03ae87dcc44b",
|
|
57
|
+
"@tldraw/validate": "4.3.0-canary.03ae87dcc44b"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.2.0 || ^19.0.0",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BaseRecord } from '@tldraw/store'
|
|
2
1
|
import { JsonObject } from '@tldraw/utils'
|
|
3
2
|
import { T } from '@tldraw/validate'
|
|
4
3
|
import { idValidator } from '../misc/id-validator'
|
|
@@ -10,33 +9,41 @@ import { shapeIdValidator } from '../shapes/TLBaseShape'
|
|
|
10
9
|
* Base interface for all binding types in tldraw. Bindings represent relationships
|
|
11
10
|
* between shapes, such as arrows connecting to other shapes or organizational connections.
|
|
12
11
|
*
|
|
13
|
-
* All bindings extend this base interface with specific type and property definitions.
|
|
12
|
+
* All default bindings extend this base interface with specific type and property definitions.
|
|
14
13
|
* The binding system enables shapes to maintain relationships that persist through
|
|
15
14
|
* transformations, movements, and other operations.
|
|
16
15
|
*
|
|
16
|
+
* Custom bindings should be defined by augmenting the TLGlobalBindingPropsMap type and getting the binding type from the TLBinding type.
|
|
17
|
+
*
|
|
17
18
|
* @param Type - String literal type identifying the specific binding type (e.g., 'arrow')
|
|
18
19
|
* @param Props - Object containing binding-specific properties and configuration
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```ts
|
|
22
|
-
* // Define a
|
|
23
|
-
* interface
|
|
24
|
-
*
|
|
25
|
-
* interface
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
* // Define a default binding type
|
|
24
|
+
* interface TLArrowBinding extends TLBaseBinding<'arrow', TLArrowBindingProps> {}
|
|
25
|
+
*
|
|
26
|
+
* interface TLArrowBindingProps {
|
|
27
|
+
* terminal: 'start' | 'end'
|
|
28
|
+
* normalizedAnchor: VecModel
|
|
29
|
+
* isExact: boolean
|
|
30
|
+
* isPrecise: boolean
|
|
31
|
+
* snap: ElbowArrowSnap
|
|
28
32
|
* }
|
|
29
33
|
*
|
|
30
34
|
* // Create a binding instance
|
|
31
|
-
* const
|
|
35
|
+
* const arrowBinding: TLArrowBinding = {
|
|
32
36
|
* id: 'binding:abc123',
|
|
33
37
|
* typeName: 'binding',
|
|
34
|
-
* type: '
|
|
38
|
+
* type: 'arrow',
|
|
35
39
|
* fromId: 'shape:source1',
|
|
36
40
|
* toId: 'shape:target1',
|
|
37
41
|
* props: {
|
|
38
|
-
*
|
|
39
|
-
*
|
|
42
|
+
* terminal: 'end',
|
|
43
|
+
* normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
44
|
+
* isExact: false,
|
|
45
|
+
* isPrecise: true,
|
|
46
|
+
* snap: 'edge'
|
|
40
47
|
* },
|
|
41
48
|
* meta: {}
|
|
42
49
|
* }
|
|
@@ -44,8 +51,12 @@ import { shapeIdValidator } from '../shapes/TLBaseShape'
|
|
|
44
51
|
*
|
|
45
52
|
* @public
|
|
46
53
|
*/
|
|
47
|
-
export interface TLBaseBinding<Type extends string, Props extends object>
|
|
48
|
-
extends BaseRecord<'binding', TLBindingId
|
|
54
|
+
export interface TLBaseBinding<Type extends string, Props extends object> {
|
|
55
|
+
// using real `extends BaseRecord<'binding', TLBindingId>` introduces a circularity in the types
|
|
56
|
+
// and for that reason those "base members" have to be declared manually here
|
|
57
|
+
readonly id: TLBindingId
|
|
58
|
+
readonly typeName: 'binding'
|
|
59
|
+
|
|
49
60
|
/** The specific type of this binding (e.g., 'arrow', 'custom') */
|
|
50
61
|
type: Type
|
|
51
62
|
/** ID of the source shape in this binding relationship */
|
package/src/createTLSchema.ts
CHANGED
|
@@ -22,8 +22,9 @@ import {
|
|
|
22
22
|
getShapePropKeysByStyle,
|
|
23
23
|
rootShapeMigrations,
|
|
24
24
|
} from './records/TLShape'
|
|
25
|
-
import { TLPropsMigrations, processPropsMigrations } from './recordsWithProps'
|
|
25
|
+
import { RecordProps, TLPropsMigrations, processPropsMigrations } from './recordsWithProps'
|
|
26
26
|
import { arrowShapeMigrations, arrowShapeProps } from './shapes/TLArrowShape'
|
|
27
|
+
import { TLBaseShape } from './shapes/TLBaseShape'
|
|
27
28
|
import { bookmarkShapeMigrations, bookmarkShapeProps } from './shapes/TLBookmarkShape'
|
|
28
29
|
import { drawShapeMigrations, drawShapeProps } from './shapes/TLDrawShape'
|
|
29
30
|
import { embedShapeMigrations, embedShapeProps } from './shapes/TLEmbedShape'
|
|
@@ -147,7 +148,12 @@ export const defaultShapeSchemas = {
|
|
|
147
148
|
note: { migrations: noteShapeMigrations, props: noteShapeProps },
|
|
148
149
|
text: { migrations: textShapeMigrations, props: textShapeProps },
|
|
149
150
|
video: { migrations: videoShapeMigrations, props: videoShapeProps },
|
|
150
|
-
} satisfies {
|
|
151
|
+
} satisfies {
|
|
152
|
+
[T in TLDefaultShape['type']]: {
|
|
153
|
+
migrations: SchemaPropsInfo['migrations']
|
|
154
|
+
props: RecordProps<TLBaseShape<T, Extract<TLDefaultShape, { type: T }>['props']>>
|
|
155
|
+
}
|
|
156
|
+
}
|
|
151
157
|
|
|
152
158
|
/**
|
|
153
159
|
* Default binding schema configurations for all built-in tldraw binding types.
|
package/src/index.ts
CHANGED
|
@@ -99,6 +99,8 @@ export {
|
|
|
99
99
|
type TLBindingId,
|
|
100
100
|
type TLBindingUpdate,
|
|
101
101
|
type TLDefaultBinding,
|
|
102
|
+
type TLGlobalBindingPropsMap,
|
|
103
|
+
type TLIndexedBindings,
|
|
102
104
|
type TLUnknownBinding,
|
|
103
105
|
} from './records/TLBinding'
|
|
104
106
|
export { CameraRecordType, type TLCamera, type TLCameraId } from './records/TLCamera'
|
|
@@ -146,7 +148,11 @@ export {
|
|
|
146
148
|
isShape,
|
|
147
149
|
isShapeId,
|
|
148
150
|
rootShapeMigrations,
|
|
151
|
+
type ExtractShapeByProps,
|
|
152
|
+
type TLCreateShapePartial,
|
|
149
153
|
type TLDefaultShape,
|
|
154
|
+
type TLGlobalShapePropsMap,
|
|
155
|
+
type TLIndexedShapes,
|
|
150
156
|
type TLParentId,
|
|
151
157
|
type TLShape,
|
|
152
158
|
type TLShapeId,
|
|
@@ -262,6 +268,7 @@ export {
|
|
|
262
268
|
defaultColorNames,
|
|
263
269
|
DefaultColorStyle,
|
|
264
270
|
DefaultColorThemePalette,
|
|
271
|
+
DefaultLabelColorStyle,
|
|
265
272
|
getColorValue,
|
|
266
273
|
getDefaultColorTheme,
|
|
267
274
|
type TLDefaultColorStyle,
|
package/src/misc/TLHandle.ts
CHANGED
|
@@ -102,6 +102,8 @@ export interface TLHandle {
|
|
|
102
102
|
canSnap?: boolean
|
|
103
103
|
/** The type of snap to use for this handle */
|
|
104
104
|
snapType?: 'point' | 'align'
|
|
105
|
+
/** The ID of the handle to use as reference point for shift-modifier angle snapping */
|
|
106
|
+
snapReferenceHandleId?: string
|
|
105
107
|
/** The fractional index used for ordering handles */
|
|
106
108
|
index: IndexKey
|
|
107
109
|
/** The x-coordinate of the handle in the shape's local coordinate system */
|
package/src/records/TLAsset.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { TLBaseAsset } from '../assets/TLBaseAsset'
|
|
|
9
9
|
import { bookmarkAssetValidator, TLBookmarkAsset } from '../assets/TLBookmarkAsset'
|
|
10
10
|
import { imageAssetValidator, TLImageAsset } from '../assets/TLImageAsset'
|
|
11
11
|
import { TLVideoAsset, videoAssetValidator } from '../assets/TLVideoAsset'
|
|
12
|
-
import {
|
|
12
|
+
import { ExtractShapeByProps } from './TLShape'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Union type representing all possible asset types in tldraw.
|
|
@@ -222,4 +222,4 @@ export type TLAssetId = RecordId<TLBaseAsset<any, any>>
|
|
|
222
222
|
*
|
|
223
223
|
* @public
|
|
224
224
|
*/
|
|
225
|
-
export type TLAssetShape =
|
|
225
|
+
export type TLAssetShape = ExtractShapeByProps<{ assetId: TLAssetId }>
|
package/src/records/TLBinding.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
createRecordMigrationSequence,
|
|
6
6
|
createRecordType,
|
|
7
7
|
} from '@tldraw/store'
|
|
8
|
-
import {
|
|
8
|
+
import { mapObjectMapValues, uniqueId } from '@tldraw/utils'
|
|
9
9
|
import { T } from '@tldraw/validate'
|
|
10
10
|
import { TLArrowBinding } from '../bindings/TLArrowBinding'
|
|
11
11
|
import { TLBaseBinding, createBindingValidator } from '../bindings/TLBaseBinding'
|
|
@@ -56,10 +56,42 @@ export type TLDefaultBinding = TLArrowBinding
|
|
|
56
56
|
*/
|
|
57
57
|
export type TLUnknownBinding = TLBaseBinding<string, object>
|
|
58
58
|
|
|
59
|
+
/** @public */
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
61
|
+
export interface TLGlobalBindingPropsMap {}
|
|
62
|
+
|
|
63
|
+
/** @public */
|
|
64
|
+
// prettier-ignore
|
|
65
|
+
export type TLIndexedBindings = {
|
|
66
|
+
// We iterate over a union of augmented keys and default binding types.
|
|
67
|
+
// This allows us to include (or conditionally exclude or override) the default bindings in one go.
|
|
68
|
+
//
|
|
69
|
+
// In the `as` clause we are filtering out disabled bindings.
|
|
70
|
+
[K in keyof TLGlobalBindingPropsMap | TLDefaultBinding['type'] as K extends TLDefaultBinding['type']
|
|
71
|
+
? K extends keyof TLGlobalBindingPropsMap
|
|
72
|
+
? // if it extends a nullish value the user has disabled this binding type so we filter it out with never
|
|
73
|
+
TLGlobalBindingPropsMap[K] extends null | undefined
|
|
74
|
+
? never
|
|
75
|
+
: K
|
|
76
|
+
: K
|
|
77
|
+
: K]: K extends TLDefaultBinding['type']
|
|
78
|
+
? // if it's a default binding type we need to check if it's been overridden
|
|
79
|
+
K extends keyof TLGlobalBindingPropsMap
|
|
80
|
+
? // if it has been overriden then use the custom binding definition
|
|
81
|
+
TLBaseBinding<K, TLGlobalBindingPropsMap[K]>
|
|
82
|
+
: // if it has not been overriden then reuse existing type aliases for better type display
|
|
83
|
+
Extract<TLDefaultBinding, { type: K }>
|
|
84
|
+
: // use the custom binding definition
|
|
85
|
+
TLBaseBinding<K, TLGlobalBindingPropsMap[K & keyof TLGlobalBindingPropsMap]>
|
|
86
|
+
}
|
|
87
|
+
|
|
59
88
|
/**
|
|
60
|
-
* The set of all bindings that are available in the editor
|
|
89
|
+
* The set of all bindings that are available in the editor.
|
|
61
90
|
* Bindings represent relationships between shapes, such as arrows connecting to other shapes.
|
|
62
91
|
*
|
|
92
|
+
* You can use this type without a type argument to work with any binding, or pass
|
|
93
|
+
* a specific binding type string (e.g., `'arrow'`) to narrow down to that specific binding type.
|
|
94
|
+
*
|
|
63
95
|
* @example
|
|
64
96
|
* ```ts
|
|
65
97
|
* // Check binding type and handle accordingly
|
|
@@ -73,11 +105,17 @@ export type TLUnknownBinding = TLBaseBinding<string, object>
|
|
|
73
105
|
* break
|
|
74
106
|
* }
|
|
75
107
|
* }
|
|
108
|
+
*
|
|
109
|
+
* // Narrow to a specific binding type by passing the type as a generic argument
|
|
110
|
+
* function getArrowSourceId(binding: TLBinding<'arrow'>) {
|
|
111
|
+
* return binding.fromId // TypeScript knows this is a TLArrowBinding
|
|
112
|
+
* }
|
|
76
113
|
* ```
|
|
77
114
|
*
|
|
78
115
|
* @public
|
|
79
116
|
*/
|
|
80
|
-
export type TLBinding =
|
|
117
|
+
export type TLBinding<K extends keyof TLIndexedBindings = keyof TLIndexedBindings> =
|
|
118
|
+
TLIndexedBindings[K]
|
|
81
119
|
|
|
82
120
|
/**
|
|
83
121
|
* Type for updating existing bindings with partial properties.
|
|
@@ -99,15 +137,17 @@ export type TLBinding = TLDefaultBinding | TLUnknownBinding
|
|
|
99
137
|
*
|
|
100
138
|
* @public
|
|
101
139
|
*/
|
|
102
|
-
export type TLBindingUpdate<T extends TLBinding = TLBinding> =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
140
|
+
export type TLBindingUpdate<T extends TLBinding = TLBinding> = T extends T
|
|
141
|
+
? {
|
|
142
|
+
id: TLBindingId
|
|
143
|
+
type: T['type']
|
|
144
|
+
typeName?: T['typeName']
|
|
145
|
+
fromId?: T['fromId']
|
|
146
|
+
toId?: T['toId']
|
|
147
|
+
props?: Partial<T['props']>
|
|
148
|
+
meta?: Partial<T['meta']>
|
|
149
|
+
}
|
|
150
|
+
: never
|
|
111
151
|
|
|
112
152
|
/**
|
|
113
153
|
* Type for creating new bindings with required fromId and toId.
|
|
@@ -133,15 +173,17 @@ export type TLBindingUpdate<T extends TLBinding = TLBinding> = Expand<{
|
|
|
133
173
|
*
|
|
134
174
|
* @public
|
|
135
175
|
*/
|
|
136
|
-
export type TLBindingCreate<T extends TLBinding = TLBinding> =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
176
|
+
export type TLBindingCreate<T extends TLBinding = TLBinding> = T extends T
|
|
177
|
+
? {
|
|
178
|
+
id?: TLBindingId
|
|
179
|
+
type: T['type']
|
|
180
|
+
typeName?: T['typeName']
|
|
181
|
+
fromId: T['fromId']
|
|
182
|
+
toId: T['toId']
|
|
183
|
+
props?: Partial<T['props']>
|
|
184
|
+
meta?: Partial<T['meta']>
|
|
185
|
+
}
|
|
186
|
+
: never
|
|
145
187
|
|
|
146
188
|
/**
|
|
147
189
|
* Branded string type for binding record identifiers.
|
|
@@ -166,7 +208,7 @@ export type TLBindingCreate<T extends TLBinding = TLBinding> = Expand<{
|
|
|
166
208
|
*
|
|
167
209
|
* @public
|
|
168
210
|
*/
|
|
169
|
-
export type TLBindingId = RecordId<
|
|
211
|
+
export type TLBindingId = RecordId<TLBinding>
|
|
170
212
|
|
|
171
213
|
/**
|
|
172
214
|
* Migration version identifiers for the root binding record schema.
|
|
@@ -375,7 +417,7 @@ export function createBindingPropsMigrationIds<S extends string, T extends Recor
|
|
|
375
417
|
* @internal
|
|
376
418
|
*/
|
|
377
419
|
export function createBindingRecordType(bindings: Record<string, SchemaPropsInfo>) {
|
|
378
|
-
return createRecordType
|
|
420
|
+
return createRecordType('binding', {
|
|
379
421
|
scope: 'document',
|
|
380
422
|
validator: T.model(
|
|
381
423
|
'binding',
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { IndexKey } from '@tldraw/utils'
|
|
1
2
|
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { toRichText } from '../misc/TLRichText'
|
|
4
|
+
import { TLPageId } from './TLPage'
|
|
2
5
|
import { TLRecord } from './TLRecord'
|
|
6
|
+
import { TLParentId, TLShapeId } from './TLShape'
|
|
3
7
|
|
|
4
8
|
describe('TLRecord', () => {
|
|
5
9
|
it('should support type discrimination by typeName', () => {
|
|
@@ -34,14 +38,14 @@ describe('TLRecord', () => {
|
|
|
34
38
|
|
|
35
39
|
// Test that the discriminated union works correctly
|
|
36
40
|
const shapeRecord: TLRecord = {
|
|
37
|
-
id: 'shape:test' as
|
|
41
|
+
id: 'shape:test' as TLShapeId,
|
|
38
42
|
typeName: 'shape',
|
|
39
43
|
type: 'geo',
|
|
40
44
|
x: 50,
|
|
41
45
|
y: 100,
|
|
42
46
|
rotation: 0,
|
|
43
|
-
index: 'a1' as
|
|
44
|
-
parentId: 'page:main' as
|
|
47
|
+
index: 'a1' as IndexKey,
|
|
48
|
+
parentId: 'page:main' as TLParentId,
|
|
45
49
|
isLocked: false,
|
|
46
50
|
opacity: 1,
|
|
47
51
|
props: {
|
|
@@ -52,15 +56,23 @@ describe('TLRecord', () => {
|
|
|
52
56
|
fill: 'none',
|
|
53
57
|
dash: 'draw',
|
|
54
58
|
size: 'm',
|
|
59
|
+
growY: 0,
|
|
60
|
+
url: '',
|
|
61
|
+
scale: 1,
|
|
62
|
+
font: 'draw',
|
|
63
|
+
align: 'middle',
|
|
64
|
+
verticalAlign: 'middle',
|
|
65
|
+
labelColor: 'black',
|
|
66
|
+
richText: toRichText(''),
|
|
55
67
|
},
|
|
56
68
|
meta: {},
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
const pageRecord: TLRecord = {
|
|
60
|
-
id: 'page:test' as
|
|
72
|
+
id: 'page:test' as TLPageId,
|
|
61
73
|
typeName: 'page',
|
|
62
74
|
name: 'Test Page',
|
|
63
|
-
index: 'a1' as
|
|
75
|
+
index: 'a1' as IndexKey,
|
|
64
76
|
meta: {},
|
|
65
77
|
}
|
|
66
78
|
|