@sanity/ui 2.16.22 → 2.16.23

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 (325) hide show
  1. package/dist/_chunks-cjs/_visual-editing.js +115 -1040
  2. package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
  3. package/dist/_chunks-cjs/refractor.js.map +1 -1
  4. package/dist/_chunks-es/_visual-editing.mjs +115 -1040
  5. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  6. package/dist/_chunks-es/refractor.mjs.map +1 -1
  7. package/dist/_visual-editing.d.mts +411 -351
  8. package/dist/_visual-editing.d.ts +411 -351
  9. package/dist/index.d.mts +1107 -930
  10. package/dist/index.d.ts +1107 -930
  11. package/dist/index.js +64 -155
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +64 -155
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/theme.d.mts +769 -681
  16. package/dist/theme.d.ts +769 -681
  17. package/dist/theme.js +47 -0
  18. package/dist/theme.js.map +1 -1
  19. package/dist/theme.mjs +47 -0
  20. package/dist/theme.mjs.map +1 -1
  21. package/exports/_visual-editing.ts +1 -0
  22. package/package.json +49 -162
  23. package/src/core/_compat.ts +30 -0
  24. package/src/core/components/autocomplete/autocomplete.tsx +11 -4
  25. package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
  26. package/src/core/components/breadcrumbs/breadcrumbs.tsx +1 -0
  27. package/src/core/components/dialog/dialog.tsx +3 -0
  28. package/src/core/components/hotkeys/hotkeys.tsx +1 -0
  29. package/src/core/components/menu/menu.test.tsx +6 -4
  30. package/src/core/components/menu/menu.tsx +3 -2
  31. package/src/core/components/menu/menuButton.tsx +8 -0
  32. package/src/core/components/menu/menuGroup.tsx +5 -2
  33. package/src/core/components/menu/menuItem.tsx +4 -0
  34. package/src/core/components/menu/useMenuController.ts +6 -4
  35. package/src/core/components/skeleton/skeleton.tsx +2 -1
  36. package/src/core/components/tab/tab.tsx +1 -0
  37. package/src/core/components/tab/tabList.tsx +1 -0
  38. package/src/core/components/toast/toast.test.tsx +9 -4
  39. package/src/core/components/tree/tree.tsx +1 -0
  40. package/src/core/components/tree/treeGroup.tsx +1 -0
  41. package/src/core/components/tree/treeItem.tsx +2 -2
  42. package/src/core/hooks/useClickOutside.test.tsx +43 -15
  43. package/src/core/hooks/useClickOutside.ts +1 -1
  44. package/src/core/hooks/useClickOutsideEvent.test.tsx +8 -4
  45. package/src/core/hooks/useDelayed.test.ts +7 -6
  46. package/src/core/hooks/useElementRect/useElementRect.ts +1 -0
  47. package/src/core/hooks/useForwardedRef.ts +1 -0
  48. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -1
  49. package/src/core/hooks/usePrefersDark.hydration.test.tsx +7 -5
  50. package/src/core/hooks/usePrefersDark.test.tsx +3 -1
  51. package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +7 -5
  52. package/src/core/hooks/usePrefersReducedMotion.test.tsx +3 -1
  53. package/src/core/lib/createGlobalScopedContext.ts +1 -0
  54. package/src/core/lib/globalScope.ts +1 -0
  55. package/src/core/observers/elementSizeObserver.ts +1 -0
  56. package/src/core/primitives/avatar/avatar.tsx +1 -2
  57. package/src/core/primitives/avatar/avatarStack.tsx +1 -0
  58. package/src/core/primitives/badge/badge.test.tsx +3 -2
  59. package/src/core/primitives/badge/badge.tsx +2 -1
  60. package/src/core/primitives/box/box.tsx +2 -1
  61. package/src/core/primitives/button/button.test.tsx +3 -2
  62. package/src/core/primitives/button/button.tsx +2 -0
  63. package/src/core/primitives/button/styles.ts +1 -0
  64. package/src/core/primitives/card/card.tsx +1 -5
  65. package/src/core/primitives/card/types.ts +1 -0
  66. package/src/core/primitives/code/refractor.tsx +2 -0
  67. package/src/core/primitives/flex/flex.tsx +1 -3
  68. package/src/core/primitives/inline/inline.tsx +1 -0
  69. package/src/core/primitives/popover/popover.tsx +12 -3
  70. package/src/core/primitives/popover/popoverCard.tsx +1 -0
  71. package/src/core/primitives/popover/types.ts +0 -1
  72. package/src/core/primitives/stack/styles.ts +1 -0
  73. package/src/core/primitives/textInput/textInput.tsx +2 -0
  74. package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
  75. package/src/core/primitives/tooltip/tooltip.tsx +5 -0
  76. package/src/core/primitives/tooltip/tooltipCard.tsx +1 -0
  77. package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +2 -0
  78. package/src/core/styles/flex/types.ts +0 -1
  79. package/src/core/styles/font/responsiveFont.ts +0 -3
  80. package/src/core/styles/font/types.ts +1 -3
  81. package/src/core/styles/grid/gridStyle.ts +1 -0
  82. package/src/core/styles/margin/marginStyle.ts +1 -0
  83. package/src/core/styles/margin/marginsStyle.test.ts +2 -1
  84. package/src/core/styles/padding/paddingStyle.test.ts +2 -1
  85. package/src/core/styles/padding/paddingStyle.ts +1 -0
  86. package/src/core/theme/theme.test.tsx +7 -3
  87. package/src/core/theme/useRootTheme.ts +1 -0
  88. package/src/core/theme/useTheme.ts +2 -0
  89. package/src/core/utils/arrow/arrow.tsx +1 -0
  90. package/src/core/utils/boundaryElement/boundaryElement.test.tsx +9 -4
  91. package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +1 -0
  92. package/src/core/utils/getElementRef.ts +5 -0
  93. package/src/core/utils/layer/getLayerContext.test.ts +2 -0
  94. package/src/core/utils/layer/layer.test.tsx +9 -4
  95. package/src/core/utils/layer/layer.tsx +1 -0
  96. package/src/core/utils/layer/useLayer.ts +2 -0
  97. package/src/core/utils/portal/portal.test.tsx +9 -4
  98. package/src/core/utils/portal/portalProvider.tsx +4 -3
  99. package/src/core/utils/virtualList/virtualList.tsx +2 -1
  100. package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +10 -0
  101. package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +4 -0
  102. package/src/theme/build/_deprecated/color/button/createButtonModes.ts +5 -0
  103. package/src/theme/build/_deprecated/color/button/createButtonTones.ts +5 -0
  104. package/src/theme/build/_deprecated/color/card/createCardStates.ts +6 -0
  105. package/src/theme/build/_deprecated/color/color.test.ts +5 -1
  106. package/src/theme/build/_deprecated/color/defaults.ts +1 -0
  107. package/src/theme/build/_deprecated/color/factory.ts +36 -0
  108. package/src/theme/build/_deprecated/color/input/createInputModes.ts +5 -0
  109. package/src/theme/build/_deprecated/color/muted/createMuted.ts +4 -0
  110. package/src/theme/build/_deprecated/color/spot/createSpot.ts +3 -0
  111. package/src/theme/build/buildColorTheme.test.ts +2 -0
  112. package/src/theme/build/buildColorTheme.ts +7 -0
  113. package/src/theme/build/buildTheme.test.ts +2 -0
  114. package/src/theme/build/lib/color-fns/color-fns.test.ts +3 -1
  115. package/src/theme/build/merge.ts +5 -0
  116. package/src/theme/build/mixThemeColor.test.ts +2 -0
  117. package/src/theme/build/renderColorTheme.ts +6 -0
  118. package/src/theme/build/renderColorValue.ts +0 -2
  119. package/src/theme/build/resolveColorTokens.ts +6 -0
  120. package/src/theme/build/theme.test.ts +2 -0
  121. package/src/theme/config/helpers.ts +5 -0
  122. package/src/theme/config/system.ts +2 -0
  123. package/src/theme/config/tokens/color/types.ts +6 -4
  124. package/src/theme/config/tokens/parseTokenKey.test.ts +2 -0
  125. package/src/theme/config/tokens/parseTokenValue.test.ts +2 -0
  126. package/src/theme/config/tokens/parseTokenValue.ts +1 -0
  127. package/src/theme/getScopedTheme.ts +5 -0
  128. package/src/theme/system/color/_helpers.ts +4 -0
  129. package/src/theme/system/theme.ts +4 -0
  130. package/src/theme/system/v0/color/_system.ts +1 -0
  131. package/src/theme/system/v0/color/button.ts +14 -0
  132. package/src/theme/system/v0/color/card.ts +6 -0
  133. package/src/theme/system/v0/color/color.ts +11 -0
  134. package/src/theme/system/v0/color/input.ts +6 -0
  135. package/src/theme/system/v0/color/muted.ts +11 -0
  136. package/src/theme/system/v0/color/selectable.ts +11 -0
  137. package/src/theme/system/v0/color/solid.ts +11 -0
  138. package/src/theme/system/v0/color/spot.ts +1 -0
  139. package/src/theme/versioning/getTheme_v2.ts +15 -0
  140. package/src/theme/versioning/themeColor_v0_v2.ts +7 -0
  141. package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -0
  142. package/src/theme/versioning/v0_v2.ts +13 -1
  143. package/src/theme/versioning/v2_v0.ts +15 -0
  144. package/src/core/__workshop__/constants.ts +0 -293
  145. package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
  146. package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
  147. package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
  148. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
  149. package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
  150. package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
  151. package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
  152. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
  153. package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
  154. package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
  155. package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
  156. package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
  157. package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
  158. package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
  159. package/src/core/components/dialog/__workshop__/index.ts +0 -19
  160. package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
  161. package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
  162. package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
  163. package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
  164. package/src/core/components/dialog/__workshop__/position.tsx +0 -30
  165. package/src/core/components/dialog/__workshop__/props.tsx +0 -75
  166. package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
  167. package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
  168. package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
  169. package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
  170. package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
  171. package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
  172. package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
  173. package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
  174. package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
  175. package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
  176. package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
  177. package/src/core/components/menu/__workshop__/groups.tsx +0 -156
  178. package/src/core/components/menu/__workshop__/index.ts +0 -89
  179. package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
  180. package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -65
  181. package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
  182. package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
  183. package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
  184. package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
  185. package/src/core/components/menu/__workshop__/tones.tsx +0 -25
  186. package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
  187. package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
  188. package/src/core/components/skeleton/__workshop__/index.ts +0 -11
  189. package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
  190. package/src/core/components/tab/__workshop__/example.tsx +0 -79
  191. package/src/core/components/tab/__workshop__/index.ts +0 -14
  192. package/src/core/components/toast/__workshop__/hook.tsx +0 -71
  193. package/src/core/components/toast/__workshop__/index.ts +0 -19
  194. package/src/core/components/toast/__workshop__/toast.tsx +0 -26
  195. package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
  196. package/src/core/components/tree/__workshop__/basic.tsx +0 -105
  197. package/src/core/components/tree/__workshop__/index.ts +0 -21
  198. package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
  199. package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
  200. package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
  201. package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
  202. package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
  203. package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
  204. package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
  205. package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
  206. package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
  207. package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
  208. package/src/core/primitives/badge/__workshop__/index.ts +0 -19
  209. package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
  210. package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
  211. package/src/core/primitives/box/__workshop__/index.ts +0 -19
  212. package/src/core/primitives/box/__workshop__/props.tsx +0 -20
  213. package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
  214. package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
  215. package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
  216. package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
  217. package/src/core/primitives/button/__workshop__/index.ts +0 -59
  218. package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
  219. package/src/core/primitives/button/__workshop__/props.tsx +0 -55
  220. package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +0 -36
  221. package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
  222. package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
  223. package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
  224. package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
  225. package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
  226. package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
  227. package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
  228. package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
  229. package/src/core/primitives/card/__workshop__/index.ts +0 -18
  230. package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
  231. package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
  232. package/src/core/primitives/card/__workshop__/props.tsx +0 -53
  233. package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
  234. package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
  235. package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
  236. package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
  237. package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
  238. package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
  239. package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
  240. package/src/core/primitives/code/__workshop__/index.ts +0 -19
  241. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
  242. package/src/core/primitives/code/__workshop__/props.tsx +0 -21
  243. package/src/core/primitives/container/__workshop__/example.tsx +0 -20
  244. package/src/core/primitives/container/__workshop__/index.ts +0 -8
  245. package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
  246. package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
  247. package/src/core/primitives/flex/__workshop__/index.ts +0 -11
  248. package/src/core/primitives/grid/__workshop__/index.ts +0 -10
  249. package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
  250. package/src/core/primitives/heading/__workshop__/index.ts +0 -19
  251. package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
  252. package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
  253. package/src/core/primitives/inline/__workshop__/index.ts +0 -8
  254. package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
  255. package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
  256. package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
  257. package/src/core/primitives/label/__workshop__/index.ts +0 -19
  258. package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
  259. package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
  260. package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
  261. package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
  262. package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
  263. package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
  264. package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
  265. package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
  266. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
  267. package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
  268. package/src/core/primitives/popover/__workshop__/index.ts +0 -49
  269. package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
  270. package/src/core/primitives/radio/__workshop__/index.ts +0 -11
  271. package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
  272. package/src/core/primitives/select/__workshop__/index.ts +0 -11
  273. package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
  274. package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
  275. package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
  276. package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
  277. package/src/core/primitives/stack/__workshop__/index.ts +0 -14
  278. package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
  279. package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
  280. package/src/core/primitives/switch/__workshop__/index.ts +0 -11
  281. package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
  282. package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
  283. package/src/core/primitives/text/__workshop__/example.tsx +0 -39
  284. package/src/core/primitives/text/__workshop__/index.ts +0 -24
  285. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
  286. package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
  287. package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
  288. package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
  289. package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
  290. package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
  291. package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
  292. package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
  293. package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
  294. package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
  295. package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
  296. package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
  297. package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
  298. package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
  299. package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
  300. package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
  301. package/src/core/theme/__workshop__/build/Root.tsx +0 -367
  302. package/src/core/theme/__workshop__/build/helpers.ts +0 -46
  303. package/src/core/theme/__workshop__/build/story.tsx +0 -465
  304. package/src/core/theme/__workshop__/canvas.tsx +0 -352
  305. package/src/core/theme/__workshop__/color.tsx +0 -62
  306. package/src/core/theme/__workshop__/debug/story.tsx +0 -408
  307. package/src/core/theme/__workshop__/index.ts +0 -39
  308. package/src/core/theme/__workshop__/layer.tsx +0 -78
  309. package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
  310. package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
  311. package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
  312. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
  313. package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
  314. package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
  315. package/src/core/utils/layer/__workshop__/index.ts +0 -24
  316. package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
  317. package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
  318. package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
  319. package/src/core/utils/portal/__workshop__/index.ts +0 -14
  320. package/src/core/utils/portal/__workshop__/named.tsx +0 -63
  321. package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
  322. package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
  323. package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
  324. package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
  325. package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
