@sanity/ui 2.6.7-canary.0 → 2.6.7

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 (59) hide show
  1. package/dist/index.d.mts +15 -51
  2. package/dist/index.d.ts +15 -51
  3. package/dist/index.esm.js +186 -120
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +186 -119
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +186 -120
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/theme.d.mts +14 -14
  10. package/dist/theme.d.ts +14 -14
  11. package/dist/theme.esm.js.map +1 -1
  12. package/dist/theme.js.map +1 -1
  13. package/dist/theme.mjs.map +1 -1
  14. package/package.json +53 -46
  15. package/src/core/__workshop__/constants.ts +36 -36
  16. package/src/core/components/autocomplete/autocomplete.tsx +1 -1
  17. package/src/core/components/breadcrumbs/breadcrumbs.tsx +6 -15
  18. package/src/core/components/dialog/dialog.tsx +21 -12
  19. package/src/core/components/dialog/styles.ts +8 -8
  20. package/src/core/components/menu/menu.tsx +18 -11
  21. package/src/core/components/menu/menuButton.tsx +11 -11
  22. package/src/core/components/menu/menuContext.ts +1 -1
  23. package/src/core/components/menu/useMenuController.ts +17 -11
  24. package/src/core/components/tab/tab.tsx +8 -8
  25. package/src/core/components/tab/tabPanel.tsx +1 -1
  26. package/src/core/components/toast/styles.ts +1 -2
  27. package/src/core/components/toast/useToast.ts +0 -1
  28. package/src/core/components/tree/tree.tsx +0 -1
  29. package/src/core/components/tree/treeItem.tsx +0 -1
  30. package/src/core/helpers/focus.ts +0 -1
  31. package/src/core/helpers/scroll.ts +0 -1
  32. package/src/core/hooks/_internal/index.ts +1 -0
  33. package/src/core/hooks/_internal/useUnique.ts +34 -0
  34. package/src/core/hooks/index.ts +2 -3
  35. package/src/core/hooks/useClickOutside.ts +72 -38
  36. package/src/core/hooks/useElementSize.ts +0 -1
  37. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +10 -2
  38. package/src/core/hooks/usePrefersDark.ts +55 -10
  39. package/src/core/hooks/usePrefersReducedMotion.ts +56 -10
  40. package/src/core/primitives/avatar/styles.ts +42 -42
  41. package/src/core/primitives/badge/styles.ts +2 -2
  42. package/src/core/primitives/button/styles.ts +4 -4
  43. package/src/core/primitives/inline/styles.ts +2 -2
  44. package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +7 -9
  45. package/src/core/primitives/popover/constants.ts +4 -4
  46. package/src/core/primitives/stack/styles.ts +2 -2
  47. package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +7 -9
  48. package/src/core/primitives/tooltip/constants.ts +4 -4
  49. package/src/core/primitives/tooltip/tooltip.tsx +49 -68
  50. package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +0 -1
  51. package/src/core/styles/font/responsiveFont.ts +8 -8
  52. package/src/core/theme/__workshop__/debug/story.tsx +11 -11
  53. package/src/core/utils/layer/layerProvider.tsx +0 -1
  54. package/src/core/utils/portal/__workshop__/named.tsx +8 -10
  55. package/src/core/utils/portal/portalProvider.tsx +13 -7
  56. package/src/theme/build/buildColorTheme.test.ts +13 -13
  57. package/src/theme/config/tokens/color/types.ts +14 -14
  58. package/src/theme/defaults/colorTokens.ts +36 -36
  59. package/src/core/hooks/useMatchMedia.ts +0 -46
@@ -22,11 +22,11 @@ export const defaultColorTokens: ThemeColorTokens = {
22
22
  icon: ['500', '500'],
23
23
  dot: ['500', '500'],
24
24
  },
