sanity-plugin-media 2.2.1 → 2.2.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 (35) hide show
  1. package/lib/index.esm.js +1 -1
  2. package/lib/index.esm.js.map +1 -1
  3. package/lib/index.js +1 -1
  4. package/lib/index.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/components/AssetMetadata/index.tsx +34 -26
  7. package/src/components/Browser/index.tsx +3 -2
  8. package/src/components/CardAsset/index.tsx +52 -35
  9. package/src/components/CardUpload/index.tsx +8 -5
  10. package/src/components/Controls/index.tsx +1 -2
  11. package/src/components/DialogAssetEdit/index.tsx +7 -5
  12. package/src/components/FileIcon/index.tsx +11 -9
  13. package/src/components/FormFieldInputTags/index.tsx +4 -1
  14. package/src/components/Image/index.tsx +5 -2
  15. package/src/components/OrderSelect/index.tsx +8 -4
  16. package/src/components/PickedBar/index.tsx +6 -3
  17. package/src/components/SearchFacet/index.tsx +13 -7
  18. package/src/components/SearchFacetNumber/index.tsx +17 -13
  19. package/src/components/SearchFacetSelect/index.tsx +25 -27
  20. package/src/components/SearchFacetString/index.tsx +3 -2
  21. package/src/components/SearchFacetTags/index.tsx +9 -3
  22. package/src/components/SearchFacets/index.tsx +9 -7
  23. package/src/components/SearchFacetsControl/index.tsx +3 -2
  24. package/src/components/TableHeader/index.tsx +18 -13
  25. package/src/components/TableRowAsset/index.tsx +49 -29
  26. package/src/components/TableRowUpload/index.tsx +7 -4
  27. package/src/components/Tag/index.tsx +2 -2
  28. package/src/components/TagView/index.tsx +3 -12
  29. package/src/components/TagViewHeader/index.tsx +6 -4
  30. package/src/components/TagsPanel/index.tsx +1 -2
  31. package/src/modules/assets/index.ts +5 -2
  32. package/src/styled/GlobalStyles/index.tsx +2 -3
  33. package/src/styled/react-select/creatable.tsx +87 -90
  34. package/src/styled/react-select/single.tsx +83 -89
  35. package/src/utils/getSchemeColor.ts +43 -0
@@ -1,101 +1,98 @@
1
- import {black, hues, white} from '@sanity/color'
2
1
  import {AddIcon, ChevronDownIcon, CloseIcon} from '@sanity/icons'
3
- import {Box, Card, Flex, studioTheme, Text} from '@sanity/ui'
2
+ import {Box, Card, Flex, rem, studioTheme, Text, ThemeColorSchemeKey} from '@sanity/ui'
4
3
  import React from 'react'
5
4
  import {components, StylesConfig} from 'react-select'
6
5
  import {Virtuoso} from 'react-virtuoso'
6
+ import {getSchemeColor} from '../../utils/getSchemeColor'
7
7
 
8
- const themeDarkPrimaryBlue = studioTheme?.color?.dark?.primary?.spot?.blue
9
- const themeDarkPrimaryGray = studioTheme?.color?.dark?.primary?.spot?.gray
10
- const themeRadius = studioTheme?.radius
11
- const themeSpace = studioTheme?.space
8
+ const {radius: themeRadius, space: themeSpace} = studioTheme
12
9
 
