sanity-plugin-media 4.3.1 → 4.3.2

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 (145) hide show
  1. package/LICENSE +4 -4
  2. package/README.md +12 -12
  3. package/dist/index.d.mts +263 -195
  4. package/dist/index.d.ts +263 -195
  5. package/dist/index.js +83 -203
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +84 -203
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +41 -63
  10. package/src/__tests__/fixtures/createEpicTestStore.ts +5 -4
  11. package/src/__tests__/fixtures/mockSanityClient.ts +8 -8
  12. package/src/__tests__/fixtures/renderWithProviders.tsx +8 -7
  13. package/src/__tests__/fixtures/rootState.ts +4 -4
  14. package/src/components/AssetGridVirtualized/index.tsx +8 -7
  15. package/src/components/AssetMetadata/index.tsx +6 -5
  16. package/src/components/AssetTableVirtualized/index.tsx +7 -6
  17. package/src/components/AutoTagInputWrapper/index.tsx +9 -4
  18. package/src/components/Browser/Browser.test.tsx +9 -8
  19. package/src/components/Browser/index.tsx +2 -1
  20. package/src/components/Browser/useBrowserInit.ts +9 -9
  21. package/src/components/ButtonAssetCopy/index.tsx +1 -0
  22. package/src/components/ButtonViewGroup/index.tsx +4 -3
  23. package/src/components/CardAsset/CardAsset.test.tsx +53 -52
  24. package/src/components/CardAsset/index.tsx +52 -49
  25. package/src/components/CardUpload/index.tsx +7 -6
  26. package/src/components/Controls/index.tsx +7 -6
  27. package/src/components/DebugControls/index.tsx +5 -4
  28. package/src/components/DialogAssetEdit/Details.tsx +3 -2
  29. package/src/components/DialogAssetEdit/DialogAssetEdit.test.tsx +28 -27
  30. package/src/components/DialogAssetEdit/index.tsx +37 -37
  31. package/src/components/DialogConfirm/index.tsx +2 -1
  32. package/src/components/DialogSearchFacets/index.tsx +3 -2
  33. package/src/components/DialogTagCreate/DialogTagCreate.test.tsx +16 -15
  34. package/src/components/DialogTagCreate/index.tsx +11 -10
  35. package/src/components/DialogTagEdit/DialogTagEdit.test.tsx +28 -27
  36. package/src/components/DialogTagEdit/index.tsx +17 -16
  37. package/src/components/DialogTags/index.tsx +4 -3
  38. package/src/components/Dialogs/index.tsx +2 -3
  39. package/src/components/DocumentList/index.tsx +2 -3
  40. package/src/components/FileAssetPreview/index.tsx +2 -2
  41. package/src/components/FormBuilderTool/FormBuilderTool.test.tsx +12 -11
  42. package/src/components/FormBuilderTool/index.tsx +2 -1
  43. package/src/components/FormFieldInputLabel/index.tsx +1 -2
  44. package/src/components/FormFieldInputTags/index.tsx +4 -3
  45. package/src/components/FormSubmitButton/index.tsx +1 -1
  46. package/src/components/Header/index.tsx +3 -3
  47. package/src/components/Image/index.tsx +10 -4
  48. package/src/components/Items/index.tsx +5 -4
  49. package/src/components/Notifications/index.tsx +3 -2
  50. package/src/components/OrderSelect/index.tsx +4 -3
  51. package/src/components/PickedBar/index.tsx +2 -1
  52. package/src/components/Progress/index.tsx +3 -3
  53. package/src/components/ReduxProvider/index.tsx +15 -12
  54. package/src/components/SearchFacet/index.tsx +3 -2
  55. package/src/components/SearchFacetNumber/index.tsx +8 -8
  56. package/src/components/SearchFacetSelect/index.tsx +7 -8
  57. package/src/components/SearchFacetString/index.tsx +1 -1
  58. package/src/components/SearchFacetTags/index.tsx +13 -12
  59. package/src/components/SearchFacets/index.tsx +2 -3
  60. package/src/components/SearchFacetsControl/index.tsx +13 -12
  61. package/src/components/TableHeader/index.tsx +18 -17
  62. package/src/components/TableHeaderItem/index.tsx +4 -4
  63. package/src/components/TableRowAsset/index.tsx +37 -36
  64. package/src/components/TableRowUpload/index.tsx +7 -6
  65. package/src/components/Tag/index.tsx +8 -7
  66. package/src/components/TagView/index.tsx +2 -2
  67. package/src/components/TagViewHeader/index.tsx +5 -4
  68. package/src/components/TagsPanel/index.tsx +3 -3
  69. package/src/components/TagsVirtualized/index.tsx +25 -24
  70. package/src/components/TextInputSearch/index.tsx +3 -2
  71. package/src/components/UploadDropzone/UploadDropzone.test.tsx +8 -7
  72. package/src/components/UploadDropzone/index.tsx +14 -13
  73. package/src/config/orders.ts +6 -6
  74. package/src/config/searchFacets.ts +56 -55
  75. package/src/constants.ts +15 -14
  76. package/src/contexts/AssetSourceDispatchContext.tsx +1 -1
  77. package/src/contexts/ToolOptionsContext.tsx +6 -5
  78. package/src/formSchema/index.test.ts +6 -5
  79. package/src/formSchema/index.ts +5 -5
  80. package/src/hooks/useBreakpointIndex.ts +6 -6
  81. package/src/hooks/useKeyPress.ts +2 -2
  82. package/src/hooks/usePortalPopoverProps.ts +1 -1
  83. package/src/modules/assets/actions.ts +8 -7
  84. package/src/modules/assets/deleteAndUpdateEpics.test.ts +18 -17
  85. package/src/modules/assets/fetchEpic.test.ts +12 -11
  86. package/src/modules/assets/index.ts +134 -133
  87. package/src/modules/assets/reducer.test.ts +9 -8
  88. package/src/modules/assets/tagsAndListenerEpics.test.ts +36 -35
  89. package/src/modules/debug/index.ts +3 -3
  90. package/src/modules/dialog/actions.ts +2 -2
  91. package/src/modules/dialog/epics.test.ts +29 -28
  92. package/src/modules/dialog/index.ts +36 -35
  93. package/src/modules/dialog/reducer.test.ts +31 -30
  94. package/src/modules/index.ts +9 -9
  95. package/src/modules/notifications/epics.test.ts +71 -70
  96. package/src/modules/notifications/index.ts +50 -49
  97. package/src/modules/notifications/reducer.test.ts +8 -7
  98. package/src/modules/search/index.test.ts +2 -1
  99. package/src/modules/search/index.ts +22 -22
  100. package/src/modules/selected/index.ts +2 -2
  101. package/src/modules/selectors.test.ts +4 -3
  102. package/src/modules/selectors.ts +5 -5
  103. package/src/modules/tags/epics.test.ts +16 -15
  104. package/src/modules/tags/index.test.ts +2 -1
  105. package/src/modules/tags/index.ts +82 -81
  106. package/src/modules/uploads/actions.ts +3 -3
  107. package/src/modules/uploads/epics.test.ts +13 -12
  108. package/src/modules/uploads/index.test.ts +8 -7
  109. package/src/modules/uploads/index.ts +48 -47
  110. package/src/operators/checkTagName.test.ts +7 -6
  111. package/src/operators/checkTagName.ts +6 -5
  112. package/src/operators/debugThrottle.ts +4 -4
  113. package/src/plugin.tsx +18 -18
  114. package/src/schemas/tag.ts +7 -7
  115. package/src/styled/react-select/creatable.tsx +40 -39
  116. package/src/styled/react-select/single.tsx +39 -38
  117. package/src/types/index.ts +4 -3
  118. package/src/utils/applyMediaTags.ts +11 -10
  119. package/src/utils/blocksToText.test.ts +5 -4
  120. package/src/utils/blocksToText.ts +2 -2
  121. package/src/utils/constructFilter.test.ts +15 -14
  122. package/src/utils/constructFilter.ts +7 -7
  123. package/src/utils/generatePreviewBlobUrl.test.ts +6 -5
  124. package/src/utils/generatePreviewBlobUrl.ts +2 -2
  125. package/src/utils/getAssetResolution.test.ts +3 -2
  126. package/src/utils/getDocumentAssetIds.test.ts +7 -6
  127. package/src/utils/getDocumentAssetIds.ts +2 -2
  128. package/src/utils/getSchemeColor.test.ts +1 -0
  129. package/src/utils/getSchemeColor.ts +9 -9
  130. package/src/utils/getTagSelectOptions.test.ts +6 -5
  131. package/src/utils/getTagSelectOptions.ts +1 -1
  132. package/src/utils/getUniqueDocuments.test.ts +4 -3
  133. package/src/utils/getUniqueDocuments.ts +2 -2
  134. package/src/utils/imageDprUrl.test.ts +4 -3
  135. package/src/utils/imageDprUrl.ts +1 -1
  136. package/src/utils/isSupportedAssetType.test.ts +1 -0
  137. package/src/utils/mediaField.ts +4 -3
  138. package/src/utils/sanitizeFormData.test.ts +14 -13
  139. package/src/utils/typeGuards.test.ts +2 -1
  140. package/src/utils/uploadSanityAsset.test.ts +5 -4
  141. package/src/utils/uploadSanityAsset.ts +17 -16
  142. package/src/utils/withMaxConcurrency.test.ts +5 -4
  143. package/src/utils/withMaxConcurrency.ts +4 -4
  144. package/src/utils/zodFormResolver.ts +17 -0
  145. package/v2-incompatible.js +2 -2
