@tldraw/tlschema 4.1.0-canary.e653ec63c99b → 4.1.0-canary.f2f81cd6fe2c

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.
Files changed (214) hide show
  1. package/dist-cjs/TLStore.js +3 -10
  2. package/dist-cjs/TLStore.js.map +2 -2
  3. package/dist-cjs/assets/TLBaseAsset.js.map +2 -2
  4. package/dist-cjs/assets/TLBookmarkAsset.js.map +2 -2
  5. package/dist-cjs/assets/TLImageAsset.js.map +2 -2
  6. package/dist-cjs/assets/TLVideoAsset.js.map +2 -2
  7. package/dist-cjs/bindings/TLArrowBinding.js.map +2 -2
  8. package/dist-cjs/bindings/TLBaseBinding.js.map +2 -2
  9. package/dist-cjs/createPresenceStateDerivation.js.map +2 -2
  10. package/dist-cjs/createTLSchema.js.map +2 -2
  11. package/dist-cjs/index.d.ts +4416 -223
  12. package/dist-cjs/index.js +1 -1
  13. package/dist-cjs/index.js.map +2 -2
  14. package/dist-cjs/misc/TLColor.js.map +2 -2
  15. package/dist-cjs/misc/TLCursor.js.map +2 -2
  16. package/dist-cjs/misc/TLHandle.js.map +2 -2
  17. package/dist-cjs/misc/TLOpacity.js.map +2 -2
  18. package/dist-cjs/misc/TLRichText.js.map +2 -2
  19. package/dist-cjs/misc/TLScribble.js.map +2 -2
  20. package/dist-cjs/misc/geometry-types.js.map +2 -2
  21. package/dist-cjs/misc/id-validator.js.map +2 -2
  22. package/dist-cjs/records/TLAsset.js.map +2 -2
  23. package/dist-cjs/records/TLBinding.js.map +2 -2
  24. package/dist-cjs/records/TLCamera.js.map +2 -2
  25. package/dist-cjs/records/TLDocument.js.map +2 -2
  26. package/dist-cjs/records/TLInstance.js.map +2 -2
  27. package/dist-cjs/records/TLPage.js.map +2 -2
  28. package/dist-cjs/records/TLPageState.js.map +2 -2
  29. package/dist-cjs/records/TLPointer.js.map +2 -2
  30. package/dist-cjs/records/TLPresence.js.map +2 -2
  31. package/dist-cjs/records/TLRecord.js.map +1 -1
  32. package/dist-cjs/records/TLShape.js.map +2 -2
  33. package/dist-cjs/recordsWithProps.js.map +2 -2
  34. package/dist-cjs/shapes/ShapeWithCrop.js.map +1 -1
  35. package/dist-cjs/shapes/TLArrowShape.js.map +2 -2
  36. package/dist-cjs/shapes/TLBaseShape.js.map +2 -2
  37. package/dist-cjs/shapes/TLBookmarkShape.js.map +2 -2
  38. package/dist-cjs/shapes/TLDrawShape.js.map +2 -2
  39. package/dist-cjs/shapes/TLEmbedShape.js +0 -10
  40. package/dist-cjs/shapes/TLEmbedShape.js.map +2 -2
  41. package/dist-cjs/shapes/TLFrameShape.js.map +2 -2
  42. package/dist-cjs/shapes/TLGeoShape.js.map +2 -2
  43. package/dist-cjs/shapes/TLGroupShape.js.map +2 -2
  44. package/dist-cjs/shapes/TLHighlightShape.js.map +2 -2
  45. package/dist-cjs/shapes/TLImageShape.js.map +2 -2
  46. package/dist-cjs/shapes/TLLineShape.js.map +2 -2
  47. package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
  48. package/dist-cjs/shapes/TLTextShape.js.map +2 -2
  49. package/dist-cjs/shapes/TLVideoShape.js.map +2 -2
  50. package/dist-cjs/store-migrations.js.map +2 -2
  51. package/dist-cjs/styles/TLColorStyle.js.map +2 -2
  52. package/dist-cjs/styles/TLDashStyle.js.map +2 -2
  53. package/dist-cjs/styles/TLFillStyle.js.map +2 -2
  54. package/dist-cjs/styles/TLFontStyle.js.map +2 -2
  55. package/dist-cjs/styles/TLHorizontalAlignStyle.js.map +2 -2
  56. package/dist-cjs/styles/TLSizeStyle.js.map +2 -2
  57. package/dist-cjs/styles/TLTextAlignStyle.js.map +2 -2
  58. package/dist-cjs/styles/TLVerticalAlignStyle.js.map +2 -2
  59. package/dist-cjs/translations/translations.js +1 -1
  60. package/dist-cjs/translations/translations.js.map +2 -2
  61. package/dist-cjs/util-types.js.map +1 -1
  62. package/dist-esm/TLStore.mjs +3 -10
  63. package/dist-esm/TLStore.mjs.map +2 -2
  64. package/dist-esm/assets/TLBaseAsset.mjs.map +2 -2
  65. package/dist-esm/assets/TLBookmarkAsset.mjs.map +2 -2
  66. package/dist-esm/assets/TLImageAsset.mjs.map +2 -2
  67. package/dist-esm/assets/TLVideoAsset.mjs.map +2 -2
  68. package/dist-esm/bindings/TLArrowBinding.mjs.map +2 -2
  69. package/dist-esm/bindings/TLBaseBinding.mjs.map +2 -2
  70. package/dist-esm/createPresenceStateDerivation.mjs.map +2 -2
  71. package/dist-esm/createTLSchema.mjs.map +2 -2
  72. package/dist-esm/index.d.mts +4416 -223
  73. package/dist-esm/index.mjs +1 -1
  74. package/dist-esm/index.mjs.map +2 -2
  75. package/dist-esm/misc/TLColor.mjs.map +2 -2
  76. package/dist-esm/misc/TLCursor.mjs.map +2 -2
  77. package/dist-esm/misc/TLHandle.mjs.map +2 -2
  78. package/dist-esm/misc/TLOpacity.mjs.map +2 -2
  79. package/dist-esm/misc/TLRichText.mjs.map +2 -2
  80. package/dist-esm/misc/TLScribble.mjs.map +2 -2
  81. package/dist-esm/misc/geometry-types.mjs.map +2 -2
  82. package/dist-esm/misc/id-validator.mjs.map +2 -2
  83. package/dist-esm/records/TLAsset.mjs.map +2 -2
  84. package/dist-esm/records/TLBinding.mjs.map +2 -2
  85. package/dist-esm/records/TLCamera.mjs.map +2 -2
  86. package/dist-esm/records/TLDocument.mjs.map +2 -2
  87. package/dist-esm/records/TLInstance.mjs.map +2 -2
  88. package/dist-esm/records/TLPage.mjs.map +2 -2
  89. package/dist-esm/records/TLPageState.mjs.map +2 -2
  90. package/dist-esm/records/TLPointer.mjs.map +2 -2
  91. package/dist-esm/records/TLPresence.mjs.map +2 -2
  92. package/dist-esm/records/TLShape.mjs.map +2 -2
  93. package/dist-esm/recordsWithProps.mjs.map +2 -2
  94. package/dist-esm/shapes/TLArrowShape.mjs.map +2 -2
  95. package/dist-esm/shapes/TLBaseShape.mjs.map +2 -2
  96. package/dist-esm/shapes/TLBookmarkShape.mjs.map +2 -2
  97. package/dist-esm/shapes/TLDrawShape.mjs.map +2 -2
  98. package/dist-esm/shapes/TLEmbedShape.mjs +0 -10
  99. package/dist-esm/shapes/TLEmbedShape.mjs.map +2 -2
  100. package/dist-esm/shapes/TLFrameShape.mjs.map +2 -2
  101. package/dist-esm/shapes/TLGeoShape.mjs.map +2 -2
  102. package/dist-esm/shapes/TLGroupShape.mjs.map +2 -2
  103. package/dist-esm/shapes/TLHighlightShape.mjs.map +2 -2
  104. package/dist-esm/shapes/TLImageShape.mjs.map +2 -2
  105. package/dist-esm/shapes/TLLineShape.mjs.map +2 -2
  106. package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
  107. package/dist-esm/shapes/TLTextShape.mjs.map +2 -2
  108. package/dist-esm/shapes/TLVideoShape.mjs.map +2 -2
  109. package/dist-esm/store-migrations.mjs.map +2 -2
  110. package/dist-esm/styles/TLColorStyle.mjs.map +2 -2
  111. package/dist-esm/styles/TLDashStyle.mjs.map +2 -2
  112. package/dist-esm/styles/TLFillStyle.mjs.map +2 -2
  113. package/dist-esm/styles/TLFontStyle.mjs.map +2 -2
  114. package/dist-esm/styles/TLHorizontalAlignStyle.mjs.map +2 -2
  115. package/dist-esm/styles/TLSizeStyle.mjs.map +2 -2
  116. package/dist-esm/styles/TLTextAlignStyle.mjs.map +2 -2
  117. package/dist-esm/styles/TLVerticalAlignStyle.mjs.map +2 -2
  118. package/dist-esm/translations/translations.mjs +1 -1
  119. package/dist-esm/translations/translations.mjs.map +2 -2
  120. package/package.json +5 -5
  121. package/src/TLStore.test.ts +644 -0
  122. package/src/TLStore.ts +205 -20
  123. package/src/assets/TLBaseAsset.ts +90 -7
  124. package/src/assets/TLBookmarkAsset.test.ts +96 -0
  125. package/src/assets/TLBookmarkAsset.ts +52 -2
  126. package/src/assets/TLImageAsset.test.ts +213 -0
  127. package/src/assets/TLImageAsset.ts +60 -2
  128. package/src/assets/TLVideoAsset.test.ts +105 -0
  129. package/src/assets/TLVideoAsset.ts +93 -4
  130. package/src/bindings/TLArrowBinding.test.ts +55 -0
  131. package/src/bindings/TLArrowBinding.ts +132 -10
  132. package/src/bindings/TLBaseBinding.ts +140 -3
  133. package/src/createPresenceStateDerivation.test.ts +158 -0
  134. package/src/createPresenceStateDerivation.ts +71 -2
  135. package/src/createTLSchema.test.ts +181 -0
  136. package/src/createTLSchema.ts +164 -7
  137. package/src/index.ts +32 -0
  138. package/src/misc/TLColor.ts +50 -6
  139. package/src/misc/TLCursor.ts +110 -8
  140. package/src/misc/TLHandle.ts +86 -6
  141. package/src/misc/TLOpacity.ts +51 -2
  142. package/src/misc/TLRichText.ts +56 -3
  143. package/src/misc/TLScribble.ts +105 -5
  144. package/src/misc/geometry-types.ts +30 -2
  145. package/src/misc/id-validator.test.ts +50 -0
  146. package/src/misc/id-validator.ts +20 -1
  147. package/src/records/TLAsset.test.ts +234 -0
  148. package/src/records/TLAsset.ts +165 -8
  149. package/src/records/TLBinding.test.ts +22 -0
  150. package/src/records/TLBinding.ts +277 -11
  151. package/src/records/TLCamera.test.ts +19 -0
  152. package/src/records/TLCamera.ts +118 -7
  153. package/src/records/TLDocument.test.ts +35 -0
  154. package/src/records/TLDocument.ts +148 -8
  155. package/src/records/TLInstance.test.ts +201 -0
  156. package/src/records/TLInstance.ts +117 -9
  157. package/src/records/TLPage.test.ts +110 -0
  158. package/src/records/TLPage.ts +106 -8
  159. package/src/records/TLPageState.test.ts +228 -0
  160. package/src/records/TLPageState.ts +88 -7
  161. package/src/records/TLPointer.test.ts +63 -0
  162. package/src/records/TLPointer.ts +105 -7
  163. package/src/records/TLPresence.test.ts +190 -0
  164. package/src/records/TLPresence.ts +99 -5
  165. package/src/records/TLRecord.test.ts +70 -0
  166. package/src/records/TLRecord.ts +43 -1
  167. package/src/records/TLShape.test.ts +232 -0
  168. package/src/records/TLShape.ts +289 -12
  169. package/src/recordsWithProps.test.ts +188 -0
  170. package/src/recordsWithProps.ts +131 -2
  171. package/src/shapes/ShapeWithCrop.test.ts +18 -0
  172. package/src/shapes/ShapeWithCrop.ts +64 -2
  173. package/src/shapes/TLArrowShape.test.ts +505 -0
  174. package/src/shapes/TLArrowShape.ts +188 -10
  175. package/src/shapes/TLBaseShape.test.ts +142 -0
  176. package/src/shapes/TLBaseShape.ts +103 -4
  177. package/src/shapes/TLBookmarkShape.test.ts +122 -0
  178. package/src/shapes/TLBookmarkShape.ts +58 -4
  179. package/src/shapes/TLDrawShape.test.ts +177 -0
  180. package/src/shapes/TLDrawShape.ts +97 -6
  181. package/src/shapes/TLEmbedShape.test.ts +286 -0
  182. package/src/shapes/TLEmbedShape.ts +57 -14
  183. package/src/shapes/TLFrameShape.test.ts +71 -0
  184. package/src/shapes/TLFrameShape.ts +59 -4
  185. package/src/shapes/TLGeoShape.test.ts +247 -0
  186. package/src/shapes/TLGeoShape.ts +103 -7
  187. package/src/shapes/TLGroupShape.test.ts +59 -0
  188. package/src/shapes/TLGroupShape.ts +52 -4
  189. package/src/shapes/TLHighlightShape.test.ts +325 -0
  190. package/src/shapes/TLHighlightShape.ts +79 -4
  191. package/src/shapes/TLImageShape.test.ts +534 -0
  192. package/src/shapes/TLImageShape.ts +105 -5
  193. package/src/shapes/TLLineShape.test.ts +269 -0
  194. package/src/shapes/TLLineShape.ts +128 -8
  195. package/src/shapes/TLNoteShape.test.ts +1568 -0
  196. package/src/shapes/TLNoteShape.ts +97 -4
  197. package/src/shapes/TLTextShape.test.ts +407 -0
  198. package/src/shapes/TLTextShape.ts +94 -4
  199. package/src/shapes/TLVideoShape.test.ts +112 -0
  200. package/src/shapes/TLVideoShape.ts +99 -4
  201. package/src/store-migrations.test.ts +88 -0
  202. package/src/store-migrations.ts +47 -1
  203. package/src/styles/TLColorStyle.test.ts +439 -0
  204. package/src/styles/TLColorStyle.ts +228 -10
  205. package/src/styles/TLDashStyle.ts +54 -2
  206. package/src/styles/TLFillStyle.ts +54 -2
  207. package/src/styles/TLFontStyle.ts +72 -3
  208. package/src/styles/TLHorizontalAlignStyle.ts +55 -2
  209. package/src/styles/TLSizeStyle.ts +54 -2
  210. package/src/styles/TLTextAlignStyle.ts +52 -2
  211. package/src/styles/TLVerticalAlignStyle.ts +52 -2
  212. package/src/translations/translations.test.ts +378 -35
  213. package/src/translations/translations.ts +157 -10
  214. package/src/util-types.ts +51 -1