25
- 'positive': {
25
+ positive: {
26
26
  bg: ['200 50%', '900'],
27
27
  fg: ['600', '500'],
28
28
  },
29
- 'caution': {
29
+ caution: {
30
30
  bg: ['200 50%', '900'],
31
31
  fg: ['600', '500'],
32
32
  },
@@ -63,26 +63,26 @@ export const defaultColorTokens: ThemeColorTokens = {
63
63
  to: ['100 50%', '900 50%'],
64
64
  },
65
65
  },
66
- 'transparent': {
66
+ transparent: {
67
67
  bg: ['50', 'black'],
68
68
  },
69
- 'default': {
69
+ default: {
70
70
  bg: ['white', '950'],
71
71
  fg: ['800', '200'],
72
72
  muted: {
73
73
  fg: ['600', '400'],
74
74
  },
75
75
  },
76
- 'primary': {_hue: 'blue'},
77
- 'positive': {
76
+ primary: {_hue: 'blue'},
77
+ positive: {
78
78
  _hue: 'green',
79
79
  shadow: {outline: ['500/0.4', '500/0.4']},
80
80
  },
81
- 'caution': {
81
+ caution: {
82
82
  _hue: 'yellow',
83
83
  shadow: {outline: ['600/0.3', '500/0.4']},
84
84
  },
85
- 'critical': {_hue: 'red'},
85
+ critical: {_hue: 'red'},
86
86
  },
87
87
  button: {
88
88
  default: {
@@ -132,17 +132,17 @@ export const defaultColorTokens: ThemeColorTokens = {
132
132
  to: ['900 50%', '100 50%'],
133
133
  },
134
134
  },
135
- 'hovered': {
135
+ hovered: {
136
136
  bg: ['700', '300'],
137
137
  border: ['700/0', '300/0'],
138
138
  },
139
- 'pressed': {
139
+ pressed: {
140
140
  bg: ['700', '300'],
141
141
  },
142
- 'selected': {
142
+ selected: {
143
143
  bg: ['700', '300'],
144
144
  },
145
- 'disabled': {
145
+ disabled: {
146
146
  _hue: 'gray',
147
147
  accent: {
148
148
  fg: ['100 70%', '900 70%'],
@@ -182,7 +182,7 @@ export const defaultColorTokens: ThemeColorTokens = {
182
182
  },
183
183
  },
184
184
  },
185
- 'default': {
185
+ default: {
186
186
  '*': {
187
187
  avatar: {
188
188
  '*': {
@@ -197,13 +197,13 @@ export const defaultColorTokens: ThemeColorTokens = {
197
197
  fg: ['400', '600'],
198
198
  },
199
199
  },
200
- 'hovered': {
200
+ hovered: {
201
201
  bg: ['900', '100'],
202
202
  },
203
- 'pressed': {
203
+ pressed: {
204
204
  bg: ['black', 'white'],
205
205
  },
206
- 'selected': {
206
+ selected: {
207
207
  bg: ['black', 'white'],
208
208
  },
209
209
  },
@@ -255,19 +255,19 @@ export const defaultColorTokens: ThemeColorTokens = {
255
255
  to: ['100 50%', '900 50%'],
256
256
  },
257
257
  },
258
- 'hovered': {
258
+ hovered: {
259
259
  bg: ['100', '900'],
260
260
  fg: ['700', '300'],
261
261
  },
262
- 'pressed': {
262
+ pressed: {
263
263
  bg: ['100', '900'],
264
264
  fg: ['800', '200'],
265
265
  },
266
- 'selected': {
266
+ selected: {
267
267
  bg: ['100', '900'],
268
268
  fg: ['800', '200'],
269
269
  },
270
- 'disabled': {
270
+ disabled: {
271
271
  _hue: 'gray',
272
272
  accent: {
273
273
  fg: ['200', '800'],
@@ -308,12 +308,12 @@ export const defaultColorTokens: ThemeColorTokens = {
308
308
  },
309
309
  },
310
310
  },
311
- 'positive': {
311
+ positive: {
312
312
  '*': {
313
313
  border: ['600 20%', '800'],
314
314
  },
315
315
  },
316
- 'caution': {
316
+ caution: {
317
317
  '*': {
318
318
  border: ['600 20%', '800'],
319
319
  },
@@ -366,21 +366,21 @@ export const defaultColorTokens: ThemeColorTokens = {
366
366
  to: ['100 50%', '900 50%'],
367
367
  },
368
368
  },
369
- 'hovered': {
369
+ hovered: {
370
370
  bg: ['50', '950'],
371
371
  icon: ['700 70%', '400 70%'],
372
372
  },
373
- 'pressed': {
373
+ pressed: {
374
374
  bg: ['100', '900'],
375
375
  fg: ['800', '200'],
376
376
  icon: ['800 70%', '200 70%'],
377
377
  },
378
- 'selected': {
378
+ selected: {
379
379
  bg: ['100', '900'],
380
380
  fg: ['800', '200'],
381
381
  icon: ['800 60%', '200 60%'],
382
382
  },
383
- 'disabled': {
383
+ disabled: {
384
384
  _hue: 'gray',
385
385
  accent: {
386
386
  fg: ['200', '800'],
@@ -434,21 +434,21 @@ export const defaultColorTokens: ThemeColorTokens = {
434
434
  },
435
435
  placeholder: ['400', '600'],
436
436
  },
437
- 'hovered': {
437
+ hovered: {
438
438
  border: ['300', '700'],
439
439
  },
440
- 'readOnly': {
440
+ readOnly: {
441
441
  bg: ['50', '950'],
442
442
  border: ['200', '800'],
443
443
  fg: ['800', '200'],
444
444
  },
445
- 'disabled': {
445
+ disabled: {
446
446
  fg: ['400', '600'],
447
447
  border: ['100', '900'],
448
448
  placeholder: ['200', '800 50%'],
449
449
  },
450
450
  },
451
- 'invalid': {
451
+ invalid: {
452
452
  '*': {
453
453
  _hue: 'red',
454
454
  bg: ['100', '950'],
@@ -502,13 +502,13 @@ export const defaultColorTokens: ThemeColorTokens = {
502
502
  to: ['100 50%', '900 50%'],
503
503
  },
504
504
  },
505
- 'hovered': {
505
+ hovered: {
506
506
  bg: ['50', '950'],
507
507
  },
508
- 'pressed': {
508
+ pressed: {
509
509
  bg: ['100', '900'],
510
510
  },
511
- 'selected': {
511
+ selected: {
512
512
  _blend: ['screen', 'multiply'],
513
513
  accent: {
514
514
  fg: ['purple/300', 'purple/700'],
@@ -553,7 +553,7 @@ export const defaultColorTokens: ThemeColorTokens = {
553
553
  to: ['900 50%', '100 50%'],
554
554
  },
555
555
  },
556
- 'disabled': {
556
+ disabled: {
557
557
  _hue: 'gray',
558
558
  accent: {
559
559
  fg: ['200', '800'],
@@ -595,12 +595,12 @@ export const defaultColorTokens: ThemeColorTokens = {
595
595
  },
596
596
  },
597
597
  },
598
- 'default': {
598
+ default: {
599
599
  selected: {
600
600
  _hue: 'blue',
601
601
  },
602
602
  },
603
- 'critical': {
603
+ critical: {
604
604
  disabled: {
605
605
  bg: ['50 50%', '950 50%'],
606
606
  },
@@ -1,46 +0,0 @@
1
- import {useDebugValue, useMemo, useSyncExternalStore} from 'react'
2
-
3
- /**
4
- * Efficiently subscribes to `window.matchMedia` queries
5
- *
6
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
7
- *
8
- * @public
9
- */
10
- export function useMatchMedia(
11
- mediaQueryString: `(${string})`,
12
- getServerSnapshot?: () => boolean,
13
- ): boolean {
14
- const {subscribe, getSnapshot} = useMemo(() => {
15
- /**
16
- * `subscribe` and `getSnapshot` are only called on the client and both need access to the same `matchMedia` instance
17
- * we don't want to eagerly instantiate it to ensure it's only created when actually used
18
- */
19
- let MEDIA_QUERY_CACHE: MediaQueryList | undefined
20
-
21
- const getMatchMedia = (): MediaQueryList => {
22
- if (!MEDIA_QUERY_CACHE) {
23
- // As this function is only called during `subscribe` and `getSnapshot`, we can assume that the
24
- // the `window` global is available and we're in a browser environment
25
- MEDIA_QUERY_CACHE = window.matchMedia(mediaQueryString)
26
- }
27
-
28
- return MEDIA_QUERY_CACHE
29
- }
30
-
31
- return {
32
- subscribe: (onStoreChange: () => void): (() => void) => {
33
- const matchMedia = getMatchMedia()
34
-
35
- matchMedia.addEventListener('change', onStoreChange)
36
-
37
- return () => matchMedia.removeEventListener('change', onStoreChange)
38
- },
39
- getSnapshot: () => getMatchMedia().matches,
40
- }
41
- }, [mediaQueryString])
42
-
43
- useDebugValue(mediaQueryString)
44
-
45
- return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)
46
- }