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,9 +1,10 @@
1
1
  import {type AnyAction, configureStore, type Store} from '@reduxjs/toolkit'
2
2
  import type {SanityClient} from '@sanity/client'
3
- import type {AssetSourceComponentProps, SanityDocument} from 'sanity'
4
3
  import {Component, type ReactNode} from 'react'
5
4
  import {Provider} from 'react-redux'
6
5
  import {createEpicMiddleware} from 'redux-observable'
6
+ import type {AssetSourceComponentProps, SanityDocument} from 'sanity'
7
+
7
8
  import {rootEpic, rootReducer} from '../../modules'
8
9
  import {initialState as assetsInitialState} from '../../modules/assets'
9
10
  // import {assetsActions} from '../../modules/assets'
@@ -30,12 +31,12 @@ class ReduxProvider extends Component<Props> {
30
31
  // Initialize redux store + middleware
31
32
  const epicMiddleware = createEpicMiddleware<AnyAction, AnyAction, RootReducerState>({
32
33
  dependencies: {
33
- client: props.client // inject sanity client as a dependency to all epics
34
- }
34
+ client: props.client, // inject sanity client as a dependency to all epics
35
+ },
35
36
  })
36
37
  this.store = configureStore({
37
38
  reducer: rootReducer,
38
- middleware: getDefaultMiddleware =>
39
+ middleware: (getDefaultMiddleware) =>
39
40
  getDefaultMiddleware({
40
41
  /*
41
42
  serializableCheck: {
@@ -48,17 +49,19 @@ class ReduxProvider extends Component<Props> {
48
49
  */
49
50
  // TODO: remove once we're no longer storing non-serializable data in the store
50
51
  serializableCheck: false,
51
- thunk: false
52
+ thunk: false,
52
53
  }).prepend(epicMiddleware),
53
54
  devTools: true,
54
55
  preloadedState: {
55
56
  assets: {
56
57
  ...assetsInitialState,
57
- assetTypes: isSupportedAssetType(props?.assetType) ? [props.assetType] : ['file', 'image']
58
+ assetTypes: isSupportedAssetType(props?.assetType)
59
+ ? [props.assetType]
60
+ : ['file', 'image'],
58
61
  },
59
62
  debug: {
60
63
  badConnection: false,
61
- enabled: false
64
+ enabled: false,
62
65
  },
63
66
  dialog: {items: []},
64
67
  notifications: {items: []},
@@ -66,7 +69,7 @@ class ReduxProvider extends Component<Props> {
66
69
  selected: {
67
70
  assets: props.selectedAssets || [],
68
71
  document: props.document,
69
- documentAssetIds: props.document ? getDocumentAssetIds(props.document) : []
72
+ documentAssetIds: props.document ? getDocumentAssetIds(props.document) : [],
70
73
  },
71
74
  tags: {
72
75
  allIds: [],
@@ -74,13 +77,13 @@ class ReduxProvider extends Component<Props> {
74
77
  creating: false,
75
78
  fetchCount: -1,
76
79
  fetching: false,
77
- panelVisible: true
80
+ panelVisible: true,
78
81
  },
79
82
  uploads: {
80
83
  allIds: [],
81
- byIds: {}
82
- }
83
- }
84
+ byIds: {},
85
+ },
86
+ },
84
87
  })
85
88
  epicMiddleware.run(rootEpic)
86
89
  }
@@ -1,11 +1,12 @@
1
1
  import {CloseIcon} from '@sanity/icons'
2
2
  import {Box, Flex, Label, rem, Text, type ThemeColorSchemeKey} from '@sanity/ui'
3
- import type {SearchFacetInputProps, WithId} from '../../types'
4
3
  import {type ReactNode} from 'react'
5
4
  import {useDispatch} from 'react-redux'
6
5
  import {useColorSchemeValue} from 'sanity'
7
6
  import {styled, css} from 'styled-components'
7
+
8
8
  import {searchActions} from '../../modules/search'
9
+ import type {SearchFacetInputProps, WithId} from '../../types'
9
10
  import {getSchemeColor} from '../../utils/getSchemeColor'
10
11
 
