@rubixstudios/payload-media 1.2.4 → 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.
Files changed (47) hide show
  1. package/README.md +72 -35
  2. package/dist/components/media-search/index.d.ts.map +1 -1
  3. package/dist/components/media-search/index.js +6 -5
  4. package/dist/components/search-drawer/filters/pexels.d.ts +4 -4
  5. package/dist/components/search-drawer/filters/pexels.d.ts.map +1 -1
  6. package/dist/components/search-drawer/filters/pexels.js +9 -8
  7. package/dist/components/search-drawer/filters/pixabay.d.ts +4 -4
  8. package/dist/components/search-drawer/filters/pixabay.d.ts.map +1 -1
  9. package/dist/components/search-drawer/filters/pixabay.js +11 -11
  10. package/dist/components/search-drawer/filters/unsplash.d.ts +4 -4
  11. package/dist/components/search-drawer/filters/unsplash.d.ts.map +1 -1
  12. package/dist/components/search-drawer/filters/unsplash.js +5 -5
  13. package/dist/components/search-drawer/index.d.ts +2 -2
  14. package/dist/components/search-drawer/index.d.ts.map +1 -1
  15. package/dist/components/search-drawer/index.js +56 -50
  16. package/dist/components/search-drawer/media/image.d.ts +2 -2
  17. package/dist/components/search-drawer/media/image.d.ts.map +1 -1
  18. package/dist/components/search-drawer/media/image.js +2 -2
  19. package/dist/components/search-drawer/media/video.d.ts +2 -2
  20. package/dist/components/search-drawer/media/video.d.ts.map +1 -1
  21. package/dist/components/search-drawer/media/video.js +5 -3
  22. package/dist/components/search-drawer/style.css +1 -1
  23. package/dist/endpoints/handler/Pexels.d.ts.map +1 -1
  24. package/dist/endpoints/handler/Pexels.js +7 -21
  25. package/dist/endpoints/handler/Pixabay.d.ts.map +1 -1
  26. package/dist/endpoints/handler/Pixabay.js +9 -22
  27. package/dist/endpoints/handler/Provider.d.ts +3 -3
  28. package/dist/endpoints/handler/Provider.d.ts.map +1 -1
  29. package/dist/endpoints/handler/Provider.js +11 -11
  30. package/dist/endpoints/handler/Unsplash.d.ts.map +1 -1
  31. package/dist/endpoints/handler/Unsplash.js +2 -6
  32. package/dist/endpoints/index.d.ts.map +1 -1
  33. package/dist/endpoints/index.js +42 -75
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +18 -19
  36. package/dist/lib/cache.d.ts.map +1 -1
  37. package/dist/lib/cache.js +12 -9
  38. package/dist/types.d.ts +101 -100
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/utils/fetchCache.d.ts.map +1 -1
  41. package/dist/utils/fetchCache.js +4 -4
  42. package/dist/utils/getProviders.d.ts +1 -1
  43. package/dist/utils/getProviders.d.ts.map +1 -1
  44. package/dist/utils/getProviders.js +6 -6
  45. package/dist/utils/resolveProvider.d.ts +1 -4
  46. package/dist/utils/resolveProvider.d.ts.map +1 -1
  47. package/package.json +3 -3
package/README.md CHANGED
@@ -1,75 +1,112 @@
1
- # PayloadCMS Media Search Plugin
1
+ # Payload CMS Media Plugin
2
2
 