@@ -1,156 +0,0 @@
1
- import {EarthAmericasIcon, SearchIcon} from '@sanity/icons'
2
- import {
3
- Autocomplete,
4
- BaseAutocompleteOption,
5
- Box,
6
- Card,
7
- Code,
8
- Flex,
9
- LayerProvider,
10
- Stack,
11
- Text,
12
- } from '@sanity/ui'
13
- import {useCallback, useEffect, useRef, useState} from 'react'
14
-
15
- import {countriesStore} from '../__mocks__/apiStore'
16
-
17
- export default function AsyncStory() {
18
- const [options, setOptions] = useState<BaseAutocompleteOption[]>([])
19
- const [loading, setLoading] = useState(false)
20
- const searchRef = useRef<{cancel: () => void} | null>(null)
21
- const fetchRef = useRef<{cancel: () => void} | null>(null)
22
- const [query, setQuery] = useState<string | null>(null)
23
- const [value, setValue] = useState('')
24
- const [optionTitle, setOptionTitle] = useState<string | null>(null)
25
- const [loadingCurrentRef, setLoadingCurrentRef] = useState(false)
26
-
27
- const doSearch = useCallback((query: string | null) => {
28
- if (searchRef.current) searchRef.current.cancel()
29
- searchRef.current = countriesStore.search(query || '', setOptions, setLoading)
30
- }, [])
31
-
32
- const filterOption = useCallback(() => true, [])
33
-
34
- const handleQueryChange = useCallback(
35
- (query: string | null) => {
36
- setQuery(query)
37
-
38
- if (query !== null) {
39
- doSearch(query)
40
- }
41
- },
42
- [doSearch],
43
- )
44
-
45
- const handleOpenButtonClick = useCallback(() => {
46
- if (!value) {
47
- doSearch('')
48
- }
49
- }, [doSearch, value])
50
-
51
- const renderValue = useCallback(() => {
52
- if (loadingCurrentRef) {
53
- return 'Loading…'
54
- }
55
-
56
- return optionTitle || ''
57
- }, [loadingCurrentRef, optionTitle])
58
-
59
- const renderOption = useCallback((option: BaseAutocompleteOption) => {
60
- return <AsyncOption documentId={option.value} />
61
- }, [])
62
-
63
- useEffect(() => {
64
- if (fetchRef.current) fetchRef.current.cancel()
65
-
66
- if (value) {
67
- fetchRef.current = countriesStore.fetchDocument(
68
- value,
69
- (data) => setOptionTitle(data?.title || null),
70
- setLoadingCurrentRef,
71
- )
72
- } else {
73
- setOptionTitle(null)
74
- setLoadingCurrentRef(false)
75
- }
76
- }, [value])
77
-
78
- useEffect(() => {
79
- if (optionTitle) doSearch(optionTitle)
80
- }, [doSearch, optionTitle])
81
-
82
- return (
83
- <Box paddingX={[4, 5, 6]} paddingY={[5, 6, 7]}>
84
- <Stack space={[3, 3, 4]}>
85
- <Text as="label" htmlFor="async" size={[1, 1, 2]} weight="medium">
86
- Country
87
- </Text>
88
- <LayerProvider zOffset={100}>
89
- <Autocomplete
90
- disabled={loadingCurrentRef}
91
- filterOption={filterOption}
92
- icon={value ? EarthAmericasIcon : SearchIcon}
93
- id="async"
94
- loading={loading}
95
- onChange={setValue}
96
- onQueryChange={handleQueryChange}
97
- openButton={{onClick: handleOpenButtonClick}}
98
- options={options}
99
- placeholder="Search"
100
- renderOption={renderOption}
101
- renderValue={renderValue}
102
- value={value}
103
- />
104
- </LayerProvider>
105
-
106
- <Card overflow="auto" padding={3} radius={2} tone="transparent">
107
- <Code language="json" size={1}>
108
- {JSON.stringify({loading, options, query, value}, null, 2)}
109
- </Code>
110
- </Card>
111
- </Stack>
112
- </Box>
113
- )
114
- }
115
-
116
- function AsyncOption(props: {
117
- documentId: string
118
- disabled?: boolean
119
- selected?: boolean
120
- tabIndex?: number
121
- }) {
122
- const {documentId, disabled, selected, tabIndex} = props
123
- const [data, setData] = useState<{title: string} | null>(null)
124
- const [loading, setLoading] = useState(false)
125
- const ref = useRef<{cancel: () => void} | null>(null)
126
-
127
- useEffect(() => {
128
- if (ref.current) ref.current.cancel()
129
- ref.current = countriesStore.fetchDocument(documentId, setData, setLoading)
130
- }, [documentId])
131
-
132
- return (
133
- <Card
134
- data-as="button"
135
- disabled={disabled}
136
- padding={3}
137
- radius={1}
138
- selected={selected}
139
- tabIndex={tabIndex}
140
- >
141
- <Flex gap={3}>
142
- <Text>
143
- <EarthAmericasIcon />
144
- </Text>
145
-
146
- {loading && (
147
- <Text muted>
148
- <>Loading…</>
149
- </Text>
150
- )}
151
-
152
- {!loading && <Text muted={!data}>{data ? data.title : <>Untitled</>}</Text>}
153
- </Flex>
154
- </Card>
155
- )
156
- }
@@ -1,137 +0,0 @@
1
- import {
2
- Autocomplete,
3
- BoundaryElementProvider,
4
- Box,
5
- Card,
6
- Container,
7
- LayerProvider,
8
- Stack,
9
- Text,
10
- } from '@sanity/ui'
11
- import {useCallback, useState} from 'react'
12
-
13
- import {Popover} from '../../../primitives'
14
- import countries from '../__mocks__/countries'
15
- import {AutocompleteProps} from '../autocomplete'
16
- import {ExampleOption} from './types'
17
-
18
- export default function ConstrainedHeightStory() {
19
- const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
20
-
21
- return (
22
- <Card height="fill" tone="transparent">
23
- <Container height="fill" padding={3} sizing="border" width={1}>
24
- <Card
25
- height="fill"
26
- ref={setBoundaryElement}
27
- radius={3}
28
- shadow={3}
29
- style={{position: 'relative'}}
30
- // style={{position: 'absolute', top: 12, right: 12, bottom: 12, left: 12}}
31
- >
32
- <Box height="fill" overflow="auto" padding={[4, 4, 5]} sizing="border">
33
- <Stack space={5}>
34
- <BoundaryElementProvider element={boundaryElement}>
35
- <ConstrainedHeightExampleField id="example-1" label="Example 1" />
36
- <ConstrainedHeightExampleField id="example-2" label="Example 2" />
37
- <ConstrainedHeightExampleField id="example-3" label="Example 3" />
38
- <ConstrainedHeightExampleField id="example-4" label="Example 4" />
39
- <ConstrainedHeightExampleField id="example-5" label="Example 5" />
40
- <ConstrainedHeightExampleField id="example-6" label="Example 6" />
41
- <ConstrainedHeightExampleField id="example-7" label="Example 7" />
42
- <ConstrainedHeightExampleField id="example-8" label="Example 8" />
43
- <ConstrainedHeightExampleField id="example-9" label="Example 9" />
44
- </BoundaryElementProvider>
45
- </Stack>
46
- </Box>
47
- </Card>
48
- </Container>
49
- </Card>
50
- )
51
- }
52
-
53
- function ConstrainedHeightExampleField({id, label}: {id: string; label: string}) {
54
- const [value, setValue] = useState('')
55
-
56
- const renderOption = useCallback((option: ExampleOption) => {
57
- return (
58
- <Card
59
- as="a"
60
- data-qa={`option-${option.value}`}
61
- href="#"
62
- key={option.value}
63
- onClick={(event) => event.preventDefault()}
64
- padding={3}
65
- radius={2}
66
- >
67
- <Text textOverflow="ellipsis">{option.title}</Text>
68
- </Card>
69
- )
70
- }, [])
71
-
72
- const renderValue = useCallback((currentValue: string, option?: ExampleOption) => {
73
- return option ? option.title : currentValue
74
- }, [])
75
-
76
- const filterOption = useCallback((query: string, option: ExampleOption) => {
77
- return option.title.toLowerCase().indexOf(query.toLowerCase()) > -1
78
- }, [])
79
-
80
- const options = countries.map((item) => ({value: item.code, title: item.name}))
81
-
82
- const renderPopover: AutocompleteProps['renderPopover'] = useCallback(
83
- (
84
- popoverProps: {
85
- content: React.JSX.Element | null
86
- hidden: boolean
87
- inputElement: HTMLInputElement | null
88
- onMouseEnter: () => void
89
- onMouseLeave: () => void
90
- },
91
- popoverRef: React.Ref<HTMLDivElement>,
92
- ) => {
93
- const {hidden, inputElement, ...restProps} = popoverProps
94
-
95
- if (hidden) return null
96
-
97
- return (
98
- <Popover
99
- {...restProps}
100
- arrow={false}
101
- constrainSize
102
- matchReferenceWidth
103
- open
104
- overflow="auto"
105
- placement="bottom-start"
106
- radius={1}
107
- ref={popoverRef}
108
- referenceElement={inputElement}
109
- />
110
- )
111
- },
112
- [],
113
- )
114
-
115
- return (
116
- <Stack space={3}>
117
- <Text size={1} weight="medium">
118
- {label}
119
- </Text>
120
- <LayerProvider zOffset={100}>
121
- <Autocomplete
122
- filterOption={filterOption}
123
- id={id}
124
- onChange={setValue}
125
- openButton
126
- options={options}
127
- placeholder="Search"
128
- radius={1}
129
- renderOption={renderOption}
130
- renderPopover={renderPopover}
131
- renderValue={renderValue}
132
- value={value}
133
- />
134
- </LayerProvider>
135
- </Stack>
136
- )
137
- }
@@ -1,89 +0,0 @@
1
- import {Autocomplete, Box, Button, Card, Code, Container, Stack, Text} from '@sanity/ui'
2
- import {useBoolean, useSelect} from '@sanity/ui-workshop'
3
- import {useCallback, useState} from 'react'
4
-
5
- import {
6
- WORKSHOP_RADIUS_OPTIONS,
7
- WORKSHOP_SPACE_OPTIONS,
8
- WORKSHOP_TEXT_SIZE_OPTIONS,
9
- } from '../../../__workshop__/constants'
10
- import countries from '../__mocks__/countries'
11
- import {ExampleOption} from './types'
12
-
13
- export default function CustomStory() {
14
- const data: ExampleOption[] = countries.map((d) => ({value: d.code, title: d.name}))
15
- const border = useBoolean('Border', true, 'Props')
16
- const disabled = useBoolean('Disabled', false, 'Props')
17
- const fontSize = Number(useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props'))
18
- const openButton = useBoolean('Open button', true, 'Props')
19
- const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
20
- const radius = Number(useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props'))
21
- const readOnly = useBoolean('Read only', false, 'Props')
22
- const [value, setValue] = useState('')
23
-
24
- const renderOption = useCallback(
25
- (option: ExampleOption) => (
26
- <Card
27
- as="a"
28
- data-qa={`option-${option.value}`}
29
- href="#"
30
- key={option.value}
31
- onClick={(event) => event.preventDefault()}
32
- padding={padding}
33
- radius={radius - 1}
34
- >
35
- <Text size={fontSize}>{option.title}</Text>
36
- </Card>
37
- ),
38
- [fontSize, padding, radius],
39
- )
40
-
41
- const renderValue = useCallback((currentValue: string, option?: ExampleOption) => {
42
- return option ? option.title : currentValue
43
- }, [])
44
-
45
- const filterOption = useCallback((query: string, option: ExampleOption) => {
46
- return option.title.toLowerCase().indexOf(query.toLowerCase()) > -1
47
- }, [])
48
-
49
- const options = data.map((item) => ({value: item.value, title: item.title}))
50
-
51
- return (
52
- <Box paddingX={[4, 5, 6]} paddingY={[5, 6, 7]}>
53
- <Container width={0}>
54
- <Stack space={5}>
55
- <Stack space={3}>
56
- <Text as="label" htmlFor="custom" id="custom-label" size={1} weight="medium">
57
- Country
58
- </Text>
59
- <Autocomplete
60
- aria-describedby="custom-label"
61
- border={border}
62
- disabled={disabled}
63
- filterOption={filterOption}
64
- fontSize={fontSize}
65
- id="custom"
66
- onChange={setValue}
67
- openButton={openButton}
68
- options={options}
69
- padding={padding}
70
- placeholder="Search"
71
- radius={radius}
72
- readOnly={readOnly}
73
- renderOption={renderOption}
74
- renderValue={renderValue}
75
- value={value}
76
- />
77
- </Stack>
78
-
79
- <Card padding={3} radius={2} tone="transparent">
80
- <Code size={1}>{JSON.stringify(value)}</Code>
81
- </Card>
82
- <Box>
83
- <Button id="set-value-btn" onClick={() => setValue('NO')} text="Set to NO" />
84
- </Box>
85
- </Stack>
86
- </Container>
87
- </Box>
88
- )
89
- }
@@ -1,79 +0,0 @@
1
- import {Autocomplete, Box, Card, Container, Stack, Text} from '@sanity/ui'
2
- import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
3
- import {PerfTestProps, usePerfTest} from '@sanity/ui-workshop/plugin-perf'
4
- import {fireEvent} from '@testing-library/dom'
5
- import {useCallback, useMemo, useState} from 'react'
6
-
7
- import {
8
- WORKSHOP_CARD_TONE_OPTIONS,
9
- WORKSHOP_RADIUS_OPTIONS,
10
- WORKSHOP_SPACE_OPTIONS,
11
- WORKSHOP_TEXT_SIZE_OPTIONS,
12
- } from '../../../__workshop__/constants'
13
- import countries from '../__mocks__/countries'
14
-
15
- const typingPerfTest: PerfTestProps<HTMLInputElement> = {
16
- name: 'typing',
17
- title: 'Typing',
18
- description: 'This test types one character at a time',
19
- run({target}) {
20
- const text = 'Hello, world & Hello, world & Hello, world'
21
- const len = text.length
22
-
23
- for (let i = 0; i < len; i += 1) {
24
- const value = text.slice(0, i + 1)
25
-
26
- fireEvent.change(target, {target: {value}})
27
- }
28
- },
29
- }
30
-
31
- export default function ExampleStory() {
32
- const {ref, Wrapper} = usePerfTest(typingPerfTest)
33
-
34
- const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS, 'default', 'Layout')
35
- const options = useMemo(() => countries.map((country) => ({value: country.code})), [])
36
- const border = useBoolean('Border', true, 'Props')
37
- const customValidity = useText('Custom validity', '', 'Props') || undefined
38
- const disabled = useBoolean('Disabled', false, 'Props')
39
- const fontSize = Number(useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props'))
40
- const openButton = useBoolean('Open button', false, 'Props')
41
- const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
42
- const radius = Number(useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props'))
43
- const readOnly = useBoolean('Read only', false, 'Props')
44
- const [value, setValue] = useState('')
45
-
46
- const handleChange = useCallback((value: string) => setValue(value), [])
47
-
48
- return (
49
- <Card height="fill" tone={layoutTone}>
50
- <Container width={1}>
51
- <Box paddingX={[4, 5, 6]} paddingY={[5, 6, 7]}>
52
- <Stack space={3}>
53
- <Text as="label" htmlFor="default" size={1} weight="medium">
54
- Country code
55
- </Text>
56
- <Wrapper>
57
- <Autocomplete
58
- border={border}
59
- customValidity={customValidity}
60
- disabled={disabled}
61
- fontSize={fontSize}
62
- onChange={handleChange}
63
- id="default"
64
- openButton={openButton}
65
- options={options}
66
- padding={padding}
67
- placeholder="Search"
68
- radius={radius}
69
- readOnly={readOnly}
70
- ref={ref}
71
- value={value}
72
- />
73
- </Wrapper>
74
- </Stack>
75
- </Box>
76
- </Container>
77
- </Card>
78
- )
79
- }
@@ -1,36 +0,0 @@
1
- import {Autocomplete, Box, Button, Card, Code, Stack} from '@sanity/ui'
2
- import {useCallback, useState} from 'react'
3
-
4
- export default function FocusAndBlurStory() {
5
- const [value, setValue] = useState('')
6
- const [log, setLog] = useState<string[]>([])
7
- const handleBlur = useCallback(() => setLog((v) => v.concat(['blur'])), [])
8
- const handleFocus = useCallback(() => setLog((v) => v.concat(['focus'])), [])
9
- const handleClear = useCallback(() => setLog([]), [])
10
-
11
- return (
12
- <Box padding={[4, 5, 6]}>
13
- <Stack space={3}>
14
- <Autocomplete
15
- id="focus-and-blur"
16
- onBlur={handleBlur}
17
- onChange={setValue}
18
- onFocus={handleFocus}
19
- openButton
20
- options={[{value: 'foo'}, {value: 'bar'}]}
21
- placeholder="Search"
22
- value={value}
23
- />
24
- <Stack space={3}>
25
- <Card overflow="auto" padding={3} radius={2} tone="transparent">
26
- <Code id="focus-and-blur-log" language="json" size={1}>
27
- {JSON.stringify(log)}
28
- </Code>
29
- </Card>
30
-
31
- <Button id="focus-and-blur-clear-btn" mode="ghost" onClick={handleClear} text="Clear" />
32
- </Stack>
33
- </Stack>
34
- </Box>
35
- )
36
- }