@sanity/ui 3.0.0-static.19 → 3.0.0-static.20
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/_chunks-cjs/_visual-editing.cjs +109 -112
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-cjs/buildCommand.cjs +30 -24
- package/dist/_chunks-cjs/buildCommand.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +110 -113
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/css.cjs +379 -358
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +45 -10
- package/dist/css.d.ts +45 -10
- package/dist/css.js +379 -358
- package/dist/css.js.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/theme.cjs +89 -64
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.cts +28 -2
- package/dist/theme.d.ts +28 -2
- package/dist/theme.js +89 -64
- package/dist/theme.js.map +1 -1
- package/dist/ui-system.css +1236 -801
- package/dist/ui-system.min.css +1 -1
- package/dist/ui-theme.css +413 -82
- package/dist/ui-theme.min.css +1 -1
- package/dist/ui.css +1649 -883
- package/dist/ui.min.css +1 -1
- package/exports/_visual-editing.ts +0 -1
- package/package.json +6 -6
- package/src/cli/buildCommand.ts +48 -41
- package/src/core/components/autocomplete/__workshop__/async.tsx +1 -1
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +1 -1
- package/src/core/components/autocomplete/__workshop__/custom.tsx +12 -11
- package/src/core/components/autocomplete/__workshop__/example.tsx +13 -12
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +53 -54
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -2
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +2 -2
- package/src/core/components/dialog/__workshop__/onScroll.tsx +16 -4
- package/src/core/components/dialog/__workshop__/position.tsx +3 -3
- package/src/core/components/dialog/__workshop__/props.tsx +6 -6
- package/src/core/components/menu/__workshop__/menuButton.tsx +3 -3
- package/src/core/components/menu/__workshop__/tones.tsx +3 -3
- package/src/core/components/skeleton/__workshop__/delay.tsx +2 -2
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +2 -2
- package/src/core/components/tab/__workshop__/example.tsx +1 -1
- package/src/core/components/toast/__workshop__/toast.tsx +5 -5
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +2 -2
- package/src/core/primitives/avatar/__workshop__/stack.tsx +2 -2
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +1 -1
- package/src/core/primitives/badge/__workshop__/props.tsx +5 -8
- package/src/core/primitives/box/__workshop__/props.tsx +2 -2
- package/src/core/primitives/box/box.tsx +2 -0
- package/src/core/primitives/button/__workshop__/props.tsx +17 -19
- package/src/core/primitives/button/__workshop__/stacked.tsx +12 -12
- package/src/core/primitives/card/__workshop__/asButton.tsx +1 -1
- package/src/core/primitives/card/__workshop__/interactive.tsx +2 -2
- package/src/core/primitives/card/__workshop__/props.tsx +11 -11
- package/src/core/primitives/card/__workshop__/selected.tsx +2 -2
- package/src/core/primitives/checkbox/__workshop__/props.tsx +5 -5
- package/src/core/primitives/code/__workshop__/props.tsx +4 -7
- package/src/core/primitives/code/code.tsx +1 -1
- package/src/core/primitives/container/__workshop__/example.tsx +2 -2
- package/src/core/primitives/flex/__workshop__/example.tsx +2 -2
- package/src/core/primitives/heading/__workshop__/plain.tsx +11 -7
- package/src/core/primitives/heading/heading.tsx +1 -1
- package/src/core/primitives/inline/__workshop__/plain.tsx +2 -5
- package/src/core/primitives/label/__workshop__/plain.tsx +7 -8
- package/src/core/primitives/label/label.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +6 -6
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +3 -1
- package/src/core/primitives/radio/__workshop__/example.tsx +2 -2
- package/src/core/primitives/radio/__workshop__/plain.tsx +3 -3
- package/src/core/primitives/select/__workshop__/plain.tsx +5 -8
- package/src/core/primitives/spinner/__workshop__/Props.tsx +3 -3
- package/src/core/primitives/stack/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
- package/src/core/primitives/text/__workshop__/example.tsx +8 -11
- package/src/core/primitives/textArea/__workshop__/plain.tsx +11 -12
- package/src/core/primitives/textArea/textArea.tsx +10 -7
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/plain.tsx +30 -18
- package/src/core/primitives/textInput/__workshop__/states.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/typed.tsx +2 -2
- package/src/core/primitives/textInput/textInput.tsx +11 -20
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +3 -3
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +1 -1
- package/src/core/primitives/tooltip/__workshop__/props.tsx +4 -4
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +1 -1
- package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -3
- package/src/css/_system.style.ts +2 -0
- package/src/css/aspects/font/font.style.ts +9 -8
- package/src/css/aspects/index.ts +1 -0
- package/src/css/aspects/margin/margin.style.ts +13 -0
- package/src/css/aspects/margin/types.ts +12 -7
- package/src/css/aspects/minHeight/index.ts +2 -0
- package/src/css/aspects/minHeight/minHeight.style.ts +9 -0
- package/src/css/aspects/minHeight/minHeight.ts +8 -0
- package/src/css/aspects/minHeight/types.ts +9 -0
- package/src/css/components/skeleton/skeleton.style.ts +7 -10
- package/src/css/primitives/_input/_input.style.ts +30 -51
- package/src/css/primitives/_selectable/_selectable.style.ts +2 -3
- package/src/css/primitives/box/box.style.ts +0 -3
- package/src/css/primitives/box/box.ts +2 -0
- package/src/css/primitives/box/types.ts +2 -0
- package/src/css/primitives/card/card.style.ts +3 -0
- package/src/css/primitives/code/code.style.ts +1 -0
- package/src/css/primitives/heading/heading.style.ts +1 -0
- package/src/css/primitives/label/label.style.ts +1 -0
- package/src/css/primitives/text/text.style.ts +1 -0
- package/src/css/primitives/textArea/textArea.style.ts +1 -3
- package/src/css/primitives/textInput/textInput.style.ts +10 -18
- package/src/css/primitives/textInput/textInput.ts +15 -0
- package/src/css/primitives/tooltip/tooltip.style.ts +0 -13
- package/src/css/primitives/tooltip/tooltip.ts +0 -5
- package/src/css/theme/resolveTheme.ts +29 -18
- package/src/theme/v0/font.ts +0 -1
- package/src/theme/v2/defaults/fonts.ts +0 -1
- package/src/theme/v3/_parseColorToken.ts +0 -5
- package/src/theme/v3/buildTheme_v3.ts +2 -2
- package/src/theme/v3/defaultFonts.ts +250 -0
- package/src/theme/v3/defaultTokens.ts +39 -35
- package/src/theme/v3/types.ts +35 -2
- package/src/theme/versioning/v3_v2.ts +1 -0
- package/src/css/primitives/_input/__workshop__/customInput.tsx +0 -16
- package/src/css/primitives/_input/__workshop__/index.ts +0 -14
- /package/src/core/components/autocomplete/{__mocks__ → __workshop__/mock}/apiStore.ts +0 -0
- /package/src/core/components/autocomplete/{__mocks__ → __workshop__/mock}/countries.ts +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* These are internal exports for usage in `@sanity/visual-editing` and `@sanity/insert-menu`,
|
|
3
3
|
* which are used in environments where the regular `@sanity/ui` export is far too heavy due to imports from refractor and more.
|
|
4
4
|
*/
|
|
5
|
-
// export {studioTheme} from '../src/core/_compat'
|
|
6
5
|
export {ThemeProvider, type ThemeProviderProps} from '../src/core/_compat/theme/themeProvider'
|
|
7
6
|
export {useTheme_v2} from '../src/core/_compat/theme/useTheme'
|
|
8
7
|
export {Hotkeys, type HotkeysProps} from '../src/core/components/hotkeys/hotkeys'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "3.0.0-static.
|
|
3
|
+
"version": "3.0.0-static.20",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"ui",
|
|
@@ -197,10 +197,10 @@
|
|
|
197
197
|
"vitest-axe": "1.0.0-pre.5"
|
|
198
198
|
},
|
|
199
199
|
"peerDependencies": {
|
|
200
|
-
"react": "^
|
|
201
|
-
"react-dom": "^
|
|
202
|
-
"react-is": "^
|
|
203
|
-
"styled-components": "^
|
|
200
|
+
"react": "^19",
|
|
201
|
+
"react-dom": "^19",
|
|
202
|
+
"react-is": "^19",
|
|
203
|
+
"styled-components": "^6"
|
|
204
204
|
},
|
|
205
205
|
"engines": {
|
|
206
206
|
"node": ">=14.0.0"
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"storybook:dev": "storybook dev -p 6006",
|
|
231
231
|
"test": "vitest run",
|
|
232
232
|
"test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
|
|
233
|
-
"
|
|
233
|
+
"typecheck": "tsc",
|
|
234
234
|
"watch": "pkg watch --strict",
|
|
235
235
|
"workshop:build": "workshop build",
|
|
236
236
|
"workshop:clean": "rimraf .workshop",
|
package/src/cli/buildCommand.ts
CHANGED
|
@@ -13,64 +13,50 @@ export async function buildCommand(options: {cwd?: string; outDir?: string}): Pr
|
|
|
13
13
|
const cwd = options.cwd ?? process.cwd()
|
|
14
14
|
const outDir = options.outDir ?? path.resolve(cwd, 'dist')
|
|
15
15
|
|
|
16
|
-
await buildTheme({outDir})
|
|
17
|
-
await buildSystem({outDir})
|
|
18
|
-
await buildAll({outDir})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
async function minify(css: string) {
|
|
24
|
-
return postcss([cssnano()]).process(css, {from: undefined})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function prettify(css: string) {
|
|
28
|
-
const options = await resolveConfig(__dirname)
|
|
29
|
-
|
|
30
|
-
if (!options) {
|
|
31
|
-
throw new Error('Prettier config not found')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return format(css, {...options, filepath: 'index.css', printWidth: 9999})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function prettySize(str: string) {
|
|
38
|
-
return `${prettyBytes(str.length)} / ${prettyBytes(gzipSizeSync(str))}`
|
|
16
|
+
await buildTheme({cwd, outDir})
|
|
17
|
+
await buildSystem({cwd, outDir})
|
|
18
|
+
await buildAll({cwd, outDir})
|
|
39
19
|
}
|
|
40
20
|
|
|
41
21
|
// @sanity/ui/ui-theme.css
|
|
42
|
-
async function buildTheme(options: {outDir: string}) {
|
|
43
|
-
const {outDir} = options
|
|
22
|
+
async function buildTheme(options: {cwd: string; outDir: string}) {
|
|
23
|
+
const {cwd, outDir} = options
|
|
44
24
|
const css = await prettify(_compileTheme())
|
|
45
25
|
const minified = await minify(css)
|
|
46
26
|
const prettified = await prettify(css)
|
|
47
27
|
|
|
28
|
+
const cssFile = path.resolve(outDir, 'ui-theme.css')
|
|
29
|
+
const minCssFile = path.resolve(outDir, 'ui-theme.min.css')
|
|
30
|
+
|
|
48
31
|
await fs.mkdir(outDir, {recursive: true})
|
|
49
|
-
await fs.writeFile(
|
|
50
|
-
await fs.writeFile(
|
|
32
|
+
await fs.writeFile(cssFile, prettified, 'utf-8')
|
|
33
|
+
await fs.writeFile(minCssFile, minified.css, 'utf-8')
|
|
51
34
|
|
|
52
|
-
console.log(`- built
|
|
53
|
-
console.log(`- built
|
|
35
|
+
console.log(`- built ${path.relative(cwd, cssFile)} (${prettySize(prettified)})`)
|
|
36
|
+
console.log(`- built ${path.relative(cwd, minCssFile)} (${prettySize(minified.css)})`)
|
|
54
37
|
}
|
|
55
38
|
|
|
56
39
|
// @sanity/ui/ui-system.css
|
|
57
|
-
async function buildSystem(options: {outDir: string}) {
|
|
58
|
-
const {outDir} = options
|
|
40
|
+
async function buildSystem(options: {cwd: string; outDir: string}) {
|
|
41
|
+
const {cwd, outDir} = options
|
|
59
42
|
const css = await prettify(_compileSystem())
|
|
60
43
|
const minified = await minify(css)
|
|
61
44
|
const prettified = await prettify(css)
|
|
62
45
|
|
|
46
|
+
const cssFile = path.resolve(outDir, 'ui-system.css')
|
|
47
|
+
const minCssFile = path.resolve(outDir, 'ui-system.min.css')
|
|
48
|
+
|
|
63
49
|
await fs.mkdir(outDir, {recursive: true})
|
|
64
|
-
await fs.writeFile(
|
|
65
|
-
await fs.writeFile(
|
|
50
|
+
await fs.writeFile(cssFile, prettified, 'utf-8')
|
|
51
|
+
await fs.writeFile(minCssFile, minified.css, 'utf-8')
|
|
66
52
|
|
|
67
|
-
console.log(`- built
|
|
68
|
-
console.log(`- built
|
|
53
|
+
console.log(`- built ${path.relative(cwd, cssFile)} (${prettySize(prettified)})`)
|
|
54
|
+
console.log(`- built ${path.relative(cwd, minCssFile)} (${prettySize(minified.css)})`)
|
|
69
55
|
}
|
|
70
56
|
|
|
71
57
|
// @sanity/ui/ui.css
|
|
72
|
-
async function buildAll(options: {outDir: string}) {
|
|
73
|
-
const {outDir} = options
|
|
58
|
+
async function buildAll(options: {cwd: string; outDir: string}) {
|
|
59
|
+
const {cwd, outDir} = options
|
|
74
60
|
const css = await prettify(
|
|
75
61
|
[
|
|
76
62
|
`/* @sanity/ui/ui-theme.css */\n`,
|
|
@@ -84,10 +70,31 @@ async function buildAll(options: {outDir: string}) {
|
|
|
84
70
|
const minified = await minify(css)
|
|
85
71
|
const prettified = await prettify(css)
|
|
86
72
|
|
|
73
|
+
const cssFile = path.resolve(outDir, 'ui.css')
|
|
74
|
+
const minCssFile = path.resolve(outDir, 'ui.min.css')
|
|
75
|
+
|
|
87
76
|
await fs.mkdir(outDir, {recursive: true})
|
|
88
|
-
await fs.writeFile(
|
|
89
|
-
await fs.writeFile(
|
|
77
|
+
await fs.writeFile(cssFile, prettified, 'utf-8')
|
|
78
|
+
await fs.writeFile(minCssFile, minified.css, 'utf-8')
|
|
79
|
+
|
|
80
|
+
console.log(`- built ${path.relative(cwd, cssFile)} (${prettySize(prettified)})`)
|
|
81
|
+
console.log(`- built ${path.relative(cwd, minCssFile)} (${prettySize(minified.css)})`)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function minify(css: string) {
|
|
85
|
+
return postcss([cssnano()]).process(css, {from: undefined})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function prettify(css: string) {
|
|
89
|
+
const options = await resolveConfig(__dirname)
|
|
90
|
+
|
|
91
|
+
if (!options) {
|
|
92
|
+
throw new Error('Prettier config not found')
|
|
93
|
+
}
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
return format(css, {...options, filepath: 'index.css', printWidth: 9999})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function prettySize(str: string) {
|
|
99
|
+
return `${prettyBytes(str.length)} / ${prettyBytes(gzipSizeSync(str))}`
|
|
93
100
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '@sanity/ui'
|
|
13
13
|
import {useCallback, useEffect, useRef, useState} from 'react'
|
|
14
14
|
|
|
15
|
-
import {countriesStore} from '
|
|
15
|
+
import {countriesStore} from './mock/apiStore'
|
|
16
16
|
|
|
17
17
|
export default function AsyncStory() {
|
|
18
18
|
const [options, setOptions] = useState<BaseAutocompleteOption[]>([])
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
import {useCallback, useState} from 'react'
|
|
12
12
|
|
|
13
13
|
import {Popover} from '../../../primitives'
|
|
14
|
-
import countries from '../__mocks__/countries'
|
|
15
14
|
import type {AutocompleteProps} from '../autocomplete'
|
|
15
|
+
import countries from './mock/countries'
|
|
16
16
|
import type {ExampleOption} from './types'
|
|
17
17
|
|
|
18
18
|
export default function ConstrainedHeightStory() {
|
|
@@ -6,20 +6,21 @@ import {useCallback, useState} from 'react'
|
|
|
6
6
|
import {
|
|
7
7
|
WORKSHOP_RADIUS_OPTIONS,
|
|
8
8
|
WORKSHOP_SPACE_OPTIONS,
|
|
9
|
-
|
|
10
|
-
} from '
|
|
11
|
-
|
|
9
|
+
WORKSHOP_TEXT_FONT_SIZE_OPTIONS,
|
|
10
|
+
} from '$workshop'
|
|
11
|
+
|
|
12
|
+
import countries from './mock/countries'
|
|
12
13
|
import type {ExampleOption} from './types'
|
|
13
14
|
|
|
14
15
|
export default function CustomStory() {
|
|
15
16
|
const data: ExampleOption[] = countries.map((d) => ({value: d.code, title: d.name}))
|
|
16
|
-
const border = useBoolean('Border', true
|
|
17
|
-
const disabled = useBoolean('Disabled', false
|
|
18
|
-
const fontSize = useSelect('Font size',
|
|
19
|
-
const openButton = useBoolean('Open button', true
|
|
20
|
-
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS,
|
|
21
|
-
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS,
|
|
22
|
-
const readOnly = useBoolean('Read only', false
|
|
17
|
+
const border = useBoolean('Border', true)
|
|
18
|
+
const disabled = useBoolean('Disabled', false)
|
|
19
|
+
const fontSize = useSelect('Font size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS, 2)
|
|
20
|
+
const openButton = useBoolean('Open button', true)
|
|
21
|
+
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3)
|
|
22
|
+
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2)
|
|
23
|
+
const readOnly = useBoolean('Read only', false)
|
|
23
24
|
const [value, setValue] = useState('')
|
|
24
25
|
|
|
25
26
|
const renderOption = useCallback(
|
|
@@ -31,7 +32,7 @@ export default function CustomStory() {
|
|
|
31
32
|
key={option.value}
|
|
32
33
|
onClick={(event) => event.preventDefault()}
|
|
33
34
|
padding={padding}
|
|
34
|
-
radius={Math.max(radius - 1, 0) as Radius}
|
|
35
|
+
radius={Math.max((radius ?? 0) - 1, 0) as Radius}
|
|
35
36
|
>
|
|
36
37
|
<Text size={fontSize}>{option.title}</Text>
|
|
37
38
|
</Card>
|
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
WORKSHOP_CARD_TONE_OPTIONS,
|
|
9
9
|
WORKSHOP_RADIUS_OPTIONS,
|
|
10
10
|
WORKSHOP_SPACE_OPTIONS,
|
|
11
|
-
|
|
12
|
-
} from '
|
|
13
|
-
|
|
11
|
+
WORKSHOP_TEXT_FONT_SIZE_OPTIONS,
|
|
12
|
+
} from '$workshop'
|
|
13
|
+
|
|
14
|
+
import countries from './mock/countries'
|
|
14
15
|
|
|
15
16
|
const typingPerfTest: PerfTestProps<HTMLInputElement> = {
|
|
16
17
|
name: 'typing',
|
|
@@ -31,16 +32,16 @@ const typingPerfTest: PerfTestProps<HTMLInputElement> = {
|
|
|
31
32
|
export default function ExampleStory() {
|
|
32
33
|
const {ref, Wrapper} = usePerfTest(typingPerfTest)
|
|
33
34
|
|
|
34
|
-
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS
|
|
35
|
+
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS)
|
|
35
36
|
const options = useMemo(() => countries.map((country) => ({value: country.code})), [])
|
|
36
|
-
const border = useBoolean('Border', true
|
|
37
|
-
const customValidity = useText('Custom validity'
|
|
38
|
-
const disabled = useBoolean('Disabled', false
|
|
39
|
-
const fontSize = useSelect('Font size',
|
|
40
|
-
const openButton = useBoolean('Open button', false
|
|
41
|
-
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3
|
|
42
|
-
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2
|
|
43
|
-
const readOnly = useBoolean('Read only', false
|
|
37
|
+
const border = useBoolean('Border', true)
|
|
38
|
+
const customValidity = useText('Custom validity')
|
|
39
|
+
const disabled = useBoolean('Disabled', false)
|
|
40
|
+
const fontSize = useSelect('Font size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS)
|
|
41
|
+
const openButton = useBoolean('Open button', false)
|
|
42
|
+
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3)
|
|
43
|
+
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2)
|
|
44
|
+
const readOnly = useBoolean('Read only', false)
|
|
44
45
|
const [value, setValue] = useState('')
|
|
45
46
|
|
|
46
47
|
const handleChange = useCallback((value: string) => setValue(value), [])
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
import {useBoolean} from '@sanity/ui-workshop'
|
|
20
20
|
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
|
21
21
|
|
|
22
|
-
import {countriesStore} from '
|
|
22
|
+
import {countriesStore} from './mock/apiStore'
|
|
23
23
|
|
|
24
24
|
export default function Fullscreen() {
|
|
25
|
-
const error = useBoolean('Error', false
|
|
25
|
+
const error = useBoolean('Error', false)
|
|
26
26
|
|
|
27
27
|
const {push: pushToast} = useToast()
|
|
28
28
|
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
@@ -174,60 +174,59 @@ export default function Fullscreen() {
|
|
|
174
174
|
}, [value])
|
|
175
175
|
|
|
176
176
|
return (
|
|
177
|
-
<Card
|
|
177
|
+
<Card display="flex" direction="column" minHeight="full" tone="transparent">
|
|
178
178
|
<PortalProvider element={portalElement}>
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
179
|
+
<Card hidden={open} padding={2}>
|
|
180
|
+
<Flex align="center">
|
|
181
|
+
<Box flex={1} />
|
|
182
|
+
<Button
|
|
183
|
+
aria-label="Open search"
|
|
184
|
+
icon={SearchIcon}
|
|
185
|
+
mode="bleed"
|
|
186
|
+
onClick={handleOpen}
|
|
187
|
+
ref={openSearchButtonElementRef}
|
|
188
|
+
/>
|
|
189
|
+
</Flex>
|
|
190
|
+
</Card>
|
|
191
|
+
<Layer hidden={!open} style={{position: 'sticky', top: 0}}>
|
|
192
|
+
<Card padding={2} shadow={1}>
|
|
193
|
+
<Autocomplete
|
|
194
|
+
filterOption={filterOption}
|
|
195
|
+
fontSize={1}
|
|
196
|
+
icon={SearchIcon}
|
|
197
|
+
id="fullsceen-example"
|
|
198
|
+
listBox={{padding: 2}}
|
|
199
|
+
loading={loading}
|
|
200
|
+
onQueryChange={handleQueryChange}
|
|
201
|
+
onSelect={handleSelect}
|
|
202
|
+
options={options}
|
|
203
|
+
placeholder="Search"
|
|
204
|
+
radius={2}
|
|
205
|
+
ref={inputRef}
|
|
206
|
+
relatedElements={relatedElements}
|
|
207
|
+
renderOption={renderOption}
|
|
208
|
+
renderPopover={renderPopover}
|
|
209
|
+
renderValue={renderValue}
|
|
210
|
+
suffix={
|
|
211
|
+
<Box padding={1}>
|
|
212
|
+
<Button
|
|
213
|
+
aria-label="Close search"
|
|
214
|
+
icon={CloseIcon}
|
|
215
|
+
onClick={handleClose}
|
|
216
|
+
padding={2}
|
|
217
|
+
mode="bleed"
|
|
218
|
+
ref={setCloseSearchButtonElement}
|
|
219
|
+
/>
|
|
220
|
+
</Box>
|
|
221
|
+
}
|
|
222
|
+
value={value}
|
|
223
|
+
/>
|
|
191
224
|
</Card>
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
id="fullsceen-example"
|
|
198
|
-
listBox={{padding: 2}}
|
|
199
|
-
loading={loading}
|
|
200
|
-
onQueryChange={handleQueryChange}
|
|
201
|
-
onSelect={handleSelect}
|
|
202
|
-
options={options}
|
|
203
|
-
placeholder="Search"
|
|
204
|
-
radius={2}
|
|
205
|
-
ref={inputRef}
|
|
206
|
-
relatedElements={relatedElements}
|
|
207
|
-
renderOption={renderOption}
|
|
208
|
-
renderPopover={renderPopover}
|
|
209
|
-
renderValue={renderValue}
|
|
210
|
-
suffix={
|
|
211
|
-
<Box padding={1}>
|
|
212
|
-
<Button
|
|
213
|
-
aria-label="Close search"
|
|
214
|
-
icon={CloseIcon}
|
|
215
|
-
onClick={handleClose}
|
|
216
|
-
padding={2}
|
|
217
|
-
mode="bleed"
|
|
218
|
-
ref={setCloseSearchButtonElement}
|
|
219
|
-
/>
|
|
220
|
-
</Box>
|
|
221
|
-
}
|
|
222
|
-
value={value}
|
|
223
|
-
/>
|
|
224
|
-
</Card>
|
|
225
|
-
</Layer>
|
|
226
|
-
<Card flex={1} hidden={!open} ref={setPortalElement} style={{position: 'relative'}} />
|
|
227
|
-
<Box flex={1} hidden={open} padding={4}>
|
|
228
|
-
<Heading>Welcome to this app</Heading>
|
|
229
|
-
</Box>
|
|
230
|
-
</Flex>
|
|
225
|
+
</Layer>
|
|
226
|
+
<Card flex={1} hidden={!open} position="relative" ref={setPortalElement} />
|
|
227
|
+
<Box flex={1} hidden={open} padding={4}>
|
|
228
|
+
<Heading>Welcome to this app</Heading>
|
|
229
|
+
</Box>
|
|
231
230
|
</PortalProvider>
|
|
232
231
|
</Card>
|
|
233
232
|
)
|
|
@@ -13,8 +13,7 @@ const BREADCRUMBS_MAX_LENGTH_OPTIONS = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export default function Example() {
|
|
16
|
-
const maxLength =
|
|
17
|
-
useSelect('Max. length', BREADCRUMBS_MAX_LENGTH_OPTIONS, 0, 'Props') || undefined
|
|
16
|
+
const maxLength = useSelect('Max. length', BREADCRUMBS_MAX_LENGTH_OPTIONS)
|
|
18
17
|
|
|
19
18
|
return (
|
|
20
19
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -2,8 +2,8 @@ import {Box, Button, Dialog, Text} from '@sanity/ui'
|
|
|
2
2
|
import {useAction, useBoolean} from '@sanity/ui-workshop'
|
|
3
3
|
|
|
4
4
|
export default function AutoFocusStory() {
|
|
5
|
-
const autoFocus = useBoolean('Auto-focus', true
|
|
6
|
-
const open = useBoolean('Open', false
|
|
5
|
+
const autoFocus = useBoolean('Auto-focus', true)
|
|
6
|
+
const open = useBoolean('Open', false)
|
|
7
7
|
const handleClose = useAction('onClose')
|
|
8
8
|
|
|
9
9
|
if (!open) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Dialog, LayerProvider, Stack, Text} from '@sanity/ui'
|
|
2
2
|
import {useAction} from '@sanity/ui-workshop'
|
|
3
3
|
import {useEffect, useRef} from 'react'
|
|
4
4
|
|
|
@@ -19,8 +19,8 @@ export default function OnScrollStory() {
|
|
|
19
19
|
return (
|
|
20
20
|
<LayerProvider>
|
|
21
21
|
<Dialog contentRef={ref} header="On scroll example" id="on-scroll-example">
|
|
22
|
-
<
|
|
23
|
-
<Text muted>
|
|
22
|
+
<Stack gap={4} padding={4} paddingTop={1}>
|
|
23
|
+
<Text muted size={1}>
|
|
24
24
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at nisl at sem tempor
|
|
25
25
|
hendrerit scelerisque ut libero. Maecenas iaculis efficitur lorem, ac faucibus mi
|
|
26
26
|
imperdiet quis. Cras a consectetur erat. Fusce imperdiet, dolor et pellentesque iaculis,
|
|
@@ -32,7 +32,19 @@ export default function OnScrollStory() {
|
|
|
32
32
|
mattis tristique nunc ac lacinia. Vestibulum non pulvinar turpis, posuere consequat
|
|
33
33
|
arcu. Fusce ut urna blandit, finibus nisi a, molestie elit. Nulla sed eleifend mi.
|
|
34
34
|
</Text>
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
<Text muted size={1}>
|
|
37
|
+
Aliquam quis finibus ex. Fusce semper lorem sed orci tempor gravida. Cras dui urna,
|
|
38
|
+
congue quis ipsum in, viverra facilisis libero. Vivamus vehicula libero quam, at posuere
|
|
39
|
+
leo ornare imperdiet. Cras eu neque eu tellus scelerisque iaculis ac id ex. Vestibulum
|
|
40
|
+
quam enim, lacinia ac ultricies at, molestie ut nisi. Vivamus vitae elit vel ante
|
|
41
|
+
feugiat iaculis. Pellentesque vel diam volutpat, luctus magna at, laoreet tellus.
|
|
42
|
+
Aliquam congue id nisi at sollicitudin. In sed nisi libero. Nulla ornare, mauris et
|
|
43
|
+
pulvinar hendrerit, ligula leo auctor enim, vestibulum laoreet metus nisl a nulla. Sed
|
|
44
|
+
et interdum sapien. Mauris lacinia interdum nisi quis ultrices. Etiam lobortis, dui
|
|
45
|
+
semper ornare fringilla, felis lacus feugiat dui, vitae rhoncus tellus tortor ut ipsum.
|
|
46
|
+
</Text>
|
|
47
|
+
</Stack>
|
|
36
48
|
</Dialog>
|
|
37
49
|
</LayerProvider>
|
|
38
50
|
)
|
|
@@ -2,11 +2,11 @@ import {ArrowDownIcon, ArrowUpIcon} from '@sanity/icons'
|
|
|
2
2
|
import {Box, Dialog, LayerProvider, Stack, Text} from '@sanity/ui'
|
|
3
3
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
4
4
|
|
|
5
|
-
import {WORKSHOP_DIALOG_POSITION_OPTIONS} from '
|
|
5
|
+
import {WORKSHOP_DIALOG_POSITION_OPTIONS} from '$workshop'
|
|
6
6
|
|
|
7
7
|
export default function PositionStory() {
|
|
8
|
-
const open = useBoolean('Open', true
|
|
9
|
-
const position = useSelect('Position', WORKSHOP_DIALOG_POSITION_OPTIONS
|
|
8
|
+
const open = useBoolean('Open', true)
|
|
9
|
+
const position = useSelect('Position', WORKSHOP_DIALOG_POSITION_OPTIONS)
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
12
|
<Box padding={4}>
|
|
@@ -2,14 +2,14 @@ import {Box, Button, Dialog, LayerProvider, Stack, Text} from '@sanity/ui'
|
|
|
2
2
|
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
3
|
import {useCallback, useRef, useState} from 'react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {WORKSHOP_CONTAINER_WIDTH_OPTIONS} from '$workshop'
|
|
6
6
|
|
|
7
7
|
export default function PropsStory() {
|
|
8
|
-
const animate = useBoolean('Animate', false
|
|
9
|
-
const header = useText('Header', 'Props example'
|
|
10
|
-
const onClickOutside = useBoolean('Close when click outside', false
|
|
11
|
-
const hideCloseButton = useBoolean('Hide close button', false
|
|
12
|
-
const width = useSelect('Width',
|
|
8
|
+
const animate = useBoolean('Animate', false)
|
|
9
|
+
const header = useText('Header', 'Props example')
|
|
10
|
+
const onClickOutside = useBoolean('Close when click outside', false)
|
|
11
|
+
const hideCloseButton = useBoolean('Hide close button', false)
|
|
12
|
+
const width = useSelect('Width', WORKSHOP_CONTAINER_WIDTH_OPTIONS)
|
|
13
13
|
const [open, setOpen] = useState(false)
|
|
14
14
|
const buttonRef = useRef<HTMLButtonElement | null>(null)
|
|
15
15
|
|
|
@@ -14,11 +14,11 @@ import {
|
|
|
14
14
|
import {useAction, useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
15
|
import {useMemo} from 'react'
|
|
16
16
|
|
|
17
|
-
import {WORKSHOP_CARD_TONE_OPTIONS} from '
|
|
17
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
18
18
|
|
|
19
19
|
export default function MenuButtonStory() {
|
|
20
|
-
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS, 'default'
|
|
21
|
-
const portal = useBoolean('Portal', false
|
|
20
|
+
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS, 'default')
|
|
21
|
+
const portal = useBoolean('Portal', false)
|
|
22
22
|
|
|
23
23
|
const popover: MenuButtonProps['popover'] = useMemo(
|
|
24
24
|
() => ({
|
|
@@ -3,11 +3,11 @@ import {Box, Card, LayerProvider, Menu, MenuItem} from '@sanity/ui'
|
|
|
3
3
|
import {THEME_COLOR_STATE_TONES} from '@sanity/ui/theme'
|
|
4
4
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
5
5
|
|
|
6
|
-
import {WORKSHOP_CARD_TONE_OPTIONS} from '
|
|
6
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
7
7
|
|
|
8
8
|
export default function TonesStory() {
|
|
9
|
-
const disabled = useBoolean('Disabled', false
|
|
10
|
-
const parentTone = useSelect('Parent tone', WORKSHOP_CARD_TONE_OPTIONS, 'default'
|
|
9
|
+
const disabled = useBoolean('Disabled', false)
|
|
10
|
+
const parentTone = useSelect('Parent tone', WORKSHOP_CARD_TONE_OPTIONS, 'default')
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<LayerProvider>
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
} from '@sanity/ui'
|
|
14
14
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
15
|
|
|
16
|
-
import {WORKSHOP_CARD_TONE_OPTIONS} from '
|
|
16
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
17
17
|
|
|
18
18
|
export default function SkeletonDelayStory() {
|
|
19
|
-
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS
|
|
19
|
+
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS)
|
|
20
20
|
const animated = useBoolean('Animated', true)
|
|
21
21
|
|
|
22
22
|
return (
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
} from '@sanity/ui'
|
|
14
14
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
15
|
|
|
16
|
-
import {WORKSHOP_CARD_TONE_OPTIONS} from '
|
|
16
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
17
17
|
|
|
18
18
|
export default function SkeletonStory() {
|
|
19
|
-
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS
|
|
19
|
+
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS)
|
|
20
20
|
const animated = useBoolean('Animated', true)
|
|
21
21
|
|
|
22
22
|
return (
|
|
@@ -5,7 +5,7 @@ import {useState} from 'react'
|
|
|
5
5
|
|
|
6
6
|
export default function ExampleStory() {
|
|
7
7
|
const [tab, setTab] = useState('foo')
|
|
8
|
-
const useLongTitle = useBoolean('Use long title', false
|
|
8
|
+
const useLongTitle = useBoolean('Use long title', false)
|
|
9
9
|
|
|
10
10
|
const longTitle =
|
|
11
11
|
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {Box, Container, Toast} from '@sanity/ui'
|
|
2
2
|
import {useAction, useBoolean, useSelect, useString, useText} from '@sanity/ui-workshop'
|
|
3
3
|
|
|
4
|
-
import {WORKSHOP_TOAST_STATUS_OPTIONS} from '
|
|
4
|
+
import {WORKSHOP_TOAST_STATUS_OPTIONS} from '$workshop'
|
|
5
5
|
|
|
6
6
|
export default function ToastStory() {
|
|
7
|
-
const closable = useBoolean('Closable', false
|
|
8
|
-
const title = useString('Title', 'Toast title'
|
|
9
|
-
const status = useSelect('Status', WORKSHOP_TOAST_STATUS_OPTIONS
|
|
10
|
-
const description = useText('Description'
|
|
7
|
+
const closable = useBoolean('Closable', false)
|
|
8
|
+
const title = useString('Title', 'Toast title')
|
|
9
|
+
const status = useSelect('Status', WORKSHOP_TOAST_STATUS_OPTIONS)
|
|
10
|
+
const description = useText('Description')
|
|
11
11
|
const handleClose = useAction('onClose')
|
|
12
12
|
|
|
13
13
|
return (
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {Avatar, Flex} from '@sanity/ui'
|
|
2
2
|
import {useSelect} from '@sanity/ui-workshop'
|
|
3
3
|
|
|
4
|
-
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '
|
|
4
|
+
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '$workshop'
|
|
5
5
|
|
|
6
6
|
export default function AsButtonStory() {
|
|
7
|
-
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1
|
|
7
|
+
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1)
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
10
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {Avatar, AvatarCounter, AvatarStack, Flex} from '@sanity/ui'
|
|
2
2
|
import {useSelect} from '@sanity/ui-workshop'
|
|
3
3
|
|
|
4
|
-
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '
|
|
4
|
+
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '$workshop'
|
|
5
5
|
|
|
6
6
|
export default function StackStory() {
|
|
7
|
-
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1
|
|
7
|
+
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1)
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
10
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -10,7 +10,7 @@ import {Avatar} from '../avatar'
|
|
|
10
10
|
import {AvatarStack} from '../avatarStack'
|
|
11
11
|
|
|
12
12
|
export default function WithinButtonStory() {
|
|
13
|
-
const disabled = useBoolean('Disabled', false
|
|
13
|
+
const disabled = useBoolean('Disabled', false)
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Container width={1}>
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {useBoolean} from '@sanity/ui-workshop'
|
|
14
14
|
|
|
15
15
|
export default function WithinMenuItemStory() {
|
|
16
|
-
const disabled = useBoolean('Disabled', false
|
|
16
|
+
const disabled = useBoolean('Disabled', false)
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<Container width={1}>
|