@tldraw/tlschema 4.1.0-canary.9f9255bd7a83 → 4.1.0-canary.a6e63b3bbde6

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 (212) 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.map +2 -2
  40. package/dist-cjs/shapes/TLFrameShape.js.map +2 -2
  41. package/dist-cjs/shapes/TLGeoShape.js.map +2 -2
  42. package/dist-cjs/shapes/TLGroupShape.js.map +2 -2
  43. package/dist-cjs/shapes/TLHighlightShape.js.map +2 -2
  44. package/dist-cjs/shapes/TLImageShape.js.map +2 -2
  45. package/dist-cjs/shapes/TLLineShape.js.map +2 -2
  46. package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
  47. package/dist-cjs/shapes/TLTextShape.js.map +2 -2
  48. package/dist-cjs/shapes/TLVideoShape.js.map +2 -2
  49. package/dist-cjs/store-migrations.js.map +2 -2
  50. package/dist-cjs/styles/TLColorStyle.js.map +2 -2
  51. package/dist-cjs/styles/TLDashStyle.js.map +2 -2
  52. package/dist-cjs/styles/TLFillStyle.js.map +2 -2
  53. package/dist-cjs/styles/TLFontStyle.js.map +2 -2
  54. package/dist-cjs/styles/TLHorizontalAlignStyle.js.map +2 -2
  55. package/dist-cjs/styles/TLSizeStyle.js.map +2 -2
  56. package/dist-cjs/styles/TLTextAlignStyle.js.map +2 -2
  57. package/dist-cjs/styles/TLVerticalAlignStyle.js.map +2 -2
  58. package/dist-cjs/translations/translations.js +1 -1
  59. package/dist-cjs/translations/translations.js.map +2 -2
  60. package/dist-cjs/util-types.js.map +1 -1
  61. package/dist-esm/TLStore.mjs +3 -10
  62. package/dist-esm/TLStore.mjs.map +2 -2
  63. package/dist-esm/assets/TLBaseAsset.mjs.map +2 -2
  64. package/dist-esm/assets/TLBookmarkAsset.mjs.map +2 -2
  65. package/dist-esm/assets/TLImageAsset.mjs.map +2 -2
  66. package/dist-esm/assets/TLVideoAsset.mjs.map +2 -2
  67. package/dist-esm/bindings/TLArrowBinding.mjs.map +2 -2
  68. package/dist-esm/bindings/TLBaseBinding.mjs.map +2 -2
  69. package/dist-esm/createPresenceStateDerivation.mjs.map +2 -2
  70. package/dist-esm/createTLSchema.mjs.map +2 -2
  71. package/dist-esm/index.d.mts +4416 -223
  72. package/dist-esm/index.mjs +1 -1
  73. package/dist-esm/index.mjs.map +2 -2
  74. package/dist-esm/misc/TLColor.mjs.map +2 -2
  75. package/dist-esm/misc/TLCursor.mjs.map +2 -2
  76. package/dist-esm/misc/TLHandle.mjs.map +2 -2
  77. package/dist-esm/misc/TLOpacity.mjs.map +2 -2
  78. package/dist-esm/misc/TLRichText.mjs.map +2 -2
  79. package/dist-esm/misc/TLScribble.mjs.map +2 -2
  80. package/dist-esm/misc/geometry-types.mjs.map +2 -2
  81. package/dist-esm/misc/id-validator.mjs.map +2 -2
  82. package/dist-esm/records/TLAsset.mjs.map +2 -2
  83. package/dist-esm/records/TLBinding.mjs.map +2 -2
  84. package/dist-esm/records/TLCamera.mjs.map +2 -2
  85. package/dist-esm/records/TLDocument.mjs.map +2 -2
  86. package/dist-esm/records/TLInstance.mjs.map +2 -2
  87. package/dist-esm/records/TLPage.mjs.map +2 -2
  88. package/dist-esm/records/TLPageState.mjs.map +2 -2
  89. package/dist-esm/records/TLPointer.mjs.map +2 -2
  90. package/dist-esm/records/TLPresence.mjs.map +2 -2
  91. package/dist-esm/records/TLShape.mjs.map +2 -2
  92. package/dist-esm/recordsWithProps.mjs.map +2 -2
  93. package/dist-esm/shapes/TLArrowShape.mjs.map +2 -2
  94. package/dist-esm/shapes/TLBaseShape.mjs.map +2 -2
  95. package/dist-esm/shapes/TLBookmarkShape.mjs.map +2 -2
  96. package/dist-esm/shapes/TLDrawShape.mjs.map +2 -2
  97. package/dist-esm/shapes/TLEmbedShape.mjs.map +2 -2
  98. package/dist-esm/shapes/TLFrameShape.mjs.map +2 -2
  99. package/dist-esm/shapes/TLGeoShape.mjs.map +2 -2
  100. package/dist-esm/shapes/TLGroupShape.mjs.map +2 -2
  101. package/dist-esm/shapes/TLHighlightShape.mjs.map +2 -2
  102. package/dist-esm/shapes/TLImageShape.mjs.map +2 -2
  103. package/dist-esm/shapes/TLLineShape.mjs.map +2 -2
  104. package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
  105. package/dist-esm/shapes/TLTextShape.mjs.map +2 -2
  106. package/dist-esm/shapes/TLVideoShape.mjs.map +2 -2
  107. package/dist-esm/store-migrations.mjs.map +2 -2
  108. package/dist-esm/styles/TLColorStyle.mjs.map +2 -2
  109. package/dist-esm/styles/TLDashStyle.mjs.map +2 -2
  110. package/dist-esm/styles/TLFillStyle.mjs.map +2 -2
  111. package/dist-esm/styles/TLFontStyle.mjs.map +2 -2
  112. package/dist-esm/styles/TLHorizontalAlignStyle.mjs.map +2 -2
  113. package/dist-esm/styles/TLSizeStyle.mjs.map +2 -2
  114. package/dist-esm/styles/TLTextAlignStyle.mjs.map +2 -2
  115. package/dist-esm/styles/TLVerticalAlignStyle.mjs.map +2 -2
  116. package/dist-esm/translations/translations.mjs +1 -1
  117. package/dist-esm/translations/translations.mjs.map +2 -2
  118. package/package.json +5 -5
  119. package/src/TLStore.test.ts +644 -0
  120. package/src/TLStore.ts +205 -20
  121. package/src/assets/TLBaseAsset.ts +90 -7
  122. package/src/assets/TLBookmarkAsset.test.ts +96 -0
  123. package/src/assets/TLBookmarkAsset.ts +52 -2
  124. package/src/assets/TLImageAsset.test.ts +213 -0
  125. package/src/assets/TLImageAsset.ts +60 -2
  126. package/src/assets/TLVideoAsset.test.ts +105 -0
  127. package/src/assets/TLVideoAsset.ts +93 -4
  128. package/src/bindings/TLArrowBinding.test.ts +55 -0
  129. package/src/bindings/TLArrowBinding.ts +132 -10
  130. package/src/bindings/TLBaseBinding.ts +140 -3
  131. package/src/createPresenceStateDerivation.test.ts +158 -0
  132. package/src/createPresenceStateDerivation.ts +71 -2
  133. package/src/createTLSchema.test.ts +181 -0
  134. package/src/createTLSchema.ts +164 -7
  135. package/src/index.ts +32 -0
  136. package/src/misc/TLColor.ts +50 -6
  137. package/src/misc/TLCursor.ts +110 -8
  138. package/src/misc/TLHandle.ts +86 -6
  139. package/src/misc/TLOpacity.ts +51 -2
  140. package/src/misc/TLRichText.ts +56 -3
  141. package/src/misc/TLScribble.ts +105 -5
  142. package/src/misc/geometry-types.ts +30 -2
  143. package/src/misc/id-validator.test.ts +50 -0
  144. package/src/misc/id-validator.ts +20 -1
  145. package/src/records/TLAsset.test.ts +234 -0
  146. package/src/records/TLAsset.ts +165 -8
  147. package/src/records/TLBinding.test.ts +22 -0
  148. package/src/records/TLBinding.ts +277 -11
  149. package/src/records/TLCamera.test.ts +19 -0
  150. package/src/records/TLCamera.ts +118 -7
  151. package/src/records/TLDocument.test.ts +35 -0
  152. package/src/records/TLDocument.ts +148 -8
  153. package/src/records/TLInstance.test.ts +201 -0
  154. package/src/records/TLInstance.ts +117 -9
  155. package/src/records/TLPage.test.ts +110 -0
  156. package/src/records/TLPage.ts +106 -8
  157. package/src/records/TLPageState.test.ts +228 -0
  158. package/src/records/TLPageState.ts +88 -7
  159. package/src/records/TLPointer.test.ts +63 -0
  160. package/src/records/TLPointer.ts +105 -7
  161. package/src/records/TLPresence.test.ts +190 -0
  162. package/src/records/TLPresence.ts +99 -5
  163. package/src/records/TLRecord.test.ts +70 -0
  164. package/src/records/TLRecord.ts +43 -1
  165. package/src/records/TLShape.test.ts +232 -0
  166. package/src/records/TLShape.ts +289 -12
  167. package/src/recordsWithProps.test.ts +188 -0
  168. package/src/recordsWithProps.ts +131 -2
  169. package/src/shapes/ShapeWithCrop.test.ts +18 -0
  170. package/src/shapes/ShapeWithCrop.ts +64 -2
  171. package/src/shapes/TLArrowShape.test.ts +505 -0
  172. package/src/shapes/TLArrowShape.ts +188 -10
  173. package/src/shapes/TLBaseShape.test.ts +142 -0
  174. package/src/shapes/TLBaseShape.ts +103 -4
  175. package/src/shapes/TLBookmarkShape.test.ts +122 -0
  176. package/src/shapes/TLBookmarkShape.ts +58 -4
  177. package/src/shapes/TLDrawShape.test.ts +177 -0
  178. package/src/shapes/TLDrawShape.ts +97 -6
  179. package/src/shapes/TLEmbedShape.test.ts +286 -0
  180. package/src/shapes/TLEmbedShape.ts +57 -4
  181. package/src/shapes/TLFrameShape.test.ts +71 -0
  182. package/src/shapes/TLFrameShape.ts +59 -4
  183. package/src/shapes/TLGeoShape.test.ts +247 -0
  184. package/src/shapes/TLGeoShape.ts +103 -7
  185. package/src/shapes/TLGroupShape.test.ts +59 -0
  186. package/src/shapes/TLGroupShape.ts +52 -4
  187. package/src/shapes/TLHighlightShape.test.ts +325 -0
  188. package/src/shapes/TLHighlightShape.ts +79 -4
  189. package/src/shapes/TLImageShape.test.ts +534 -0
  190. package/src/shapes/TLImageShape.ts +105 -5
  191. package/src/shapes/TLLineShape.test.ts +269 -0
  192. package/src/shapes/TLLineShape.ts +128 -8
  193. package/src/shapes/TLNoteShape.test.ts +1568 -0
  194. package/src/shapes/TLNoteShape.ts +97 -4
  195. package/src/shapes/TLTextShape.test.ts +407 -0
  196. package/src/shapes/TLTextShape.ts +94 -4
  197. package/src/shapes/TLVideoShape.test.ts +112 -0
  198. package/src/shapes/TLVideoShape.ts +99 -4
  199. package/src/store-migrations.test.ts +88 -0
  200. package/src/store-migrations.ts +47 -1
  201. package/src/styles/TLColorStyle.test.ts +439 -0
  202. package/src/styles/TLColorStyle.ts +228 -10
  203. package/src/styles/TLDashStyle.ts +54 -2
  204. package/src/styles/TLFillStyle.ts +54 -2
  205. package/src/styles/TLFontStyle.ts +72 -3
  206. package/src/styles/TLHorizontalAlignStyle.ts +55 -2
  207. package/src/styles/TLSizeStyle.ts +54 -2
  208. package/src/styles/TLTextAlignStyle.ts +52 -2
  209. package/src/styles/TLVerticalAlignStyle.ts +52 -2
  210. package/src/translations/translations.test.ts +378 -35
  211. package/src/translations/translations.ts +157 -10
  212. package/src/util-types.ts +51 -1