@@ -1,14 +1,15 @@
1
- import userEvent from '@testing-library/user-event'
2
1
  import {fireEvent, screen, waitFor} from '@testing-library/react'
3
- import {describe, expect, it, vi} from 'vitest'
2
+ import userEvent from '@testing-library/user-event'
4
3
  import {Subject} from 'rxjs'
5
- import DialogTagEdit from './index'
4
+ import {describe, expect, it, vi} from 'vitest'
5
+
6
6
  import {createMockSanityClient} from '../../__tests__/fixtures/mockSanityClient'
7
7
  import {renderWithProviders} from '../../__tests__/fixtures/renderWithProviders'
8
8
  import {createTestRootState} from '../../__tests__/fixtures/rootState'
9
9
  import {inputByName, withinDialog} from '../../__tests__/fixtures/withinDialog'
10
10
  import {tagsActions} from '../../modules/tags'
11
11
  import type {Tag} from '../../types'
12
+ import DialogTagEdit from './index'
12
13
 
13
14
  const tag: Tag = {
14
15
  _id: 't1',
@@ -16,25 +17,25 @@ const tag: Tag = {
16
17
  _createdAt: '',
17
18
  _updatedAt: '',
18
19
  _rev: 'r1',
19
- name: {_type: 'slug', current: 'alpha'}
20
+ name: {_type: 'slug', current: 'alpha'},
20
21
  }
21
22
 
22
23
  const tagsPreloaded = {
23
24
  allIds: ['t1'],
24
25
  byIds: {
25
- t1: {_type: 'tag' as const, tag, picked: false, updating: false}
26
+ t1: {_type: 'tag' as const, tag, picked: false, updating: false},
26
27
  },
27
28
  creating: false,
28
29
  fetchCount: -1,
29
30
  fetching: false,
30
- panelVisible: true
31
+ panelVisible: true,
31
32
  }
32
33
 
33
34
  vi.mock('../../hooks/useVersionedClient', () => ({
34
35
  default: () =>
35
36
  createMockSanityClient({
36
- listen: vi.fn(() => new Subject())
37
- })
37
+ listen: vi.fn(() => new Subject()),
38
+ }),
38
39
  }))
