@sanity/ui 0.37.10 → 0.37.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/lib/dts/src/components/autocomplete/autocomplete.d.ts +2 -2
- package/lib/dts/src/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/lib/dts/src/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
- package/lib/dts/src/components/autocomplete/constants.d.ts +0 -4
- package/lib/dts/src/components/autocomplete/constants.d.ts.map +1 -1
- package/lib/dts/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/lib/dts/src/components/dialog/dialog.d.ts.map +1 -1
- package/lib/dts/src/components/dialog/styles.d.ts +1 -1
- package/lib/dts/src/components/dialog/styles.d.ts.map +1 -1
- package/lib/dts/src/components/hotkeys/hotkeys.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuButton.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuGroup.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuItem.d.ts.map +1 -1
- package/lib/dts/src/components/skeleton/skeleton.d.ts.map +1 -1
- package/lib/dts/src/hooks/_internal/useUnique.d.ts +2 -3
- package/lib/dts/src/hooks/_internal/useUnique.d.ts.map +1 -1
- package/lib/dts/src/hooks/index.d.ts +2 -1
- package/lib/dts/src/hooks/index.d.ts.map +1 -1
- package/lib/dts/src/hooks/useArrayProp.d.ts +7 -0
- package/lib/dts/src/hooks/useArrayProp.d.ts.map +1 -0
- package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts +1 -1
- package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts.map +1 -1
- package/lib/dts/src/hooks/useElementSize.d.ts +7 -0
- package/lib/dts/src/hooks/useElementSize.d.ts.map +1 -0
- package/lib/dts/src/index.d.ts +1 -0
- package/lib/dts/src/index.d.ts.map +1 -1
- package/lib/dts/src/observers/elementSizeObserver.d.ts +37 -0
- package/lib/dts/src/observers/elementSizeObserver.d.ts.map +1 -0
- package/lib/dts/src/observers/index.d.ts +3 -0
- package/lib/dts/src/observers/index.d.ts.map +1 -0
- package/lib/dts/src/observers/resizeObserver.d.ts +5 -0
- package/lib/dts/src/observers/resizeObserver.d.ts.map +1 -0
- package/lib/dts/src/primitives/_selectable/selectable.d.ts +1 -2
- package/lib/dts/src/primitives/_selectable/selectable.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatar.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatarCounter.d.ts +1 -0
- package/lib/dts/src/primitives/avatar/avatarCounter.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatarStack.d.ts +1 -0
- package/lib/dts/src/primitives/avatar/avatarStack.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/badge/badge.d.ts.map +1 -1
- package/lib/dts/src/primitives/box/box.d.ts.map +1 -1
- package/lib/dts/src/primitives/button/button.d.ts.map +1 -1
- package/lib/dts/src/primitives/card/card.d.ts.map +1 -1
- package/lib/dts/src/primitives/code/code.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/container.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/types.d.ts +1 -1
- package/lib/dts/src/primitives/container/types.d.ts.map +1 -1
- package/lib/dts/src/primitives/flex/flex.d.ts.map +1 -1
- package/lib/dts/src/primitives/grid/grid.d.ts.map +1 -1
- package/lib/dts/src/primitives/heading/heading.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/inline.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/types.d.ts +1 -1
- package/lib/dts/src/primitives/inline/types.d.ts.map +1 -1
- package/lib/dts/src/primitives/kbd/kbd.d.ts.map +1 -1
- package/lib/dts/src/primitives/label/label.d.ts.map +1 -1
- package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
- package/lib/dts/src/primitives/select/styles.d.ts +5 -1
- package/lib/dts/src/primitives/select/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/stack/stack.d.ts.map +1 -1
- package/lib/dts/src/primitives/stack/styles.d.ts +1 -1
- package/lib/dts/src/primitives/stack/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/text/text.d.ts.map +1 -1
- package/lib/dts/src/primitives/textArea/textArea.d.ts.map +1 -1
- package/lib/dts/src/primitives/textInput/textInput.d.ts.map +1 -1
- package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
- package/lib/dts/src/primitives/types.d.ts +1 -1
- package/lib/dts/src/primitives/types.d.ts.map +1 -1
- package/lib/dts/src/styles/border/types.d.ts +5 -5
- package/lib/dts/src/styles/border/types.d.ts.map +1 -1
- package/lib/dts/src/styles/box/types.d.ts +4 -4
- package/lib/dts/src/styles/box/types.d.ts.map +1 -1
- package/lib/dts/src/styles/flex/flexItemStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/flex/types.d.ts +6 -6
- package/lib/dts/src/styles/flex/types.d.ts.map +1 -1
- package/lib/dts/src/styles/font/responsiveFont.d.ts +1 -1
- package/lib/dts/src/styles/font/responsiveFont.d.ts.map +1 -1
- package/lib/dts/src/styles/font/types.d.ts +3 -3
- package/lib/dts/src/styles/font/types.d.ts.map +1 -1
- package/lib/dts/src/styles/grid/types.d.ts +14 -14
- package/lib/dts/src/styles/grid/types.d.ts.map +1 -1
- package/lib/dts/src/styles/helpers.d.ts +4 -4
- package/lib/dts/src/styles/helpers.d.ts.map +1 -1
- package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts +12 -12
- package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/input/textInputStyle.d.ts +4 -1
- package/lib/dts/src/styles/input/textInputStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/margin/types.d.ts +7 -7
- package/lib/dts/src/styles/margin/types.d.ts.map +1 -1
- package/lib/dts/src/styles/padding/types.d.ts +7 -7
- package/lib/dts/src/styles/padding/types.d.ts.map +1 -1
- package/lib/dts/src/styles/radius/types.d.ts +1 -1
- package/lib/dts/src/styles/radius/types.d.ts.map +1 -1
- package/lib/dts/src/styles/shadow/shadowStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/shadow/types.d.ts +1 -1
- package/lib/dts/src/styles/shadow/types.d.ts.map +1 -1
- package/lib/dts/src/theme/lib/theme/fonts.d.ts +1 -3
- package/lib/dts/src/theme/lib/theme/fonts.d.ts.map +1 -1
- package/lib/dts/src/theme/studioTheme/fonts.d.ts.map +1 -1
- package/lib/dts/src/types/index.d.ts +2 -1
- package/lib/dts/src/types/index.d.ts.map +1 -1
- package/lib/dts/src/types/placement.d.ts +7 -0
- package/lib/dts/src/types/placement.d.ts.map +1 -0
- package/lib/dts/src/types/text.d.ts +5 -0
- package/lib/dts/src/types/text.d.ts.map +1 -0
- package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
- package/lib/dts/src/utils/index.d.ts +0 -1
- package/lib/dts/src/utils/index.d.ts.map +1 -1
- package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
- package/lib/sanity-ui.js +738 -627
- package/lib/sanity-ui.js.map +1 -1
- package/lib/{sanity-ui.modern.js → sanity-ui.modern.mjs} +736 -616
- package/lib/sanity-ui.modern.mjs.map +1 -0
- package/lib/sanity-ui.module.js +732 -623
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +11 -11
- package/src/__workshop__/color/overview.tsx +9 -11
- package/src/components/autocomplete/__workshop__/async.tsx +14 -12
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +36 -0
- package/src/components/autocomplete/autocomplete.styles.tsx +0 -1
- package/src/components/autocomplete/autocomplete.tsx +14 -7
- package/src/components/autocomplete/constants.ts +0 -5
- package/src/components/breadcrumbs/breadcrumbs.tsx +3 -2
- package/src/components/dialog/dialog.tsx +17 -9
- package/src/components/dialog/styles.ts +3 -3
- package/src/components/hotkeys/hotkeys.tsx +3 -1
- package/src/components/menu/__workshop__/constrainedInBoundary.tsx +11 -14
- package/src/components/menu/__workshop__/groups.tsx +1 -1
- package/src/components/menu/menuButton.tsx +21 -13
- package/src/components/menu/menuGroup.tsx +3 -2
- package/src/components/menu/menuItem.tsx +4 -5
- package/src/components/skeleton/skeleton.tsx +10 -1
- package/src/components/skeleton/textSkeleton.tsx +7 -7
- package/src/hooks/_internal/useUnique.ts +4 -5
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useArrayProp.ts +23 -0
- package/src/hooks/useElementRect/useElementRect.ts +4 -16
- package/src/hooks/useElementSize.ts +18 -0
- package/src/index.ts +1 -0
- package/src/observers/elementSizeObserver.ts +116 -0
- package/src/observers/index.ts +2 -0
- package/src/{utils → observers}/resizeObserver.ts +1 -4
- package/src/primitives/_selectable/selectable.tsx +5 -4
- package/src/primitives/avatar/avatar.tsx +7 -5
- package/src/primitives/avatar/avatarCounter.tsx +14 -12
- package/src/primitives/avatar/avatarStack.tsx +19 -13
- package/src/primitives/avatar/styles.ts +2 -2
- package/src/primitives/badge/badge.tsx +3 -2
- package/src/primitives/box/box.tsx +27 -26
- package/src/primitives/button/button.tsx +22 -10
- package/src/primitives/card/card.tsx +13 -11
- package/src/primitives/checkbox/__workshop__/example.tsx +4 -2
- package/src/primitives/checkbox/__workshop__/props.tsx +4 -2
- package/src/primitives/checkbox/__workshop__/readOnly.tsx +4 -2
- package/src/primitives/code/__workshop__/props.tsx +1 -1
- package/src/primitives/code/code.tsx +2 -1
- package/src/primitives/container/container.tsx +10 -1
- package/src/primitives/container/styles.ts +2 -2
- package/src/primitives/container/types.ts +1 -1
- package/src/primitives/flex/flex.tsx +6 -5
- package/src/primitives/grid/__workshop__/responsive.tsx +13 -12
- package/src/primitives/grid/grid.tsx +9 -8
- package/src/primitives/heading/__workshop__/opticalAlignment.tsx +19 -7
- package/src/primitives/heading/heading.tsx +3 -2
- package/src/primitives/inline/inline.tsx +12 -6
- package/src/primitives/inline/styles.ts +2 -2
- package/src/primitives/inline/types.ts +1 -1
- package/src/primitives/kbd/kbd.tsx +2 -1
- package/src/primitives/label/label.tsx +4 -3
- package/src/primitives/popover/__workshop__/{margins.tsx → MarginsStory.tsx} +1 -1
- package/src/primitives/popover/__workshop__/{matchReferenceWidth.tsx → MatchReferenceWidthStory.tsx} +0 -0
- package/src/primitives/popover/__workshop__/{plain.tsx → PlainStory.tsx} +12 -14
- package/src/primitives/popover/__workshop__/{recursive.tsx → RecursiveStory.tsx} +4 -1
- package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +60 -0
- package/src/primitives/popover/__workshop__/TestStory.tsx +79 -0
- package/src/primitives/popover/__workshop__/index.ts +10 -5
- package/src/primitives/popover/popover.tsx +5 -3
- package/src/primitives/select/select.tsx +9 -9
- package/src/primitives/select/styles.ts +10 -4
- package/src/primitives/stack/stack.tsx +2 -1
- package/src/primitives/stack/styles.ts +3 -3
- package/src/primitives/text/__workshop__/opticalAlignment.tsx +15 -5
- package/src/primitives/text/text.tsx +3 -2
- package/src/primitives/textArea/__workshop__/plain.tsx +23 -18
- package/src/primitives/textArea/textArea.tsx +17 -5
- package/src/primitives/textInput/__workshop__/clearButton.tsx +14 -8
- package/src/primitives/textInput/__workshop__/index.ts +2 -2
- package/src/primitives/textInput/__workshop__/plain.tsx +39 -32
- package/src/primitives/textInput/__workshop__/tones.tsx +97 -75
- package/src/primitives/textInput/__workshop__/typed.tsx +8 -2
- package/src/primitives/textInput/textInput.tsx +43 -12
- package/src/primitives/tooltip/__workshop__/props.tsx +5 -1
- package/src/primitives/tooltip/tooltip.tsx +3 -2
- package/src/primitives/types.ts +1 -1
- package/src/styles/border/borderStyle.ts +6 -6
- package/src/styles/border/types.ts +5 -5
- package/src/styles/box/boxStyle.ts +5 -5
- package/src/styles/box/types.ts +4 -4
- package/src/styles/flex/flexItemStyle.ts +5 -4
- package/src/styles/flex/flexStyle.ts +6 -6
- package/src/styles/flex/types.ts +6 -6
- package/src/styles/font/responsiveFont.ts +7 -27
- package/src/styles/font/textAlignStyle.ts +2 -2
- package/src/styles/font/types.ts +4 -3
- package/src/styles/grid/gridItemStyle.ts +7 -7
- package/src/styles/grid/gridStyle.ts +9 -9
- package/src/styles/grid/types.ts +14 -14
- package/src/styles/helpers.ts +9 -9
- package/src/styles/input/responsiveInputPaddingStyle.ts +24 -27
- package/src/styles/input/textInputStyle.ts +89 -79
- package/src/styles/margin/marginStyle.ts +8 -8
- package/src/styles/margin/marginsStyle.test.ts +1 -1
- package/src/styles/margin/types.ts +7 -7
- package/src/styles/padding/paddingStyle.test.ts +1 -1
- package/src/styles/padding/paddingStyle.ts +8 -8
- package/src/styles/padding/types.ts +7 -7
- package/src/styles/radius/radiusStyle.ts +2 -2
- package/src/styles/radius/types.ts +1 -1
- package/src/styles/shadow/shadowStyle.ts +2 -5
- package/src/styles/shadow/types.ts +1 -1
- package/src/theme/lib/theme/fonts.ts +1 -3
- package/src/theme/studioTheme/fonts.ts +5 -9
- package/src/types/index.ts +2 -2
- package/src/types/placement.ts +18 -0
- package/src/types/text.ts +4 -0
- package/src/utils/elementQuery/elementQuery.tsx +5 -18
- package/src/utils/index.ts +0 -1
- package/src/utils/layer/layer.tsx +1 -1
- package/src/utils/layer/layerProvider.tsx +2 -2
- package/src/utils/virtualList/virtualList.tsx +8 -7
- package/lib/dts/src/hooks/useResponsiveProp.d.ts +0 -6
- package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +0 -1
- package/lib/dts/src/types/common.d.ts +0 -11
- package/lib/dts/src/types/common.d.ts.map +0 -1
- package/lib/dts/src/utils/resizeObserver.d.ts +0 -6
- package/lib/dts/src/utils/resizeObserver.d.ts.map +0 -1
- package/lib/sanity-ui.modern.js.map +0 -1
- package/src/hooks/useResponsiveProp.ts +0 -10
- package/src/primitives/popover/__workshop__/rightAligned.tsx +0 -57
- package/src/types/common.ts +0 -12
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {css, CSSObject, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {ThemeFontWeightKey} from '../../theme'
|
|
3
|
+
import {CardTone} from '../../types'
|
|
3
4
|
import {focusRingBorderStyle, focusRingStyle} from '../focusRing'
|
|
4
|
-
import {
|
|
5
|
+
import {rem, _responsive} from '../helpers'
|
|
5
6
|
import {ThemeProps} from '../types'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @internal
|
|
9
10
|
*/
|
|
10
11
|
export interface TextInputInputStyleProps {
|
|
11
|
-
$fontSize
|
|
12
|
+
$fontSize: number[]
|
|
13
|
+
$tone: CardTone
|
|
12
14
|
$weight?: ThemeFontWeightKey
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -19,6 +21,7 @@ export interface TextInputRepresentationStyleProps {
|
|
|
19
21
|
$border?: boolean
|
|
20
22
|
$hasPrefix?: boolean
|
|
21
23
|
$hasSuffix?: boolean
|
|
24
|
+
$tone: CardTone
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
const ROOT_STYLE = css`
|
|
@@ -36,14 +39,11 @@ export function textInputRootStyle(): FlattenSimpleInterpolation {
|
|
|
36
39
|
export function textInputBaseStyle(
|
|
37
40
|
props: TextInputInputStyleProps & ThemeProps
|
|
38
41
|
): FlattenSimpleInterpolation {
|
|
39
|
-
const {theme, $weight} = props
|
|
42
|
+
const {theme, $tone, $weight} = props
|
|
40
43
|
const font = theme.sanity.fonts.text
|
|
41
44
|
const color = theme.sanity.color.input
|
|
42
45
|
|
|
43
46
|
return css`
|
|
44
|
-
--input-fg-color: ${color.default.enabled.fg};
|
|
45
|
-
--input-placeholder-color: ${color.default.enabled.placeholder};
|
|
46
|
-
|
|
47
47
|
appearance: none;
|
|
48
48
|
background: none;
|
|
49
49
|
border: 0;
|
|
@@ -57,7 +57,6 @@ export function textInputBaseStyle(
|
|
|
57
57
|
position: relative;
|
|
58
58
|
z-index: 1;
|
|
59
59
|
display: block;
|
|
60
|
-
color: var(--input-fg-color);
|
|
61
60
|
|
|
62
61
|
/* NOTE: This is a hack to disable Chrome’s autofill styles */
|
|
63
62
|
&:-webkit-autofill,
|
|
@@ -69,37 +68,44 @@ export function textInputBaseStyle(
|
|
|
69
68
|
transition-delay: 86400s /* 24h */;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
&::placeholder {
|
|
73
|
-
color: var(--input-placeholder-color);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
71
|
/* &:is(textarea) */
|
|
77
72
|
&[data-as='textarea'] {
|
|
78
73
|
resize: none;
|
|
79
74
|
}
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
color: var(--input-fg-color);
|
|
77
|
+
|
|
78
|
+
&::placeholder {
|
|
79
|
+
color: var(--input-placeholder-color);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&[data-tone='${$tone}'] {
|
|
83
83
|
--input-fg-color: ${color.default.enabled.fg};
|
|
84
84
|
--input-placeholder-color: ${color.default.enabled.placeholder};
|
|
85
|
-
}
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
/* enabled */
|
|
87
|
+
&:not(:invalid):not(:disabled):not(:read-only) {
|
|
88
|
+
--input-fg-color: ${color.default.enabled.fg};
|
|
89
|
+
--input-placeholder-color: ${color.default.enabled.placeholder};
|
|
90
|
+
}
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
/* disabled */
|
|
93
|
+
&:not(:invalid):disabled {
|
|
94
|
+
--input-fg-color: ${color.default.disabled.fg};
|
|
95
|
+
--input-placeholder-color: ${color.default.disabled.placeholder};
|
|
96
|
+
}
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
/* invalid */
|
|
99
|
+
&:invalid {
|
|
100
|
+
--input-fg-color: ${color.invalid.enabled.fg};
|
|
101
|
+
--input-placeholder-color: ${color.invalid.enabled.placeholder};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* readOnly */
|
|
105
|
+
&:read-only {
|
|
106
|
+
--input-fg-color: ${color.default.readOnly.fg};
|
|
107
|
+
--input-placeholder-color: ${color.default.readOnly.placeholder};
|
|
108
|
+
}
|
|
103
109
|
}
|
|
104
110
|
`
|
|
105
111
|
}
|
|
@@ -108,7 +114,7 @@ export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemePr
|
|
|
108
114
|
const {theme} = props
|
|
109
115
|
const {fonts, media} = theme.sanity
|
|
110
116
|
|
|
111
|
-
return
|
|
117
|
+
return _responsive(media, props.$fontSize, (sizeIndex) => {
|
|
112
118
|
const size = fonts.text.sizes[sizeIndex] || fonts.text.sizes[2]
|
|
113
119
|
|
|
114
120
|
return {
|
|
@@ -121,13 +127,11 @@ export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemePr
|
|
|
121
127
|
export function textInputRepresentationStyle(
|
|
122
128
|
props: TextInputRepresentationStyleProps & ThemeProps
|
|
123
129
|
): FlattenSimpleInterpolation {
|
|
124
|
-
const {$border, $hasPrefix, $hasSuffix, theme} = props
|
|
130
|
+
const {$border, $hasPrefix, $hasSuffix, $tone, theme} = props
|
|
125
131
|
const {focusRing, input} = theme.sanity
|
|
126
132
|
const color = theme.sanity.color.input
|
|
127
133
|
|
|
128
134
|
return css`
|
|
129
|
-
--card-bg-color: ${color.default.enabled.bg};
|
|
130
|
-
--card-fg-color: ${color.default.enabled.fg};
|
|
131
135
|
--input-box-shadow: none;
|
|
132
136
|
|
|
133
137
|
position: absolute;
|
|
@@ -138,6 +142,7 @@ export function textInputRepresentationStyle(
|
|
|
138
142
|
display: block;
|
|
139
143
|
pointer-events: none;
|
|
140
144
|
z-index: 0;
|
|
145
|
+
|
|
141
146
|
background-color: var(--card-bg-color);
|
|
142
147
|
box-shadow: var(--input-box-shadow);
|
|
143
148
|
|
|
@@ -146,65 +151,70 @@ export function textInputRepresentationStyle(
|
|
|
146
151
|
border-top-right-radius: ${$hasSuffix ? 0 : undefined};
|
|
147
152
|
border-bottom-right-radius: ${$hasSuffix ? 0 : undefined};
|
|
148
153
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
--
|
|
152
|
-
? focusRingBorderStyle({color: color.default.enabled.border, width: input.border.width})
|
|
153
|
-
: undefined};
|
|
154
|
-
}
|
|
154
|
+
&[data-tone='${$tone}'] {
|
|
155
|
+
--card-bg-color: ${color.default.enabled.bg};
|
|
156
|
+
--card-fg-color: ${color.default.enabled.fg};
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
: 'none'};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* focused */
|
|
166
|
-
*:not(:disabled):focus + && {
|
|
167
|
-
--input-box-shadow: ${focusRingStyle({
|
|
168
|
-
border: $border
|
|
169
|
-
? {color: color.default.enabled.border, width: input.border.width}
|
|
170
|
-
: undefined,
|
|
171
|
-
focusRing,
|
|
172
|
-
})};
|
|
173
|
-
}
|
|
158
|
+
/* enabled */
|
|
159
|
+
*:not(:disabled) + & {
|
|
160
|
+
--input-box-shadow: ${$border
|
|
161
|
+
? focusRingBorderStyle({color: color.default.enabled.border, width: input.border.width})
|
|
162
|
+
: undefined};
|
|
163
|
+
}
|
|
174
164
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
})
|
|
184
|
-
: 'none'};
|
|
185
|
-
}
|
|
165
|
+
/* invalid */
|
|
166
|
+
*:not(:disabled):invalid + & {
|
|
167
|
+
--card-bg-color: ${color.invalid.enabled.bg};
|
|
168
|
+
--card-fg-color: ${color.invalid.enabled.fg};
|
|
169
|
+
--input-box-shadow: ${$border
|
|
170
|
+
? focusRingBorderStyle({color: color.invalid.enabled.border, width: input.border.width})
|
|
171
|
+
: 'none'};
|
|
172
|
+
}
|
|
186
173
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
174
|
+
/* focused */
|
|
175
|
+
*:not(:disabled):focus + & {
|
|
176
|
+
--input-box-shadow: ${focusRingStyle({
|
|
177
|
+
border: $border
|
|
178
|
+
? {color: color.default.enabled.border, width: input.border.width}
|
|
179
|
+
: undefined,
|
|
180
|
+
focusRing,
|
|
181
|
+
})};
|
|
192
182
|
}
|
|
193
183
|
|
|
194
|
-
|
|
184
|
+
/* disabled */
|
|
185
|
+
*:disabled + & {
|
|
186
|
+
--card-bg-color: ${color.default.disabled.bg} !important;
|
|
187
|
+
--card-fg-color: ${color.default.disabled.fg} !important;
|
|
195
188
|
--input-box-shadow: ${$border
|
|
196
189
|
? focusRingBorderStyle({
|
|
197
|
-
color: color.default.
|
|
190
|
+
color: color.default.disabled.border,
|
|
198
191
|
width: input.border.width,
|
|
199
192
|
})
|
|
200
193
|
: 'none'};
|
|
201
194
|
}
|
|
202
|
-
}
|
|
203
195
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
/* readOnly */
|
|
197
|
+
*:read-only + & {
|
|
198
|
+
--card-bg-color: ${color.default.readOnly.bg} !important;
|
|
199
|
+
--card-fg-color: ${color.default.readOnly.fg} !important;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* hovered */
|
|
203
|
+
@media (hover: hover) {
|
|
204
|
+
*:not(:disabled):not(:read-only):not(:invalid):hover + & {
|
|
205
|
+
--card-bg-color: ${color.default.hovered.bg};
|
|
206
|
+
--card-fg-color: ${color.default.hovered.fg};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
*:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + & {
|
|
210
|
+
--input-box-shadow: ${$border
|
|
211
|
+
? focusRingBorderStyle({
|
|
212
|
+
color: color.default.hovered.border,
|
|
213
|
+
width: input.border.width,
|
|
214
|
+
})
|
|
215
|
+
: 'none'};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
208
218
|
}
|
|
209
219
|
`
|
|
210
220
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {
|
|
2
|
+
import {_getResponsiveSpace} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveMarginStyleProps} from './types'
|
|
5
5
|
|
|
@@ -9,12 +9,12 @@ export function responsiveMarginStyle(
|
|
|
9
9
|
const {theme} = props
|
|
10
10
|
|
|
11
11
|
return [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
_getResponsiveSpace(theme, ['margin'], props.$margin),
|
|
13
|
+
_getResponsiveSpace(theme, ['marginLeft', 'marginRight'], props.$marginX),
|
|
14
|
+
_getResponsiveSpace(theme, ['marginTop', 'marginBottom'], props.$marginY),
|
|
15
|
+
_getResponsiveSpace(theme, ['marginTop'], props.$marginTop),
|
|
16
|
+
_getResponsiveSpace(theme, ['marginRight'], props.$marginRight),
|
|
17
|
+
_getResponsiveSpace(theme, ['marginBottom'], props.$marginBottom),
|
|
18
|
+
_getResponsiveSpace(theme, ['marginLeft'], props.$marginLeft),
|
|
19
19
|
].filter(Boolean) as CSSObject[][]
|
|
20
20
|
}
|
|
@@ -6,7 +6,7 @@ const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
|
|
|
6
6
|
|
|
7
7
|
describe('styles/margin', () => {
|
|
8
8
|
it('should 1', () => {
|
|
9
|
-
const styles = responsiveMarginStyle({$margin: 0, theme})
|
|
9
|
+
const styles = responsiveMarginStyle({$margin: [0], theme})
|
|
10
10
|
|
|
11
11
|
expect(styles).toEqual([[{margin: 0}]])
|
|
12
12
|
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface ResponsiveMarginStyleProps {
|
|
2
|
-
$margin?: number
|
|
3
|
-
$marginX?: number
|
|
4
|
-
$marginY?: number
|
|
5
|
-
$marginTop?: number
|
|
6
|
-
$marginRight?: number
|
|
7
|
-
$marginBottom?: number
|
|
8
|
-
$marginLeft?: number
|
|
2
|
+
$margin?: number[]
|
|
3
|
+
$marginX?: number[]
|
|
4
|
+
$marginY?: number[]
|
|
5
|
+
$marginTop?: number[]
|
|
6
|
+
$marginRight?: number[]
|
|
7
|
+
$marginBottom?: number[]
|
|
8
|
+
$marginLeft?: number[]
|
|
9
9
|
}
|
|
@@ -6,7 +6,7 @@ const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
|
|
|
6
6
|
|
|
7
7
|
describe('styles/padding', () => {
|
|
8
8
|
it('should 1', () => {
|
|
9
|
-
const styles = responsivePaddingStyle({$padding: 0, theme})
|
|
9
|
+
const styles = responsivePaddingStyle({$padding: [0], theme})
|
|
10
10
|
|
|
11
11
|
expect(styles).toEqual([[{padding: 0}]])
|
|
12
12
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {
|
|
2
|
+
import {_getResponsiveSpace} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsivePaddingStyleProps} from './types'
|
|
5
5
|
|
|
@@ -9,12 +9,12 @@ export function responsivePaddingStyle(
|
|
|
9
9
|
const {theme} = props
|
|
10
10
|
|
|
11
11
|
return [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
_getResponsiveSpace(theme, ['padding'], props.$padding),
|
|
13
|
+
_getResponsiveSpace(theme, ['paddingLeft', 'paddingRight'], props.$paddingX),
|
|
14
|
+
_getResponsiveSpace(theme, ['paddingTop', 'paddingBottom'], props.$paddingY),
|
|
15
|
+
_getResponsiveSpace(theme, ['paddingTop'], props.$paddingTop),
|
|
16
|
+
_getResponsiveSpace(theme, ['paddingRight'], props.$paddingRight),
|
|
17
|
+
_getResponsiveSpace(theme, ['paddingBottom'], props.$paddingBottom),
|
|
18
|
+
_getResponsiveSpace(theme, ['paddingLeft'], props.$paddingLeft),
|
|
19
19
|
].filter(Boolean) as CSSObject[][]
|
|
20
20
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
4
|
export interface ResponsivePaddingStyleProps {
|
|
5
|
-
$padding?: number
|
|
6
|
-
$paddingX?: number
|
|
7
|
-
$paddingY?: number
|
|
8
|
-
$paddingTop?: number
|
|
9
|
-
$paddingRight?: number
|
|
10
|
-
$paddingBottom?: number
|
|
11
|
-
$paddingLeft?: number
|
|
5
|
+
$padding?: number[]
|
|
6
|
+
$paddingX?: number[]
|
|
7
|
+
$paddingY?: number[]
|
|
8
|
+
$paddingTop?: number[]
|
|
9
|
+
$paddingRight?: number[]
|
|
10
|
+
$paddingBottom?: number[]
|
|
11
|
+
$paddingLeft?: number[]
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {
|
|
2
|
+
import {rem, _responsive} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveRadiusStyleProps} from './types'
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ export function responsiveRadiusStyle(props: ResponsiveRadiusStyleProps & ThemeP
|
|
|
7
7
|
const {theme} = props
|
|
8
8
|
const {media, radius} = theme.sanity
|
|
9
9
|
|
|
10
|
-
return
|
|
10
|
+
return _responsive(media, props.$radius, (radiusIndex) => ({
|
|
11
11
|
borderRadius: rem(radius[radiusIndex]),
|
|
12
12
|
}))
|
|
13
13
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {getResponsiveProp} from '..'
|
|
3
2
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
3
|
import {BoxShadow, ThemeShadow} from '../../theme'
|
|
5
|
-
import {rem,
|
|
4
|
+
import {rem, _responsive} from '../helpers'
|
|
6
5
|
import {ThemeProps} from '../types'
|
|
7
6
|
import {ResponsiveShadowStyleProps} from './types'
|
|
8
7
|
|
|
@@ -25,7 +24,5 @@ export function responsiveShadowStyle(props: ResponsiveShadowStyleProps & ThemeP
|
|
|
25
24
|
const {theme} = props
|
|
26
25
|
const {media, shadows} = theme.sanity
|
|
27
26
|
|
|
28
|
-
return
|
|
29
|
-
shadowStyle(shadows[shadow])
|
|
30
|
-
)
|
|
27
|
+
return _responsive(media, props.$shadow, (shadow) => shadowStyle(shadows[shadow]))
|
|
31
28
|
}
|
|
@@ -2,8 +2,7 @@ import {ThemeFonts} from '../lib/theme'
|
|
|
2
2
|
|
|
3
3
|
export const fonts: ThemeFonts = {
|
|
4
4
|
code: {
|
|
5
|
-
family: '
|
|
6
|
-
horizontalOffset: 0.075,
|
|
5
|
+
family: 'ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace',
|
|
7
6
|
weights: {
|
|
8
7
|
regular: 400,
|
|
9
8
|
medium: 500,
|
|
@@ -56,7 +55,6 @@ export const fonts: ThemeFonts = {
|
|
|
56
55
|
heading: {
|
|
57
56
|
family:
|
|
58
57
|
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
|
|
59
|
-
horizontalOffset: 0.075,
|
|
60
58
|
weights: {
|
|
61
59
|
regular: 700,
|
|
62
60
|
medium: 800,
|
|
@@ -97,16 +95,16 @@ export const fonts: ThemeFonts = {
|
|
|
97
95
|
letterSpacing: 0,
|
|
98
96
|
},
|
|
99
97
|
{
|
|
100
|
-
ascenderHeight:
|
|
101
|
-
descenderHeight:
|
|
98
|
+
ascenderHeight: 8,
|
|
99
|
+
descenderHeight: 8,
|
|
102
100
|
fontSize: 33,
|
|
103
101
|
iconSize: 49,
|
|
104
102
|
lineHeight: 39,
|
|
105
103
|
letterSpacing: 0,
|
|
106
104
|
},
|
|
107
105
|
{
|
|
108
|
-
ascenderHeight:
|
|
109
|
-
descenderHeight:
|
|
106
|
+
ascenderHeight: 9,
|
|
107
|
+
descenderHeight: 9,
|
|
110
108
|
fontSize: 38,
|
|
111
109
|
iconSize: 53,
|
|
112
110
|
lineHeight: 45,
|
|
@@ -117,7 +115,6 @@ export const fonts: ThemeFonts = {
|
|
|
117
115
|
label: {
|
|
118
116
|
family:
|
|
119
117
|
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
|
|
120
|
-
horizontalOffset: 0.075,
|
|
121
118
|
weights: {
|
|
122
119
|
regular: 600,
|
|
123
120
|
medium: 700,
|
|
@@ -170,7 +167,6 @@ export const fonts: ThemeFonts = {
|
|
|
170
167
|
text: {
|
|
171
168
|
family:
|
|
172
169
|
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
|
|
173
|
-
horizontalOffset: 0.075,
|
|
174
170
|
weights: {
|
|
175
171
|
regular: 400,
|
|
176
172
|
medium: 500,
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export * from './common'
|
|
2
|
-
|
|
3
1
|
export * from './avatar'
|
|
4
2
|
export * from './badge'
|
|
5
3
|
export * from './box'
|
|
@@ -9,5 +7,7 @@ export * from './dialog'
|
|
|
9
7
|
export * from './flex'
|
|
10
8
|
export * from './grid'
|
|
11
9
|
export * from './gridItem'
|
|
10
|
+
export * from './placement'
|
|
12
11
|
export * from './popover'
|
|
13
12
|
export * from './selectable'
|
|
13
|
+
export * from './text'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placement of floating UI elements.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type Placement =
|
|
7
|
+
| 'top'
|
|
8
|
+
| 'top-start'
|
|
9
|
+
| 'top-end'
|
|
10
|
+
| 'right'
|
|
11
|
+
| 'right-start'
|
|
12
|
+
| 'right-end'
|
|
13
|
+
| 'bottom'
|
|
14
|
+
| 'bottom-start'
|
|
15
|
+
| 'bottom-end'
|
|
16
|
+
| 'left'
|
|
17
|
+
| 'left-start'
|
|
18
|
+
| 'left-end'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, {forwardRef, useCallback,
|
|
2
|
-
import {useForwardedRef} from '../../hooks'
|
|
1
|
+
import React, {forwardRef, useCallback, useMemo, useState} from 'react'
|
|
2
|
+
import {useElementSize, useForwardedRef} from '../../hooks'
|
|
3
3
|
import {useTheme} from '../../theme'
|
|
4
|
-
import {ResizeObserver} from '../resizeObserver'
|
|
5
4
|
import {findMaxBreakpoints, findMinBreakpoints} from './helpers'
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -23,23 +22,11 @@ export const ElementQuery = forwardRef(function ElementQuery(
|
|
|
23
22
|
) {
|
|
24
23
|
const theme = useTheme()
|
|
25
24
|
const {children, media = theme.sanity.media, ...restProps} = props
|
|
26
|
-
|
|
25
|
+
|
|
27
26
|
const forwardedRef = useForwardedRef(ref)
|
|
28
27
|
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!element) return
|
|
32
|
-
|
|
33
|
-
const handleResizeEntries: ResizeObserverCallback = (entries) => {
|
|
34
|
-
setWidth(entries[0].contentRect.width)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const ro = new ResizeObserver(handleResizeEntries)
|
|
38
|
-
|
|
39
|
-
ro.observe(element)
|
|
40
|
-
|
|
41
|
-
return () => ro.disconnect()
|
|
42
|
-
}, [element])
|
|
28
|
+
const elementSize = useElementSize(element)
|
|
29
|
+
const width = useMemo(() => elementSize?.border.width ?? window.innerWidth, [elementSize])
|
|
43
30
|
|
|
44
31
|
const max = useMemo(() => findMaxBreakpoints(media, width), [media, width])
|
|
45
32
|
const min = useMemo(() => findMinBreakpoints(media, width), [media, width])
|
package/src/utils/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ const LayerChildren = forwardRef(function LayerChildren(
|
|
|
28
28
|
const {zIndex} = useLayer()
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
|
-
<Root {...restProps} ref={ref} style={{...style, zIndex}}>
|
|
31
|
+
<Root {...restProps} data-ui="Layer" ref={ref} style={{...style, zIndex}}>
|
|
32
32
|
{children}
|
|
33
33
|
</Root>
|
|
34
34
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react'
|
|
2
|
-
import {useMediaIndex,
|
|
2
|
+
import {useMediaIndex, useArrayProp} from '../../hooks'
|
|
3
3
|
import {LayerContext} from './layerContext'
|
|
4
4
|
import {LayerContextValue} from './types'
|
|
5
5
|
|
|
@@ -17,7 +17,7 @@ export interface LayerProviderProps {
|
|
|
17
17
|
export function LayerProvider(props: LayerProviderProps): React.ReactElement {
|
|
18
18
|
const {children, zOffset: zOffsetProp = 0} = props
|
|
19
19
|
const parent = useContext(LayerContext)
|
|
20
|
-
const zOffset =
|
|
20
|
+
const zOffset = useArrayProp(zOffsetProp)
|
|
21
21
|
const maxMediaIndex = zOffset.length - 1
|
|
22
22
|
const mediaIndex = Math.min(useMediaIndex(), maxMediaIndex)
|
|
23
23
|
const zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex]
|
|
@@ -2,6 +2,7 @@ import React, {forwardRef, useEffect, useMemo, useRef, useState} from 'react'
|
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {_isScrollable} from '../../helpers'
|
|
4
4
|
import {useForwardedRef} from '../../hooks'
|
|
5
|
+
import {_elementSizeObserver} from '../../observers'
|
|
5
6
|
import {StackProps} from '../../primitives'
|
|
6
7
|
import {useTheme} from '../../theme'
|
|
7
8
|
|
|
@@ -86,18 +87,18 @@ export const VirtualList = forwardRef(function VirtualList(
|
|
|
86
87
|
|
|
87
88
|
scrollEl.addEventListener('scroll', handleScroll, {passive: true})
|
|
88
89
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const disposeElementSizeListener = _elementSizeObserver.subscribe(
|
|
91
|
+
scrollEl,
|
|
92
|
+
(scrollElementSize) => {
|
|
93
|
+
setScrollHeight(scrollElementSize.content.height)
|
|
94
|
+
}
|
|
95
|
+
)
|
|
94
96
|
|
|
95
97
|
handleScroll()
|
|
96
98
|
|
|
97
99
|
return () => {
|
|
98
100
|
scrollEl.removeEventListener('scroll', handleScroll)
|
|
99
|
-
|
|
100
|
-
ro.disconnect()
|
|
101
|
+
disposeElementSizeListener()
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useResponsiveProp.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useResponsiveProp.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7F"}
|