@@ -3,20 +3,102 @@ import { LANGUAGES } from './languages'
3
3
  /** @public */
4
4
  export { LANGUAGES }
5
5
 
6
- /** @public */
6
+ /**
7
+ * A language definition object representing a supported localization in tldraw.
8
+ *
9
+ * Derived from the LANGUAGES array, this type represents a single language entry
10
+ * containing a locale identifier and human-readable label. The locale follows
11
+ * BCP 47 standards (e.g., 'en', 'fr', 'zh-CN') and the label is in the native language.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { TLLanguage } from '@tldraw/tlschema'
16
+ *
17
+ * // Using TLLanguage type
18
+ * const currentLanguage: TLLanguage = { locale: 'fr', label: 'Français' }
19
+ *
20
+ * // Access locale and label
21
+ * console.log(currentLanguage.locale) // "fr"
22
+ * console.log(currentLanguage.label) // "Français"
23
+ * ```
24
+ *
25
+ * @public
26
+ */
7
27
  export type TLLanguage = (typeof LANGUAGES)[number]
8
- // {
9
- // readonly locale: string
10
- // readonly label: string
11
- // }
12
28
 
13
- /** @public */
29
+ /**
30
+ * Gets the default translation locale based on the user's browser language preferences.
31
+ *
32
+ * This function determines the best matching locale from the user's browser language
33
+ * settings, falling back to English if no suitable match is found. It works in both
34
+ * browser and server-side environments, defaulting to English on the server.
35
+ *
36
+ * The function prioritizes exact matches first, then falls back to language-only
37
+ * matches, and finally uses predefined regional defaults for languages like Chinese,
38
+ * Portuguese, Korean, and Hindi.
39
+ *
40
+ * @returns The locale identifier (e.g., 'en', 'fr', 'zh-cn') that best matches the user's preferences
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { getDefaultTranslationLocale } from '@tldraw/tlschema'
45
+ *
46
+ * // Get the user's preferred locale
47
+ * const locale = getDefaultTranslationLocale()
48
+ * console.log(locale) // e.g., "fr" or "en" or "zh-cn"
49
+ *
50
+ * // Use in localization setup
51
+ * const i18n = new I18n({
52
+ * locale,
53
+ * // ... other config
54
+ * })
55
+ * ```
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * // Browser with languages: ['fr-CA', 'en-US']
60
+ * const locale = getDefaultTranslationLocale()
61
+ * console.log(locale) // "fr" (if French is supported)
62
+ *
63
+ * // Browser with languages: ['zh']
64
+ * const locale = getDefaultTranslationLocale()
65
+ * console.log(locale) // "zh-cn" (default region for Chinese)
66
+ * ```
67
+ *
68
+ * @public
69
+ */
14
70
  export function getDefaultTranslationLocale(): TLLanguage['locale'] {
15
- const locales = typeof window !== 'undefined' ? (window.navigator.languages ?? ['en']) : ['en']
71
+ const locales =
72
+ typeof window !== 'undefined' && window.navigator
73
+ ? (window.navigator.languages ?? ['en'])
74
+ : ['en']
16
75
  return _getDefaultTranslationLocale(locales)
17
76
  }