39
40
 
40
41
  describe('DialogTagEdit', () => {
@@ -46,9 +47,9 @@ describe('DialogTagEdit', () => {
46
47
  </DialogTagEdit>,
47
48
  {
48
49
  preloaded: {
49
- tags: tagsPreloaded
50
- }
51
- }
50
+ tags: tagsPreloaded,
51
+ },
52
+ },
52
53
  )
53
54
 
54
55
  const dlg = withinDialog(/edit tag/i, screen)
@@ -68,9 +69,9 @@ describe('DialogTagEdit', () => {
68
69
  </DialogTagEdit>,
69
70
  {
70
71
  preloaded: {
71
- tags: tagsPreloaded
72
- }
73
- }
72
+ tags: tagsPreloaded,
73
+ },
74
+ },
74
75
  )
75
76
  const dispatchSpy = vi.spyOn(store, 'dispatch')
76
77
  const dlg = withinDialog(/edit tag/i, screen)
@@ -93,9 +94,9 @@ describe('DialogTagEdit', () => {
93
94
  expect(updateAction?.payload).toMatchObject({
94
95
  closeDialogId: 't1',
95
96
  formData: {
96
- name: {_type: 'slug', current: 'gamma'}
97
+ name: {_type: 'slug', current: 'gamma'},
97
98
  },
98
- tag
99
+ tag,
99
100
  })
100
101
  })
101
102
  })
@@ -107,9 +108,9 @@ describe('DialogTagEdit', () => {
107
108
  </DialogTagEdit>,
108
109
  {
109
110
  preloaded: {
110
- tags: tagsPreloaded
111
- }
112
- }
111
+ tags: tagsPreloaded,
112
+ },
113
+ },
113
114
  )
114
115
 
115
116
  const dlg = withinDialog(/edit tag/i, screen)
@@ -122,17 +123,17 @@ describe('DialogTagEdit', () => {
122
123
  dialog: {
123
124
  items: [
124
125
  {id: 'dlg-1', type: 'tagEdit', tagId: 't1'},
125
- {id: 'tags', type: 'tags'}
126
- ]
126
+ {id: 'tags', type: 'tags'},
127
+ ],
127
128
  },
128
- tags: tagsPreloaded
129
+ tags: tagsPreloaded,
129
130
  })
