sanity-plugin-asset-source-unsplash 4.0.1 → 5.0.1

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 CHANGED
@@ -1,7 +1,5 @@
1
1
  # Sanity Asset Source Plugin: Unsplash
2
2
 
3
- > For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity-plugin-asset-source-unsplash/tree/studio-v2).
4
-
5
3
  ## What is it?
6
4
 
7
5
  Search for photos on Unsplash and add them to your project right inside Sanity Studio.
@@ -216,7 +214,7 @@ export default defineConfig({
216
214
  }
217
215
  ```
218
216
 
219
- ## Futher reading
217
+ ## Further reading
220
218
 
221
219
  - https://unsplash.com/documentation
222
220
  - https://www.sanity.io/docs/custom-asset-sources
@@ -224,18 +222,3 @@ export default defineConfig({
224
222
  ## License
225
223
 
226
224
  MIT-licensed. See LICENSE.
227
-
228
- ## Develop & test
229
-
230
- This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
231
- with default configuration for build & watch scripts.
232
-
233
- See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
234
- on how to run this plugin with hotreload in the studio.
235
-
236
- ### Release new version
237
-
238
- Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-asset-source-unsplash/actions/workflows/main.yml).
239
- Make sure to select the main branch and check "Release new version".
240
-
241
- Semantic release will only release on configured branches, so it is safe to run release on any branch.
@@ -0,0 +1,77 @@
1
+ import { AssetSource, Plugin } from "sanity";
2
+ /**
3
+ * @public
4
+ */
5
+ declare function UnsplashIcon(): React.JSX.Element;
6
+ /**
7
+ * @public
8
+ */
9
+ interface Asset {
10
+ kind: 'url' | 'base64' | 'file' | 'assetDocumentId';
11
+ value: string | File;
12
+ assetDocumentProps?: {
13
+ originalFileName?: string;
14
+ label?: string;
15
+ title?: string;
16
+ description?: string;
17
+ source?: {
18
+ id: string;
19
+ name: string;
20
+ url?: string;
21
+ };
22
+ creditLine?: string;
23
+ };
24
+ }
25
+ /**
26
+ * @public
27
+ */
28
+ interface AssetDocument {
29
+ _id: string;
30
+ label?: string;
31
+ title?: string;
32
+ description?: string;
33
+ source?: {
34
+ id: string;
35
+ name: string;
36
+ url?: string;
37
+ };
38
+ creditLine?: string;
39
+ originalFilename?: string;
40
+ }
41
+ /**
42
+ * @public
43
+ */
44
+ interface UnsplashPhoto {
45
+ id: string;
46
+ width: number;
47
+ height: number;
48
+ description?: string;
49
+ alt_description?: string;
50
+ urls: {
51
+ full: string;
52
+ small: string;
53
+ };
54
+ user: {
55
+ name: string;
56
+ username: string;
57
+ links: {
58
+ html: string;
59
+ };
60
+ };
61
+ links: {
62
+ html: string;
63
+ self: string;
64
+ download: string;
65
+ download_location: string;
66
+ };
67
+ }
68
+ /**
69
+ * @public
70
+ */
71
+ declare const unsplashAssetSource: AssetSource;
72
+ /**
73
+ * @public
74
+ */
75
+ declare const unsplashImageAsset: Plugin;
76
+ export { type Asset, type AssetDocument, UnsplashIcon, type UnsplashPhoto, unsplashAssetSource, unsplashImageAsset };
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["UnsplashIcon","React","JSX","Element","Asset","File","AssetDocument","UnsplashPhoto","AssetSource","Plugin","UnsplashIcon","Asset","AssetDocument","UnsplashPhoto","unsplashAssetSource","unsplashImageAsset"],"sources":["../src/components/Icon.d.ts","../src/types.d.ts","../src/index.d.ts"],"sourcesContent":["/**\n * @public\n */\nexport declare function UnsplashIcon(): React.JSX.Element;\n//# sourceMappingURL=Icon.d.ts.map","/**\n * @public\n */\nexport interface Asset {\n kind: 'url' | 'base64' | 'file' | 'assetDocumentId';\n value: string | File;\n assetDocumentProps?: {\n originalFileName?: string;\n label?: string;\n title?: string;\n description?: string;\n source?: {\n id: string;\n name: string;\n url?: string;\n };\n creditLine?: string;\n };\n}\n/**\n * @public\n */\nexport interface AssetDocument {\n _id: string;\n label?: string;\n title?: string;\n description?: string;\n source?: {\n id: string;\n name: string;\n url?: string;\n };\n creditLine?: string;\n originalFilename?: string;\n}\n/**\n * @public\n */\nexport interface UnsplashPhoto {\n id: string;\n width: number;\n height: number;\n description?: string;\n alt_description?: string;\n urls: {\n full: string;\n small: string;\n };\n user: {\n name: string;\n username: string;\n links: {\n html: string;\n };\n };\n links: {\n html: string;\n self: string;\n download: string;\n download_location: string;\n };\n}\n//# sourceMappingURL=types.d.ts.map","import { type AssetSource, type Plugin } from 'sanity';\nimport { UnsplashIcon } from './components/Icon';\nexport type { Asset, AssetDocument, UnsplashPhoto } from './types';\n/**\n * @public\n */\nexport declare const unsplashAssetSource: AssetSource;\n/**\n * @public\n */\nexport declare const unsplashImageAsset: Plugin;\nexport { UnsplashIcon };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;AAGA;iBAAwBA,YAAAA,CAAAA,GAAgBC,KAAAA,CAAMC,GAAAA,CAAIC;;;AAAlD;UCAiBC,KAAAA;EAAAA,IAAAA,EAAAA,KAAK,GAAA,QAEFC,GAAI,MAAA,GAAA,iBAAA;EAiBPC,KAAAA,EAAAA,MAAAA,GAjBGD,IAiBU;EAgBbE,kBAAa,CAAA,EAAA;;IChCTO,KAAAA,CAAAA,EAAAA,MAAAA;IAIAC,KAAAA,CAAAA,EAAAA,MAAAA;;;;;;;;;;;;;UDYJT,aAAAA;;;;;;;;;;;;;;;;UAgBAC,aAAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAnCjB;AAmBA;AAgBiBA,cChCIO,mBDgCS,EChCYN,WDgCZ;;AChC9B;AAIA;cAAqBO,oBAAoBN"}
package/dist/index.js ADDED
@@ -0,0 +1,284 @@
1
+ import { useClient, definePlugin } from "sanity";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { c } from "react-compiler-runtime";
4
+ import { SearchIcon } from "@sanity/icons";
5
+ import { Card, Text, TextInput, Dialog, Stack, Flex, Spinner } from "@sanity/ui";
6
+ import { useEffect, Component } from "react";
7
+ import InfiniteScroll from "react-infinite-scroll-component";
8
+ import { PhotoAlbum } from "react-photo-album";
9
+ import { concat, defer, BehaviorSubject } from "rxjs";
10
+ import { withLatestFrom, debounceTime, distinctUntilChanged, switchMap, map } from "rxjs/operators";
11
+ import { styled } from "styled-components";
12
+ function UnsplashIcon() {
13
+ const $ = c(1);
14
+ let t0;
15
+ return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxs("svg", { role: "img", viewBox: "0 0 25 25", width: "1em", height: "1em", fill: "currentColor", children: [
16
+ /* @__PURE__ */ jsx("title", { children: "Unsplash" }),
17
+ /* @__PURE__ */ jsx("path", { d: "M9 9V4h7v5H9Zm7 3h5v9H4v-9h5v5h7v-5Z" })
18
+ ] }), $[0] = t0) : t0 = $[0], t0;
19
+ }
20
+ const fetchSearch = (client, query, page, perPage) => defer(() => client.observable.request({
21
+ url: `/addons/unsplash/search/photos?query=${encodeURIComponent(query)}&page=${page}&per_page=${perPage}`,
22
+ withCredentials: !0,
23
+ method: "GET"
24
+ })), fetchList = (client, type, page, perPage) => defer(() => client.observable.request({
25
+ url: `/addons/unsplash/photos?order_by=${type}&page=${page}&per_page=${perPage}`,
26
+ withCredentials: !0,
27
+ method: "GET"
28
+ }));
29
+ function fetchDownloadUrl(client, photo) {
30
+ const downloadUrl = photo.links.download_location.replace("https://api.unsplash.com", "/addons/unsplash");
31
+ return client.request({
32
+ url: downloadUrl,
33
+ withCredentials: !0,
34
+ method: "GET"
35
+ }).then((result) => result.url);
36
+ }
37
+ const search = (client, query, page, resultsPerPage) => concat(query.pipe(withLatestFrom(page), debounceTime(500), distinctUntilChanged(), switchMap(([q, p]) => q ? fetchSearch(client, q, p, resultsPerPage).pipe(distinctUntilChanged(), map((result) => result.results)) : fetchList(client, "popular", p, resultsPerPage)))), Root = styled.div.withConfig({
38
+ displayName: "Root",
39
+ componentId: "sc-1yt1fqs-0"
40
+ })`overflow:hidden;background-origin:content-box;background-repeat:no-repeat;background-clip:border-box;background-size:cover;position:relative;outline:none !important;border:${({
41
+ theme
42
+ }) => `1px solid ${theme.sanity.color.card.enabled.border}`};box-sizing:content-box;-webkit-user-drag:none;&:hover{opacity:0.85;}&:focus,&:active{border:1px solid var(--input-border-color-focus);box-shadow:inset 0 0 0 3px var(--input-border-color-focus);}`, CreditLineLink = styled.a.withConfig({
43
+ displayName: "CreditLineLink",
44
+ componentId: "sc-1yt1fqs-1"
45
+ })`text-decoration:none;cursor:pointer;`, CreditLine = styled(Card).withConfig({
46
+ displayName: "CreditLine",
47
+ componentId: "sc-1yt1fqs-2"
48
+ })`${({
49
+ theme
50
+ }) => `
51
+ --creditline-fg: ${theme.sanity.color.card.enabled.fg};
52
+ --creditline-bg: ${theme.sanity.color.card.enabled.bg};
53
+ `};-webkit-user-drag:none;position:absolute;background-color:var(--creditline-bg);bottom:0;[data-ui='Text']{color:var(--creditline-fg);}`, UTM_SOURCE = "sanity-plugin-asset-source-unsplash";
54
+ function Photo(props) {
55
+ const $ = c(35), {
56
+ onClick,
57
+ data,
58
+ onKeyDown,
59
+ onFocus,
60
+ active,
61
+ width,
62
+ height
63
+ } = props;
64
+ let t0;
65
+ $[0] !== data || $[1] !== onClick ? (t0 = () => {
66
+ onClick(data);
67
+ }, $[0] = data, $[1] = onClick, $[2] = t0) : t0 = $[2];
68
+ const handleClick = t0;
69
+ let t1;
70
+ $[3] !== data.id || $[4] !== data.links.html ? (t1 = (event) => {
71
+ event.stopPropagation();
72
+ const url = `${data.links.html}?utm_source=${encodeURIComponent(UTM_SOURCE)}&utm_medium=referral`;
73
+ window.open(url, data.id, "noreferrer,noopener");
74
+ }, $[3] = data.id, $[4] = data.links.html, $[5] = t1) : t1 = $[5];
75
+ const handleCreditLineClicked = t1;
76
+ let t2;
77
+ $[6] !== data || $[7] !== onClick || $[8] !== onKeyDown ? (t2 = (event_0) => {
78
+ onKeyDown(event_0), event_0.key === "Enter" && onClick(data);
79
+ }, $[6] = data, $[7] = onClick, $[8] = onKeyDown, $[9] = t2) : t2 = $[9];
80
+ const handleKeyDown = t2;
81
+ let t3;
82
+ $[10] !== data || $[11] !== onFocus ? (t3 = () => {
83
+ onFocus(data);
84
+ }, $[10] = data, $[11] = onFocus, $[12] = t3) : t3 = $[12];
85
+ const handleMouseDown = t3;
86
+ let t4, t5;
87
+ $[13] !== active || $[14] !== data || $[15] !== onFocus ? (t4 = () => {
88
+ active && onFocus(data);
89
+ }, t5 = [active, data, onFocus], $[13] = active, $[14] = data, $[15] = onFocus, $[16] = t4, $[17] = t5) : (t4 = $[16], t5 = $[17]), useEffect(t4, t5);
90
+ const src = data.urls.small, userName = data.user.name, t6 = `Select image by ${userName} from Unsplash`, t7 = `${width}px`, t8 = `${height}px`, t9 = `url("${src}")`;
91
+ let t10;
92
+ $[18] !== t7 || $[19] !== t8 || $[20] !== t9 ? (t10 = {
93
+ width: t7,
94
+ height: t8,
95
+ backgroundImage: t9
96
+ }, $[18] = t7, $[19] = t8, $[20] = t9, $[21] = t10) : t10 = $[21];
97
+ const t11 = `Open image by ${userName} on Unsplash in new window`;
98
+ let t12;
99
+ $[22] !== data.user.username || $[23] !== t11 ? (t12 = /* @__PURE__ */ jsx(CreditLine, { padding: 2, radius: 2, margin: 2, children: /* @__PURE__ */ jsxs(Text, { size: 1, title: t11, children: [
100
+ "By @",
101
+ data.user.username
102
+ ] }) }), $[22] = data.user.username, $[23] = t11, $[24] = t12) : t12 = $[24];
103
+ let t13;
104
+ $[25] !== handleCreditLineClicked || $[26] !== t12 ? (t13 = /* @__PURE__ */ jsx(CreditLineLink, { onClick: handleCreditLineClicked, children: t12 }), $[25] = handleCreditLineClicked, $[26] = t12, $[27] = t13) : t13 = $[27];
105
+ let t14;
106
+ return $[28] !== handleClick || $[29] !== handleKeyDown || $[30] !== handleMouseDown || $[31] !== t10 || $[32] !== t13 || $[33] !== t6 ? (t14 = /* @__PURE__ */ jsx(Root, { title: t6, tabIndex: 0, onKeyDown: handleKeyDown, onMouseDown: handleMouseDown, style: t10, onClick: handleClick, children: t13 }), $[28] = handleClick, $[29] = handleKeyDown, $[30] = handleMouseDown, $[31] = t10, $[32] = t13, $[33] = t6, $[34] = t14) : t14 = $[34], t14;
107
+ }
108
+ const SearchInput = styled(TextInput).withConfig({
109
+ displayName: "SearchInput",
110
+ componentId: "sc-ssjkn6-0"
111
+ })`position:sticky;top:0;z-index:1;`;
112
+ styled.div.withConfig({
113
+ displayName: "Scroller",
114
+ componentId: "sc-ssjkn6-1"
115
+ })`overflow-y:auto;max-height:80vh;`;
116
+ const RESULTS_PER_PAGE = 42, PHOTO_SPACING = 2, PHOTO_PADDING = 1;
117
+ function UnsplashAssetSource(props) {
118
+ const $ = c(4);
119
+ let t0;
120
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
121
+ apiVersion: "2022-09-01"
122
+ }, $[0] = t0) : t0 = $[0];
123
+ const client = useClient(t0);
124
+ let t1;
125
+ return $[1] !== client || $[2] !== props ? (t1 = /* @__PURE__ */ jsx(UnsplashAssetSourceInternal, { ...props, client }), $[1] = client, $[2] = props, $[3] = t1) : t1 = $[3], t1;
126
+ }
127
+ class UnsplashAssetSourceInternal extends Component {
128
+ static defaultProps = {
129
+ selectedAssets: void 0
130
+ };
131
+ state = {
132
+ cursor: 0,
133
+ query: "",
134
+ page: 1,
135
+ searchResults: [[]],
136
+ isLoading: !0
137
+ };
138
+ searchSubscription = null;
139
+ searchSubject$ = new BehaviorSubject("");
140
+ pageSubject$ = new BehaviorSubject(1);
141
+ componentDidMount() {
142
+ this.searchSubscription = search(this.props.client, this.searchSubject$, this.pageSubject$, RESULTS_PER_PAGE).subscribe({
143
+ next: (results) => {
144
+ this.setState((prev) => ({
145
+ searchResults: [...prev.searchResults, results],
146
+ isLoading: !1
147
+ }));
148
+ }
149
+ });
150
+ }
151
+ componentWillUnmount() {
152
+ this.searchSubscription && this.searchSubscription.unsubscribe();
153
+ }
154
+ handleSelect = (photo) => (this.setState({
155
+ isLoading: !0
156
+ }), fetchDownloadUrl(this.props.client, photo).then((downloadUrl) => {
157
+ const description = photo.description || void 0, asset = {
158
+ kind: "url",
159
+ value: downloadUrl,
160
+ // @ts-expect-error TODO: this is a partial assetDocumentProps, update types.
161
+ assetDocumentProps: {
162
+ _type: "sanity.imageAsset",
163
+ source: {
164
+ name: "unsplash",
165
+ id: photo.id,
166
+ url: photo.links.html
167
+ },
168
+ description,
169
+ creditLine: `${photo.user.name} by Unsplash`
170
+ }
171
+ };
172
+ this.props.onSelect([asset]);
173
+ }));
174
+ handleClose = () => {
175
+ this.props.onClose();
176
+ };
177
+ handleSearchTermChanged = (event) => {
178
+ const query = event.currentTarget.value;
179
+ this.setState({
180
+ query,
181
+ page: 1,
182
+ searchResults: [[]],
183
+ isLoading: !0,
184
+ cursor: 0
185
+ }), this.pageSubject$.next(1), this.searchSubject$.next(query);
186
+ };
187
+ handleSearchTermCleared = () => {
188
+ this.setState({
189
+ query: "",
190
+ page: 1,
191
+ searchResults: [[]],
192
+ isLoading: !0,
193
+ cursor: 0
194
+ }), this.pageSubject$.next(1), this.searchSubject$.next("");
195
+ };
196
+ handleScrollerLoadMore = () => {
197
+ const nextPage = this.state.page + 1;
198
+ this.setState({
199
+ page: nextPage,
200
+ isLoading: !0
201
+ }), this.pageSubject$.next(nextPage), this.searchSubject$.next(this.state.query);
202
+ };
203
+ handleKeyDown = (event) => {
204
+ const {
205
+ cursor
206
+ } = this.state;
207
+ (event.keyCode === 38 || event.keyCode === 37) && cursor > 0 ? this.setState((prevState) => ({
208
+ cursor: prevState.cursor - 1
209
+ })) : (event.keyCode === 40 || event.keyCode === 39) && cursor < this.getPhotos().length - 1 && this.setState((prevState) => ({
210
+ cursor: prevState.cursor + 1
211
+ }));
212
+ };
213
+ getPhotos() {
214
+ return this.state.searchResults.flat();
215
+ }
216
+ updateCursor = (photo) => {
217
+ const index = this.getPhotos().findIndex((result) => result.id === photo.id);
218
+ this.setState({
219
+ cursor: index
220
+ });
221
+ };
222
+ renderImage = (props) => {
223
+ const {
224
+ photo,
225
+ layout
226
+ } = props, active = this.getPhotos().findIndex((result) => result.id === photo.data.id) === this.state.cursor || !1;
227
+ return /* @__PURE__ */ jsx(Photo, { onClick: this.handleSelect, onKeyDown: this.handleKeyDown, data: photo.data, width: layout.width, height: layout.height, active, onFocus: this.updateCursor });
228
+ };
229
+ render() {
230
+ const {
231
+ query,
232
+ searchResults,
233
+ isLoading
234
+ } = this.state;
235
+ return /* @__PURE__ */ jsx(Dialog, { animate: !0, id: "unsplash-asset-source", header: "Select image from Unsplash", onClose: this.handleClose, open: !0, width: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, paddingX: 4, paddingBottom: 4, children: [
236
+ /* @__PURE__ */ jsx(SearchInput, { clearButton: query.length > 0, icon: SearchIcon, onChange: this.handleSearchTermChanged, onClear: this.handleSearchTermCleared, placeholder: "Search by topics or colors", value: query }),
237
+ !isLoading && this.getPhotos().length === 0 && /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "No results found" }),
238
+ /* @__PURE__ */ jsx(
239
+ InfiniteScroll,
240
+ {
241
+ dataLength: this.getPhotos().length,
242
+ next: this.handleScrollerLoadMore,
243
+ hasMore: !0,
244
+ scrollThreshold: 0.99,
245
+ height: "60vh",
246
+ loader: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", padding: 3, children: /* @__PURE__ */ jsx(Spinner, { muted: !0 }) }),
247
+ endMessage: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "No more results" }),
248
+ children: searchResults.filter((photos) => photos.length > 0).map((photos, index) => /* @__PURE__ */ jsx(PhotoAlbum, { layout: "rows", spacing: PHOTO_SPACING, padding: PHOTO_PADDING, targetRowHeight: (width) => width < 300 ? 150 : width < 600 ? 200 : 300, photos: photos.map((photo) => ({
249
+ src: photo.urls.small,
250
+ width: photo.width,
251
+ height: photo.height,
252
+ key: photo.id,
253
+ data: photo
254
+ })), renderPhoto: this.renderImage, componentsProps: {
255
+ containerProps: {
256
+ style: {
257
+ marginBottom: `${PHOTO_SPACING}px`
258
+ }
259
+ }
260
+ } }, `gallery-${query || "popular"}-${index}`))
261
+ }
262
+ )
263
+ ] }) });
264
+ }
265
+ }
266
+ const unsplashAssetSource = {
267
+ name: "unsplash",
268
+ title: "Unsplash",
269
+ component: UnsplashAssetSource,
270
+ icon: UnsplashIcon
271
+ }, unsplashImageAsset = definePlugin({
272
+ name: "asset-source-unsplash-plugin",
273
+ form: {
274
+ image: {
275
+ assetSources: [unsplashAssetSource]
276
+ }
277
+ }
278
+ });
279
+ export {
280
+ UnsplashIcon,
281
+ unsplashAssetSource,
282
+ unsplashImageAsset
283
+ };
284
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/components/Icon.tsx","../src/datastores/unsplash.ts","../src/components/Photo.styled.tsx","../src/components/Photo.tsx","../src/components/UnsplashAssetSource.styled.tsx","../src/components/UnsplashAssetSource.tsx","../src/index.ts"],"sourcesContent":["/**\n * @public\n */\nexport function UnsplashIcon(): React.JSX.Element {\n return (\n <svg role=\"img\" viewBox=\"0 0 25 25\" width=\"1em\" height=\"1em\" fill=\"currentColor\">\n <title>Unsplash</title>\n <path d=\"M9 9V4h7v5H9Zm7 3h5v9H4v-9h5v5h7v-5Z\" />\n </svg>\n )\n}\n","import type {SanityClient} from 'sanity'\n\nimport {type BehaviorSubject, concat, defer, type Observable} from 'rxjs'\nimport {debounceTime, distinctUntilChanged, map, switchMap, withLatestFrom} from 'rxjs/operators'\n\nimport type {UnsplashPhoto} from '../types'\n\ntype SearchSubject = BehaviorSubject<string>\ntype PageSubject = BehaviorSubject<number>\n\nconst fetchSearch = (\n client: SanityClient,\n query: string,\n page: number,\n perPage: number,\n): Observable<{\n results: UnsplashPhoto[]\n total: number\n total_pages: number\n}> =>\n defer(() =>\n client.observable.request({\n url: `/addons/unsplash/search/photos?query=${encodeURIComponent(\n query,\n )}&page=${page}&per_page=${perPage}`,\n withCredentials: true,\n method: 'GET',\n }),\n )\n\nconst fetchList = (\n client: SanityClient,\n type: string,\n page: number,\n perPage: number,\n): Observable<UnsplashPhoto[]> =>\n defer(() =>\n client.observable.request({\n url: `/addons/unsplash/photos?order_by=${type}&page=${page}&per_page=${perPage}`,\n withCredentials: true,\n method: 'GET',\n }),\n )\n\nexport function fetchDownloadUrl(client: SanityClient, photo: UnsplashPhoto): Promise<string> {\n const downloadUrl = photo.links.download_location.replace(\n 'https://api.unsplash.com',\n '/addons/unsplash',\n )\n return client\n .request({\n url: downloadUrl,\n withCredentials: true,\n method: 'GET',\n })\n .then((result: {url: string}) => {\n return result.url\n })\n}\n\nexport const search = (\n client: SanityClient,\n query: SearchSubject,\n page: PageSubject,\n resultsPerPage: number,\n): Observable<UnsplashPhoto[]> => {\n return concat(\n query.pipe(\n withLatestFrom(page),\n debounceTime(500),\n distinctUntilChanged(),\n switchMap(([q, p]) => {\n if (q) {\n return fetchSearch(client, q, p, resultsPerPage).pipe(\n distinctUntilChanged(),\n map((result) => result.results),\n )\n }\n return fetchList(client, 'popular', p, resultsPerPage)\n }),\n ),\n )\n}\n","import {Card} from '@sanity/ui'\nimport {styled} from 'styled-components'\n\nexport const Root = styled.div`\n overflow: hidden;\n background-origin: content-box;\n background-repeat: no-repeat;\n background-clip: border-box;\n background-size: cover;\n position: relative;\n outline: none !important;\n border: ${({theme}) => `1px solid ${theme.sanity.color.card.enabled.border}`};\n box-sizing: content-box;\n -webkit-user-drag: none;\n\n &:hover {\n opacity: 0.85;\n }\n\n &:focus,\n &:active {\n border: 1px solid var(--input-border-color-focus);\n box-shadow: inset 0 0 0 3px var(--input-border-color-focus);\n }\n`\n\nexport const CreditLineLink = styled.a`\n text-decoration: none;\n cursor: pointer;\n`\n\nexport const CreditLine = styled(Card)`\n ${({theme}) => `\n --creditline-fg: ${theme.sanity.color.card.enabled.fg};\n --creditline-bg: ${theme.sanity.color.card.enabled.bg};\n `};\n -webkit-user-drag: none;\n position: absolute;\n background-color: var(--creditline-bg);\n bottom: 0;\n\n [data-ui='Text'] {\n color: var(--creditline-fg);\n }\n`\n","import {Text} from '@sanity/ui'\nimport {useCallback, useEffect} from 'react'\n\nimport type {UnsplashPhoto} from '../types'\n\nimport {CreditLine, CreditLineLink, Root} from './Photo.styled'\n\ntype Props = {\n data: UnsplashPhoto\n width: number\n height: number\n onClick: (photo: UnsplashPhoto) => void\n onKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void\n active: boolean\n onFocus: (photo: UnsplashPhoto) => void\n}\n\nconst UTM_SOURCE = 'sanity-plugin-asset-source-unsplash'\n\nexport default function Photo(props: Props) {\n const {onClick, data, onKeyDown, onFocus, active, width, height} = props\n\n const handleClick = useCallback(() => {\n onClick(data)\n }, [onClick, data])\n\n const handleCreditLineClicked = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n event.stopPropagation()\n const url = `${data.links.html}?utm_source=${encodeURIComponent(\n UTM_SOURCE,\n )}&utm_medium=referral`\n window.open(url, data.id, 'noreferrer,noopener')\n },\n [data],\n )\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown(event)\n if (event.key === 'Enter') {\n onClick(data)\n }\n },\n [onKeyDown, data, onClick],\n )\n\n const handleMouseDown = useCallback(() => {\n onFocus(data)\n }, [onFocus, data])\n\n useEffect(() => {\n if (active) {\n onFocus(data)\n }\n }, [active, data, onFocus])\n\n const src = data.urls.small\n const userName = data.user.name\n\n return (\n <Root\n title={`Select image by ${userName} from Unsplash`}\n tabIndex={0}\n onKeyDown={handleKeyDown}\n onMouseDown={handleMouseDown}\n style={{\n width: `${width}px`,\n height: `${height}px`,\n backgroundImage: `url(\"${src}\")`,\n }}\n onClick={handleClick}\n >\n <CreditLineLink onClick={handleCreditLineClicked}>\n <CreditLine padding={2} radius={2} margin={2}>\n <Text size={1} title={`Open image by ${userName} on Unsplash in new window`}>\n By @{data.user.username}\n </Text>\n </CreditLine>\n </CreditLineLink>\n </Root>\n )\n}\n","import {TextInput} from '@sanity/ui'\nimport {styled} from 'styled-components'\n\nexport const SearchInput = styled(TextInput)`\n position: sticky;\n top: 0;\n z-index: 1;\n`\n\nexport const Scroller = styled.div`\n overflow-y: auto;\n max-height: 80vh;\n`\n","import {SearchIcon} from '@sanity/icons'\nimport {Dialog, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {Component} from 'react'\nimport InfiniteScroll from 'react-infinite-scroll-component'\nimport {PhotoAlbum, type RenderPhotoProps, type Photo as PhotoType} from 'react-photo-album'\nimport {BehaviorSubject, type Subscription} from 'rxjs'\nimport {\n type AssetFromSource,\n type AssetSourceComponentProps,\n type SanityClient,\n useClient,\n} from 'sanity'\n\nimport type {UnsplashPhoto} from '../types'\n\nimport {fetchDownloadUrl, search} from '../datastores/unsplash'\nimport Photo from './Photo'\nimport {SearchInput} from './UnsplashAssetSource.styled'\n\ntype UnsplashPhotoAlbumPhoto = PhotoType & {\n key: string\n data: UnsplashPhoto\n}\n\ntype State = {\n query: string\n searchResults: UnsplashPhoto[][]\n page: number\n isLoading: boolean\n cursor: number\n}\n\nconst RESULTS_PER_PAGE = 42\nconst PHOTO_SPACING = 2\nconst PHOTO_PADDING = 1 // offset the 1px border width\n\nexport default function UnsplashAssetSource(props: AssetSourceComponentProps) {\n const client = useClient({apiVersion: '2022-09-01'})\n return <UnsplashAssetSourceInternal {...props} client={client} />\n}\n\nclass UnsplashAssetSourceInternal extends Component<\n AssetSourceComponentProps & {client: SanityClient},\n State\n> {\n static defaultProps = {\n selectedAssets: undefined,\n }\n\n override state = {\n cursor: 0,\n query: '',\n page: 1,\n searchResults: [[]],\n isLoading: true,\n }\n\n searchSubscription: Subscription | null = null\n\n searchSubject$ = new BehaviorSubject('')\n pageSubject$ = new BehaviorSubject(1)\n\n override componentDidMount() {\n this.searchSubscription = search(\n this.props.client,\n this.searchSubject$,\n this.pageSubject$,\n RESULTS_PER_PAGE,\n ).subscribe({\n next: (results: UnsplashPhoto[]) => {\n this.setState((prev) => ({\n searchResults: [...prev.searchResults, results],\n isLoading: false,\n }))\n },\n })\n }\n\n override componentWillUnmount() {\n if (this.searchSubscription) {\n this.searchSubscription.unsubscribe()\n }\n }\n\n handleSelect = (photo: UnsplashPhoto) => {\n this.setState({isLoading: true})\n return fetchDownloadUrl(this.props.client, photo).then((downloadUrl) => {\n const description = photo.description || undefined\n const asset: AssetFromSource = {\n kind: 'url',\n value: downloadUrl,\n // @ts-expect-error TODO: this is a partial assetDocumentProps, update types.\n assetDocumentProps: {\n _type: 'sanity.imageAsset',\n source: {\n name: 'unsplash',\n id: photo.id,\n url: photo.links.html,\n },\n description,\n creditLine: `${photo.user.name} by Unsplash`,\n },\n }\n this.props.onSelect([asset])\n return undefined\n })\n }\n\n handleClose = () => {\n this.props.onClose()\n }\n\n handleSearchTermChanged = (event: React.ChangeEvent<HTMLInputElement>) => {\n const query = event.currentTarget.value\n this.setState({\n query,\n page: 1,\n searchResults: [[]],\n isLoading: true,\n cursor: 0,\n })\n this.pageSubject$.next(1)\n this.searchSubject$.next(query)\n }\n\n handleSearchTermCleared = () => {\n this.setState({\n query: '',\n page: 1,\n searchResults: [[]],\n isLoading: true,\n cursor: 0,\n })\n this.pageSubject$.next(1)\n this.searchSubject$.next('')\n }\n\n handleScrollerLoadMore = () => {\n const nextPage = this.state.page + 1\n this.setState({page: nextPage, isLoading: true})\n this.pageSubject$.next(nextPage)\n this.searchSubject$.next(this.state.query)\n }\n\n handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const {cursor} = this.state\n if ((event.keyCode === 38 || event.keyCode === 37) && cursor > 0) {\n this.setState((prevState) => ({\n cursor: prevState.cursor - 1,\n }))\n } else if (\n (event.keyCode === 40 || event.keyCode === 39) &&\n cursor < this.getPhotos().length - 1\n ) {\n this.setState((prevState) => ({\n cursor: prevState.cursor + 1,\n }))\n }\n }\n\n getPhotos() {\n return this.state.searchResults.flat()\n }\n\n updateCursor = (photo: UnsplashPhoto) => {\n const index = this.getPhotos().findIndex((result: UnsplashPhoto) => result.id === photo.id)\n this.setState({cursor: index})\n }\n\n renderImage = (props: RenderPhotoProps<UnsplashPhotoAlbumPhoto>) => {\n const {photo, layout} = props\n const active =\n this.getPhotos().findIndex((result: UnsplashPhoto) => result.id === photo.data.id) ===\n this.state.cursor || false\n return (\n <Photo\n onClick={this.handleSelect}\n onKeyDown={this.handleKeyDown}\n data={photo.data}\n width={layout.width}\n height={layout.height}\n active={active}\n onFocus={this.updateCursor}\n />\n )\n }\n\n override render() {\n const {query, searchResults, isLoading} = this.state\n\n return (\n <Dialog\n animate\n id=\"unsplash-asset-source\"\n header=\"Select image from Unsplash\"\n onClose={this.handleClose}\n open\n width={4}\n >\n <Stack space={3} paddingX={4} paddingBottom={4}>\n <SearchInput\n clearButton={query.length > 0}\n icon={SearchIcon}\n onChange={this.handleSearchTermChanged}\n onClear={this.handleSearchTermCleared}\n placeholder=\"Search by topics or colors\"\n value={query}\n />\n {!isLoading && this.getPhotos().length === 0 && (\n <Text size={1} muted>\n No results found\n </Text>\n )}\n <InfiniteScroll\n dataLength={this.getPhotos().length} // This is important field to render the next data\n next={this.handleScrollerLoadMore}\n // scrollableTarget=\"unsplash-scroller\"\n hasMore\n scrollThreshold={0.99}\n height=\"60vh\"\n loader={\n <Flex align=\"center\" justify=\"center\" padding={3}>\n <Spinner muted />\n </Flex>\n }\n endMessage={\n <Text size={1} muted>\n No more results\n </Text>\n }\n >\n {searchResults\n .filter((photos) => photos.length > 0)\n .map((photos: UnsplashPhoto[], index) => (\n <PhotoAlbum\n key={`gallery-${query || 'popular'}-${index}`}\n layout=\"rows\"\n spacing={PHOTO_SPACING}\n padding={PHOTO_PADDING}\n targetRowHeight={(width) => {\n if (width < 300) return 150\n if (width < 600) return 200\n return 300\n }}\n photos={photos.map((photo: UnsplashPhoto) => ({\n src: photo.urls.small,\n width: photo.width,\n height: photo.height,\n key: photo.id,\n data: photo,\n }))}\n renderPhoto={this.renderImage}\n componentsProps={{\n containerProps: {\n style: {marginBottom: `${PHOTO_SPACING}px`},\n },\n }}\n />\n ))}\n </InfiniteScroll>\n </Stack>\n </Dialog>\n )\n }\n}\n","import {type AssetSource, definePlugin, type Plugin} from 'sanity'\n\nimport {UnsplashIcon} from './components/Icon'\nimport Unsplash from './components/UnsplashAssetSource'\n\nexport type {Asset, AssetDocument, UnsplashPhoto} from './types'\n\n/**\n * @public\n */\nexport const unsplashAssetSource: AssetSource = {\n name: 'unsplash',\n title: 'Unsplash',\n component: Unsplash,\n icon: UnsplashIcon,\n}\n\n/**\n * @public\n */\nexport const unsplashImageAsset: Plugin = definePlugin({\n name: 'asset-source-unsplash-plugin',\n\n form: {\n image: {\n assetSources: [unsplashAssetSource],\n },\n },\n})\n\nexport {UnsplashIcon}\n"],"names":["UnsplashIcon","$","_c","t0","for","fetchSearch","client","query","page","perPage","defer","observable","request","url","encodeURIComponent","withCredentials","method","fetchList","type","fetchDownloadUrl","photo","downloadUrl","links","download_location","replace","then","result","search","resultsPerPage","concat","pipe","withLatestFrom","debounceTime","distinctUntilChanged","switchMap","q","p","map","results","Root","styled","div","withConfig","displayName","componentId","theme","sanity","color","card","enabled","border","CreditLineLink","a","CreditLine","Card","fg","bg","UTM_SOURCE","Photo","props","onClick","data","onKeyDown","onFocus","active","width","height","handleClick","t1","id","html","event","stopPropagation","window","open","handleCreditLineClicked","t2","event_0","key","handleKeyDown","t3","handleMouseDown","t4","t5","useEffect","src","urls","small","userName","user","name","t6","t7","t8","t9","t10","backgroundImage","t11","t12","username","t13","t14","SearchInput","TextInput","RESULTS_PER_PAGE","PHOTO_SPACING","PHOTO_PADDING","UnsplashAssetSource","apiVersion","useClient","UnsplashAssetSourceInternal","Component","defaultProps","selectedAssets","undefined","state","cursor","searchResults","isLoading","searchSubscription","searchSubject$","BehaviorSubject","pageSubject$","componentDidMount","subscribe","next","setState","prev","componentWillUnmount","unsubscribe","handleSelect","description","asset","kind","value","assetDocumentProps","_type","source","creditLine","onSelect","handleClose","onClose","handleSearchTermChanged","currentTarget","handleSearchTermCleared","handleScrollerLoadMore","nextPage","keyCode","prevState","getPhotos","length","flat","updateCursor","index","findIndex","renderImage","layout","render","SearchIcon","filter","photos","containerProps","style","marginBottom","unsplashAssetSource","title","component","Unsplash","icon","unsplashImageAsset","definePlugin","form","image","assetSources"],"mappings":";;;;;;;;;;;AAGO,SAAAA,eAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AAAA,MAAAC;AAAA,SAAAF,EAAA,CAAA,6BAAAG,IAAA,2BAAA,KAEHD,KAAA,qBAAA,SAAU,MAAA,OAAc,SAAA,aAAkB,OAAA,OAAa,QAAA,OAAW,MAAA,gBAChE,UAAA;AAAA,IAAA,oBAAA,WAAO,UAAA,WAAA,CAAQ;AAAA,IACf,oBAAA,QAAA,EAAQ,GAAA,uCAAA,CAAsC;AAAA,EAAA,GAChD,GAAMF,OAAAE,MAAAA,KAAAF,EAAA,CAAA,GAHNE;AAGM;ACEV,MAAME,cAAcA,CAClBC,QACAC,OACAC,MACAC,YAMAC,MAAM,MACJJ,OAAOK,WAAWC,QAAQ;AAAA,EACxBC,KAAK,wCAAwCC,mBAC3CP,KACF,CAAC,SAASC,IAAI,aAAaC,OAAO;AAAA,EAClCM,iBAAiB;AAAA,EACjBC,QAAQ;AACV,CAAC,CACH,GAEIC,YAAYA,CAChBX,QACAY,MACAV,MACAC,YAEAC,MAAM,MACJJ,OAAOK,WAAWC,QAAQ;AAAA,EACxBC,KAAK,oCAAoCK,IAAI,SAASV,IAAI,aAAaC,OAAO;AAAA,EAC9EM,iBAAiB;AAAA,EACjBC,QAAQ;AACV,CAAC,CACH;AAEK,SAASG,iBAAiBb,QAAsBc,OAAuC;AAC5F,QAAMC,cAAcD,MAAME,MAAMC,kBAAkBC,QAChD,4BACA,kBACF;AACA,SAAOlB,OACJM,QAAQ;AAAA,IACPC,KAAKQ;AAAAA,IACLN,iBAAiB;AAAA,IACjBC,QAAQ;AAAA,EAAA,CACT,EACAS,K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9C1E,MAAM;AAAA,EACN2E,OAAO;AAAA,EACPC,WAAWC;AAAAA,EACXC,MAAMxK;AACR,GAKayK,qBAA6BC,aAAa;AAAA,EACrDhF,MAAM;AAAA,EAENiF,MAAM;AAAA,IACJC,OAAO;AAAA,MACLC,cAAc,CAACT,mBAAmB;AAAA,IAAA;AAAA,EACpC;AAEJ,CAAC;"}
package/package.json CHANGED
@@ -1,106 +1,68 @@
1
1
  {
2
2
  "name": "sanity-plugin-asset-source-unsplash",
3
- "version": "4.0.1",
3
+ "version": "5.0.1",
4
4
  "description": "Use images from Unsplash.com in your Sanity Studio",
5
5
  "keywords": [
6
- "sanity",
7
- "plugin",
8
- "images",
9
- "unsplash",
10
6
  "assets",
11
- "source"
7
+ "images",
8
+ "plugin",
9
+ "sanity",
10
+ "source",
11
+ "unsplash"
12
12
  ],
13
- "homepage": "https://github.com/sanity-io/sanity-plugin-asset-source-unsplash#readme",
13
+ "homepage": "https://github.com/sanity-io/plugins/tree/main/plugins/sanity-plugin-asset-source-unsplash#readme",
14
14
  "bugs": {
15
- "url": "https://github.com/sanity-io/sanity-plugin-asset-source-unsplash/issues"
15
+ "url": "https://github.com/sanity-io/plugins/issues"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git@github.com:sanity-io/sanity-plugin-asset-source-unsplash.git"
19
+ "url": "git+ssh://git@github.com/sanity-io/plugins.git",
20
+ "directory": "plugins/sanity-plugin-asset-source-unsplash"
20
21
  },
21
- "license": "MIT",
22
22
  "author": "Sanity.io <hello@sanity.io>",
23
- "sideEffects": false,
23
+ "license": "MIT",
24
24
  "type": "module",
25
25
  "exports": {
26
- ".": {
27
- "source": "./src/index.ts",
28
- "default": "./lib/index.js"
29
- },
26
+ ".": "./dist/index.js",
30
27
  "./package.json": "./package.json"
31
28
  },
32
- "main": "./lib/index.js",
33
- "types": "./lib/index.d.ts",
29
+ "types": "./dist/index.d.ts",
34
30
  "files": [
35
- "src",
36
- "lib"
31
+ "dist"
37
32
  ],
38
- "scripts": {
39
- "build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
40
- "format": "prettier --write --cache --ignore-unknown .",
41
- "link-watch": "plugin-kit link-watch",
42
- "lint": "eslint .",
43
- "prepare": "husky install || true",
44
- "prepublishOnly": "npm run build",
45
- "test": "npm run lint && npm run type-check && npm run build",
46
- "type-check": "tsc --noEmit",
47
- "watch": "pkg-utils watch --strict"
48
- },
49
- "browserslist": "extends @sanity/browserslist-config",
50
33
  "dependencies": {
51
34
  "@sanity/icons": "^3.7.4",
52
- "@sanity/ui": "^3.0.7",
35
+ "@sanity/ui": "^3.1.11",
36
+ "react-compiler-runtime": "^1.0.0",
53
37
  "react-infinite-scroll-component": "6.1.0",
54
38
  "react-photo-album": "2.4.1",
55
39
  "rxjs": "^7.8.2"
56
40
  },
57
41
  "devDependencies": {
58
- "@commitlint/cli": "^19.6.1",
59
- "@commitlint/config-conventional": "^19.6.0",
60
- "@sanity/pkg-utils": "^7.11.9",
61
- "@sanity/plugin-kit": "4.0.19",
62
- "@sanity/semantic-release-preset": "^4.1.8",
63
- "@types/node": "^24.3.0",
64
- "@types/react": "^19.1.10",
65
- "@types/react-dom": "^19.1.7",
66
- "@typescript-eslint/eslint-plugin": "^8.22.0",
67
- "@typescript-eslint/parser": "^8.22.0",
68
- "eslint": "^8.57.1",
69
- "eslint-config-prettier": "^9.1.0",
70
- "eslint-config-sanity": "^7.1.4",
71
- "eslint-plugin-import": "^2.31.0",
72
- "eslint-plugin-prettier": "^5.2.3",
73
- "eslint-plugin-react": "^7.37.4",
74
- "eslint-plugin-react-hooks": "^5.1.0",
75
- "eslint-plugin-simple-import-sort": "^12.1.1",
76
- "husky": "^8.0.3",
77
- "lint-staged": "^15.0.2",
78
- "prettier": "^3.6.2",
79
- "prettier-plugin-packagejson": "^2.5.19",
80
- "react": "^19.1.1",
81
- "react-dom": "^19.1.1",
82
- "sanity": "^4.4.1",
83
- "semantic-release": "^23.1.1",
42
+ "@sanity/pkg-utils": "^10.2.1",
43
+ "@types/react": "^19.2.7",
44
+ "@typescript/native-preview": "7.0.0-dev.20251212.1",
45
+ "babel-plugin-react-compiler": "^1.0.0",
46
+ "babel-plugin-styled-components": "^2.1.4",
47
+ "eslint": "^9.39.1",
48
+ "react": "^19.2.3",
49
+ "sanity": "^4.21.1",
84
50
  "styled-components": "^6.1.19",
85
- "typescript": "5.8.3"
51
+ "typescript": "5.9.3",
52
+ "@repo/eslint-config": "0.0.7",
53
+ "@repo/package.config": "0.0.0",
54
+ "@repo/tsconfig": "1.0.0"
86
55
  },
87
56
  "peerDependencies": {
88
57
  "react": "^18.3 || ^19",
89
- "react-dom": "^18.3 || ^19",
90
- "sanity": "^4",
58
+ "sanity": "^4.0.0-0 || ^5.0.0-0",
91
59
  "styled-components": "^6.1"
92
60
  },
93
61
  "engines": {
94
62
  "node": ">=20.19 <22 || >=22.12"
95
63
  },
96
- "publishConfig": {
97
- "access": "public"
98
- },
99
- "sanityExchangeUrl": "https://www.sanity.io/plugins/sanity-plugin-asset-source-unsplash",
100
- "sanityPlugin": {
101
- "verifyPackage": {
102
- "nodeEngine": false,
103
- "sanityV2Json": false
104
- }
64
+ "scripts": {
65
+ "build": "pkg build --strict --check --clean",
66
+ "lint": "eslint ."
105
67
  }
106
- }
68
+ }