13
- export const reactSelectStyles: StylesConfig<
14
- {
15
- label: string
16
- value: string
17
- },
18
- true
19
- > = {
20
- control: (styles, {isDisabled, isFocused}) => {
21
- let boxShadow = `inset 0 0 0 1px ${hues.gray[900].hex}`
22
- if (isFocused) {
23
- boxShadow = `inset 0 0 0 1px ${hues.gray[900].hex}, 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color) !important`
24
- }
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
+ }
25
19
 
26
- return {
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}) => ({
27
76
  ...styles,
28
- background: isDisabled
29
- ? studioTheme.color.dark.default.input.default.disabled.bg
30
- : 'transparent',
31
- color: white.hex,
32
- border: 'none',
33
- borderRadius: themeRadius[1],
34
- boxShadow,
35
- minHeight: '35px',
36
- outline: 'none',
37
- transition: 'none',
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])}`,
38
81
  '&:hover': {
39
- boxShadow: `inset 0 0 0 1px ${studioTheme.color.dark.default.input.default.hovered.border}`
82
+ backgroundColor: getSchemeColor(scheme, 'spotBlue'),
83
+ color: getSchemeColor(scheme, 'bg')
40
84
  }
41
- }
42
- },
43
- indicatorsContainer: (styles, {isDisabled}) => ({
44
- ...styles,
45
- opacity: isDisabled ? 0.25 : 1
46
- }),
47
- input: styles => ({
48
- ...styles,
49
- color: white.hex,
50
- fontFamily: studioTheme.fonts.text.family,
51
- marginLeft: themeSpace[2]
52
- }),
53
- menuList: styles => ({
54
- ...styles
55
- }),
56
- multiValue: (styles, {isDisabled}) => ({
57
- ...styles,
58
- backgroundColor: themeDarkPrimaryGray,
59
- borderRadius: themeRadius[2],
60
- opacity: isDisabled ? 0.5 : 1
61
- }),
62
- multiValueRemove: styles => ({
63
- ...styles,
64
- paddingLeft: 0,
65
- '&:hover': {
66
- background: 'transparent',
67
- color: 'inherit'
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 ? themeDarkPrimaryBlue : 'transparent',
78
- borderRadius: themeRadius[2],
79
- color: isFocused ? black.hex : 'inherit',
80
- fontFamily: studioTheme.fonts.text.family,
81
- padding: '4px 8px', // TODO: use theme value
82
- '&:hover': {
83
- backgroundColor: themeDarkPrimaryBlue,
84
- color: black.hex
85
- }
86
- }),
87
- placeholder: styles => ({
88
- ...styles,
89
- fontFamily: studioTheme.fonts.text.family,
90
- marginLeft: themeSpace[2]
91
- }),
92
- valueContainer: styles => ({
93
- ...styles,
94
- marginBottom: themeSpace[0],
95
- marginLeft: themeSpace[1],
96
- marginTop: themeSpace[0],
97
- padding: 0
98
- })
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
+ }
99
96
  }
100
97
 
101
98
  const DropdownIndicator = (props: any) => {
@@ -147,8 +144,8 @@ const MenuList = (props: any) => {
147
144
 
148
145
  const MultiValueLabel = (props: any) => {
149
146
  return (
150
- <Box paddingLeft={1} paddingRight={0} paddingY={1}>
151
- <Text size={2} weight="medium">
147
+ <Box padding={2} paddingRight={1}>
148
+ <Text size={1} weight="medium">
152
149
  <components.MultiValueLabel {...props} />
153
150
  </Text>
154
151
  </Box>
@@ -1,92 +1,95 @@
1
- import {black, hues, white} from '@sanity/color'
2
1
  import {CloseIcon} from '@sanity/icons'
3
- import {Box, Card, studioTheme, Text} from '@sanity/ui'
2
+ import {Box, Card, rem, studioTheme, Text, ThemeColorSchemeKey} from '@sanity/ui'
4
3
  import React from 'react'
5
4
  import {components, StylesConfig} from 'react-select'
6
5
  import {Virtuoso} from 'react-virtuoso'
6
+ import {getSchemeColor} from '../../utils/getSchemeColor'
7
7
 
8
- const themeDarkPrimaryBlue = studioTheme?.color?.dark?.primary?.spot?.blue
9
- const themeDarkDefaultBaseBg = studioTheme?.color?.dark?.default?.base?.bg
10
- const themeRadius = studioTheme?.radius
11
- const themeSpace = studioTheme?.space
12
- const themeTextSizes = studioTheme?.fonts?.text?.sizes
13
-
14
- export const reactSelectStyles: StylesConfig<
15
- {
16
- label: string
17
- value: string
8
+ const {
9
+ fonts: {
10
+ text: {sizes: themeTextSizes}
18
11
  },
19
- false
20
- > = {
21
- control: (styles, {isDisabled, isFocused}) => {
22
- let boxShadow = `inset 0 0 0 1px ${hues.gray[900].hex}`
23
- if (isFocused) {
24
- boxShadow = `inset 0 0 0 1px ${hues.gray[900].hex}, 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color) !important`
25
- }
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
+ }
26
25
 
27
- return {
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}) => ({
28
61
  ...styles,
29
- backgroundColor: themeDarkDefaultBaseBg,
30
- color: white.hex,
31
- border: 'none',
62
+ backgroundColor: isFocused ? getSchemeColor(scheme, 'spotBlue') : 'transparent',
32
63
  borderRadius: themeRadius[2],
33
- boxShadow,
64
+ color: isFocused ? getSchemeColor(scheme, 'bg') : 'inherit',
34
65
  fontSize: themeTextSizes[1].fontSize,
35
- minHeight: '25px',
36
- opacity: isDisabled ? 0.5 : 'inherit',
37
- outline: 'none',
38
- transition: 'none',
66
+ lineHeight: '1em',
67
+ margin: 0,
68
+ padding: rem(themeSpace[1]),
39
69
  '&:hover': {
40
- boxShadow: `inset 0 0 0 1px ${studioTheme.color.dark.default.input.default.hovered.border}`
70
+ backgroundColor: getSchemeColor(scheme, 'spotBlue'),
71
+ color: getSchemeColor(scheme, 'bg')
41
72
  }
42
- }
43
- },
44
- input: styles => ({
45
- ...styles,
46
- color: white.hex,
47
- fontFamily: studioTheme.fonts.text.family,
48
- marginLeft: 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 ? themeDarkPrimaryBlue : 'transparent',
63
- borderRadius: themeRadius[2],
64
- color: isFocused ? black.hex : 'inherit',
65
- fontSize: themeTextSizes[1].fontSize,
66
- lineHeight: '1em',
67
- padding: '4px 6px', // TODO: use theme value
68
- '&:hover': {
69
- backgroundColor: themeDarkPrimaryBlue,
70
- color: black.hex
71
- }
72
- }),
73
- placeholder: styles => ({
74
- ...styles,
75
- fontFamily: studioTheme.fonts.text.family,
76
- marginLeft: themeSpace[2],
77
- paddingBottom: '2px'
78
- }),
79
- singleValue: styles => ({
80
- ...styles,
81
- color: white.hex,
82
- lineHeight: '1em',
83
- paddingBottom: '1px'
84
- }),
85
- valueContainer: styles => ({
86
- ...styles,
87
- margin: 0,
88
- padding: 0
89
- })
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
+ }
90
93
  }
91
94
 
92
95
  const ClearIndicator = (props: any) => {
@@ -162,18 +165,9 @@ const Option = (props: any) => {
162
165
  const SingleValue = (props: any) => {
163
166
  return (
164
167
  <components.SingleValue {...props}>
165
- <Box paddingLeft={2}>
166
- <Text
167
- size={1}
168
- style={{
169
- color: 'inherit',
170
- lineHeight: '2em' // HACK: prevent text descenders from cropping
171
- }}
172
- textOverflow="ellipsis"
173
- >
174
- {props.children}
175
- </Text>
176
- </Box>
168
+ <Text size={1} textOverflow="ellipsis">
169
+ {props.children}
170
+ </Text>
177
171
  </components.SingleValue>
178
172
  )
179
173
  }
@@ -0,0 +1,43 @@
1
+ import {hues} from '@sanity/color'
2
+ import {ThemeColorSchemeKey, studioTheme} from '@sanity/ui'
3
+
4
+ const SCHEME_COLORS = {
5
+ bg: {
6
+ dark: hues.gray[950].hex,
7
+ light: hues.gray[50].hex
8
+ },
9
+ bg2: {
10
+ dark: hues.gray[900].hex,
11
+ light: hues.gray[100].hex
12
+ },
13
+ inputEnabledBorder: {
14
+ dark: studioTheme.color.dark.default.input.default.enabled.border,
15
+ light: studioTheme.color.light.default.input.default.enabled.border
16
+ },
17
+ inputHoveredBorder: {
18
+ dark: studioTheme.color.dark.default.input.default.hovered.border,
19
+ light: studioTheme.color.light.default.input.default.hovered.border
20
+ },
21
+ mutedHoveredBg: {
22
+ dark: studioTheme.color.dark.primary.muted.primary.hovered.bg,
23
+ light: studioTheme.color.light.primary.muted.primary.hovered.bg
24
+ },
25
+ mutedHoveredFg: {
26
+ dark: studioTheme.color.dark.primary.muted.primary.hovered.fg,
27
+ light: studioTheme.color.light.primary.muted.primary.hovered.fg
28
+ },
29
+ mutedSelectedBg: {
30
+ dark: studioTheme.color.dark.primary.muted.primary.selected.bg,
31
+ light: studioTheme.color.light.primary.muted.primary.selected.bg
32
+ },
33
+ spotBlue: {
34
+ dark: studioTheme.color.dark.primary.spot.blue,
35
+ light: studioTheme.color.light.primary.spot.blue
36
+ }
37
+ }
38
+
39
+ type SchemeColorKey = keyof typeof SCHEME_COLORS
40
+
41
+ export function getSchemeColor(scheme: ThemeColorSchemeKey, colorKey: SchemeColorKey): string {
42
+ return SCHEME_COLORS[colorKey]?.[scheme]
43
+ }