@sanity/ui 2.0.0-alpha.35 → 2.0.0-alpha.37

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/theme.d.ts CHANGED
@@ -8,42 +8,64 @@ import type {StyledObject} from 'styled-components'
8
8
  */
9
9
  export declare interface BaseTheme {
10
10
  _version?: 0
11
+ /**
12
+ * @deprecated Use `v2.avatar` instead
13
+ */
11
14
  avatar: ThemeAvatar
15
+ /**
16
+ * @deprecated Use `v2.button` instead
17
+ */
12
18
  button: {
13
- border: {
14
- width: number
15
- }
16
- focusRing: ThemeFocusRing
17
19
  textWeight: ThemeFontWeightKey
18
20
  }
19
- card: {
20
- border: {
21
- width: number
22
- }
23
- focusRing: ThemeFocusRing
24
- shadow: {
25
- outline: number
26
- }
27
- }
21
+ /**
22
+ * @deprecated Use `v2.color` instead
23
+ */
28
24
  color: ThemeColorSchemes
25
+ /**
26
+ * @deprecated Use `v2.container` instead
27
+ */
29
28
  container: number[]
30
- /** @deprecated Use component-specific `focusRing` values instead */
29
+ /**
30
+ * @deprecated Use component-specific `v2.{button | card | input}.focusRing` values instead
31
+ */
31
32
  focusRing: {
32
33
  offset: number
33
34
  width: number
34
35
  }
36
+ /**
37
+ * @deprecated Use `v2.font` instead
38
+ */
35
39
  fonts: ThemeFonts
40
+ /**
41
+ * @deprecated Use `v2.input` instead
42
+ */
36
43
  input: ThemeInput
37
44
  /**
38
45
  * THIS API MAY BE UNSTABLE. DO NOT USE IN PRODUCTION.
39
46
  * @beta
47
+ * @deprecated Use `v2.layer` instead
40
48
  */
41
49
  layer?: ThemeLayer
50
+ /**
51
+ * @deprecated Use `v2.media` instead
52
+ */
42
53
  media: number[]
54
+ /**
55
+ * @deprecated Use `v2.radius` instead
56
+ */
43
57
  radius: number[]
58
+ /**
59
+ * @deprecated Use `v2.shadow` instead
60
+ */
44
61
  shadows: Array<ThemeShadow | null>
62
+ /**
63
+ * @deprecated Use `v2.space` instead
64
+ */
45
65
  space: number[]
46
- /** @internal */
66
+ /**
67
+ * @deprecated Use `v2.style` instead
68
+ */
47
69
  styles?: ThemeStyles
48
70
  v2?: RootTheme_v2
49
71
  }
@@ -370,7 +392,7 @@ export declare type RootTheme = BaseTheme
370
392
  */