3
- PayloadCMS plugin for stock image and video search across Unsplash, Pexels, and Pixabay, with filterable results and instant import.
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
- <img width="1912" height="914" alt="Image stock selection" src="https://github.com/user-attachments/assets/80ecb11f-65eb-4f58-a422-df9b170ac5d2" />
5
+ ![Stock image selection](https://github.com/user-attachments/assets/f5e62ede-11d9-4d93-9510-9d9dda73dae7)
6
6
 
7
- <img width="1912" height="914" alt="Video stock selection" src="https://github.com/user-attachments/assets/28044aaa-7144-4b66-9d5f-afc58d7939d5" />
7
+ ![Stock video selection](https://github.com/user-attachments/assets/4a1e0a7a-f593-45c4-a4c3-4b9325569a52)
8
8
 
9
- This project is an independent implementation derived [PayloadBites' Image Search](https://github.com/rilrom/payload-bites/tree/main/packages/image-search) extended with provider-specific image filtering and improved Windows OS compatibility.
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
- // payload.config.ts
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
- disabled: false, // Optional, defaults to false
26
- access: ({ req: { user } }) => Boolean(user), // Media search access control
27
- pexels: process.env.API_KEY_PEXELS!,
28
- pixabay: process.env.API_KEY_PIXABAY!,
29
- unsplash: process.env.API_KEY_UNSPLASH!,
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
- ## Notes
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
- API key can be obtained from the respective provider's website.
71
+ ## Provider API keys
38
72
 
39
- - [Unsplash](https://unsplash.com/developers)
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
- When using Unplash, utilise your Access Key for the API Token.
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
- - Stock image and video search inside Payload Admin
48
- - Providers: Unsplash, Pexels, Pixabay
49
- - Provider-specific filters (color, orientation, size, type)
50
- - Featured and keyword search modes
51
- - One-click image import
52
- - Permission-based access control
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
- ## Liability
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 images are used.
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 inquiries:
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
- - LinkedIn: [rubixvi](https://www.linkedin.com/in/rubixvi/)
64
- - Website: [Rubix Studios](https://rubixstudios.com.au)
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 based on the Image Search by Riley Langbein:
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,yBA8BvB,CAAA"}
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 handleSearchSubmit = useCallback((url)=>{
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: "pill",
21
+ buttonStyle: "secondary",
22
22
  onClick: ()=>openModal(drawerSlug),
23
- size: "small"
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: handleSearchSubmit,
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 PexelsFiltersProps = {
3
+ type Props = {
4
4
  filters: ProviderFilters;
5
5
  mediaType: 'image' | 'video';
6
- setFilters: React.Dispatch<React.SetStateAction<ProviderFilters | null>>;
6
+ setFilters: Dispatch<SetStateAction<ProviderFilters | null>>;
7
7
  baseClass: string;
8
8
  };
9
- export declare const PexelsFilters: ({ filters, mediaType, setFilters, baseClass, }: PexelsFiltersProps) => React.JSX.Element | null;
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;AAGzB,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAA;AAE1B,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,OAAO,GAAG,OAAO,CAAA;IAC5B,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAA;IACxE,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,aAAa,mDAKvB,kBAAkB,6BAyEpB,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?.provider !== 'pexels') return null;
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
- provider: 'pexels',
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((o)=>o.value === filters.options.color)
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
- provider: 'pexels',
26
+ ...prev,
26
27
  options: {
27
28
  ...prev.options,
28
29
  size: opt?.value
29
30
  }
30
31
  } : prev),
31
- options: mediaType === 'video' ? PexelsVideoSize : PexelsSize,
32
+ options: sizeOptions,
32
33
  placeholder: "Size",
33
- value: (mediaType === 'video' ? PexelsVideoSize : PexelsSize).find((o)=>o.value === filters.options.size)
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
- provider: 'pexels',
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((o)=>o.value === filters.options.orientation)
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 PixabayFiltersProps = {
3
+ type Props = {
4
4
  filters: ProviderFilters;
5
5
  mediaType: 'image' | 'video';
6
- setFilters: React.Dispatch<React.SetStateAction<ProviderFilters | null>>;
6
+ setFilters: Dispatch<SetStateAction<ProviderFilters | null>>;
7
7
  baseClass: string;
8
8
  };
9
- export declare const PixabayFilters: ({ filters, mediaType, setFilters, baseClass, }: PixabayFiltersProps) => React.JSX.Element | null;
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;AAGzB,OAAO,EAML,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAA;AAE1B,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,OAAO,GAAG,OAAO,CAAA;IAC5B,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAA;IACxE,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,mDAKxB,mBAAmB,6BAmHrB,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?.provider !== 'pixabay') return null;
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
- provider: 'pixabay',
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((o)=>o.value === filters.options.category)
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
- provider: 'pixabay',
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((o)=>o.value === filters.options.image_type)
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
- provider: 'pixabay',
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((o)=>o.value === filters.options.colors)
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
- provider: 'pixabay',
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((o)=>o.value === filters.options.orientation)
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
- provider: 'pixabay',
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((o)=>o.value === filters.options.order)
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 UnsplashFiltersProps = {
3
+ type Props = {
4
4
  filters: ProviderFilters;
5
- setFilters: React.Dispatch<React.SetStateAction<ProviderFilters | null>>;
5
+ setFilters: Dispatch<SetStateAction<ProviderFilters | null>>;
6
6
  baseClass: string;
7
7
  };
8
- export declare const UnsplashFilters: ({ filters, setFilters, baseClass }: UnsplashFiltersProps) => React.JSX.Element | null;
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;AAGzB,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,mBAAmB,CAAA;AAE1B,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAA;IACxE,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,eAAe,uCAAwC,oBAAoB,6BAgDvF,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?.provider !== 'unsplash') return null;
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
- provider: 'unsplash',
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((o)=>o.value === filters.options.color)
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
- provider: 'unsplash',
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((o)=>o.value === filters.options.orientation)
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 SearchDrawerProps = {
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: SearchDrawerProps) => React.JSX.Element;
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,KAA2C,MAAM,OAAO,CAAA;AAgB/D,OAAO,aAAa,CAAA;AAIpB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,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,iBAAiB,sBA8TpD,CAAA"}
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"}