sanity-plugin-media 1.4.0-beta.2 → 1.4.3
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/CHANGELOG.md +26 -13
- package/README.md +10 -8
- package/dist/app.js +3 -3
- package/dist/app.js.map +1 -1
- package/dist/utils/constructFilter.js +3 -1
- package/dist/utils/constructFilter.js.map +1 -1
- package/dist/utils/generatePreviewBlobUrl.js +3 -1
- package/dist/utils/generatePreviewBlobUrl.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/ButtonAssetClipboardCopy/index.js +0 -71
- package/dist/components/ButtonC/index.js +0 -71
- package/dist/components/ButtonClipboardCopy/index.js +0 -71
- package/dist/components/Card/index.js +0 -185
- package/dist/components/Card/index.js.map +0 -1
- package/dist/components/CardUpload copy/index.js +0 -60
- package/dist/components/Cards/index.js +0 -94
- package/dist/components/Cards/index.js.map +0 -1
- package/dist/components/DialogDeleteConfirm/index.js +0 -62
- package/dist/components/DialogDeleteConfirm/index.js.map +0 -1
- package/dist/components/DialogDetails/index.js +0 -322
- package/dist/components/DialogDetails/index.js.map +0 -1
- package/dist/components/DialogSearchFacets copy/index.js +0 -45
- package/dist/components/DialogTagCreate copy/index.js +0 -38
- package/dist/components/Dropzone/index.js +0 -66
- package/dist/components/Dropzone/index.js.map +0 -1
- package/dist/components/DropzoneTest/index.js +0 -37
- package/dist/components/FormDetails/index.js +0 -241
- package/dist/components/GlobalStyles/index.js +0 -10
- package/dist/components/NoResults/index.js +0 -12
- package/dist/components/PanelHeader/index.js +0 -48
- package/dist/components/PanelHeader/index.js.map +0 -1
- package/dist/components/Portal/Portal.js +0 -50
- package/dist/components/Portal/index.js +0 -49
- package/dist/components/Portal/index.js.map +0 -1
- package/dist/components/SearchFacetSearchable/index.js +0 -61
- package/dist/components/SearchFacetSearchable/index.js.map +0 -1
- package/dist/components/Table/index.js +0 -86
- package/dist/components/Table/index.js.map +0 -1
- package/dist/components/TableRow/index.js +0 -221
- package/dist/components/TableRow/index.js.map +0 -1
- package/dist/components/TagPanel/index.js +0 -19
- package/dist/components/TagPanel/index.js.map +0 -1
- package/dist/components/Tags/index.js +0 -21
- package/dist/components/Tags/index.js.map +0 -1
- package/dist/components/TagsAll/index.js +0 -23
- package/dist/components/TagsAll/index.js.map +0 -1
- package/dist/components/TagsPicked/index.js +0 -81
- package/dist/components/TagsPicked/index.js.map +0 -1
- package/dist/components/TextEllipsis/index.js +0 -14
- package/dist/components/TextEllipsis/index.js.map +0 -1
- package/dist/components/UploadCard/index.js +0 -14
- package/dist/constants/searchFacets.js +0 -272
- package/dist/contexts/AssetSourceDispatchContext copy.js +0 -41
- package/dist/helpers/withRedux.js +0 -84
- package/dist/helpers/withRedux.js.map +0 -1
- package/dist/modules/assets/assetsSlice.js +0 -552
- package/dist/modules/assets/types.js +0 -2
- package/dist/modules/assets/types.js.map +0 -1
- package/dist/modules/debug/debugSlice.js +0 -23
- package/dist/modules/debug/types.js +0 -2
- package/dist/modules/debug/types.js.map +0 -1
- package/dist/modules/dialog/dialogSlice.js +0 -192
- package/dist/modules/dialog/types.js +0 -2
- package/dist/modules/dialog/types.js.map +0 -1
- package/dist/modules/document/documentSlice.js +0 -9
- package/dist/modules/document/index.js +0 -10
- package/dist/modules/document/index.js.map +0 -1
- package/dist/modules/document/types.js +0 -3
- package/dist/modules/document/types.js.map +0 -1
- package/dist/modules/document copy/index.js +0 -9
- package/dist/modules/documentAssets/index.js +0 -9
- package/dist/modules/notifications/notificationsSlice.js +0 -123
- package/dist/modules/notifications/types.js +0 -2
- package/dist/modules/notifications/types.js.map +0 -1
- package/dist/modules/search/searchSlice.js +0 -122
- package/dist/modules/search/types.js +0 -2
- package/dist/modules/search/types.js.map +0 -1
- package/dist/modules/selectedAssets/index.js +0 -10
- package/dist/modules/selectedAssets/index.js.map +0 -1
- package/dist/modules/selectedAssets/selectedAssetsSlice.js +0 -9
- package/dist/modules/selectedAssets/types.js +0 -2
- package/dist/modules/selectedAssets/types.js.map +0 -1
- package/dist/modules/selectedAssets copy/index.js +0 -9
- package/dist/modules/tags/selectedAssetsSlice.js +0 -9
- package/dist/modules/tags/tagsSlice.js +0 -442
- package/dist/modules/tags/tagsSlice.js.map +0 -1
- package/dist/modules/tags/types.js +0 -2
- package/dist/modules/tags/types.js.map +0 -1
- package/dist/operators/debugThrottle copy.js +0 -15
- package/dist/operators/fetchExistingTag.js +0 -27
- package/dist/utils/getDocumentAssetRefs.js +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -2,33 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### [1.4.3](https://github.com/robinpyon/sanity-plugin-media/compare/v1.4.2...v1.4.3) (2021-10-26)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
### Bug Fixes
|
|
9
9
|
|
|
10
|
-
*
|
|
10
|
+
* expose _id, assetId and url in default input search ([0f7d544](https://github.com/robinpyon/sanity-plugin-media/commit/0f7d544d7b688972e3d12f1fac1b6a2bc3b94a02))
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
### [1.4.2](https://github.com/robinpyon/sanity-plugin-media/compare/v1.4.1...v1.4.2) (2021-10-21)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* force minimum height on canvas when generating low res previews ([8e30854](https://github.com/robinpyon/sanity-plugin-media/commit/8e3085462cb2eeaa289b83e21dfa2e6ec7787831))
|
|
18
|
+
|
|
19
|
+
### [1.4.1](https://github.com/robinpyon/sanity-plugin-media/compare/v1.4.0...v1.4.1) (2021-10-14)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* quickfix to work around a minor regression in sanity 2.21.0 ([1abf9e8](https://github.com/robinpyon/sanity-plugin-media/commit/1abf9e8b3f5f24e3848d4193193fba187fa65ab2))
|
|
25
|
+
|
|
26
|
+
## [1.4.0](https://github.com/robinpyon/sanity-plugin-media/compare/v1.3.1...v1.4.0) (2021-09-22)
|
|
15
27
|
|
|
16
28
|
|
|
17
29
|
### Features
|
|
18
30
|
|
|
19
|
-
* add filename facet ([
|
|
20
|
-
* add initial file custom asset source support: conditionally filter and facet by asset type ([
|
|
21
|
-
* add overscan to asset grid view ([
|
|
22
|
-
* disable react-select until all tags have loaded in full ([
|
|
23
|
-
* virtualize react-select views ([
|
|
31
|
+
* add filename facet ([4f70fab](https://github.com/robinpyon/sanity-plugin-media/commit/4f70fabbf7a47c16e60ae3d7d861b1381a5c4a9f))
|
|
32
|
+
* add initial file custom asset source support: conditionally filter and facet by asset type ([7a2b988](https://github.com/robinpyon/sanity-plugin-media/commit/7a2b9883827ff5283fed842cb8635fa7d509483b))
|
|
33
|
+
* add overscan to asset grid view ([7b3aaba](https://github.com/robinpyon/sanity-plugin-media/commit/7b3aabafa75cdda41380c900d9b96c0b654054c9))
|
|
34
|
+
* disable react-select until all tags have loaded in full ([5948a94](https://github.com/robinpyon/sanity-plugin-media/commit/5948a947ee32c860edad0a47aa9b8d20ec7111e8))
|
|
35
|
+
* virtualize react-select views ([f712c4c](https://github.com/robinpyon/sanity-plugin-media/commit/f712c4ccec9901321bcaaef7dca237c07dbdc49c))
|
|
24
36
|
|
|
25
37
|
|
|
26
38
|
### Bug Fixes
|
|
27
39
|
|
|
28
|
-
* ensure that
|
|
29
|
-
*
|
|
30
|
-
* force
|
|
31
|
-
*
|
|
40
|
+
* ensure that generic tag deletion errors are caught and displayed in notifications ([b65e0e6](https://github.com/robinpyon/sanity-plugin-media/commit/b65e0e69cbce78fc0b49610ba87f5c0ec2707122))
|
|
41
|
+
* ensure that no empty virtuoso views are rendered ([04904e5](https://github.com/robinpyon/sanity-plugin-media/commit/04904e5ca408d424e28c2dca05d0b545d1b04b21))
|
|
42
|
+
* force fixed positioning on sanity-ui Dialogs to prevent mobile scrolling issues ([94465a5](https://github.com/robinpyon/sanity-plugin-media/commit/94465a5c89166501cd65d9d387f09d5c7d567b41))
|
|
43
|
+
* force search facet <MenuButton /> to render in a portal, remove hard-coded z-index ([4afb51e](https://github.com/robinpyon/sanity-plugin-media/commit/4afb51eed57926ca7279b351fd588f3ac86c70d6))
|
|
44
|
+
* **tags:** render all tags in a virtualized container ([abdc7e3](https://github.com/robinpyon/sanity-plugin-media/commit/abdc7e362d4ed5f62ff5bd632e9b886fdbd36771))
|
|
32
45
|
|
|
33
46
|
### [1.3.1](https://github.com/robinpyon/sanity-plugin-media/compare/v1.3.0...v1.3.1) (2021-05-09)
|
|
34
47
|
|
package/README.md
CHANGED
|
@@ -48,7 +48,9 @@ In your Sanity project folder:
|
|
|
48
48
|
sanity install media
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
This will add the Media
|
|
51
|
+
This will add the Media plugin as a standalone tool, accessible via your studio menu.
|
|
52
|
+
|
|
53
|
+
If you're happy with Sanity's default image and file pickers, then this is all you need to do!
|
|
52
54
|
|
|
53
55
|
### Enabling it as a global [custom asset source](https://www.sanity.io/docs/custom-asset-sources)
|
|
54
56
|
|
|
@@ -56,15 +58,15 @@ You'll need to do this if you want to use the plugin when selecting images or fi
|
|
|
56
58
|
|
|
57
59
|
This plugin exposes `part:sanity-plugin-media/asset-source` which you import when defining custom asset sources.
|
|
58
60
|
|
|
59
|
-
In `sanity.json`, add the following snippet to the `parts` array
|
|
61
|
+
In `sanity.json`, add the following snippet to the `parts` array.
|
|
62
|
+
|
|
63
|
+
_File asset support requires Sanity 2.16.x or greater._
|
|
60
64
|
|
|
61
65
|
```json
|
|
62
|
-
// Images
|
|
63
66
|
{
|
|
64
67
|
"implements": "part:@sanity/form-builder/input/image/asset-sources",
|
|
65
68
|
"path": "./parts/assetSources.js"
|
|
66
69
|
},
|
|
67
|
-
// Files (Sanity >= 2.16.0)
|
|
68
70
|
{
|
|
69
71
|
"implements": "part:@sanity/form-builder/input/file/asset-sources",
|
|
70
72
|
"path": "./parts/assetSources.js"
|
|
@@ -79,7 +81,7 @@ import MediaAssetSource from 'part:sanity-plugin-media/asset-source'
|
|
|
79
81
|
export default [MediaAssetSource]
|
|
80
82
|
```
|
|
81
83
|
|
|
82
|
-
That's it! The
|
|
84
|
+
That's it! The plugin will now pop up every time you try select an image or file.
|
|
83
85
|
|
|
84
86
|
## Known issues
|
|
85
87
|
|
|
@@ -197,7 +199,7 @@ Note that tags are namespaced within `opt.media` and tag names are accessed via
|
|
|
197
199
|
#### Deleting assets
|
|
198
200
|
|
|
199
201
|
<details>
|
|
200
|
-
<summary>
|
|
202
|
+
<summary>Why am I unable to delete multiple assets, even if only one asset is in use?</summary>
|
|
201
203
|
|
|
202
204
|
- Batch mutations are carried out via Sanity [transactions](https://www.sanity.io/docs/transactions). These transactions are _atomic_, meaning that if one deletion fails (often because it's referenced elsewhere), then all mutations in the transaction will fail and no changes will occur
|
|
203
205
|
- To get around this, simply make sure that all assets you've marked for deletion are not referenced – this can be easily accomplished by using a search facet to only show assets which are not in use
|
|
@@ -209,8 +211,8 @@ Note that tags are namespaced within `opt.media` and tag names are accessed via
|
|
|
209
211
|
<details>
|
|
210
212
|
<summary>How does the plugin determine what should uploaded as a <code>sanity.imageAsset</code> or <code>sanity.fileAsset</code>?</summary>
|
|
211
213
|
|
|
212
|
-
- As a rule of thumb, when uploading when accessing the plugin as a _tool_ (e.g. if you've acceessed it via the
|
|
213
|
-
- If you upload when using the plugin in a
|
|
214
|
+
- As a rule of thumb, when uploading when accessing the plugin as a _tool_ (e.g. if you've acceessed it via the studio menu), it will look at any incoming files' MIME type. All files of type `image/*` will be uploaded as `sanity.imageAsset` whilst everything else will be treated as `sanity.fileAsset`
|
|
215
|
+
- If you upload when using the plugin in a _file_ selection context, these be uploaded as `sanity.fileAsset` regardless of their MIME type. This is probably not what you want, since images uploaded as files won't have associated metadata nor will they work in Sanity's image pipeline.
|
|
214
216
|
|
|
215
217
|
</details>
|
|
216
218
|
|
package/dist/app.js
CHANGED
|
@@ -44,7 +44,7 @@ var useKeyPress_1 = __importDefault(require("./hooks/useKeyPress"));
|
|
|
44
44
|
var GlobalStyles_1 = __importDefault(require("./styled/GlobalStyles"));
|
|
45
45
|
var theme_1 = __importDefault(require("./styled/theme"));
|
|
46
46
|
var AssetBrowser = react_1.forwardRef(function (props, ref) {
|
|
47
|
-
var onClose = props.onClose, onSelect = props.onSelect
|
|
47
|
+
var onClose = props.onClose, onSelect = props.onSelect;
|
|
48
48
|
// Close on escape key press
|
|
49
49
|
useKeyPress_1.default('escape', onClose);
|
|
50
50
|
// Stop propagation and prevent document mouse events from firing.
|
|
@@ -61,8 +61,8 @@ var AssetBrowser = react_1.forwardRef(function (props, ref) {
|
|
|
61
61
|
react_1.default.createElement(ui_1.ToastProvider, { zOffset: constants_1.Z_INDEX_TOAST_PROVIDER },
|
|
62
62
|
react_1.default.createElement(AssetSourceDispatchContext_1.AssetBrowserDispatchProvider, { onSelect: onSelect },
|
|
63
63
|
react_1.default.createElement(GlobalStyles_1.default, null),
|
|
64
|
-
|
|
65
|
-
react_1.default.createElement(Browser_1.default,
|
|
64
|
+
!onClose ? (react_1.default.createElement(ui_1.Box, { ref: ref, style: { background: 'red', height: '100%', position: 'relative' } },
|
|
65
|
+
react_1.default.createElement(Browser_1.default, null))) : (react_1.default.createElement(ui_1.Portal, null,
|
|
66
66
|
react_1.default.createElement(ui_1.Box, { onDragEnter: handleStopPropagation, onDragLeave: handleStopPropagation, onDragOver: handleStopPropagation, onDrop: handleStopPropagation, onMouseUp: handleStopPropagation, ref: ref, style: {
|
|
67
67
|
bottom: 0,
|
|
68
68
|
height: 'auto',
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAiG;AAEjG,6CAA4D;AAC5D,qCAA6D;AAC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,8BAAC,QAAG,IAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAC;gCAC7E,8BAAC,iBAAO,OAAG,CACP,CACP,CAAC,CAAC,CAAC,CACF,8BAAC,WAAM;gCACL,8BAAC,QAAG,IACF,WAAW,EAAE,qBAAqB,EAClC,WAAW,EAAE,qBAAqB,EAClC,UAAU,EAAE,qBAAqB,EACjC,MAAM,EAAE,qBAAqB,EAC7B,SAAS,EAAE,qBAAqB,EAChC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE;wCACL,MAAM,EAAE,CAAC;wCACT,MAAM,EAAE,MAAM;wCACd,IAAI,EAAE,CAAC;wCACP,QAAQ,EAAE,OAAO;wCACjB,GAAG,EAAE,CAAC;wCACN,KAAK,EAAE,MAAM;wCACb,MAAM,EAAE,uBAAW;qCACpB;oCAED,8BAAC,iBAAO,IAAC,OAAO,EAAE,OAAO,GAAI,CACzB,CACC,CACV,CAC4B,CACjB,CACD,CACG,CACR,CACF,CACjB,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,kBAAe,YAAY,CAAA"}
|
|
@@ -83,7 +83,9 @@ var constructFilter = function (_a) {
|
|
|
83
83
|
// Base filter
|
|
84
84
|
baseFilter
|
|
85
85
|
], (searchQuery
|
|
86
|
-
? [
|
|
86
|
+
? [
|
|
87
|
+
groq_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["[_id, altText, assetId, description, originalFilename, title, url] match '*", "*'"], ["[_id, altText, assetId, description, originalFilename, title, url] match '*", "*'"])), searchQuery.trim())
|
|
88
|
+
]
|
|
87
89
|
: []), searchFacetFragments).join(' && ');
|
|
88
90
|
return constructedQuery;
|
|
89
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructFilter.js","sourceRoot":"","sources":["../../src/utils/constructFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;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I,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,OAAK,EAAhB,CAAgB,2CAAG,KAAK,CAAA;YAEtE,IAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;YACvD,IAAI,QAAQ,EAAE;gBACZ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aACnB;SACF;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YACpB,IAAA,KAAK,GAAyB,KAAK,MAA9B,EAAE,YAAY,GAAW,KAAK,aAAhB,EAAE,KAAK,GAAI,KAAK,MAAT,CAAS;YAC1C,IAAM,QAAQ,GAAG,wBAAS,CAAC,YAAY,CAAC,CAAA;YAExC,IAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;YAC1C,IAAI,QAAQ,EAAE;gBACZ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aACnB;SACF;QAED,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,iCAAiC;IACjC,IAAM,gBAAgB,GAAG;QACvB,cAAc;QACd,UAAU;OAKP,CAAC,WAAW;QACb,CAAC,CAAC;YACE,cAAI,sJAAA,6EAA8E,EAAkB,IAAI,KAAtB,WAAW,CAAC,IAAI,EAAE;SACrG;QACH,CAAC,CAAC,EAAE,CAAC,EAEJ,oBAAoB,EACvB,IAAI,CAAC,MAAM,CAAC,CAAA;IAEd,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AAED,kBAAe,eAAe,CAAA"}
|
|
@@ -43,9 +43,11 @@ var PREVIEW_WIDTH = 180; // px
|
|
|
43
43
|
var createBlob = function (img) {
|
|
44
44
|
return new Promise(function (resolve) {
|
|
45
45
|
var imageAspect = img.width / img.height;
|
|
46
|
+
// Create a canvas element which we'll use to generate a low resolution preview.
|
|
47
|
+
// Ensure that the canvas is at least 1 pixel high as blob generation will fail otherwise.
|
|
46
48
|
var canvas = document.createElement('canvas');
|
|
47
49
|
canvas.width = PREVIEW_WIDTH;
|
|
48
|
-
canvas.height = PREVIEW_WIDTH / imageAspect;
|
|
50
|
+
canvas.height = Math.max(PREVIEW_WIDTH / imageAspect, 1);
|
|
49
51
|
var ctx = canvas.getContext('2d');
|
|
50
52
|
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(img, 0, 0, PREVIEW_WIDTH, PREVIEW_WIDTH / imageAspect);
|
|
51
53
|
canvas.toBlob(resolve, 'image/jpeg');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePreviewBlobUrl.js","sourceRoot":"","sources":["../../src/utils/generatePreviewBlobUrl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyC;AACzC,4CAAuC;AAEvC,IAAM,aAAa,GAAG,GAAG,CAAA,CAAC,KAAK;AAE/B,IAAM,UAAU,GAAG,UAAC,GAAqB;IACvC,OAAO,IAAI,OAAO,CAAC,UAAA,OAAO;QACxB,IAAM,WAAW,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAA;QAE1C,IAAM,MAAM,GAAsB,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAClE,MAAM,CAAC,KAAK,GAAG,aAAa,CAAA;QAC5B,MAAM,CAAC,MAAM,GAAG,aAAa,GAAG,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"generatePreviewBlobUrl.js","sourceRoot":"","sources":["../../src/utils/generatePreviewBlobUrl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyC;AACzC,4CAAuC;AAEvC,IAAM,aAAa,GAAG,GAAG,CAAA,CAAC,KAAK;AAE/B,IAAM,UAAU,GAAG,UAAC,GAAqB;IACvC,OAAO,IAAI,OAAO,CAAC,UAAA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yB;gBAEtC,sBAAO,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,EAAA;;;KACxC,CAAA;AAEM,IAAM,uBAAuB,GAAG,UAAC,IAAU;IAChD,OAAO,SAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAQ,CAAC,cAAM,OAAA,WAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC,CAAA;AAC1E,CAAC,CAAA;AAFY,QAAA,uBAAuB,2BAEnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-media",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Robin Pyon",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@hookform/resolvers": "2.0.0-beta.3",
|
|
40
|
-
"@reduxjs/toolkit": "1.5.
|
|
40
|
+
"@reduxjs/toolkit": "1.5.1",
|
|
41
41
|
"@sanity/color": "2.1.5",
|
|
42
42
|
"@sanity/icons": "1.1.7",
|
|
43
43
|
"@sanity/types": "^2.17.1",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
22
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
23
|
-
if (!m) return o;
|
|
24
|
-
var i = m.call(o), r, ar = [], e;
|
|
25
|
-
try {
|
|
26
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
-
}
|
|
28
|
-
catch (error) { e = { error: error }; }
|
|
29
|
-
finally {
|
|
30
|
-
try {
|
|
31
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
32
|
-
}
|
|
33
|
-
finally { if (e) throw e.error; }
|
|
34
|
-
}
|
|
35
|
-
return ar;
|
|
36
|
-
};
|
|
37
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
var icons_1 = require("@sanity/icons");
|
|
42
|
-
var ui_1 = require("@sanity/ui");
|
|
43
|
-
var copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
|
|
44
|
-
var react_1 = __importStar(require("react"));
|
|
45
|
-
var ButtonClipboardCopy = function (props) {
|
|
46
|
-
var disabled = props.disabled;
|
|
47
|
-
var _a = __read(react_1.useState(false), 2), popoverVisible = _a[0], setPopoverVisible = _a[1];
|
|
48
|
-
var refPopoverTimeout = react_1.useRef();
|
|
49
|
-
// Callbacks
|
|
50
|
-
var handleClick = function () {
|
|
51
|
-
if (refPopoverTimeout.current) {
|
|
52
|
-
clearTimeout(refPopoverTimeout.current);
|
|
53
|
-
}
|
|
54
|
-
setPopoverVisible(true);
|
|
55
|
-
copy_to_clipboard_1.default(asset.url);
|
|
56
|
-
refPopoverTimeout.current = setTimeout(function () {
|
|
57
|
-
setPopoverVisible(false);
|
|
58
|
-
}, 2000);
|
|
59
|
-
};
|
|
60
|
-
// Effects
|
|
61
|
-
react_1.useEffect(function () {
|
|
62
|
-
return function () {
|
|
63
|
-
if (refPopoverTimeout.current) {
|
|
64
|
-
clearTimeout(refPopoverTimeout.current);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
return (react_1.default.createElement(ui_1.Popover, { content: react_1.default.createElement(ui_1.Text, { muted: true, size: 1 }, "Copied!"), open: popoverVisible, padding: 2, placement: "top", radius: 1 },
|
|
69
|
-
react_1.default.createElement(ui_1.Button, { disabled: disabled, fontSize: 1, icon: icons_1.ClipboardIcon, mode: "ghost", onClick: handleClick, text: "Copy" })));
|
|
70
|
-
};
|
|
71
|
-
exports.default = ButtonClipboardCopy;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
22
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
23
|
-
if (!m) return o;
|
|
24
|
-
var i = m.call(o), r, ar = [], e;
|
|
25
|
-
try {
|
|
26
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
-
}
|
|
28
|
-
catch (error) { e = { error: error }; }
|
|
29
|
-
finally {
|
|
30
|
-
try {
|
|
31
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
32
|
-
}
|
|
33
|
-
finally { if (e) throw e.error; }
|
|
34
|
-
}
|
|
35
|
-
return ar;
|
|
36
|
-
};
|
|
37
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
var icons_1 = require("@sanity/icons");
|
|
42
|
-
var ui_1 = require("@sanity/ui");
|
|
43
|
-
var copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
|
|
44
|
-
var react_1 = __importStar(require("react"));
|
|
45
|
-
var ButtonClipboardCopy = function (props) {
|
|
46
|
-
var disabled = props.disabled;
|
|
47
|
-
var _a = __read(react_1.useState(false), 2), popoverVisible = _a[0], setPopoverVisible = _a[1];
|
|
48
|
-
var refPopoverTimeout = react_1.useRef();
|
|
49
|
-
// Callbacks
|
|
50
|
-
var handleClick = function () {
|
|
51
|
-
if (refPopoverTimeout.current) {
|
|
52
|
-
clearTimeout(refPopoverTimeout.current);
|
|
53
|
-
}
|
|
54
|
-
setPopoverVisible(true);
|
|
55
|
-
copy_to_clipboard_1.default(asset.url);
|
|
56
|
-
refPopoverTimeout.current = setTimeout(function () {
|
|
57
|
-
setPopoverVisible(false);
|
|
58
|
-
}, 2000);
|
|
59
|
-
};
|
|
60
|
-
// Effects
|
|
61
|
-
react_1.useEffect(function () {
|
|
62
|
-
return function () {
|
|
63
|
-
if (refPopoverTimeout.current) {
|
|
64
|
-
clearTimeout(refPopoverTimeout.current);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
return (react_1.default.createElement(ui_1.Popover, { content: react_1.default.createElement(ui_1.Text, { muted: true, size: 1 }, "Copied!"), open: popoverVisible, padding: 2, placement: "top", radius: 1 },
|
|
69
|
-
react_1.default.createElement(ui_1.Button, { disabled: disabled, fontSize: 1, icon: icons_1.ClipboardIcon, mode: "ghost", onClick: handleClick, text: "Copy" })));
|
|
70
|
-
};
|
|
71
|
-
exports.default = ButtonClipboardCopy;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
22
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
23
|
-
if (!m) return o;
|
|
24
|
-
var i = m.call(o), r, ar = [], e;
|
|
25
|
-
try {
|
|
26
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
-
}
|
|
28
|
-
catch (error) { e = { error: error }; }
|
|
29
|
-
finally {
|
|
30
|
-
try {
|
|
31
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
32
|
-
}
|
|
33
|
-
finally { if (e) throw e.error; }
|
|
34
|
-
}
|
|
35
|
-
return ar;
|
|
36
|
-
};
|
|
37
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
var icons_1 = require("@sanity/icons");
|
|
42
|
-
var ui_1 = require("@sanity/ui");
|
|
43
|
-
var copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
|
|
44
|
-
var react_1 = __importStar(require("react"));
|
|
45
|
-
var ButtonClipboardCopy = function (props) {
|
|
46
|
-
var disabled = props.disabled;
|
|
47
|
-
var _a = __read(react_1.useState(false), 2), popoverVisible = _a[0], setPopoverVisible = _a[1];
|
|
48
|
-
var refPopoverTimeout = react_1.useRef();
|
|
49
|
-
// Callbacks
|
|
50
|
-
var handleClick = function () {
|
|
51
|
-
if (refPopoverTimeout.current) {
|
|
52
|
-
clearTimeout(refPopoverTimeout.current);
|
|
53
|
-
}
|
|
54
|
-
setPopoverVisible(true);
|
|
55
|
-
copy_to_clipboard_1.default(asset.url);
|
|
56
|
-
refPopoverTimeout.current = setTimeout(function () {
|
|
57
|
-
setPopoverVisible(false);
|
|
58
|
-
}, 2000);
|
|
59
|
-
};
|
|
60
|
-
// Effects
|
|
61
|
-
react_1.useEffect(function () {
|
|
62
|
-
return function () {
|
|
63
|
-
if (refPopoverTimeout.current) {
|
|
64
|
-
clearTimeout(refPopoverTimeout.current);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
return (react_1.default.createElement(ui_1.Popover, { content: react_1.default.createElement(ui_1.Text, { muted: true, size: 1 }, "Copied!"), open: popoverVisible, padding: 2, placement: "top", radius: 1 },
|
|
69
|
-
react_1.default.createElement(ui_1.Button, { disabled: disabled, fontSize: 1, icon: icons_1.ClipboardIcon, mode: "ghost", onClick: handleClick, text: "Copy" })));
|
|
70
|
-
};
|
|
71
|
-
exports.default = ButtonClipboardCopy;
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var color_1 = require("@sanity/color");
|
|
41
|
-
var icons_1 = require("@sanity/icons");
|
|
42
|
-
var ui_1 = require("@sanity/ui");
|
|
43
|
-
var react_1 = __importStar(require("react"));
|
|
44
|
-
var react_redux_1 = require("react-redux");
|
|
45
|
-
var styled_components_1 = __importStar(require("styled-components"));
|
|
46
|
-
var FileIcon_1 = __importDefault(require("../../components/FileIcon"));
|
|
47
|
-
var AssetSourceDispatchContext_1 = require("../../contexts/AssetSourceDispatchContext");
|
|
48
|
-
var useKeyPress_1 = __importDefault(require("../../hooks/useKeyPress"));
|
|
49
|
-
var useTypedSelector_1 = __importDefault(require("../../hooks/useTypedSelector"));
|
|
50
|
-
var assets_1 = require("../../modules/assets");
|
|
51
|
-
var dialog_1 = require("../../modules/dialog");
|
|
52
|
-
var imageDprUrl_1 = __importDefault(require("../../utils/imageDprUrl"));
|
|
53
|
-
var typeGuards_1 = require("../../utils/typeGuards");
|
|
54
|
-
var Image_1 = __importDefault(require("../Image"));
|
|
55
|
-
var CardContainer = styled_components_1.default(ui_1.Flex)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n /* background: ", "; */\n border: 1px solid transparent;\n overflow: hidden;\n pointer-events: ", ";\n position: relative;\n transition: all 300ms;\n user-select: none;\n\n border: ", ";\n\n ", "\n"], ["\n /* background: ", "; */\n border: 1px solid transparent;\n overflow: hidden;\n pointer-events: ", ";\n position: relative;\n transition: all 300ms;\n user-select: none;\n\n border: ",
|
|
56
|
-
";\n\n ",
|
|
57
|
-
"\n"])), color_1.hues.gray[950].hex, function (props) { return (props.updating ? 'none' : 'auto'); }, function (props) {
|
|
58
|
-
return props.picked
|
|
59
|
-
? "1px solid " + props.theme.sanity.color.spot.orange + " !important"
|
|
60
|
-
: '1px solid inherit';
|
|
61
|
-
}, function (props) {
|
|
62
|
-
return !props.updating && styled_components_1.css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n border: 1px solid ", ";\n }\n }\n "], ["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n border: 1px solid ", ";\n }\n }\n "])), color_1.hues.gray[500].hex);
|
|
63
|
-
});
|
|
64
|
-
var ContextActionContainer = styled_components_1.default(ui_1.Box)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n cursor: ", ";\n transition: all 300ms;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ", ";\n }\n }\n"], ["\n cursor: ", ";\n transition: all 300ms;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ", ";\n }\n }\n"])), function (props) { return (props.selected ? 'default' : 'pointer'); }, color_1.hues.gray[950].hex);
|
|
65
|
-
var StyledWarningOutlineIcon = styled_components_1.default(icons_1.WarningOutlineIcon)(function (_a) {
|
|
66
|
-
var theme = _a.theme;
|
|
67
|
-
return {
|
|
68
|
-
color: theme.sanity.color.spot.red
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
var Card = function (props) {
|
|
72
|
-
var _a, _b;
|
|
73
|
-
var item = props.item, selected = props.selected, style = props.style;
|
|
74
|
-
// Refs
|
|
75
|
-
var shiftPressed = useKeyPress_1.default('shift');
|
|
76
|
-
// Redux
|
|
77
|
-
var dispatch = react_redux_1.useDispatch();
|
|
78
|
-
var lastPicked = useTypedSelector_1.default(function (state) { return state.assets.lastPicked; });
|
|
79
|
-
var asset = item === null || item === void 0 ? void 0 : item.asset;
|
|
80
|
-
var error = item === null || item === void 0 ? void 0 : item.error;
|
|
81
|
-
var isOpaque = (_b = (_a = item === null || item === void 0 ? void 0 : item.asset) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.isOpaque;
|
|
82
|
-
var picked = item === null || item === void 0 ? void 0 : item.picked;
|
|
83
|
-
var updating = item === null || item === void 0 ? void 0 : item.updating;
|
|
84
|
-
var onSelect = AssetSourceDispatchContext_1.useAssetSourceActions().onSelect;
|
|
85
|
-
// Short circuit if no asset is available
|
|
86
|
-
if (!asset) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
// Callbacks
|
|
90
|
-
var handleAssetClick = function (e) {
|
|
91
|
-
e.stopPropagation();
|
|
92
|
-
if (onSelect) {
|
|
93
|
-
onSelect([
|
|
94
|
-
{
|
|
95
|
-
kind: 'assetDocumentId',
|
|
96
|
-
value: asset._id
|
|
97
|
-
}
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
if (shiftPressed.current) {
|
|
102
|
-
if (picked) {
|
|
103
|
-
dispatch(assets_1.assetsActions.pick({ assetId: asset._id, picked: !picked }));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
dispatch(assets_1.assetsActions.pickRange({ startId: lastPicked || asset._id, endId: asset._id }));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
dispatch(dialog_1.dialogActions.showAssetEdit({ assetId: asset._id }));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
var handleContextActionClick = function (e) {
|
|
115
|
-
e.stopPropagation();
|
|
116
|
-
if (onSelect) {
|
|
117
|
-
dispatch(dialog_1.dialogActions.showAssetEdit({ assetId: asset._id }));
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
if (shiftPressed.current && !picked) {
|
|
121
|
-
dispatch(assets_1.assetsActions.pickRange({ startId: lastPicked || asset._id, endId: asset._id }));
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
dispatch(assets_1.assetsActions.pick({ assetId: asset._id, picked: !picked }));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
var opacityContainer = updating ? 0.5 : 1;
|
|
129
|
-
var opacityPreview = selected || updating ? 0.25 : 1;
|
|
130
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
131
|
-
react_1.default.createElement(CardContainer, { direction: "column", picked: picked, style: __assign({}, style), updating: item.updating },
|
|
132
|
-
react_1.default.createElement(ui_1.Box, { flex: 1, style: {
|
|
133
|
-
cursor: selected ? 'default' : 'pointer',
|
|
134
|
-
position: 'relative'
|
|
135
|
-
} },
|
|
136
|
-
react_1.default.createElement("div", { onClick: handleAssetClick, style: { height: '100%', opacity: opacityPreview } },
|
|
137
|
-
typeGuards_1.isFileAsset(asset) && react_1.default.createElement(FileIcon_1.default, { asset: asset, width: "80px" }),
|
|
138
|
-
typeGuards_1.isImageAsset(asset) && (react_1.default.createElement(Image_1.default, { showCheckerboard: !isOpaque, src: imageDprUrl_1.default(asset, { height: 250, width: 250 }), style: {
|
|
139
|
-
draggable: false,
|
|
140
|
-
transition: 'opacity 1000ms'
|
|
141
|
-
} }))),
|
|
142
|
-
selected && !updating && (react_1.default.createElement(ui_1.Flex, { align: "center", justify: "center", style: {
|
|
143
|
-
height: '100%',
|
|
144
|
-
left: 0,
|
|
145
|
-
opacity: opacityContainer,
|
|
146
|
-
position: 'absolute',
|
|
147
|
-
top: 0,
|
|
148
|
-
width: '100%'
|
|
149
|
-
} },
|
|
150
|
-
react_1.default.createElement(ui_1.Text, { size: 2 },
|
|
151
|
-
react_1.default.createElement(icons_1.CheckmarkCircleIcon, null)))),
|
|
152
|
-
updating && (react_1.default.createElement(ui_1.Flex, { align: "center", justify: "center", style: {
|
|
153
|
-
height: '100%',
|
|
154
|
-
left: 0,
|
|
155
|
-
position: 'absolute',
|
|
156
|
-
top: 0,
|
|
157
|
-
width: '100%'
|
|
158
|
-
} },
|
|
159
|
-
react_1.default.createElement(ui_1.Spinner, null)))),
|
|
160
|
-
react_1.default.createElement(ContextActionContainer, { onClick: handleContextActionClick, paddingX: 1, paddingY: 2, style: {
|
|
161
|
-
opacity: opacityContainer
|
|
162
|
-
} },
|
|
163
|
-
react_1.default.createElement(ui_1.Flex, { align: "center" },
|
|
164
|
-
onSelect ? (react_1.default.createElement(icons_1.EditIcon, { style: {
|
|
165
|
-
flexShrink: 0,
|
|
166
|
-
opacity: 0.5
|
|
167
|
-
} })) : (react_1.default.createElement(ui_1.Checkbox, { checked: picked, readOnly: true, style: {
|
|
168
|
-
flexShrink: 0,
|
|
169
|
-
pointerEvents: 'none',
|
|
170
|
-
transform: 'scale(0.8)'
|
|
171
|
-
} })),
|
|
172
|
-
react_1.default.createElement(ui_1.Box, { marginLeft: 2 },
|
|
173
|
-
react_1.default.createElement(ui_1.Text, { muted: true, size: 0, textOverflow: "ellipsis" }, asset.originalFilename)))),
|
|
174
|
-
error && (react_1.default.createElement(ui_1.Box, { padding: 3, style: {
|
|
175
|
-
position: 'absolute',
|
|
176
|
-
right: 0,
|
|
177
|
-
top: 0
|
|
178
|
-
} },
|
|
179
|
-
react_1.default.createElement(ui_1.Tooltip, { content: react_1.default.createElement(ui_1.Container, { padding: 2, width: 0 },
|
|
180
|
-
react_1.default.createElement(ui_1.Text, { size: 1 }, error.message)), placement: "left", portal: true },
|
|
181
|
-
react_1.default.createElement(ui_1.Text, { size: 1 },
|
|
182
|
-
react_1.default.createElement(StyledWarningOutlineIcon, { color: "critical" }))))))));
|
|
183
|
-
};
|
|
184
|
-
exports.default = react_1.memo(Card);
|
|
185
|
-
var templateObject_1, templateObject_2, templateObject_3;
|