@sanity/ui 2.0.0-alpha.2 → 2.0.0-alpha.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/dist/index.cjs.mjs +28 -0
- package/dist/index.d.ts +476 -12
- package/dist/index.esm.js +1326 -524
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1353 -523
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
- package/src/components/autocomplete/autocomplete.tsx +6 -0
- package/src/components/dialog/constants.ts +4 -0
- package/src/components/dialog/dialog.tsx +79 -15
- package/src/components/hotkeys/hotkeys.tsx +2 -0
- package/src/components/menu/menu.tsx +2 -0
- package/src/components/menu/menuButton.tsx +2 -0
- package/src/components/menu/menuGroup.tsx +22 -23
- package/src/components/menu/menuItem.tsx +29 -35
- package/src/components/tab/tab.tsx +4 -1
- package/src/components/toast/toast.tsx +4 -0
- package/src/primitives/_selectable/style.ts +2 -1
- package/src/primitives/avatar/avatar.tsx +16 -9
- package/src/primitives/avatar/avatarCounter.tsx +3 -3
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/badge/badge.tsx +7 -3
- package/src/primitives/box/box.tsx +3 -0
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +2 -1
- package/src/primitives/button/button.tsx +7 -3
- package/src/primitives/button/styles.ts +9 -2
- package/src/primitives/card/card.tsx +4 -0
- package/src/primitives/card/styles.ts +2 -0
- package/src/primitives/checkbox/checkbox.tsx +2 -0
- package/src/primitives/code/code.tsx +1 -0
- package/src/primitives/container/container.tsx +2 -0
- package/src/primitives/flex/flex.tsx +2 -0
- package/src/primitives/grid/grid.tsx +2 -0
- package/src/primitives/heading/heading.tsx +2 -0
- package/src/primitives/inline/inline.tsx +3 -0
- package/src/primitives/kbd/kbd.tsx +2 -0
- package/src/primitives/label/label.tsx +2 -0
- package/src/primitives/popover/popover.tsx +6 -1
- package/src/primitives/radio/radio.tsx +2 -0
- package/src/primitives/select/select.tsx +2 -0
- package/src/primitives/select/styles.ts +2 -0
- package/src/primitives/spinner/spinner.tsx +2 -0
- package/src/primitives/stack/stack.tsx +2 -0
- package/src/primitives/switch/switch.tsx +4 -0
- package/src/primitives/text/text.tsx +3 -0
- package/src/primitives/textArea/textArea.tsx +4 -1
- package/src/primitives/textInput/textInput.tsx +10 -1
- package/src/primitives/tooltip/__workshop__/customPortal.tsx +99 -0
- package/src/primitives/tooltip/__workshop__/index.ts +15 -0
- package/src/primitives/tooltip/__workshop__/overflowingBoundary.tsx +73 -0
- package/src/primitives/tooltip/__workshop__/resizableBoundary.tsx +85 -0
- package/src/primitives/tooltip/constants.ts +1 -0
- package/src/primitives/tooltip/tooltip.test.tsx +192 -0
- package/src/primitives/tooltip/tooltip.tsx +109 -33
- package/src/primitives/types.ts +4 -0
- package/src/styles/input/textInputStyle.ts +11 -6
- package/src/theme/_internal/__workshop__/build/story.tsx +288 -0
- package/src/theme/_internal/__workshop__/build/theme.ts +3 -0
- package/src/theme/_internal/__workshop__/index.ts +14 -0
- package/src/theme/_internal/build/buildTheme.test.ts +78 -0
- package/src/theme/_internal/build/buildTheme.ts +16 -0
- package/src/theme/_internal/build/colorTheme/buildColorTheme.test.ts +185 -0
- package/src/theme/_internal/build/colorTheme/buildColorTheme.ts +164 -0
- package/src/theme/_internal/build/colorTheme/renderColorTheme.ts +242 -0
- package/src/theme/_internal/build/colorTheme/resolveColorTokens.ts +121 -0
- package/src/theme/_internal/build/defaults/colorPalette.ts +8 -0
- package/src/theme/_internal/build/defaults/colorTokens.ts +147 -0
- package/src/theme/_internal/build/helpers.ts +65 -0
- package/src/theme/_internal/build/index.ts +1 -0
- package/src/theme/_internal/config/helpers.ts +47 -0
- package/src/theme/_internal/config/index.ts +3 -0
- package/src/theme/_internal/config/token/index.ts +2 -0
- package/src/theme/_internal/config/token/parseTokenKey.test.ts +72 -0
- package/src/theme/_internal/config/token/parseTokenKey.ts +88 -0
- package/src/theme/_internal/config/token/parseTokenValue.test.ts +45 -0
- package/src/theme/_internal/config/token/parseTokenValue.ts +123 -0
- package/src/theme/_internal/config/types.ts +137 -0
- package/src/theme/_internal/constants.ts +48 -0
- package/src/theme/_internal/helpers.ts +19 -0
- package/src/theme/_internal/index.ts +5 -0
- package/src/theme/_internal/types.ts +91 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
- package/src/theme/lib/color-fns/blend/screen.ts +2 -2
- package/src/theme/lib/color-fns/convert.ts +15 -1
- package/src/theme/lib/color-fns/parse.ts +7 -3
- package/src/theme/lib/color-fns/types.ts +11 -0
- package/src/theme/lib/theme/avatar.ts +2 -0
- package/src/theme/lib/theme/color/_legacy/createColorTheme.ts +7 -0
- package/src/theme/lib/theme/color/_legacy/index.ts +1 -0
- package/src/theme/lib/theme/color/_legacy/legacyColor.ts +3997 -0
- package/src/theme/studioTheme/color.ts +98 -82
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +5 -5
- package/src/theme/studioTheme/tints.ts +244 -84
- package/src/types/button.ts +5 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {ColorBlendModeValue} from './config'
|
|
2
|
+
import {
|
|
3
|
+
COLOR_BASE_TONES,
|
|
4
|
+
COLOR_BUTTON_MODES,
|
|
5
|
+
COLOR_HUES,
|
|
6
|
+
COLOR_STATE_TONES,
|
|
7
|
+
COLOR_STATES,
|
|
8
|
+
COLOR_TINTS,
|
|
9
|
+
} from './constants'
|
|
10
|
+
|
|
11
|
+
export type ColorHueValue = (typeof COLOR_HUES)[number]
|
|
12
|
+
|
|
13
|
+
export type ColorTintValue = (typeof COLOR_TINTS)[number]
|
|
14
|
+
|
|
15
|
+
export type ColorBaseTone = (typeof COLOR_BASE_TONES)[number]
|
|
16
|
+
|
|
17
|
+
export type ColorButtonMode = (typeof COLOR_BUTTON_MODES)[number]
|
|
18
|
+
|
|
19
|
+
export type ColorState = (typeof COLOR_STATES)[number]
|
|
20
|
+
|
|
21
|
+
export type ColorStateTone = (typeof COLOR_STATE_TONES)[number]
|
|
22
|
+
|
|
23
|
+
export interface TMP_StateColorTheme {
|
|
24
|
+
_blend: ColorBlendModeValue
|
|
25
|
+
bg: string
|
|
26
|
+
bg2?: string
|
|
27
|
+
fg: string
|
|
28
|
+
border: string
|
|
29
|
+
muted: {
|
|
30
|
+
fg: string
|
|
31
|
+
}
|
|
32
|
+
accent: {
|
|
33
|
+
fg: string
|
|
34
|
+
}
|
|
35
|
+
link: {
|
|
36
|
+
fg: string
|
|
37
|
+
}
|
|
38
|
+
code: {
|
|
39
|
+
bg: string
|
|
40
|
+
fg: string
|
|
41
|
+
}
|
|
42
|
+
skeleton?: {
|
|
43
|
+
from: string
|
|
44
|
+
to: string
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type TMP_ButtonStatesColorTheme = Record<ColorState, TMP_StateColorTheme>
|
|
49
|
+
|
|
50
|
+
export type TMP_ButtonModesColorTheme = Record<ColorButtonMode, TMP_ButtonStatesColorTheme>
|
|
51
|
+
|
|
52
|
+
export type TMP_ButtonColorTheme = Record<ColorStateTone, TMP_ButtonModesColorTheme>
|
|
53
|
+
|
|
54
|
+
export interface TMP_BaseColorTheme {
|
|
55
|
+
_blend: ColorBlendModeValue
|
|
56
|
+
dark: boolean
|
|
57
|
+
// base: ThemeColorBase
|
|
58
|
+
base: {
|
|
59
|
+
bg: string
|
|
60
|
+
fg: string
|
|
61
|
+
border: string
|
|
62
|
+
focusRing: string
|
|
63
|
+
shadow: {
|
|
64
|
+
outline: string
|
|
65
|
+
umbra: string
|
|
66
|
+
penumbra: string
|
|
67
|
+
ambient: string
|
|
68
|
+
}
|
|
69
|
+
skeleton: {
|
|
70
|
+
from: string
|
|
71
|
+
to: string
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
button: TMP_ButtonColorTheme
|
|
75
|
+
// card: ThemeColorCard
|
|
76
|
+
// input: ThemeColorInput
|
|
77
|
+
// selectable?: ThemeColorSelectable
|
|
78
|
+
// spot: ThemeColorSpot
|
|
79
|
+
// syntax: ThemeColorSyntax
|
|
80
|
+
// solid: ThemeColorSolid
|
|
81
|
+
// muted: ThemeColorMuted
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type TMP_ColorTheme = Record<ColorBaseTone, TMP_BaseColorTheme>
|
|
85
|
+
|
|
86
|
+
export interface TMP_Theme {
|
|
87
|
+
color: {
|
|
88
|
+
light: TMP_ColorTheme
|
|
89
|
+
dark: TMP_ColorTheme
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/theme/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {RGB} from '../types'
|
|
1
|
+
import {RGB, RGBA} from '../types'
|
|
2
2
|
|
|
3
3
|
function multiplyChannel(b: number, s: number) {
|
|
4
4
|
return b * s
|
|
@@ -9,7 +9,7 @@ function multiplyChannel(b: number, s: number) {
|
|
|
9
9
|
* Source: https://www.w3.org/TR/compositing-1/#blendingmultiply
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export function multiply(b: RGB, s: RGB): RGB {
|
|
12
|
+
export function multiply(b: RGB | RGBA, s: RGB | RGBA): RGB {
|
|
13
13
|
return {
|
|
14
14
|
r: Math.round(clamp(multiplyChannel(b.r / 255, s.r / 255) * 255)),
|
|
15
15
|
g: Math.round(clamp(multiplyChannel(b.g / 255, s.g / 255) * 255)),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {RGB} from '../types'
|
|
1
|
+
import {RGB, RGBA} from '../types'
|
|
2
2
|
|
|
3
3
|
function screenChannel(b: number, s: number) {
|
|
4
4
|
return b + s - b * s
|
|
@@ -9,7 +9,7 @@ function screenChannel(b: number, s: number) {
|
|
|
9
9
|
* Source: https://www.w3.org/TR/compositing-1/#blendingscreen
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export function screen(b: RGB, s: RGB): RGB {
|
|
12
|
+
export function screen(b: RGB | RGBA, s: RGB | RGBA): RGB {
|
|
13
13
|
return {
|
|
14
14
|
r: Math.round(clamp(screenChannel(b.r / 255, s.r / 255) * 255)),
|
|
15
15
|
g: Math.round(clamp(screenChannel(b.g / 255, s.g / 255) * 255)),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {HSL, RGB} from './types'
|
|
1
|
+
import {HSL, RGB, RGBA} from './types'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
@@ -23,6 +23,20 @@ export function hexToRgb(hex: string): RGB {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export function rgbaToRGBA(rgba: string): RGBA {
|
|
30
|
+
const values = rgba.replace(/rgba\(|\)/g, '').split(',')
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
r: parseInt(values[0]),
|
|
34
|
+
g: parseInt(values[1]),
|
|
35
|
+
b: parseInt(values[2]),
|
|
36
|
+
a: parseFloat(values[3]),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
26
40
|
/**
|
|
27
41
|
* @internal
|
|
28
42
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {hexToRgb, hslToRgb} from './convert'
|
|
2
|
-
import {HSL, RGB} from './types'
|
|
1
|
+
import {hexToRgb, hslToRgb, rgbaToRGBA} from './convert'
|
|
2
|
+
import {HSL, RGB, RGBA} from './types'
|
|
3
3
|
|
|
4
4
|
const HEX_CHARS = '0123456789ABCDEFabcdef'
|
|
5
5
|
|
|
@@ -37,7 +37,7 @@ function parseHsl(str: string): HSL {
|
|
|
37
37
|
/**
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
|
-
export function parseColor(color: unknown): RGB {
|
|
40
|
+
export function parseColor(color: unknown): RGB | RGBA {
|
|
41
41
|
if (!color) return {r: 0, g: 0, b: 0}
|
|
42
42
|
|
|
43
43
|
if (typeof color !== 'string') {
|
|
@@ -52,5 +52,9 @@ export function parseColor(color: unknown): RGB {
|
|
|
52
52
|
return hslToRgb(parseHsl(color))
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
if (color.startsWith('rgba(')) {
|
|
56
|
+
return rgbaToRGBA(color)
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
throw new Error(`parseColor: unexpected color format: "${color}"`)
|
|
56
60
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createColorTheme'
|