11
12
  type Props = {
@@ -40,7 +41,7 @@ const SearchFacet = (props: Props) => {
40
41
  <Label
41
42
  size={0}
42
43
  style={{
43
- whiteSpace: 'nowrap'
44
+ whiteSpace: 'nowrap',
44
45
  }}
45
46
  >
46
47
  {facet.title}
@@ -1,16 +1,16 @@
1
1
  import {SelectIcon} from '@sanity/icons'
2
2
  import {Box, Button, Menu, MenuButton, MenuDivider, MenuItem} from '@sanity/ui'
3
+ import {useDispatch} from 'react-redux'
4
+
5
+ import {operators} from '../../config/searchFacets'
6
+ import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
7
+ import {searchActions} from '../../modules/search'
3
8
  import type {
4
9
  SearchFacetInputNumberModifier,
5
10
  SearchFacetInputNumberProps,
6
11
  SearchFacetOperatorType,
7
- WithId
12
+ WithId,
8
13
  } from '../../types'
9
-
10
- import {useDispatch} from 'react-redux'
11
- import {operators} from '../../config/searchFacets'
12
- import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
13
- import {searchActions} from '../../modules/search'
14
14
  import SearchFacet from '../SearchFacet'
15
15
  import TextInputNumber from '../TextInputNumber'
16
16
 
@@ -26,7 +26,7 @@ const SearchFacetNumber = ({facet}: Props) => {
26
26
 
27
27
  const modifiers = facet?.modifiers
28
28
  const selectedModifier = facet?.modifier
29
- ? modifiers?.find(modifier => modifier.name === facet?.modifier)
29
+ ? modifiers?.find((modifier) => modifier.name === facet?.modifier)
30
30
  : modifiers?.[0]
31
31
 
32
32
  const handleOperatorItemClick = (operatorType: SearchFacetOperatorType) => {
@@ -108,7 +108,7 @@ const SearchFacetNumber = ({facet}: Props) => {
108
108
  id="modifier"
109
109
  menu={
110
110
  <Menu>
111
- {modifiers.map(modifier => {
111
+ {modifiers.map((modifier) => {
112
112
  const selected = modifier.name === facet.modifier
113
113
  return (
114
114
  <MenuItem
@@ -1,18 +1,17 @@
1
1
  import {SelectIcon} from '@sanity/icons'
2
2
  import {Box, Button, Menu, MenuButton, MenuDivider, MenuItem} from '@sanity/ui'
3
+ import {useDispatch} from 'react-redux'
4
+
5
+ import {operators} from '../../config/searchFacets'
6
+ import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
7
+ import {searchActions} from '../../modules/search'
3
8
  import type {
4
9
  SearchFacetInputSelectListItemProps,
5
10
  SearchFacetInputSelectProps,
6
11
  SearchFacetOperatorType,
7
- WithId
12
+ WithId,
8
13
  } from '../../types'
9
-
10
- import {useDispatch} from 'react-redux'
11
-
12
- import {operators} from '../../config/searchFacets'
13
- import {searchActions} from '../../modules/search'
14
14
  import SearchFacet from '../SearchFacet'
15
- import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
16
15
 
17
16
  type Props = {
18
17
  facet: WithId<SearchFacetInputSelectProps>
@@ -26,7 +25,7 @@ const SearchFacetSelect = ({facet}: Props) => {
26
25
 
27
26
  const options = facet?.options
28
27
 
29
- const selectedItem = options?.find(v => v.name === facet?.value)
28
+ const selectedItem = options?.find((v) => v.name === facet?.value)
30
29
 
31
30
  const handleListItemClick = (option: SearchFacetInputSelectListItemProps) => {
32
31
  dispatch(searchActions.facetsUpdate({name: facet.name, value: option.name}))
@@ -1,12 +1,12 @@
1
1
  import {SelectIcon} from '@sanity/icons'
2
2
  import {Box, Button, Menu, MenuButton, MenuDivider, MenuItem, TextInput} from '@sanity/ui'
3
- import type {SearchFacetInputStringProps, SearchFacetOperatorType, WithId} from '../../types'
4
3
  import {type ChangeEvent} from 'react'
5
4
  import {useDispatch} from 'react-redux'
6
5
 
7
6
  import {operators} from '../../config/searchFacets'
8
7
  import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
9
8
  import {searchActions} from '../../modules/search'
9
+ import type {SearchFacetInputStringProps, SearchFacetOperatorType, WithId} from '../../types'
10
10
  import SearchFacet from '../SearchFacet'
11
11
 
12
12
  type Props = {
@@ -1,20 +1,21 @@
1
1
  import {SelectIcon} from '@sanity/icons'
2
2
  import {Box, Button, Menu, MenuButton, MenuDivider, MenuItem} from '@sanity/ui'
3
- import type {
4
- TagSelectOption,
5
- SearchFacetInputSearchableProps,
6
- SearchFacetOperatorType,
7
- WithId
8
- } from '../../types'
9
3
  import {useDispatch} from 'react-redux'
10
4
  import Select from 'react-select'
11
5
  import {useColorSchemeValue} from 'sanity'
6
+
12
7
  import {operators} from '../../config/searchFacets'
13
8
  import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
14
9
  import useTypedSelector from '../../hooks/useTypedSelector'
15
10
  import {searchActions} from '../../modules/search'
16
11
  import {selectTags} from '../../modules/tags'
17
12
  import {reactSelectComponents, reactSelectStyles} from '../../styled/react-select/single'
13
+ import type {
14
+ TagSelectOption,
15
+ SearchFacetInputSearchableProps,
16
+ SearchFacetOperatorType,
17
+ WithId,
18
+ } from '../../types'
18
19
  import getTagSelectOptions from '../../utils/getTagSelectOptions'
19
20
  import SearchFacet from '../SearchFacet'
20
21
 
@@ -27,8 +28,8 @@ const SearchFacetTags = ({facet}: Props) => {
27
28
 
28
29
  // Redux
29
30
  const dispatch = useDispatch()
30
- const tags = useTypedSelector(state => selectTags(state))
31
- const tagsFetching = useTypedSelector(state => state.tags.fetching)
31
+ const tags = useTypedSelector((state) => selectTags(state))
32
+ const tagsFetching = useTypedSelector((state) => state.tags.fetching)
32
33
  const allTagOptions = getTagSelectOptions(tags)
33
34
 
34
35
  const popoverProps = usePortalPopoverProps()
@@ -37,8 +38,8 @@ const SearchFacetTags = ({facet}: Props) => {
37
38
  dispatch(
38
39
  searchActions.facetsUpdateById({
39
40
  id: facet.id,
40
- value: option
41
- })
41
+ value: option,
42
+ }),
42
43
  )
43
44
  }
44
45
 
@@ -46,8 +47,8 @@ const SearchFacetTags = ({facet}: Props) => {
46
47
  dispatch(
47
48
  searchActions.facetsUpdateById({
48
49
  id: facet.id,
49
- operatorType
50
- })
50
+ operatorType,
51
+ }),
51
52
  )
52
53
  }
53
54
 
@@ -1,5 +1,4 @@
1
1
  import {Box, Flex, Inline, rem, type Theme} from '@sanity/ui'
2
-
3
2
  import {styled, css} from 'styled-components'
4
3
 
5
4
  import useTypedSelector from '../../hooks/useTypedSelector'
@@ -24,9 +23,9 @@ const SearchFacets = (props: Props) => {
24
23
  const {layout = 'inline'} = props
25
24
 
26
25
  // Redux
27
- const searchFacets = useTypedSelector(state => state.search.facets)
26
+ const searchFacets = useTypedSelector((state) => state.search.facets)
28
27
 
29
- const Items = searchFacets.map(facet => {
28
+ const Items = searchFacets.map((facet) => {
30
29
  const key = facet.id
31
30
  if (facet.type === 'number') {
32
31
  return <SearchFacetNumber facet={facet} key={key} />
@@ -1,20 +1,20 @@
1
1
  import {AddIcon} from '@sanity/icons'
2
2
  import {Button, Flex, Menu, MenuButton, MenuDivider, MenuGroup, MenuItem} from '@sanity/ui'
3
- import type {SearchFacetDivider, SearchFacetGroup, SearchFacetInputProps} from '../../types'
4
-
5
3
  import {useDispatch} from 'react-redux'
4
+
6
5
  import {FACETS} from '../../constants'
6
+ import {useToolOptions} from '../../contexts/ToolOptionsContext'
7
7
  import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
8
8
  import useTypedSelector from '../../hooks/useTypedSelector'
9
9
  import {searchActions} from '../../modules/search'
10
- import {useToolOptions} from '../../contexts/ToolOptionsContext'
10
+ import type {SearchFacetDivider, SearchFacetGroup, SearchFacetInputProps} from '../../types'
11
11
 
12
12
  const SearchFacetsControl = () => {
13
13
  // Redux
14
14
  const dispatch = useDispatch()
15
- const assetTypes = useTypedSelector(state => state.assets.assetTypes)
16
- const searchFacets = useTypedSelector(state => state.search.facets)
17
- const selectedDocument = useTypedSelector(state => state.selected.document)
15
+ const assetTypes = useTypedSelector((state) => state.assets.assetTypes)
16
+ const searchFacets = useTypedSelector((state) => state.search.facets)
17
+ const selectedDocument = useTypedSelector((state) => state.selected.document)
18
18
 
19
19
  const popoverProps = usePortalPopoverProps()
20
20
 
@@ -24,7 +24,7 @@ const SearchFacetsControl = () => {
24
24
 
25
25
  const filteredFacets = FACETS
26
26
  // Filter facets based on current context, whether it's invoked as a tool, or via selection through via custom asset source.
27
- .filter(facet => {
27
+ .filter((facet) => {
28
28
  // Remove credit line filter if it's not enabled
29
29
  if (!creditLine?.enabled && facet?.type === 'string' && facet?.name === 'creditLine') {
30
30
  return false
@@ -38,8 +38,8 @@ const SearchFacetsControl = () => {
38
38
  return !facet?.selectOnly
39
39
  }
40
40
 
41
- const matchingAssetTypes = facet.assetTypes.filter(assetType =>
42
- assetTypes.includes(assetType)
41
+ const matchingAssetTypes = facet.assetTypes.filter((assetType) =>
42
+ assetTypes.includes(assetType),
43
43
  )
44
44
  return matchingAssetTypes.length > 0
45
45
  })
@@ -61,7 +61,7 @@ const SearchFacetsControl = () => {
61
61
 
62
62
  const renderMenuFacets = (
63
63
  facets: (SearchFacetDivider | SearchFacetGroup | SearchFacetInputProps)[],
64
- level: number = 0
64
+ level: number = 0,
65
65
  ) => {
66
66
  return (
67
67
  <>
@@ -80,7 +80,8 @@ const SearchFacetsControl = () => {
80
80
  }
81
81
 
82
82
  if (facet) {
83
- const disabled = !facet.operatorTypes && !!searchFacets.find(v => v.name === facet.name)
83
+ const disabled =
84
+ !facet.operatorTypes && !!searchFacets.find((v) => v.name === facet.name)
84
85
 
85
86
  return (
86
87
  <MenuItem
@@ -119,7 +120,7 @@ const SearchFacetsControl = () => {
119
120
  menu={<Menu>{renderMenuFacets(filteredFacets)}</Menu>}
120
121
  popover={{
121
122
  ...popoverProps,
122
- placement: 'right-start'
123
+ placement: 'right-start',
123
124
  }}
124
125
  />
125
126
 
@@ -1,35 +1,36 @@
1
1
  import {Checkbox, Flex, Grid, type ThemeColorSchemeKey, useMediaIndex} from '@sanity/ui'
2
2
  import {type MouseEvent} from 'react'
3
3
  import {useDispatch} from 'react-redux'
4
+ import {useColorSchemeValue} from 'sanity'
4
5
  import {styled, css} from 'styled-components'
6
+
5
7
  import {GRID_TEMPLATE_COLUMNS, PANEL_HEIGHT} from '../../constants'
6
8
  import {useAssetSourceActions} from '../../contexts/AssetSourceDispatchContext'
7
9
  import useTypedSelector from '../../hooks/useTypedSelector'
8
10
  import {assetsActions, selectAssetsLength, selectAssetsPickedLength} from '../../modules/assets'
9
- import TableHeaderItem from '../TableHeaderItem'
10
- import {useColorSchemeValue} from 'sanity'
11
11
  import {getSchemeColor} from '../../utils/getSchemeColor'
12
+ import TableHeaderItem from '../TableHeaderItem'
12
13
 
13
14
  // TODO: DRY
14
- const ContextActionContainer = styled<typeof Flex, {$scheme: ThemeColorSchemeKey}>(Flex)(
15
- ({$scheme}) => {
16
- return css`
17
- cursor: pointer;
18
- @media (hover: hover) and (pointer: fine) {
19
- &:hover {
20
- background: ${getSchemeColor($scheme, 'bg')};
21
- }
15
+ const ContextActionContainer = styled<typeof Flex, {$scheme: ThemeColorSchemeKey}>(Flex)(({
16
+ $scheme,
17
+ }) => {
18
+ return css`
19
+ cursor: pointer;
20
+ @media (hover: hover) and (pointer: fine) {
21
+ &:hover {
22
+ background: ${getSchemeColor($scheme, 'bg')};
22
23
  }
23
- `
24
- }
25
- )
24
+ }
25
+ `
26
+ })
26
27
 
27
28
  const TableHeader = () => {
28
29
  const scheme = useColorSchemeValue()
29
30
 
30
31
  // Redux
31
32
  const dispatch = useDispatch()
32
- const fetching = useTypedSelector(state => state.assets.fetching)
33
+ const fetching = useTypedSelector((state) => state.assets.fetching)
33
34
  const itemsLength = useTypedSelector(selectAssetsLength)
34
35
  const numPickedAssets = useTypedSelector(selectAssetsPickedLength)
35
36
 
@@ -67,7 +68,7 @@ const TableHeader = () => {
67
68
  top: 0,
68
69
  visibility: mediaIndex < 3 ? 'hidden' : 'visible',
69
70
  width: '100%',
70
- zIndex: 1 // force stacking context
71
+ zIndex: 1, // force stacking context
71
72
  }}
72
73
  >
73
74
  {onSelect ? (
@@ -80,7 +81,7 @@ const TableHeader = () => {
80
81
  $scheme={scheme}
81
82
  style={{
82
83
  height: '100%',
83
- position: 'relative'
84
+ position: 'relative',
84
85
  }}
85
86
  >
86
87
  <Checkbox
@@ -88,7 +89,7 @@ const TableHeader = () => {
88
89
  readOnly
89
90
  style={{
90
91
  pointerEvents: 'none', // TODO: consider alternative for usability
91
- transform: 'scale(0.8)'
92
+ transform: 'scale(0.8)',
92
93
  }}
93
94
  />
94
95
  </ContextActionContainer>
@@ -1,7 +1,7 @@
1
1
  import {ChevronDownIcon, ChevronUpIcon} from '@sanity/icons'
2
2
  import {Box, Label} from '@sanity/ui'
3
-
4
3
  import {useDispatch} from 'react-redux'
4
+
5
5
  import useTypedSelector from '../../hooks/useTypedSelector'
6
6
  import {assetsActions} from '../../modules/assets'
7
7
 
@@ -15,7 +15,7 @@ const TableHeaderItem = (props: Props) => {
15
15
 
16
16
  // Redux
17
17
  const dispatch = useDispatch()
18
- const order = useTypedSelector(state => state.assets.order)
18
+ const order = useTypedSelector((state) => state.assets.order)
19
19
 
20
20
  const isActive = order.field === field
21
21
 
@@ -40,12 +40,12 @@ const TableHeaderItem = (props: Props) => {
40
40
  style={{
41
41
  cursor: field ? 'pointer' : 'default',
42
42
  display: 'inline',
43
- whiteSpace: 'nowrap'
43
+ whiteSpace: 'nowrap',
44
44
  }}
45
45
  >
46
46
  <span
47
47
  style={{
48
- marginRight: '0.4em'
48
+ marginRight: '0.4em',
49
49
  }}
50
50
  >
51
51
  {title}