@rubixstudios/payload-media 1.2.3 → 2.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.
- package/README.md +72 -35
- package/dist/components/media-search/index.d.ts.map +1 -1
- package/dist/components/media-search/index.js +6 -5
- package/dist/components/search-drawer/filters/pexels.d.ts +4 -4
- package/dist/components/search-drawer/filters/pexels.d.ts.map +1 -1
- package/dist/components/search-drawer/filters/pexels.js +9 -8
- package/dist/components/search-drawer/filters/pixabay.d.ts +4 -4
- package/dist/components/search-drawer/filters/pixabay.d.ts.map +1 -1
- package/dist/components/search-drawer/filters/pixabay.js +11 -11
- package/dist/components/search-drawer/filters/unsplash.d.ts +4 -4
- package/dist/components/search-drawer/filters/unsplash.d.ts.map +1 -1
- package/dist/components/search-drawer/filters/unsplash.js +5 -5
- package/dist/components/search-drawer/index.d.ts +2 -2
- package/dist/components/search-drawer/index.d.ts.map +1 -1
- package/dist/components/search-drawer/index.js +56 -50
- package/dist/components/search-drawer/media/image.d.ts +2 -2
- package/dist/components/search-drawer/media/image.d.ts.map +1 -1
- package/dist/components/search-drawer/media/image.js +2 -2
- package/dist/components/search-drawer/media/video.d.ts +2 -2
- package/dist/components/search-drawer/media/video.d.ts.map +1 -1
- package/dist/components/search-drawer/media/video.js +5 -3
- package/dist/components/search-drawer/style.css +1 -1
- package/dist/endpoints/handler/Pexels.d.ts.map +1 -1
- package/dist/endpoints/handler/Pexels.js +7 -21
- package/dist/endpoints/handler/Pixabay.d.ts.map +1 -1
- package/dist/endpoints/handler/Pixabay.js +9 -22
- package/dist/endpoints/handler/Provider.d.ts +3 -3
- package/dist/endpoints/handler/Provider.d.ts.map +1 -1
- package/dist/endpoints/handler/Provider.js +11 -11
- package/dist/endpoints/handler/Unsplash.d.ts.map +1 -1
- package/dist/endpoints/handler/Unsplash.js +2 -6
- package/dist/endpoints/index.d.ts.map +1 -1
- package/dist/endpoints/index.js +42 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -19
- package/dist/lib/cache.d.ts.map +1 -1
- package/dist/lib/cache.js +12 -9
- package/dist/types.d.ts +101 -100
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/fetchCache.d.ts.map +1 -1
- package/dist/utils/fetchCache.js +4 -4
- package/dist/utils/getProviders.d.ts +1 -1
- package/dist/utils/getProviders.d.ts.map +1 -1
- package/dist/utils/getProviders.js +6 -6
- package/dist/utils/resolveProvider.d.ts +1 -4
- package/dist/utils/resolveProvider.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,75 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Payload CMS Media Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Payload CMS Media Plugin adds stock image and video search to the Payload Admin interface. Search Unsplash, Pexels, and Pixabay, apply provider-specific filters, preview results, and import selected media into upload collections.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+

