sanity-plugin-media 4.3.6 → 5.0.0

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 (162) hide show
  1. package/package.json +6 -15
  2. package/dist/index.cjs +0 -4721
  3. package/dist/index.cjs.map +0 -1
  4. package/dist/index.d.cts +0 -239
  5. package/dist/index.d.cts.map +0 -1
  6. package/sanity.json +0 -8
  7. package/src/__tests__/fixtures/createEpicTestStore.ts +0 -28
  8. package/src/__tests__/fixtures/listenMock.ts +0 -9
  9. package/src/__tests__/fixtures/mockSanityClient.ts +0 -84
  10. package/src/__tests__/fixtures/renderWithProviders.tsx +0 -55
  11. package/src/__tests__/fixtures/rootState.ts +0 -27
  12. package/src/__tests__/fixtures/withinDialog.ts +0 -28
  13. package/src/components/AssetGridVirtualized/index.tsx +0 -94
  14. package/src/components/AssetMetadata/index.tsx +0 -122
  15. package/src/components/AssetTableVirtualized/index.tsx +0 -73
  16. package/src/components/AutoTagInputWrapper/index.tsx +0 -85
  17. package/src/components/Browser/Browser.test.tsx +0 -45
  18. package/src/components/Browser/index.tsx +0 -90
  19. package/src/components/Browser/useBrowserInit.ts +0 -126
  20. package/src/components/ButtonAssetCopy/index.tsx +0 -65
  21. package/src/components/ButtonViewGroup/index.tsx +0 -39
  22. package/src/components/CardAsset/CardAsset.test.tsx +0 -323
  23. package/src/components/CardAsset/index.tsx +0 -290
  24. package/src/components/CardUpload/index.tsx +0 -161
  25. package/src/components/Controls/index.tsx +0 -136
  26. package/src/components/DebugControls/index.tsx +0 -80
  27. package/src/components/Dialog/index.tsx +0 -11
  28. package/src/components/DialogAssetEdit/Details.tsx +0 -181
  29. package/src/components/DialogAssetEdit/DialogAssetEdit.test.tsx +0 -216
  30. package/src/components/DialogAssetEdit/index.tsx +0 -493
  31. package/src/components/DialogConfirm/index.tsx +0 -90
  32. package/src/components/DialogSearchFacets/index.tsx +0 -42
  33. package/src/components/DialogTagCreate/DialogTagCreate.test.tsx +0 -121
  34. package/src/components/DialogTagCreate/index.tsx +0 -111
  35. package/src/components/DialogTagEdit/DialogTagEdit.test.tsx +0 -165
  36. package/src/components/DialogTagEdit/index.tsx +0 -201
  37. package/src/components/DialogTags/index.tsx +0 -45
  38. package/src/components/Dialogs/index.tsx +0 -76
  39. package/src/components/DocumentList/index.tsx +0 -62
  40. package/src/components/FileAssetPreview/index.tsx +0 -37
  41. package/src/components/FileIcon/index.tsx +0 -43
  42. package/src/components/FormBuilderTool/FormBuilderTool.test.tsx +0 -63
  43. package/src/components/FormBuilderTool/index.tsx +0 -69
  44. package/src/components/FormFieldInputLabel/index.tsx +0 -66
  45. package/src/components/FormFieldInputTags/index.tsx +0 -98
  46. package/src/components/FormFieldInputText/index.tsx +0 -41
  47. package/src/components/FormFieldInputTextarea/index.tsx +0 -43
  48. package/src/components/FormSubmitButton/index.tsx +0 -59
  49. package/src/components/Header/index.tsx +0 -80
  50. package/src/components/Image/index.tsx +0 -41
  51. package/src/components/Items/index.tsx +0 -68
  52. package/src/components/Notifications/index.tsx +0 -24
  53. package/src/components/OrderSelect/index.tsx +0 -66
  54. package/src/components/PickedBar/index.tsx +0 -77
  55. package/src/components/Progress/index.tsx +0 -38
  56. package/src/components/ReduxProvider/index.tsx +0 -96
  57. package/src/components/SearchFacet/index.tsx +0 -66
  58. package/src/components/SearchFacetNumber/index.tsx +0 -133
  59. package/src/components/SearchFacetSelect/index.tsx +0 -110
  60. package/src/components/SearchFacetString/index.tsx +0 -88
  61. package/src/components/SearchFacetTags/index.tsx +0 -121
  62. package/src/components/SearchFacets/index.tsx +0 -72
  63. package/src/components/SearchFacetsControl/index.tsx +0 -140
  64. package/src/components/TableHeader/index.tsx +0 -110
  65. package/src/components/TableHeaderItem/index.tsx +0 -61
  66. package/src/components/TableRowAsset/index.tsx +0 -419
  67. package/src/components/TableRowUpload/index.tsx +0 -164
  68. package/src/components/Tag/index.tsx +0 -200
  69. package/src/components/TagIcon/index.tsx +0 -22
  70. package/src/components/TagView/index.tsx +0 -39
  71. package/src/components/TagViewHeader/index.tsx +0 -70
  72. package/src/components/TagsPanel/index.tsx +0 -40
  73. package/src/components/TagsVirtualized/index.tsx +0 -160
  74. package/src/components/TextInputNumber/index.tsx +0 -32
  75. package/src/components/TextInputSearch/index.tsx +0 -60
  76. package/src/components/Tool/index.tsx +0 -13
  77. package/src/components/UploadDropzone/UploadDropzone.test.tsx +0 -40
  78. package/src/components/UploadDropzone/index.tsx +0 -173
  79. package/src/config/orders.ts +0 -28
  80. package/src/config/searchFacets.ts +0 -312
  81. package/src/constants.ts +0 -87
  82. package/src/contexts/AssetSourceDispatchContext.tsx +0 -38
  83. package/src/contexts/DropzoneDispatchContext.tsx +0 -32
  84. package/src/contexts/ToolOptionsContext.tsx +0 -66
  85. package/src/formSchema/index.test.ts +0 -56
  86. package/src/formSchema/index.ts +0 -39
  87. package/src/hooks/useBreakpointIndex.ts +0 -50
  88. package/src/hooks/useKeyPress.ts +0 -39
  89. package/src/hooks/usePortalPopoverProps.ts +0 -13
  90. package/src/hooks/useTypedSelector.ts +0 -7
  91. package/src/hooks/useVersionedClient.ts +0 -6
  92. package/src/index.ts +0 -5
  93. package/src/modules/assets/actions.ts +0 -42
  94. package/src/modules/assets/deleteAndUpdateEpics.test.ts +0 -87
  95. package/src/modules/assets/fetchEpic.test.ts +0 -73
  96. package/src/modules/assets/index.ts +0 -782
  97. package/src/modules/assets/reducer.test.ts +0 -91
  98. package/src/modules/assets/tagsAndListenerEpics.test.ts +0 -206
  99. package/src/modules/debug/index.ts +0 -28
  100. package/src/modules/dialog/actions.ts +0 -10
  101. package/src/modules/dialog/epics.test.ts +0 -168
  102. package/src/modules/dialog/index.ts +0 -238
  103. package/src/modules/dialog/reducer.test.ts +0 -185
  104. package/src/modules/index.ts +0 -117
  105. package/src/modules/notifications/epics.test.ts +0 -374
  106. package/src/modules/notifications/index.ts +0 -199
  107. package/src/modules/notifications/reducer.test.ts +0 -54
  108. package/src/modules/search/index.test.ts +0 -36
  109. package/src/modules/search/index.ts +0 -167
  110. package/src/modules/selected/index.ts +0 -22
  111. package/src/modules/selectors.test.ts +0 -21
  112. package/src/modules/selectors.ts +0 -17
  113. package/src/modules/tags/epics.test.ts +0 -96
  114. package/src/modules/tags/index.test.ts +0 -42
  115. package/src/modules/tags/index.ts +0 -540
  116. package/src/modules/types.ts +0 -3
  117. package/src/modules/uploads/actions.ts +0 -13
  118. package/src/modules/uploads/epics.test.ts +0 -109
  119. package/src/modules/uploads/index.test.ts +0 -59
  120. package/src/modules/uploads/index.ts +0 -272
  121. package/src/operators/checkTagName.test.ts +0 -29
  122. package/src/operators/checkTagName.ts +0 -33
  123. package/src/operators/debugThrottle.ts +0 -25
  124. package/src/plugin.tsx +0 -54
  125. package/src/schemas/tag.ts +0 -28
  126. package/src/styled/GlobalStyles/index.tsx +0 -40
  127. package/src/styled/react-select/creatable.tsx +0 -184
  128. package/src/styled/react-select/single.tsx +0 -184
  129. package/src/types/index.ts +0 -346
  130. package/src/types/sanity-ui.d.ts +0 -5
  131. package/src/utils/applyMediaTags.ts +0 -87
  132. package/src/utils/blocksToText.test.ts +0 -43
  133. package/src/utils/blocksToText.ts +0 -27
  134. package/src/utils/constructFilter.test.ts +0 -120
  135. package/src/utils/constructFilter.ts +0 -98
  136. package/src/utils/generatePreviewBlobUrl.test.ts +0 -68
  137. package/src/utils/generatePreviewBlobUrl.ts +0 -53
  138. package/src/utils/getAssetResolution.test.ts +0 -13
  139. package/src/utils/getAssetResolution.ts +0 -7
  140. package/src/utils/getDocumentAssetIds.test.ts +0 -50
  141. package/src/utils/getDocumentAssetIds.ts +0 -35
  142. package/src/utils/getSchemeColor.test.ts +0 -12
  143. package/src/utils/getSchemeColor.ts +0 -43
  144. package/src/utils/getTagSelectOptions.test.ts +0 -44
  145. package/src/utils/getTagSelectOptions.ts +0 -16
  146. package/src/utils/getUniqueDocuments.test.ts +0 -26
  147. package/src/utils/getUniqueDocuments.ts +0 -15
  148. package/src/utils/imageDprUrl.test.ts +0 -46
  149. package/src/utils/imageDprUrl.ts +0 -27
  150. package/src/utils/isSupportedAssetType.test.ts +0 -16
  151. package/src/utils/isSupportedAssetType.ts +0 -15
  152. package/src/utils/mediaField.ts +0 -73
  153. package/src/utils/sanitizeFormData.test.ts +0 -59
  154. package/src/utils/sanitizeFormData.ts +0 -26
  155. package/src/utils/typeGuards.test.ts +0 -18
  156. package/src/utils/typeGuards.ts +0 -9
  157. package/src/utils/uploadSanityAsset.test.ts +0 -29
  158. package/src/utils/uploadSanityAsset.ts +0 -97
  159. package/src/utils/withMaxConcurrency.test.ts +0 -43
  160. package/src/utils/withMaxConcurrency.ts +0 -55
  161. package/src/utils/zodFormResolver.ts +0 -17
  162. package/v2-incompatible.js +0 -11
