@sanity/ui 4.0.0-static.26 → 4.0.0-static.28
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/css/index.css +1 -1
- package/dist/css/index.css.map +1 -1
- package/dist/index.js +57 -53
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/core/components/menu/MenuItem.tsx +0 -2
- package/src/core/components/menu/__workshop__/DataProps.tsx +27 -0
- package/src/core/components/menu/__workshop__/index.ts +6 -1
- package/src/core/primitives/button/Button.tsx +2 -2
- package/src/core/primitives/button/__workshop__/DataProps.tsx +22 -0
- package/src/core/primitives/button/__workshop__/index.ts +5 -0
- package/src/core/primitives/card/Card.tsx +4 -4
- package/src/core/primitives/card/__workshop__/DataProps.tsx +30 -0
- package/src/core/primitives/card/__workshop__/index.ts +1 -0
- package/src/core/primitives/selectable/Selectable.tsx +1 -1
- package/src/core/primitives/selectable/__workshop__/DataProps.tsx +27 -0
- package/src/core/primitives/selectable/__workshop__/index.ts +14 -0
- package/src/css/primitives/_input/_input.css.ts +6 -5
- package/src/css/primitives/box/box.css.ts +0 -2
- package/src/css/primitives/button/button.css.ts +251 -183
- package/src/css/primitives/card/card.css.ts +133 -80
- package/src/css/primitives/selectable/selectable.css.ts +79 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "4.0.0-static.
|
|
3
|
+
"version": "4.0.0-static.28",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"ui",
|
|
@@ -140,13 +140,13 @@
|
|
|
140
140
|
"@testing-library/jest-dom": "^6.8.0",
|
|
141
141
|
"@testing-library/react": "^16.3.0",
|
|
142
142
|
"@testing-library/user-event": "^14.6.1",
|
|
143
|
-
"@types/node": "^24.
|
|
143
|
+
"@types/node": "^24.5.2",
|
|
144
144
|
"@types/react": "^19.1.13",
|
|
145
145
|
"@types/react-dom": "^19.1.9",
|
|
146
146
|
"@types/react-is": "^19.0.0",
|
|
147
147
|
"@vanilla-extract/css": "^1.17.4",
|
|
148
148
|
"@vanilla-extract/vite-plugin": "^5.1.1",
|
|
149
|
-
"@vitejs/plugin-react": "^5.0.
|
|
149
|
+
"@vitejs/plugin-react": "^5.0.3",
|
|
150
150
|
"@vitest/browser": "^3.2.4",
|
|
151
151
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
152
152
|
"browserslist-config-baseline": "^0.5.0",
|
|
@@ -182,12 +182,12 @@
|
|
|
182
182
|
"refractor": "^5.0.0",
|
|
183
183
|
"rimraf": "^5.0.10",
|
|
184
184
|
"semantic-release": "24.2.7",
|
|
185
|
-
"start-server-and-test": "^2.
|
|
185
|
+
"start-server-and-test": "^2.1.1",
|
|
186
186
|
"styled-components": "^6.1.19",
|
|
187
187
|
"tsconfig-paths": "^4.2.0",
|
|
188
188
|
"typescript": "5.9.2",
|
|
189
189
|
"typescript-eslint": "^8.44.0",
|
|
190
|
-
"vite": "^7.1.
|
|
190
|
+
"vite": "^7.1.6",
|
|
191
191
|
"vite-tsconfig-paths": "^5.1.4",
|
|
192
192
|
"vitest": "^3.2.4",
|
|
193
193
|
"vitest-axe": "1.0.0-pre.5"
|
|
@@ -132,8 +132,6 @@ export function MenuItem<E extends MenuItemElementType = typeof DEFAULT_MENU_ITE
|
|
|
132
132
|
data-ui="MenuItem"
|
|
133
133
|
{...rest}
|
|
134
134
|
as={as}
|
|
135
|
-
data-pressed={pressed ? '' : undefined}
|
|
136
|
-
data-disabled={disabled ? '' : undefined}
|
|
137
135
|
radius={radius}
|
|
138
136
|
disabled={disabled}
|
|
139
137
|
onClick={handleClick}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {Menu, MenuItem, Text} from '@sanity/ui'
|
|
2
|
+
import type {ElementTone} from '@sanity/ui/theme'
|
|
3
|
+
import {useSelect} from '@sanity/ui-workshop'
|
|
4
|
+
|
|
5
|
+
import {WORKSHOP_BUTTON_TONE_OPTIONS} from '$workshop'
|
|
6
|
+
|
|
7
|
+
export default function DataPropsStory(): React.JSX.Element {
|
|
8
|
+
// @ts-expect-error - TODO: fix this
|
|
9
|
+
const tone = useSelect('Tone', WORKSHOP_BUTTON_TONE_OPTIONS, 'default') as ElementTone | undefined
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Menu gap={4} padding={4}>
|
|
13
|
+
<MenuItem data-enabled="" padding={3} tone={tone}>
|
|
14
|
+
<Text>MenuItem</Text>
|
|
15
|
+
</MenuItem>
|
|
16
|
+
<MenuItem data-hovered="" padding={3} tone={tone}>
|
|
17
|
+
<Text>MenuItem</Text>
|
|
18
|
+
</MenuItem>
|
|
19
|
+
<MenuItem data-pressed="" padding={3} tone={tone}>
|
|
20
|
+
<Text>MenuItem</Text>
|
|
21
|
+
</MenuItem>
|
|
22
|
+
<MenuItem data-selected="" padding={3} tone={tone}>
|
|
23
|
+
<Text>MenuItem</Text>
|
|
24
|
+
</MenuItem>
|
|
25
|
+
</Menu>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -71,7 +71,7 @@ const scope: WorkshopScope = {
|
|
|
71
71
|
component: lazy(() => import('./OnCloseMenuButton')),
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
name: '
|
|
74
|
+
name: 'should-focus',
|
|
75
75
|
title: 'Menu with shouldFocus',
|
|
76
76
|
component: lazy(() => import('./ShouldFocus')),
|
|
77
77
|
},
|
|
@@ -85,6 +85,11 @@ const scope: WorkshopScope = {
|
|
|
85
85
|
title: 'Custom selected state',
|
|
86
86
|
component: lazy(() => import('./CustomSelectedState')),
|
|
87
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: 'data-props',
|
|
90
|
+
title: 'Data props',
|
|
91
|
+
component: lazy(() => import('./DataProps')),
|
|
92
|
+
},
|
|
88
93
|
],
|
|
89
94
|
}
|
|
90
95
|
|
|
@@ -103,8 +103,8 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
|
|
|
103
103
|
data-ui="Button"
|
|
104
104
|
{...rest}
|
|
105
105
|
className={button({className, flex, mode, radius, tone, width})}
|
|
106
|
-
data-disabled={loading || disabled ? '' :
|
|
107
|
-
data-selected={selected ? '' :
|
|
106
|
+
data-disabled={loading || disabled ? '' : props['data-disabled']}
|
|
107
|
+
data-selected={selected ? '' : props['data-selected']}
|
|
108
108
|
disabled={Boolean(loading || disabled)}
|
|
109
109
|
// @ts-expect-error - TODO: fix this
|
|
110
110
|
href={disabled ? undefined : href}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Button, Stack} from '@sanity/ui'
|
|
2
|
+
import type {ButtonMode, ElementTone} from '@sanity/ui/theme'
|
|
3
|
+
import {useSelect} from '@sanity/ui-workshop'
|
|
4
|
+
|
|
5
|
+
import {WORKSHOP_BUTTON_MODE_OPTIONS, WORKSHOP_BUTTON_TONE_OPTIONS} from '$workshop'
|
|
6
|
+
|
|
7
|
+
export default function DataPropsStory(): React.JSX.Element {
|
|
8
|
+
// @ts-expect-error - TODO: fix this
|
|
9
|
+
const mode = useSelect('Mode', WORKSHOP_BUTTON_MODE_OPTIONS, 'default') as ButtonMode | undefined
|
|
10
|
+
|
|
11
|
+
// @ts-expect-error - TODO: fix this
|
|
12
|
+
const tone = useSelect('Tone', WORKSHOP_BUTTON_TONE_OPTIONS, 'default') as ElementTone | undefined
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Stack gap={4} padding={4}>
|
|
16
|
+
<Button data-enabled="" mode={mode} text="Button" tone={tone} />
|
|
17
|
+
<Button data-hovered="" mode={mode} text="Button" tone={tone} />
|
|
18
|
+
<Button data-pressed="" mode={mode} text="Button" tone={tone} />
|
|
19
|
+
<Button data-selected="" mode={mode} text="Button" tone={tone} />
|
|
20
|
+
</Stack>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -72,10 +72,10 @@ export function Card<E extends CardElementType = typeof DEFAULT_CARD_ELEMENT>(
|
|
|
72
72
|
})}
|
|
73
73
|
data-checkered={checkered ? '' : undefined}
|
|
74
74
|
// Extract the disabled prop without removing it from `...rest` so that the underlying <button> or <a> has `[disabled]` when needed
|
|
75
|
-
data-disabled={props.disabled ? '' :
|
|
76
|
-
data-focus-ring={focusRing ? '' :
|
|
77
|
-
data-pressed={pressed ? '' :
|
|
78
|
-
data-selected={selected ? '' :
|
|
75
|
+
data-disabled={props.disabled ? '' : props['data-disabled']}
|
|
76
|
+
data-focus-ring={focusRing ? '' : props['data-focus-ring']}
|
|
77
|
+
data-pressed={pressed ? '' : props['data-pressed']}
|
|
78
|
+
data-selected={selected ? '' : props['data-selected']}
|
|
79
79
|
radius={radius}
|
|
80
80
|
style={style}
|
|
81
81
|
/>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {Card, Stack, Text} from '@sanity/ui'
|
|
2
|
+
import type {CardTone} from '@sanity/ui/theme'
|
|
3
|
+
import {useSelect} from '@sanity/ui-workshop'
|
|
4
|
+
|
|
5
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
6
|
+
|
|
7
|
+
export default function DataPropsStory(): React.JSX.Element {
|
|
8
|
+
// @ts-expect-error - TODO: fix this
|
|
9
|
+
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS, 'default') as CardTone | undefined
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Stack gap={1} padding={4}>
|
|
13
|
+
<Card as="button" data-enabled="" padding={3} tone={tone}>
|
|
14
|
+
<Text>Card</Text>
|
|
15
|
+
</Card>
|
|
16
|
+
<Card as="button" data-hovered="" padding={3} tone={tone}>
|
|
17
|
+
<Text>Card</Text>
|
|
18
|
+
</Card>
|
|
19
|
+
<Card as="button" data-pressed="" padding={3} tone={tone}>
|
|
20
|
+
<Text>Card</Text>
|
|
21
|
+
</Card>
|
|
22
|
+
<Card as="button" data-selected="" padding={3} tone={tone}>
|
|
23
|
+
<Text>Card</Text>
|
|
24
|
+
</Card>
|
|
25
|
+
<Card as="button" data-disabled="" padding={3} tone={tone}>
|
|
26
|
+
<Text>Card</Text>
|
|
27
|
+
</Card>
|
|
28
|
+
</Stack>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -14,6 +14,7 @@ const scope: WorkshopScope = {
|
|
|
14
14
|
{name: 'checkered', title: 'Checkered', component: lazy(() => import('./Checkered'))},
|
|
15
15
|
{name: 'as-component', title: 'As component', component: lazy(() => import('./AsComponent'))},
|
|
16
16
|
{name: 'selected', title: 'Selected', component: lazy(() => import('./Selected'))},
|
|
17
|
+
{name: 'data-props', title: 'Data props', component: lazy(() => import('./DataProps'))},
|
|
17
18
|
],
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -44,7 +44,7 @@ export function Selectable<E extends SelectableElementType = typeof DEFAULT_SELE
|
|
|
44
44
|
{...rest}
|
|
45
45
|
as={as}
|
|
46
46
|
className={_selectable({className, radius, tone})}
|
|
47
|
-
data-selected={selected ? '' :
|
|
47
|
+
data-selected={selected ? '' : props['data-selected']}
|
|
48
48
|
/>
|
|
49
49
|
)
|
|
50
50
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {Selectable, Stack, Text} from '@sanity/ui'
|
|
2
|
+
import type {ElementTone} from '@sanity/ui/theme'
|
|
3
|
+
import {useSelect} from '@sanity/ui-workshop'
|
|
4
|
+
|
|
5
|
+
import {WORKSHOP_BUTTON_TONE_OPTIONS} from '$workshop'
|
|
6
|
+
|
|
7
|
+
export default function DataPropsStory(): React.JSX.Element {
|
|
8
|
+
// @ts-expect-error - TODO: fix this
|
|
9
|
+
const tone = useSelect('Tone', WORKSHOP_BUTTON_TONE_OPTIONS, 'default') as ElementTone | undefined
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Stack gap={4} padding={4}>
|
|
13
|
+
<Selectable data-enabled="" padding={3} tone={tone}>
|
|
14
|
+
<Text>Selectable</Text>
|
|
15
|
+
</Selectable>
|
|
16
|
+
<Selectable data-hovered="" padding={3} tone={tone}>
|
|
17
|
+
<Text>Selectable</Text>
|
|
18
|
+
</Selectable>
|
|
19
|
+
<Selectable data-pressed="" padding={3} tone={tone}>
|
|
20
|
+
<Text>Selectable</Text>
|
|
21
|
+
</Selectable>
|
|
22
|
+
<Selectable data-selected="" padding={3} tone={tone}>
|
|
23
|
+
<Text>Selectable</Text>
|
|
24
|
+
</Selectable>
|
|
25
|
+
</Stack>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
+
import {lazy} from 'react'
|
|
3
|
+
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/selectable',
|
|
6
|
+
title: 'Selectable',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'data-props',
|
|
10
|
+
title: 'Data props',
|
|
11
|
+
component: lazy(() => import('./DataProps')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -154,11 +154,12 @@ export const presentation: string = _style(layers.primitives, {
|
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
|
|
157
|
-
[`${root}:not([data-invalid]):not([data-read-only]) ${element}:not(:disabled):hover + &`]:
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
[`${root}.${border}:not([data-invalid]):not([data-read-only]) ${element}:not(:disabled):hover + &`]:
|
|
158
|
+
{
|
|
159
|
+
vars: {
|
|
160
|
+
[vars.color.input.text.border]: vars.color.tinted.default.border[2],
|
|
161
|
+
},
|
|
160
162
|
},
|
|
161
|
-
},
|
|
162
163
|
|
|
163
164
|
[`${root}:not([data-invalid]) ${element}:focus + &`]: {
|
|
164
165
|
vars: {
|
|
@@ -185,7 +186,7 @@ export const presentation: string = _style(layers.primitives, {
|
|
|
185
186
|
},
|
|
186
187
|
},
|
|
187
188
|
|
|
188
|
-
[`${root}[data-invalid] ${element}:not(:disabled):hover + &`]: {
|
|
189
|
+
[`${root}.${border}[data-invalid] ${element}:not(:disabled):hover + &`]: {
|
|
189
190
|
vars: {
|
|
190
191
|
[vars.color.input.text.border]: vars.color.tinted.critical.border[2],
|
|
191
192
|
},
|