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,184 +0,0 @@
1
- import {AddIcon, ChevronDownIcon, CloseIcon} from '@sanity/icons'
2
- import {Box, Card, Flex, rem, studioTheme, Text, type ThemeColorSchemeKey} from '@sanity/ui'
3
- import {components, type StylesConfig} from 'react-select'
4
- import {Virtuoso} from 'react-virtuoso'
5
-
6
- import {getSchemeColor} from '../../utils/getSchemeColor'
7
-
8
- const {radius: themeRadius, space: themeSpace} = studioTheme
9
-
10
- export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig => {
11
- return {
12
- control: (styles, {isFocused}) => {
13
- let boxShadow = `inset 0 0 0 1px var(--card-border-color)`
14
- if (isFocused) {
15
- boxShadow = `inset 0 0 0 1px ${getSchemeColor(scheme, 'inputEnabledBorder')},
16
- 0 0 0 1px var(--card-bg-color),
17
- 0 0 0 3px var(--card-focus-ring-color) !important`
18
- }
19
-
20
- return {
21
- ...styles,
22
- 'backgroundColor': 'var(--card-bg-color)',
23
- 'color': 'inherit',
24
- 'border': 'none',
25
- 'borderRadius': themeRadius[1],
26
- boxShadow,
27
- 'margin': 0,
28
- 'minHeight': '35px',
29
- 'outline': 'none',
30
- 'padding': rem(themeSpace[1]!),
31
- 'transition': 'none',
32
- '&:hover': {
33
- boxShadow: `inset 0 0 0 1px ${getSchemeColor(scheme, 'inputHoveredBorder')}`,
34
- },
35
- }
36
- },
37
- indicatorsContainer: (styles, {isDisabled}) => ({
38
- ...styles,
39
- opacity: isDisabled ? 0.25 : 1,
40
- }),
41
- input: (styles) => ({
42
- ...styles,
43
- color: 'var(--card-fg-color)',
44
- fontFamily: studioTheme.fonts.text.family,
45
- marginLeft: rem(themeSpace[2]!),
46
- }),
47
- menuList: (styles) => ({
48
- ...styles,
49
- }),
50
- multiValue: (styles, {isDisabled}) => ({
51
- ...styles,
52
- backgroundColor: getSchemeColor(scheme, 'mutedHoveredBg'),
53
- borderRadius: themeRadius[2],
54
- opacity: isDisabled ? 0.5 : 1,
55
- }),
56
- multiValueLabel: () => ({
57
- color: getSchemeColor(scheme, 'mutedHoveredFg'),
58
- fontSize: 'inherit',
59
- padding: 0,
60
- }),
61
- multiValueRemove: (styles) => ({
62
- ...styles,
63
- 'borderTopLeftRadius': 0,
64
- 'borderBottomLeftRadius': 0,
65
- 'svg': {color: getSchemeColor(scheme, 'mutedHoveredFg')},
66
- '&:hover': {
67
- backgroundColor: getSchemeColor(scheme, 'mutedSelectedBg'),
68
- },
69
- }),
70
- noOptionsMessage: (styles) => ({
71
- ...styles,
72
- fontFamily: studioTheme.fonts.text.family,
73
- lineHeight: '1em',
74
- }),
75
- option: (styles, {isFocused}) => ({
76
- ...styles,
77
- 'backgroundColor': isFocused ? getSchemeColor(scheme, 'spotBlue') : 'transparent',
78
- 'borderRadius': themeRadius[2],
79
- 'color': isFocused ? getSchemeColor(scheme, 'bg') : 'inherit',
80
- 'padding': `${rem(themeSpace[1]!)} ${rem(themeSpace[2]!)}`,
81
- '&:hover': {
82
- backgroundColor: getSchemeColor(scheme, 'spotBlue'),
83
- color: getSchemeColor(scheme, 'bg'),
84
- },
85
- }),
86
- placeholder: (styles) => ({
87
- ...styles,
88
- marginLeft: rem(themeSpace[2]!),
89
- }),
90
- valueContainer: (styles) => ({
91
- ...styles,
92
- margin: 0,
93
- padding: 0,
94
- }),
95
- }
96
- }
97
-
98
- const DropdownIndicator = (props: any) => {
99
- return (
100
- <components.DropdownIndicator {...props}>
101
- <Box paddingX={2}>
102
- <Text size={1}>
103
- <ChevronDownIcon />
104
- </Text>
105
- </Box>
106
- </components.DropdownIndicator>
107
- )
108
- }
109
-
110
- const Menu = (props: any) => {
111
- return (
112
- <components.Menu {...props}>
113
- <Card radius={1} shadow={2}>
114
- {props.children}
115
- </Card>
116
- </components.Menu>
117
- )
118
- }
119
-
120
- const MenuList = (props: any) => {
121
- const {children} = props
122
-
123
- const MAX_ROWS = 5
124
- const OPTION_HEIGHT = 37
125
-
126
- if (Array.isArray(children)) {
127
- const height =
128
- children.length > MAX_ROWS ? OPTION_HEIGHT * MAX_ROWS : children.length * OPTION_HEIGHT
129
-
130
- return (
131
- <Virtuoso
132
- className="media__custom-scrollbar"
133
- itemContent={(index) => {
134
- const item = children[index]
135
- return <Option {...item.props} />
136
- }}
137
- style={{height}}
138
- totalCount={children.length}
139
- />
140
- )
141
- }
142
- return <components.MenuList {...props}>{children}</components.MenuList>
143
- }
144
-
145
- const MultiValueLabel = (props: any) => {
146
- return (
147
- <Box padding={2} paddingRight={1}>
148
- <Text size={1} weight="medium">
149
- <components.MultiValueLabel {...props} />
150
- </Text>
151
- </Box>
152
- )
153
- }
154
-
155
- const MultiValueRemove = (props: any) => {
156
- return (
157
- <components.MultiValueRemove {...props}>
158
- <CloseIcon color="#1f2123" />
159
- </components.MultiValueRemove>
160
- )
161
- }
162
-
163
- const Option = (props: any) => {
164
- return (
165
- <Box paddingX={1} paddingY={1}>
166
- <components.Option {...props}>
167
- <Flex align="center">
168
- {props.data.__isNew__ && <AddIcon style={{marginRight: '3px'}} />}
169
- {props.children}
170
- </Flex>
171
- </components.Option>
172
- </Box>
173
- )
174
- }
175
-
176
- export const reactSelectComponents = {
177
- DropdownIndicator,
178
- IndicatorSeparator: null,
179
- Menu,
180
- MenuList,
181
- MultiValueLabel,
182
- MultiValueRemove,
183
- Option,
184
- }
@@ -1,184 +0,0 @@
1
- import {CloseIcon} from '@sanity/icons'
2
- import {Box, Card, rem, studioTheme, Text, type ThemeColorSchemeKey} from '@sanity/ui'
3
- import {components, type StylesConfig} from 'react-select'
4
- import {Virtuoso} from 'react-virtuoso'
5
-
6
- import {getSchemeColor} from '../../utils/getSchemeColor'
7
-
8
- const {
9
- fonts: {
10
- text: {sizes: themeTextSizes},
11
- },
12
- radius: themeRadius,
13
- space: themeSpace,
14
- } = studioTheme
15
-
16
- export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig => {
17
- return {
18
- control: (styles, {isDisabled, isFocused}) => {
19
- let boxShadow = `inset 0 0 0 1px var(--card-border-color)`
20
- if (isFocused) {
21
- boxShadow = `inset 0 0 0 1px ${getSchemeColor(scheme, 'inputEnabledBorder')},
22
- 0 0 0 1px ${getSchemeColor(scheme, 'bg2')},
23
- 0 0 0 3px var(--card-focus-ring-color) !important`
24
- }
25
-
26
- return {
27
- ...styles,
28
- 'backgroundColor': 'var(--card-bg-color)',
29
- 'color': 'inherit',
30
- 'border': 'none',
31
- 'borderRadius': themeRadius[2],
32
- boxShadow,
33
- 'fontSize': themeTextSizes[1]!.fontSize,
34
- 'minHeight': '25px',
35
- 'opacity': isDisabled ? 0.5 : 'inherit',
36
- 'outline': 'none',
37
- 'transition': 'none',
38
- '&:hover': {
39
- boxShadow: `inset 0 0 0 1px ${getSchemeColor(scheme, 'inputHoveredBorder')}`,
40
- },
41
- }
42
- },
43
- input: (styles) => ({
44
- ...styles,
45
- color: 'var(--card-fg-color)',
46
- fontFamily: studioTheme.fonts.text.family,
47
- fontSize: themeTextSizes[1]!.fontSize,
48
- marginLeft: rem(themeSpace[2]!),
49
- }),
50
- menuList: (styles) => ({
51
- ...styles,
52
- padding: 0,
53
- }),
54
- noOptionsMessage: (styles) => ({
55
- ...styles,
56
- fontFamily: studioTheme.fonts.text.family,
57
- fontSize: themeTextSizes[1]!.fontSize,
58
- lineHeight: '1em',
59
- }),
60
- option: (styles, {isFocused}) => ({
61
- ...styles,
62
- 'backgroundColor': isFocused ? getSchemeColor(scheme, 'spotBlue') : 'transparent',
63
- 'borderRadius': themeRadius[2],
64
- 'color': isFocused ? getSchemeColor(scheme, 'bg') : 'inherit',
65
- 'fontSize': themeTextSizes[1]!.fontSize,
66
- 'lineHeight': '1em',
67
- 'margin': 0,
68
- 'padding': rem(themeSpace[1]!),
69
- '&:hover': {
70
- backgroundColor: getSchemeColor(scheme, 'spotBlue'),
71
- color: getSchemeColor(scheme, 'bg'),
72
- },
73
- }),
74
- placeholder: (styles) => ({
75
- ...styles,
76
- fontSize: themeTextSizes[1]!.fontSize,
77
- marginLeft: rem(themeSpace[2]!),
78
- paddingLeft: 0,
79
- }),
80
- singleValue: (styles) => ({
81
- ...styles,
82
- alignItems: 'center',
83
- display: 'inline-flex',
84
- height: '100%',
85
- marginLeft: rem(themeSpace[2]!),
86
- }),
87
- valueContainer: (styles) => ({
88
- ...styles,
89
- margin: 0,
90
- padding: 0,
91
- }),
92
- }
93
- }
94
-
95
- const ClearIndicator = (props: any) => {
96
- return (
97
- <components.ClearIndicator {...props}>
98
- <Box
99
- paddingRight={1}
100
- style={{
101
- transform: 'scale(0.85)',
102
- }}
103
- >
104
- <Text muted size={0}>
105
- <CloseIcon />
106
- </Text>
107
- </Box>
108
- </components.ClearIndicator>
109
- )
110
- }
111
-
112
- const Menu = (props: any) => {
113
- return (
114
- <components.Menu {...props}>
115
- <Card radius={1} shadow={2}>
116
- {props.children}
117
- </Card>
118
- </components.Menu>
119
- )
120
- }
121
-
122
- const MenuList = (props: any) => {
123
- const {children} = props
124
-
125
- const MAX_ROWS = 5
126
- const OPTION_HEIGHT = 33
127
-
128
- if (Array.isArray(children)) {
129
- const height =
130
- children.length > MAX_ROWS ? OPTION_HEIGHT * MAX_ROWS : children.length * OPTION_HEIGHT
131
-
132
- return (
133
- <Virtuoso
134
- className="media__custom-scrollbar"
135
- itemContent={(index) => {
136
- const item = children[index]
137
- return <Option {...item.props} />
138
- }}
139
- style={{height}}
140
- totalCount={children.length}
141
- />
142
- )
143
- }
144
- return <components.MenuList {...props}>{children}</components.MenuList>
145
- }
146
-
147
- const NoOptionsMessage = (props: any) => {
148
- return <components.NoOptionsMessage {...props}>{props.children}</components.NoOptionsMessage>
149
- }
150
-
151
- const Option = (props: any) => {
152
- return (
153
- <Box padding={1}>
154
- <components.Option {...props}>
155
- <Box paddingY={1}>
156
- <Text size={1} style={{color: 'inherit'}} textOverflow="ellipsis">
157
- {props.children}
158
- </Text>
159
- </Box>
160
- </components.Option>
161
- </Box>
162
- )
163
- }
164
-
165
- const SingleValue = (props: any) => {
166
- return (
167
- <components.SingleValue {...props}>
168
- <Text size={1} textOverflow="ellipsis">
169
- {props.children}
170
- </Text>
171
- </components.SingleValue>
172
- )
173
- }
174
-
175
- export const reactSelectComponents = {
176
- ClearIndicator,
177
- DropdownIndicator: null,
178
- IndicatorSeparator: null,
179
- Menu,
180
- MenuList,
181
- NoOptionsMessage,
182
- Option,
183
- SingleValue,
184
- }
@@ -1,346 +0,0 @@
1
- import type {Action} from '@reduxjs/toolkit'
2
- import type {
3
- SanityAssetDocument,
4
- SanityClient,
5
- SanityDocument,
6
- SanityImageAssetDocument,
7
- } from '@sanity/client'
8
- import type {ComponentType, JSX} from 'react'
9
- import type {Epic} from 'redux-observable'
10
- import * as z from 'zod'
11
-
12
- import type {DetailsProps} from '../components/DialogAssetEdit/Details'
13
- import {getAssetFormSchema, tagFormSchema, tagOptionSchema} from '../formSchema'
14
- import type {RootReducerState} from '../modules/types'
15
-
16
- export type MediaTagsOptions = {
17
- mediaTags?: string[]
18
- }
19
-
20
- export type MediaToolOptions = {
21
- maximumUploadSize?: number
22
- createTagsOnUpload?: boolean
23
- components?: {
24
- details?: ComponentType<
25
- DetailsProps & {renderDefaultDetails: (props: DetailsProps) => JSX.Element}
26
- >
27
- }
28
- creditLine?: {
29
- enabled: boolean
30
- excludeSources?: string | string[]
31
- }
32
- directUploads?: boolean
33
- /**
34
- * Optional locales following Sanity recommended scheme: [{ id, title }]
35
- * https://www.sanity.io/docs/studio/localization#k4da239411955
36
- */
37
- locales?: Locale[]
38
- }
39
-
40
- export type Locale = {
41
- title: string
42
- id: string
43
- [key: string]: unknown
44
- }
45
-
46
- type LocalizedString = string | Record<string, string>
47
-
48
- type CustomFields = {
49
- altText?: LocalizedString
50
- description?: LocalizedString
51
- opt?: {
52
- media?: {
53
- tags?: SanityReference[]
54
- }
55
- }
56
- title?: LocalizedString
57
- }
58
-
59
- type SearchFacetInputCommon = {
60
- assetTypes: AssetType[]
61
- name: string
62
- operatorType: SearchFacetOperatorType
63
- operatorTypes?: (SearchFacetOperatorType | null)[]
64
- selectOnly?: boolean
65
- title: string
66
- }
67
-
68
- export type Asset = FileAsset | ImageAsset
69
-
70
- export type AssetFormData = z.infer<ReturnType<typeof getAssetFormSchema>>
71
-
72
- export type AssetItem = {
73
- _type: 'asset'
74
- asset: Asset
75
- error?: string
76
- picked: boolean
77
- updating: boolean
78
- }
79
-
80
- export type AssetType = 'file' | 'image'
81
-
82
- export type Block = {
83
- _type: string
84
- _key: string
85
- children: Span[]
86
- markDefs: MarkDef[]
87
- }
88
-
89
- export type BrowserView = 'grid' | 'table'
90
-
91
- // TODO: rename
92
- export type CardAssetData = {
93
- id: string
94
- type: 'asset'
95
- }
96
-
97
- export type CardUploadData = {
98
- id: string
99
- type: 'upload'
100
- }
101
-
102
- export type Dialog =
103
- | DialogAssetEditProps
104
- | DialogConfirmProps
105
- | DialogSearchFacetsProps
106
- | DialogTagCreateProps
107
- | DialogTagEditProps
108
- | DialogTagsProps
109
-
110
- export type DialogAssetEditProps = {
111
- assetId?: string
112
- closeDialogId?: string
113
- id: string
114
- lastCreatedTag?: {
115
- label: string
116
- value: string
117
- }
118
- lastRemovedTagIds?: string[]
119
- type: 'assetEdit'
120
- }
121
-
122
- export type DialogConfirmProps = {
123
- closeDialogId?: string
124
- confirmCallbackAction: Action // TODO: reconsider
125
- confirmText: string
126
- description?: string
127
- headerTitle: string
128
- id: string
129
- title: string
130
- tone: 'critical' | 'primary'
131
- type: 'confirm'
132
- }
133
-
134
- export type DialogSearchFacetsProps = {
135
- closeDialogId?: string
136
- id: string
137
- type: 'searchFacets'
138
- }
139
-
140
- export type DialogTagsProps = {
141
- closeDialogId?: string
142
- id: string
143
- type: 'tags'
144
- }
145
-
146
- export type DialogTagCreateProps = {
147
- closeDialogId?: string
148
- id: string
149
- type: 'tagCreate'
150
- }
151
-
152
- export type DialogTagEditProps = {
153
- closeDialogId?: string
154
- id: string
155
- tagId?: string
156
- type: 'tagEdit'
157
- }
158
-
159
- export type HttpError = {
160
- message: string
161
- statusCode: number
162
- }
163
-
164
- export type FileAsset = SanityAssetDocument &
165
- CustomFields & {
166
- _type: 'sanity.fileAsset'
167
- }
168
-
169
- export type ImageAsset = SanityImageAssetDocument &
170
- CustomFields & {
171
- _type: 'sanity.imageAsset'
172
- creditLine?: LocalizedString
173
- }
174
-
175
- export type MarkDef = {_key: string; _type: string}
176
-
177
- export type MyEpic = Epic<
178
- Action,
179
- Action,
180
- RootReducerState,
181
- {
182
- client: SanityClient
183
- }
184
- >
185
-
186
- export type Order = {
187
- direction: OrderDirection
188
- field: string
189
- }
190
-
191
- export type OrderDirection = 'asc' | 'desc'
192
-
193
- export type SanityReference = {
194
- _ref: string
195
- _type: 'reference'
196
- _weak?: boolean
197
- }
198
-
199
- export type SearchFacetInputProps =
200
- | SearchFacetInputNumberProps
201
- | SearchFacetInputSearchableProps
202
- | SearchFacetInputSelectProps
203
- | SearchFacetInputStringProps
204
-
205
- export type SearchFacetDivider = {
206
- type: 'divider'
207
- }
208
-
209
- export type SearchFacetGroup = {
210
- facets: (SearchFacetDivider | SearchFacetGroup | SearchFacetInputProps)[]
211
- title: string
212
- type: 'group'
213
- }
214
-
215
- export type SearchFacetInputNumberModifier = {
216
- fieldModifier?: (fieldName: string) => string
217
- name: string
218
- title: string
219
- }
220
-
221
- export type SearchFacetInputNumberProps = SearchFacetInputCommon & {
222
- field: string
223
- modifier?: string
224
- modifiers?: SearchFacetInputNumberModifier[]
225
- type: 'number'
226
- value?: number
227
- }
228
-
229
- export type SearchFacetInputSearchableProps = SearchFacetInputCommon & {
230
- field: string
231
- name: string
232
- options?: SearchFacetInputSelectListItemProps[]
233
- type: 'searchable'
234
- value?: TagSelectOption
235
- }
236
-
237
- export type SearchFacetInputSelectProps = SearchFacetInputCommon & {
238
- field?: string
239
- options: SearchFacetInputSelectListItemProps[]
240
- type: 'select'
241
- value: string
242
- }
243
-
244
- export type SearchFacetInputSelectListItemProps = {
245
- name: string
246
- title: string
247
- value: string
248
- }
249
-
250
- export type SearchFacetInputStringProps = SearchFacetInputCommon & {
251
- field: string
252
- modifier?: string
253
- type: 'string'
254
- value?: string
255
- }
256
-
257
- export type SearchFacetName =
258
- | 'altText'
259
- | 'creditLine'
260
- | 'description'
261
- | 'fileName'
262
- | 'height'
263
- | 'inCurrentDocument'
264
- | 'inUse'
265
- | 'isOpaque'
266
- | 'orientation'
267
- | 'size'
268
- | 'tag'
269
- | 'title'
270
- | 'type'
271
- | 'width'
272
-
273
- export type SearchFacetOperatorType =
274
- | 'doesNotInclude'
275
- | 'doesNotReference'
276
- | 'empty'
277
- | 'equalTo'
278
- | 'greaterThan'
279
- | 'greaterThanOrEqualTo'
280
- | 'includes'
281
- | 'is'
282
- | 'isNot'
283
- | 'lessThan'
284
- | 'lessThanOrEqualTo'
285
- | 'notEmpty'
286
- | 'references'
287
-
288
- export type SearchFacetOperators = Record<
289
- SearchFacetOperatorType,
290
- {
291
- fn: (value: number | string | undefined, field?: string) => string | undefined
292
- hideInput?: boolean
293
- label: string
294
- }
295
- >
296
-
297
- export type SanityUploadProgressEvent = {
298
- lengthComputable: boolean
299
- loaded: number
300
- percent: number
301
- stage: 'download' | 'upload'
302
- total: number
303
- type: 'progress'
304
- }
305
-
306
- export type Span = {
307
- _key: string
308
- text: string
309
- marks: string[]
310
- }
311
-
312
- export type Tag = SanityDocument & {
313
- name: {
314
- _type: 'slug'
315
- current: string
316
- }
317
- }
318
-
319
- export type TagActions = 'applyAll' | 'delete' | 'edit' | 'removeAll' | 'search'
320
-
321
- export type TagFormData = z.infer<typeof tagFormSchema>
322
-
323
- export type TagItem = {
324
- _type: 'tag'
325
- tag: Tag
326
- error?: HttpError
327
- picked: boolean
328
- updating: boolean
329
- }
330
-
331
- export type TagSelectOption = z.infer<typeof tagOptionSchema>
332
-
333
- export type UploadItem = {
334
- _type: 'upload'
335
- assetType: AssetType
336
- hash: string
337
- name: string
338
- objectUrl?: string
339
- percent?: number
340
- size: number
341
- status: 'complete' | 'queued' | 'uploading'
342
- }
343
-
344
- export type WithId<T extends SearchFacetInputProps> = T & {
345
- id: string
346
- }
@@ -1,5 +0,0 @@
1
- import {type Theme} from '@sanity/ui'
2
-
3
- declare module 'styled-components' {
4
- interface DefaultTheme extends Theme {}
5
- }