@sanity/ui 4.0.0-static.24 → 4.0.0-static.26
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/css/index.d.ts +22 -6
- package/dist/css/index.js +29 -20
- package/dist/css/index.js.map +1 -1
- package/dist/index.d.ts +8 -13
- package/dist/index.js +519 -531
- package/dist/index.js.map +1 -1
- package/exports/css/index.css +1 -0
- package/package.json +12 -12
- package/src/core/components/dialog/__workshop__/Panes.tsx +4 -0
- package/src/core/components/menu/Menu.tsx +0 -4
- package/src/core/components/menu/MenuItem.tsx +1 -1
- package/src/core/components/toast/useToast.ts +2 -2
- package/src/core/primitives/avatar/Avatar.tsx +2 -2
- package/src/core/primitives/avatar/__workshop__/PropsStory.tsx +22 -0
- package/src/core/primitives/avatar/__workshop__/index.ts +5 -0
- package/src/core/primitives/button/Button.tsx +5 -5
- package/src/core/primitives/code/Code.tsx +25 -1
- package/src/core/primitives/heading/Heading.tsx +16 -0
- package/src/core/primitives/label/Label.tsx +16 -0
- package/src/core/primitives/radio/Radio.tsx +2 -2
- package/src/core/primitives/select/Select.tsx +5 -3
- package/src/core/primitives/switch/Switch.tsx +2 -10
- package/src/core/primitives/text/Text.tsx +14 -0
- package/src/core/primitives/textArea/TextArea.tsx +7 -1
- package/src/core/primitives/textInput/TextInput.tsx +18 -17
- package/src/core/types.ts +6 -5
- package/src/core/utils/portal/PortalProvider.tsx +2 -2
- package/src/css/primitives/_input/_input.css.ts +2 -3
- package/src/css/primitives/_input/input.ts +2 -0
- package/src/css/primitives/_input/types.ts +2 -1
- package/src/css/primitives/avatar/avatar.css.ts +8 -0
- package/src/css/primitives/box/box.css.ts +21 -1
- package/src/css/primitives/button/button.css.ts +1 -0
- package/src/css/primitives/card/card.css.ts +0 -60
- package/src/css/primitives/checkbox/checkbox.css.ts +1 -0
- package/src/css/primitives/code/code.ts +4 -0
- package/src/css/primitives/code/types.ts +7 -1
- package/src/css/primitives/heading/heading.ts +4 -0
- package/src/css/primitives/heading/types.ts +7 -1
- package/src/css/primitives/label/label.ts +4 -0
- package/src/css/primitives/label/types.ts +7 -1
- package/src/css/primitives/radio/radio.css.ts +1 -1
- package/src/css/primitives/root/root.css.ts +0 -1
- package/src/css/primitives/select/select.css.ts +7 -1
- package/src/css/primitives/selectable/selectable.css.ts +5 -31
- package/src/css/primitives/switch/switch.css.ts +10 -1
- package/src/css/primitives/text/text.ts +2 -0
- package/src/css/primitives/text/types.ts +6 -1
- package/src/css/primitives/textInput/textInput.css.ts +15 -3
- package/src/css/props/width/types.ts +1 -1
- package/src/css/props/width/width.css.ts +5 -2
- package/src/core/primitives/popover/helpers.ts +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* this file is used to support importing `@sanity/ui/css/index.css` in dev mode */
|
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.26",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"ui",
|
|
@@ -119,20 +119,20 @@
|
|
|
119
119
|
"@sanity/icons": "^3.7.4",
|
|
120
120
|
"@vanilla-extract/dynamic": "^2.1.5",
|
|
121
121
|
"csstype": "^3.1.3",
|
|
122
|
-
"framer-motion": "^12.23.
|
|
122
|
+
"framer-motion": "^12.23.15",
|
|
123
123
|
"react-refractor": "^4.0.0",
|
|
124
124
|
"use-effect-event": "^2.0.3"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
|
-
"@babel/core": "^7.28.
|
|
127
|
+
"@babel/core": "^7.28.4",
|
|
128
128
|
"@babel/preset-env": "^7.28.3",
|
|
129
129
|
"@babel/preset-react": "^7.27.1",
|
|
130
130
|
"@babel/preset-typescript": "^7.27.1",
|
|
131
131
|
"@commitlint/cli": "^19.8.1",
|
|
132
132
|
"@commitlint/config-conventional": "^19.8.1",
|
|
133
|
-
"@eslint/js": "^9.
|
|
133
|
+
"@eslint/js": "^9.35.0",
|
|
134
134
|
"@sanity/browserslist-config": "^1.0.5",
|
|
135
|
-
"@sanity/pkg-utils": "^8.1.
|
|
135
|
+
"@sanity/pkg-utils": "^8.1.12",
|
|
136
136
|
"@sanity/prettier-config": "^2.0.1",
|
|
137
137
|
"@sanity/semantic-release-preset": "^5.0.0",
|
|
138
138
|
"@sanity/ui-workshop": "4.0.0-static.11",
|
|
@@ -141,14 +141,14 @@
|
|
|
141
141
|
"@testing-library/react": "^16.3.0",
|
|
142
142
|
"@testing-library/user-event": "^14.6.1",
|
|
143
143
|
"@types/node": "^24.3.0",
|
|
144
|
-
"@types/react": "^19.1.
|
|
145
|
-
"@types/react-dom": "^19.1.
|
|
144
|
+
"@types/react": "^19.1.13",
|
|
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
149
|
"@vitejs/plugin-react": "^5.0.1",
|
|
150
150
|
"@vitest/browser": "^3.2.4",
|
|
151
|
-
"babel-plugin-react-compiler": "19.1.0-rc.
|
|
151
|
+
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
152
152
|
"browserslist-config-baseline": "^0.5.0",
|
|
153
153
|
"cac": "^6.7.14",
|
|
154
154
|
"commitizen": "^4.3.1",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"cypress-real-events": "^1.14.0",
|
|
157
157
|
"cz-conventional-changelog": "^3.3.0",
|
|
158
158
|
"dotenv-flow": "^4.1.0",
|
|
159
|
-
"eslint": "^9.
|
|
159
|
+
"eslint": "^9.35.0",
|
|
160
160
|
"eslint-config-prettier": "^10.1.8",
|
|
161
161
|
"eslint-formatter-compact": "^8.40.0",
|
|
162
162
|
"eslint-plugin-boundaries": "^5.0.1",
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"eslint-plugin-react-hooks": "0.0.0-experimental-66f09bd0-20250806",
|
|
168
168
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
169
169
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
170
|
-
"eslint-plugin-storybook": "^9.1.
|
|
170
|
+
"eslint-plugin-storybook": "^9.1.7",
|
|
171
171
|
"globals": "^16.3.0",
|
|
172
172
|
"husky": "^8.0.3",
|
|
173
173
|
"jsdom": "^26.1.0",
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
"styled-components": "^6.1.19",
|
|
187
187
|
"tsconfig-paths": "^4.2.0",
|
|
188
188
|
"typescript": "5.9.2",
|
|
189
|
-
"typescript-eslint": "^8.
|
|
189
|
+
"typescript-eslint": "^8.44.0",
|
|
190
190
|
"vite": "^7.1.3",
|
|
191
191
|
"vite-tsconfig-paths": "^5.1.4",
|
|
192
192
|
"vitest": "^3.2.4",
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"react-dom": "^19",
|
|
198
198
|
"react-is": "^19"
|
|
199
199
|
},
|
|
200
|
-
"packageManager": "pnpm@10.
|
|
200
|
+
"packageManager": "pnpm@10.17.0",
|
|
201
201
|
"engines": {
|
|
202
202
|
"node": ">=20.19 <22 || >=22.12"
|
|
203
203
|
},
|
|
@@ -139,10 +139,6 @@ export function Menu<E extends MenuElementType = typeof DEFAULT_MENU_ELEMENT>(
|
|
|
139
139
|
onItemMouseEnter: handleItemMouseEnter,
|
|
140
140
|
onItemMouseLeave: handleItemMouseLeave,
|
|
141
141
|
registerElement,
|
|
142
|
-
|
|
143
|
-
// deprecated
|
|
144
|
-
onMouseEnter: handleItemMouseEnter,
|
|
145
|
-
onMouseLeave: handleItemMouseLeave,
|
|
146
142
|
}),
|
|
147
143
|
[
|
|
148
144
|
activeElement,
|
|
@@ -133,7 +133,6 @@ export function MenuItem<E extends MenuItemElementType = typeof DEFAULT_MENU_ITE
|
|
|
133
133
|
{...rest}
|
|
134
134
|
as={as}
|
|
135
135
|
data-pressed={pressed ? '' : undefined}
|
|
136
|
-
data-selected={active ? '' : undefined}
|
|
137
136
|
data-disabled={disabled ? '' : undefined}
|
|
138
137
|
radius={radius}
|
|
139
138
|
disabled={disabled}
|
|
@@ -142,6 +141,7 @@ export function MenuItem<E extends MenuItemElementType = typeof DEFAULT_MENU_ITE
|
|
|
142
141
|
onMouseLeave={onItemMouseLeave}
|
|
143
142
|
ref={setRef}
|
|
144
143
|
role={role}
|
|
144
|
+
selected={active}
|
|
145
145
|
tabIndex={-1}
|
|
146
146
|
tone={tone}
|
|
147
147
|
type={as === 'button' ? 'button' : undefined}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {use} from 'react'
|
|
2
2
|
|
|
3
3
|
import {isRecord} from '../../lib/isRecord'
|
|
4
4
|
import {ToastContext} from './ToastContext'
|
|
@@ -6,7 +6,7 @@ import type {ToastContextValue} from './types'
|
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export function useToast(): ToastContextValue {
|
|
9
|
-
const value =
|
|
9
|
+
const value = use(ToastContext)
|
|
10
10
|
|
|
11
11
|
if (!value) {
|
|
12
12
|
throw new Error('useToast(): missing context value')
|
|
@@ -47,7 +47,7 @@ export function Avatar<E extends AvatarElementType = typeof DEFAULT_AVATAR_ELEME
|
|
|
47
47
|
props: AvatarProps<E>,
|
|
48
48
|
): React.JSX.Element {
|
|
49
49
|
const {
|
|
50
|
-
__unstable_hideInnerStroke,
|
|
50
|
+
__unstable_hideInnerStroke: hideInnerStroke,
|
|
51
51
|
as: Element = DEFAULT_AVATAR_ELEMENT,
|
|
52
52
|
className,
|
|
53
53
|
color = 'magenta',
|
|
@@ -104,7 +104,7 @@ export function Avatar<E extends AvatarElementType = typeof DEFAULT_AVATAR_ELEME
|
|
|
104
104
|
|
|
105
105
|
return (
|
|
106
106
|
<Element
|
|
107
|
-
data-hide-inner-stroke={
|
|
107
|
+
data-hide-inner-stroke={hideInnerStroke ? '' : undefined}
|
|
108
108
|
data-ui="Avatar"
|
|
109
109
|
{...rest}
|
|
110
110
|
aria-label={title}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Avatar, Box} from '@sanity/ui'
|
|
2
|
+
import type {AvatarSize} from '@sanity/ui/theme'
|
|
3
|
+
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
4
|
+
|
|
5
|
+
import {WORKSHOP_AVATAR_SIZE_OPTIONS, WORKSHOP_AVATAR_SRC} from '$workshop'
|
|
6
|
+
|
|
7
|
+
export default function PropsStory() {
|
|
8
|
+
const hideInnerStroke = useBoolean('Hide inner stroke', false)
|
|
9
|
+
const src = useBoolean('With image source (src)', false)
|
|
10
|
+
// @ts-expect-error - TODO: fix this
|
|
11
|
+
const size = useSelect<AvatarSize>('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Box alignItems="center" display="flex" height="fill" justifyContent="center">
|
|
15
|
+
<Avatar
|
|
16
|
+
__unstable_hideInnerStroke={hideInnerStroke}
|
|
17
|
+
size={size}
|
|
18
|
+
src={src ? WORKSHOP_AVATAR_SRC : undefined}
|
|
19
|
+
/>
|
|
20
|
+
</Box>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
} from '@sanity/ui/css'
|
|
10
10
|
import {button, buttonLoadingBox} from '@sanity/ui/css'
|
|
11
11
|
import type {FontTextSize} from '@sanity/ui/theme'
|
|
12
|
-
import {
|
|
12
|
+
import {isValidElement} from 'react'
|
|
13
13
|
import {isValidElementType} from 'react-is'
|
|
14
14
|
|
|
15
15
|
import type {ComponentType, Props} from '../../types'
|
|
@@ -30,8 +30,8 @@ export type ButtonOwnProps = ButtonStyleProps &
|
|
|
30
30
|
'data-ui'?: string
|
|
31
31
|
'disabled'?: boolean
|
|
32
32
|
'fontSize'?: ResponsiveProp<FontTextSize>
|
|
33
|
-
'icon'?:
|
|
34
|
-
'iconRight'?:
|
|
33
|
+
'icon'?: React.ElementType | React.ReactNode
|
|
34
|
+
'iconRight'?: React.ElementType | React.ReactNode
|
|
35
35
|
'justify'?: BoxStyleProps['justifyContent']
|
|
36
36
|
/** @beta Do not use in production, as this might change.*/
|
|
37
37
|
'loading'?: boolean
|
|
@@ -39,7 +39,7 @@ export type ButtonOwnProps = ButtonStyleProps &
|
|
|
39
39
|
'textAlign'?: ButtonTextAlign
|
|
40
40
|
'muted'?: boolean
|
|
41
41
|
'target'?: string
|
|
42
|
-
'text'?: ReactNode
|
|
42
|
+
'text'?: React.ReactNode
|
|
43
43
|
'textOverflow'?: TextOwnProps['textOverflow']
|
|
44
44
|
'textWeight'?: TextOwnProps['weight']
|
|
45
45
|
'width'?: ResponsiveProp<Width>
|
|
@@ -71,6 +71,7 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
|
|
|
71
71
|
justify = 'center',
|
|
72
72
|
loading,
|
|
73
73
|
mode = 'default',
|
|
74
|
+
muted = false,
|
|
74
75
|
padding = 3,
|
|
75
76
|
paddingX,
|
|
76
77
|
paddingY,
|
|
@@ -86,7 +87,6 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
|
|
|
86
87
|
textWeight = 'medium',
|
|
87
88
|
tone = 'default',
|
|
88
89
|
type = 'button',
|
|
89
|
-
muted = false,
|
|
90
90
|
width,
|
|
91
91
|
...rest
|
|
92
92
|
} = props as ButtonProps<typeof DEFAULT_BUTTON_ELEMENT>
|
|
@@ -31,6 +31,14 @@ export function Code<E extends CodeElementType = typeof DEFAULT_CODE_ELEMENT>(
|
|
|
31
31
|
children,
|
|
32
32
|
className,
|
|
33
33
|
language: languageProp,
|
|
34
|
+
margin,
|
|
35
|
+
marginX,
|
|
36
|
+
marginY,
|
|
37
|
+
marginTop,
|
|
38
|
+
marginRight,
|
|
39
|
+
marginBottom,
|
|
40
|
+
marginLeft,
|
|
41
|
+
maxWidth,
|
|
34
42
|
size = 2,
|
|
35
43
|
weight = 'regular',
|
|
36
44
|
...rest
|
|
@@ -39,7 +47,23 @@ export function Code<E extends CodeElementType = typeof DEFAULT_CODE_ELEMENT>(
|
|
|
39
47
|
const language = typeof languageProp === 'string' ? languageProp : undefined
|
|
40
48
|
|
|
41
49
|
return (
|
|
42
|
-
<Element
|
|
50
|
+
<Element
|
|
51
|
+
data-ui="Code"
|
|
52
|
+
{...rest}
|
|
53
|
+
className={code({
|
|
54
|
+
className,
|
|
55
|
+
margin,
|
|
56
|
+
marginX,
|
|
57
|
+
marginY,
|
|
58
|
+
marginTop,
|
|
59
|
+
marginRight,
|
|
60
|
+
marginBottom,
|
|
61
|
+
marginLeft,
|
|
62
|
+
maxWidth,
|
|
63
|
+
size,
|
|
64
|
+
weight,
|
|
65
|
+
})}
|
|
66
|
+
>
|
|
43
67
|
<Suspense fallback={<code>{children}</code>}>
|
|
44
68
|
<LazyRefractor language={language} value={children} />
|
|
45
69
|
</Suspense>
|
|
@@ -46,6 +46,14 @@ export function Heading<E extends HeadingElementType = typeof DEFAULT_HEADING_EL
|
|
|
46
46
|
children,
|
|
47
47
|
className,
|
|
48
48
|
flex,
|
|
49
|
+
margin,
|
|
50
|
+
marginX,
|
|
51
|
+
marginY,
|
|
52
|
+
marginTop,
|
|
53
|
+
marginRight,
|
|
54
|
+
marginBottom,
|
|
55
|
+
marginLeft,
|
|
56
|
+
maxWidth,
|
|
49
57
|
muted = false,
|
|
50
58
|
size = 2,
|
|
51
59
|
textOverflow: textOverflowProp,
|
|
@@ -61,6 +69,14 @@ export function Heading<E extends HeadingElementType = typeof DEFAULT_HEADING_EL
|
|
|
61
69
|
className,
|
|
62
70
|
align,
|
|
63
71
|
flex,
|
|
72
|
+
margin,
|
|
73
|
+
marginX,
|
|
74
|
+
marginY,
|
|
75
|
+
marginTop,
|
|
76
|
+
marginRight,
|
|
77
|
+
marginBottom,
|
|
78
|
+
marginLeft,
|
|
79
|
+
maxWidth,
|
|
64
80
|
muted,
|
|
65
81
|
size,
|
|
66
82
|
weight,
|
|
@@ -44,6 +44,14 @@ export function Label<E extends LabelElementType = typeof DEFAULT_LABEL_ELEMENT>
|
|
|
44
44
|
as: Element = DEFAULT_LABEL_ELEMENT,
|
|
45
45
|
children,
|
|
46
46
|
className,
|
|
47
|
+
margin,
|
|
48
|
+
marginX,
|
|
49
|
+
marginY,
|
|
50
|
+
marginTop,
|
|
51
|
+
marginRight,
|
|
52
|
+
marginBottom,
|
|
53
|
+
marginLeft,
|
|
54
|
+
maxWidth,
|
|
47
55
|
muted = false,
|
|
48
56
|
size = 1,
|
|
49
57
|
textOverflow: textOverflowProp,
|
|
@@ -58,6 +66,14 @@ export function Label<E extends LabelElementType = typeof DEFAULT_LABEL_ELEMENT>
|
|
|
58
66
|
className={label({
|
|
59
67
|
className,
|
|
60
68
|
align,
|
|
69
|
+
margin,
|
|
70
|
+
marginX,
|
|
71
|
+
marginY,
|
|
72
|
+
marginTop,
|
|
73
|
+
marginRight,
|
|
74
|
+
marginBottom,
|
|
75
|
+
marginLeft,
|
|
76
|
+
maxWidth,
|
|
61
77
|
muted,
|
|
62
78
|
size,
|
|
63
79
|
weight,
|
|
@@ -47,7 +47,7 @@ export function Radio<E extends RadioElementType = typeof DEFAULT_RADIO_ELEMENT>
|
|
|
47
47
|
useCustomValidity(ref, customValidity)
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<
|
|
50
|
+
<span className={radio({className})} data-ui="Radio" style={style}>
|
|
51
51
|
<Element
|
|
52
52
|
{...rest}
|
|
53
53
|
className={radioInput()}
|
|
@@ -59,6 +59,6 @@ export function Radio<E extends RadioElementType = typeof DEFAULT_RADIO_ELEMENT>
|
|
|
59
59
|
type="radio"
|
|
60
60
|
/>
|
|
61
61
|
<span className={radioPresentation()} />
|
|
62
|
-
</
|
|
62
|
+
</span>
|
|
63
63
|
)
|
|
64
64
|
}
|
|
@@ -36,12 +36,14 @@ export function Select<E extends SelectElementType = typeof DEFAULT_SELECT_ELEME
|
|
|
36
36
|
children,
|
|
37
37
|
customValidity,
|
|
38
38
|
disabled,
|
|
39
|
+
flex,
|
|
39
40
|
fontSize = 2,
|
|
40
41
|
gap = 2,
|
|
41
42
|
padding = 3,
|
|
42
43
|
radius = 1,
|
|
43
44
|
readOnly,
|
|
44
45
|
ref: forwardedRef,
|
|
46
|
+
width = 'fill',
|
|
45
47
|
...rest
|
|
46
48
|
} = props as SelectProps<typeof DEFAULT_SELECT_ELEMENT>
|
|
47
49
|
|
|
@@ -55,9 +57,9 @@ export function Select<E extends SelectElementType = typeof DEFAULT_SELECT_ELEME
|
|
|
55
57
|
useCustomValidity(ref, customValidity)
|
|
56
58
|
|
|
57
59
|
return (
|
|
58
|
-
<
|
|
60
|
+
<span
|
|
59
61
|
data-ui="Select"
|
|
60
|
-
className={select({border, fontSize, gap, padding, radius})}
|
|
62
|
+
className={select({border, fontSize, flex, gap, padding, radius, width})}
|
|
61
63
|
data-icon-right=""
|
|
62
64
|
>
|
|
63
65
|
<Element {...rest} className={_inputElement()} disabled={disabled || readOnly} ref={ref}>
|
|
@@ -70,6 +72,6 @@ export function Select<E extends SelectElementType = typeof DEFAULT_SELECT_ELEME
|
|
|
70
72
|
</Text>
|
|
71
73
|
</Box>
|
|
72
74
|
</span>
|
|
73
|
-
</
|
|
75
|
+
</span>
|
|
74
76
|
)
|
|
75
77
|
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
import {useEffect, useImperativeHandle, useRef} from 'react'
|
|
9
9
|
|
|
10
10
|
import type {ComponentType, Props} from '../../types'
|
|
11
|
-
import {Box} from '../box/Box'
|
|
12
11
|
|
|
13
12
|
/** @public */
|
|
14
13
|
export const DEFAULT_SWITCH_ELEMENT = 'input'
|
|
@@ -41,7 +40,6 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
|
|
|
41
40
|
indeterminate,
|
|
42
41
|
readOnly,
|
|
43
42
|
ref: forwardedRef,
|
|
44
|
-
style,
|
|
45
43
|
...rest
|
|
46
44
|
} = props as SwitchProps<typeof DEFAULT_SWITCH_ELEMENT>
|
|
47
45
|
|
|
@@ -60,13 +58,7 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
|
|
|
60
58
|
}, [indeterminate])
|
|
61
59
|
|
|
62
60
|
return (
|
|
63
|
-
<
|
|
64
|
-
className={_switch({className})}
|
|
65
|
-
data-ui="Switch"
|
|
66
|
-
display="block"
|
|
67
|
-
position="relative"
|
|
68
|
-
style={style}
|
|
69
|
-
>
|
|
61
|
+
<span className={_switch({className})} data-ui="Switch">
|
|
70
62
|
<Element
|
|
71
63
|
{...rest}
|
|
72
64
|
className={_switchElement()}
|
|
@@ -79,6 +71,6 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
|
|
|
79
71
|
<span className={_switchTrack()} />
|
|
80
72
|
<span className={_switchThumb()} />
|
|
81
73
|
</span>
|
|
82
|
-
</
|
|
74
|
+
</span>
|
|
83
75
|
)
|
|
84
76
|
}
|
|
@@ -42,6 +42,13 @@ export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(
|
|
|
42
42
|
children,
|
|
43
43
|
className,
|
|
44
44
|
flex,
|
|
45
|
+
margin,
|
|
46
|
+
marginX,
|
|
47
|
+
marginY,
|
|
48
|
+
marginTop,
|
|
49
|
+
marginRight,
|
|
50
|
+
marginBottom,
|
|
51
|
+
marginLeft,
|
|
45
52
|
maxWidth = 'fill',
|
|
46
53
|
muted,
|
|
47
54
|
size = 2,
|
|
@@ -58,6 +65,13 @@ export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(
|
|
|
58
65
|
className,
|
|
59
66
|
align,
|
|
60
67
|
flex,
|
|
68
|
+
margin,
|
|
69
|
+
marginX,
|
|
70
|
+
marginY,
|
|
71
|
+
marginTop,
|
|
72
|
+
marginRight,
|
|
73
|
+
marginBottom,
|
|
74
|
+
marginLeft,
|
|
61
75
|
maxWidth,
|
|
62
76
|
muted,
|
|
63
77
|
size,
|
|
@@ -37,14 +37,17 @@ export function TextArea<E extends TextAreaElementType = typeof DEFAULT_TEXT_ARE
|
|
|
37
37
|
__unstable_disableFocusRing,
|
|
38
38
|
as: Element = DEFAULT_TEXT_AREA_ELEMENT,
|
|
39
39
|
border = true,
|
|
40
|
+
className,
|
|
40
41
|
customValidity,
|
|
41
42
|
disabled = false,
|
|
43
|
+
flex,
|
|
42
44
|
fontSize = 2,
|
|
43
45
|
gap = 3,
|
|
44
46
|
padding = 3,
|
|
45
47
|
radius = 2,
|
|
46
48
|
readOnly,
|
|
47
49
|
ref: forwardedRef,
|
|
50
|
+
width,
|
|
48
51
|
...rest
|
|
49
52
|
} = props as TextAreaProps<typeof DEFAULT_TEXT_AREA_ELEMENT>
|
|
50
53
|
|
|
@@ -60,11 +63,14 @@ export function TextArea<E extends TextAreaElementType = typeof DEFAULT_TEXT_ARE
|
|
|
60
63
|
return (
|
|
61
64
|
<span
|
|
62
65
|
className={textArea({
|
|
66
|
+
className,
|
|
63
67
|
border,
|
|
68
|
+
flex,
|
|
64
69
|
fontSize,
|
|
70
|
+
gap,
|
|
65
71
|
padding,
|
|
66
72
|
radius,
|
|
67
|
-
|
|
73
|
+
width,
|
|
68
74
|
})}
|
|
69
75
|
data-invalid={customValidity ? '' : undefined}
|
|
70
76
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
@@ -86,6 +86,7 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
86
86
|
className,
|
|
87
87
|
clearButton,
|
|
88
88
|
disabled = false,
|
|
89
|
+
flex,
|
|
89
90
|
fontSize = 2,
|
|
90
91
|
gap = 3,
|
|
91
92
|
icon: IconComponent,
|
|
@@ -166,15 +167,15 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
166
167
|
)
|
|
167
168
|
|
|
168
169
|
return (
|
|
169
|
-
<
|
|
170
|
-
alignItems="center"
|
|
170
|
+
<span
|
|
171
171
|
className={textInput({
|
|
172
172
|
className,
|
|
173
173
|
border,
|
|
174
|
+
flex,
|
|
174
175
|
fontSize,
|
|
175
176
|
padding,
|
|
176
177
|
radius,
|
|
177
|
-
gap
|
|
178
|
+
gap,
|
|
178
179
|
width,
|
|
179
180
|
})}
|
|
180
181
|
data-icon-left={IconComponent ? '' : undefined}
|
|
@@ -184,15 +185,14 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
184
185
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
185
186
|
data-suffix={suffix ? '' : undefined}
|
|
186
187
|
data-ui="TextInput"
|
|
187
|
-
display="flex"
|
|
188
188
|
>
|
|
189
189
|
{prefix && (
|
|
190
|
-
<
|
|
190
|
+
<span className={textInputPrefix()}>
|
|
191
191
|
<span>{prefix}</span>
|
|
192
|
-
</
|
|
192
|
+
</span>
|
|
193
193
|
)}
|
|
194
194
|
|
|
195
|
-
<
|
|
195
|
+
<span className={textInputElement()}>
|
|
196
196
|
<Element
|
|
197
197
|
{...rest}
|
|
198
198
|
className={_inputElement()}
|
|
@@ -203,10 +203,10 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
203
203
|
type={type}
|
|
204
204
|
/>
|
|
205
205
|
|
|
206
|
-
<
|
|
206
|
+
<span className={_inputPresentation()}>
|
|
207
207
|
{IconComponent && (
|
|
208
|
-
<Box padding={padding} position="absolute" insetTop={0} insetLeft={0}>
|
|
209
|
-
<Text size={fontSize}>
|
|
208
|
+
<Box as="span" padding={padding} position="absolute" insetTop={0} insetLeft={0}>
|
|
209
|
+
<Text as="span" size={fontSize}>
|
|
210
210
|
{isValidElement(IconComponent) && IconComponent}
|
|
211
211
|
{isValidElementType(IconComponent) && <IconComponent />}
|
|
212
212
|
</Text>
|
|
@@ -214,17 +214,18 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
214
214
|
)}
|
|
215
215
|
|
|
216
216
|
{!withClearButton && IconRightComponent && (
|
|
217
|
-
<Box padding={padding} position="absolute" insetTop={0} insetRight={0}>
|
|
218
|
-
<Text size={fontSize}>
|
|
217
|
+
<Box as="span" padding={padding} position="absolute" insetTop={0} insetRight={0}>
|
|
218
|
+
<Text as="span" size={fontSize}>
|
|
219
219
|
{isValidElement(IconRightComponent) && IconRightComponent}
|
|
220
220
|
{isValidElementType(IconRightComponent) && <IconRightComponent />}
|
|
221
221
|
</Text>
|
|
222
222
|
</Box>
|
|
223
223
|
)}
|
|
224
|
-
</
|
|
224
|
+
</span>
|
|
225
225
|
|
|
226
226
|
{!disabled && !readOnly && clearButton && (
|
|
227
227
|
<Box
|
|
228
|
+
as="span"
|
|
228
229
|
insetTop={0}
|
|
229
230
|
insetRight={0}
|
|
230
231
|
padding={clearButtonBoxPadding}
|
|
@@ -246,13 +247,13 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
246
247
|
/>
|
|
247
248
|
</Box>
|
|
248
249
|
)}
|
|
249
|
-
</
|
|
250
|
+
</span>
|
|
250
251
|
|
|
251
252
|
{suffix && (
|
|
252
|
-
<
|
|
253
|
+
<span className={textInputSuffix()}>
|
|
253
254
|
<span>{suffix}</span>
|
|
254
|
-
</
|
|
255
|
+
</span>
|
|
255
256
|
)}
|
|
256
|
-
</
|
|
257
|
+
</span>
|
|
257
258
|
)
|
|
258
259
|
}
|
package/src/core/types.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
|
|
4
|
-
import type {ComponentClass, ComponentProps, ExoticComponent, FunctionComponent, JSX} from 'react'
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Assign properties from `U` to `T`, excluding properties that already exist in `T`.
|
|
8
6
|
*
|
|
@@ -14,17 +12,20 @@ export type Assign<T extends {}, U extends {}> = Omit<T, keyof U> & U
|
|
|
14
12
|
export type EmptyProps = {}
|
|
15
13
|
|
|
16
14
|
/** @public */
|
|
17
|
-
export type TagType = keyof JSX.IntrinsicElements
|
|
15
|
+
export type TagType = keyof React.JSX.IntrinsicElements
|
|
18
16
|
|
|
19
17
|
/** @public */
|
|
20
|
-
export type ComponentType<P = any> =
|
|
18
|
+
export type ComponentType<P = any> =
|
|
19
|
+
| React.FunctionComponent<P>
|
|
20
|
+
| React.ComponentClass<P>
|
|
21
|
+
| React.ExoticComponent<P>
|
|
21
22
|
|
|
22
23
|
/** @public */
|
|
23
24
|
export type ElementType<P> = TagType | ComponentType<P>
|
|
24
25
|
|
|
25
26
|
/** @public */
|
|
26
27
|
export type Props<P extends EmptyProps, E extends ElementType<P>> = Assign<
|
|
27
|
-
E extends TagType ? JSX.IntrinsicElements[E] : ComponentProps<E>,
|
|
28
|
+
E extends TagType ? React.JSX.IntrinsicElements[E] : React.ComponentProps<E>,
|
|
28
29
|
P & {as?: E}
|
|
29
30
|
>
|
|
30
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {type ReactNode,
|
|
1
|
+
import {type ReactNode, use, useMemo, useRef, useSyncExternalStore} from 'react'
|
|
2
2
|
|
|
3
3
|
import {PortalContext} from './PortalContext'
|
|
4
4
|
import type {PortalContextValue} from './types'
|
|
@@ -17,7 +17,7 @@ export interface PortalProviderProps {
|
|
|
17
17
|
export function PortalProvider(props: PortalProviderProps): React.JSX.Element {
|
|
18
18
|
const {children, element, __unstable_elements: elementsProp} = props
|
|
19
19
|
const elements = useUnique(elementsProp)
|
|
20
|
-
const parentPortal =
|
|
20
|
+
const parentPortal = use(PortalContext)
|
|
21
21
|
const fallbackElement = useSyncExternalStore(
|
|
22
22
|
emptySubscribe,
|
|
23
23
|
() => elements?.['default'] ?? (parentPortal.element || document.body),
|
|
@@ -37,8 +37,7 @@ export const element: string = _style(layers.primitives, {
|
|
|
37
37
|
display: 'block',
|
|
38
38
|
boxSizing: 'border-box',
|
|
39
39
|
resize: 'none',
|
|
40
|
-
|
|
41
|
-
width: ['-moz-available', '-webkit-fill-available', 'stretch'],
|
|
40
|
+
inlineSize: 'stretch',
|
|
42
41
|
|
|
43
42
|
selectors: {
|
|
44
43
|
'&::placeholder': {
|
|
@@ -112,12 +111,12 @@ export const presentation: string = _style(layers.primitives, {
|
|
|
112
111
|
backgroundColor: vars.color.input.text.bg,
|
|
113
112
|
borderRadius: 'inherit',
|
|
114
113
|
boxShadow: `inset 0 0 0 ${vars.input.border.width} ${vars.color.input.text.border}`,
|
|
114
|
+
display: 'block',
|
|
115
115
|
position: 'absolute',
|
|
116
116
|
top: 0,
|
|
117
117
|
left: 0,
|
|
118
118
|
right: 0,
|
|
119
119
|
bottom: 0,
|
|
120
|
-
display: 'block',
|
|
121
120
|
pointerEvents: 'none',
|
|
122
121
|
zIndex: 0,
|
|
123
122
|
|