@tldraw/tlschema 4.1.0-next.542f014c3fac → 4.1.0-next.9f145d10c7d0
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/TLStore.js +3 -10
- package/dist-cjs/TLStore.js.map +2 -2
- package/dist-cjs/assets/TLBaseAsset.js.map +2 -2
- package/dist-cjs/assets/TLBookmarkAsset.js.map +2 -2
- package/dist-cjs/assets/TLImageAsset.js.map +2 -2
- package/dist-cjs/assets/TLVideoAsset.js.map +2 -2
- package/dist-cjs/bindings/TLArrowBinding.js.map +2 -2
- package/dist-cjs/bindings/TLBaseBinding.js.map +2 -2
- package/dist-cjs/createPresenceStateDerivation.js.map +2 -2
- package/dist-cjs/createTLSchema.js.map +2 -2
- package/dist-cjs/index.d.ts +4416 -223
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/misc/TLColor.js.map +2 -2
- package/dist-cjs/misc/TLCursor.js.map +2 -2
- package/dist-cjs/misc/TLHandle.js.map +2 -2
- package/dist-cjs/misc/TLOpacity.js.map +2 -2
- package/dist-cjs/misc/TLRichText.js.map +2 -2
- package/dist-cjs/misc/TLScribble.js.map +2 -2
- package/dist-cjs/misc/geometry-types.js.map +2 -2
- package/dist-cjs/misc/id-validator.js.map +2 -2
- package/dist-cjs/records/TLAsset.js.map +2 -2
- package/dist-cjs/records/TLBinding.js.map +2 -2
- package/dist-cjs/records/TLCamera.js.map +2 -2
- package/dist-cjs/records/TLDocument.js.map +2 -2
- package/dist-cjs/records/TLInstance.js.map +2 -2
- package/dist-cjs/records/TLPage.js.map +2 -2
- package/dist-cjs/records/TLPageState.js.map +2 -2
- package/dist-cjs/records/TLPointer.js.map +2 -2
- package/dist-cjs/records/TLPresence.js.map +2 -2
- package/dist-cjs/records/TLRecord.js.map +1 -1
- package/dist-cjs/records/TLShape.js.map +2 -2
- package/dist-cjs/recordsWithProps.js.map +2 -2
- package/dist-cjs/shapes/ShapeWithCrop.js.map +1 -1
- package/dist-cjs/shapes/TLArrowShape.js.map +2 -2
- package/dist-cjs/shapes/TLBaseShape.js.map +2 -2
- package/dist-cjs/shapes/TLBookmarkShape.js.map +2 -2
- package/dist-cjs/shapes/TLDrawShape.js.map +2 -2
- package/dist-cjs/shapes/TLEmbedShape.js.map +2 -2
- package/dist-cjs/shapes/TLFrameShape.js.map +2 -2
- package/dist-cjs/shapes/TLGeoShape.js.map +2 -2
- package/dist-cjs/shapes/TLGroupShape.js.map +2 -2
- package/dist-cjs/shapes/TLHighlightShape.js.map +2 -2
- package/dist-cjs/shapes/TLImageShape.js.map +2 -2
- package/dist-cjs/shapes/TLLineShape.js.map +2 -2
- package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
- package/dist-cjs/shapes/TLTextShape.js.map +2 -2
- package/dist-cjs/shapes/TLVideoShape.js.map +2 -2
- package/dist-cjs/store-migrations.js.map +2 -2
- package/dist-cjs/styles/TLColorStyle.js.map +2 -2
- package/dist-cjs/styles/TLDashStyle.js.map +2 -2
- package/dist-cjs/styles/TLFillStyle.js.map +2 -2
- package/dist-cjs/styles/TLFontStyle.js.map +2 -2
- package/dist-cjs/styles/TLHorizontalAlignStyle.js.map +2 -2
- package/dist-cjs/styles/TLSizeStyle.js.map +2 -2
- package/dist-cjs/styles/TLTextAlignStyle.js.map +2 -2
- package/dist-cjs/styles/TLVerticalAlignStyle.js.map +2 -2
- package/dist-cjs/translations/translations.js +1 -1
- package/dist-cjs/translations/translations.js.map +2 -2
- package/dist-cjs/util-types.js.map +1 -1
- package/dist-esm/TLStore.mjs +3 -10
- package/dist-esm/TLStore.mjs.map +2 -2
- package/dist-esm/assets/TLBaseAsset.mjs.map +2 -2
- package/dist-esm/assets/TLBookmarkAsset.mjs.map +2 -2
- package/dist-esm/assets/TLImageAsset.mjs.map +2 -2
- package/dist-esm/assets/TLVideoAsset.mjs.map +2 -2
- package/dist-esm/bindings/TLArrowBinding.mjs.map +2 -2
- package/dist-esm/bindings/TLBaseBinding.mjs.map +2 -2
- package/dist-esm/createPresenceStateDerivation.mjs.map +2 -2
- package/dist-esm/createTLSchema.mjs.map +2 -2
- package/dist-esm/index.d.mts +4416 -223
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/misc/TLColor.mjs.map +2 -2
- package/dist-esm/misc/TLCursor.mjs.map +2 -2
- package/dist-esm/misc/TLHandle.mjs.map +2 -2
- package/dist-esm/misc/TLOpacity.mjs.map +2 -2
- package/dist-esm/misc/TLRichText.mjs.map +2 -2
- package/dist-esm/misc/TLScribble.mjs.map +2 -2
- package/dist-esm/misc/geometry-types.mjs.map +2 -2
- package/dist-esm/misc/id-validator.mjs.map +2 -2
- package/dist-esm/records/TLAsset.mjs.map +2 -2
- package/dist-esm/records/TLBinding.mjs.map +2 -2
- package/dist-esm/records/TLCamera.mjs.map +2 -2
- package/dist-esm/records/TLDocument.mjs.map +2 -2
- package/dist-esm/records/TLInstance.mjs.map +2 -2
- package/dist-esm/records/TLPage.mjs.map +2 -2
- package/dist-esm/records/TLPageState.mjs.map +2 -2
- package/dist-esm/records/TLPointer.mjs.map +2 -2
- package/dist-esm/records/TLPresence.mjs.map +2 -2
- package/dist-esm/records/TLShape.mjs.map +2 -2
- package/dist-esm/recordsWithProps.mjs.map +2 -2
- package/dist-esm/shapes/TLArrowShape.mjs.map +2 -2
- package/dist-esm/shapes/TLBaseShape.mjs.map +2 -2
- package/dist-esm/shapes/TLBookmarkShape.mjs.map +2 -2
- package/dist-esm/shapes/TLDrawShape.mjs.map +2 -2
- package/dist-esm/shapes/TLEmbedShape.mjs.map +2 -2
- package/dist-esm/shapes/TLFrameShape.mjs.map +2 -2
- package/dist-esm/shapes/TLGeoShape.mjs.map +2 -2
- package/dist-esm/shapes/TLGroupShape.mjs.map +2 -2
- package/dist-esm/shapes/TLHighlightShape.mjs.map +2 -2
- package/dist-esm/shapes/TLImageShape.mjs.map +2 -2
- package/dist-esm/shapes/TLLineShape.mjs.map +2 -2
- package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
- package/dist-esm/shapes/TLTextShape.mjs.map +2 -2
- package/dist-esm/shapes/TLVideoShape.mjs.map +2 -2
- package/dist-esm/store-migrations.mjs.map +2 -2
- package/dist-esm/styles/TLColorStyle.mjs.map +2 -2
- package/dist-esm/styles/TLDashStyle.mjs.map +2 -2
- package/dist-esm/styles/TLFillStyle.mjs.map +2 -2
- package/dist-esm/styles/TLFontStyle.mjs.map +2 -2
- package/dist-esm/styles/TLHorizontalAlignStyle.mjs.map +2 -2
- package/dist-esm/styles/TLSizeStyle.mjs.map +2 -2
- package/dist-esm/styles/TLTextAlignStyle.mjs.map +2 -2
- package/dist-esm/styles/TLVerticalAlignStyle.mjs.map +2 -2
- package/dist-esm/translations/translations.mjs +1 -1
- package/dist-esm/translations/translations.mjs.map +2 -2
- package/package.json +5 -5
- package/src/TLStore.test.ts +644 -0
- package/src/TLStore.ts +205 -20
- package/src/assets/TLBaseAsset.ts +90 -7
- package/src/assets/TLBookmarkAsset.test.ts +96 -0
- package/src/assets/TLBookmarkAsset.ts +52 -2
- package/src/assets/TLImageAsset.test.ts +213 -0
- package/src/assets/TLImageAsset.ts +60 -2
- package/src/assets/TLVideoAsset.test.ts +105 -0
- package/src/assets/TLVideoAsset.ts +93 -4
- package/src/bindings/TLArrowBinding.test.ts +55 -0
- package/src/bindings/TLArrowBinding.ts +132 -10
- package/src/bindings/TLBaseBinding.ts +140 -3
- package/src/createPresenceStateDerivation.test.ts +158 -0
- package/src/createPresenceStateDerivation.ts +71 -2
- package/src/createTLSchema.test.ts +181 -0
- package/src/createTLSchema.ts +164 -7
- package/src/index.ts +32 -0
- package/src/misc/TLColor.ts +50 -6
- package/src/misc/TLCursor.ts +110 -8
- package/src/misc/TLHandle.ts +86 -6
- package/src/misc/TLOpacity.ts +51 -2
- package/src/misc/TLRichText.ts +56 -3
- package/src/misc/TLScribble.ts +105 -5
- package/src/misc/geometry-types.ts +30 -2
- package/src/misc/id-validator.test.ts +50 -0
- package/src/misc/id-validator.ts +20 -1
- package/src/records/TLAsset.test.ts +234 -0
- package/src/records/TLAsset.ts +165 -8
- package/src/records/TLBinding.test.ts +22 -0
- package/src/records/TLBinding.ts +277 -11
- package/src/records/TLCamera.test.ts +19 -0
- package/src/records/TLCamera.ts +118 -7
- package/src/records/TLDocument.test.ts +35 -0
- package/src/records/TLDocument.ts +148 -8
- package/src/records/TLInstance.test.ts +201 -0
- package/src/records/TLInstance.ts +117 -9
- package/src/records/TLPage.test.ts +110 -0
- package/src/records/TLPage.ts +106 -8
- package/src/records/TLPageState.test.ts +228 -0
- package/src/records/TLPageState.ts +88 -7
- package/src/records/TLPointer.test.ts +63 -0
- package/src/records/TLPointer.ts +105 -7
- package/src/records/TLPresence.test.ts +190 -0
- package/src/records/TLPresence.ts +99 -5
- package/src/records/TLRecord.test.ts +70 -0
- package/src/records/TLRecord.ts +43 -1
- package/src/records/TLShape.test.ts +232 -0
- package/src/records/TLShape.ts +289 -12
- package/src/recordsWithProps.test.ts +188 -0
- package/src/recordsWithProps.ts +131 -2
- package/src/shapes/ShapeWithCrop.test.ts +18 -0
- package/src/shapes/ShapeWithCrop.ts +64 -2
- package/src/shapes/TLArrowShape.test.ts +505 -0
- package/src/shapes/TLArrowShape.ts +188 -10
- package/src/shapes/TLBaseShape.test.ts +142 -0
- package/src/shapes/TLBaseShape.ts +103 -4
- package/src/shapes/TLBookmarkShape.test.ts +122 -0
- package/src/shapes/TLBookmarkShape.ts +58 -4
- package/src/shapes/TLDrawShape.test.ts +177 -0
- package/src/shapes/TLDrawShape.ts +97 -6
- package/src/shapes/TLEmbedShape.test.ts +286 -0
- package/src/shapes/TLEmbedShape.ts +57 -4
- package/src/shapes/TLFrameShape.test.ts +71 -0
- package/src/shapes/TLFrameShape.ts +59 -4
- package/src/shapes/TLGeoShape.test.ts +247 -0
- package/src/shapes/TLGeoShape.ts +103 -7
- package/src/shapes/TLGroupShape.test.ts +59 -0
- package/src/shapes/TLGroupShape.ts +52 -4
- package/src/shapes/TLHighlightShape.test.ts +325 -0
- package/src/shapes/TLHighlightShape.ts +79 -4
- package/src/shapes/TLImageShape.test.ts +534 -0
- package/src/shapes/TLImageShape.ts +105 -5
- package/src/shapes/TLLineShape.test.ts +269 -0
- package/src/shapes/TLLineShape.ts +128 -8
- package/src/shapes/TLNoteShape.test.ts +1568 -0
- package/src/shapes/TLNoteShape.ts +97 -4
- package/src/shapes/TLTextShape.test.ts +407 -0
- package/src/shapes/TLTextShape.ts +94 -4
- package/src/shapes/TLVideoShape.test.ts +112 -0
- package/src/shapes/TLVideoShape.ts +99 -4
- package/src/store-migrations.test.ts +88 -0
- package/src/store-migrations.ts +47 -1
- package/src/styles/TLColorStyle.test.ts +439 -0
- package/src/styles/TLColorStyle.ts +228 -10
- package/src/styles/TLDashStyle.ts +54 -2
- package/src/styles/TLFillStyle.ts +54 -2
- package/src/styles/TLFontStyle.ts +72 -3
- package/src/styles/TLHorizontalAlignStyle.ts +55 -2
- package/src/styles/TLSizeStyle.ts +54 -2
- package/src/styles/TLTextAlignStyle.ts +52 -2
- package/src/styles/TLVerticalAlignStyle.ts +52 -2
- package/src/translations/translations.test.ts +378 -35
- package/src/translations/translations.ts +157 -10
- 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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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>
|