130
131
 
131
132
  const {store} = renderWithProviders(
132
133
  <DialogTagEdit dialog={{id: 'dlg-1', type: 'tagEdit', tagId: 't1'}}>
133
134
  <span />
134
135
  </DialogTagEdit>,
135
- {preloaded: base}
136
+ {preloaded: base},
136
137
  )
137
138
 
138
139
  const dlg = withinDialog(/edit tag/i, screen)
@@ -148,15 +149,15 @@ describe('DialogTagEdit', () => {
148
149
  </DialogTagEdit>,
149
150
  {
150
151
  preloaded: {
151
- tags: tagsPreloaded
152
- }
153
- }
152
+ tags: tagsPreloaded,
153
+ },
154
+ },
154
155
  )
155
156
 
156
157
  const dlg = withinDialog(/edit tag/i, screen)
157
158
  fireEvent.click(dlg.getByRole('button', {name: /^delete$/i}))
158
159
 
159
- const confirm = store.getState().dialog.items.find(d => d.type === 'confirm')
160
+ const confirm = store.getState().dialog.items.find((d) => d.type === 'confirm')
160
161
  expect(confirm).toBeDefined()
161
162
  expect(confirm?.title).toMatch(/permanently delete/i)
162
163
  expect(confirm?.headerTitle).toBe('Confirm deletion')
@@ -1,17 +1,18 @@
1
- import {zodResolver} from '@hookform/resolvers/zod'
2
1
  import type {MutationEvent} from '@sanity/client'
3
2
  import {Box, Button, Card, Flex, Text} from '@sanity/ui'
4
- import type {DialogTagEditProps, Tag, TagFormData} from '../../types'
5
3
  import groq from 'groq'
6
4
  import {type ReactNode, useCallback, useEffect, useState} from 'react'
7
5
  import {type SubmitHandler, useForm} from 'react-hook-form'
8
6
  import {useDispatch} from 'react-redux'
7
+
9
8
  import {tagFormSchema} from '../../formSchema'
10
9
  import useTypedSelector from '../../hooks/useTypedSelector'
11
10
  import useVersionedClient from '../../hooks/useVersionedClient'
12
11
  import {dialogActions} from '../../modules/dialog'
13
12
  import {selectTagById, tagsActions} from '../../modules/tags'
13
+ import type {DialogTagEditProps, Tag, TagFormData} from '../../types'
14
14
  import sanitizeFormData from '../../utils/sanitizeFormData'
15
+ import zodFormResolver from '../../utils/zodFormResolver'
15
16
  import Dialog from '../Dialog'
16
17
  import FormFieldInputText from '../FormFieldInputText'
17
18
  import FormSubmitButton from '../FormSubmitButton'
@@ -24,20 +25,20 @@ type Props = {
24
25
  const DialogTagEdit = (props: Props) => {
25
26
  const {
26
27
  children,
27
- dialog: {id, tagId}
28
+ dialog: {id, tagId},
28
29
  } = props
29
30
 
30
31
  const client = useVersionedClient()
31
32
 
32
33
  const dispatch = useDispatch()
33
- const tagItem = useTypedSelector(state => selectTagById(state, String(tagId))) // TODO: double check string cast
34
+ const tagItem = useTypedSelector((state) => selectTagById(state, String(tagId))) // TODO: double check string cast
34
35
 
35
36
  // - Generate a snapshot of the current tag
36
37
  const [tagSnapshot, setTagSnapshot] = useState(tagItem?.tag)
37
38
 
38
39
  const currentTag = tagItem ? tagItem?.tag : tagSnapshot
39
40
  const generateDefaultValues = (tag?: Tag) => ({
40
- name: tag?.name?.current || ''
41
+ name: tag?.name?.current || '',
41
42
  })
42
43
 
43
44
  const {
@@ -46,11 +47,11 @@ const DialogTagEdit = (props: Props) => {
46
47
  handleSubmit,
47
48
  register,
48
49
  reset,
49
- setError
50
+ setError,
50
51
  } = useForm<TagFormData>({
51
52
  defaultValues: generateDefaultValues(tagItem?.tag),
52
53
  mode: 'onChange',
53
- resolver: zodResolver(tagFormSchema)
54
+ resolver: zodFormResolver<TagFormData>(tagFormSchema),
54
55
  })
55
56
 
56
57
  const formUpdating = !tagItem || tagItem?.updating
@@ -60,7 +61,7 @@ const DialogTagEdit = (props: Props) => {
60
61
  }
61
62
 
62
63
  // Submit react-hook-form
63
- const onSubmit: SubmitHandler<TagFormData> = formData => {
64
+ const onSubmit: SubmitHandler<TagFormData> = (formData) => {
64
65
  if (!tagItem?.tag) {
65
66
  return
66
67
  }
@@ -71,11 +72,11 @@ const DialogTagEdit = (props: Props) => {
71
72
  formData: {
72
73
  name: {
73
74
  _type: 'slug',
74
- current: sanitizedFormData.name
75
- }
75
+ current: sanitizedFormData.name,
76
+ },
76
77
  },
77
- tag: tagItem?.tag
78
- })
78
+ tag: tagItem?.tag,
79
+ }),
79
80
  )
