@sanity/ui 1.0.0-beta.31 → 1.0.0-beta.33

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.
Files changed (71) hide show
  1. package/LICENSE +1 -1
  2. package/dist/{types/src/index.d.ts → index.d.ts} +136 -68
  3. package/dist/{sanity-ui.esm.js → index.esm.js} +699 -1528
  4. package/dist/index.esm.js.map +1 -0
  5. package/dist/{sanity-ui.js → index.js} +698 -1542
  6. package/dist/index.js.map +1 -0
  7. package/package.json +113 -23
  8. package/src/components/autocomplete/__workshop__/example.tsx +1 -1
  9. package/src/components/autocomplete/__workshop__/index.ts +36 -32
  10. package/src/components/autocomplete/autocomplete.tsx +1 -2
  11. package/src/components/autocomplete/constants.ts +3 -8
  12. package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
  13. package/src/components/dialog/__workshop__/index.ts +13 -9
  14. package/src/components/hotkeys/__workshop__/index.ts +11 -3
  15. package/src/components/menu/__workshop__/index.ts +71 -67
  16. package/src/components/menu/menuButton.tsx +16 -14
  17. package/src/components/skeleton/__workshop__/index.ts +8 -4
  18. package/src/components/tab/__workshop__/index.ts +11 -3
  19. package/src/components/toast/__workshop__/index.ts +16 -4
  20. package/src/components/tree/__workshop__/basic.perf.ts +1 -14
  21. package/src/components/tree/__workshop__/basic.tsx +1 -1
  22. package/src/components/tree/__workshop__/index.ts +12 -8
  23. package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
  24. package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
  25. package/src/primitives/avatar/__workshop__/index.ts +16 -12
  26. package/src/primitives/badge/__workshop__/index.ts +16 -12
  27. package/src/primitives/badge/__workshop__/tones.tsx +1 -1
  28. package/src/primitives/box/__workshop__/index.ts +16 -4
  29. package/src/primitives/button/__workshop__/index.ts +51 -47
  30. package/src/primitives/card/__workshop__/index.ts +15 -11
  31. package/src/primitives/checkbox/__workshop__/index.ts +10 -6
  32. package/src/primitives/code/__workshop__/index.ts +16 -12
  33. package/src/primitives/container/__workshop__/index.ts +5 -3
  34. package/src/primitives/flex/__workshop__/index.ts +8 -4
  35. package/src/primitives/grid/__workshop__/index.ts +7 -3
  36. package/src/primitives/heading/__workshop__/index.ts +16 -12
  37. package/src/primitives/inline/__workshop__/index.ts +5 -3
  38. package/src/primitives/kbd/__workshop__/index.ts +5 -3
  39. package/src/primitives/label/__workshop__/index.ts +16 -12
  40. package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
  41. package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
  42. package/src/primitives/popover/__workshop__/index.ts +36 -32
  43. package/src/primitives/popover/constants.ts +0 -3
  44. package/src/primitives/popover/floating-ui/size.ts +40 -25
  45. package/src/primitives/popover/popover.tsx +54 -41
  46. package/src/primitives/popover/popoverCard.tsx +9 -19
  47. package/src/primitives/radio/__workshop__/index.ts +8 -4
  48. package/src/primitives/select/__workshop__/index.ts +8 -4
  49. package/src/primitives/spinner/__workshop__/index.ts +11 -7
  50. package/src/primitives/stack/__workshop__/index.ts +11 -7
  51. package/src/primitives/switch/__workshop__/index.ts +8 -4
  52. package/src/primitives/text/__workshop__/index.ts +21 -17
  53. package/src/primitives/textArea/__workshop__/index.ts +11 -7
  54. package/src/primitives/textInput/__workshop__/index.ts +46 -42
  55. package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
  56. package/src/primitives/tooltip/__workshop__/index.ts +11 -7
  57. package/src/theme/__workshop__/index.ts +26 -22
  58. package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
  59. package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
  60. package/src/utils/elementQuery/__workshop__/index.ts +11 -7
  61. package/src/utils/layer/__workshop__/index.ts +21 -17
  62. package/src/utils/portal/__workshop__/index.ts +11 -7
  63. package/src/utils/virtualList/__workshop__/index.ts +26 -22
  64. package/dist/sanity-ui.esm.js.map +0 -1
  65. package/dist/sanity-ui.js.map +0 -1
  66. package/src/__workshop__/color/overview.tsx +0 -101
  67. package/src/__workshop__/index.ts +0 -10
  68. package/src/icons/__workshop__/.eslintrc +0 -5
  69. package/src/icons/__workshop__/index.tsx +0 -6
  70. package/src/icons/__workshop__/overview.tsx +0 -76
  71. package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
