@sanity/ui 2.0.0-beta.2 → 2.0.0-beta.21
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/LICENSE +1 -1
- package/README.md +6 -3
- package/dist/index.cjs.mjs +11 -36
- package/dist/index.d.ts +247 -267
- package/dist/index.esm.js +477 -326
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +486 -539
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs.mjs +1 -1
- package/dist/theme.d.ts +87 -115
- package/dist/theme.esm.js +348 -290
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +348 -290
- package/dist/theme.js.map +1 -1
- package/package.json +6 -3
- package/src/core/__workshop__/fontsPlugin.tsx +48 -8
- package/src/core/_compat.ts +236 -87
- package/src/core/components/dialog/dialog.tsx +1 -1
- package/src/core/components/dialog/styles.ts +2 -2
- package/src/core/components/menu/__workshop__/selectedItem.tsx +7 -2
- package/src/core/components/menu/menuButton.tsx +12 -1
- package/src/core/components/toast/toast.tsx +17 -2
- package/src/core/components/toast/toastProvider.tsx +20 -3
- package/src/core/constants.ts +37 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +6 -3
- package/src/core/middleware/origin.ts +47 -0
- package/src/core/primitives/badge/badge.tsx +1 -3
- package/src/core/primitives/button/button.tsx +9 -11
- package/src/core/primitives/heading/styles.ts +4 -0
- package/src/core/primitives/kbd/kbd.tsx +2 -0
- package/src/core/primitives/popover/popover.tsx +67 -13
- package/src/core/primitives/popover/popoverCard.tsx +31 -15
- package/src/core/primitives/select/select.tsx +1 -1
- package/src/core/primitives/switch/styles.ts +6 -1
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/states.tsx +10 -2
- package/src/core/primitives/tooltip/tooltip.tsx +46 -56
- package/src/core/primitives/tooltip/tooltipCard.tsx +110 -0
- package/src/core/styles/card/_cardColorStyle.ts +2 -0
- package/src/core/styles/input/textInputStyle.ts +33 -2
- package/src/core/styles/margin/marginsStyle.test.ts +2 -2
- package/src/core/styles/padding/paddingStyle.test.ts +2 -2
- package/src/core/theme/__workshop__/build/Root.tsx +20 -3
- package/src/core/theme/__workshop__/build/story.tsx +16 -10
- package/src/core/theme/__workshop__/canvas.tsx +7 -7
- package/src/core/theme/__workshop__/debug/story.tsx +196 -0
- package/src/core/theme/__workshop__/index.ts +5 -0
- package/src/core/theme/theme.test.tsx +2 -2
- package/src/core/types/button.ts +1 -2
- package/src/core/{primitives/tooltip → utils/conditionalWrapper}/conditionalWrapper.tsx +3 -0
- package/src/core/utils/conditionalWrapper/index.ts +1 -0
- package/src/core/utils/index.ts +1 -0
- package/src/theme/build/_deprecated/color/factory.ts +3 -3
- package/src/theme/build/buildColorTheme.test.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +16 -16
- package/src/theme/build/colorToken/colorToken.ts +19 -0
- package/src/theme/build/colorToken/compileColorToken.ts +21 -0
- package/src/theme/build/colorToken/index.ts +2 -0
- package/src/theme/build/colorToken/types.ts +6 -0
- package/src/theme/build/renderColorTheme.ts +14 -15
- package/src/theme/build/renderColorValue.ts +9 -2
- package/src/theme/config/system.ts +12 -10
- package/src/theme/config/tokens/color/types.ts +12 -1
- package/src/theme/config/tokens/parseTokenKey.ts +1 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +13 -16
- package/src/theme/config/tokens/parseTokenValue.ts +45 -14
- package/src/theme/config/tokens/types.ts +3 -2
- package/src/theme/defaults/colorTokens.ts +279 -253
- package/src/theme/defaults/config.ts +2 -2
- package/src/theme/getScopedTheme.ts +1 -0
- package/src/theme/index.ts +0 -7
- package/src/theme/system/color/_constants.ts +5 -2
- package/src/theme/system/color/_system.ts +2 -1
- package/src/theme/system/color/avatar.ts +2 -12
- package/src/theme/system/color/button.ts +4 -20
- package/src/theme/system/color/input.ts +3 -11
- package/src/theme/system/color/selectable.ts +3 -14
- package/src/theme/system/shadow.ts +0 -6
- package/src/theme/system/styles.ts +0 -6
- package/src/theme/system/theme.ts +11 -1
- package/src/theme/system/v0/avatar.ts +1 -1
- package/src/theme/system/v0/color/button.ts +4 -4
- package/src/theme/system/v0/color/card.ts +2 -2
- package/src/theme/system/v0/color/color.ts +0 -1
- package/src/theme/system/v0/color/input.ts +3 -3
- package/src/theme/system/v0/color/muted.ts +2 -2
- package/src/theme/system/v0/color/solid.ts +2 -2
- package/src/theme/versioning/getTheme_v2.ts +2 -1
- package/src/theme/versioning/themeColor_v0_v2.ts +2 -2
- package/src/theme/versioning/v2_v0.ts +3 -2
- package/src/theme/build/colorToken.ts +0 -39
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ThemeColorTokenValue,
|
|
11
11
|
} from '../../system'
|
|
12
12
|
|
|
13
|
+
/** @public */
|
|
13
14
|
export interface ThemeColorAvatarHueTokens {
|
|
14
15
|
_blend?: ColorBlendModeTokenValue
|
|
15
16
|
_hue?: ColorHueKey
|
|
@@ -17,6 +18,7 @@ export interface ThemeColorAvatarHueTokens {
|
|
|
17
18
|
fg?: ThemeColorTokenValue
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
/** @public */
|
|
20
22
|
export interface ThemeColorAvatarTokens {
|
|
21
23
|
'*'?: ThemeColorAvatarHueTokens
|
|
22
24
|
gray?: ThemeColorAvatarHueTokens
|
|
@@ -30,8 +32,8 @@ export interface ThemeColorAvatarTokens {
|
|
|
30
32
|
cyan?: ThemeColorAvatarHueTokens
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/** @public */
|
|
33
36
|
export interface ThemeColorBadgeTokens {
|
|
34
|
-
// _blend?: ColorBlendModeTokenValue
|
|
35
37
|
_hue?: ColorHueKey
|
|
36
38
|
bg?: ThemeColorTokenValue
|
|
37
39
|
fg?: ThemeColorTokenValue
|
|
@@ -39,6 +41,7 @@ export interface ThemeColorBadgeTokens {
|
|
|
39
41
|
icon?: ThemeColorTokenValue
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
/** @public */
|
|
42
45
|
export interface ThemeColorBaseTokens extends ThemeColorStateTokens {
|
|
43
46
|
focusRing?: ThemeColorTokenValue
|
|
44
47
|
backdrop?: ThemeColorTokenValue
|
|
@@ -50,6 +53,7 @@ export interface ThemeColorBaseTokens extends ThemeColorStateTokens {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
/** @public */
|
|
53
57
|
export interface ThemeColorBadgeToneTokens {
|
|
54
58
|
_blend?: ColorBlendModeTokenValue
|
|
55
59
|
_hue?: ColorHueKey
|
|
@@ -59,6 +63,7 @@ export interface ThemeColorBadgeToneTokens {
|
|
|
59
63
|
icon?: ThemeColorTokenValue
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
/** @public */
|
|
62
67
|
export interface ThemeColorBadgeTokens {
|
|
63
68
|
'*'?: ThemeColorBadgeToneTokens
|
|
64
69
|
default?: ThemeColorBadgeToneTokens
|
|
@@ -68,6 +73,7 @@ export interface ThemeColorBadgeTokens {
|
|
|
68
73
|
critical?: ThemeColorBadgeToneTokens
|
|
69
74
|
}
|
|
70
75
|
|
|
76
|
+
/** @public */
|
|
71
77
|
export interface ThemeColorStateTokens {
|
|
72
78
|
_blend?: ColorBlendModeTokenValue
|
|
73
79
|
_hue?: ColorHueKey
|
|
@@ -102,13 +108,16 @@ export interface ThemeColorStateTokens {
|
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
110
|
|
|
111
|
+
/** @public */
|
|
105
112
|
export type ThemeColorStatesTokens = Partial<Record<ColorConfigState, ThemeColorStateTokens>>
|
|
106
113
|
|
|
114
|
+
/** @public */
|
|
107
115
|
export interface ThemeColorButtonTokens
|
|
108
116
|
extends Partial<Record<ColorConfigStateTone, ThemeColorStatesTokens>> {
|
|
109
117
|
_hue?: ColorHueKey
|
|
110
118
|
}
|
|
111
119
|
|
|
120
|
+
/** @public */
|
|
112
121
|
export interface ThemeColorInputStateTokens {
|
|
113
122
|
_blend?: ColorBlendModeTokenValue
|
|
114
123
|
_hue?: ColorHueKey
|
|
@@ -121,11 +130,13 @@ export interface ThemeColorInputStateTokens {
|
|
|
121
130
|
placeholder?: ThemeColorTokenValue
|
|
122
131
|
}
|
|
123
132
|
|
|
133
|
+
/** @public */
|
|
124
134
|
export interface ThemeColorInputTokens
|
|
125
135
|
extends Partial<Record<ColorConfigInputState, ThemeColorInputStateTokens>> {
|
|
126
136
|
_hue?: ColorHueKey
|
|
127
137
|
}
|
|
128
138
|
|
|
139
|
+
/** @public */
|
|
129
140
|
export interface ThemeColorTokens {
|
|
130
141
|
base?: Partial<Record<ColorConfigCardTone, ThemeColorBaseTokens>>
|
|
131
142
|
button?: Partial<Record<ThemeColorButtonModeKey, ThemeColorButtonTokens>>
|
|
@@ -11,13 +11,25 @@ test('parse color value', () => {
|
|
|
11
11
|
tint: '50',
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
+
expect(parseTokenValue('50 50%')).toEqual({
|
|
15
|
+
type: 'color',
|
|
16
|
+
tint: '50',
|
|
17
|
+
mix: 0.5,
|
|
18
|
+
})
|
|
19
|
+
|
|
14
20
|
expect(parseTokenValue('cyan/500')).toEqual({
|
|
15
21
|
type: 'color',
|
|
16
|
-
key: 'cyan/500',
|
|
17
22
|
hue: 'cyan',
|
|
18
23
|
tint: '500',
|
|
19
24
|
})
|
|
20
25
|
|
|
26
|
+
expect(parseTokenValue('cyan/500 50%')).toEqual({
|
|
27
|
+
type: 'color',
|
|
28
|
+
hue: 'cyan',
|
|
29
|
+
mix: 0.5,
|
|
30
|
+
tint: '500',
|
|
31
|
+
})
|
|
32
|
+
|
|
21
33
|
expect(parseTokenValue('screen')).toEqual({
|
|
22
34
|
type: 'blendMode',
|
|
23
35
|
value: 'screen',
|
|
@@ -27,19 +39,4 @@ test('parse color value', () => {
|
|
|
27
39
|
type: 'blendMode',
|
|
28
40
|
value: 'multiply',
|
|
29
41
|
})
|
|
30
|
-
|
|
31
|
-
expect(parseTokenValue('0')).toEqual({
|
|
32
|
-
type: 'color',
|
|
33
|
-
opacity: 0,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
expect(parseTokenValue('0.1')).toEqual({
|
|
37
|
-
type: 'color',
|
|
38
|
-
opacity: 0.1,
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
expect(parseTokenValue('1')).toEqual({
|
|
42
|
-
type: 'color',
|
|
43
|
-
opacity: 1,
|
|
44
|
-
})
|
|
45
42
|
})
|
|
@@ -2,14 +2,32 @@ import {isColorBlendModeValue, isColorHueKey, isColorTintKey} from '../../system
|
|
|
2
2
|
import {isColorOpacityValue, isColorValue} from '../helpers'
|
|
3
3
|
import {TokenValueNode} from './types'
|
|
4
4
|
|
|
5
|
+
function isColorMixPercentValue(str: string): str is `${number}%` {
|
|
6
|
+
return /^\d+%$/.test(str)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** @internal */
|
|
5
10
|
export function parseTokenValue(str: string): TokenValueNode | undefined {
|
|
6
11
|
const segments = str.split('/')
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
let nextSegment = segments.shift() || ''
|
|
14
|
+
|
|
15
|
+
const [segment0, segment0mix] = nextSegment.split(' ')
|
|
8
16
|
|
|
9
17
|
if (isColorTintKey(segment0)) {
|
|
10
18
|
const tint = segment0
|
|
11
19
|
const segment1 = segments.shift() || ''
|
|
12
20
|
|
|
21
|
+
if (isColorMixPercentValue(segment0mix)) {
|
|
22
|
+
const mix = Number(segment0mix.slice(0, -1)) / 100
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
type: 'color',
|
|
26
|
+
tint,
|
|
27
|
+
mix,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
if (isColorOpacityValue(segment1)) {
|
|
14
32
|
const opacity = Number(segment1)
|
|
15
33
|
|
|
@@ -30,6 +48,16 @@ export function parseTokenValue(str: string): TokenValueNode | undefined {
|
|
|
30
48
|
const key = segment0 as 'black' | 'white'
|
|
31
49
|
const segment1 = segments.shift() || ''
|
|
32
50
|
|
|
51
|
+
if (isColorMixPercentValue(segment0mix)) {
|
|
52
|
+
const mix = Number(segment0mix.slice(0, -1)) / 100
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
type: 'color',
|
|
56
|
+
key,
|
|
57
|
+
mix,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
33
61
|
if (isColorOpacityValue(segment1)) {
|
|
34
62
|
const opacity = Number(segment1)
|
|
35
63
|
|
|
@@ -48,18 +76,31 @@ export function parseTokenValue(str: string): TokenValueNode | undefined {
|
|
|
48
76
|
|
|
49
77
|
if (isColorHueKey(segment0)) {
|
|
50
78
|
const hue = segment0
|
|
51
|
-
|
|
79
|
+
|
|
80
|
+
nextSegment = segments.shift() || ''
|
|
81
|
+
|
|
82
|
+
const [segment1, segment1mix] = nextSegment.split(' ')
|
|
52
83
|
|
|
53
84
|
if (isColorTintKey(segment1)) {
|
|
54
85
|
const tint = segment1
|
|
55
86
|
const segment2 = segments.shift() || ''
|
|
56
87
|
|
|
88
|
+
if (isColorMixPercentValue(segment1mix)) {
|
|
89
|
+
const mix = Number(segment1mix.slice(0, -1)) / 100
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
type: 'color',
|
|
93
|
+
hue,
|
|
94
|
+
tint,
|
|
95
|
+
mix,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
57
99
|
if (isColorOpacityValue(segment2)) {
|
|
58
100
|
const opacity = Number(segment2)
|
|
59
101
|
|
|
60
102
|
return {
|
|
61
103
|
type: 'color',
|
|
62
|
-
key: `${hue}/${tint}`,
|
|
63
104
|
hue,
|
|
64
105
|
tint,
|
|
65
106
|
opacity,
|
|
@@ -68,7 +109,6 @@ export function parseTokenValue(str: string): TokenValueNode | undefined {
|
|
|
68
109
|
|
|
69
110
|
return {
|
|
70
111
|
type: 'color',
|
|
71
|
-
key: `${hue}/${tint}`,
|
|
72
112
|
hue,
|
|
73
113
|
tint,
|
|
74
114
|
}
|
|
@@ -76,16 +116,7 @@ export function parseTokenValue(str: string): TokenValueNode | undefined {
|
|
|
76
116
|
|
|
77
117
|
return {
|
|
78
118
|
type: 'hue',
|
|
79
|
-
value:
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (isColorOpacityValue(segment0)) {
|
|
84
|
-
const opacity = Number(segment0)
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
type: 'color',
|
|
88
|
-
opacity,
|
|
119
|
+
value: hue,
|
|
89
120
|
}
|
|
90
121
|
}
|
|
91
122
|
|
|
@@ -29,10 +29,11 @@ export type TokenKeyNode = TokenBaseKeyNode | TokenButtonKeyNode
|
|
|
29
29
|
/** @internal */
|
|
30
30
|
export interface TokenColorValueNode {
|
|
31
31
|
type: 'color'
|
|
32
|
-
key?: 'black' | 'white'
|
|
32
|
+
key?: 'black' | 'white'
|
|
33
33
|
hue?: ColorHueKey
|
|
34
|
-
|
|
34
|
+
mix?: number
|
|
35
35
|
opacity?: number
|
|
36
|
+
tint?: ColorTintKey
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/** @internal */
|