@@ -1,98 +0,0 @@
1
- import {Box} from '@sanity/ui'
2
- import {Controller} from 'react-hook-form'
3
- import CreatableSelect from 'react-select/creatable'
4
- import {useColorSchemeValue} from 'sanity'
5
-
6
- import useTypedSelector from '../../hooks/useTypedSelector'
7
- import {reactSelectComponents, reactSelectStyles} from '../../styled/react-select/creatable'
8
- import type {TagSelectOption} from '../../types'
9
- import FormFieldInputLabel from '../FormFieldInputLabel'
10
-
11
- type Props = {
12
- control: any
13
- description?: string
14
- disabled?: boolean
15
- error?: string
16
- label: string
17
- name: string
18
- onCreateTag: (tagName: string) => void
19
- options: {
20
- label: string
21
- value: string
22
- }[]
23
- placeholder?: string
24
- value?: TagSelectOption[] | null
25
- }
26
-
27
- const FormFieldInputTags = (props: Props) => {
28
- const {
29
- control,
30
- description,
31
- disabled,
32
- error,
33
- label,
34
- name,
35
- onCreateTag,
36
- options,
37
- placeholder,
38
- value,
39
- } = props
40
-
41
- const scheme = useColorSchemeValue()
42
-
43
- // Redux
44
- const creating = useTypedSelector((state) => state.tags.creating)
45
- const tagsFetching = useTypedSelector((state) => state.tags.fetching)
46
-
47
- return (
48
- <Box
49
- // HACK: force stacking context to ensure react-select dropdown sits above other fields
50
- style={{zIndex: 2}}
51
- >
52
- {/* Label */}
53
- <FormFieldInputLabel description={description} error={error} label={label} name={name} />
54
-
55
- {/* Select */}
56
- <Controller
57
- control={control}
58
- defaultValue={value}
59
- name={name}
60
- render={({field}) => {
61
- const {onBlur, onChange, value: controllerValue} = field
62
- // TODO: investigate overriding `onChange` and updating form state manually.
63
- // `opt.media.tags` is initialised with `null` as a defaultValue in react-hook-form
64
- // Ideally, we'd be able to set `opt.media.tags` as null when all items are cleared, rather than
65
- // setting it to an empty array (which is currently causing false positives in denoting whether the form is dirty)
66
- //
67
- // To illustrate this issue:
68
- // - Edit an asset with no tags
69
- // - Add a new tag (either an existing one, or create one inline)
70
- // - Remove the tag you've just created
71
- //
72
- // At this point, the form will still be marked as dirty when it shouldnt be
73
- return (
74
- <CreatableSelect
75
- components={reactSelectComponents}
76
- instanceId="tags"
77
- isClearable={false} // TODO: re-enable when we're able to correctly (manually) re-validate on clear
78
- isDisabled={creating || disabled || tagsFetching}
79
- isLoading={creating}
80
- isMulti
81
- name={name}
82
- noOptionsMessage={() => 'No tags'}
83
- onBlur={onBlur}
84
- onChange={onChange}
85
- onCreateOption={onCreateTag}
86
- options={options}
87
- placeholder={tagsFetching ? 'Loading...' : placeholder}
88
- styles={reactSelectStyles(scheme)}
89
- value={controllerValue}
90
- />
91
- )
92
- }}
93
- />
94
- </Box>
95
- )
96
- }
97
-
98
- export default FormFieldInputTags
@@ -1,41 +0,0 @@
1
- import {Box, TextInput} from '@sanity/ui'
2
- import {forwardRef} from 'react'
3
-
4
- import FormFieldInputLabel from '../FormFieldInputLabel'
5
-
6
- type Props = {
7
- description?: string
8
- disabled?: boolean
9
- error?: string
10
- label: string
11
- name: string
12
- placeholder?: string
13
- value?: string
14
- }
15
-
16
- type Ref = HTMLInputElement
17
-
18
- const FormFieldInputText = forwardRef<Ref, Props>((props: Props, ref) => {
19
- const {description, disabled, error, label, name, placeholder, value, ...rest} = props
20
-
21
- return (
22
- <Box>
23
- {/* Label */}
24
- <FormFieldInputLabel description={description} error={error} label={label} name={name} />
25
- {/* Input */}
26
- <TextInput
27
- {...rest}
28
- autoComplete="off"
29
- autoFocus
30
- defaultValue={value}
31
- disabled={disabled}
32
- id={name}
33
- name={name}
34
- placeholder={placeholder}
35
- ref={ref}
36
- />
37
- </Box>
38
- )
39
- })
40
-
41
- export default FormFieldInputText
@@ -1,43 +0,0 @@
1
- import {Box, TextArea} from '@sanity/ui'
2
- import {forwardRef} from 'react'
3
-
4
- import FormFieldInputLabel from '../FormFieldInputLabel'
5
-
6
- type Props = {
7
- description?: string
8
- disabled?: boolean
9
- error?: string
10
- label: string
11
- name: string
12
- placeholder?: string
13
- rows?: number
14
- value?: string
15
- }
16
-
17
- type Ref = HTMLTextAreaElement
18
-
19
- const FormFieldInputTextarea = forwardRef<Ref, Props>((props: Props, ref) => {
20
- const {description, disabled, error, label, name, placeholder, rows, value, ...rest} = props
21
-
22
- return (
23
- <Box>
24
- {/* Label */}
25
- <FormFieldInputLabel description={description} error={error} label={label} name={name} />
26
-
27
- {/* Input */}
28
- <TextArea
29
- {...rest}
30
- autoComplete="off"
31
- defaultValue={value}
32
- disabled={disabled}
33
- id={name}
34
- name={name}
35
- placeholder={placeholder}
36
- ref={ref}
37
- rows={rows}
38
- />
39
- </Box>
40
- )
41
- })
42
-
43
- export default FormFieldInputTextarea
@@ -1,59 +0,0 @@
1
- import {Box, Button, Text, Tooltip} from '@sanity/ui'
2
- import {format} from 'date-fns'
3
- import {type ReactNode} from 'react'
4
-
5
- type Props = {
6
- disabled: boolean
7
- isValid: boolean
8
- lastUpdated?: string
9
- onClick: () => void
10
- }
11
-
12
- const FormSubmitButton = (props: Props) => {
13
- const {disabled, isValid, lastUpdated, onClick} = props
14
-
15
- let content: ReactNode
16
- if (isValid) {
17
- if (lastUpdated) {
18
- content = (
19
- <>
20
- Last updated
21
- <br /> {format(new Date(lastUpdated), 'PPp')}
22
- </>
23
- )
24
- } else {
25
- content = 'No unpublished changes'
26
- }
27
- } else {
28
- content =
29
- 'There are validation errors that need to be fixed before this document can be published'
30
- }
31
-
32
- return (
33
- <Tooltip
34
- animate
35
- content={
36
- <Box padding={3} style={{maxWidth: '185px'}}>
37
- <Text muted size={1}>
38
- {content}
39
- </Text>
40
- </Box>
41
- }
42
- disabled={'ontouchstart' in window}
43
- placement="top"
44
- portal
45
- >
46
- <Box>
47
- <Button
48
- disabled={disabled}
49
- fontSize={1}
50
- onClick={onClick}
51
- text="Save and close"
52
- tone="primary"
53
- />
54
- </Box>
55
- </Tooltip>
56
- )
57
- }
58
-
59
- export default FormSubmitButton
@@ -1,80 +0,0 @@
1
- import {CloseIcon, Icon, UploadIcon} from '@sanity/icons'
2
- import {Box, Button, Flex, Inline, Text} from '@sanity/ui'
3
- import pluralize from 'pluralize'
4
-
5
- import {useAssetSourceActions} from '../../contexts/AssetSourceDispatchContext'
6
- import {useDropzoneActions} from '../../contexts/DropzoneDispatchContext'
7
- import {useToolOptions} from '../../contexts/ToolOptionsContext'
8
- import useTypedSelector from '../../hooks/useTypedSelector'
9
-
10
- type Props = {
11
- onClose?: () => void
12
- }
13
-
14
- const Header = (props: Props) => {
15
- const {onClose} = props
16
-
17
- const {open} = useDropzoneActions()
18
- const {onSelect} = useAssetSourceActions()
19
-
20
- // Redux
21
- const assetTypes = useTypedSelector((state) => state.assets.assetTypes)
22
- const selectedDocument = useTypedSelector((state) => state.selected.document)
23
-
24
- const {directUploads} = useToolOptions()
25
-
26
- // Row: Current document / close button
27
- return (
28
- <Box paddingY={2}>
29
- <Flex align="center" justify="space-between">
30
- {/* Label */}
31
- <Box flex={1} marginX={3}>
32
- <Inline style={{whiteSpace: 'nowrap'}}>
33
- <Text textOverflow="ellipsis" weight="semibold">
34
- <span>{onSelect ? `Insert ${assetTypes.join(' or ')}` : 'Browse Assets'}</span>
35
- </Text>
36
-
37
- {selectedDocument && (
38
- <Box display={['none', 'none', 'block']}>
39
- <Text>
40
- <span style={{margin: '0 0.5em'}}>
41
- <Icon symbol="arrow-right" />
42
- </span>
43
- <span style={{textTransform: 'capitalize'}}>{selectedDocument._type}</span>
44
- </Text>
45
- </Box>
46
- )}
47
- </Inline>
48
- </Box>
49
-
50
- <Flex marginX={2}>
51
- {/* Upload */}
52
- {directUploads && (
53
- <Button
54
- fontSize={1}
55
- icon={UploadIcon}
56
- mode="bleed"
57
- onClick={open}
58
- text={`Upload ${assetTypes.length === 1 ? pluralize(assetTypes[0]!) : 'assets'}`}
59
- />
60
- )}
61
-
62
- {/* Close */}
63
- {onClose && (
64
- <Box style={{flexShrink: 0}}>
65
- <Button
66
- disabled={!onClose}
67
- icon={CloseIcon}
68
- mode="bleed"
69
- onClick={onClose}
70
- radius={2}
71
- />
72
- </Box>
73
- )}
74
- </Flex>
75
- </Flex>
76
- </Box>
77
- )
78
- }
79
-
80
- export default Header
@@ -1,41 +0,0 @@
1
- import type {ThemeColorSchemeKey} from '@sanity/ui'
2
- import type {MouseEvent} from 'react'
3
- import {styled, css} from 'styled-components'
4
-
5
- import {getSchemeColor} from '../../utils/getSchemeColor'
6
-
7
- type Props = {
8
- onClick?: (e: MouseEvent) => void
9
- $showCheckerboard?: boolean
10
- $scheme?: ThemeColorSchemeKey
11
- src: string
12
- style?: any
13
- }
14
-
15
- const Image = styled.img<Props>`
16
- --checkerboard-color: ${(props) =>
17
- props.$scheme ? getSchemeColor(props.$scheme, 'bg2') : 'inherit'};
18
-
19
- display: block;
20
- width: 100%;
21
- height: 100%;
22
- object-fit: contain;
23
-
24
- ${(props) =>
25
- props.$showCheckerboard &&
26
- css`
27
- background-image:
28
- linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),
29
- linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),
30
- linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),
31
- linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);
32
- background-size: 20px 20px;
33
- background-position:
34
- 0 0,
35
- 0 10px,
36
- 10px -10px,
37
- -10px 0;
38
- `}
39
- `
40
-
41
- export default Image
@@ -1,68 +0,0 @@
1
- import {Box, Text} from '@sanity/ui'
2
- import {useEffect} from 'react'
3
- import {useDispatch} from 'react-redux'
4
-
5
- import useBreakpointIndex from '../../hooks/useBreakpointIndex'
6
- import useTypedSelector from '../../hooks/useTypedSelector'
7
- import {assetsActions} from '../../modules/assets'
8
- import {selectCombinedItems} from '../../modules/selectors'
9
- import {tagsActions} from '../../modules/tags'
10
- import AssetGridVirtualized from '../AssetGridVirtualized'
11
- import AssetTableVirtualized from '../AssetTableVirtualized'
12
-
13
- const Items = () => {
14
- // Redux
15
- const dispatch = useDispatch()
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)
20
- const combinedItems = useTypedSelector(selectCombinedItems)
21
-
22
- const breakpointIndex = useBreakpointIndex()
23
-
24
- const hasFetchedOnce = fetchCount >= 0
25
- const hasItems = combinedItems.length > 0
26
-
27
- // Only load 1 page of items at a time.
28
- const handleLoadMoreItems = () => {
29
- if (!fetching) {
30
- dispatch(assetsActions.loadNextPage())
31
- }
32
- }
33
-
34
- // Effects
35
-
36
- // - Hide tag panel on smaller breakpoints
37
- useEffect(() => {
38
- if (breakpointIndex <= 1 && tagsPanelVisible) {
39
- dispatch(tagsActions.panelVisibleSet({panelVisible: false}))
40
- }
41
- }, [breakpointIndex, dispatch, tagsPanelVisible])
42
-
43
- const isEmpty = !hasItems && hasFetchedOnce && !fetching
44
-
45
- return (
46
- <Box flex={1} style={{width: '100%'}}>
47
- {isEmpty ? (
48
- <Box padding={4}>
49
- <Text size={1} weight="semibold">
50
- No results for the current query
51
- </Text>
52
- </Box>
53
- ) : (
54
- <>
55
- {view === 'grid' && (
56
- <AssetGridVirtualized items={combinedItems} onLoadMore={handleLoadMoreItems} />
57
- )}
58
-
59
- {view === 'table' && (
60
- <AssetTableVirtualized items={combinedItems} onLoadMore={handleLoadMoreItems} />
61
- )}
62
- </>
63
- )}
64
- </Box>
65
- )
66
- }
67
-
68
- export default Items
@@ -1,24 +0,0 @@
1
- import {useToast} from '@sanity/ui'
2
- import {useEffect} from 'react'
3
-
4
- import useTypedSelector from '../../hooks/useTypedSelector'
5
-
6
- const Notifications = () => {
7
- const items = useTypedSelector((state) => state.notifications.items)
8
- const toast = useToast()
9
-
10
- useEffect(() => {
11
- if (items.length > 0) {
12
- const lastItem = items[items.length - 1]!
13
- toast.push({
14
- closable: true,
15
- status: lastItem.status,
16
- title: lastItem.title,
17
- })
18
- }
19
- }, [items, toast])
20
-
21
- return null
22
- }
23
-
24
- export default Notifications
@@ -1,66 +0,0 @@
1
- import {SortIcon} from '@sanity/icons'
2
- import {Button, Menu, MenuButton, MenuDivider, MenuItem} from '@sanity/ui'
3
- import {useDispatch} from 'react-redux'
4
-
5
- import {getOrderTitle} from '../../config/orders'
6
- import {ORDER_OPTIONS} from '../../constants'
7
- import {usePortalPopoverProps} from '../../hooks/usePortalPopoverProps'
8
- import useTypedSelector from '../../hooks/useTypedSelector'
9
- import {assetsActions} from '../../modules/assets'
10
-
11
- const OrderSelect = () => {
12
- // Redux
13
- const dispatch = useDispatch()
14
- const order = useTypedSelector((state) => state.assets.order)
15
-
16
- const popoverProps = usePortalPopoverProps()
17
-
18
- return (
19
- <MenuButton
20
- button={
21
- <Button
22
- fontSize={1}
23
- icon={SortIcon}
24
- mode="bleed"
25
- padding={3}
26
- text={getOrderTitle(order.field, order.direction)}
27
- />
28
- }
29
- id="order"
30
- menu={
31
- <Menu>
32
- {ORDER_OPTIONS?.map((item, index) => {
33
- if (item) {
34
- const selected = order.field === item.field && order.direction === item.direction
35
- return (
36
- <MenuItem
37
- disabled={selected}
38
- fontSize={1}
39
- iconRight={selected}
40
- key={index}
41
- onClick={() =>
42
- dispatch(
43
- assetsActions.orderSet({
44
- order: {direction: item.direction, field: item.field},
45
- }),
46
- )
47
- }
48
- padding={2}
49
- selected={selected}
50
- space={4}
51
- style={{minWidth: '200px'}}
52
- text={getOrderTitle(item.field, item.direction)}
53
- />
54
- )
55
- }
56
-
57
- return <MenuDivider key={index} />
58
- })}
59
- </Menu>
60
- }
61
- popover={popoverProps}
62
- />
63
- )
64
- }
65
-
66
- export default OrderSelect
@@ -1,77 +0,0 @@
1
- import {Box, Button, Flex, Label} from '@sanity/ui'
2
- import pluralize from 'pluralize'
3
- import {useDispatch} from 'react-redux'
4
- import {useColorSchemeValue} from 'sanity'
5
-
6
- import {PANEL_HEIGHT} from '../../constants'
7
- import useTypedSelector from '../../hooks/useTypedSelector'
8
- import {assetsActions, selectAssetsPicked} from '../../modules/assets'
9
- import {dialogActions} from '../../modules/dialog'
10
- import {getSchemeColor} from '../../utils/getSchemeColor'
11
-
12
- const PickedBar = () => {
13
- const scheme = useColorSchemeValue()
14
-
15
- // Redux
16
- const dispatch = useDispatch()
17
- const assetsPicked = useTypedSelector(selectAssetsPicked)
18
-
19
- // Callbacks
20
- const handlePickClear = () => {
21
- dispatch(assetsActions.pickClear())
22
- }
23
-
24
- const handleDeletePicked = () => {
25
- dispatch(dialogActions.showConfirmDeleteAssets({assets: assetsPicked}))
26
- }
27
-
28
- if (assetsPicked.length === 0) {
29
- return null
30
- }
31
-
32
- return (
33
- <Flex
34
- align="center"
35
- justify="flex-start"
36
- style={{
37
- background: getSchemeColor(scheme, 'bg'),
38
- borderBottom: '1px solid var(--card-border-color)',
39
- height: `${PANEL_HEIGHT}px`,
40
- position: 'relative',
41
- width: '100%',
42
- }}
43
- >
44
- <Flex align="center" paddingX={3}>
45
- <Box paddingRight={2}>
46
- <Label size={0} style={{color: 'inherit'}}>
47
- {assetsPicked.length} {pluralize('asset', assetsPicked.length)} selected
48
- </Label>
49
- </Box>
50
-
51
- {/* Deselect button */}
52
- <Button
53
- mode="bleed"
54
- onClick={handlePickClear}
55
- padding={2}
56
- style={{background: 'none', boxShadow: 'none'}}
57
- tone="default"
58
- >
59
- <Label size={0}>Deselect</Label>
60
- </Button>
61
-
62
- {/* Delete button */}
63
- <Button
64
- mode="bleed"
65
- onClick={handleDeletePicked}
66
- padding={2}
67
- style={{background: 'none', boxShadow: 'none'}}
68
- tone="critical"
69
- >
70
- <Label size={0}>Delete</Label>
71
- </Button>
72
- </Flex>
73
- </Flex>
74
- )
75
- }
76
-
77
- export default PickedBar
@@ -1,38 +0,0 @@
1
- import {Box} from '@sanity/ui'
2
- import {useNProgress} from '@tanem/react-nprogress'
3
-
4
- type Props = {
5
- loading?: boolean
6
- }
7
-
8
- const Progress = (props: Props) => {
9
- const {loading} = props
10
-
11
- const {animationDuration, isFinished, progress} = useNProgress({
12
- animationDuration: 300,
13
- isAnimating: loading,
14
- })
15
-
16
- return (
17
- <Box
18
- style={{
19
- opacity: isFinished ? 0 : 1,
20
- transition: `opacity ${animationDuration}ms linear`,
21
- }}
22
- >
23
- <Box
24
- style={{
25
- height: '1px',
26
- background: 'rgba(255, 255, 255, 0.5)',
27
- position: 'absolute',
28
- left: 0,
29
- top: 0,
30
- transition: `width ${animationDuration}ms linear`,
31
- width: `${progress * 100}%`,
32
- }}
33
- />
34
- </Box>
35
- )
36
- }
37
-
38
- export default Progress