80
81
  }
81
82
 
@@ -87,8 +88,8 @@ const DialogTagEdit = (props: Props) => {
87
88
  dispatch(
88
89
  dialogActions.showConfirmDeleteTag({
89
90
  closeDialogId: tagItem?.tag?._id,
90
- tag: tagItem?.tag
91
- })
91
+ tag: tagItem?.tag,
92
+ }),
92
93
  )
93
94
  }
94
95
 
@@ -102,13 +103,13 @@ const DialogTagEdit = (props: Props) => {
102
103
  reset(generateDefaultValues(result as Tag))
103
104
  }
104
105
  },
105
- [reset]
106
+ [reset],
106
107
  )
107
108
 
108
109
  useEffect(() => {
109
110
  if (tagItem?.error) {
110
111
  setError('name', {
111
- message: tagItem.error?.message
112
+ message: tagItem.error?.message,
112
113
  })
113
114
  }
114
115
  }, [setError, tagItem.error])
@@ -1,8 +1,9 @@
1
1
  import {Box} from '@sanity/ui'
2
- import type {DialogTagsProps} from '../../types'
3
2
  import {type ReactNode, useCallback} from 'react'
4
3
  import {useDispatch} from 'react-redux'
4
+
5
5
  import {dialogActions} from '../../modules/dialog'
6
+ import type {DialogTagsProps} from '../../types'
6
7
  import Dialog from '../Dialog'
7
8
  import TagView from '../TagView'
8
9
 
