@sanity/ui 5.0.0-alpha.12 → 5.0.0-alpha.14
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/index.d.ts +46 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +321 -300
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/components/index.css +1 -0
- package/src/components/select/Select.tsx +1 -7
- package/src/components/select/select.css +2 -2
- package/src/components/select/select.props.ts +6 -14
- package/src/components/text-input/TextInput.tsx +32 -0
- package/src/components/text-input/text-input.css +49 -0
- package/src/components/text-input/textInput.props.ts +41 -0
- package/src/css/classes/local/text-trim.css +0 -4
- package/src/css/classes/system/typography.css +0 -4
- package/src/css/tokens/semantic.css +1 -1
- package/src/index.ts +2 -1
- package/src/types/Heading.ts +1 -1
- package/src/version.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.14",
|
|
4
4
|
"description": "Sanity UI Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@sanity-labs/design-tokens": "0.0.2-alpha.
|
|
51
|
+
"@sanity-labs/design-tokens": "0.0.2-alpha.6",
|
|
52
52
|
"@sanity/icons": "^5.2.1",
|
|
53
53
|
"clsx": "^2.1.1",
|
|
54
54
|
"comment-json": "^5.0.0",
|
package/src/components/index.css
CHANGED
|
@@ -16,13 +16,7 @@ export function Select({density = 'regular', hasError = false, ...props}: Select
|
|
|
16
16
|
const anchorId = useId()
|
|
17
17
|
const anchorName = `--anchor-${anchorId}`
|
|
18
18
|
|
|
19
|
-
const selectClasses = clsx(
|
|
20
|
-
selectClassName,
|
|
21
|
-
hasError && 'sui-error',
|
|
22
|
-
'sui-radius2',
|
|
23
|
-
'sui-width-full',
|
|
24
|
-
className,
|
|
25
|
-
)
|
|
19
|
+
const selectClasses = clsx(selectClassName, 'sui-radius2', 'sui-width-full', className)
|
|
26
20
|
|
|
27
21
|
const iconClasses = `sui-position-absolute sui-display-flex sui-align-items-center sui-px1`
|
|
28
22
|
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
/**
|
|
22
22
|
* Error
|
|
23
23
|
*/
|
|
24
|
-
.sui-Select
|
|
24
|
+
.sui-Select[aria-invalid="true"] {
|
|
25
25
|
--border-color: var(--error-separator);
|
|
26
26
|
--color: var(--error-foreground);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.sui-Select
|
|
29
|
+
.sui-Select[aria-invalid="true"] + [data-ui="Select-icon"] svg {
|
|
30
30
|
color: var(--error-foreground);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -2,22 +2,14 @@ import {formElementDensityProps, type FormElementDensityProps} from '../../props
|
|
|
2
2
|
import {type PropDef} from '../../types/PropDef'
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Used to trigger styling for invalid states.
|
|
13
|
-
*/
|
|
14
|
-
hasError?: boolean
|
|
15
|
-
}
|
|
5
|
+
export interface SelectProps extends React.ComponentProps<'select'>, FormElementDensityProps {
|
|
6
|
+
/**
|
|
7
|
+
* Used to trigger styling for invalid states.
|
|
8
|
+
*/
|
|
9
|
+
hasError?: boolean
|
|
10
|
+
}
|
|
16
11
|
|
|
17
12
|
export const selectProps: Record<string, PropDef> = {
|
|
18
|
-
disabled: {
|
|
19
|
-
type: 'boolean',
|
|
20
|
-
},
|
|
21
13
|
hasError: {
|
|
22
14
|
type: 'boolean',
|
|
23
15
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
|
|
3
|
+
import {getProps} from '../../utils/getProps'
|
|
4
|
+
import {suffixClassName} from '../../utils/suffixClassName'
|
|
5
|
+
import {type TextInputProps, textInputProps} from './textInput.props'
|
|
6
|
+
|
|
7
|
+
const textInputClassName = suffixClassName('sui-TextInput')
|
|
8
|
+
|
|
9
|
+
/** @public */
|
|
10
|
+
export function TextInput({
|
|
11
|
+
density = 'regular',
|
|
12
|
+
hasError = false,
|
|
13
|
+
type = 'text',
|
|
14
|
+
...props
|
|
15
|
+
}: TextInputProps) {
|
|
16
|
+
const {className, style, ...rest} = getProps({density, ...props}, textInputProps)
|
|
17
|
+
|
|
18
|
+
const textInputClasses = clsx(textInputClassName, 'sui-radius2', 'sui-width-full', className)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<input
|
|
22
|
+
type={type}
|
|
23
|
+
className={textInputClasses}
|
|
24
|
+
style={style}
|
|
25
|
+
data-ui="TextInput"
|
|
26
|
+
{...rest}
|
|
27
|
+
aria-invalid={hasError || undefined}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type {TextInputProps}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.sui-TextInput {
|
|
2
|
+
--background-color: var(--backdrop);
|
|
3
|
+
--border-color: var(--separator-high);
|
|
4
|
+
--color: var(--foreground-high);
|
|
5
|
+
background-color: var(--background-color);
|
|
6
|
+
border: 1px solid var(--border-color);
|
|
7
|
+
font: var(--form-element-text);
|
|
8
|
+
color: var(--color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sui-TextInput::placeholder {
|
|
12
|
+
color: oklch(from var(--color) l c h / var(--placeholder-opacity));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Error
|
|
17
|
+
*/
|
|
18
|
+
.sui-TextInput[aria-invalid="true"] {
|
|
19
|
+
--border-color: var(--error-separator);
|
|
20
|
+
--color: var(--error-foreground);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Hover - uses relative border/background colours to darken/lighten in both normal & error state
|
|
25
|
+
*/
|
|
26
|
+
.sui-TextInput:hover {
|
|
27
|
+
border-color: light-dark(
|
|
28
|
+
oklch(from var(--border-color) calc(l - var(--hover-lightness-delta)) c h),
|
|
29
|
+
oklch(from var(--border-color) calc(l + var(--hover-lightness-delta)) c h)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Disabled
|
|
35
|
+
*/
|
|
36
|
+
.sui-TextInput:disabled {
|
|
37
|
+
--background-color: var(--inert-background);
|
|
38
|
+
--border-color: var(--separator-low);
|
|
39
|
+
--color: var(--inert-foreground);
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Focus
|
|
45
|
+
*/
|
|
46
|
+
.sui-TextInput:focus-visible {
|
|
47
|
+
outline: var(--focus-outline);
|
|
48
|
+
outline-offset: var(--focus-offset);
|
|
49
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
|
|
2
|
+
import {type PropDef} from '../../types/PropDef'
|
|
3
|
+
|
|
4
|
+
export const TEXT_INPUT_EXCLUDED_TYPES = [
|
|
5
|
+
'button',
|
|
6
|
+
'checkbox',
|
|
7
|
+
'color',
|
|
8
|
+
'file',
|
|
9
|
+
'hidden',
|
|
10
|
+
'image',
|
|
11
|
+
'radio',
|
|
12
|
+
'range',
|
|
13
|
+
'reset',
|
|
14
|
+
'submit',
|
|
15
|
+
] as const
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
export type TextInputExcludedTypes = (typeof TEXT_INPUT_EXCLUDED_TYPES)[number]
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export type TextInputType = Exclude<React.HTMLInputTypeAttribute, TextInputExcludedTypes>
|
|
22
|
+
|
|
23
|
+
/** @public */
|
|
24
|
+
export interface TextInputProps
|
|
25
|
+
extends Omit<React.ComponentProps<'input'>, 'type'>, FormElementDensityProps {
|
|
26
|
+
/**
|
|
27
|
+
* Used to trigger styling for invalid states.
|
|
28
|
+
*/
|
|
29
|
+
hasError?: boolean
|
|
30
|
+
/**
|
|
31
|
+
* The html `type` attribute, with non-text based types excluded.
|
|
32
|
+
*/
|
|
33
|
+
type?: TextInputType
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const textInputProps: Record<string, PropDef> = {
|
|
37
|
+
hasError: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
},
|
|
40
|
+
...formElementDensityProps,
|
|
41
|
+
}
|
|
@@ -32,10 +32,6 @@
|
|
|
32
32
|
.sui-text-heading3 { --trim: -7px; }
|
|
33
33
|
.sui-text-heading4 { --trim: -8px; }
|
|
34
34
|
.sui-text-heading5 { --trim: -10px; }
|
|
35
|
-
.sui-text-heading6 { --trim: -13px; }
|
|
36
|
-
.sui-text-heading7 { --trim: -16px; }
|
|
37
|
-
.sui-text-heading8 { --trim: -22px; }
|
|
38
|
-
.sui-text-heading9 { --trim: -30px; }
|
|
39
35
|
|
|
40
36
|
.sui-text-code0 { --trim: -4px; }
|
|
41
37
|
.sui-text-code1 { --trim: -5px; }
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
.sui-text-heading3 { font: var(--heading-3); }
|
|
18
18
|
.sui-text-heading4 { font: var(--heading-4); }
|
|
19
19
|
.sui-text-heading5 { font: var(--heading-5); }
|
|
20
|
-
.sui-text-heading6 { font: var(--heading-6); }
|
|
21
|
-
.sui-text-heading7 { font: var(--heading-7); }
|
|
22
|
-
.sui-text-heading8 { font: var(--heading-8); }
|
|
23
|
-
.sui-text-heading9 { font: var(--heading-9); }
|
|
24
20
|
|
|
25
21
|
.sui-text-eyebrow0 { font: var(--label-0); }
|
|
26
22
|
.sui-text-eyebrow1 { font: var(--label-1); }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
--backdrop: light-dark(var(--white), var(--black));
|
|
3
3
|
--brand-background: #eb5228;
|
|
4
4
|
--brand-foreground: var(--black);
|
|
5
|
-
--placeholder-opacity:
|
|
5
|
+
--placeholder-opacity: 0.64;
|
|
6
6
|
--overlay-opacity: var(--opacity-mid);
|
|
7
7
|
/* State */
|
|
8
8
|
--active-background-normal: light-dark(var(--blue-50), var(--blue-950));
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
export * from './components/badge/Badge'
|
|
3
4
|
export * from './components/box/Box'
|
|
4
5
|
export * from './components/button/Button'
|
|
5
6
|
export * from './components/card/Card'
|
|
@@ -29,6 +30,7 @@ export * from './components/skip-to-content/SkipToContent'
|
|
|
29
30
|
export * from './components/spinner/Spinner'
|
|
30
31
|
export * from './components/switch/Switch'
|
|
31
32
|
export * from './components/text/Text'
|
|
33
|
+
export * from './components/text-input/TextInput'
|
|
32
34
|
export * from './components/tooltip/Tooltip'
|
|
33
35
|
export * from './components/tooltip-group/TooltipGroup'
|
|
34
36
|
export * from './components/v-stack/VStack'
|
|
@@ -65,4 +67,3 @@ export type {TextSize} from './types/Text'
|
|
|
65
67
|
export type {TextAlign} from './types/TextAlign'
|
|
66
68
|
export type {FontWeight} from './types/FontWeight'
|
|
67
69
|
export type {Tone} from './types/Tone'
|
|
68
|
-
export * from './components/badge/Badge'
|
package/src/types/Heading.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const HEADING_TAG = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const
|
|
2
2
|
export type HeadingTag = (typeof HEADING_TAG)[number]
|
|
3
3
|
|
|
4
|
-
export const HEADING_SIZE = [0, 1, 2, 3, 4, 5
|
|
4
|
+
export const HEADING_SIZE = [0, 1, 2, 3, 4, 5] as const
|
|
5
5
|
/** @public */
|
|
6
6
|
export type HeadingSize = (typeof HEADING_SIZE)[number]
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is generated by scripts/write-version.js. Do not edit.
|
|
2
|
-
export const VERSION = '
|
|
3
|
-
export const HASH = '
|
|
2
|
+
export const VERSION = '500alpha14'
|
|
3
|
+
export const HASH = 'f8a1c2'
|