|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Compatibility
|
|
10
|
+
|
|
11
|
+
The plugin maintains two release lines, with Payload CMS v4 as the primary release and Payload CMS v3 maintained separately.
|
|
12
|
+
|
|
13
|
+
| Payload CMS | Plugin version | Release branch | npm dist-tag |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| v4 | 2.x | `main` | `latest` |
|
|
16
|
+
| v3 | 1.x | `payload-v3` | `payload-v3` |
|
|
17
|
+
|
|
18
|
+
Install the release matching your Payload version. The `latest` tag targets Payload v4 after the v4 release is published.
|
|
10
19
|
|
|
11
20
|
## Installation
|
|
12
21
|
|
|
22
|
+
### Payload CMS v4
|
|
23
|
+
|
|
24
|
+
Install the latest release.
|
|
25
|
+
|
|
13
26
|
```sh
|
|
14
27
|
pnpm add @rubixstudios/payload-media
|
|
15
28
|
```
|
|
16
29
|
|
|
30
|
+
### Payload CMS v3
|
|
31
|
+
|
|
32
|
+
Install from the dedicated v3 release channel.
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pnpm add @rubixstudios/payload-media@payload-v3
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Register `mediaPlugin` in `payload.config.ts`. The plugin uses the same configuration options across both supported Payload versions.
|
|
41
|
+
|
|
17
42
|
```typescript
|
|
18
|
-
|
|
19
|
-
import { buildConfig } from 'payload/config'
|
|
43
|
+
import { buildConfig } from 'payload'
|
|
20
44
|
import { mediaPlugin } from '@rubixstudios/payload-media'
|
|
21
45
|
|
|
22
46
|
export default buildConfig({
|
|
23
47
|
plugins: [
|
|
24
48
|
mediaPlugin({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
49
|
+
pexels: process.env.API_KEY_PEXELS,
|
|
50
|
+
pixabay: process.env.API_KEY_PIXABAY,
|
|
51
|
+
unsplash: process.env.API_KEY_UNSPLASH,
|
|
52
|
+
access: ({ req: { user } }) => Boolean(user),
|
|
53
|
+
disabled: false,
|
|
30
54
|
}),
|
|
31
55
|
],
|
|
32
56
|
})
|
|
33
57
|
```
|
|
34
58
|
|
|
35
|
-
|
|
59
|
+
Provide an API key only for the providers you want to enable. Configured providers appear in the search interface. The plugin adds a **Search media** control to collections with uploads enabled.
|
|
60
|
+
|
|
61
|
+
### Options
|
|
62
|
+
|
|
63
|
+
| Option | Type | Default | Description |
|
|
64
|
+
| --- | --- | --- | --- |
|
|
65
|
+
| `pexels` | `string` | `''` | Pexels API key |
|
|
66
|
+
| `pixabay` | `string` | `''` | Pixabay API key |
|
|
67
|
+
| `unsplash` | `string` | `''` | Unsplash access key |
|
|
68
|
+
| `access` | Payload `Access` | Authenticated users | Controls who may use the media search endpoints |
|
|
69
|
+
| `disabled` | `boolean` | `false` | Disables plugin registration |
|
|
36
70
|
|
|
37
|
-
|
|
71
|
+
## Provider API keys
|
|
38
72
|
|
|
39
|
-
|
|
40
|
-
- [Pexels](https://www.pexels.com/api/)
|
|
41
|
-
- [Pixabay](https://pixabay.com/api/docs/)
|
|
73
|
+
Obtain API credentials from the relevant provider.
|
|
42
74
|
|
|
43
|
-
|
|
75
|
+
- [Unsplash Developers](https://unsplash.com/developers)
|
|
76
|
+
- [Pexels API](https://www.pexels.com/api/)
|
|
77
|
+
- [Pixabay API](https://pixabay.com/api/docs/)
|
|
78
|
+
|
|
79
|
+
For Unsplash, use the application's **Access Key**, not its Secret Key. Keep credentials in server-side environment variables.
|
|
44
80
|
|
|
45
81
|
## Features
|
|
46
82
|
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
83
|
+
- Search stock images and videos inside Payload Admin upload collections.
|
|
84
|
+
- Search images from Unsplash, Pexels, and Pixabay, and videos from Pexels and Pixabay.
|
|
85
|
+
- Browse featured results or search by keyword.
|
|
86
|
+
- Refine searches with provider-specific controls, including colour, orientation, size, image type, category, and ordering where supported.
|
|
87
|
+
- Preview images and videos before selection.
|
|
88
|
+
- Import a selected asset using Payload's upload controls.
|
|
89
|
+
- Restrict access using a configurable Payload access function.
|
|
90
|
+
- Cache successful search responses in browser storage for 24 hours.
|
|
91
|
+
|
|
92
|
+
## Usage and liability
|
|
53
93
|
|
|
54
|
-
|
|
94
|
+
Media availability, licensing, attribution, and permitted uses depend on the source provider. Review the applicable provider terms and licence conditions before using imported assets.
|
|
55
95
|
|
|
56
|
-
Rubix Studios, its developers, and contributors bear no responsibility for how
|
|
57
|
-
Before using any provider, ensure you have reviewed and agreed to their terms and usage policies.
|
|
96
|
+
Rubix Studios, its developers, and contributors bear no responsibility for how imported media is used.
|
|
58
97
|
|
|
59
98
|
## Support
|
|
60
99
|
|
|
61
|
-
For support or
|
|
100
|
+
For support or enquiries, contact [Rubix Studios](https://rubixstudios.com.au) or [rubixvi on LinkedIn](https://www.linkedin.com/in/rubixvi/). You can also [open an issue on GitHub](https://github.com/rubix-studios-pty-ltd/payload-media/issues).
|
|
62
101
|
|
|
63
|
-
|
|
64
|
-
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
Distributed under the [MIT License](LICENSE).
|
|
65
105
|
|
|
66
106
|
## Author
|
|
67
107
|
|
|
68
|
-
Rubix Studios
|
|
69
|
-
[https://rubixstudios.com.au](https://rubixstudios.com.au)
|
|
108
|
+
[Rubix Studios](https://rubixstudios.com.au)
|
|
70
109
|
|
|
71
110
|
## Acknowledgments
|
|
72
111
|
|
|
73
|
-
This project is
|
|
74
|
-
|
|
75
|
-
- [Riley Langbein](https://github.com/rilrom)
|
|
112
|
+
This project is an independent implementation derived from [PayloadBites' Image Search](https://github.com/rilrom/payload-bites/tree/main/packages/image-search) by [Riley Langbein](https://github.com/rilrom), extended with provider-specific filters, video support, and Windows compatibility improvements.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-search/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAK1C,eAAO,MAAM,UAAU,yBAAyB,CAAA;AAEhD,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-search/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAK1C,eAAO,MAAM,UAAU,yBAAyB,CAAA;AAEhD,eAAO,MAAM,WAAW,yBAgCvB,CAAA"}
|
|
@@ -7,7 +7,7 @@ export const MediaSearch = ()=>{
|
|
|
7
7
|
const { config } = useConfig();
|
|
8
8
|
const { setUploadControlFileUrl } = useUploadControls();
|
|
9
9
|
const { openModal, closeModal } = useModal();
|
|
10
|
-
const
|
|
10
|
+
const handleSubmit = useCallback((url)=>{
|
|
11
11
|
if (!url) return;
|
|
12
12
|
setUploadControlFileUrl(url);
|
|
13
13
|
closeModal(drawerSlug);
|
|
@@ -18,14 +18,15 @@ export const MediaSearch = ()=>{
|
|
|
18
18
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("span", {
|
|
19
19
|
className: "file-field__orText"
|
|
20
20
|
}, "Or"), /*#__PURE__*/ React.createElement(Button, {
|
|
21
|
-
buttonStyle: "
|
|
21
|
+
buttonStyle: "secondary",
|
|
22
22
|
onClick: ()=>openModal(drawerSlug),
|
|
23
|
-
size: "
|
|
23
|
+
size: "medium"
|
|
24
24
|
}, "Search media"), /*#__PURE__*/ React.createElement(Drawer, {
|
|
25
|
-
slug: drawerSlug
|
|
25
|
+
slug: drawerSlug,
|
|
26
|
+
title: "Media"
|
|
26
27
|
}, /*#__PURE__*/ React.createElement(SearchDrawer, {
|
|
27
28
|
api: config.routes.api,
|
|
28
|
-
onSelect:
|
|
29
|
+
onSelect: handleSubmit,
|
|
29
30
|
serverURL: config.serverURL
|
|
30
31
|
})));
|
|
31
32
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type Dispatch, type SetStateAction } from 'react';
|
|
2
2
|
import { type ProviderFilters } from '../../../types.js';
|
|
3
|
-
type
|
|
3
|
+
type Props = {
|
|
4
4
|
filters: ProviderFilters;
|
|
5
5
|
mediaType: 'image' | 'video';
|
|
6
|
-
setFilters:
|
|
6
|
+
setFilters: Dispatch<SetStateAction<ProviderFilters | null>>;
|
|
7
7
|
baseClass: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const PexelsFilters: ({ filters, mediaType, setFilters, baseClass
|
|
9
|
+
export declare const PexelsFilters: ({ filters, mediaType, setFilters, baseClass }: Props) => React.JSX.Element | null;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=pexels.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pexels.d.ts","sourceRoot":"","sources":["../../../../src/components/search-drawer/filters/pexels.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"pexels.d.ts","sourceRoot":"","sources":["../../../../src/components/search-drawer/filters/pexels.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;AAGjE,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAA;AAE1B,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,OAAO,GAAG,OAAO,CAAA;IAC5B,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5D,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,aAAa,kDAAmD,KAAK,6BAyEjF,CAAA"}
|
|
@@ -2,14 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import { Select } from '@payloadcms/ui';
|
|
3
3
|
import { PexelsColours, PexelsOrientation, PexelsSize, PexelsVideoSize } from '../../../types.js';
|
|
4
4
|
export const PexelsFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
5
|
-
if (filters
|
|
5
|
+
if (filters.provider !== 'pexels') return null;
|
|
6
|
+
const sizeOptions = mediaType === 'video' ? PexelsVideoSize : PexelsSize;
|
|
6
7
|
return /*#__PURE__*/ React.createElement("div", {
|
|
7
8
|
className: `${baseClass}__filters`
|
|
8
9
|
}, mediaType !== 'video' && /*#__PURE__*/ React.createElement(Select, {
|
|
9
10
|
isClearable: true,
|
|
10
11
|
isSearchable: false,
|
|
11
12
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pexels' ? {
|
|
12
|
-
|
|
13
|
+
...prev,
|
|
13
14
|
options: {
|
|
14
15
|
...prev.options,
|
|
15
16
|
color: opt?.value
|
|
@@ -17,25 +18,25 @@ export const PexelsFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
17
18
|
} : prev),
|
|
18
19
|
options: PexelsColours,
|
|
19
20
|
placeholder: "Colour",
|
|
20
|
-
value: PexelsColours.find((
|
|
21
|
+
value: PexelsColours.find((option)=>option.value === filters.options.color)
|
|
21
22
|
}), /*#__PURE__*/ React.createElement(Select, {
|
|
22
23
|
isClearable: true,
|
|
23
24
|
isSearchable: false,
|
|
24
25
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pexels' ? {
|
|
25
|
-
|
|
26
|
+
...prev,
|
|
26
27
|
options: {
|
|
27
28
|
...prev.options,
|
|
28
29
|
size: opt?.value
|
|
29
30
|
}
|
|
30
31
|
} : prev),
|
|
31
|
-
options:
|
|
32
|
+
options: sizeOptions,
|
|
32
33
|
placeholder: "Size",
|
|
33
|
-
value:
|
|
34
|
+
value: sizeOptions.find((option)=>option.value === filters.options.size)
|
|
34
35
|
}), /*#__PURE__*/ React.createElement(Select, {
|
|
35
36
|
isClearable: true,
|
|
36
37
|
isSearchable: false,
|
|
37
38
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pexels' ? {
|
|
38
|
-
|
|
39
|
+
...prev,
|
|
39
40
|
options: {
|
|
40
41
|
...prev.options,
|
|
41
42
|
orientation: opt?.value
|
|
@@ -43,6 +44,6 @@ export const PexelsFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
43
44
|
} : prev),
|
|
44
45
|
options: PexelsOrientation,
|
|
45
46
|
placeholder: "Orientation",
|
|
46
|
-
value: PexelsOrientation.find((
|
|
47
|
+
value: PexelsOrientation.find((option)=>option.value === filters.options.orientation)
|
|
47
48
|
}));
|
|
48
49
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type Dispatch, type SetStateAction } from 'react';
|
|
2
2
|
import { type ProviderFilters } from '../../../types.js';
|
|
3
|
-
type
|
|
3
|
+
type Props = {
|
|
4
4
|
filters: ProviderFilters;
|
|
5
5
|
mediaType: 'image' | 'video';
|
|
6
|
-
setFilters:
|
|
6
|
+
setFilters: Dispatch<SetStateAction<ProviderFilters | null>>;
|
|
7
7
|
baseClass: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const PixabayFilters: ({ filters, mediaType, setFilters, baseClass
|
|
9
|
+
export declare const PixabayFilters: ({ filters, mediaType, setFilters, baseClass }: Props) => React.JSX.Element | null;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=pixabay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixabay.d.ts","sourceRoot":"","sources":["../../../../src/components/search-drawer/filters/pixabay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"pixabay.d.ts","sourceRoot":"","sources":["../../../../src/components/search-drawer/filters/pixabay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;AAGjE,OAAO,EAML,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAA;AAE1B,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,OAAO,GAAG,OAAO,CAAA;IAC5B,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5D,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,kDAAmD,KAAK,6BAqHlF,CAAA"}
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { Select } from '@payloadcms/ui';
|
|
3
3
|
import { PixabayCategories, PixabayColours, PixabayImageType, PixabayOrder, PixabayOrientation } from '../../../types.js';
|
|
4
4
|
export const PixabayFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
5
|
-
if (filters
|
|
5
|
+
if (filters.provider !== 'pixabay') return null;
|
|
6
6
|
return /*#__PURE__*/ React.createElement("div", {
|
|
7
7
|
className: `${baseClass}__filters`
|
|
8
8
|
}, /*#__PURE__*/ React.createElement(Select, {
|
|
9
9
|
isClearable: true,
|
|
10
10
|
isSearchable: false,
|
|
11
11
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pixabay' ? {
|
|
12
|
-
|
|
12
|
+
...prev,
|
|
13
13
|
options: {
|
|
14
14
|
...prev.options,
|
|
15
15
|
category: opt?.value
|
|
@@ -17,12 +17,12 @@ export const PixabayFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
17
17
|
} : prev),
|
|
18
18
|
options: PixabayCategories,
|
|
19
19
|
placeholder: "Category",
|
|
20
|
-
value: PixabayCategories.find((
|
|
20
|
+
value: PixabayCategories.find((option)=>option.value === filters.options.category)
|
|
21
21
|
}), mediaType !== 'video' && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Select, {
|
|
22
22
|
isClearable: true,
|
|
23
23
|
isSearchable: false,
|
|
24
24
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pixabay' ? {
|
|
25
|
-
|
|
25
|
+
...prev,
|
|
26
26
|
options: {
|
|
27
27
|
...prev.options,
|
|
28
28
|
image_type: opt?.value
|
|
@@ -30,12 +30,12 @@ export const PixabayFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
30
30
|
} : prev),
|
|
31
31
|
options: PixabayImageType,
|
|
32
32
|
placeholder: "Type",
|
|
33
|
-
value: PixabayImageType.find((
|
|
33
|
+
value: PixabayImageType.find((option)=>option.value === filters.options.image_type)
|
|
34
34
|
}), /*#__PURE__*/ React.createElement(Select, {
|
|
35
35
|
isClearable: true,
|
|
36
36
|
isSearchable: false,
|
|
37
37
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pixabay' ? {
|
|
38
|
-
|
|
38
|
+
...prev,
|
|
39
39
|
options: {
|
|
40
40
|
...prev.options,
|
|
41
41
|
colors: opt?.value
|
|
@@ -43,12 +43,12 @@ export const PixabayFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
43
43
|
} : prev),
|
|
44
44
|
options: PixabayColours,
|
|
45
45
|
placeholder: "Colour",
|
|
46
|
-
value: PixabayColours.find((
|
|
46
|
+
value: PixabayColours.find((option)=>option.value === filters.options.colors)
|
|
47
47
|
}), /*#__PURE__*/ React.createElement(Select, {
|
|
48
48
|
isClearable: true,
|
|
49
49
|
isSearchable: false,
|
|
50
50
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pixabay' ? {
|
|
51
|
-
|
|
51
|
+
...prev,
|
|
52
52
|
options: {
|
|
53
53
|
...prev.options,
|
|
54
54
|
orientation: opt?.value
|
|
@@ -56,12 +56,12 @@ export const PixabayFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
56
56
|
} : prev),
|
|
57
57
|
options: PixabayOrientation,
|
|
58
58
|
placeholder: "Orientation",
|
|
59
|
-
value: PixabayOrientation.find((
|
|
59
|
+
value: PixabayOrientation.find((option)=>option.value === filters.options.orientation)
|
|
60
60
|
})), /*#__PURE__*/ React.createElement(Select, {
|
|
61
61
|
isClearable: true,
|
|
62
62
|
isSearchable: false,
|
|
63
63
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'pixabay' ? {
|
|
64
|
-
|
|
64
|
+
...prev,
|
|
65
65
|
options: {
|
|
66
66
|
...prev.options,
|
|
67
67
|
order: opt?.value
|
|
@@ -69,6 +69,6 @@ export const PixabayFilters = ({ filters, mediaType, setFilters, baseClass })=>{
|
|
|
69
69
|
} : prev),
|
|
70
70
|
options: PixabayOrder,
|
|
71
71
|
placeholder: "Order",
|
|
72
|
-
value: PixabayOrder.find((
|
|
72
|
+
value: PixabayOrder.find((option)=>option.value === filters.options.order)
|
|
73
73
|
}));
|
|
74
74
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type Dispatch, type SetStateAction } from 'react';
|
|
2
2
|
import { type ProviderFilters } from '../../../types.js';
|
|
3
|
-
type
|
|
3
|
+
type Props = {
|
|
4
4
|
filters: ProviderFilters;
|
|
5
|
-
setFilters:
|
|
5
|
+
setFilters: Dispatch<SetStateAction<ProviderFilters | null>>;
|
|
6
6
|
baseClass: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const UnsplashFilters: ({ filters, setFilters, baseClass }:
|
|
8
|
+
export declare const UnsplashFilters: ({ filters, setFilters, baseClass }: Props) => React.JSX.Element | null;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=unsplash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsplash.d.ts","sourceRoot":"","sources":["../../../../src/components/search-drawer/filters/unsplash.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"unsplash.d.ts","sourceRoot":"","sources":["../../../../src/components/search-drawer/filters/unsplash.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;AAGjE,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,mBAAmB,CAAA;AAE1B,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5D,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,eAAe,uCAAwC,KAAK,6BAgDxE,CAAA"}
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { Select } from '@payloadcms/ui';
|
|
3
3
|
import { UnsplashColours, UnsplashOrientation } from '../../../types.js';
|
|
4
4
|
export const UnsplashFilters = ({ filters, setFilters, baseClass })=>{
|
|
5
|
-
if (filters
|
|
5
|
+
if (filters.provider !== 'unsplash') return null;
|
|
6
6
|
return /*#__PURE__*/ React.createElement("div", {
|
|
7
7
|
className: `${baseClass}__filters`
|
|
8
8
|
}, /*#__PURE__*/ React.createElement(Select, {
|
|
9
9
|
isClearable: true,
|
|
10
10
|
isSearchable: false,
|
|
11
11
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'unsplash' ? {
|
|
12
|
-
|
|
12
|
+
...prev,
|
|
13
13
|
options: {
|
|
14
14
|
...prev.options,
|
|
15
15
|
color: opt?.value
|
|
@@ -17,12 +17,12 @@ export const UnsplashFilters = ({ filters, setFilters, baseClass })=>{
|
|
|
17
17
|
} : prev),
|
|
18
18
|
options: UnsplashColours,
|
|
19
19
|
placeholder: "Colour",
|
|
20
|
-
value: UnsplashColours.find((
|
|
20
|
+
value: UnsplashColours.find((option)=>option.value === filters.options.color)
|
|
21
21
|
}), /*#__PURE__*/ React.createElement(Select, {
|
|
22
22
|
isClearable: true,
|
|
23
23
|
isSearchable: false,
|
|
24
24
|
onChange: (opt)=>setFilters((prev)=>prev?.provider === 'unsplash' ? {
|
|
25
|
-
|
|
25
|
+
...prev,
|
|
26
26
|
options: {
|
|
27
27
|
...prev.options,
|
|
28
28
|
orientation: opt?.value
|
|
@@ -30,6 +30,6 @@ export const UnsplashFilters = ({ filters, setFilters, baseClass })=>{
|
|
|
30
30
|
} : prev),
|
|
31
31
|
options: UnsplashOrientation,
|
|
32
32
|
placeholder: "Orientation",
|
|
33
|
-
value: UnsplashOrientation.find((
|
|
33
|
+
value: UnsplashOrientation.find((option)=>option.value === filters.options.orientation)
|
|
34
34
|
}));
|
|
35
35
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style.css';
|
|
3
|
-
export type
|
|
3
|
+
export type Props = {
|
|
4
4
|
serverURL: string;
|
|
5
5
|
api: string;
|
|
6
6
|
onSelect: (value: string) => void;
|
|
7
7
|
};
|
|
8
|
-
export declare const SearchDrawer: (props:
|
|
8
|
+
export declare const SearchDrawer: (props: Props) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/search-drawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/search-drawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqD,MAAM,OAAO,CAAA;AAgBzE,OAAO,aAAa,CAAA;AAIpB,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,KAAK,sBA6UxC,CAAA"}
|