@@ -14,7 +15,7 @@ type Props = {
14
15
  const DialogTags = (props: Props) => {
15
16
  const {
16
17
  children,
17
- dialog: {id}
18
+ dialog: {id},
18
19
  } = props
19
20
 
20
21
  // Redux
@@ -30,7 +31,7 @@ const DialogTags = (props: Props) => {
30
31
  <Box
31
32
  style={{
32
33
  height: '100%',
33
- minHeight: '420px' // explicit height required as <TagView> is virtualized
34
+ minHeight: '420px', // explicit height required as <TagView> is virtualized
34
35
  }}
35
36
  >
36
37
  <TagView />
@@ -1,6 +1,5 @@
1
- import type {Dialog} from '../../types'
2
-
3
1
  import useTypedSelector from '../../hooks/useTypedSelector'
2
+ import type {Dialog} from '../../types'
4
3
  import DialogAssetEdit from '../DialogAssetEdit'
5
4
  import DialogConfirm from '../DialogConfirm'
6
5
  import DialogSearchFacets from '../DialogSearchFacets'
@@ -10,7 +9,7 @@ import DialogTags from '../DialogTags'
10
9
 
11
10
  const Dialogs = () => {
12
11
  // Redux
13
- const currentDialogs = useTypedSelector(state => state.dialog.items)
12
+ const currentDialogs = useTypedSelector((state) => state.dialog.items)
14
13
 
15
14
  const renderDialogs = (dialogs: Dialog[], index: number) => {
16
15
  if (dialogs.length === 0 || index >= dialogs.length) {
@@ -1,6 +1,5 @@
1
1
  import type {SanityDocument} from '@sanity/client'
2
2
  import {Box, Button, Card, Stack, Text} from '@sanity/ui'
3
-
4
3
  import {Preview, type SchemaType, useSchema} from 'sanity'
5
4
  import {useIntentLink} from 'sanity/router'
6
5
 
@@ -31,7 +30,7 @@ const DocumentList = ({documents, isLoading}: Props) => {
31
30
  return (
32
31
  <Card flex={1} marginBottom={2} padding={2} radius={2} shadow={1}>
33
32
  <Stack space={2}>
34
- {documents?.map(doc => (
33
+ {documents?.map((doc) => (
35
34
  <ReferringDocument doc={doc} key={doc._id} schemaType={schema.get(doc._type)} />
36
35
  ))}
37
36
  </Stack>
@@ -44,7 +43,7 @@ const ReferringDocument = (props: {doc: SanityDocument; schemaType?: SchemaType}
44
43
 
45
44
  const {onClick} = useIntentLink({
46
45
  intent: 'edit',
47
- params: {id: doc._id}
46
+ params: {id: doc._id},
48
47
  })
49
48
 
50
49
  return schemaType ? (
@@ -1,6 +1,6 @@
1
1
  import {Flex} from '@sanity/ui'
2
- import type {Asset} from '../../types'
3
2
 
3
+ import type {Asset} from '../../types'
4
4
  import FileIcon from '../FileIcon'
5
5
 
6
6
  type Props = {
@@ -25,7 +25,7 @@ const FileAssetPreview = (props: Props) => {
25
25
  src={asset.url}
26
26
  style={{
27
27
  height: '100%',
28
- width: '100%'
28
+ width: '100%',
29
29
  }}
30
30
  />
31
31
  )
@@ -1,23 +1,24 @@
1
- import {describe, expect, it, vi, beforeEach} from 'vitest'
2
- import {render, screen, waitFor} from '@testing-library/react'
3
1
  import {LayerProvider, studioTheme, ThemeProvider, ToastProvider} from '@sanity/ui'
4
- import {ColorSchemeProvider} from 'sanity'
2
+ import {render, screen, waitFor} from '@testing-library/react'
5
3
  import {of} from 'rxjs'
6
- import FormBuilderTool from './index'
4
+ import {ColorSchemeProvider} from 'sanity'
5
+ import {describe, expect, it, vi, beforeEach} from 'vitest'
6
+
7
7
  import {createListenMock} from '../../__tests__/fixtures/listenMock'
8
8
  import {createMockSanityClient} from '../../__tests__/fixtures/mockSanityClient'
9
9
  import {ToolOptionsProvider} from '../../contexts/ToolOptionsContext'
10
10
  import useVersionedClient from '../../hooks/useVersionedClient'
11
+ import FormBuilderTool from './index'
11
12
 
12
13
  vi.mock('../../hooks/useVersionedClient', () => ({
13
- default: vi.fn()
14
+ default: vi.fn(),
14
15
  }))
15
16
 
16
- vi.mock('sanity', async importOriginal => {
17
+ vi.mock('sanity', async (importOriginal) => {
17
18
  const mod = await importOriginal<typeof import('sanity')>()
18
19
  return {
19
20
  ...mod,
20
- useFormValue: () => ({_id: 'doc-1', _type: 'article'})
21
+ useFormValue: () => ({_id: 'doc-1', _type: 'article'}),
21
22
  }
22
23
  })
23
24
 
@@ -27,8 +28,8 @@ describe('FormBuilderTool', () => {
27
28
  vi.mocked(useVersionedClient).mockReturnValue(
28
29
  createMockSanityClient({
29
30
  listen: createListenMock(),
30
- observable: {fetch}
31
- })
31
+ observable: {fetch},
32
+ }),
32
33
  )
33
34
  })
34
35
 
@@ -45,14 +46,14 @@ describe('FormBuilderTool', () => {
45
46
  onClose: vi.fn(),
46
47
  onSelect: vi.fn(),
47
48
  schemaType: {},
48
- selectedAssets: undefined
49
+ selectedAssets: undefined,
49
50
  } as any)}
50
51
  />
51
52
  </ToolOptionsProvider>
52
53
  </LayerProvider>
53
54
  </ToastProvider>
54
55
  </ThemeProvider>
55
- </ColorSchemeProvider>
56
+ </ColorSchemeProvider>,
56
57
  )
57
58
 
58
59
  await waitFor(() => {
@@ -1,6 +1,7 @@
1
1
  import {Box, Portal, PortalProvider, useLayer} from '@sanity/ui'
2
2
  import {type SyntheticEvent, useEffect, useState} from 'react'
3
3
  import {type AssetSourceComponentProps, type SanityDocument, useFormValue} from 'sanity'
4
+
4
5
  import useKeyPress from '../../hooks/useKeyPress'
5
6
  import Browser from '../Browser'
6
7
 
@@ -41,7 +42,7 @@ const FormBuilderTool = (props: AssetSourceComponentProps) => {
41
42
  position: 'fixed',
42
43
  top: 0,
43
44
  width: '100%',
44
- zIndex
45
+ zIndex,
45
46
  }}
46
47
  >
47
48
  <Browser document={currentDocument} schemaType={props.schemaType} {...props} />
@@ -1,6 +1,5 @@
1
1
  import {ErrorOutlineIcon} from '@sanity/icons'
2
2
  import {Box, Inline, Text, Tooltip} from '@sanity/ui'
3
-
4
3
  import {styled} from 'styled-components'
5
4
 
6
5
  type Props = {
@@ -12,7 +11,7 @@ type Props = {
12
11
 
13
12
  const StyledErrorOutlineIcon = styled(ErrorOutlineIcon)(({theme}) => {
14
13
  return {
15
- color: theme.sanity.color.spot.red
14
+ color: theme.sanity.color.spot.red,
16
15
  }
17
16
  })
18
17
 
@@ -2,6 +2,7 @@ import {Box} from '@sanity/ui'
2
2
  import {Controller} from 'react-hook-form'
3
3
  import CreatableSelect from 'react-select/creatable'
4
4
  import {useColorSchemeValue} from 'sanity'
5
+
5
6
  import useTypedSelector from '../../hooks/useTypedSelector'
6
7
  import {reactSelectComponents, reactSelectStyles} from '../../styled/react-select/creatable'
7
8
  import type {TagSelectOption} from '../../types'
@@ -34,14 +35,14 @@ const FormFieldInputTags = (props: Props) => {
34
35
  onCreateTag,
35
36
  options,
36
37
  placeholder,
37
- value
38
+ value,
38
39
  } = props
39
40
 
40
41
  const scheme = useColorSchemeValue()
41
42
 
42
43
  // Redux
43
- const creating = useTypedSelector(state => state.tags.creating)
44
- const tagsFetching = useTypedSelector(state => state.tags.fetching)
44
+ const creating = useTypedSelector((state) => state.tags.creating)
45
+ const tagsFetching = useTypedSelector((state) => state.tags.fetching)
45
46
 
46
47
  return (
47
48
  <Box
@@ -1,5 +1,5 @@
1
1
  import {Box, Button, Text, Tooltip} from '@sanity/ui'
2
- import { format } from 'date-fns'
2
+ import {format} from 'date-fns'
3
3
  import {type ReactNode} from 'react'
4
4
 
5
5
  type Props = {
@@ -4,8 +4,8 @@ import pluralize from 'pluralize'
4
4
 
5
5
  import {useAssetSourceActions} from '../../contexts/AssetSourceDispatchContext'
6
6
  import {useDropzoneActions} from '../../contexts/DropzoneDispatchContext'
7
- import useTypedSelector from '../../hooks/useTypedSelector'
8
7
  import {useToolOptions} from '../../contexts/ToolOptionsContext'
8
+ import useTypedSelector from '../../hooks/useTypedSelector'
9
9
 
10
10
  type Props = {
11
11
  onClose?: () => void
@@ -18,8 +18,8 @@ const Header = (props: Props) => {
18
18
  const {onSelect} = useAssetSourceActions()
19
19
 
20
20
  // Redux
21
- const assetTypes = useTypedSelector(state => state.assets.assetTypes)
22
- const selectedDocument = useTypedSelector(state => state.selected.document)
21
+ const assetTypes = useTypedSelector((state) => state.assets.assetTypes)
22
+ const selectedDocument = useTypedSelector((state) => state.selected.document)
23
23
 
24
24
  const {directUploads} = useToolOptions()
25
25
 
@@ -1,6 +1,7 @@
1
1
  import type {ThemeColorSchemeKey} from '@sanity/ui'
2
2
  import type {MouseEvent} from 'react'
3
3
  import {styled, css} from 'styled-components'
4
+
4
5
  import {getSchemeColor} from '../../utils/getSchemeColor'
5
6
 
6
7
  type Props = {
@@ -12,7 +13,7 @@ type Props = {
12
13
  }
13
14
 
14
15
  const Image = styled.img<Props>`
15
- --checkerboard-color: ${props =>
16
+ --checkerboard-color: ${(props) =>
16
17
  props.$scheme ? getSchemeColor(props.$scheme, 'bg2') : 'inherit'};
17
18
 
18
19
  display: block;
@@ -20,15 +21,20 @@ const Image = styled.img<Props>`
20
21
  height: 100%;
21
22
  object-fit: contain;
22
23
 
23
- ${props =>
24
+ ${(props) =>
24
25
  props.$showCheckerboard &&
25
26
  css`
26
- background-image: linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),
27
+ background-image:
28
+ linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),
27
29
  linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),
28
30
  linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),
29
31
  linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);
30
32
  background-size: 20px 20px;
31
- background-position: 0 0, 0 10px, 10px -10px, -10px 0;
33
+ background-position:
34
+ 0 0,
35
+ 0 10px,
36
+ 10px -10px,
37
+ -10px 0;
32
38
  `}
33
39
  `
34
40
 
@@ -1,6 +1,7 @@
1
1
  import {Box, Text} from '@sanity/ui'
2
2
  import {useEffect} from 'react'
3
3
  import {useDispatch} from 'react-redux'
4
+
4
5
  import useBreakpointIndex from '../../hooks/useBreakpointIndex'
5
6
  import useTypedSelector from '../../hooks/useTypedSelector'
6
7
  import {assetsActions} from '../../modules/assets'
@@ -12,10 +13,10 @@ import AssetTableVirtualized from '../AssetTableVirtualized'
12
13
  const Items = () => {
13
14
  // Redux
14
15
  const dispatch = useDispatch()
15
- const fetchCount = useTypedSelector(state => state.assets.fetchCount)
16
- const fetching = useTypedSelector(state => state.assets.fetching)
17
- const tagsPanelVisible = useTypedSelector(state => state.tags.panelVisible)
18
- const view = useTypedSelector(state => state.assets.view)
16
+ const fetchCount = useTypedSelector((state) => state.assets.fetchCount)
17
+ const fetching = useTypedSelector((state) => state.assets.fetching)
18
+ const tagsPanelVisible = useTypedSelector((state) => state.tags.panelVisible)
19
+ const view = useTypedSelector((state) => state.assets.view)
19
20
  const combinedItems = useTypedSelector(selectCombinedItems)
20
21
 
21
22
  const breakpointIndex = useBreakpointIndex()
@@ -1,9 +1,10 @@
1
1
  import {useToast} from '@sanity/ui'
2
2
  import {useEffect} from 'react'
3
+
3
4
  import useTypedSelector from '../../hooks/useTypedSelector'
4
5
 
5
6
  const Notifications = () => {
6
- const items = useTypedSelector(state => state.notifications.items)
7
+ const items = useTypedSelector((state) => state.notifications.items)
7
8
  const toast = useToast()
8
9
 
9
10
  useEffect(() => {
@@ -12,7 +13,7 @@ const Notifications = () => {
12
13
  toast.push({
13
14
  closable: true,
14
15
  status: lastItem.status,
15
- title: lastItem.title
16
+ title: lastItem.title,
16
17
  })
17
18
  }
18
19
  }, [items.length])
@@ -1,6 +1,7 @@
1
1
  import {SortIcon} from '@sanity/icons'
2
2
  import {Button, Menu, MenuButton, MenuDivider, MenuItem} from '@sanity/ui'
3
3
  import {useDispatch} from 'react-redux'
4
+
4
5
  import {getOrderTitle} from '../../config/orders'
5
6
  import {ORDER_OPTIONS} from '../../constants'
6
7
  import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
@@ -10,7 +11,7 @@ import {assetsActions} from '../../modules/assets'
10
11
  const OrderSelect = () => {
11
12
  // Redux
12
13
  const dispatch = useDispatch()
13
- const order = useTypedSelector(state => state.assets.order)
14
+ const order = useTypedSelector((state) => state.assets.order)
14
15
 
15
16
  const popoverProps = usePortalPopoverProps()
16
17
 
@@ -40,8 +41,8 @@ const OrderSelect = () => {
40
41
  onClick={() =>
41
42
  dispatch(
42
43
  assetsActions.orderSet({
43
- order: {direction: item.direction, field: item.field}
44
- })
44
+ order: {direction: item.direction, field: item.field},
45
+ }),
45
46
  )
46
47
  }
47
48
  padding={2}
@@ -2,6 +2,7 @@ import {Box, Button, Flex, Label} from '@sanity/ui'
2
2
  import pluralize from 'pluralize'
3
3
  import {useDispatch} from 'react-redux'
4
4
  import {useColorSchemeValue} from 'sanity'
5
+
5
6
  import {PANEL_HEIGHT} from '../../constants'
6
7
  import useTypedSelector from '../../hooks/useTypedSelector'
7
8
  import {assetsActions, selectAssetsPicked} from '../../modules/assets'
@@ -37,7 +38,7 @@ const PickedBar = () => {
37
38
  borderBottom: '1px solid var(--card-border-color)',
38
39
  height: `${PANEL_HEIGHT}px`,
39
40
  position: 'relative',
40
- width: '100%'
41
+ width: '100%',
41
42
  }}
42
43
  >
43
44
  <Flex align="center" paddingX={3}>
@@ -10,14 +10,14 @@ const Progress = (props: Props) => {
10
10
 
11
11
  const {animationDuration, isFinished, progress} = useNProgress({
12
12
  animationDuration: 300,
13
- isAnimating: loading
13
+ isAnimating: loading,
14
14
  })
15
15
 
16
16
  return (
17
17
  <Box
18
18
  style={{
19
19
  opacity: isFinished ? 0 : 1,
20
- transition: `opacity ${animationDuration}ms linear`
20
+ transition: `opacity ${animationDuration}ms linear`,
21
21
  }}
22
22
  >
23
23
  <Box
@@ -28,7 +28,7 @@ const Progress = (props: Props) => {
28
28
  left: 0,
29
29
  top: 0,
30
30
  transition: `width ${animationDuration}ms linear`,
31
- width: `${progress * 100}%`
31
+ width: `${progress * 100}%`,
32
32
  }}
33
33
  />
34
34
  </Box>