18
77
 
19
- /** @internal */
78
+ /**
79
+ * Internal function that determines the default translation locale from a list of locale preferences.
80
+ *
81
+ * This function is the core logic for locale resolution, separated from browser-specific code
82
+ * for easier testing and reuse. It iterates through the provided locales in priority order
83
+ * and returns the first supported locale found, or 'en' as the ultimate fallback.
84
+ *
85
+ * @param locales - Array of locale identifiers in preference order (e.g., from navigator.languages)
86
+ * @returns The best matching supported locale identifier
87
+ *
88
+ * @example
89
+ * ```ts
90
+ *
91
+ * // Test locale resolution
92
+ * const locale = _getDefaultTranslationLocale(['fr-CA', 'en-US', 'es'])
93
+ * console.log(locale) // "fr" (if French is supported)
94
+ *
95
+ * // No supported locales
96
+ * const fallback = _getDefaultTranslationLocale(['xx-YY', 'zz-AA'])
97
+ * console.log(fallback) // "en"
98
+ * ```
99
+ *
100
+ * @internal
101
+ */
20
102
  export function _getDefaultTranslationLocale(locales: readonly string[]): TLLanguage['locale'] {
21
103
  for (const locale of locales) {
22
104
  const supportedLocale = getSupportedLocale(locale)
@@ -27,7 +109,28 @@ export function _getDefaultTranslationLocale(locales: readonly string[]): TLLang
27
109
  return 'en'
28
110
  }
29
111
 
30
- /** @public */
112
+ /**
113
+ * Default regional variants for languages that have multiple regional versions.
114
+ *
115
+ * When a user's locale contains only a language code (e.g., 'zh', 'pt') but tldraw
116
+ * only supports region-specific variants, this mapping determines which regional
117
+ * variant to use as the default. This ensures users get the most appropriate
118
+ * localization even when their preference doesn't specify a region.
119
+ *
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * // User has locale preference "zh" but we only support "zh-cn" and "zh-tw"
124
+ * const defaultRegion = DEFAULT_LOCALE_REGIONS['zh']
125
+ * console.log(defaultRegion) // "zh-cn"
126
+ *
127
+ * // User has locale preference "pt" but we support "pt-br" and "pt-pt"
128
+ * const defaultRegion = DEFAULT_LOCALE_REGIONS['pt']
129
+ * console.log(defaultRegion) // "pt-br"
130
+ * ```
131
+ *
132
+ * @public
133
+ */
31
134
  const DEFAULT_LOCALE_REGIONS: { [locale: string]: TLLanguage['locale'] } = {
32
135
  zh: 'zh-cn',
33
136
  pt: 'pt-br',
@@ -35,7 +138,51 @@ const DEFAULT_LOCALE_REGIONS: { [locale: string]: TLLanguage['locale'] } = {
35
138
  hi: 'hi-in',
36
139
  }
37
140
 
38
- /** @public */
141
+ /**
142
+ * Finds a supported locale that matches the given locale identifier.
143
+ *
144
+ * This function implements a flexible locale matching algorithm that tries multiple
145
+ * strategies to find the best available translation:
146
+ *
147
+ * 1. **Exact match**: Looks for an exact locale match (case-insensitive)
148
+ * 2. **Language-only match**: If the input has a region, tries matching just the language
149
+ * 3. **Default region**: If the input lacks a region, uses the default region for that language
150
+ * 4. **No match**: Returns null if no suitable locale is found
151
+ *
152
+ * @param locale - The locale identifier to match (e.g., 'fr-CA', 'pt', 'zh-TW')
153
+ * @returns The matching supported locale identifier, or null if no match is found
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * // Exact matches
158
+ * getSupportedLocale('fr') // "fr" (if supported)
159
+ * getSupportedLocale('PT-BR') // "pt-br" (case insensitive)
160
+ *
161
+ * // Language-only fallback
162
+ * getSupportedLocale('fr-CA') // "fr" (if we only support generic French)
163
+ *
164
+ * // Default region assignment
165
+ * getSupportedLocale('zh') // "zh-cn" (default Chinese region)
166
+ *
167
+ * // No match
168
+ * getSupportedLocale('xyz') // null
169
+ * ```
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * // Usage in locale resolution
174
+ * const userLocales = ['es-MX', 'en-US']
175
+ * for (const userLocale of userLocales) {
176
+ * const supported = getSupportedLocale(userLocale)
177
+ * if (supported) {
178
+ * console.log(`Using locale: ${supported}`)
179
+ * break
180
+ * }
181
+ * }
182
+ * ```
183
+ *
184
+ * @public
185
+ */
39
186
  function getSupportedLocale(locale: string): TLLanguage['locale'] | null {
40
187
  // If we have an exact match, return it!
41
188
  // (e.g. if the user has 'fr' and we have 'fr')
package/src/util-types.ts CHANGED
@@ -1,2 +1,52 @@
1
- /** @public */
1
+ /**
2
+ * Utility type that extracts the value type from a Set type.
3
+ *
4
+ * This helper type uses conditional type inference to extract the element type
5
+ * from a Set. It's useful when working with sets in type definitions where you
6
+ * need to reference the type of elements contained within the set.
7
+ *
8
+ * The type uses TypeScript's `infer` keyword to capture the generic parameter
9
+ * of the Set type, making it reusable across different Set types.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { SetValue } from '@tldraw/tlschema'
14
+ *
15
+ * // Extract value type from a Set type
16
+ * type StringSet = Set<string>
17
+ * type StringValue = SetValue<StringSet> // string
18
+ *
19
+ * type NumberSet = Set<number>
20
+ * type NumberValue = SetValue<NumberSet> // number
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // Usage with const sets
26
+ * const COLORS = new Set(['red', 'green', 'blue'] as const)
27
+ * type ColorSet = typeof COLORS
28
+ * type Color = SetValue<ColorSet> // 'red' | 'green' | 'blue'
29
+ *
30
+ * // Function that accepts set values
31
+ * function processColor(color: SetValue<typeof COLORS>) {
32
+ * // color is typed as 'red' | 'green' | 'blue'
33
+ * console.log(`Processing color: ${color}`)
34
+ * }
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // Complex usage with union types
40
+ * const UI_COLORS = new Set(['selection-stroke', 'accent', 'muted'])
41
+ * type UIColorSet = typeof UI_COLORS
42
+ * type UIColor = SetValue<UIColorSet> // 'selection-stroke' | 'accent' | 'muted'
43
+ *
44
+ * // Validate color is in set
45
+ * function isValidUIColor(color: string): color is UIColor {
46
+ * return UI_COLORS.has(color)
47
+ * }
48
+ * ```
49
+ *
50
+ * @public
51
+ */
2
52
  export type SetValue<T extends Set<any>> = T extends Set<infer U> ? U : never