@sanity/ui 3.0.0-static.11 → 3.0.0-static.13
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/_chunks-cjs/_visual-editing.js +1293 -1215
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/buildCommand.js +28 -10
- package/dist/_chunks-cjs/buildCommand.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +1284 -1202
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +528 -358
- package/dist/_visual-editing.d.ts +528 -358
- package/dist/cli.js +1 -1
- package/dist/css.d.mts +143 -73
- package/dist/css.d.ts +143 -73
- package/dist/css.js +329 -472
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +330 -473
- package/dist/css.mjs.map +1 -1
- package/dist/index.d.mts +1362 -869
- package/dist/index.d.ts +1362 -869
- package/dist/index.js +383 -308
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +387 -312
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-palette.css +105 -1
- package/dist/sanity-palette.min.css +1 -0
- package/dist/sanity-theme.css +4571 -1
- package/dist/sanity-theme.min.css +1 -0
- package/dist/system.css +22053 -21946
- package/dist/system.min.css +1 -0
- package/dist/theme.d.mts +51 -106
- package/dist/theme.d.ts +51 -106
- package/dist/theme.js +9 -9
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +9 -9
- package/dist/theme.mjs.map +1 -1
- package/package.json +10 -5
- package/src/cli/buildCommand.ts +46 -19
- package/src/css/_comp.ts +2 -2
- package/src/css/{compile/compileStyle.ts → _compileStyle.ts} +7 -7
- package/src/css/{system.style.ts → _system.style.ts} +3 -2
- package/src/css/aspects/display/display.ts +1 -0
- package/src/css/aspects/display/types.ts +2 -3
- package/src/css/aspects/flex/types.ts +4 -12
- package/src/css/aspects/flexItem/types.ts +1 -3
- package/src/css/aspects/font/types.ts +1 -3
- package/src/css/aspects/grid/grid.ts +1 -0
- package/src/css/aspects/grid/types.ts +5 -9
- package/src/css/aspects/gridItem/gridItem.ts +1 -1
- package/src/css/aspects/gridItem/types.ts +7 -18
- package/src/css/aspects/height/height.ts +3 -4
- package/src/css/aspects/inset/inset.ts +1 -0
- package/src/css/aspects/margin/margin.ts +1 -0
- package/src/css/aspects/margin/types.ts +1 -0
- package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
- package/src/css/aspects/maxWidth/types.ts +1 -0
- package/src/css/aspects/minWidth/minWidth.ts +1 -0
- package/src/css/aspects/minWidth/types.ts +2 -0
- package/src/css/aspects/overflow/overflow.ts +1 -0
- package/src/css/aspects/padding/padding.ts +1 -0
- package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
- package/src/css/aspects/position/position.ts +1 -0
- package/src/css/aspects/shadow/shadow.ts +1 -0
- package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
- package/src/css/aspects/textOverflow/types.ts +1 -0
- package/src/css/aspects/width/types.ts +2 -0
- package/src/css/aspects/width/width.ts +1 -0
- package/src/css/{compile/compilePalette.ts → compilePalette.ts} +14 -10
- package/src/css/compileSystem.ts +7 -0
- package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
- package/src/css/{compile/compileTheme_v3.ts → compileTheme_v3.ts} +123 -104
- package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
- package/src/css/components/dialog/dialog.ts +7 -0
- package/src/css/components/menu/menu.ts +2 -0
- package/src/css/components/skeleton/skeleton.ts +4 -0
- package/src/css/components/skeleton/types.ts +4 -0
- package/src/css/components/toast/toast.ts +5 -0
- package/src/css/components/tree/tree.ts +1 -0
- package/src/css/composeClassNames.ts +4 -2
- package/src/css/constants.ts +2 -0
- package/src/css/index.ts +3 -3
- package/src/css/primitives/_arrow/_arrow.ts +3 -0
- package/src/css/primitives/_input/input.ts +2 -0
- package/src/css/primitives/_selectable/_selectable.style.ts +1 -2
- package/src/css/primitives/_selectable/selectable.ts +1 -2
- package/src/css/primitives/avatar/avatar.style.ts +5 -8
- package/src/css/primitives/avatar/avatar.ts +6 -0
- package/src/css/primitives/avatar/types.ts +1 -0
- package/src/css/primitives/box/types.ts +1 -3
- package/src/css/primitives/button/button.ts +4 -21
- package/src/css/primitives/button/index.ts +1 -0
- package/src/css/primitives/button/types.ts +18 -0
- package/src/css/primitives/card/card.style.ts +3 -6
- package/src/css/primitives/card/card.ts +2 -2
- package/src/css/primitives/card/types.ts +2 -2
- package/src/css/primitives/checkbox/checkbox.ts +2 -0
- package/src/css/primitives/container/container.ts +1 -0
- package/src/css/primitives/container/types.ts +1 -0
- package/src/css/primitives/kbd/kbd.ts +1 -0
- package/src/css/primitives/label/types.ts +7 -2
- package/src/css/primitives/popover/popover.ts +2 -0
- package/src/css/primitives/radio/radio.ts +1 -0
- package/src/css/primitives/select/select.ts +2 -0
- package/src/css/primitives/spinner/spinner.ts +2 -0
- package/src/css/primitives/switch/switch.ts +5 -0
- package/src/css/primitives/text/types.ts +4 -0
- package/src/css/primitives/textArea/textArea.ts +1 -0
- package/src/css/primitives/textInput/textInput.ts +1 -0
- package/src/css/primitives/tooltip/tooltip.ts +2 -0
- package/src/css/scopeClassName.ts +1 -0
- package/src/css/types.ts +9 -12
- package/src/css/util.ts +5 -0
- package/src/css/utils/srOnly/srOnly.ts +3 -1
- package/src/css/varNames.ts +131 -141
- package/src/css/vars.ts +1 -6
- package/src/theme/palette/constants.ts +2 -0
- package/src/theme/palette/types.ts +3 -0
- package/src/theme/types.ts +2 -6
- package/src/theme/v0/focusRing.ts +1 -3
- package/src/theme/v0/font.ts +6 -18
- package/src/theme/v0/layer.ts +1 -3
- package/src/theme/v0/shadow.ts +2 -6
- package/src/theme/v2/avatar.ts +1 -3
- package/src/theme/v2/color/_system.ts +1 -3
- package/src/theme/v2/color/avatar.ts +2 -6
- package/src/theme/v2/color/badge.ts +2 -6
- package/src/theme/v2/color/button.ts +3 -9
- package/src/theme/v2/color/color.ts +3 -9
- package/src/theme/v2/color/input.ts +3 -9
- package/src/theme/v2/color/kbd.ts +1 -3
- package/src/theme/v2/color/selectable.ts +2 -6
- package/src/theme/v2/color/state.ts +1 -3
- package/src/theme/v2/color/syntax.ts +1 -3
- package/src/theme/v2/input.ts +1 -3
- package/src/theme/v2/theme.ts +2 -6
- package/src/theme/v3/buildTheme_v3.ts +1 -0
- package/src/theme/v3/color/color.ts +6 -4
- package/src/theme/v3/color/renderColor.ts +4 -1
- package/src/theme/v3/defaultTokens.ts +1 -0
- package/src/theme/v3/resolveTokens.ts +9 -9
- package/src/ui/RootClassNames.tsx +3 -0
- package/src/ui/StyleTags.tsx +3 -1
- package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
- package/src/ui/_compat/theme/themeProvider.tsx +2 -6
- package/src/ui/_compat/theme/types.ts +1 -3
- package/src/ui/_compat/theme/useRootTheme.ts +1 -3
- package/src/ui/_compat/theme/useTheme.ts +2 -6
- package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
- package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
- package/src/ui/components/autocomplete/types.ts +3 -8
- package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
- package/src/ui/components/dialog/dialog.tsx +89 -291
- package/src/ui/components/dialog/dialogCard.tsx +183 -0
- package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
- package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
- package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
- package/src/ui/components/menu/menu.tsx +27 -33
- package/src/ui/components/menu/menuButton.tsx +10 -14
- package/src/ui/components/menu/menuDivider.tsx +25 -13
- package/src/ui/components/menu/menuGroup.tsx +34 -26
- package/src/ui/components/menu/menuItem.tsx +51 -40
- package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
- package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
- package/src/ui/components/skeleton/index.ts +3 -0
- package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
- package/src/ui/components/skeleton/skeleton.tsx +39 -16
- package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
- package/src/ui/components/tab/tab.tsx +23 -19
- package/src/ui/components/tab/tabList.tsx +34 -33
- package/src/ui/components/tab/tabPanel.tsx +25 -19
- package/src/ui/components/toast/toast.tsx +21 -16
- package/src/ui/components/toast/toastLayer.tsx +28 -10
- package/src/ui/components/toast/toastProvider.tsx +2 -6
- package/src/ui/components/toast/types.ts +2 -6
- package/src/ui/components/toast/useToast.ts +1 -3
- package/src/ui/components/tree/tree.tsx +194 -187
- package/src/ui/components/tree/treeGroup.tsx +25 -5
- package/src/ui/components/tree/treeItem.tsx +35 -23
- package/src/ui/hooks/useClickOutside.ts +2 -6
- package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
- package/src/ui/primitives/_selectable/selectable.tsx +33 -20
- package/src/ui/primitives/avatar/avatar.tsx +28 -31
- package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
- package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
- package/src/ui/primitives/avatar/types.ts +2 -0
- package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
- package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
- package/src/ui/primitives/badge/badge.tsx +33 -32
- package/src/ui/primitives/badge/types.ts +2 -1
- package/src/ui/primitives/box/box.tsx +59 -29
- package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
- package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
- package/src/ui/primitives/button/button.test.tsx +1 -15
- package/src/ui/primitives/button/button.tsx +64 -70
- package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
- package/src/ui/primitives/card/card.tsx +22 -22
- package/src/ui/primitives/card/cardProvider.tsx +2 -0
- package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
- package/src/ui/primitives/code/code.tsx +24 -22
- package/src/ui/primitives/container/container.tsx +26 -15
- package/src/ui/primitives/flex/flex.tsx +21 -19
- package/src/ui/primitives/grid/grid.tsx +21 -16
- package/src/ui/primitives/heading/heading.tsx +42 -19
- package/src/ui/primitives/inline/inline.tsx +26 -23
- package/src/ui/primitives/kbd/kbd.tsx +25 -23
- package/src/ui/primitives/label/label.tsx +41 -26
- package/src/ui/primitives/popover/popover.tsx +281 -277
- package/src/ui/primitives/popover/popoverCard.tsx +119 -118
- package/src/ui/primitives/radio/radio.tsx +30 -14
- package/src/ui/primitives/select/select.tsx +24 -16
- package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
- package/src/ui/primitives/spinner/spinner.tsx +24 -12
- package/src/ui/primitives/stack/stack.tsx +27 -18
- package/src/ui/primitives/switch/switch.tsx +31 -14
- package/src/ui/primitives/text/text.tsx +42 -24
- package/src/ui/primitives/textArea/textArea.tsx +33 -18
- package/src/ui/primitives/textInput/textInput.tsx +28 -40
- package/src/ui/primitives/tooltip/constants.ts +1 -1
- package/src/ui/primitives/tooltip/tooltip.tsx +76 -59
- package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
- package/src/ui/primitives/types.ts +1 -3
- package/src/ui/types/avatar.ts +3 -6
- package/src/ui/types/badge.ts +1 -3
- package/src/ui/types/button.ts +1 -3
- package/src/ui/types/card.ts +1 -3
- package/src/ui/types/dialog.ts +1 -3
- package/src/ui/types/props.ts +20 -10
- package/src/ui/utils/arrow/arrow.tsx +40 -14
- package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
- package/src/ui/utils/boundaryElement/types.ts +1 -3
- package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
- package/src/ui/utils/elementQuery/elementQuery.tsx +36 -14
- package/src/ui/utils/errorBoundary.tsx +2 -0
- package/src/ui/utils/index.ts +0 -1
- package/src/ui/utils/layer/layer.tsx +23 -93
- package/src/ui/utils/layer/layerCard.tsx +92 -0
- package/src/ui/utils/layer/layerProvider.tsx +2 -6
- package/src/ui/utils/layer/useLayer.ts +1 -3
- package/src/ui/utils/portal/portal.ts +2 -6
- package/src/ui/utils/portal/portalProvider.tsx +2 -6
- package/src/ui/utils/portal/types.ts +1 -3
- package/src/ui/utils/portal/usePortal.ts +1 -3
- package/src/ui/utils/srOnly/srOnly.tsx +25 -20
- package/src/ui/utils/virtualList/virtualList.tsx +36 -24
- package/src/css/compile/compileRule.ts +0 -97
- package/src/css/compile/compileRules.test.ts +0 -36
- package/src/css/compile/compileRules.ts +0 -43
- package/src/css/compile/compileSystem.ts +0 -7
- package/src/css/compile/types.ts +0 -6
- package/src/css/primitives/_selectable/_contants.ts +0 -11
- package/src/css/primitives/card/_constants.ts +0 -13
- package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
- package/src/ui/utils/conditionalWrapper/index.ts +0 -1
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import {ThemeColorStateKey, ThemeColorStateToneKey} from './_system'
|
|
2
2
|
import {ThemeColorState_v2} from './state'
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
4
|
+
/** @public */
|
|
7
5
|
export type ThemeColorSelectableTone_v2 = Record<ThemeColorStateKey, ThemeColorState_v2>
|
|
8
6
|
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
7
|
+
/** @public */
|
|
12
8
|
export type ThemeColorSelectable_v2 = Record<ThemeColorStateToneKey, ThemeColorSelectableTone_v2>
|
|
@@ -3,9 +3,7 @@ import {ThemeColorAvatar_v2} from './avatar'
|
|
|
3
3
|
import {ThemeColorBadge_v2} from './badge'
|
|
4
4
|
import {ThemeColorKBD} from './kbd'
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
6
|
+
/** @public */
|
|
9
7
|
export interface ThemeColorState_v2 {
|
|
10
8
|
/** @internal */
|
|
11
9
|
_blend?: ThemeColorBlendModeKey
|
package/src/theme/v2/input.ts
CHANGED
package/src/theme/v2/theme.ts
CHANGED
|
@@ -7,9 +7,7 @@ import {ThemeAvatar_v2} from './avatar'
|
|
|
7
7
|
import {ThemeColorCard_v2, ThemeColorSchemes_v2} from './color'
|
|
8
8
|
import {ThemeInput_v2} from './input'
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
10
|
+
/** @public */
|
|
13
11
|
export interface RootTheme_v2 {
|
|
14
12
|
_version: 2
|
|
15
13
|
avatar: ThemeAvatar_v2
|
|
@@ -35,9 +33,7 @@ export interface RootTheme_v2 {
|
|
|
35
33
|
/** @internal */
|
|
36
34
|
style?: ThemeStyles
|
|
37
35
|
}
|
|
38
|
-
/**
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
36
|
+
/** @public */
|
|
41
37
|
export type Theme_v2 = Omit<RootTheme_v2, 'color'> & {
|
|
42
38
|
color: ThemeColorCard_v2
|
|
43
39
|
/**
|
|
@@ -6,8 +6,7 @@ import {
|
|
|
6
6
|
ThemeColorStateToneKey,
|
|
7
7
|
} from '../../v2'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/** @public */
|
|
11
10
|
export interface ThemeColorElement {
|
|
12
11
|
_hue: Hue
|
|
13
12
|
bg: {
|
|
@@ -24,12 +23,13 @@ export interface ThemeColorElement {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
26
|
+
/** @public */
|
|
27
27
|
export type ThemeColorVariant = Record<ThemeColorStateToneKey, ThemeColorElement>
|
|
28
28
|
|
|
29
|
+
/** @public */
|
|
29
30
|
export type ThemeColorVariantKey = 'tinted' | 'solid'
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
/** @public */
|
|
33
33
|
export interface ThemeColorCard_v3 {
|
|
34
34
|
_hue: Hue
|
|
35
35
|
avatar: ThemeColorAvatar_v2
|
|
@@ -90,9 +90,11 @@ export interface ThemeColorCard_v3 {
|
|
|
90
90
|
variant: Record<ThemeColorVariantKey, ThemeColorVariant>
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/** @public */
|
|
93
94
|
export interface ThemeColorScheme_v3 {
|
|
94
95
|
card: Record<ThemeColorCardToneKey, ThemeColorCard_v3>
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
/** @public */
|
|
97
99
|
// color[scheme].card[cardTone][colorVariant][elementTone][property][level]
|
|
98
100
|
export type ThemeColor_v3 = Record<ThemeColorSchemeKey, ThemeColorScheme_v3>
|
|
@@ -3,14 +3,17 @@ import {ThemeColorSchemeKey} from '../../v2'
|
|
|
3
3
|
import {parseColor} from './parseColor'
|
|
4
4
|
import {ColorToken} from './token'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/** @public */
|
|
7
|
+
export type CSSVariableKey = `--${string}`
|
|
7
8
|
|
|
9
|
+
/** @public */
|
|
8
10
|
export interface RenderColorContext {
|
|
9
11
|
bgVar: CSSVariableKey
|
|
10
12
|
hue: Hue
|
|
11
13
|
scheme: ThemeColorSchemeKey
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** @public */
|
|
14
17
|
export function renderColor(token: [ColorToken, ColorToken], context: RenderColorContext): string {
|
|
15
18
|
const {bgVar, hue, scheme} = context
|
|
16
19
|
|
|
@@ -53,47 +53,47 @@ function resolveCardColorTokens(
|
|
|
53
53
|
gray: {
|
|
54
54
|
_hue: tokens?.avatar?.gray?._hue ?? 'gray',
|
|
55
55
|
bg: tokens?.avatar?.gray?.bg ?? ['400', '500'],
|
|
56
|
-
fg: tokens?.avatar?.gray?.fg ?? ['900', '
|
|
56
|
+
fg: tokens?.avatar?.gray?.fg ?? ['900', 'white'],
|
|
57
57
|
},
|
|
58
58
|
blue: {
|
|
59
59
|
_hue: tokens?.avatar?.blue?._hue ?? 'blue',
|
|
60
60
|
bg: tokens?.avatar?.blue?.bg ?? ['400', '500'],
|
|
61
|
-
fg: tokens?.avatar?.blue?.fg ?? ['900', '
|
|
61
|
+
fg: tokens?.avatar?.blue?.fg ?? ['900', 'white'],
|
|
62
62
|
},
|
|
63
63
|
purple: {
|
|
64
64
|
_hue: tokens?.avatar?.purple?._hue ?? 'purple',
|
|
65
65
|
bg: tokens?.avatar?.purple?.bg ?? ['400', '500'],
|
|
66
|
-
fg: tokens?.avatar?.purple?.fg ?? ['900', '
|
|
66
|
+
fg: tokens?.avatar?.purple?.fg ?? ['900', 'white'],
|
|
67
67
|
},
|
|
68
68
|
magenta: {
|
|
69
69
|
_hue: tokens?.avatar?.magenta?._hue ?? 'magenta',
|
|
70
70
|
bg: tokens?.avatar?.magenta?.bg ?? ['400', '500'],
|
|
71
|
-
fg: tokens?.avatar?.magenta?.fg ?? ['900', '
|
|
71
|
+
fg: tokens?.avatar?.magenta?.fg ?? ['900', 'white'],
|
|
72
72
|
},
|
|
73
73
|
red: {
|
|
74
74
|
_hue: tokens?.avatar?.red?._hue ?? 'red',
|
|
75
75
|
bg: tokens?.avatar?.red?.bg ?? ['400', '500'],
|
|
76
|
-
fg: tokens?.avatar?.red?.fg ?? ['900', '
|
|
76
|
+
fg: tokens?.avatar?.red?.fg ?? ['900', 'white'],
|
|
77
77
|
},
|
|
78
78
|
orange: {
|
|
79
79
|
_hue: tokens?.avatar?.orange?._hue ?? 'orange',
|
|
80
80
|
bg: tokens?.avatar?.orange?.bg ?? ['400', '500'],
|
|
81
|
-
fg: tokens?.avatar?.orange?.fg ?? ['900', '
|
|
81
|
+
fg: tokens?.avatar?.orange?.fg ?? ['900', 'white'],
|
|
82
82
|
},
|
|
83
83
|
yellow: {
|
|
84
84
|
_hue: tokens?.avatar?.yellow?._hue ?? 'yellow',
|
|
85
85
|
bg: tokens?.avatar?.yellow?.bg ?? ['400', '500'],
|
|
86
|
-
fg: tokens?.avatar?.yellow?.fg ?? ['900', '
|
|
86
|
+
fg: tokens?.avatar?.yellow?.fg ?? ['900', 'white'],
|
|
87
87
|
},
|
|
88
88
|
green: {
|
|
89
89
|
_hue: tokens?.avatar?.green?._hue ?? 'green',
|
|
90
90
|
bg: tokens?.avatar?.green?.bg ?? ['400', '500'],
|
|
91
|
-
fg: tokens?.avatar?.green?.fg ?? ['900', '
|
|
91
|
+
fg: tokens?.avatar?.green?.fg ?? ['900', 'white'],
|
|
92
92
|
},
|
|
93
93
|
cyan: {
|
|
94
94
|
_hue: tokens?.avatar?.cyan?._hue ?? 'cyan',
|
|
95
95
|
bg: tokens?.avatar?.cyan?.bg ?? ['400', '500'],
|
|
96
|
-
fg: tokens?.avatar?.cyan?.fg ?? ['900', '
|
|
96
|
+
fg: tokens?.avatar?.cyan?.fg ?? ['900', 'white'],
|
|
97
97
|
},
|
|
98
98
|
},
|
|
99
99
|
backdrop: tokens?.backdrop ?? ['900', '100'],
|
|
@@ -4,6 +4,7 @@ import {useEffect} from 'react'
|
|
|
4
4
|
import {_raf2} from './helpers'
|
|
5
5
|
import {useCard} from './primitives'
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
7
8
|
export function RootClassNames(props: {element: HTMLElement}) {
|
|
8
9
|
const {element} = props
|
|
9
10
|
const {scheme, tone} = useCard() ?? {}
|
|
@@ -39,3 +40,5 @@ export function RootClassNames(props: {element: HTMLElement}) {
|
|
|
39
40
|
|
|
40
41
|
return null
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
RootClassNames.displayName = 'RootClassNames'
|
package/src/ui/StyleTags.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import {compilePalette, compileSystem, compileTheme} from '@sanity/ui/css'
|
|
|
2
2
|
import {buildTheme_v3, RootTheme, Theme_v3} from '@sanity/ui/theme'
|
|
3
3
|
import {ReactNode} from 'react'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** @beta */
|
|
6
6
|
export function StyleTags(props: {theme?: Theme_v3}): ReactNode {
|
|
7
7
|
const {theme: themeProp} = props
|
|
8
8
|
|
|
@@ -22,3 +22,5 @@ export function StyleTags(props: {theme?: Theme_v3}): ReactNode {
|
|
|
22
22
|
</>
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
StyleTags.displayName = 'StyleTags'
|
|
@@ -4,18 +4,14 @@ import {ReactElement, ReactNode} from 'react'
|
|
|
4
4
|
import {ThemeProvider} from './themeProvider'
|
|
5
5
|
import {useRootTheme} from './useRootTheme'
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
7
|
+
/** @public */
|
|
10
8
|
export interface ThemeColorProviderProps {
|
|
11
9
|
children?: ReactNode
|
|
12
10
|
scheme?: ThemeColorSchemeKey
|
|
13
11
|
tone?: ThemeColorCardToneKey
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
14
|
+
/** @public */
|
|
19
15
|
export function ThemeColorProvider(props: ThemeColorProviderProps): ReactElement {
|
|
20
16
|
const {children, scheme, tone} = props
|
|
21
17
|
const root = useRootTheme()
|
|
@@ -13,9 +13,7 @@ import {ThemeColorProvider} from './themeColorProvider'
|
|
|
13
13
|
import {ThemeContext} from './themeContext'
|
|
14
14
|
import {ThemeContextValue} from './types'
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
16
|
+
/** @public */
|
|
19
17
|
export interface ThemeProviderProps {
|
|
20
18
|
children?: ReactNode
|
|
21
19
|
scheme?: ThemeColorSchemeKey
|
|
@@ -23,9 +21,7 @@ export interface ThemeProviderProps {
|
|
|
23
21
|
tone?: ThemeColorCardToneKey
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
24
|
+
/** @public */
|
|
29
25
|
export function ThemeProvider(props: ThemeProviderProps): ReactElement {
|
|
30
26
|
const parentTheme = useContext(ThemeContext)
|
|
31
27
|
const {children} = props
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import {getTheme_v2, Theme, Theme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {useTheme as useStyledTheme} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
4
|
+
/** @public */
|
|
7
5
|
export function useTheme(): Theme {
|
|
8
6
|
return useStyledTheme() as Theme
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
9
|
+
/** @public */
|
|
14
10
|
export function useTheme_v2(): Theme_v2 {
|
|
15
11
|
return getTheme_v2(useStyledTheme() as Theme)
|
|
16
12
|
}
|
|
@@ -83,13 +83,13 @@ function ConstrainedHeightExampleField({id, label}: {id: string; label: string})
|
|
|
83
83
|
},
|
|
84
84
|
popoverRef: React.Ref<HTMLDivElement>,
|
|
85
85
|
) => {
|
|
86
|
-
const {hidden, inputElement, ...
|
|
86
|
+
const {hidden, inputElement, ...rest} = popoverProps
|
|
87
87
|
|
|
88
88
|
if (hidden) return null
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<Popover
|
|
92
|
-
{...
|
|
92
|
+
{...rest}
|
|
93
93
|
arrow={false}
|
|
94
94
|
constrainSize
|
|
95
95
|
matchReferenceWidth
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import {ChevronDownIcon} from '@sanity/icons'
|
|
2
2
|
import {ResponsiveProp} from '@sanity/ui/css'
|
|
3
|
-
import {
|
|
3
|
+
import {Space} from '@sanity/ui/theme'
|
|
4
4
|
import {
|
|
5
|
-
ChangeEvent,
|
|
5
|
+
type ChangeEvent,
|
|
6
6
|
cloneElement,
|
|
7
|
-
ElementType,
|
|
8
|
-
FocusEvent,
|
|
9
|
-
ForwardedRef,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ReactElement,
|
|
14
|
-
ReactNode,
|
|
7
|
+
type ElementType,
|
|
8
|
+
type FocusEvent,
|
|
9
|
+
type ForwardedRef,
|
|
10
|
+
type KeyboardEvent,
|
|
11
|
+
type MouseEvent,
|
|
12
|
+
type ReactNode,
|
|
15
13
|
useCallback,
|
|
16
14
|
useEffect,
|
|
17
15
|
useImperativeHandle,
|
|
@@ -29,14 +27,14 @@ import {
|
|
|
29
27
|
Button,
|
|
30
28
|
Card,
|
|
31
29
|
Popover,
|
|
32
|
-
PopoverProps,
|
|
30
|
+
type PopoverProps,
|
|
33
31
|
Stack,
|
|
34
32
|
Text,
|
|
35
33
|
TextInput,
|
|
34
|
+
TextInputOwnProps,
|
|
36
35
|
} from '../../primitives'
|
|
37
|
-
// import {Selectable} from '../../primitives/_selectable'
|
|
38
36
|
import {AnimatedSpinnerIcon} from '../../primitives/spinner/animatedSpinnerIcon'
|
|
39
|
-
import {Props, Radius} from '../../types'
|
|
37
|
+
import type {ComponentType, Props, Radius} from '../../types'
|
|
40
38
|
import {AutocompleteOption} from './autocompleteOption'
|
|
41
39
|
import {autocompleteReducer} from './autocompleteReducer'
|
|
42
40
|
import {
|
|
@@ -44,58 +42,62 @@ import {
|
|
|
44
42
|
AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,
|
|
45
43
|
AUTOCOMPLETE_POPOVER_PLACEMENT,
|
|
46
44
|
} from './constants'
|
|
47
|
-
import {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
45
|
+
import type {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'
|
|
46
|
+
|
|
47
|
+
/** @public */
|
|
48
|
+
export const DEFAULT_AUTOCOMPLETE_ELEMENT = 'input'
|
|
49
|
+
|
|
50
|
+
/** @public */
|
|
51
|
+
export type AutocompleteOwnProps<O extends BaseAutocompleteOption = BaseAutocompleteOption> =
|
|
52
|
+
TextInputOwnProps & {
|
|
53
|
+
border?: boolean
|
|
54
|
+
customValidity?: string
|
|
55
|
+
filterOption?: (query: string, option: O) => boolean
|
|
56
|
+
icon?: ElementType | ReactNode
|
|
57
|
+
/** @beta */
|
|
58
|
+
listBox?: BoxProps
|
|
59
|
+
loading?: boolean
|
|
60
|
+
onChange?: (value: string) => void
|
|
61
|
+
onQueryChange?: (query: string | null) => void
|
|
62
|
+
onSelect?: (value: string) => void
|
|
63
|
+
/** @beta */
|
|
64
|
+
openButton?: boolean | AutocompleteOpenButtonProps
|
|
65
|
+
/** @beta */
|
|
66
|
+
openOnFocus?: boolean
|
|
67
|
+
/** The options to render. */
|
|
68
|
+
options?: O[]
|
|
69
|
+
padding?: ResponsiveProp<Space>
|
|
70
|
+
popover?: Omit<Props<PopoverProps, 'div'>, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'>
|
|
71
|
+
prefix?: ReactNode
|
|
72
|
+
radius?: Radius | Radius[]
|
|
73
|
+
/** @beta */
|
|
74
|
+
relatedElements?: HTMLElement[]
|
|
75
|
+
/** The callback function for rendering each option. */
|
|
76
|
+
renderOption?: (option: O) => React.JSX.Element
|
|
77
|
+
/** @beta */
|
|
78
|
+
renderPopover?: (
|
|
79
|
+
props: {
|
|
80
|
+
content: React.JSX.Element | null
|
|
81
|
+
hidden: boolean
|
|
82
|
+
inputElement: HTMLInputElement | null
|
|
83
|
+
onMouseEnter: () => void
|
|
84
|
+
onMouseLeave: () => void
|
|
85
|
+
},
|
|
86
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
87
|
+
) => ReactNode
|
|
88
|
+
renderValue?: (value: string, option?: O) => string
|
|
89
|
+
suffix?: ReactNode
|
|
90
|
+
value?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** @public */
|
|
94
|
+
export type AutocompleteElementType = 'input' | ComponentType
|
|
95
|
+
|
|
96
|
+
/** @public */
|
|
97
|
+
export type AutocompleteProps<
|
|
98
|
+
E extends AutocompleteElementType = AutocompleteElementType,
|
|
99
|
+
O extends BaseAutocompleteOption = BaseAutocompleteOption,
|
|
100
|
+
> = Props<AutocompleteOwnProps<O>, E>
|
|
99
101
|
|
|
100
102
|
const DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>
|
|
101
103
|
option ? option.value : value
|
|
@@ -103,27 +105,18 @@ const DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>
|
|
|
103
105
|
const DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>
|
|
104
106
|
option.value.toLowerCase().indexOf(query.toLowerCase()) > -1
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
| 'autoCapitalize'
|
|
117
|
-
| 'autoComplete'
|
|
118
|
-
| 'autoCorrect'
|
|
119
|
-
| 'inputMode'
|
|
120
|
-
| 'role'
|
|
121
|
-
| 'spellCheck'
|
|
122
|
-
| 'type'
|
|
123
|
-
>,
|
|
124
|
-
forwardedRef: ForwardedRef<HTMLInputElement>,
|
|
125
|
-
) {
|
|
108
|
+
/**
|
|
109
|
+
* The Autocomplete component is typically used for search components.
|
|
110
|
+
* It consists of a text input for writing a query, and properties for rendering suggestions.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export function Autocomplete<
|
|
115
|
+
E extends AutocompleteElementType = typeof DEFAULT_AUTOCOMPLETE_ELEMENT,
|
|
116
|
+
O extends BaseAutocompleteOption = BaseAutocompleteOption,
|
|
117
|
+
>(props: AutocompleteProps<E, O>) {
|
|
126
118
|
const {
|
|
119
|
+
as = DEFAULT_AUTOCOMPLETE_ELEMENT,
|
|
127
120
|
border = true,
|
|
128
121
|
customValidity,
|
|
129
122
|
disabled,
|
|
@@ -146,14 +139,15 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
146
139
|
prefix,
|
|
147
140
|
radius = 2,
|
|
148
141
|
readOnly,
|
|
142
|
+
ref: forwardedRef,
|
|
149
143
|
relatedElements,
|
|
150
144
|
renderOption: renderOptionProp,
|
|
151
145
|
renderPopover,
|
|
152
146
|
renderValue = DEFAULT_RENDER_VALUE,
|
|
153
147
|
suffix,
|
|
154
148
|
value: valueProp,
|
|
155
|
-
...
|
|
156
|
-
} = props
|
|
149
|
+
...rest
|
|
150
|
+
} = props as AutocompleteProps<typeof DEFAULT_AUTOCOMPLETE_ELEMENT, O>
|
|
157
151
|
|
|
158
152
|
const [state, dispatch] = useReducer(autocompleteReducer, {
|
|
159
153
|
activeValue: valueProp || null,
|
|
@@ -186,7 +180,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
186
180
|
const rootElementRef = useRef<HTMLDivElement | null>(null)
|
|
187
181
|
const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)
|
|
188
182
|
const inputElementRef = useRef<HTMLInputElement | null>(null)
|
|
189
|
-
const listBoxElementRef = useRef<
|
|
183
|
+
const listBoxElementRef = useRef<HTMLUListElement | null>(null)
|
|
190
184
|
|
|
191
185
|
// Value refs
|
|
192
186
|
const listFocusedRef = useRef(false)
|
|
@@ -535,7 +529,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
535
529
|
|
|
536
530
|
const input = (
|
|
537
531
|
<TextInput
|
|
538
|
-
{...
|
|
532
|
+
{...rest}
|
|
539
533
|
aria-activedescendant={activeItemId}
|
|
540
534
|
aria-autocomplete="list"
|
|
541
535
|
aria-expanded={expanded}
|
|
@@ -543,6 +537,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
543
537
|
autoCapitalize="off"
|
|
544
538
|
autoComplete="off"
|
|
545
539
|
autoCorrect="off"
|
|
540
|
+
as={as}
|
|
546
541
|
border={border}
|
|
547
542
|
clearButton={clearButton}
|
|
548
543
|
customValidity={customValidity}
|
|
@@ -694,29 +689,6 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
694
689
|
{results}
|
|
695
690
|
</div>
|
|
696
691
|
)
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
InnerAutocomplete.displayName = 'ForwardRef(Autocomplete)'
|
|
692
|
+
}
|
|
700
693
|
|
|
701
|
-
|
|
702
|
-
* The Autocomplete component is typically used for search components.
|
|
703
|
-
* It consists of a text input for writing a query, and properties for rendering suggestions.
|
|
704
|
-
*
|
|
705
|
-
* @public
|
|
706
|
-
*/
|
|
707
|
-
export const Autocomplete = InnerAutocomplete as <Option extends BaseAutocompleteOption>(
|
|
708
|
-
props: Omit<
|
|
709
|
-
Props<AutocompleteProps<Option>, 'input'>,
|
|
710
|
-
| 'aria-activedescendant'
|
|
711
|
-
| 'aria-autocomplete'
|
|
712
|
-
| 'aria-expanded'
|
|
713
|
-
| 'aria-owns'
|
|
714
|
-
| 'autoCapitalize'
|
|
715
|
-
| 'autoComplete'
|
|
716
|
-
| 'autoCorrect'
|
|
717
|
-
| 'inputMode'
|
|
718
|
-
| 'role'
|
|
719
|
-
| 'spellCheck'
|
|
720
|
-
| 'type'
|
|
721
|
-
>,
|
|
722
|
-
) => ReactElement
|
|
694
|
+
Autocomplete.displayName = 'Autocomplete'
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import {ButtonProps} from '../../primitives'
|
|
2
|
-
import {Props} from '../../types'
|
|
3
2
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export type AutocompleteOpenButtonProps = Omit<Props<ButtonProps, 'button'>, 'as'>
|
|
3
|
+
/** @public */
|
|
4
|
+
export type AutocompleteOpenButtonProps = Omit<ButtonProps<'button'>, 'as'>
|
|
8
5
|
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
6
|
+
/** @public */
|
|
12
7
|
export interface BaseAutocompleteOption {
|
|
13
8
|
value: string
|
|
14
9
|
}
|