@sanity/ui 1.0.0-next.3 → 1.0.1
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 +2 -2
- package/dist/{types/src/index.d.ts → index.d.ts} +4450 -4398
- package/dist/{sanity-ui.esm.js → index.esm.js} +889 -2678
- package/dist/index.esm.js.map +1 -0
- package/dist/{sanity-ui.js → index.js} +883 -2688
- package/dist/index.js.map +1 -0
- package/package.json +114 -23
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/components/autocomplete/__workshop__/example.tsx +1 -1
- package/src/components/autocomplete/__workshop__/index.ts +36 -32
- package/src/components/autocomplete/autocomplete.styles.tsx +22 -28
- package/src/components/autocomplete/autocomplete.tsx +1 -2
- package/src/components/autocomplete/constants.ts +3 -8
- package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
- package/src/components/breadcrumbs/breadcrumbs.styles.ts +13 -18
- package/src/components/dialog/__workshop__/index.ts +13 -9
- package/src/components/dialog/dialog.tsx +53 -67
- package/src/components/hotkeys/__workshop__/index.ts +11 -3
- package/src/components/hotkeys/hotkeys.tsx +12 -16
- package/src/components/menu/__workshop__/index.ts +71 -67
- package/src/components/menu/menu.tsx +5 -7
- package/src/components/menu/menuButton.tsx +16 -14
- package/src/components/menu/menuDivider.ts +8 -10
- package/src/components/skeleton/__workshop__/index.ts +8 -4
- package/src/components/skeleton/skeleton.tsx +4 -6
- package/src/components/skeleton/styles.ts +13 -9
- package/src/components/skeleton/textSkeleton.tsx +12 -14
- package/src/components/tab/__workshop__/index.ts +11 -3
- package/src/components/toast/__workshop__/index.ts +16 -4
- package/src/components/toast/toast.tsx +6 -11
- package/src/components/toast/toastProvider.tsx +18 -22
- package/src/components/tree/__workshop__/basic.perf.ts +1 -14
- package/src/components/tree/__workshop__/basic.tsx +1 -1
- package/src/components/tree/__workshop__/index.ts +12 -8
- package/src/components/tree/style.ts +78 -76
- package/src/components/tree/treeItem.tsx +7 -12
- package/src/global.ts +6 -0
- package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
- package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
- package/src/primitives/_selectable/selectable.tsx +4 -7
- package/src/primitives/_selectable/style.ts +85 -82
- package/src/primitives/avatar/__workshop__/index.ts +16 -12
- package/src/primitives/avatar/avatar.tsx +9 -12
- package/src/primitives/avatar/avatarCounter.tsx +22 -24
- package/src/primitives/avatar/avatarStack.tsx +16 -14
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/badge/__workshop__/index.ts +16 -12
- package/src/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/primitives/badge/badge.tsx +6 -5
- package/src/primitives/box/__workshop__/index.ts +16 -4
- package/src/primitives/box/box.tsx +21 -49
- package/src/primitives/button/__workshop__/index.ts +51 -47
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +19 -20
- package/src/primitives/button/__workshop__/styled1.tsx +6 -6
- package/src/primitives/button/button.tsx +20 -26
- package/src/primitives/button/styles.ts +30 -29
- package/src/primitives/card/__workshop__/index.ts +15 -11
- package/src/primitives/card/card.tsx +9 -25
- package/src/primitives/card/styles.ts +119 -114
- package/src/primitives/checkbox/__workshop__/index.ts +10 -6
- package/src/primitives/checkbox/checkbox.tsx +4 -4
- package/src/primitives/checkbox/styles.ts +71 -69
- package/src/primitives/code/__workshop__/index.ts +16 -12
- package/src/primitives/code/code.tsx +3 -5
- package/src/primitives/code/styles.ts +20 -18
- package/src/primitives/container/__workshop__/index.ts +5 -3
- package/src/primitives/container/container.tsx +5 -4
- package/src/primitives/flex/__workshop__/index.ts +8 -4
- package/src/primitives/flex/flex.tsx +7 -23
- package/src/primitives/grid/__workshop__/index.ts +7 -3
- package/src/primitives/grid/grid.tsx +4 -27
- package/src/primitives/heading/__workshop__/index.ts +16 -12
- package/src/primitives/heading/heading.tsx +10 -17
- package/src/primitives/heading/styles.ts +45 -36
- package/src/primitives/inline/__workshop__/index.ts +5 -3
- package/src/primitives/inline/inline.tsx +3 -5
- package/src/primitives/kbd/__workshop__/index.ts +5 -3
- package/src/primitives/kbd/kbd.tsx +12 -13
- package/src/primitives/label/__workshop__/index.ts +16 -12
- package/src/primitives/label/label.tsx +13 -18
- package/src/primitives/label/styles.ts +24 -18
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/index.ts +36 -32
- package/src/primitives/popover/constants.ts +0 -3
- package/src/primitives/popover/floating-ui/size.ts +40 -25
- package/src/primitives/popover/popover.tsx +220 -196
- package/src/primitives/popover/popoverArrow.tsx +42 -48
- package/src/primitives/popover/popoverCard.tsx +12 -22
- package/src/primitives/radio/__workshop__/index.ts +8 -4
- package/src/primitives/radio/radio.tsx +3 -3
- package/src/primitives/radio/styles.ts +73 -73
- package/src/primitives/select/__workshop__/index.ts +8 -4
- package/src/primitives/select/select.tsx +9 -11
- package/src/primitives/select/styles.ts +77 -77
- package/src/primitives/spinner/__workshop__/index.ts +11 -7
- package/src/primitives/spinner/spinner.tsx +2 -5
- package/src/primitives/stack/__workshop__/index.ts +11 -7
- package/src/primitives/stack/stack.tsx +3 -5
- package/src/primitives/switch/__workshop__/index.ts +8 -4
- package/src/primitives/switch/styles.ts +119 -112
- package/src/primitives/switch/switch.tsx +6 -6
- package/src/primitives/text/__workshop__/index.ts +21 -17
- package/src/primitives/text/styles.ts +51 -45
- package/src/primitives/text/text.tsx +11 -16
- package/src/primitives/textArea/__workshop__/index.ts +11 -7
- package/src/primitives/textArea/textArea.tsx +15 -22
- package/src/primitives/textInput/__workshop__/index.ts +46 -42
- package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
- package/src/primitives/textInput/textInput.tsx +50 -69
- package/src/primitives/tooltip/__workshop__/index.ts +11 -7
- package/src/primitives/tooltip/tooltip.tsx +3 -6
- package/src/primitives/tooltip/tooltipArrow.tsx +69 -59
- package/src/styles/border/borderStyle.ts +10 -18
- package/src/styles/box/boxStyle.ts +14 -18
- package/src/styles/flex/flexItemStyle.ts +7 -1
- package/src/styles/flex/flexStyle.ts +14 -9
- package/src/styles/grid/gridItemStyle.ts +18 -30
- package/src/styles/grid/gridStyle.ts +25 -33
- package/src/styles/helpers.ts +2 -2
- package/src/styles/index.ts +0 -1
- package/src/styles/input/textInputStyle.ts +127 -123
- package/src/styles/margin/marginStyle.ts +11 -10
- package/src/styles/margin/marginsStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.ts +9 -10
- package/src/theme/__workshop__/index.ts +26 -22
- package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
- package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
- package/src/utils/elementQuery/__workshop__/index.ts +11 -7
- package/src/utils/layer/__workshop__/index.ts +21 -17
- package/src/utils/layer/layer.tsx +4 -6
- package/src/utils/portal/__workshop__/index.ts +11 -7
- package/src/utils/srOnly/srOnly.tsx +8 -10
- package/src/utils/virtualList/__workshop__/index.ts +26 -22
- package/src/utils/virtualList/virtualList.tsx +10 -14
- package/dist/sanity-ui.esm.js.map +0 -1
- package/dist/sanity-ui.js.map +0 -1
- package/src/__workshop__/color/overview.tsx +0 -101
- package/src/__workshop__/index.ts +0 -10
- package/src/icons/__workshop__/.eslintrc +0 -5
- package/src/icons/__workshop__/index.tsx +0 -6
- package/src/icons/__workshop__/overview.tsx +0 -76
- package/src/styles/compose.ts +0 -35
- package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
|
@@ -1,65 +1,59 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {DEFAULT_POPOVER_ARROW_HEIGHT, DEFAULT_POPOVER_ARROW_WIDTH} from './constants'
|
|
4
4
|
|
|
5
|
-
const Root =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fill: 'none',
|
|
5
|
+
const Root = styled.div`
|
|
6
|
+
position: absolute;
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
width: ${DEFAULT_POPOVER_ARROW_WIDTH}px;
|
|
9
|
+
height: ${DEFAULT_POPOVER_ARROW_WIDTH}px;
|
|
10
|
+
fill: none;
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
:empty + & {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
& > svg {
|
|
17
|
+
display: block;
|
|
18
|
+
transform-origin: ${DEFAULT_POPOVER_ARROW_WIDTH / 2}px ${DEFAULT_POPOVER_ARROW_WIDTH / 2}px;
|
|
19
|
+
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
[data-placement^='top'] > & {
|
|
22
|
+
bottom: -${DEFAULT_POPOVER_ARROW_WIDTH}px;
|
|
23
|
+
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
[data-placement^='right'] > & {
|
|
26
|
+
left: -${DEFAULT_POPOVER_ARROW_WIDTH}px;
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
& > svg {
|
|
29
|
+
transform: rotate(90deg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
[data-placement^='left'] > & {
|
|
34
|
+
right: -${DEFAULT_POPOVER_ARROW_WIDTH}px;
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
& > svg {
|
|
37
|
+
transform: rotate(-90deg);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
[data-placement^='bottom'] > & {
|
|
42
|
+
top: -${DEFAULT_POPOVER_ARROW_WIDTH}px;
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
44
|
+
& > svg {
|
|
45
|
+
transform: rotate(180deg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`
|
|
51
49
|
|
|
52
|
-
const BorderPath =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
)
|
|
50
|
+
const BorderPath = styled.path`
|
|
51
|
+
fill: var(--card-shadow-outline-color);
|
|
52
|
+
`
|
|
57
53
|
|
|
58
|
-
const ShapePath =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
)
|
|
54
|
+
const ShapePath = styled.path`
|
|
55
|
+
fill: var(--card-bg-color);
|
|
56
|
+
`
|
|
63
57
|
|
|
64
58
|
export const PopoverArrow = forwardRef(function PopoverArrow(
|
|
65
59
|
props: Omit<React.HTMLProps<HTMLDivElement>, 'as'>,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {Strategy} from '@floating-ui/react-dom'
|
|
2
2
|
import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
3
|
-
import {CSSObject} from 'styled-components'
|
|
3
|
+
import styled, {CSSObject} from 'styled-components'
|
|
4
4
|
import {FLOATING_STATIC_SIDES} from '../../constants'
|
|
5
|
-
import {
|
|
5
|
+
import {ThemeProps} from '../../styles'
|
|
6
6
|
import {ThemeColorSchemeKey} from '../../theme'
|
|
7
7
|
import {BoxOverflow, CardTone, Placement, PopoverMargins} from '../../types'
|
|
8
8
|
import {useLayer} from '../../utils'
|
|
@@ -31,13 +31,15 @@ function popoverCardStyle(props: {$boundaryWidth?: number} & ThemeProps): CSSObj
|
|
|
31
31
|
typeof $boundaryWidth === 'number'
|
|
32
32
|
? `${$boundaryWidth - DEFAULT_POPOVER_PADDING * 2}px`
|
|
33
33
|
: undefined,
|
|
34
|
-
|
|
35
|
-
height: 'max-content',
|
|
36
|
-
minHeight: 'min-content',
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
const Root = memo(
|
|
37
|
+
const Root = memo(styled(Card)(popoverCardStyle))
|
|
38
|
+
|
|
39
|
+
const PopoverContainer = memo(styled(Container)`
|
|
40
|
+
max-height: inherit;
|
|
41
|
+
max-width: inherit;
|
|
42
|
+
`)
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* @internal
|
|
@@ -51,14 +53,11 @@ export const PopoverCard = memo(
|
|
|
51
53
|
arrowRef: React.Ref<HTMLDivElement>
|
|
52
54
|
arrowX?: number
|
|
53
55
|
arrowY?: number
|
|
54
|
-
availableHeight?: number
|
|
55
|
-
availableWidth?: number
|
|
56
56
|
boundaryWidth?: number
|
|
57
57
|
overflow?: BoxOverflow
|
|
58
58
|
padding?: number | number[]
|
|
59
59
|
placement?: Placement
|
|
60
60
|
radius?: number | number[]
|
|
61
|
-
referenceWidth?: number
|
|
62
61
|
scheme?: ThemeColorSchemeKey
|
|
63
62
|
shadow?: number | number[]
|
|
64
63
|
strategy: Strategy
|
|
@@ -75,15 +74,12 @@ export const PopoverCard = memo(
|
|
|
75
74
|
arrowRef,
|
|
76
75
|
arrowX,
|
|
77
76
|
arrowY,
|
|
78
|
-
availableHeight,
|
|
79
|
-
availableWidth,
|
|
80
77
|
boundaryWidth,
|
|
81
78
|
children,
|
|
82
79
|
padding,
|
|
83
80
|
placement,
|
|
84
81
|
overflow,
|
|
85
82
|
radius,
|
|
86
|
-
referenceWidth: referenceWidthProp,
|
|
87
83
|
scheme,
|
|
88
84
|
shadow,
|
|
89
85
|
strategy,
|
|
@@ -104,10 +100,6 @@ export const PopoverCard = memo(
|
|
|
104
100
|
)
|
|
105
101
|
|
|
106
102
|
// Translate according to margins
|
|
107
|
-
const referenceWidth = referenceWidthProp
|
|
108
|
-
? referenceWidthProp - margins[1] - margins[3]
|
|
109
|
-
: undefined
|
|
110
|
-
|
|
111
103
|
const x = (xProp ?? 0) + margins[3]
|
|
112
104
|
const y = (yProp ?? 0) + margins[0]
|
|
113
105
|
|
|
@@ -117,12 +109,9 @@ export const PopoverCard = memo(
|
|
|
117
109
|
top: y,
|
|
118
110
|
left: x,
|
|
119
111
|
zIndex,
|
|
120
|
-
width: referenceWidth,
|
|
121
|
-
maxWidth: availableWidth,
|
|
122
|
-
maxHeight: availableHeight,
|
|
123
112
|
...style,
|
|
124
113
|
}),
|
|
125
|
-
[
|
|
114
|
+
[strategy, style, x, y, zIndex]
|
|
126
115
|
)
|
|
127
116
|
|
|
128
117
|
const staticSide = placement && FLOATING_STATIC_SIDES[placement.split('-')[0]]
|
|
@@ -150,10 +139,11 @@ export const PopoverCard = memo(
|
|
|
150
139
|
ref={ref}
|
|
151
140
|
scheme={scheme}
|
|
152
141
|
shadow={shadow}
|
|
142
|
+
sizing="border"
|
|
153
143
|
style={rootStyle}
|
|
154
144
|
tone={tone}
|
|
155
145
|
>
|
|
156
|
-
<
|
|
146
|
+
<PopoverContainer
|
|
157
147
|
data-ui="Popover__wrapper"
|
|
158
148
|
flex={1}
|
|
159
149
|
overflow={overflow}
|
|
@@ -162,7 +152,7 @@ export const PopoverCard = memo(
|
|
|
162
152
|
width={width}
|
|
163
153
|
>
|
|
164
154
|
{children}
|
|
165
|
-
</
|
|
155
|
+
</PopoverContainer>
|
|
166
156
|
|
|
167
157
|
{arrow && <PopoverArrow ref={arrowRef} style={arrowStyle} />}
|
|
168
158
|
</Root>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/radio',
|
|
6
|
+
title: 'Radio',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))},
|
|
9
|
+
{name: 'example', title: 'Example', component: lazy(() => import('./example'))},
|
|
10
|
+
],
|
|
11
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {useForwardedRef, useCustomValidity} from '../../hooks'
|
|
4
4
|
import {radioBaseStyle, inputElementStyle} from './styles'
|
|
@@ -10,8 +10,8 @@ export interface RadioProps {
|
|
|
10
10
|
customValidity?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const Root =
|
|
14
|
-
const Input =
|
|
13
|
+
const Root = styled.div(radioBaseStyle)
|
|
14
|
+
const Input = styled.input(inputElementStyle)
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @public
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {css, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {rem, ThemeProps} from '../../styles'
|
|
3
3
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
4
4
|
|
|
5
|
-
export function radioBaseStyle():
|
|
6
|
-
return
|
|
7
|
-
position:
|
|
5
|
+
export function radioBaseStyle(): FlattenSimpleInterpolation {
|
|
6
|
+
return css`
|
|
7
|
+
position: relative;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
display:
|
|
11
|
-
}
|
|
9
|
+
&:not([hidden]) {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
outline:
|
|
15
|
-
}
|
|
16
|
-
|
|
13
|
+
&[data-read-only] {
|
|
14
|
+
outline: 1px solid red;
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function inputElementStyle(props: ThemeProps):
|
|
19
|
+
export function inputElementStyle(props: ThemeProps): FlattenSimpleInterpolation {
|
|
20
20
|
const {theme} = props
|
|
21
21
|
const {focusRing, input} = theme.sanity
|
|
22
22
|
const color = theme.sanity.color.input
|
|
23
23
|
const dist = (input.radio.size - input.radio.markSize) / 2
|
|
24
24
|
|
|
25
|
-
return
|
|
26
|
-
appearance:
|
|
27
|
-
position:
|
|
28
|
-
top: 0
|
|
29
|
-
left: 0
|
|
30
|
-
opacity: 0
|
|
31
|
-
height:
|
|
32
|
-
width:
|
|
33
|
-
outline:
|
|
34
|
-
|
|
35
|
-
padding: 0
|
|
36
|
-
margin: 0
|
|
37
|
-
|
|
38
|
-
border:
|
|
25
|
+
return css`
|
|
26
|
+
appearance: none;
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
opacity: 0;
|
|
31
|
+
height: 100%;
|
|
32
|
+
width: 100%;
|
|
33
|
+
outline: none;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
padding: 0;
|
|
36
|
+
margin: 0;
|
|
37
|
+
border-radius: ${rem(input.radio.size / 2)};
|
|
38
|
+
border: none;
|
|
39
39
|
|
|
40
40
|
/* enabled */
|
|
41
|
-
|
|
42
|
-
display:
|
|
43
|
-
position:
|
|
44
|
-
height: rem(input.radio.size)
|
|
45
|
-
width: rem(input.radio.size)
|
|
46
|
-
|
|
47
|
-
background: color.default.enabled.bg
|
|
48
|
-
|
|
41
|
+
& + span {
|
|
42
|
+
display: block;
|
|
43
|
+
position: relative;
|
|
44
|
+
height: ${rem(input.radio.size)};
|
|
45
|
+
width: ${rem(input.radio.size)};
|
|
46
|
+
border-radius: ${rem(input.radio.size / 2)};
|
|
47
|
+
background: ${color.default.enabled.bg};
|
|
48
|
+
box-shadow: ${focusRingBorderStyle({
|
|
49
49
|
color: color.default.enabled.border,
|
|
50
50
|
width: input.border.width,
|
|
51
|
-
})
|
|
51
|
+
})};
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
content: '
|
|
55
|
-
position:
|
|
56
|
-
top: rem(dist)
|
|
57
|
-
left: rem(dist)
|
|
58
|
-
height: rem(input.radio.markSize)
|
|
59
|
-
width: rem(input.radio.markSize)
|
|
60
|
-
|
|
61
|
-
background: color.default.enabled.fg
|
|
62
|
-
opacity: 0
|
|
63
|
-
}
|
|
64
|
-
}
|
|
53
|
+
&::after {
|
|
54
|
+
content: '';
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: ${rem(dist)};
|
|
57
|
+
left: ${rem(dist)};
|
|
58
|
+
height: ${rem(input.radio.markSize)};
|
|
59
|
+
width: ${rem(input.radio.markSize)};
|
|
60
|
+
border-radius: ${rem(input.radio.markSize / 2)};
|
|
61
|
+
background: ${color.default.enabled.fg};
|
|
62
|
+
opacity: 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
65
|
|
|
66
66
|
/* focused */
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
&:not(:disabled):focus + span {
|
|
68
|
+
box-shadow: ${focusRingStyle({
|
|
69
69
|
border: {width: input.border.width, color: color.default.enabled.border},
|
|
70
70
|
focusRing,
|
|
71
|
-
})
|
|
72
|
-
}
|
|
71
|
+
})};
|
|
72
|
+
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
&:not(:disabled):focus:not(:focus-visible) + span {
|
|
75
|
+
box-shadow: ${focusRingBorderStyle({
|
|
76
76
|
color: color.default.enabled.border,
|
|
77
77
|
width: input.border.width,
|
|
78
|
-
})
|
|
79
|
-
}
|
|
78
|
+
})};
|
|
79
|
+
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
opacity: 1
|
|
83
|
-
}
|
|
81
|
+
&:checked + span::after {
|
|
82
|
+
opacity: 1;
|
|
83
|
+
}
|
|
84
84
|
|
|
85
85
|
/* read only */
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
background: color.default.readOnly.bg
|
|
86
|
+
&[data-read-only] + span {
|
|
87
|
+
box-shadow: 0 0 0 1px ${color.default.readOnly.border};
|
|
88
|
+
background: ${color.default.readOnly.bg};
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
background: color.default.readOnly.fg
|
|
92
|
-
}
|
|
93
|
-
}
|
|
90
|
+
&::after {
|
|
91
|
+
background: ${color.default.readOnly.fg};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
94
|
|
|
95
95
|
/* disabled */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
background: color.default.disabled.bg
|
|
96
|
+
&:not([data-read-only]):disabled + span {
|
|
97
|
+
box-shadow: 0 0 0 1px ${color.default.disabled.border};
|
|
98
|
+
background: ${color.default.disabled.bg};
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
background: color.default.disabled.fg
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
100
|
+
&::after {
|
|
101
|
+
background: ${color.default.disabled.fg};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`
|
|
105
105
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/select',
|
|
6
|
+
title: 'Select',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))},
|
|
9
|
+
{name: 'read-only', title: 'Read-only', component: lazy(() => import('./readOnly'))},
|
|
10
|
+
],
|
|
11
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {SelectIcon} from '@sanity/icons'
|
|
2
|
-
import {forwardRef
|
|
2
|
+
import {forwardRef} from 'react'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {useForwardedRef, useCustomValidity, useArrayProp} from '../../hooks'
|
|
5
5
|
import {Box} from '../box'
|
|
@@ -17,18 +17,16 @@ export interface SelectProps {
|
|
|
17
17
|
customValidity?: string
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const Root =
|
|
20
|
+
const Root = styled.div(selectStyle.root)
|
|
21
21
|
|
|
22
|
-
const Input =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}>(selectStyle.input)
|
|
29
|
-
)
|
|
22
|
+
const Input = styled.select<{
|
|
23
|
+
$fontSize: number[]
|
|
24
|
+
$padding: number[]
|
|
25
|
+
$radius: number[]
|
|
26
|
+
$space: number[]
|
|
27
|
+
}>(selectStyle.input)
|
|
30
28
|
|
|
31
|
-
const IconBox =
|
|
29
|
+
const IconBox = styled(Box)(selectStyle.iconBox)
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* @public
|