@@ -1,25 +1,32 @@
1
- import {Middleware, detectOverflow} from '@floating-ui/react-dom'
1
+ import {Elements, Middleware, detectOverflow} from '@floating-ui/react-dom'
2
+ import {PopoverMargins} from '../../../types'
2
3
 
3
- export function size(scope: {
4
- boundaryElement: HTMLElement | null
4
+ export interface SizeMiddlewareApplyOptions {
5
+ availableWidth: number
6
+ availableHeight: number
7
+ elements: Elements
8
+ referenceWidth: number
9
+ }
10
+
11
+ export function size(options: {
12
+ apply: (args: SizeMiddlewareApplyOptions) => void
13
+ boundaryElement?: HTMLElement | null
5
14
  constrainSize: boolean
15
+ margins: PopoverMargins
6
16
  matchReferenceWidth?: boolean
7
17
  padding?: number
8
- setAvailableWidth: (v: number) => void
9
- setAvailableHeight: (v: number) => void
10
- setReferenceWidth: (v: number) => void
11
18
  }): Middleware {
12
- const {padding = 0} = scope
19
+ const {apply, margins, padding = 0} = options
13
20
 
14
21
  return {
15
22
  name: '@sanity/ui/size',
16
23
  async fn(args) {
17
- const {placement, rects} = args
24
+ const {elements, placement, platform, rects} = args
18
25
  const {floating, reference} = rects
19
26
 
20
27
  const overflow = await detectOverflow(args, {
21
28
  altBoundary: true,
22
- boundary: scope.boundaryElement || undefined,
29
+ boundary: options.boundaryElement || undefined,
23
30
  elementContext: 'floating',
24
31
  padding,
25
32
  rootBoundary: 'viewport',
@@ -28,36 +35,44 @@ export function size(scope: {
28
35
  let maxWidth = Infinity
29
36
  let maxHeight = Infinity
30
37
 
38
+ const floatingW = floating.width
39
+ const floatingH = floating.height
40
+
31
41
  if (placement.includes('top')) {
32
- maxWidth = floating.width - (overflow.left + overflow.right)
33
- maxHeight = floating.height - overflow.top - padding
42
+ maxWidth = floatingW - (overflow.left + overflow.right)
43
+ maxHeight = floatingH - overflow.top
34
44
  }
35
45
 
36
46
  if (placement.includes('right')) {
37
- maxWidth = floating.width - overflow.right - padding
38
- maxHeight = floating.height - (overflow.top + overflow.bottom)
47
+ maxWidth = floatingW - overflow.right
48
+ maxHeight = floatingH - (overflow.top + overflow.bottom)
39
49
  }
40
50
 
41
51
  if (placement.includes('bottom')) {
42
- maxWidth = floating.width - (overflow.left + overflow.right)
43
- maxHeight = floating.height - overflow.bottom - padding
52
+ maxWidth = floatingW - (overflow.left + overflow.right)
53
+ maxHeight = floatingH - overflow.bottom
44
54
  }
45
55
 
46
56
  if (placement.includes('left')) {
47
- maxWidth = floating.width - overflow.left - padding
48
- maxHeight = floating.height - (overflow.top + overflow.bottom)
57
+ maxWidth = floatingW - overflow.left
58
+ maxHeight = floatingH - (overflow.top + overflow.bottom)
49
59
  }
50
60
 
51
- if (scope.constrainSize) {
52
- scope.setAvailableWidth(maxWidth)
53
- scope.setAvailableHeight(maxHeight)
54
- }
61
+ // IMPORTANT – APPLY ELEMENT STYLES HERE
62
+ // Elements need to be resized BEFORE the `platform.getDimensions` call below
63
+ apply({
64
+ availableWidth: maxWidth - margins[1] - margins[3],
65
+ availableHeight: maxHeight - margins[0] - margins[2],
66
+ elements,
67
+ referenceWidth: reference.width - margins[1] - margins[3],
68
+ })
55
69
 
56
- if (scope.matchReferenceWidth) {
57
- scope.setReferenceWidth(reference.width)
58
- }
70
+ const nextDimensions = await platform.getDimensions(elements.floating)
71
+
72
+ const targetH = nextDimensions.height
73
+ const targetW = nextDimensions.width
59
74
 
60
- if (!floating.width || !floating.height) {
75
+ if (floatingW !== targetW || floatingH !== targetH) {
61
76
  return {reset: {rects: true}}
62
77
  }
63
78
 
@@ -8,23 +8,19 @@ import {
8
8
  offset,
9
9
  shift,
10
10
  useFloating,
11
+ UseFloatingProps,
11
12
  } from '@floating-ui/react-dom'
12
- import {
13
- cloneElement,
14
- forwardRef,
15
- memo,
16
- useCallback,
17
- useEffect,
18
- useMemo,
19
- useRef,
20
- useState,
21
- } from 'react'
13
+ import {cloneElement, forwardRef, memo, useCallback, useEffect, useMemo, useRef} from 'react'
22
14
  import {useForwardedRef, useArrayProp, useElementSize} from '../../hooks'
23
15
  import {ThemeColorSchemeKey, useTheme} from '../../theme'
24
16
  import {BoxOverflow, CardTone, Placement, PopoverMargins} from '../../types'
25
17
  import {LayerProps, LayerProvider, Portal, useBoundaryElement} from '../../utils'
26
18
  import {ResponsiveRadiusProps, ResponsiveShadowProps, ResponsiveWidthProps} from '../types'
27
- import {DEFAULT_POPOVER_DISTANCE, DEFAULT_POPOVER_PADDING} from './constants'
19
+ import {
20
+ DEFAULT_POPOVER_DISTANCE,
21
+ DEFAULT_POPOVER_MARGINS,
22
+ DEFAULT_POPOVER_PADDING,
23
+ } from './constants'
28
24
  import {size} from './floating-ui/size'
29
25
  import {PopoverCard} from './popoverCard'
30
26
 
@@ -70,7 +66,7 @@ export const Popover = memo(
70
66
  const boundaryElementContext = useBoundaryElement()
71
67
 
72
68
  const {
73
- __unstable_margins: margins,
69
+ __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
74
70
  arrow: arrowProp = true,
75
71
  boundaryElement = boundaryElementContext.element,
76
72
  children: childProp,
@@ -80,7 +76,7 @@ export const Popover = memo(
80
76
  fallbackPlacements,
81
77
  matchReferenceWidth: matchReferenceWidthProp,
82
78
  open,
83
- overflow = props.constrainSize ? 'auto' : 'hidden',
79
+ overflow = 'hidden',
84
80
  padding: paddingProp,
85
81
  placement: placementProp = 'bottom',
86
82
  portal,
@@ -100,9 +96,6 @@ export const Popover = memo(
100
96
  const shadow = useArrayProp(shadowProp)
101
97
  const width = useArrayProp(widthProp)
102
98
  const zOffset = useArrayProp(zOffsetProp)
103
- const [availableWidth, setAvailableWidth] = useState<number | undefined>(undefined)
104
- const [availableHeight, setAvailableHeight] = useState<number | undefined>(undefined)
105
- const [referenceWidth, setReferenceWidth] = useState<number | undefined>(undefined)
106
99
  const forwardedRef = useForwardedRef(ref)
107
100
  const arrowRef = useRef<HTMLDivElement | null>(null)
108
101
  const rootBoundary: RootBoundary = 'viewport'
@@ -122,29 +115,37 @@ export const Popover = memo(
122
115
  )
123
116
  }
124
117
 
118
+ // Define distance between reference and floating element
119
+ ret.push(
120
+ offset({
121
+ mainAxis: arrowProp ? DEFAULT_POPOVER_DISTANCE : 0,
122
+ })
123
+ )
124
+
125
125
  // Track sizes
126
126
  if (constrainSize || matchReferenceWidthProp) {
127
127
  ret.push(
128
128
  size({
129
+ apply({availableWidth, availableHeight, elements, referenceWidth}) {
130
+ if (matchReferenceWidthProp) {
131
+ elements.floating.style.width = `${referenceWidth}px`
132
+ }
133
+
134
+ if (constrainSize) {
135
+ elements.floating.style.maxWidth = `${availableWidth}px`
136
+ elements.floating.style.maxHeight = `${availableHeight}px`
137
+ }
138
+ },
129
139
  boundaryElement,
130
140
  constrainSize,
141
+ margins,
131
142
  matchReferenceWidth: matchReferenceWidthProp,
132
143
  padding: DEFAULT_POPOVER_PADDING,
133
- setAvailableHeight,
134
- setAvailableWidth,
135
- setReferenceWidth,
136
144
  })
137
145
  )
138
146
  }
139
147
 
140
- // Define distance between reference and floating element
141
- ret.push(
142
- offset({
143
- mainAxis: arrowProp ? DEFAULT_POPOVER_DISTANCE : 0,
144
- })
145
- )
146
-
147
- // Shift the popover so its sits with the boundary eleement
148
+ // Shift the popover so its sits within the boundary eleement
148
149
  if (preventOverflow) {
149
150
  ret.push(
150
151
  shift({
@@ -179,15 +180,29 @@ export const Popover = memo(
179
180
  boundaryElement,
180
181
  constrainSize,
181
182
  fallbackPlacements,
183
+ margins,
182
184
  matchReferenceWidthProp,
183
185
  preventOverflow,
184
186
  ])
185
187
 
186
- const {x, y, placement, reference, floating, middlewareData, strategy} = useFloating({
187
- middleware,
188
- placement: placementProp,
189
- whileElementsMounted: autoUpdate,
190
- })
188
+ const floatingProps: UseFloatingProps = useMemo(
189
+ () => ({
190
+ middleware,
191
+ placement: placementProp,
192
+ whileElementsMounted: autoUpdate,
193
+ }),
194
+ [middleware, placementProp]
195
+ )
196
+
197
+ const {
198
+ x,
199
+ y,
200
+ placement,
201
+ reference: referenceRef,
202
+ floating: floatingRef,
203
+ middlewareData,
204
+ strategy,
205
+ } = useFloating(floatingProps)
191
206
 
192
207
  const referenceHidden = middlewareData.hide?.referenceHidden
193
208
 
@@ -201,15 +216,16 @@ export const Popover = memo(
201
216
  const setFloating = useCallback(
202
217
  (node: HTMLDivElement | null) => {
203
218
  forwardedRef.current = node
204
- floating(node)
219
+ floatingRef(node)
205
220
  },
206
- [floating, forwardedRef]
221
+ [floatingRef, forwardedRef]
207
222
  )
208
223
 
209
224
  const setReference = useCallback(
210
225
  (node: HTMLElement | null) => {
211
- reference(node)
226
+ referenceRef(node)
212
227
 
228
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
229
  const childRef = (childProp as any)?.ref
214
230
 
215
231
  if (typeof childRef === 'function') {
@@ -218,7 +234,7 @@ export const Popover = memo(
218
234
  childRef.current = node
219
235
  }
220
236
  },
221
- [childProp, reference]
237
+ [childProp, referenceRef]
222
238
  )
223
239
 
224
240
  const child = useMemo(() => {
@@ -228,8 +244,8 @@ export const Popover = memo(
228
244
  }, [childProp, referenceElement, setReference])
229
245
 
230
246
  useEffect(() => {
231
- if (referenceElement) reference(referenceElement)
232
- }, [reference, referenceElement])
247
+ referenceRef(referenceElement || null)
248
+ }, [referenceRef, referenceElement])
233
249
 
234
250
  if (disabled) {
235
251
  return childProp || <></>
@@ -244,8 +260,6 @@ export const Popover = memo(
244
260
  arrowRef={setArrow}
245
261
  arrowX={arrowX}
246
262
  arrowY={arrowY}
247
- availableWidth={constrainSize ? availableWidth : undefined}
248
- availableHeight={constrainSize ? availableHeight : undefined}
249
263
  boundaryWidth={preventOverflow ? boundarySize?.width : undefined}
250
264
  hidden={referenceHidden}
251
265
  overflow={overflow}
@@ -253,7 +267,6 @@ export const Popover = memo(
253
267
  placement={placement}
254
268
  radius={radius}
255
269
  ref={setFloating}
256
- referenceWidth={matchReferenceWidthProp ? referenceWidth : undefined}
257
270
  scheme={scheme}
258
271
  shadow={shadow}
259
272
  strategy={strategy}
@@ -31,14 +31,16 @@ 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
37
  const Root = memo(styled(Card)(popoverCardStyle))
41
38
 
39
+ const PopoverContainer = memo(styled(Container)`
40
+ max-height: inherit;
41
+ max-width: inherit;
42
+ `)
43
+
42
44
  /**
43
45
  * @internal
44
46
  */
@@ -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
- [availableHeight, availableWidth, referenceWidth, strategy, style, x, y, zIndex]
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
- <Container
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
- </Container>
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('primitives/radio', 'Radio', [
5
- {name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))},
6
- {name: 'example', title: 'Example', component: lazy(() => import('./example'))},
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,7 +1,11 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/select', 'Select', [
5
- {name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))},
6
- {name: 'read-only', title: 'Read-only', component: lazy(() => import('./readOnly'))},
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,10 +1,14 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/spinner', 'Spinner', [
5
- {
6
- name: 'props',
7
- title: 'Props',
8
- component: lazy(() => import('./Props')),
9
- },
10
- ])
4
+ export default defineScope({
5
+ name: 'primitives/spinner',
6
+ title: 'Spinner',
7
+ stories: [
8
+ {
9
+ name: 'props',
10
+ title: 'Props',
11
+ component: lazy(() => import('./Props')),
12
+ },
13
+ ],
14
+ })
@@ -1,10 +1,14 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/stack', 'Stack', [
5
- {
6
- name: 'plain',
7
- title: 'Plain',
8
- component: lazy(() => import('./plain')),
9
- },
10
- ])
4
+ export default defineScope({
5
+ name: 'primitives/stack',
6
+ title: 'Stack',
7
+ stories: [
8
+ {
9
+ name: 'plain',
10
+ title: 'Plain',
11
+ component: lazy(() => import('./plain')),
12
+ },
13
+ ],
14
+ })
@@ -1,7 +1,11 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/switch', 'Switch', [
5
- {name: 'props', title: 'Props', component: lazy(() => import('./props'))},
6
- {name: 'example', title: 'Example', component: lazy(() => import('./example'))},
7
- ])
4
+ export default defineScope({
5
+ name: 'primitives/switch',
6
+ title: 'Switch',
7
+ stories: [
8
+ {name: 'props', title: 'Props', component: lazy(() => import('./props'))},
9
+ {name: 'example', title: 'Example', component: lazy(() => import('./example'))},
10
+ ],
11
+ })
@@ -1,20 +1,24 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/text', 'Text', [
5
- {
6
- name: 'default',
7
- title: 'Text',
8
- component: lazy(() => import('./example')),
9
- },
10
- {
11
- name: 'colored',
12
- title: 'Colored text',
13
- component: lazy(() => import('./colored')),
14
- },
15
- {
16
- name: 'optical-alignment',
17
- title: 'Optical alignment',
18
- component: lazy(() => import('./opticalAlignment')),
19
- },
20
- ])
4
+ export default defineScope({
5
+ name: 'primitives/text',
6
+ title: 'Text',
7
+ stories: [
8
+ {
9
+ name: 'default',
10
+ title: 'Text',
11
+ component: lazy(() => import('./example')),
12
+ },
13
+ {
14
+ name: 'colored',
15
+ title: 'Colored text',
16
+ component: lazy(() => import('./colored')),
17
+ },
18
+ {
19
+ name: 'optical-alignment',
20
+ title: 'Optical alignment',
21
+ component: lazy(() => import('./opticalAlignment')),
22
+ },
23
+ ],
24
+ })
@@ -1,10 +1,14 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/text-area', 'TextArea', [
5
- {
6
- name: 'plain',
7
- title: 'Plain',
8
- component: lazy(() => import('./plain')),
9
- },
10
- ])
4
+ export default defineScope({
5
+ name: 'primitives/text-area',
6
+ title: 'TextArea',
7
+ stories: [
8
+ {
9
+ name: 'plain',
10
+ title: 'Plain',
11
+ component: lazy(() => import('./plain')),
12
+ },
13
+ ],
14
+ })
@@ -1,45 +1,49 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/text-input', 'TextInput', [
5
- {
6
- name: 'plain',
7
- title: 'Plain',
8
- component: lazy(() => import('./plain')),
9
- },
10
- {
11
- name: 'custom-validity',
12
- title: 'Custom validity',
13
- component: lazy(() => import('./customValidity')),
14
- },
15
- {
16
- name: 'typed',
17
- title: 'Typed',
18
- component: lazy(() => import('./typed')),
19
- },
20
- {
21
- name: 'tones',
22
- title: 'Tones',
23
- component: lazy(() => import('./tones')),
24
- },
25
- {
26
- name: 'clear-button',
27
- title: 'Clear button',
28
- component: lazy(() => import('./clearButton')),
29
- },
30
- {
31
- name: 'read-only',
32
- title: 'Read only',
33
- component: lazy(() => import('./readOnly')),
34
- },
35
- {
36
- name: 'multiple-tones',
37
- title: 'Multiple tones',
38
- component: lazy(() => import('./multipleTones')),
39
- },
40
- {
41
- name: 'states',
42
- title: 'States',
43
- component: lazy(() => import('./states')),
44
- },
45
- ])
4
+ export default defineScope({
5
+ name: 'primitives/text-input',
6
+ title: 'TextInput',
7
+ stories: [
8
+ {
9
+ name: 'plain',
10
+ title: 'Plain',
11
+ component: lazy(() => import('./plain')),
12
+ },
13
+ {
14
+ name: 'custom-validity',
15
+ title: 'Custom validity',
16
+ component: lazy(() => import('./customValidity')),
17
+ },
18
+ {
19
+ name: 'typed',
20
+ title: 'Typed',
21
+ component: lazy(() => import('./typed')),
22
+ },
23
+ {
24
+ name: 'tones',
25
+ title: 'Tones',
26
+ component: lazy(() => import('./tones')),
27
+ },
28
+ {
29
+ name: 'clear-button',
30
+ title: 'Clear button',
31
+ component: lazy(() => import('./clearButton')),
32
+ },
33
+ {
34
+ name: 'read-only',
35
+ title: 'Read only',
36
+ component: lazy(() => import('./readOnly')),
37
+ },
38
+ {
39
+ name: 'multiple-tones',
40
+ title: 'Multiple tones',
41
+ component: lazy(() => import('./multipleTones')),
42
+ },
43
+ {
44
+ name: 'states',
45
+ title: 'States',
46
+ component: lazy(() => import('./states')),
47
+ },
48
+ ],
49
+ })
@@ -1,6 +1,7 @@
1
1
  import {icons, IconSymbol} from '@sanity/icons'
2
2
  import {Container, Flex, Stack, Text, TextInput} from '@sanity/ui'
3
- import {PerfTestProps, useBoolean, usePerfTest, useSelect, useText} from '@sanity/ui-workshop'
3
+ import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
4
+ import {PerfTestProps, usePerfTest} from '@sanity/ui-workshop/plugin-perf'
4
5
  import {fireEvent} from '@testing-library/dom'
5
6
  import {useCallback, useState} from 'react'
6
7
  import {