371
393
  export declare interface RootTheme_v2 {
372
394
  _version: 2
373
- avatar: ThemeAvatar
395
+ avatar: ThemeAvatar_v2
374
396
  button: {
375
397
  border: {
376
398
  width: number
@@ -390,7 +412,7 @@ export declare interface RootTheme_v2 {
390
412
  color: ThemeColorSchemes_v2
391
413
  container: number[]
392
414
  font: ThemeFonts
393
- input: ThemeInput
415
+ input: ThemeInput_v2
394
416
  layer: ThemeLayer
395
417
  media: number[]
396
418
  radius: number[]
@@ -418,6 +440,9 @@ export declare type Styles = ThemeStyles
418
440
  */
419
441
  export declare interface Theme {
420
442
  sanity: Omit<RootTheme, 'color' | 'v2'> & {
443
+ /**
444
+ * @deprecated Use `v2.color` instead
445
+ */
421
446
  color: ThemeColor
422
447
  v2?: Theme_v2
423
448
  }
@@ -480,8 +505,19 @@ export declare type Theme_v2 = Omit<RootTheme_v2, 'color'> & {
480
505
 
481
506
  /**
482
507
  * @public
508
+ * @deprecated Use `ThemeAvatar_v2` instead
483
509
  */
484
510
  export declare interface ThemeAvatar {
511
+ sizes: {
512
+ distance: number
513
+ size: number
514
+ }[]
515
+ }
516
+
517
+ /**
518
+ * @public
519
+ */
520
+ export declare interface ThemeAvatar_v2 {
485
521
  sizes: {
486
522
  /** Spacing between avatars in an <AvatarStack> component (px) */
487
523
  distance: number
@@ -1254,7 +1290,7 @@ export declare type ThemeColorToneKey = ThemeColorCardToneKey
1254
1290
 
1255
1291
  /** @public */
1256
1292
  export declare interface ThemeConfig {
1257
- avatar?: ThemeAvatar
1293
+ avatar?: ThemeAvatar_v2
1258
1294
  button?: {
1259
1295
  border: {
1260
1296
  width: number
@@ -1273,8 +1309,8 @@ export declare interface ThemeConfig {
1273
1309
  }
1274
1310
  color?: ThemeColorTokens
1275
1311
  container?: number[]
1276
- fonts?: ThemeFonts
1277
- input?: ThemeInput
1312
+ font?: ThemeFonts
1313
+ input?: ThemeInput_v2
1278
1314
  layer?: ThemeLayer
1279
1315
  media?: number[]
1280
1316
  palette?: ThemeColorPalette
@@ -1348,8 +1384,32 @@ export declare type ThemeFontWeightKey = 'regular' | 'medium' | 'semibold' | 'bo
1348
1384
 
1349
1385
  /**
1350
1386
  * @public
1387
+ * @deprecated Use `ThemeInput_v2` instead
1351
1388
  */
1352
1389
  export declare interface ThemeInput {
1390
+ checkbox: {
1391
+ size: number
1392
+ }
1393
+ radio: {
1394
+ size: number
1395
+ markSize: number
1396
+ }
1397
+ switch: {
1398
+ width: number
1399
+ height: number
1400
+ padding: number
1401
+ transitionDurationMs: number
1402
+ transitionTimingFunction: string
1403
+ }
1404
+ border: {
1405
+ width: number
1406
+ }
1407
+ }
1408
+
1409
+ /**
1410
+ * @public
1411
+ */
1412
+ export declare interface ThemeInput_v2 {
1353
1413
  checkbox: {
1354
1414
  size: number
1355
1415
  focusRing: ThemeFocusRing
package/dist/theme.esm.js CHANGED
@@ -1679,13 +1679,34 @@ function getTheme_v2(theme) {
1679
1679
  if (cached_v2) return cached_v2;
1680
1680
  const v2 = {
1681
1681
  _version: 2,
1682
- avatar: theme.sanity.avatar,
1683
- button: theme.sanity.button,
1684
- card: theme.sanity.card,
1682
+ avatar: {
1683
+ ...defaultThemeConfig.avatar,
1684
+ ...theme.sanity.avatar
1685
+ },
1686
+ button: {
1687
+ ...defaultThemeConfig.button,
1688
+ ...theme.sanity.button
1689
+ },
1690
+ card: defaultThemeConfig.card,
1685
1691
  color: themeColor_v0_v2(theme.sanity.color),
1686
1692
  container: theme.sanity.container,
1687
1693
  font: theme.sanity.fonts,
1688
- input: theme.sanity.input,
1694
+ input: {
1695
+ ...defaultThemeConfig.input,
1696
+ ...theme.sanity.input,
1697
+ checkbox: {
1698
+ ...defaultThemeConfig.input.checkbox,
1699
+ ...theme.sanity.input.checkbox
1700
+ },
1701
+ radio: {
1702
+ ...defaultThemeConfig.input.radio,
1703
+ ...theme.sanity.input.radio
1704
+ },
1705
+ switch: {
1706
+ ...defaultThemeConfig.input.switch,
1707
+ ...theme.sanity.input.switch
1708
+ }
1709
+ },
1689
1710
  layer: (_a = theme.sanity.layer) != null ? _a : defaultThemeConfig.layer,
1690
1711
  media: theme.sanity.media,
1691
1712
  radius: theme.sanity.radius,
@@ -1710,7 +1731,6 @@ function v0_v2(v0) {
1710
1731
  const {
1711
1732
  avatar,
1712
1733
  button,
1713
- card,
1714
1734
  color,
1715
1735
  container,
1716
1736
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1726,9 +1746,15 @@ function v0_v2(v0) {
1726
1746
  } = v0;
1727
1747
  const v2 = {
1728
1748
  _version: 2,
1729
- avatar,
1730
- button,
1731
- card,
1749
+ avatar: {
1750
+ ...defaultThemeConfig.avatar,
1751
+ ...avatar
1752
+ },
1753
+ button: {
1754
+ ...defaultThemeConfig.button,
1755
+ ...button
1756
+ },
1757
+ card: defaultThemeConfig.card,
1732
1758
  color: {
1733
1759
  light: {
1734
1760
  transparent: themeColor_v0_v2(color.light.transparent),
@@ -1749,7 +1775,22 @@ function v0_v2(v0) {
1749
1775
  },
1750
1776
  container,
1751
1777
  font,
1752
- input,
1778
+ input: {
1779
+ ...defaultThemeConfig.input,
1780
+ ...input,
1781
+ checkbox: {
1782
+ ...defaultThemeConfig.input.checkbox,
1783
+ ...input.checkbox
1784
+ },
1785
+ radio: {
1786
+ ...defaultThemeConfig.input.radio,
1787
+ ...input.radio
1788
+ },
1789
+ switch: {
1790
+ ...defaultThemeConfig.input.switch,
1791
+ ...input.switch
1792
+ }
1793
+ },
1753
1794
  layer: layer != null ? layer : defaultThemeConfig.layer,
1754
1795
  media,
1755
1796
  radius,
@@ -1767,7 +1808,6 @@ function v2_v0(v2) {
1767
1808
  const {
1768
1809
  avatar,
1769
1810
  button,
1770
- card,
1771
1811
  color,
1772
1812
  container,
1773
1813
  font: fonts,
@@ -1782,7 +1822,6 @@ function v2_v0(v2) {
1782
1822
  _version: 0,
1783
1823
  avatar,
1784
1824
  button,
1785
- card,
1786
1825
  container,
1787
1826
  color: {
1788
1827
  light: {
@@ -4237,9 +4276,14 @@ function buildTheme(config) {
4237
4276
  avatar: (_a = config == null ? void 0 : config.avatar) != null ? _a : defaultThemeConfig.avatar,
4238
4277
  button: (_b = config == null ? void 0 : config.button) != null ? _b : defaultThemeConfig.button,
4239
4278
  card: (_c = config == null ? void 0 : config.card) != null ? _c : defaultThemeConfig.card,
4279
+ // How colors are generated:
4280
+ // 1. Merge custom tokens with default tokens
4281
+ // 2. Generate tree of color keys (gray/500, black, white, etc.)
4282
+ // 3. Apply mixing and render to hex values
4283
+ // render(build(mergeWithDefaults()))
4240
4284
  color: renderThemeColorSchemes(colorTheme, config),
4241
4285
  container: (_d = config == null ? void 0 : config.container) != null ? _d : defaultThemeConfig.container,
4242
- font: (_e = config == null ? void 0 : config.fonts) != null ? _e : defaultThemeFonts,
4286
+ font: (_e = config == null ? void 0 : config.font) != null ? _e : defaultThemeFonts,
4243
4287
  input: (_f = config == null ? void 0 : config.input) != null ? _f : defaultThemeConfig.input,
4244
4288
  layer: (_g = config == null ? void 0 : config.layer) != null ? _g : defaultThemeConfig.layer,
4245
4289
  media: (_h = config == null ? void 0 : config.media) != null ? _h : defaultThemeConfig.media,