@@ -2,7 +2,24 @@ import { Expand } from '@tldraw/utils'
2
2
  import { T } from '@tldraw/validate'
3
3
  import { StyleProp } from './StyleProp'
4
4
 
5
- /** @public */
5
+ /**
6
+ * Array of default color names available in tldraw's color palette.
7
+ * These colors form the basis for the default color style system and are available
8
+ * in both light and dark theme variants.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { defaultColorNames } from '@tldraw/tlschema'
13
+ *
14
+ * // Create a color picker with all default colors
15
+ * const colorOptions = defaultColorNames.map(color => ({
16
+ * name: color,
17
+ * value: color
18
+ * }))
19
+ * ```
20
+ *
21
+ * @public
22
+ */
6
23
  export const defaultColorNames = [
7
24
  'black',
8
25
  'grey',
@@ -19,7 +36,26 @@ export const defaultColorNames = [
19
36
  'white',
20
37
  ] as const
21
38
 
22
- /** @public */
39
+ /**
40
+ * Defines the color variants available for each color in the default theme.
41
+ * Each color has multiple variants for different use cases like fills, strokes,
42
+ * patterns, and UI elements like frames and notes.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { TLDefaultColorThemeColor } from '@tldraw/tlschema'
47
+ *
48
+ * const blueColor: TLDefaultColorThemeColor = {
49
+ * solid: '#4465e9',
50
+ * semi: '#dce1f8',
51
+ * pattern: '#6681ee',
52
+ * fill: '#4465e9',
53
+ * // ... other variants
54
+ * }
55
+ * ```
56
+ *
57
+ * @public
58
+ */
23
59
  export interface TLDefaultColorThemeColor {
24
60
  solid: string
25
61
  semi: string
@@ -36,7 +72,27 @@ export interface TLDefaultColorThemeColor {
36
72
  highlightP3: string
37
73
  }
38
74
 
39
- /** @public */
75
+ /**
76
+ * Complete color theme definition containing all colors and their variants
77
+ * for either light or dark mode. Includes base theme properties and all
78
+ * default colors with their respective color variants.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import { TLDefaultColorTheme } from '@tldraw/tlschema'
83
+ *
84
+ * const customTheme: TLDefaultColorTheme = {
85
+ * id: 'light',
86
+ * text: '#000000',
87
+ * background: '#ffffff',
88
+ * solid: '#fcfffe',
89
+ * black: { solid: '#000000', semi: '#cccccc', ... },
90
+ * // ... other colors
91
+ * }
92
+ * ```
93
+ *
94
+ * @public
95
+ */
40
96
  export type TLDefaultColorTheme = Expand<
41
97
  {
42
98
  id: 'light' | 'dark'
@@ -46,7 +102,26 @@ export type TLDefaultColorTheme = Expand<
46
102
  } & Record<(typeof defaultColorNames)[number], TLDefaultColorThemeColor>
47
103
  >
48
104
 
49
- /** @public */
105
+ /**
106
+ * Complete color palette containing both light and dark theme definitions.
107
+ * This object provides the full color system used by tldraw's default themes,
108
+ * including all color variants and theme-specific adjustments.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { DefaultColorThemePalette } from '@tldraw/tlschema'
113
+ *
114
+ * // Get the dark theme colors
115
+ * const darkTheme = DefaultColorThemePalette.darkMode
116
+ * const redColor = darkTheme.red.solid // '#e03131'
117
+ *
118
+ * // Access light theme colors
119
+ * const lightTheme = DefaultColorThemePalette.lightMode
120
+ * const blueColor = lightTheme.blue.fill // '#4465e9'
121
+ * ```
122
+ *
123
+ * @public
124
+ */
50
125
  export const DefaultColorThemePalette: {
51
126
  lightMode: TLDefaultColorTheme
52
127
  darkMode: TLDefaultColorTheme
@@ -456,36 +531,179 @@ export const DefaultColorThemePalette: {
456
531
  },
457
532
  }
458
533
 
459
- /** @public */
534
+ /**
535
+ * Returns the appropriate default color theme based on the dark mode preference.
536
+ *
537
+ * @param opts - Configuration options
538
+ * - isDarkMode - Whether to return the dark theme (true) or light theme (false)
539
+ * @returns The corresponding TLDefaultColorTheme (light or dark)
540
+ *
541
+ * @example
542
+ * ```ts
543
+ * import { getDefaultColorTheme } from '@tldraw/tlschema'
544
+ *
545
+ * // Get light theme
546
+ * const lightTheme = getDefaultColorTheme({ isDarkMode: false })
547
+ *
548
+ * // Get dark theme
549
+ * const darkTheme = getDefaultColorTheme({ isDarkMode: true })
550
+ *
551
+ * // Use with editor
552
+ * const theme = getDefaultColorTheme({ isDarkMode: window.matchMedia('(prefers-color-scheme: dark)').matches })
553
+ * ```
554
+ *
555
+ * @public
556
+ */
460
557
  export function getDefaultColorTheme(opts: { isDarkMode: boolean }): TLDefaultColorTheme {
461
558
  return opts.isDarkMode ? DefaultColorThemePalette.darkMode : DefaultColorThemePalette.lightMode
462
559
  }
463
560
 
464
- /** @public */
561
+ /**
562
+ * Default color style property used by tldraw shapes for their primary color.
563
+ * This style prop allows shapes to use any of the default color names and
564
+ * automatically saves the last used value for new shapes.
565
+ *
566
+ * @example
567
+ * ```ts
568
+ * import { DefaultColorStyle } from '@tldraw/tlschema'
569
+ *
570
+ * // Use in shape props definition
571
+ * interface MyShapeProps {
572
+ * color: typeof DefaultColorStyle
573
+ * // other props...
574
+ * }
575
+ *
576
+ * // Set color on a shape
577
+ * const shape = {
578
+ * // ... other properties
579
+ * props: {
580
+ * color: 'red' as const,
581
+ * // ... other props
582
+ * }
583
+ * }
584
+ * ```
585
+ *
586
+ * @public
587
+ */
465
588
  export const DefaultColorStyle = StyleProp.defineEnum('tldraw:color', {
466
589
  defaultValue: 'black',
467
590
  values: defaultColorNames,
468
591
  })
469
592
 
470
- /** @public */
593
+ /**
594
+ * Default label color style property used for text labels on shapes.
595
+ * This is separate from the main color style to allow different colors
596
+ * for shape fills/strokes versus their text labels.
597
+ *
598
+ * @example
599
+ * ```ts
600
+ * import { DefaultLabelColorStyle } from '@tldraw/tlschema'
601
+ *
602
+ * // Use in shape props definition
603
+ * interface MyShapeProps {
604
+ * labelColor: typeof DefaultLabelColorStyle
605
+ * // other props...
606
+ * }
607
+ *
608
+ * // Create a shape with different fill and label colors
609
+ * const shape = {
610
+ * // ... other properties
611
+ * props: {
612
+ * color: 'blue' as const,
613
+ * labelColor: 'white' as const,
614
+ * // ... other props
615
+ * }
616
+ * }
617
+ * ```
618
+ *
619
+ * @public
620
+ */
471
621
  export const DefaultLabelColorStyle = StyleProp.defineEnum('tldraw:labelColor', {
472
622
  defaultValue: 'black',
473
623
  values: defaultColorNames,
474
624
  })
475
625
 
476
- /** @public */
626
+ /**
627
+ * Type representing a default color style value.
628
+ * This is a union type of all available default color names.
629
+ *
630
+ * @example
631
+ * ```ts
632
+ * import { TLDefaultColorStyle } from '@tldraw/tlschema'
633
+ *
634
+ * // Valid color values
635
+ * const redColor: TLDefaultColorStyle = 'red'
636
+ * const blueColor: TLDefaultColorStyle = 'blue'
637
+ *
638
+ * // Type guard usage
639
+ * function isValidColor(color: string): color is TLDefaultColorStyle {
640
+ * return ['black', 'red', 'blue'].includes(color as TLDefaultColorStyle)
641
+ * }
642
+ * ```
643
+ *
644
+ * @public
645
+ */
477
646
  export type TLDefaultColorStyle = T.TypeOf<typeof DefaultColorStyle>
478
647
 
479
648
  const defaultColorNamesSet = new Set(defaultColorNames)
480
649
 
481
- /** @public */
650
+ /**
651
+ * Type guard to check if a color value is one of the default theme colors.
652
+ * Useful for determining if a color can be looked up in the theme palette.
653
+ *
654
+ * @param color - The color value to check
655
+ * @returns True if the color is a default theme color, false otherwise
656
+ *
657
+ * @example
658
+ * ```ts
659
+ * import { isDefaultThemeColor, TLDefaultColorStyle } from '@tldraw/tlschema'
660
+ *
661
+ * const color: TLDefaultColorStyle = 'red'
662
+ *
663
+ * if (isDefaultThemeColor(color)) {
664
+ * // color is guaranteed to be a default theme color
665
+ * console.log(`${color} is a default theme color`)
666
+ * } else {
667
+ * // color might be a custom hex value or other format
668
+ * console.log(`${color} is a custom color`)
669
+ * }
670
+ * ```
671
+ *
672
+ * @public
673
+ */
482
674
  export function isDefaultThemeColor(
483
675
  color: TLDefaultColorStyle
484
676
  ): color is (typeof defaultColorNames)[number] {
485
677
  return defaultColorNamesSet.has(color as (typeof defaultColorNames)[number])
486
678
  }
487
679
 
488
- /** @public */
680
+ /**
681
+ * Resolves a color style value to its actual CSS color string for a given theme and variant.
682
+ * If the color is not a default theme color, returns the color value as-is.
683
+ *
684
+ * @param theme - The color theme to use for resolution
685
+ * @param color - The color style value to resolve
686
+ * @param variant - Which variant of the color to return (solid, fill, pattern, etc.)
687
+ * @returns The CSS color string for the specified color and variant
688
+ *
689
+ * @example
690
+ * ```ts
691
+ * import { getColorValue, getDefaultColorTheme } from '@tldraw/tlschema'
692
+ *
693
+ * const theme = getDefaultColorTheme({ isDarkMode: false })
694
+ *
695
+ * // Get the solid variant of red
696
+ * const redSolid = getColorValue(theme, 'red', 'solid') // '#e03131'
697
+ *
698
+ * // Get the fill variant of blue
699
+ * const blueFill = getColorValue(theme, 'blue', 'fill') // '#4465e9'
700
+ *
701
+ * // Custom color passes through unchanged
702
+ * const customColor = getColorValue(theme, '#ff0000', 'solid') // '#ff0000'
703
+ * ```
704
+ *
705
+ * @public
706
+ */
489
707
  export function getColorValue(
490
708
  theme: TLDefaultColorTheme,
491
709
  color: TLDefaultColorStyle,
@@ -1,11 +1,63 @@
1
1
  import { T } from '@tldraw/validate'
2
2
  import { StyleProp } from './StyleProp'
3
3
 
4
- /** @public */
4
+ /**
5
+ * Default dash style property used by tldraw shapes for line styling.
6
+ * Controls how shape outlines and lines are rendered with different dash patterns.
7
+ *
8
+ * Available values:
9
+ * - `draw` - Hand-drawn, sketchy line style
10
+ * - `solid` - Continuous solid line
11
+ * - `dashed` - Evenly spaced dashes
12
+ * - `dotted` - Evenly spaced dots
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { DefaultDashStyle } from '@tldraw/tlschema'
17
+ *
18
+ * // Use in shape props definition
19
+ * interface MyShapeProps {
20
+ * dash: typeof DefaultDashStyle
21
+ * // other props...
22
+ * }
23
+ *
24
+ * // Create a shape with dashed outline
25
+ * const shape = {
26
+ * // ... other properties
27
+ * props: {
28
+ * dash: 'dashed' as const,
29
+ * // ... other props
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @public
35
+ */
5
36
  export const DefaultDashStyle = StyleProp.defineEnum('tldraw:dash', {
6
37
  defaultValue: 'draw',
7
38
  values: ['draw', 'solid', 'dashed', 'dotted'],
8
39
  })
9
40
 
10
- /** @public */
41
+ /**
42
+ * Type representing a default dash style value.
43
+ * This is a union type of all available dash style options.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { TLDefaultDashStyle } from '@tldraw/tlschema'
48
+ *
49
+ * // Valid dash style values
50
+ * const drawStyle: TLDefaultDashStyle = 'draw'
51
+ * const solidStyle: TLDefaultDashStyle = 'solid'
52
+ * const dashedStyle: TLDefaultDashStyle = 'dashed'
53
+ * const dottedStyle: TLDefaultDashStyle = 'dotted'
54
+ *
55
+ * // Use in a function parameter
56
+ * function setShapeDash(dash: TLDefaultDashStyle) {
57
+ * // Apply dash style to shape
58
+ * }
59
+ * ```
60
+ *
61
+ * @public
62
+ */
11
63
  export type TLDefaultDashStyle = T.TypeOf<typeof DefaultDashStyle>
@@ -1,11 +1,63 @@
1
1
  import { T } from '@tldraw/validate'
2
2
  import { StyleProp } from './StyleProp'
3
3
 
4
- /** @public */
4
+ /**
5
+ * Default fill style property used by tldraw shapes for interior styling.
6
+ * Controls how the inside of shapes are filled or left empty.
7
+ *
8
+ * Available values:
9
+ * - `none` - No fill, shape interior is transparent
10
+ * - `semi` - Semi-transparent fill using the shape's color
11
+ * - `solid` - Solid fill using the shape's color
12
+ * - `pattern` - Crosshatch pattern fill using the shape's color
13
+ * - `fill` - Alternative solid fill variant
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { DefaultFillStyle } from '@tldraw/tlschema'
18
+ *
19
+ * // Use in shape props definition
20
+ * interface MyShapeProps {
21
+ * fill: typeof DefaultFillStyle
22
+ * // other props...
23
+ * }
24
+ *
25
+ * // Create a shape with solid fill
26
+ * const shape = {
27
+ * // ... other properties
28
+ * props: {
29
+ * fill: 'solid' as const,
30
+ * // ... other props
31
+ * }
32
+ * }
33
+ * ```
34
+ *
35
+ * @public
36
+ */
5
37
  export const DefaultFillStyle = StyleProp.defineEnum('tldraw:fill', {
6
38
  defaultValue: 'none',
7
39
  values: ['none', 'semi', 'solid', 'pattern', 'fill'],
8
40
  })
9
41
 
10
- /** @public */
42
+ /**
43
+ * Type representing a default fill style value.
44
+ * This is a union type of all available fill style options.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { TLDefaultFillStyle } from '@tldraw/tlschema'
49
+ *
50
+ * // Valid fill style values
51
+ * const noFill: TLDefaultFillStyle = 'none'
52
+ * const solidFill: TLDefaultFillStyle = 'solid'
53
+ * const patternFill: TLDefaultFillStyle = 'pattern'
54
+ *
55
+ * // Use in a function parameter
56
+ * function setShapeFill(fill: TLDefaultFillStyle) {
57
+ * // Apply fill style to shape
58
+ * }
59
+ * ```
60
+ *
61
+ * @public
62
+ */
11
63
  export type TLDefaultFillStyle = T.TypeOf<typeof DefaultFillStyle>
@@ -1,16 +1,85 @@
1
1
  import { T } from '@tldraw/validate'
2
2
  import { StyleProp } from './StyleProp'
3
3
 
4
- /** @public */
4
+ /**
5
+ * Default font style property used by tldraw shapes for text styling.
6
+ * Controls which typeface is used for text content within shapes.
7
+ *
8
+ * Available values:
9
+ * - `draw` - Hand-drawn, sketchy font style
10
+ * - `sans` - Clean sans-serif font
11
+ * - `serif` - Traditional serif font
12
+ * - `mono` - Monospace font for code-like text
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { DefaultFontStyle } from '@tldraw/tlschema'
17
+ *
18
+ * // Use in shape props definition
19
+ * interface MyTextShapeProps {
20
+ * font: typeof DefaultFontStyle
21
+ * // other props...
22
+ * }
23
+ *
24
+ * // Create a text shape with monospace font
25
+ * const textShape = {
26
+ * // ... other properties
27
+ * props: {
28
+ * font: 'mono' as const,
29
+ * // ... other props
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @public
35
+ */
5
36
  export const DefaultFontStyle = StyleProp.defineEnum('tldraw:font', {
6
37
  defaultValue: 'draw',
7
38
  values: ['draw', 'sans', 'serif', 'mono'],
8
39
  })
9
40
 
10
- /** @public */
41
+ /**
42
+ * Type representing a default font style value.
43
+ * This is a union type of all available font style options.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { TLDefaultFontStyle } from '@tldraw/tlschema'
48
+ *
49
+ * // Valid font style values
50
+ * const drawFont: TLDefaultFontStyle = 'draw'
51
+ * const sansFont: TLDefaultFontStyle = 'sans'
52
+ * const serifFont: TLDefaultFontStyle = 'serif'
53
+ * const monoFont: TLDefaultFontStyle = 'mono'
54
+ *
55
+ * // Use in a function parameter
56
+ * function setTextFont(font: TLDefaultFontStyle) {
57
+ * // Apply font style to text
58
+ * }
59
+ * ```
60
+ *
61
+ * @public
62
+ */
11
63
  export type TLDefaultFontStyle = T.TypeOf<typeof DefaultFontStyle>
12
64
 
13
- /** @public */
65
+ /**
66
+ * Mapping of font style names to their corresponding CSS font-family declarations.
67
+ * These are the actual CSS font families used when rendering text with each font style.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { DefaultFontFamilies, TLDefaultFontStyle } from '@tldraw/tlschema'
72
+ *
73
+ * // Get CSS font family for a font style
74
+ * const fontStyle: TLDefaultFontStyle = 'mono'
75
+ * const cssFamily = DefaultFontFamilies[fontStyle] // "'tldraw_mono', monospace"
76
+ *
77
+ * // Apply to DOM element
78
+ * element.style.fontFamily = DefaultFontFamilies.sans
79
+ * ```
80
+ *
81
+ * @public
82
+ */
14
83
  export const DefaultFontFamilies = {
15
84
  draw: "'tldraw_draw', sans-serif",
16
85
  sans: "'tldraw_sans', sans-serif",
@@ -1,11 +1,64 @@
1
1
  import { T } from '@tldraw/validate'
2
2
  import { StyleProp } from './StyleProp'
3
3
 
4
- /** @public */
4
+ /**
5
+ * Default horizontal alignment style property used by tldraw shapes for text positioning.
6
+ * Controls how text content is horizontally aligned within shape boundaries.
7
+ *
8
+ * Available values:
9
+ * - `start` - Align text to the start (left in LTR, right in RTL)
10
+ * - `middle` - Center text horizontally
11
+ * - `end` - Align text to the end (right in LTR, left in RTL)
12
+ * - `start-legacy` - Legacy start alignment (deprecated)
13
+ * - `end-legacy` - Legacy end alignment (deprecated)
14
+ * - `middle-legacy` - Legacy middle alignment (deprecated)
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { DefaultHorizontalAlignStyle } from '@tldraw/tlschema'
19
+ *
20
+ * // Use in shape props definition
21
+ * interface MyTextShapeProps {
22
+ * align: typeof DefaultHorizontalAlignStyle
23
+ * // other props...
24
+ * }
25
+ *
26
+ * // Create a shape with center-aligned text
27
+ * const textShape = {
28
+ * // ... other properties
29
+ * props: {
30
+ * align: 'middle' as const,
31
+ * // ... other props
32
+ * }
33
+ * }
34
+ * ```
35
+ *
36
+ * @public
37
+ */
5
38
  export const DefaultHorizontalAlignStyle = StyleProp.defineEnum('tldraw:horizontalAlign', {
6
39
  defaultValue: 'middle',
7
40
  values: ['start', 'middle', 'end', 'start-legacy', 'end-legacy', 'middle-legacy'],
8
41
  })
9
42
 
10
- /** @public */
43
+ /**
44
+ * Type representing a default horizontal alignment style value.
45
+ * This is a union type of all available horizontal alignment options.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { TLDefaultHorizontalAlignStyle } from '@tldraw/tlschema'
50
+ *
51
+ * // Valid horizontal alignment values
52
+ * const leftAlign: TLDefaultHorizontalAlignStyle = 'start'
53
+ * const centerAlign: TLDefaultHorizontalAlignStyle = 'middle'
54
+ * const rightAlign: TLDefaultHorizontalAlignStyle = 'end'
55
+ *
56
+ * // Use in a function parameter
57
+ * function setTextAlignment(align: TLDefaultHorizontalAlignStyle) {
58
+ * // Apply horizontal alignment to text
59
+ * }
60
+ * ```
61
+ *
62
+ * @public
63
+ */
11
64
  export type TLDefaultHorizontalAlignStyle = T.TypeOf<typeof DefaultHorizontalAlignStyle>
@@ -1,11 +1,63 @@
1
1
  import { T } from '@tldraw/validate'
2
2
  import { StyleProp } from './StyleProp'
3
3
 
4
- /** @public */
4
+ /**
5
+ * Default size style property used by tldraw shapes for scaling visual elements.
6
+ * Controls the relative size of shape elements like stroke width, text size, and other proportional features.
7
+ *
8
+ * Available values:
9
+ * - `s` - Small size
10
+ * - `m` - Medium size (default)
11
+ * - `l` - Large size
12
+ * - `xl` - Extra large size
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { DefaultSizeStyle } from '@tldraw/tlschema'
17
+ *
18
+ * // Use in shape props definition
19
+ * interface MyShapeProps {
20
+ * size: typeof DefaultSizeStyle
21
+ * // other props...
22
+ * }
23
+ *
24
+ * // Create a shape with large size
25
+ * const shape = {
26
+ * // ... other properties
27
+ * props: {
28
+ * size: 'l' as const,
29
+ * // ... other props
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @public
35
+ */
5
36
  export const DefaultSizeStyle = StyleProp.defineEnum('tldraw:size', {
6
37
  defaultValue: 'm',
7
38
  values: ['s', 'm', 'l', 'xl'],
8
39
  })
9
40
 
10
- /** @public */
41
+ /**
42
+ * Type representing a default size style value.
43
+ * This is a union type of all available size options.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { TLDefaultSizeStyle } from '@tldraw/tlschema'
48
+ *
49
+ * // Valid size values
50
+ * const smallSize: TLDefaultSizeStyle = 's'
51
+ * const mediumSize: TLDefaultSizeStyle = 'm'
52
+ * const largeSize: TLDefaultSizeStyle = 'l'
53
+ * const extraLargeSize: TLDefaultSizeStyle = 'xl'
54
+ *
55
+ * // Use in a function parameter
56
+ * function setShapeSize(size: TLDefaultSizeStyle) {
57
+ * // Apply size style to shape
58
+ * }
59
+ * ```
60
+ *
61
+ * @public
62
+ */
11
63
  export type TLDefaultSizeStyle = T.TypeOf<typeof DefaultSizeStyle>