sanity-plugin-asset-source-unsplash 1.0.7 → 1.1.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/lib/{index.esm.js → index.cjs} +144 -108
- package/lib/index.cjs.js +5 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.js +127 -121
- package/lib/index.js.map +1 -1
- package/package.json +37 -44
- package/src/components/Photo.tsx +4 -3
- package/src/components/UnsplashAssetSource.tsx +8 -6
- package/src/datastores/unsplash.ts +14 -13
- package/src/index.ts +4 -3
- package/lib/index.esm.js.map +0 -1
|
@@ -1,25 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var sanity = require('sanity');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var ui = require('@sanity/ui');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var InfiniteScroll = require('react-infinite-scroll-component');
|
|
11
|
+
var PhotoAlbum = require('react-photo-album');
|
|
12
|
+
var rxjs = require('rxjs');
|
|
13
|
+
var operators = require('rxjs/operators');
|
|
14
|
+
var styled = require('styled-components');
|
|
15
|
+
function _interopDefaultCompat(e) {
|
|
16
|
+
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
17
|
+
default: e
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
21
|
+
var InfiniteScroll__default = /*#__PURE__*/_interopDefaultCompat(InfiniteScroll);
|
|
22
|
+
var PhotoAlbum__default = /*#__PURE__*/_interopDefaultCompat(PhotoAlbum);
|
|
23
|
+
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
24
|
+
function UnsplashIcon() {
|
|
25
|
+
return /* @__PURE__ */jsxRuntime.jsxs("svg", {
|
|
26
|
+
role: "img",
|
|
27
|
+
viewBox: "0 0 25 25",
|
|
28
|
+
width: "1em",
|
|
29
|
+
height: "1em",
|
|
30
|
+
fill: "currentColor",
|
|
31
|
+
children: [/* @__PURE__ */jsxRuntime.jsx("title", {}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
32
|
+
d: "M9 9V4h7v5H9Zm7 3h5v9H4v-9h5v5h7v-5Z"
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const fetchSearch = (client, query, page, perPage) => rxjs.defer(() => client.observable.request({
|
|
37
|
+
url: "/addons/unsplash/search/photos?query=".concat(encodeURIComponent(query), "&page=").concat(page, "&per_page=").concat(perPage),
|
|
38
|
+
withCredentials: true,
|
|
39
|
+
method: "GET"
|
|
40
|
+
}));
|
|
41
|
+
const fetchList = (client, type, page, perPage) => rxjs.defer(() => client.observable.request({
|
|
42
|
+
url: "/addons/unsplash/photos?order_by=".concat(type, "&page=").concat(page, "&per_page=").concat(perPage),
|
|
43
|
+
withCredentials: true,
|
|
44
|
+
method: "GET"
|
|
45
|
+
}));
|
|
46
|
+
function fetchDownloadUrl(client, photo) {
|
|
47
|
+
const downloadUrl = photo.links.download_location.replace("https://api.unsplash.com", "/addons/unsplash");
|
|
48
|
+
return client.request({
|
|
49
|
+
url: downloadUrl,
|
|
50
|
+
withCredentials: true,
|
|
51
|
+
method: "GET"
|
|
52
|
+
}).then(result => {
|
|
53
|
+
return result.url;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const search = (client, query, page, resultsPerPage) => {
|
|
57
|
+
return rxjs.concat(query.pipe(operators.withLatestFrom(page), operators.debounceTime(500), operators.distinctUntilChanged(), operators.switchMap(_ref => {
|
|
58
|
+
let [q, p] = _ref;
|
|
59
|
+
if (q) {
|
|
60
|
+
return fetchSearch(client, q, p, resultsPerPage).pipe(operators.distinctUntilChanged(), operators.map(result => result.results));
|
|
61
|
+
}
|
|
62
|
+
return fetchList(client, "popular", p, resultsPerPage);
|
|
63
|
+
})));
|
|
64
|
+
};
|
|
65
|
+
var __freeze$1 = Object.freeze;
|
|
66
|
+
var __defProp$2 = Object.defineProperty;
|
|
67
|
+
var __template$1 = (cooked, raw) => __freeze$1(__defProp$2(cooked, "raw", {
|
|
68
|
+
value: __freeze$1(raw || cooked.slice())
|
|
69
|
+
}));
|
|
70
|
+
var _a$1, _b$1, _c;
|
|
71
|
+
const Root = styled__default.default.div(_a$1 || (_a$1 = __template$1(["\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: ", ";\n box-sizing: content-box;\n 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"])), _ref2 => {
|
|
13
72
|
let {
|
|
14
73
|
studioTheme
|
|
15
|
-
} =
|
|
74
|
+
} = _ref2;
|
|
16
75
|
return "1px solid ".concat(studioTheme.color.card.enabled.border);
|
|
17
76
|
});
|
|
18
|
-
const CreditLineLink =
|
|
19
|
-
const CreditLine =
|
|
77
|
+
const CreditLineLink = styled__default.default.a(_b$1 || (_b$1 = __template$1(["\n text-decoration: none;\n cursor: pointer;\n"])));
|
|
78
|
+
const CreditLine = styled__default.default(ui.Card)(_c || (_c = __template$1(["\n ", ";\n 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"])), _ref3 => {
|
|
20
79
|
let {
|
|
21
80
|
theme
|
|
22
|
-
} =
|
|
81
|
+
} = _ref3;
|
|
23
82
|
return "\n --creditline-fg: ".concat(theme.sanity.color.card.enabled.fg, ";\n --creditline-bg: ").concat(theme.sanity.color.card.enabled.bg, ";\n ");
|
|
24
83
|
});
|
|
25
84
|
const UTM_SOURCE = "sanity-plugin-asset-source-unsplash";
|
|
@@ -33,32 +92,32 @@ function Photo(props) {
|
|
|
33
92
|
width,
|
|
34
93
|
height
|
|
35
94
|
} = props;
|
|
36
|
-
const handleClick = useCallback(() => {
|
|
95
|
+
const handleClick = React.useCallback(() => {
|
|
37
96
|
onClick(data);
|
|
38
97
|
}, [onClick, data]);
|
|
39
|
-
const handleCreditLineClicked = useCallback(event => {
|
|
98
|
+
const handleCreditLineClicked = React.useCallback(event => {
|
|
40
99
|
event.stopPropagation();
|
|
41
100
|
const url = "".concat(data.links.html, "?utm_source=").concat(encodeURIComponent(UTM_SOURCE), "&utm_medium=referral");
|
|
42
101
|
window.open(url, data.id, "noreferrer,noopener");
|
|
43
102
|
}, [data]);
|
|
44
|
-
const handleKeyDown = useCallback(event => {
|
|
103
|
+
const handleKeyDown = React.useCallback(event => {
|
|
45
104
|
onKeyDown(event);
|
|
46
105
|
if (event.keyCode === 13) {
|
|
47
106
|
onClick(data);
|
|
48
107
|
}
|
|
49
108
|
}, [onKeyDown, data, onClick]);
|
|
50
|
-
const handleMouseDown = useCallback(() => {
|
|
109
|
+
const handleMouseDown = React.useCallback(() => {
|
|
51
110
|
onFocus(data);
|
|
52
111
|
}, [onFocus, data]);
|
|
53
|
-
useEffect(() => {
|
|
112
|
+
React.useEffect(() => {
|
|
54
113
|
if (active) {
|
|
55
114
|
onFocus(data);
|
|
56
115
|
}
|
|
57
116
|
}, [active, data, onFocus]);
|
|
58
117
|
const src = data.urls.small;
|
|
59
118
|
const userName = data.user.name;
|
|
60
|
-
const theme = useTheme().sanity;
|
|
61
|
-
return /* @__PURE__ */jsx(Root, {
|
|
119
|
+
const theme = ui.useTheme().sanity;
|
|
120
|
+
return /* @__PURE__ */jsxRuntime.jsx(Root, {
|
|
62
121
|
studioTheme: theme,
|
|
63
122
|
title: "Select image by ".concat(userName, " from Unsplash"),
|
|
64
123
|
tabIndex: 0,
|
|
@@ -67,16 +126,16 @@ function Photo(props) {
|
|
|
67
126
|
style: {
|
|
68
127
|
width: "".concat(width, "px"),
|
|
69
128
|
height: "".concat(height, "px"),
|
|
70
|
-
backgroundImage:
|
|
129
|
+
backgroundImage: 'url("'.concat(src, '")')
|
|
71
130
|
},
|
|
72
131
|
onClick: handleClick,
|
|
73
|
-
children: /* @__PURE__ */jsx(CreditLineLink, {
|
|
132
|
+
children: /* @__PURE__ */jsxRuntime.jsx(CreditLineLink, {
|
|
74
133
|
onClick: handleCreditLineClicked,
|
|
75
|
-
children: /* @__PURE__ */jsx(CreditLine, {
|
|
134
|
+
children: /* @__PURE__ */jsxRuntime.jsx(CreditLine, {
|
|
76
135
|
padding: 2,
|
|
77
136
|
radius: 2,
|
|
78
137
|
margin: 2,
|
|
79
|
-
children: /* @__PURE__ */jsxs(Text, {
|
|
138
|
+
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
80
139
|
size: 1,
|
|
81
140
|
title: "Open image by ".concat(userName, " on Unsplash in new window"),
|
|
82
141
|
children: ["By @", data.user.username]
|
|
@@ -85,63 +144,51 @@ function Photo(props) {
|
|
|
85
144
|
})
|
|
86
145
|
});
|
|
87
146
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}));
|
|
93
|
-
const fetchList = (client, type, page, perPage) => defer(() => client.observable.request({
|
|
94
|
-
url: "/addons/unsplash/photos?order_by=".concat(type, "&page=").concat(page, "&per_page=").concat(perPage),
|
|
95
|
-
withCredentials: true,
|
|
96
|
-
method: "GET"
|
|
147
|
+
var __freeze = Object.freeze;
|
|
148
|
+
var __defProp$1 = Object.defineProperty;
|
|
149
|
+
var __template = (cooked, raw) => __freeze(__defProp$1(cooked, "raw", {
|
|
150
|
+
value: __freeze(raw || cooked.slice())
|
|
97
151
|
}));
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (q) {
|
|
112
|
-
return fetchSearch(client, q, p, resultsPerPage).pipe(distinctUntilChanged(), map(result => result.results));
|
|
113
|
-
}
|
|
114
|
-
return fetchList(client, "popular", p, resultsPerPage);
|
|
115
|
-
})));
|
|
152
|
+
var _a, _b;
|
|
153
|
+
const Search = styled__default.default(ui.Stack)(_a || (_a = __template(["\n position: sticky;\n top: 0;\n z-index: 1;\n"])));
|
|
154
|
+
styled__default.default.div(_b || (_b = __template(["\n overflow-y: auto;\n max-height: 80vh;\n"])));
|
|
155
|
+
var __defProp = Object.defineProperty;
|
|
156
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
configurable: true,
|
|
159
|
+
writable: true,
|
|
160
|
+
value
|
|
161
|
+
}) : obj[key] = value;
|
|
162
|
+
var __publicField = (obj, key, value) => {
|
|
163
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
164
|
+
return value;
|
|
116
165
|
};
|
|
117
|
-
const Search = styled(Stack)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: sticky;\n top: 0;\n z-index: 1;\n"])));
|
|
118
|
-
styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n overflow-y: auto;\n max-height: 80vh;\n"])));
|
|
119
166
|
const RESULTS_PER_PAGE = 42;
|
|
120
167
|
const PHOTO_SPACING = 2;
|
|
121
168
|
const PHOTO_PADDING = 1;
|
|
122
169
|
function UnsplashAssetSource(props) {
|
|
123
|
-
const client = useClient({
|
|
170
|
+
const client = sanity.useClient({
|
|
124
171
|
apiVersion: "2022-09-01"
|
|
125
172
|
});
|
|
126
|
-
return /* @__PURE__ */jsx(UnsplashAssetSourceInternal, {
|
|
173
|
+
return /* @__PURE__ */jsxRuntime.jsx(UnsplashAssetSourceInternal, {
|
|
127
174
|
...props,
|
|
128
175
|
client
|
|
129
176
|
});
|
|
130
177
|
}
|
|
131
|
-
class UnsplashAssetSourceInternal extends
|
|
178
|
+
class UnsplashAssetSourceInternal extends React__default.default.Component {
|
|
132
179
|
constructor() {
|
|
133
180
|
super(...arguments);
|
|
134
|
-
this
|
|
181
|
+
__publicField(this, "state", {
|
|
135
182
|
cursor: 0,
|
|
136
183
|
query: "",
|
|
137
184
|
page: 1,
|
|
138
185
|
searchResults: [[]],
|
|
139
186
|
isLoading: true
|
|
140
|
-
};
|
|
141
|
-
this
|
|
142
|
-
this
|
|
143
|
-
this
|
|
144
|
-
this
|
|
187
|
+
});
|
|
188
|
+
__publicField(this, "searchSubscription", null);
|
|
189
|
+
__publicField(this, "searchSubject$", new rxjs.BehaviorSubject(""));
|
|
190
|
+
__publicField(this, "pageSubject$", new rxjs.BehaviorSubject(1));
|
|
191
|
+
__publicField(this, "handleSelect", photo => {
|
|
145
192
|
this.setState({
|
|
146
193
|
isLoading: true
|
|
147
194
|
});
|
|
@@ -163,11 +210,11 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
163
210
|
};
|
|
164
211
|
this.props.onSelect([asset]);
|
|
165
212
|
});
|
|
166
|
-
};
|
|
167
|
-
this
|
|
213
|
+
});
|
|
214
|
+
__publicField(this, "handleClose", () => {
|
|
168
215
|
this.props.onClose();
|
|
169
|
-
};
|
|
170
|
-
this
|
|
216
|
+
});
|
|
217
|
+
__publicField(this, "handleSearchTermChanged", event => {
|
|
171
218
|
const query = event.currentTarget.value;
|
|
172
219
|
this.setState({
|
|
173
220
|
query,
|
|
@@ -178,8 +225,8 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
178
225
|
});
|
|
179
226
|
this.pageSubject$.next(1);
|
|
180
227
|
this.searchSubject$.next(query);
|
|
181
|
-
};
|
|
182
|
-
this
|
|
228
|
+
});
|
|
229
|
+
__publicField(this, "handleScollerLoadMore", () => {
|
|
183
230
|
const nextPage = this.state.page + 1;
|
|
184
231
|
this.setState({
|
|
185
232
|
page: nextPage,
|
|
@@ -187,8 +234,8 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
187
234
|
});
|
|
188
235
|
this.pageSubject$.next(nextPage);
|
|
189
236
|
this.searchSubject$.next(this.state.query);
|
|
190
|
-
};
|
|
191
|
-
this
|
|
237
|
+
});
|
|
238
|
+
__publicField(this, "handleKeyDown", event => {
|
|
192
239
|
const {
|
|
193
240
|
cursor
|
|
194
241
|
} = this.state;
|
|
@@ -201,20 +248,20 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
201
248
|
cursor: prevState.cursor + 1
|
|
202
249
|
}));
|
|
203
250
|
}
|
|
204
|
-
};
|
|
205
|
-
this
|
|
251
|
+
});
|
|
252
|
+
__publicField(this, "updateCursor", photo => {
|
|
206
253
|
const index = this.getPhotos().findIndex(result => result.id === photo.id);
|
|
207
254
|
this.setState({
|
|
208
255
|
cursor: index
|
|
209
256
|
});
|
|
210
|
-
};
|
|
211
|
-
this
|
|
257
|
+
});
|
|
258
|
+
__publicField(this, "renderImage", props => {
|
|
212
259
|
const {
|
|
213
260
|
photo,
|
|
214
261
|
layout
|
|
215
262
|
} = props;
|
|
216
263
|
const active = this.getPhotos().findIndex(result => result.id === photo.data.id) === this.state.cursor || false;
|
|
217
|
-
return /* @__PURE__ */jsx(Photo, {
|
|
264
|
+
return /* @__PURE__ */jsxRuntime.jsx(Photo, {
|
|
218
265
|
onClick: this.handleSelect.bind(photo.data),
|
|
219
266
|
onKeyDown: this.handleKeyDown,
|
|
220
267
|
data: photo.data,
|
|
@@ -223,7 +270,7 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
223
270
|
active,
|
|
224
271
|
onFocus: this.updateCursor
|
|
225
272
|
});
|
|
226
|
-
};
|
|
273
|
+
});
|
|
227
274
|
}
|
|
228
275
|
componentDidMount() {
|
|
229
276
|
this.searchSubscription = search(this.props.client, this.searchSubject$, this.pageSubject$, RESULTS_PER_PAGE).subscribe({
|
|
@@ -249,53 +296,53 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
249
296
|
searchResults,
|
|
250
297
|
isLoading
|
|
251
298
|
} = this.state;
|
|
252
|
-
return /* @__PURE__ */jsx(Dialog, {
|
|
299
|
+
return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
253
300
|
id: "unsplash-asset-source",
|
|
254
301
|
header: "Select image from Unsplash",
|
|
255
302
|
onClose: this.handleClose,
|
|
256
303
|
open: true,
|
|
257
304
|
width: 4,
|
|
258
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
305
|
+
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
259
306
|
space: 3,
|
|
260
307
|
padding: 4,
|
|
261
|
-
children: [/* @__PURE__ */jsx(Card, {
|
|
262
|
-
children: /* @__PURE__ */jsxs(Search, {
|
|
308
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
309
|
+
children: /* @__PURE__ */jsxRuntime.jsxs(Search, {
|
|
263
310
|
space: 3,
|
|
264
|
-
children: [/* @__PURE__ */jsx(Text, {
|
|
311
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
265
312
|
size: 1,
|
|
266
313
|
weight: "semibold",
|
|
267
314
|
children: "Search Unsplash"
|
|
268
|
-
}), /* @__PURE__ */jsx(TextInput, {
|
|
315
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ui.TextInput, {
|
|
269
316
|
label: "Search Unsplash.com",
|
|
270
317
|
placeholder: "Topics or colors",
|
|
271
318
|
value: query,
|
|
272
319
|
onChange: this.handleSearchTermChanged
|
|
273
320
|
})]
|
|
274
321
|
})
|
|
275
|
-
}), !isLoading && this.getPhotos().length === 0 && /* @__PURE__ */jsx(Text, {
|
|
322
|
+
}), !isLoading && this.getPhotos().length === 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
276
323
|
size: 1,
|
|
277
324
|
muted: true,
|
|
278
325
|
children: "No results found"
|
|
279
|
-
}), /* @__PURE__ */jsx(
|
|
326
|
+
}), /* @__PURE__ */jsxRuntime.jsx(InfiniteScroll__default.default, {
|
|
280
327
|
dataLength: this.getPhotos().length,
|
|
281
328
|
next: this.handleScollerLoadMore,
|
|
282
329
|
hasMore: true,
|
|
283
330
|
scrollThreshold: 0.99,
|
|
284
331
|
height: "60vh",
|
|
285
|
-
loader: /* @__PURE__ */jsx(Flex, {
|
|
332
|
+
loader: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
286
333
|
align: "center",
|
|
287
334
|
justify: "center",
|
|
288
335
|
padding: 3,
|
|
289
|
-
children: /* @__PURE__ */jsx(Spinner, {
|
|
336
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {
|
|
290
337
|
muted: true
|
|
291
338
|
})
|
|
292
339
|
}),
|
|
293
|
-
endMessage: /* @__PURE__ */jsx(Text, {
|
|
340
|
+
endMessage: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
294
341
|
size: 1,
|
|
295
342
|
muted: true,
|
|
296
343
|
children: "No more results"
|
|
297
344
|
}),
|
|
298
|
-
children: searchResults.filter(photos => photos.length > 0).map((photos, index) => /* @__PURE__ */jsx(
|
|
345
|
+
children: searchResults.filter(photos => photos.length > 0).map((photos, index) => /* @__PURE__ */jsxRuntime.jsx(PhotoAlbum__default.default, {
|
|
299
346
|
layout: "rows",
|
|
300
347
|
spacing: PHOTO_SPACING,
|
|
301
348
|
padding: PHOTO_PADDING,
|
|
@@ -324,28 +371,16 @@ class UnsplashAssetSourceInternal extends React.Component {
|
|
|
324
371
|
});
|
|
325
372
|
}
|
|
326
373
|
}
|
|
327
|
-
UnsplashAssetSourceInternal
|
|
374
|
+
__publicField(UnsplashAssetSourceInternal, "defaultProps", {
|
|
328
375
|
selectedAssets: void 0
|
|
329
|
-
};
|
|
330
|
-
function UnsplashIcon() {
|
|
331
|
-
return /* @__PURE__ */jsxs("svg", {
|
|
332
|
-
role: "img",
|
|
333
|
-
viewBox: "0 0 25 25",
|
|
334
|
-
width: "1em",
|
|
335
|
-
height: "1em",
|
|
336
|
-
fill: "currentColor",
|
|
337
|
-
children: [/* @__PURE__ */jsx("title", {}), /* @__PURE__ */jsx("path", {
|
|
338
|
-
d: "M9 9V4h7v5H9Zm7 3h5v9H4v-9h5v5h7v-5Z"
|
|
339
|
-
})]
|
|
340
|
-
});
|
|
341
|
-
}
|
|
376
|
+
});
|
|
342
377
|
const unsplashAssetSource = {
|
|
343
378
|
name: "unsplash",
|
|
344
379
|
title: "Unsplash",
|
|
345
380
|
component: UnsplashAssetSource,
|
|
346
381
|
icon: UnsplashIcon
|
|
347
382
|
};
|
|
348
|
-
const unsplashImageAsset = definePlugin({
|
|
383
|
+
const unsplashImageAsset = sanity.definePlugin({
|
|
349
384
|
name: "asset-source-unsplash-plugin",
|
|
350
385
|
form: {
|
|
351
386
|
image: {
|
|
@@ -355,5 +390,6 @@ const unsplashImageAsset = definePlugin({
|
|
|
355
390
|
}
|
|
356
391
|
}
|
|
357
392
|
});
|
|
358
|
-
|
|
359
|
-
|
|
393
|
+
exports.unsplashAssetSource = unsplashAssetSource;
|
|
394
|
+
exports.unsplashImageAsset = unsplashImageAsset;
|
|
395
|
+
//# sourceMappingURL=index.cjs.map
|
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","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":["import React from 'react'\n\nexport default function UnsplashIcon() {\n return (\n <svg role=\"img\" viewBox=\"0 0 25 25\" width=\"1em\" height=\"1em\" fill=\"currentColor\">\n <title />\n <path d=\"M9 9V4h7v5H9Zm7 3h5v9H4v-9h5v5h7v-5Z\" />\n </svg>\n )\n}\n","import { SanityClient } from '@sanity/client'\nimport { BehaviorSubject, concat, defer, Observable } from 'rxjs'\nimport { debounceTime, distinctUntilChanged, map, switchMap, withLatestFrom } from 'rxjs/operators'\n\nimport { 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<any> =>\n defer(\n () =>\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 }) as any,\n )\n\nconst fetchList = (\n client: SanityClient,\n type: string,\n page: number,\n perPage: number,\n): Observable<any> =>\n defer(\n () =>\n client.observable.request({\n url: `/addons/unsplash/photos?order_by=${type}&page=${page}&per_page=${perPage}`,\n withCredentials: true,\n method: 'GET',\n }) as any,\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<any> => {\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, Theme } from '@sanity/ui'\nimport styled from 'styled-components'\n\ntype SanityTheme = Theme['sanity']\n\ninterface Style {\n studioTheme: SanityTheme\n}\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: ${({ studioTheme }: Style) => `1px solid ${studioTheme.color.card.enabled.border}`};\n box-sizing: content-box;\n 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 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, useTheme } from '@sanity/ui'\nimport React, { useCallback, useEffect } from 'react'\n\nimport { UnsplashPhoto } from '../types'\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: any) => 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: any) => {\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: any) => {\n onKeyDown(event)\n if (event.keyCode === 13) {\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 const theme = useTheme().sanity\n return (\n <Root\n studioTheme={theme}\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 { Stack } from '@sanity/ui'\nimport styled from 'styled-components'\n\nexport const Search = styled(Stack)`\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 { SanityClient } from '@sanity/client'\nimport { Card, Dialog, Flex, Spinner, Stack, Text, TextInput } from '@sanity/ui'\nimport React from 'react'\nimport InfiniteScroll from 'react-infinite-scroll-component'\nimport PhotoAlbum from 'react-photo-album'\nimport { BehaviorSubject, Subscription } from 'rxjs'\nimport { AssetFromSource, AssetSourceComponentProps, useClient } from 'sanity'\n\nimport { fetchDownloadUrl, search } from '../datastores/unsplash'\nimport { UnsplashPhoto } from '../types'\nimport Photo from './Photo'\nimport { Search } from './UnsplashAssetSource.styled'\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 React.Component<\n AssetSourceComponentProps & { client: SanityClient },\n State\n> {\n static defaultProps = {\n selectedAssets: undefined,\n }\n\n 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 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 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 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 } as any,\n }\n this.props.onSelect([asset])\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({ query, page: 1, searchResults: [[]], isLoading: true, cursor: 0 })\n this.pageSubject$.next(1)\n this.searchSubject$.next(query)\n }\n\n handleScollerLoadMore = () => {\n // eslint-disable-next-line react/no-access-state-in-setstate\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: any) => {\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: any) => {\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.bind(photo.data)}\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 render() {\n const { query, searchResults, isLoading } = this.state\n\n return (\n <Dialog\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} padding={4}>\n <Card>\n <Search space={3}>\n <Text size={1} weight=\"semibold\">\n Search Unsplash\n </Text>\n <TextInput\n label=\"Search Unsplash.com\"\n placeholder=\"Topics or colors\"\n value={query}\n onChange={this.handleSearchTermChanged}\n />\n </Search>\n </Card>\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.handleScollerLoadMore}\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 // eslint-disable-next-line react/no-array-index-key\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 else 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: { style: { marginBottom: `${PHOTO_SPACING}px` } },\n }}\n />\n ))}\n </InfiniteScroll>\n </Stack>\n </Dialog>\n )\n }\n}\n","import { AssetSource, definePlugin } from 'sanity'\n\nimport Icon 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: Icon,\n}\n\n/**\n * @public\n */\nexport const unsplashImageAsset = definePlugin({\n name: 'asset-source-unsplash-plugin',\n\n form: {\n image: {\n assetSources: (prev) => {\n return [...prev, unsplashAssetSource]\n },\n },\n },\n})\n"],"names":["UnsplashIcon","jsxs","role","viewBox","width","height","fill","children","jsx","d","fetchSearch","client","query","page","perPage","defer","observable","request","url","concat","encodeURIComponent","withCredentials","method","fetchList","type","fetchDownloadUrl","photo","downloadUrl","links","download_location","replace","then","result","search","resultsPerPage","pipe","withLatestFrom","debounceTime","distinctUntilChanged","switchMap","_ref","q","p","map","results","_a","_b","_c","Root","styled","div","__template","_ref2","studioTheme","color","card","enabled","border","CreditLineLink","a","CreditLine","default","Card","_ref3","theme","sanity","fg","bg","UTM_SOURCE","Photo","props","onClick","data","onKeyDown","onFocus","active","handleClick","useCallback","handleCreditLineClicked","event","stopPropagation","html","window","open","id","handleKeyDown","keyCode","handleMouseDown","useEffect","src","urls","small","userName","user","name","useTheme","title","tabIndex","onMouseDown","style","backgroundImage","padding","radius","margin","Text","size","username","Search","Stack","RESULTS_PER_PAGE","PHOTO_SPACING","PHOTO_PADDING","UnsplashAssetSource","useClient","apiVersion","UnsplashAssetSourceInternal","React","Component","constructor","arguments","__publicField","cursor","searchResults","isLoading","BehaviorSubject","setState","description","asset","kind","value","assetDocumentProps","_type","source","creditLine","onSelect","onClose","currentTarget","pageSubject$","next","searchSubject$","nextPage","state","prevState","getPhotos","length","index","findIndex","layout","handleSelect","bind","updateCursor","componentDidMount","searchSubscription","subscribe","prev","componentWillUnmount","unsubscribe","flat","render","Dialog","header","handleClose","space","weight","TextInput","label","placeholder","onChange","handleSearchTermChanged","muted","InfiniteScroll","dataLength","handleScollerLoadMore","hasMore","scrollThreshold","loader","Flex","align","justify","Spinner","endMessage","filter","photos","PhotoAlbum","spacing","targetRowHeight","key","renderPhoto","renderImage","componentsProps","containerProps","marginBottom","selectedAssets","unsplashAssetSource","component","Unsplash","icon","Icon","unsplashImageAsset","definePlugin","form","image","assetSources"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAwBA,YAAeA,CAAA,EAAA;EAEnC,OAAA,eAAAC,UAAA,CAAAA,IAAA,CAAC,KAAI,EAAA;IAAAC,IAAA,EAAK,KAAM;IAAAC,OAAA,EAAQ,WAAY;IAAAC,KAAA,EAAM,KAAM;IAAAC,MAAA,EAAO,KAAM;IAAAC,IAAA,EAAK,cAChE;IAAAC,QAAA,EAAA,CAAA,eAAAC,UAAA,CAAAA,GAAA,CAAC,OAAM,EAAA,EAAA,CAAA,EACPA,eAAAA,UAAAA,CAAAA,GAAA,CAAC,MAAK,EAAA;MAAAC,CAAA,EAAE;IAAuC,CAAA,CAAA;EACjD,CAAA,CAAA;AAEJ;ACAA,MAAMC,WAAc,GAAAA,CAClBC,MACA,EAAAC,KAAA,EACAC,MACAC,OAEA,KAAAC,IAAA,CAAAA,KAAA,CACE,MACEJ,MAAO,CAAAK,UAAA,CAAWC,OAAQ,CAAA;EACxBC,KAAK,uCAAwC,CAAAC,MAAA,CAAAC,kBAAA,CAC3CR,KAAA,CACF,EAAC,QAAS,CAAA,CAAAO,MAAA,CAAAN,IAAA,EAAI,YAAa,CAAA,CAAAM,MAAA,CAAAL,OAAA,CAAA;EAC3BO,eAAiB,EAAA,IAAA;EACjBC,MAAQ,EAAA;AAAA,C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